Agriculture-front-end/public/Cesium/index.cjs

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 Rxe=Object.create;var c3=Object.defineProperty;var Bxe=Object.getOwnPropertyDescriptor;var Lxe=Object.getOwnPropertyNames;var Nxe=Object.getPrototypeOf,Fxe=Object.prototype.hasOwnProperty;var Uxe=(e,t)=>()=>(e&&(t=e(e=0)),t);var Xn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ZK=(e,t)=>{for(var n in t)c3(e,n,{get:t[n],enumerable:!0})},QK=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Lxe(t))!Fxe.call(e,r)&&r!==n&&c3(e,r,{get:()=>t[r],enumerable:!(i=Bxe(t,r))||i.enumerable});return e};var Wi=(e,t,n)=>(n=e!=null?Rxe(Nxe(e)):{},QK(t||!e||!e.__esModule?c3(n,"default",{value:e,enumerable:!0}):n,e)),Dh=e=>QK(c3({},"__esModule",{value:!0}),e);var l3=Xn((Uxt,eJ)=>{var Ym=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)};Ym.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}};Ym.prototype.init_by_array=function(e,t){var n,i,r;for(this.init_seed(19650218),n=1,i=0,r=this.N>t?this.N:t;r;r--){var o=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((o&4294901760)>>>16)*1664525<<16)+(o&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(r=this.N-1;r;r--){var o=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((o&4294901760)>>>16)*1566083941<<16)+(o&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};Ym.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};Ym.prototype.random_int31=function(){return this.random_int()>>>1};Ym.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};Ym.prototype.random=function(){return this.random_int()*(1/4294967296)};Ym.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};Ym.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};eJ.exports=Ym});var LJ=Xn((rT,oT)=>{/*! https://mths.be/punycode v1.4.0 by @mathias */(function(e){var t=typeof rT=="object"&&rT&&!rT.nodeType&&rT,n=typeof oT=="object"&&oT&&!oT.nodeType&&oT,i=typeof global=="object"&&global;(i.global===i||i.window===i||i.self===i)&&(e=i);var r,o=2147483647,s=36,a=1,c=26,l=38,f=700,d=72,p=128,g="-",m=/^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"},E=s-a,T=Math.floor,S=String.fromCharCode,v;function D(V){throw new RangeError(C[V])}function M(V,G){for(var U=V.length,Y=[];U--;)Y[U]=G(V[U]);return Y}function O(V,G){var U=V.split("@"),Y="";U.length>1&&(Y=U[0]+"@",V=U[1]),V=V.replace(x,".");var j=V.split("."),Q=M(j,G).join(".");return Y+Q}function B(V){for(var G=[],U=0,Y=V.length,j,Q;U<Y;)j=V.charCodeAt(U++),j>=55296&&j<=56319&&U<Y?(Q=V.charCodeAt(U++),(Q&64512)==56320?G.push(((j&1023)<<10)+(Q&1023)+65536):(G.push(j),U--)):G.push(j);return G}function L(V){return M(V,function(G){var U="";return G>65535&&(G-=65536,U+=S(G>>>10&1023|55296),G=56320|G&1023),U+=S(G),U}).join("")}function _(V){return V-48<10?V-22:V-65<26?V-65:V-97<26?V-97:s}function b(V,G){return V+22+7
* 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 P3=="object"&&P3.exports?P3.exports=t():typeof define=="function"&&define.amd?define(t):e.IPv6=t(e)})(NJ,function(e){"use strict";var t=e&&e.IPv6;function n(r){var o=r.toLowerCase(),s=o.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,m=0,A=0,x=-1,C=!1;for(d=0;d<c;d++)C?s[d]==="0"?A+=1:(C=!1,A>m&&(g=x,m=A)):s[d]==="0"&&(C=!0,x=d,A=1);A>m&&(g=x,m=A),m>1&&s.splice(g,m,""),a=s.length;var E="";for(s[0]===""&&(E=":"),d=0;d<a&&(E+=s[d],d!==a-1);d++)E+=":";return s[a-1]===""&&(E+=":"),E}function i(){return e.IPv6===this&&(e.IPv6=t),this}return{best:n,noConflict:i}})});var VJ=Xn((UJ,O3)=>{/*!
* 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 O3=="object"&&O3.exports?O3.exports=t():typeof define=="function"&&define.amd?define(t):e.SecondLevelDomains=t(e)})(UJ,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 M3=="object"&&M3.exports?M3.exports=t(LJ(),FJ(),VJ()):typeof define=="function"&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):e.URI=t(e.punycode,e.IPv6,e.SecondLevelDomains,e)})(kJ,function(e,t,n,i){"use strict";var r=i&&i.URI;function o(b,w){var I=arguments.length>=1,R=arguments.length>=2;if(!(this instanceof o))return I?R?new o(b,w):new o(b):new o;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),w!==void 0?this.absoluteTo(w):this}function s(b){return/^[0-9]+$/.test(b)}o.version="1.19.11";var a=o.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,w){var I={},R,F;if(f(w)==="RegExp")I=null;else if(d(w))for(R=0,F=w.length;R<F;R++)I[w[R]]=!0;else I[w]=!0;for(R=0,F=b.length;R<F;R++){var k=I&&I[b[R]]!==void 0||!I&&w.test(b[R]);k&&(b.splice(R,1),F--,R--)}return b}function g(b,w){var I,R;if(d(w)){for(I=0,R=w.length;I<R;I++)if(!g(b,w[I]))return!1;return!0}var F=f(w);for(I=0,R=b.length;I<R;I++)if(F==="RegExp"){if(typeof b[I]=="string"&&b[I].match(w))return!0}else if(b[I]===w)return!0;return!1}function m(b,w){if(!d(b)||!d(w)||b.length!==w.length)return!1;b.sort(),w.sort();for(var I=0,R=b.length;I<R;I++)if(b[I]!==w[I])return!1;return!0}function A(b){var w=/^\/+|\/+$/g;return b.replace(w,"")}o._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:o.preventInvalidHostname,duplicateQueryParameters:o.duplicateQueryParameters,escapeQuerySpace:o.escapeQuerySpace}},o.preventInvalidHostname=!1,o.duplicateQueryParameters=!1,o.escapeQuerySpace=!0,o.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,o.idn_expression=/[^a-z0-9\._-]/i,o.punycode_expression=/(xn--)/i,o.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,o.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*$/,o.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,o.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},o.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,o.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,o.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},o.hostProtocols=["http","https"],o.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,o.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 XPe=Object.hasOwnProperty,jee=Object.setPrototypeOf,KPe=Object.isFrozen,JPe=Object.getPrototypeOf,ZPe=Object.getOwnPropertyDescriptor,Bc=Object.freeze,yd=Object.seal,QPe=Object.create,Zee=typeof Reflect<"u"&&Reflect,AU=Zee.apply,h5=Zee.construct;AU||(AU=function(t,n,i){return t.apply(n,i)});Bc||(Bc=function(t){return t});yd||(yd=function(t){return t});h5||(h5=function(t,n){return gU(t,gd(n))});var $Pe=tf(Array.prototype.forEach),qee=tf(Array.prototype.pop),xP=tf(Array.prototype.push),yU=tf(String.prototype.toLowerCase),o5=tf(String.prototype.toString),e1e=tf(String.prototype.match),_d=tf(String.prototype.replace),t1e=tf(String.prototype.indexOf),n1e=tf(String.prototype.trim),Rc=tf(RegExp.prototype.test),s5=i1e(TypeError);function tf(e){return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),r=1;r<n;r++)i[r-1]=arguments[r];return AU(e,t,i)}}function i1e(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return h5(e,n)}}function hi(e,t,n){n=n||yU,jee&&jee(e,null);for(var i=t.length;i--;){var r=t[i];if(typeof r=="string"){var o=n(r);o!==r&&(KPe(t)||(t[i]=o),r=o)}e[r]=!0}return e}function fA(e){var t=QPe(null),n;for(n in e)AU(XPe,e,[n])===!0&&(t[n]=e[n]);return t}function pU(e,t){for(;e!==null;){var n=ZPe(e,t);if(n){if(n.get)return tf(n.get);if(typeof n.value=="function")return tf(n.value)}e=JPe(e)}function i(r){return console.warn("fallback value for",r),null}return i}var Yee=Bc(["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"]),a5=Bc(["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"]),c5=Bc(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),r1e=Bc(["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"]),l5=Bc(["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"]),o1e=Bc(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Xee=Bc(["#text"]),Kee=Bc(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspac
`+ks),Ie&&(ks=_d(ks,I," "),ks=_d(ks,R," "),ks=_d(ks,F," ")),S&&ut?S.createHTML(ks):ks},t.setConfig=function(mn){Fi(mn),Ye=!0},t.clearConfig=function(){Co=null,Ye=!1},t.isValidAttribute=function(mn,ve,yt){Co||Fi({});var jt=Zn(mn),hr=Zn(ve);return wh(jt,hr,yt)},t.addHook=function(mn,ve){typeof ve=="function"&&(w[mn]=w[mn]||[],xP(w[mn],ve))},t.removeHook=function(mn){if(w[mn])return qee(w[mn])},t.removeHooks=function(mn){w[mn]&&(w[mn]=[])},t.removeAllHooks=function(){w={}},t}var g1e=Qee();$ee.exports=g1e});var qte=Xn((BP,R5)=>{var BU=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+TJJJB8aALCuFGR9CU83IBALC8wFGW9CU83IBALCYFGd9CU83IBALCAFGQ9CU83IBALCkFGK9CU83IBALCZFGX9CU83IBAL9CU83IWAL9CU83IBABAEFC9wFHMABCEFGpAOFHEDNAItMBCMCSAVCB9KGSeHZAVCE9IHhCBHoCBHaCBHcCBHxCBHqINDNAEAM9NMBCBHVXIKAqCUFHVADAcCDTFGOYDBHlAOCWFYDBHkAOCLFYDBHyCBH8aDNDNINALC/ABFAVCSgCITFGOYDLHeDNDNDNAOYDBGOAl9HMBAeAysMEKDNAOAy9HMBAeAk9HMBA8aCEFH8aXEKAOAk9HMEAeAl9HMEA8aCDFH8aKA8aC870MDAxCUFHVADA8aCIgCX2GOC+Y1JJBFYDBAcFCDTFYDBHeADAOCn1JJBFYDBAcFCDTFYDBHkADAOC+Q1JJBFYDBAcFCDTFYDBHlCBHODNINDNALAVCSgCDTFYDBAe9HMBAOHyXDKCUHyAVCUFHVAOCEFGOCZ9HMBKKAyCB9KAyAZ9IgGVCU7AeAosGOgH3DNDNDNDNDNAyCBCSAOeAVeGVCS9HMBAhMBAeAeAaAeCEFAasGVeGaCEFsMECMCSAVeHVKApAVA8aCDTC/wEgv86BBAVCS9HMEAeAa9rGVCETAVC8f917HVINAEAVCfB0CRTAVCfBgv86BBAECEFHEAVCJE6HOAVCR4HVAOtMBKAeHaXDKCpHVApA8aCDTCpv86BBAeHaKAVtMBAVAZ9IMEKALAxCDTFAebDBAxCEFCSgHxKAoA3FHoALC/ABFAqCITFGVAkbDLAVAebDBALC/ABFAqCEFCSgGVCITFGOAebDLAOAlbDBAVCEFHOXIKAVCUFHVA
* 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 r(s){var a=n[s];return a||t[s][0].call(a=n[s]={exports:{}},r,a,a.exports),a.exports}var o=r(i[0]);o.util.global.protobuf=o,typeof define=="function"&&define.amd&&define(["long"],function(s){return s&&s.isLong&&(o.util.Long=s,o.configure()),o}),typeof module=="object"&&module&&module.exports&&(module.exports=o)})({1:[function(e,t,n){"use strict";t.exports=i;function i(r,o){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(m){if(l)if(l=!1,m)p(m);else{for(var A=new Array(arguments.length-1),x=0;x<A.length;)A[x++]=arguments[x];d.apply(null,A)}};try{r.apply(o||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 r=new Array(64),o=new Array(123),s=0;s<64;)o[r[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=[],m=0,A=0,x;f<d;){var C=l[f++];switch(A){case 0:g[m++]=r[C>>2],x=(C&3)<<4,A=1;break;case 1:g[m++]=r[x|C>>4],x=(C&15)<<2,A=2;break;case 2:g[m++]=r[x|C>>6],g[m++]=r[C&63],A=0;break}m>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,g)),m=0)}return A&&(g[m++]=r[x],g[m++]=61,A===1&&(g[m++]=61)),p?(m&&p.push(String.fromCharCode.apply(String,g.slice(0,m))),p.join("")):String.fromCharCode.apply(String,g.slice(0,m))};var a="invalid encoding";i.decode=function(l,f,d){for(var p=d,g=0,m,A=0;A<l.length;){var x=l.charCodeAt(A++);if(x===61&&g>1)break;if((x=o[x])===undefined)throw Error(a);switch(g){case 0:m=x,g=1;break;case 1:f[d++]=m<<2|(x&48)>>4,m=x,g=2;break;case 2:f[d++]=(m&15)<<4|(x&60)>>2,m=x,g=3;break;case 3:f[d++]=(m&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(o,s,a){return(this._listeners[o]||(this._listeners[o]=[])).push({fn:s,ctx:a||this}),this},i.prototype.off=function(o,s){if(o===undefined)this._listeners={};else if(s===undefined)this._listeners[o]=[];else for(var a=this._listeners[o],c=0;c<a.length;)a[c].fn===s?a.splice(c,1):++c;return this},i.prototype.emit=function(o){var s=this._listeners[o];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,E){l[0]=x,C[E]=f[0],C[E+1]=f[1],C[E+2]=f[2],C[E+3]=f[3]}function g(x,C,E){l[0]=x,C[E]=f[3],C[E+1]=f[2],C[E+2]=f[1],C[E+3]=f[0]}c.writeFloatLE=d?p:g,c.writeFloatBE=d?g:p;function m(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?m:A,c.readFloatBE=d?A:m}():function(){function l(d,p,g,m){var A=p<0?1:0;if(A&&(p=-p),p===0)d(1/p>0?0:2147483648,g,m);else if(isNaN(p))d(2143289344,g,m);else if(p>34028234663852886e22)d((A<<31|2139095040)>>>0,g,m);else if(p<11754943508222875e-54)d((A<<31|Math.round(p/1401298464324817e-60))>>>0,g,m);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,m)}}c.writeFloatLE=l.bind(null,r),c.writeFloatBE=l.bind(null,o);function f(d,p,g){var m=d(p,g),A=(m>>31)*2+1,x=m>>>23&255,C=m&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,E){l[0]=x,C[E]=f[0],C[E+1]=f[1],C[E+2]=f[2],C[E+3]=f[3],C[E+4]=f[4],C[E+5]=f[5],C[E+6]=f[6],C[E+7]=f[7]}function g(x,C,E){l[0]=x,C[E]=f[7],C[E+1]=f[6],C[E+2]=f[5],C[E+3]=f[4],C[E+4]=f[3],C[E+5]=f[2],C[E+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(function(){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(function(p){return d.enabled=!0,p}).catch(function(p){throw d.enabled=!1,p})}},{key:"disable",value:function(){c()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):a()?this.noSleepTimer&&(console.warn(`
NoSleep now disabled for older iOS devices.
`),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}},{key:"isEnabled",get:function(){return this.enabled}}]),f}();e.exports=l},function(e,t,n){"use strict";e.exports={webm:"data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEHFO7a1OsghV17AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmAQAAAAAAAEUq17GDD0JATYCNTGF2ZjU1LjMzLjEwMFdBjUxhdmY1NS4zMy4xMDBzpJBlrrXf3DCDVB8KcgbMpcr+RImIQJBgAAAAAAAWVK5rAQAAAAAAD++uAQAAAAAAADLXgQFzxYEBnIEAIrWcg3VuZIaFVl9WUDiDgQEj44OEAmJaAOABAAAAAAAABrCBsLqBkK4BAAAAAAAPq9eBAnPFgQKcgQAitZyDdW5khohBX1ZPUkJJU4OBAuEBAAAAAAAAEZ+BArWIQOdwAAAAAABiZIEgY6JPbwIeVgF2b3JiaXMAAAAAAoC7AAAAAAAAgLUBAAAAAAC4AQN2b3JiaXMtAAAAWGlwaC5PcmcgbGliVm9yYmlzIEkgMjAxMDExMDEgKFNjaGF1ZmVudWdnZXQpAQAAABUAAABlbmNvZGVyPUxhdmM1NS41Mi4xMDIBBXZvcmJpcyVCQ1YBAEAAACRzGCpGpXMWhBAaQlAZ4xxCzmvsGUJMEYIcMkxbyyVzkCGkoEKIWyiB0JBVAABAAACHQXgUhIpBCCGEJT1YkoMnPQghhIg5eBSEaUEIIYQQQgghhBBCCCGERTlokoMnQQgdhOMwOAyD5Tj4HIRFOVgQgydB6CCED0K4moOsOQghhCQ1SFCDBjnoHITCLCiKgsQwuBaEBDUojILkMMjUgwtCiJqDSTX4GoRnQXgWhGlBCCGEJEFIkIMGQcgYhEZBWJKDBjm4FITLQagahCo5CB+EIDRkFQCQAACgoiiKoigKEBqyCgDIAAAQQFEUx3EcyZEcybEcCwgNWQUAAAEACAAAoEiKpEiO5EiSJFmSJVmSJVmS5omqLMuyLMuyLMsyEBqyCgBIAABQUQxFcRQHCA1ZBQBkAAAIoDiKpViKpWiK54iOCISGrAIAgAAABAAAEDRDUzxHlETPVFXXtm3btm3btm3btm3btm1blmUZCA1ZBQBAAAAQ0mlmqQaIMAMZBkJDVgEACAAAgBGKMMSA0JBVAABAAACAGEoOogmtOd+c46BZDppKsTkdnEi1eZKbirk555xzzsnmnDHOOeecopxZDJoJrTnnnMSgWQqaCa0555wnsXnQmiqtOeeccc7pYJwRxjnnnCateZCajbU555wFrWmOmkuxOeecSLl5UptLtTnnnHPOOeecc84555zqxekcnBPOOeecqL25lpvQxTnnnE/G6d6cEM4555xzzjnnnHPOOeecIDRkFQAABABAEIaNYdwpCNLnaCBGEWIaMulB9+gwCRqDnELq0ehopJQ6CCWVcVJKJwgNWQUAAAIAQAghhRRSSCGFFFJIIYUUYoghhhhyyimnoIJKKqmooowyyyyzzDLLLLPMOuyssw47DDHEEEMrrcRSU2011lhr7jnnmoO0VlprrbVSSimllFIKQkNWAQAgAAAEQgYZZJBRSCGFFGKIKaeccgoqqIDQkFUAACAAgAAAAABP8hzRER3RER3RER3RER3R8RzPESVREiVREi3TMjXTU0VVdWXXlnVZt31b2IVd933d933d+HVhWJZlWZZlWZZlWZZlWZZlWZYgNGQVAAACAAAghBBCSCGFFFJIKcYYc8w56CSUEAgNWQUAAAIACAAAAHAUR3EcyZEcSbIkS9IkzdIsT/M0TxM9URRF0zRV0RVdUTdtUTZl0zVdUzZdVVZtV5ZtW7Z125dl2/d93/d93/d93/d93/d9XQdCQ1YBABIAADqSIymSIimS4ziOJElAaMgqAEAGAEAAAIriKI7jOJIkSZIlaZJneZaomZrpmZ4qqkBoyCoAABAAQAAAAAAAAIqmeIqpeIqoeI7oiJJomZaoqZoryqbsuq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq4LhIasAgAkAAB0JEdyJEdSJEVSJEdygNCQVQCADACAAAAcwzEkRXIsy9I0T/M0TxM90RM901NFV3SB0JBVAAAgAIAAAAAAAAAMybAUy9EcTRIl1VItVVMt1VJF1VNVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVN0zRNEwgNWQkAkAEAkBBTLS3GmgmLJGLSaqugYwxS7KWxSCpntbfKMYUYtV4ah5RREHupJGOKQcwtpNApJq3WVEKFFKSYYyoVUg5SIDRkhQAQmgHgcBxAsixAsiwAAAAAAAAAkDQN0DwPsDQPAAAAAAAAACRNAyxPAzTPAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA0jRA8zxA8zwAAAAAAAAA0DwP8DwR8EQRAAAAAAAAACzPAzTRAzxRBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA0jRA8zxA8zwAAAAAAAAAsDwP8EQR0DwRAAAAAAAAACzPAzxRBDzRAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAEOAAABBgIRQasiIAiBMAcEgSJAmSBM0DSJYFTYOmwTQBkmVB06BpME0AAAAAAAAAAAAAJE2DpkHTIIoASdOgadA0iCIAAAAAAAAAAAAAkqZB06BpEEWApGnQNGgaRBEAA
${this.stack.toString()}`),e};C0.throwInstantiationError=function(){throw new C0("This function defines an interface and should not be called directly.")};var fe=C0;var os={};os.typeOf={};function kxe(e){return`${e} is required, actual value was undefined`}function ZC(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(kxe(e))};os.typeOf.func=function(e,t){if(typeof t!="function")throw new fe(ZC(typeof t,"function",e))};os.typeOf.string=function(e,t){if(typeof t!="string")throw new fe(ZC(typeof t,"string",e))};os.typeOf.number=function(e,t){if(typeof t!="number")throw new fe(ZC(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(ZC(typeof t,"object",e))};os.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new fe(ZC(typeof t,"boolean",e))};os.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new fe(ZC(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 ul=os;function av(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}Object.defineProperties(av.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}});av.prototype.addEventListener=function(e,t){this._listeners.push(e),this._scopes.push(t);let n=this;return function(){n.removeEventListener(e,t)}};av.prototype.removeEventListener=function(e,t){let n=this._listeners,i=this._scopes,r=-1;for(let o=0;o<n.length;o++)if(n[o]===e&&i[o]===t){r=o;break}return r!==-1?(this._insideRaiseEvent?(this._toRemove.push(r),n[r]=void 0,i[r]=void 0):(n.splice(r,1),i.splice(r,1)),!0):!1};function zxe(e,t){return t-e}av.prototype.raiseEvent=function(){this._insideRaiseEvent=!0;let e,t=this._listeners,n=this._scopes,i=t.length;for(e=0;e<i;e++){let o=t[e];u(o)&&t[e].apply(n[e],arguments)}let r=this._toRemove;if(i=r.length,i>0){for(r.sort(zxe),e=0;e<i;e++){let o=r[e];t.splice(o,1),n.splice(o,1)}r.length=0}this._insideRaiseEvent=!1};var ge=av;function Q_(e){this._value=void 0,this._hasClone=!1,this._hasEquals=!1,this._definitionChanged=new ge,this.setValue(e)}Object.defineProperties(Q_.prototype,{isConstant:{value:!0},definitionChanged:{get:function(){return this._definitionChanged}}});Q_.prototype.getValue=function(e,t){return this._hasClone?this._value.clone(t):this._value};Q_.prototype.setValue=function(e){let t=this._value;if(t!==e){let n=u(e),i=n&&typeof e.clone=="function",r=n&&typeof e.equals=="function";(!r||!e.equals(t))&&(this._hasClone=i,this._hasEquals=r,this._value=i?e.clone(this._value):e,this._definitionChanged.raiseEvent(this))}};Q_.prototype.equals=function(e){return this===e||e instanceof Q_&&(!this._hasEquals&&this._value===e._value||this._hasEquals&&this._value.equals(e._value))};Q_.prototype.valueOf=function(){return this._value};Q_.prototype.toString=function(){return String(this._value)};var ti=Q_;function Hxe(e,t,n,i,r){return{configurable:i,get:function(){return this[t]},set:function(o){let s=this[t],a=this[n];u(a)&&(a(),this[n]=void 0),o!==void 0&&(!u(o)||!u(o.getValue))&&u(r)&&(o=r(o)),s!==o&&(this[t]=o,this._definitionChanged.raiseEvent(this,e,o,s)),u(o)&&u(o.definitionChanged)&&(this[n]=o.definitionChanged.addEventListener(function(){this._definitionChanged.raiseEvent(this,e,o,o)},this))}}}function Gxe(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,r){return u(r)?(r.x=e,r.y=t,r.z=n,r.w=i,r):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 r=0;r<n;++r)gt.pack(e[r],t,r*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 r=i/4;t[r]=gt.unpack(e,i,t[r])}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 r=P.clamp(e.x,t.x,n.x),o=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=r,i.y=o,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 E3=new gt;gt.distance=function(e,t){return gt.subtract(e,t,E3),gt.magnitude(E3)};gt.distanceSquared=function(e,t){return gt.subtract(e,t,E3),gt.magnitudeSquared(E3)};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 xJ=new gt;gt.lerp=function(e,t,n,i){return gt.multiplyByScalar(t,n,xJ),i=gt.multiplyByScalar(e,1-n,i),gt.add(xJ,i,i)};var lTe=new gt;gt.mostOrthogonalAxis=function(e,t){let n=gt.normalize(e,lTe);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=fv;function $e(e,t,n,i,r,o,s,a,c,l,f,d,p,g,m,A){this[0]=y(e,0),this[1]=y(r,0),this[2]=y(c,0),this[3]=y(p,0),this[4]=y(t,0),this[5]=y(o,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(m,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 r=0;r<n;++r)$e.pack(e[r],t,r*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 r=i/16;t[r]=$e.unpack(e,i,t[r])}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,h.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 r=n.x,o=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,m=t.z*t.z,A=t.z*t.w,x=t.w*t.w,C=a-d-m+x,E=2*(c-A),T=2*(l+g),S=2*(c+A),v=-a+d-m+x,D=2*(p-f),M=2*(l-g),O=2*(p+f),B=-a-d+m+x;return i[0]=C*r,i[1]=S*r,i[2]=M*r,i[3]=0,i[4]=E*o,i[5]=v*o,i[6]=O*o,i[7]=0,i[8]=T*s,i[9]=D*s,i[10]=B*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 eT=new h,tT=new h,dv=new h;$e.fromCamera=function(e,t){let n=e.position,i=e.direction,r=e.up;h.normalize(i,eT),h.normalize(h.cross(eT,r,tT),tT),h.normalize(h.cross(tT,eT,dv),dv);let o=tT.x,s=tT.y,a=tT.z,c=eT.x,l=eT.y,f=eT.z,d=dv.x,p=dv.y,g=dv.z,m=n.x,A=n.y,x=n.z,C=o*-m+s*-A+a*-x,E=d*-m+p*-A+g*-x,T=c*m+l*A+f*x;return u(t)?(t[0]=o,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]=E,t[14]=T,t[15]=1,t):new $e(o,s,a,C,d,p,g,E,-c,-l,-f,T,0,0,0,1)};$e.computePerspectiveFieldOfView=function(e,t,n,i,r){let s=1/Math.tan(e*.5),a=s/t,c=(i+n)/(n-i),l=2*i*n/(n-i);return r[0]=a,r
(${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 N=$e;function hn(e,t){this.center=h.clone(y(e,h.ZERO)),this.radius=y(t,0)}var bG=new h,SG=new h,vG=new h,wG=new h,DG=new h,IG=new h,PG=new h,zs=new h,OG=new h,MG=new h,RG=new h,BG=new h,CTe=4/3*P.PI;hn.fromPoints=function(e,t){if(u(t)||(t=new hn),!u(e)||e.length===0)return t.center=h.clone(h.ZERO,t.center),t.radius=0,t;let n=h.clone(e[0],PG),i=h.clone(n,bG),r=h.clone(n,SG),o=h.clone(n,vG),s=h.clone(n,wG),a=h.clone(n,DG),c=h.clone(n,IG),l=e.length,f;for(f=1;f<l;f++){h.clone(e[f],n);let O=n.x,B=n.y,L=n.z;O<i.x&&h.clone(n,i),O>s.x&&h.clone(n,s),B<r.y&&h.clone(n,r),B>a.y&&h.clone(n,a),L<o.z&&h.clone(n,o),L>c.z&&h.clone(n,c)}let d=h.magnitudeSquared(h.subtract(s,i,zs)),p=h.magnitudeSquared(h.subtract(a,r,zs)),g=h.magnitudeSquared(h.subtract(c,o,zs)),m=i,A=s,x=d;p>x&&(x=p,m=r,A=a),g>x&&(x=g,m=o,A=c);let C=OG;C.x=(m.x+A.x)*.5,C.y=(m.y+A.y)*.5,C.z=(m.z+A.z)*.5;let E=h.magnitudeSquared(h.subtract(A,C,zs)),T=Math.sqrt(E),S=MG;S.x=i.x,S.y=r.y,S.z=o.z;let v=RG;v.x=s.x,v.y=a.y,v.z=c.z;let D=h.midpoint(S,v,BG),M=0;for(f=0;f<l;f++){h.clone(e[f],n);let O=h.magnitude(h.subtract(n,D,zs));O>M&&(M=O);let B=h.magnitudeSquared(h.subtract(n,C,zs));if(B>E){let L=Math.sqrt(B);T=(T+L)*.5,E=T*T;let _=L-T;C.x=(T*C.x+_*n.x)/L,C.y=(T*C.y+_*n.y)/L,C.z=(T*C.z+_*n.z)/L}}return T<M?(h.clone(C,t.center),t.radius=T):(h.clone(D,t.center),t.radius=M),t};var TTe=new Di,ETe=new h,bTe=new h,TG=new me,EG=new me;hn.fromRectangle2D=function(e,t,n){return hn.fromRectangleWithHeights2D(e,t,0,0,n)};hn.fromRectangleWithHeights2D=function(e,t,n,i,r){if(u(r)||(r=new hn),!u(e))return r.center=h.clone(h.ZERO,r.center),r.radius=0,r;t=y(t,TTe),le.southwest(e,TG),TG.height=n,le.northeast(e,EG),EG.height=i;let o=t.project(TG,ETe),s=t.project(EG,bTe),a=s.x-o.x,c=s.y-o.y,l=s.z-o.z;r.radius=Math.sqrt(a*a+c*c+l*l)*.5;let f=r.center;return f.x=o.x+a*.5,f.y=o.y+c*.5,f.z=o.z+l*.5,r};var STe=[];hn.fromRectangle3D=function(e,t,n,i){if(t=y(t,re.WGS84),n=y(n,0),u(i)||(i=new hn),!u(e))return i.center=h.clone(h.ZERO,i.center),i.radius=0,i;let r=le.subsample(e,t,n,STe);return hn.fromPoints(r,i)};hn.fromVertices=function(e,t,n,i){if(u(i)||(i=new hn),!u(e)||e.length===0)return i.center=h.clone(h.ZERO,i.center),i.radius=0,i;t=y(t,h.ZERO),n=y(n,3);let r=PG;r.x=e[0]+t.x,r.y=e[1]+t.y,r.z=e[2]+t.z;let o=h.clone(r,bG),s=h.clone(r,SG),a=h.clone(r,vG),c=h.clone(r,wG),l=h.clone(r,DG),f=h.clone(r,IG),d=e.length,p;for(p=0;p<d;p+=n){let L=e[p]+t.x,_=e[p+1]+t.y,b=e[p+2]+t.z;r.x=L,r.y=_,r.z=b,L<o.x&&h.clone(r,o),L>c.x&&h.clone(r,c),_<s.y&&h.clone(r,s),_>l.y&&h.clone(r,l),b<a.z&&h.clone(r,a),b>f.z&&h.clone(r,f)}let g=h.magnitudeSquared(h.subtract(c,o,zs)),m=h.magnitudeSquared(h.subtract(l,s,zs)),A=h.magnitudeSquared(h.subtract(f,a,zs)),x=o,C=c,E=g;m>E&&(E=m,x=s,C=l),A>E&&(E=A,x=a,C=f);let T=OG;T.x=(x.x+C.x)*.5,T.y=(x.y+C.y)*.5,T.z=(x.z+C.z)*.5;let S=h.magnitudeSquared(h.subtract(C,T,zs)),v=Math.sqrt(S),D=MG;D.x=o.x,D.y=s.y,D.z=a.z;let M=RG;M.x=c.x,M.y=l.y,M.z=f.z;let O=h.midpoint(D,M,BG),B=0;for(p=0;p<d;p+=n){r.x=e[p]+t.x,r.y=e[p+1]+t.y,r.z=e[p+2]+t.z;let L=h.magnitude(h.subtract(r,O,zs));L>B&&(B=L);let _=h.magnitudeSquared(h.subtract(r,T,zs));if(_>S){let b=Math.sqrt(_);v=(v+b)*.5,S=v*v;let w=b-v;T.x=(v*T.x+w*r.x)/b,T.y=(v*T.y+w*r.y)/b,T.z=(v*T.z+w*r.z)/b}}return v<B?(h.clone(T,i.center),i.radius=v):(h.clone(O,i.center),i.radius=B),i};hn.fromEncodedCartesianVertices=function(e,t,n){if(u(n)||(n=new hn),!u(e)||!u(t)||e.length!==t.length||e.length===0)return n.center=h.clone(h.ZERO,n.center),n.radius=0,n;let i=PG;i.x=e[0]+t[0],i.y=e[1]+t[1],i.z=e[2]+t[2];let r=h.clone(i,bG),o=h.clone(i,SG),s=h.clone(i,vG),a=h.clone(i,wG),c=h.clone(i,DG),l=h.clone(i,IG),f=e.length,d;for(d=0;d<f;d+=3){let B=e[d]+t[d],L=e[d+1]+t[d+1],_=e[d+2]+t[d+2];i.x=B,i.y=L,i.z=_,B<r.x&&h.clone(i,r),B>a.x&&h.clone(i,a),L<o.y&&h.clone(i,o),L>c.y&&h.clone(i,c),_<s.z&&h.clone(i,s),_>l.z&&h.clone(i,l)}let p=h.magnitudeSquared(h.subtract(a,r,zs)),g=h.magnitudeSquared(h.subtract(c,o,zs)),m=h.magnitudeSquared(h.subtract(l,s,zs)),A=r,x=a,C=p;g>C&&(C=g,A=o,x=c),m>C&&(C=m,A=s,x=l);let E=OG;E.x=
(${this[1]}, ${this[3]})`};var nr=qt;var da={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};da.isLines=function(e){return e===da.LINES||e===da.LINE_LOOP||e===da.LINE_STRIP};da.isTriangles=function(e){return e===da.TRIANGLES||e===da.TRIANGLE_STRIP||e===da.TRIANGLE_FAN};da.validate=function(e){return e===da.POINTS||e===da.LINES||e===da.LINE_LOOP||e===da.LINE_STRIP||e===da.TRIANGLES||e===da.TRIANGLE_STRIP||e===da.TRIANGLE_FAN};var Be=Object.freeze(da);function rt(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 hv=new h;rt.fromAxisAngle=function(e,t,n){let i=t/2,r=Math.sin(i);hv=h.normalize(e,hv);let o=hv.x*r,s=hv.y*r,a=hv.z*r,c=Math.cos(i);return u(n)?(n.x=o,n.y=s,n.z=a,n.w=c,n):new rt(o,s,a,c)};var KTe=[1,2,0],JTe=new Array(3);rt.fromRotationMatrix=function(e,t){let n,i,r,o,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,r=(e[Z.COLUMN2ROW0]-e[Z.COLUMN0ROW2])*n,o=(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],m=d[g];n=Math.sqrt(e[Z.getElementIndex(p,p)]-e[Z.getElementIndex(g,g)]-e[Z.getElementIndex(m,m)]+1);let A=JTe;A[p]=.5*n,n=.5/n,s=(e[Z.getElementIndex(m,g)]-e[Z.getElementIndex(g,m)])*n,A[g]=(e[Z.getElementIndex(g,p)]+e[Z.getElementIndex(p,g)])*n,A[m]=(e[Z.getElementIndex(m,p)]+e[Z.getElementIndex(p,m)])*n,i=-A[0],r=-A[1],o=-A[2]}return u(t)?(t.x=i,t.y=r,t.z=o,t.w=s,t):new rt(i,r,o,s)};var wJ=new rt,DJ=new rt,LG=new rt,IJ=new rt;rt.fromHeadingPitchRoll=function(e,t){return IJ=rt.fromAxisAngle(h.UNIT_X,e.roll,wJ),LG=rt.fromAxisAngle(h.UNIT_Y,-e.pitch,t),t=rt.multiply(LG,IJ,LG),DJ=rt.fromAxisAngle(h.UNIT_Z,-e.heading,wJ),rt.multiply(DJ,t,t)};var b3=new h,NG=new h,rd=new rt,PJ=new rt,S3=new rt;rt.packedLength=4;rt.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};rt.unpack=function(e,t,n){return t=y(t,0),u(n)||(n=new rt),n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3],n};rt.packedInterpolationLength=3;rt.convertPackedArrayForInterpolation=function(e,t,n,i){rt.unpack(e,n*4,S3),rt.conjugate(S3,S3);for(let r=0,o=n-t+1;r<o;r++){let s=r*3;rt.unpack(e,(t+r)*4,rd),rt.multiply(rd,S3,rd),rd.w<0&&rt.negate(rd,rd),rt.computeAxis(rd,b3);let a=rt.computeAngle(rd);u(i)||(i=[]),i[s]=b3.x*a,i[s+1]=b3.y*a,i[s+2]=b3.z*a}};rt.unpackInterpolationResult=function(e,t,n,i,r){u(r)||(r=new rt),h.fromArray(e,0,NG);let o=h.magnitude(NG);return rt.unpack(t,i*4,PJ),o===0?rt.clone(rt.IDENTITY,rd):rt.fromAxisAngle(NG,o,rd),rt.multiply(rd,PJ,r)};rt.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 rt(e.x,e.y,e.z,e.w)};rt.conjugate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=e.w,t};rt.magnitudeSquared=function(e){return e.x*e.x+e.y*e.y+e.z*e.z+e.w*e.w};rt.magnitude=function(e){return Math.sqrt(rt.magnitudeSquared(e))};rt.normalize=function(e,t){let n=1/rt.magnitude(e),i=e.x*n,r=e.y*n,o=e.z*n,s=e.w*n;return t.x=i,t.y=r,t.z=o,t.w=s,t};rt.inverse=function(e,t){let n=rt.magnitudeSquared(e);return t=rt.conjugate(e,t),rt.multiplyByScalar(t,1/n,t)};rt.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};rt.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};rt.negate=function(e,t){return t.x=-e.x,t.y=-e.y,t.z=-e.z,t.w=-e.w,t};rt.dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w};rt.multiply=function(e,t,n){let i=e.x,r=e.y,o=e.z,s=e.w,a=t.x,c=t.y,l=t.z,f=t.w,d=s*a+i*f+r*l-o*c,p=s*c-i*l+r*f+o*a,g=s*l+i*c-r*a+o*f,m=s*f-i*a-r*c-o*l;return n.x=d,n.y=p,n.z=g,n.w=m,n};rt.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};rt.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};rt.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};rt.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 r=n[i],o=r.indexOf(": ");if(o>0){let s=r.substring(0,o),a=r.substring(o+2);t[s]=a}}return t}var gv=PEe;function YJ(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=gv(this.responseHeaders))}YJ.prototype.toString=function(){let e="Request has failed.";return u(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};var Ph=YJ;var Av=Wi(Ql(),1);function P0(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(P0.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 qG(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}P0.prototype.reserve=function(e){e=y(e,this._length),this._array.length=e};P0.prototype.heapify=function(e){e=y(e,0);let t=this._length,n=this._comparator,i=this._array,r=-1,o=!0;for(;o;){let s=2*(e+1),a=s-1;a<t&&n(i[a],i[e])<0?r=a:r=e,s<t&&n(i[s],i[r])<0&&(r=s),r!==e?(qG(i,r,e),e=r):o=!1}};P0.prototype.resort=function(){let e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};P0.prototype.insert=function(e){let t=this._array,n=this._comparator,i=this._maximumLength,r=this._length++;for(r<t.length?t[r]=e:t.push(e);r!==0;){let s=Math.floor((r-1)/2);if(n(t[r],t[s])<0)qG(t,r,s),r=s;else break}let o;return u(i)&&this._length>i&&(o=t[i],this._length=i),o};P0.prototype.pop=function(e){if(e=y(e,0),this._length===0)return;let t=this._array,n=t[e];return qG(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};var yv=P0;function OEe(e,t){return e.priority-t.priority}var ir={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0},sT=20,Fa=new yv({comparator:OEe});Fa.maximumLength=sT;Fa.reserve(sT);var Oh=[],tp={},MEe=typeof document<"u"?new Av.default(document.location.href):new Av.default,B3=new ge;function Wr(){}Wr.maximumRequests=50;Wr.maximumRequestsPerServer=6;Wr.requestsByServer={"api.cesium.com:443":18,"assets.ion.cesium.com:443":18};Wr.throttleRequests=!0;Wr.debugShowStatistics=!1;Wr.requestCompletedEvent=B3;Object.defineProperties(Wr,{statistics:{get:function(){return ir}},priorityHeapLength:{get:function(){return sT},set:function(e){if(e<sT)for(;Fa.length>e;){let t=Fa.pop();O0(t)}sT=e,Fa.maximumLength=e,Fa.reserve(e)}}});function XJ(e){u(e.priorityFunction)&&(e.priority=e.priorityFunction())}Wr.serverHasOpenSlots=function(e,t){t=y(t,1);let n=y(Wr.requestsByServer[e],Wr.maximumRequestsPerServer);return tp[e]+t<=n};Wr.heapHasOpenSlots=function(e){return Fa.length+e<=sT};function KJ(e){return e.state===ri.UNISSUED&&(e.state=ri.ISSUED,e.deferred=Hs()),e.deferred.promise}function REe(e){return function(t){if(e.state===ri.CANCELLED)return;let n=e.deferred;--ir.numberOfActiveRequests,--tp[e.serverKey],B3.raiseEvent(),e.state=ri.RECEIVED,e.deferred=void 0,n.resolve(t)}}function BEe(e){return function(t){e.state!==ri.CANCELLED&&(++ir.numberOfFailedRequests,--ir.numberOfActiveRequests,--tp[e.serverKey],B3.raiseEvent(t),e.state=ri.FAILED,e.deferred.reject(t))}}function JJ(e){let t=KJ(e);return e.state=ri.ACTIVE,Oh.push(e),++ir.numberOfActiveRequests,++ir.numberOfActiveRequestsEver,++tp[e.serverKey],e.requestFunction().then(REe(e)).catch(BEe(e)),t}function O0(e){let t=e.state===ri.ACTIVE;if(e.state=ri.CANCELLED,++ir.numberOfCancelledRequests,u(e.deferred)){let n=e.deferred;e.deferred=void 0,n.reject()}t&&(--ir.numberOfActiveRequests,--tp[e.serverKey],++ir.numberOfCancelledActiveRequests),u(e.cancelFunction)&&e.cancelFunction()}Wr.update=function(){let e,t,n=0,i=Oh.length;for(e=0;e<i;++e){if(t=Oh[e],t.cancelled&&O0(t),t.state!==ri.ACTIVE){++n;continue}n>0&&(Oh[e-n]=t)}Oh.length-=n;let r=Fa.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 Dv=`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 Iv=`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 Pv=`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 Ov=`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 Mv=`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 Nbe={ADD:te.FUNC_ADD,SUBTRACT:te.FUNC_SUBTRACT,REVERSE_SUBTRACT:te.FUNC_REVERSE_SUBTRACT,MIN:te.MIN,MAX:te.MAX},ha=Object.freeze(Nbe);var Fbe={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},vr=Object.freeze(Fbe);var Ube={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:ha.ADD,equationAlpha:ha.ADD,functionSourceRgb:vr.SOURCE_ALPHA,functionSourceAlpha:vr.ONE,functionDestinationRgb:vr.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:vr.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:ha.ADD,equationAlpha:ha.ADD,functionSourceRgb:vr.ONE,functionSourceAlpha:vr.ONE,functionDestinationRgb:vr.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:vr.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:ha.ADD,equationAlpha:ha.ADD,functionSourceRgb:vr.SOURCE_ALPHA,functionSourceAlpha:vr.ONE,functionDestinationRgb:vr.ONE,functionDestinationAlpha:vr.ONE})},ln=Object.freeze(Ube);var Vbe={FRONT:te.FRONT,BACK:te.BACK,FRONT_AND_BACK:te.FRONT_AND_BACK},gi=Object.freeze(Vbe);function pT(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(pT.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}}});pT.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(`
`)};pT.prototype.isTranslucent=function(){return u(this.material)&&this.material.isTranslucent()||!u(this.material)&&this.translucent};pT.prototype.getRenderState=function(){let e=this.isTranslucent(),t=je(this.renderState,!1);return e?(t.depthMask=!1,t.blending=ln.ALPHA_BLEND):t.depthMask=!0,t};pT.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=ln.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:gi.BACK}),u(n)&&(i=mt(n,i,!0)),i};var rr=pT;function kbe(){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=kbe;function _T(e,t,n,i,r){this._format=e,this._datatype=t,this._width=n,this._height=i,this._buffer=r}Object.defineProperties(_T.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}}});_T.clone=function(e){if(u(e))return new _T(e._format,e._datatype,e._width,e._height,e._buffer)};_T.prototype.clone=function(){return _T.clone(this)};var Rv=_T;var bZ=Wi(Ql(),1);function SZ(){if(!u(ma._canTransferArrayBuffer)){let e=new Worker(wZ("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(r){let o=r.data.array,s=u(o)&&o[0]===t;i.resolve(s),e.terminate(),ma._canTransferArrayBuffer=s},ma._canTransferArrayBuffer=i.promise}return ma._canTransferArrayBuffer}var c8=new ge;function vZ(e,t){--e._activeTasks;let n=t.id;if(!u(n))return;let i=e._deferreds,r=i[n];if(u(t.error)){let o=t.error;o.name==="RuntimeError"?(o=new de(t.error.message),o.stack=t.error.stack):o.name==="DeveloperError"&&(o=new fe(t.error.message),o.stack=t.error.stack),c8.raiseEvent(o),r.reject(o)}else c8.raiseEvent(),r.resolve(t.result);delete i[n]}function wZ(e){let t=$t(e);if(w0(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 a8;function zbe(){return u(a8)||(a8=wZ("Workers/cesiumWorkerBootstrapper.js")),a8}function DZ(e){let t=new Worker(zbe());t.postMessage=y(t.webkitPostMessage,t.postMessage);let n={loaderConfig:{paths:{Workers:$t("Workers")},baseUrl:$t.getCesiumBaseUrl().url},workerModule:e._workerPath};return t.postMessage(n),t.onmessage=function(i){vZ(e,i.data)},t}function Hbe(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=$t(t.fallbackModulePath),Promise.resolve(n)}return n.modulePath=$t(t.modulePath),n.wasmBinaryFile=$t(t.wasmBinaryFile),De.fetchArrayBuffer({url:n.wasmBinaryFile}).then(function(i){return n.wasmBinary=i,n})}function ma(e,t){let n=new bZ.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 Gbe=[];ma.prototype.scheduleTask=function(e,t){if(u(this._worker)||(this._worker=DZ(this)),this._activeTasks>=this._maximumActiveTasks)return;++this._activeTasks;let n=this;return Promise.resolve(SZ()).then(function(i){u(t)?i||(t.length=0):t=Gbe;let r=n._nextID++,o=Hs();return n._deferreds[r]=o,n._worker.postMessage({id:r,parameters:e,canTransferArrayBuffer:i},t),o.promise})};ma.prototype.initWebAssemblyModule=function(e){u(this._worker)||(this._worker=DZ(this));let t=Hs(),n=this,i=this._worker;return Hbe(this,e).then(function(r){return Promise.resolve(SZ()).then(function(o){let s,a=r.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 Uv=`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 Vv=`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 kv=`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 zv=`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 Hv=`#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 Gv=`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 Wv=`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 jv=`#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 qv=`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 Yv=`#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 Xv=`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 Kv=`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 Jv=`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 Qv=`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 $v=`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 ew=`// 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 qe(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,an.LINEAR),this._magnificationFilter=y(e.magnificationFilter,Ti.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,jbe(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),u(qe._uniformList[this.type])||(qe._uniformList[this.type]=Object.keys(this._uniforms))}qe._uniformList={};qe.fromType=function(e,t){let n=new qe({fabric:{type:e}});if(u(t))for(let i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};qe.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 r=t[i];if(typeof r=="function"?e=e&&r():e=e&&r,!e)break}return e};qe.prototype.update=function(e){this._defaultTexture=e.defaultTexture;let t,n,i=this._loadedImages,r=i.length;for(t=0;t<r;++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 un({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter}),p;u(l.internalFormat)?p=new Ot({context:e,pixelFormat:l.internalFormat,width:l.width,height:l.height,source:{arrayBufferView:l.bufferView,mipLevels:f},sampler:d}):p=new Ot({context:e,source:l,sampler:d});let g=this._textures[n];u(g)&&g!==this._defaultTexture&&g.destroy(),this._textures[n]=p;let m=`${n}Dimensions`;if(this.uniforms.hasOwnProperty(m)){let A=this.uniforms[m];A.x=p._width,A.y=p._height}}i.length=0;let o=this._loadedCubeMaps;for(r=o.length,t=0;t<r;++t){let c=o[t];n=c.id;let l=c.images,f=new za({context:e,source:{positiveX:l[0],negativeX:l[1],positiveY:l[2],negativeY:l[3],positiveZ:l[4],negativeZ:l[5]},sampler:new un({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[n]=f}o.length=0;let s=this._updateFunctions;for(r=s.length,t=0;t<r;++t)s[t](this,e);let a=this.materials;for(let c in a)a.hasOwnProperty(c)&&a[c].update(e)};qe.prototype.isDestroyed=function(){return!1};qe.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 jbe(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=qe._materialCache.getMaterial(t.type);if(u(i)){let o=je(i.fabric,!0);t._template=mt(t._template,o,!0),n=i.translucent}Kbe(t),u(i)||qe._materialCache.addMaterial(t.type,t),Zbe(t),tSe(t),iSe(t);let r=t._translucentFunctions.length===0?!0:void 0;if(n=y(n,r),n=y(e.translucent,n),u(n))if(typeof n=="function"){let o=function(){return n(t)};t._translucentFunctions.push(o)}else t._translucentFunctions.push(n)}function l8(e,t,n,i){if(u(e)){for(let r in e)if(e.hasOwnProperty(r)){let o=t.indexOf(r)!==-1;(i&&!o||!i&&o)&&n(r,t)}}}function OZ(e,t){}function qbe(e,t){}var Ybe=["type","materials","uniforms","components","source"],Xbe=["diffuse","specular","shininess","normal","emission","alpha"];function Kbe(e){let t=e._template,n=t.uniforms,i=t.materials,r=t.components;l8(t,Ybe,OZ,!0),l8(r,Xbe,OZ,!0);let o=[];for(let s in i)i.hasOwnProperty(s)&&o.push(s);l8(n,o,qbe,!1)}function Jbe(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 Zbe(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 r in t)if(t.hasOwnProperty(r))if(r==="diffuse"||r==="emission"){let s=i&&Jbe(t[r],e)?t[r]:`czm_gammaCorrect(${t[r]})`;e.shaderSource+=`material.${r} = ${s};
`}else r==="alpha"?e.shaderSource+=`material.alpha = ${t.alpha};
`:e.shaderSource+=`material.${r} = ${t[r]};
`}e.shaderSource+=`return material;
}
`}}var MZ={mat2:nr,mat3:Z,mat4:N},Qbe=/\.ktx2$/i;function $be(e){let t;return function(n,i){let r=n.uniforms,o=r[e],s=t!==o,a=!u(o)||o===qe.DefaultImageId;t=o;let c=n._textures[e],l,f;if(o instanceof HTMLVideoElement){if(o.readyState>=2){if(s&&u(c)&&(c!==i.defaultTexture&&c.destroy(),c=void 0),!u(c)||c===i.defaultTexture){let p=new un({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new Ot({context:i,source:o,sampler:p}),n._textures[e]=c;return}c.copyFrom({source:o})}else u(c)||(n._textures[e]=i.defaultTexture);return}if(o instanceof Ot&&o!==c){n._texturePaths[e]=void 0;let p=n._textures[e];u(p)&&p!==n._defaultTexture&&p.destroy(),n._textures[e]=o,l=`${e}Dimensions`,r.hasOwnProperty(l)&&(f=r[l],f.x=o._width,f.y=o._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`,r.hasOwnProperty(l)&&(f=r[l],f.x=c._width,f.y=c._height)),a)return;let d=o instanceof De;if(!u(n._texturePaths[e])||d&&o.url!==n._texturePaths[e].url||!d&&o!==n._texturePaths[e]){if(typeof o=="string"||d){let p=d?o:De.createIfNeeded(o),g;Qbe.test(p.url)?g=ml(p.url):g=p.fetchImage(),Promise.resolve(g).then(function(m){n._loadedImages.push({id:e,image:m})}).catch(function(){u(c)&&c!==n._defaultTexture&&c.destroy(),n._textures[e]=n._defaultTexture})}else(o instanceof HTMLCanvasElement||o instanceof HTMLImageElement)&&n._loadedImages.push({id:e,image:o});n._texturePaths[e]=o}}}function eSe(e){return function(t,n){let i=t.uniforms[e];if(i instanceof za){let o=t._textures[e];o!==t._defaultTexture&&o.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===qe.DefaultCubeMapId)return;let r=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(r!==t._texturePaths[e]){let o=[De.createIfNeeded(i.positiveX).fetchImage(),De.createIfNeeded(i.negativeX).fetchImage(),De.createIfNeeded(i.positiveY).fetchImage(),De.createIfNeeded(i.negativeY).fetchImage(),De.createIfNeeded(i.positiveZ).fetchImage(),De.createIfNeeded(i.negativeZ).fetchImage()];Promise.all(o).then(function(s){t._loadedCubeMaps.push({id:e,images:s})}),t._texturePaths[e]=r}}}function tSe(e){let t=e._template.uniforms;for(let n in t)t.hasOwnProperty(n)&&RZ(e,n)}function RZ(e,t){let n=e._strict,i=e._template.uniforms,r=i[t],o=nSe(r),s;if(o==="channels")s=tw(e,t,r,!1);else{if(o==="sampler2D"){let l=`${t}Dimensions`;rSe(e,l)>0&&(i[l]={type:"ivec3",x:1,y:1},RZ(e,l))}if(!new RegExp(`uniform\\s+${o}\\s+${t}\\s*;`).test(e.shaderSource)){let l=`uniform ${o} ${t};`;e.shaderSource=l+e.shaderSource}let c=`${t}_${e._count++}`;if(s=tw(e,t,c),e.uniforms[t]=r,o==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push($be(t));else if(o==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(eSe(t));else if(o.indexOf("mat")!==-1){let l=new MZ[o];e._uniforms[c]=function(){return MZ[o].fromColumnMajorArray(e.uniforms[t],l)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function nSe(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 De||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)/^([rgba]){1,4}$/i.test(e)?t="channels":e===qe.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 r in e)e.hasOwnProperty(r)&&(i+=1);i>=2&&i<=4?t=`vec${i}`:i===6&&(t="samplerCube")}}return t}function iSe(e){let t=e._strict,n=e._template.materials;for(let i in n)if(n.hasOwnProperty(i)){let r=new qe({strict:t,fabric:n[i],count:e._count});e._count=r._count,e._uniforms=mt(e._uniforms,r._uniforms,!0),e.materials[i]=r,e._translucentFunctions=e._translucentFunctions.concat(r._translucentFunctions);let o="czm_getMaterial",s=`${o}_${e._count++}`;tw(r,o,s),e.shaderSource=r.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 iw=`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 N0=`in vec4 v_color;
void main()
{
out_FragColor = czm_gammaCorrect(v_color);
}
`;var rw=`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 ip(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=y(e.closed,!1),i=y(e.flat,!1),r=i?rw:iw,o=i?N0:nw,s=i?ip.FLAT_VERTEX_FORMAT:ip.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,r),this._fragmentShaderSource=y(e.fragmentShaderSource,o),this._renderState=rr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=y(e.faceForward,!n)}Object.defineProperties(ip.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}}});ip.VERTEX_FORMAT=Pe.POSITION_AND_NORMAL;ip.FLAT_VERTEX_FORMAT=Pe.POSITION_ONLY;ip.prototype.getFragmentShaderSource=rr.prototype.getFragmentShaderSource;ip.prototype.isTranslucent=rr.prototype.isTranslucent;ip.prototype.getRenderState=rr.prototype.getRenderState;var rn=ip;function gT(e){this._definitionChanged=new ge,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(gT.prototype,{isConstant:{get:function(){return q.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:ce("color")});gT.prototype.getType=function(e){return"Color"};gT.prototype.getValue=function(e,t){return u(t)||(t={}),t.color=q.getValueOrClonedDefault(this._color,e,z.WHITE,t.color),t};gT.prototype.equals=function(e){return this===e||e instanceof gT&&q.equals(this._color,e._color)};var Nt=gT;function ag(e){e=y(e,y.EMPTY_OBJECT),this._ellipsoid=y(e.ellipsoid,re.WGS84),this._rectangle=y(e.rectangle,le.MAX_VALUE),this._projection=new Di(this._ellipsoid),this._numberOfLevelZeroTilesX=y(e.numberOfLevelZeroTilesX,2),this._numberOfLevelZeroTilesY=y(e.numberOfLevelZeroTilesY,1)}Object.defineProperties(ag.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});ag.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};ag.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};ag.prototype.rectangleToNativeRectangle=function(e,t){let n=P.toDegrees(e.west),i=P.toDegrees(e.south),r=P.toDegrees(e.east),o=P.toDegrees(e.north);return u(t)?(t.west=n,t.south=i,t.east=r,t.north=o,t):new le(n,i,r,o)};ag.prototype.tileXYToNativeRectangle=function(e,t,n,i){let r=this.tileXYToRectangle(e,t,n,i);return r.west=P.toDegrees(r.west),r.south=P.toDegrees(r.south),r.east=P.toDegrees(r.east),r.north=P.toDegrees(r.north),r};ag.prototype.tileXYToRectangle=function(e,t,n,i){let r=this._rectangle,o=this.getNumberOfXTilesAtLevel(n),s=this.getNumberOfYTilesAtLevel(n),a=r.width/o,c=e*a+r.west,l=(e+1)*a+r.west,f=r.height/s,d=r.north-t*f,p=r.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};ag.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!le.contains(i,e))return;let r=this.getNumberOfXTilesAtLevel(t),o=this.getNumberOfYTilesAtLevel(t),s=i.width/r,a=i.height/o,c=e.longitude;i.east<i.west&&(c+=P.TWO_PI);let l=(c-i.west)/s|0;l>=r&&(l=r-1);let f=(i.north-e.latitude)/a|0;return f>=o&&(f=o-1),u(n)?(n.x=l,n.y=f,n):new H(l,f)};var Yi=ag;var BZ=new h,LZ=new h,NZ=new me,u8=new h,oSe=new h,FZ=new ae,sSe=new Yi,ow=[new me,new me,new me,new me],sw=new H,Uo={};Uo.initialize=function(){let e=Uo._initPromise;return u(e)||(e=De.fetchJson($t("Assets/approximateTerrainHeights.json")).then(function(t){Uo._terrainHeights=t}),Uo._initPromise=e),e};Uo.getMinimumMaximumHeights=function(e,t){t=y(t,re.WGS84);let n=UZ(e),i=Uo._defaultMinTerrainHeight,r=Uo._defaultMaxTerrainHeight;if(u(n)){let o=`${n.level}-${n.x}-${n.y}`,s=Uo._terrainHeights[o];u(s)&&(i=s[0],r=s[1]),t.cartographicToCartesian(le.northeast(e,NZ),BZ),t.cartographicToCarte
${n}`),l=`Vertex shader failed to compile. Compile log: ${c}`):(c=e.getShaderInfoLog(o),console.error(`${Vh}Fragment shader compile log: ${c}`),console.error(`${Vh} Fragment shader source:
${i}`),l=`Fragment shader failed to compile. Compile log: ${c}`),e.deleteShader(r),e.deleteShader(o),e.deleteProgram(s),new de(l);function d(p,g){if(!u(f))return;let m=f.getTranslatedShaderSource(p);if(m===""){console.error(`${Vh}${g} shader translation failed.`);return}console.error(`${Vh}Translated ${g} shaderSource:
${m}`)}}function Nve(e,t,n){let i={};for(let r=0;r<n;++r){let o=e.getActiveAttrib(t,r),s=e.getAttribLocation(t,o.name);i[o.name]={name:o.name,type:o.type,index:s}}return i}function Fve(e,t){let n={},i=[],r=[],o=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<o;++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=fw(e,a,l,f);n[l]=d,i.push(d),d._setSampler&&r.push(d)}}else{let f,d,p,g,m=l.indexOf("[");if(m>=0){if(f=n[l.slice(0,m)],!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=dw(e,a,l,d),n[l]=f,i.push(f),f._setSampler&&r.push(f)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:r}}function Uve(e,t){let n=[],i=[];for(let r in t)if(t.hasOwnProperty(r)){let o=t[r],s=r,a=e._duplicateUniformNames[s];u(a)&&(o.name=a,s=a);let c=rp[s];u(c)?n.push({uniform:o,automaticUniform:c}):i.push(o)}return{automaticUniforms:n,manualUniforms:i}}function Vve(e,t,n){e.useProgram(t);let i=0,r=n.length;for(let o=0;o<r;++o)i=n[o]._setSampler(i);return e.useProgram(null),i}function J3(e){u(e._program)||WQ(e)}function WQ(e){let t=e._program,n=e._gl,i=Lve(n,e,e._debugShaders),r=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),o=Fve(n,i),s=Uve(e,o.uniformsByName);e._program=i,e._numberOfVertexAttributes=r,e._vertexAttributes=Nve(n,i,r),e._uniformsByName=o.uniformsByName,e._uniforms=o.uniforms,e._automaticUniforms=s.automaticUniforms,e._manualUniforms=s.manualUniforms,e.maximumTextureUnitIndex=Vve(n,i,o.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{WQ(e),l(e._program)}catch(m){e._vertexShaderText=d,e._fragmentShaderText=p;let x=/(?:Compile|Link) error: ([^]*)/.exec(m.message);f(x?x[1]:m.message)}})}op.prototype._bind=function(){J3(this),this._gl.useProgram(this._program)};op.prototype._setUniforms=function(e,t,n){let i,r;if(u(e)){let a=this._manualUniforms;for(i=a.length,r=0;r<i;++r){let c=a[r];c.value=e[c.name]()}}let o=this._automaticUniforms;for(i=o.length,r=0;r<i;++r){let a=o[r];a.uniform.value=a.automaticUniform.getValue(t)}let s=this._uniforms;for(i=s.length,r=0;r<i;++r)s[r].set();if(n){let a=this._gl,c=this._program;a.validateProgram(c)}};op.prototype.isDestroyed=function(){return!1};op.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};op.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),ue(this)};var Xt=op;var hw=`/**
* 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 mw=`/**
* 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 pw=`/**
* 0.1
*
* @name czm_epsilon1
* @glslConstant
*/
const float czm_epsilon1 = 0.1;
`;var _w=`/**
* 0.01
*
* @name czm_epsilon2
* @glslConstant
*/
const float czm_epsilon2 = 0.01;
`;var gw=`/**
* 0.001
*
* @name czm_epsilon3
* @glslConstant
*/
const float czm_epsilon3 = 0.001;
`;var yw=`/**
* 0.0001
*
* @name czm_epsilon4
* @glslConstant
*/
const float czm_epsilon4 = 0.0001;
`;var Aw=`/**
* 0.00001
*
* @name czm_epsilon5
* @glslConstant
*/
const float czm_epsilon5 = 0.00001;
`;var xw=`/**
* 0.000001
*
* @name czm_epsilon6
* @glslConstant
*/
const float czm_epsilon6 = 0.000001;
`;var Cw=`/**
* 0.0000001
*
* @name czm_epsilon7
* @glslConstant
*/
const float czm_epsilon7 = 0.0000001;
`;var Tw=`/**
* 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 Ew=`/**
* 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 bw=`/**
* 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 Sw=`/**
* The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
*
* @name czm_passCesium3DTile
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCesium3DTile = 4.0;
`;var vw=`/**
* 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 ww=`/**
* 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 Dw=`/**
* The automatic GLSL constant for {@link Pass#CLASSIFICATION}
*
* @name czm_passClassification
* @glslConstant
*
* @see czm_pass
*/
const float czm_passClassification = 7.0;
`;var Iw=`/**
* The automatic GLSL constant for {@link Pass#COMPUTE}
*
* @name czm_passCompute
* @glslConstant
*
* @see czm_pass
*/
const float czm_passCompute = 1.0;
`;var Pw=`/**
* The automatic GLSL constant for {@link Pass#ENVIRONMENT}
*
* @name czm_passEnvironment
* @glslConstant
*
* @see czm_pass
*/
const float czm_passEnvironment = 0.0;
`;var Ow=`/**
* The automatic GLSL constant for {@link Pass#GLOBE}
*
* @name czm_passGlobe
* @glslConstant
*
* @see czm_pass
*/
const float czm_passGlobe = 2.0;
`;var Mw=`/**
* The automatic GLSL constant for {@link Pass#OPAQUE}
*
* @name czm_passOpaque
* @glslConstant
*
* @see czm_pass
*/
const float czm_passOpaque = 7.0;
`;var Rw=`/**
* 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 Lw=`/**
* The automatic GLSL constant for {@link Pass#TRANSLUCENT}
*
* @name czm_passTranslucent
* @glslConstant
*
* @see czm_pass
*/
const float czm_passTranslucent = 8.0;
`;var Nw=`/**
* The automatic GLSL constant for {@link Pass#VOXELS}
*
* @name czm_passVoxels
* @glslConstant
*
* @see czm_pass
*/
const float czm_passVoxels = 9.0;
`;var Fw=`/**
* 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 Uw=`/**
* 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 Vw=`/**
* 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 kw=`/**
* 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 zw=`/**
* 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 Hw=`/**
* 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 Gw=`/**
* 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 Ww=`/**
* 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 jw=`/**
* 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 qw=`/**
* 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 Yw=`/**
* 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 Xw=`/**
* 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 Kw=`/**
* 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 Jw=`/**
* 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 Qw=`/**
* 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 $w=`/**
* 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 eD=`/**
* 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 tD=`/**
* 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 nD=`/**
* 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 iD=`/**
* DOC_TBA
*
* @name czm_ray
* @glslStruct
*/
struct czm_ray
{
vec3 origin;
vec3 direction;
};
`;var rD=`/**
* 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 oD=`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 sD=`/**
* 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 aD=`/**
* 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 cD=`/**
* 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 lD=`/**
* 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 uD=`/**
* 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 fD=`/**
* 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 dD=`// 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 hD=`/**
* @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 mD=`/**
* 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 pD=`/**
* 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 _D=`/**
* 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 gD=`/**
* 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 yD=`
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 AD=`
uniform vec4 shadowMap_cascadeDistances;
float czm_cascadeDistance(vec4 weights)
{
return dot(shadowMap_cascadeDistances, weights);
}
`;var xD=`
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 CD=`
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 TD=`/**
* 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 ED=`/**
* 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 bD=`/**
* @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 SD=`/**
* 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 vD=`/**
* 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 wD=`// 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 DD=`/**
* 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 ID=`/**
* 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 PD=`/**
* 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 OD=`/**
* 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 MD=`/**
* 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 RD=`/**
* 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 LD=`/**
* 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 ND=`/**
* 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 FD=`/**
* 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 UD=`/**
* 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 VD=`/**
* 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 kD=`/**
* 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 zD=`/**
* @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 HD=`/**
* 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 GD=`/**
* 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 WD=`/**
* 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 jD=`/**
* 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 qD=`/**
* 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 YD=`/**
* 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 XD=`/**
* 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 KD=`/**
* 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 JD=`/**
* 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 QD=`/**
* 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 $D=`/**
* 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 eI=` /**
* 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 tI=`/**
* 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 nI=`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 iI=`/**
* 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 rI=`/**
* 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 oI=`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 sI=`/**
* 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 aI=`/**
* 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 cI=`/**
* 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 lI=`/**
* 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 uI=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
{
return czm_reverseLogDepth(texture(depthTexture, texCoords).r);
}
`;var fI=`/**
* 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 dI=`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 hI=`/**
* 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 mI=`/**
* 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 pI=`/**
* 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 _I=`
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 gI=`
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 yI=`/**
* 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 AI=`/**
* 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 xI=`/**
* 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 CI=`/**
* 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 TI=`/**
* 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 EI=`/**
* 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 bI=`/**
* 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 SI=`/**
* @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 vI=`/**
* 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 wI=`/**
* 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 DI=`/**
* 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 II=`/**
* 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 PI=`/**
* 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 OI=`#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 MI=`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 RI=`// 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 LI=`/**
* 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 k0={czm_degreesPerRadian:hw,czm_depthRange:mw,czm_epsilon1:pw,czm_epsilon2:_w,czm_epsilon3:gw,czm_epsilon4:yw,czm_epsilon5:Aw,czm_epsilon6:xw,czm_epsilon7:Cw,czm_infinity:Tw,czm_oneOverPi:Ew,czm_oneOverTwoPi:bw,czm_passCesium3DTile:Sw,czm_passCesium3DTileClassification:vw,czm_passCesium3DTileClassificationIgnoreShow:ww,czm_passClassification:Dw,czm_passCompute:Iw,czm_passEnvironment:Pw,czm_passGlobe:Ow,czm_passOpaque:Mw,czm_passOverlay:Rw,czm_passTerrainClassification:Bw,czm_passTranslucent:Lw,czm_passVoxels:Nw,czm_pi:Fw,czm_piOverFour:Uw,czm_piOverSix:Vw,czm_piOverThree:kw,czm_piOverTwo:zw,czm_radiansPerDegree:Hw,czm_sceneMode2D:Gw,czm_sceneMode3D:Ww,czm_sceneModeColumbusView:jw,czm_sceneModeMorphing:qw,czm_solarRadius:Yw,czm_threePiOver2:Xw,czm_twoPi:Kw,czm_webMercatorMaxLatitude:Jw,czm_depthRangeStruct:Zw,czm_material:Qw,czm_materialInput:$w,czm_modelMaterial:eD,czm_modelVertexOutput:tD,czm_pbrParameters:nD,czm_ray:iD,czm_raySegment:rD,czm_shadowParameters:oD,czm_HSBToRGB:sD,czm_HSLToRGB:aD,czm_RGBToHSB:cD,czm_RGBToHSL:lD,czm_RGBToXYZ:uD,czm_XYZToRGB:fD,czm_acesTonemapping:dD,czm_alphaWeight:hD,czm_antialias:mD,czm_approximateSphericalCoordinates:pD,czm_backFacing:_D,czm_branchFreeTernary:gD,czm_cascadeColor:yD,czm_cascadeDistance:AD,czm_cascadeMatrix:xD,czm_cascadeWeights:CD,czm_columbusViewMorph:TD,czm_computePosition:ED,czm_cosineAndSine:bD,czm_decompressTextureCoordinates:SD,czm_defaultPbrMaterial:vD,czm_depthClamp:wD,czm_eastNorthUpToEyeCoordinates:DD,czm_ellipsoidContainsPoint:ID,czm_ellipsoidWgs84TextureCoordinates:PD,czm_equalsEpsilon:OD,czm_eyeOffset:MD,czm_eyeToWindowCoordinates:RD,czm_fastApproximateAtan:BD,czm_fog:LD,czm_gammaCorrect:ND,czm_geodeticSurfaceNormal:FD,czm_getDefaultMaterial:UD,czm_getLambertDiffuse:VD,czm_getSpecular:kD,czm_getWaterNoise:zD,czm_hue:HD,czm_inverseGamma:GD,czm_isEmpty:WD,czm_isFull:jD,czm_latitudeToWebMercatorFraction:qD,czm_lineDistance:YD,czm_linearToSrgb:XD,czm_luminance:KD,czm_metersPerPixel:JD,czm_modelToWindowCoordinates:ZD,czm_multiplyWithColorBalance:QD,czm_nearFarScalar:$D,czm_octDecode:eI,czm_packDepth:tI,czm_pbrLighting:nI,czm_pbrMetallicRoughnessMaterial:iI,czm_pbrSpecularGlossinessMaterial:rI,czm_phong:oI,czm_planeDistance:sI,czm_pointAlongRay:aI,czm_rayEllipsoidIntersectionInterval:cI,czm_raySphereIntersectionInterval:lI,czm_readDepth:uI,czm_readNonPerspective:fI,czm_reverseLogDepth:dI,czm_round:hI,czm_sampleOctahedralProjection:mI,czm_saturation:pI,czm_shadowDepthCompare:_I,czm_shadowVisibility:gI,czm_signNotZero:yI,czm_sphericalHarmonics:AI,czm_srgbToLinear:xI,czm_tangentToEyeSpaceMatrix:CI,czm_textureCube:TI,czm_transformPlane:EI,czm_translateRelativeToEye:bI,czm_translucentPhong:SI,czm_transpose:vI,czm_unpackDepth:wI,czm_unpackFloat:DI,czm_unpackUint:II,czm_valueTransform:PI,czm_vertexLogDepth:OI,czm_windowToEyeCoordinates:MI,czm_writeDepthClamp:RI,czm_writeLogDepth:BI,czm_writeNonPerspective:LI};function kve(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 NI=kve;function jQ(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(t){let n=t.match(/\n/gm).length,i="";for(let r=0;r<n;++r)i+=`
`;return i})}function qQ(e,t,n){let i;for(let r=0;r<n.length;++r)n[r].name===e&&(i=n[r]);return u(i)||(t=jQ(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function YQ(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,r){return n.indexOf(i)===r}),n.forEach(function(i){if(i!==e.name&&Ts._czmBuiltinsAndUniforms.hasOwnProperty(i)){let r=qQ(i,Ts._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(r),r.requiredBy.push(e),YQ(r,t)}}))}function zve(e){let t=[],n=[];for(;e.length>0;){let r=e.pop();n.push(r),r.requiredBy.length===0&&t.push(r)}for(;t.length>0;){let r=t.shift();e.push(r);for(let o=0;o<r.dependsOn.length;++o){let s=r.dependsOn[o],a=s.requiredBy.indexOf(r);s.requiredBy.splice(a,1),s.requiredBy.length===0&&t.push(s)}}let i=[];for(let r=0;r<n.length;++r)n[r].requiredBy.length!==0&&i.push(n[r])}function Hve(e){let t=[],n=qQ("main",e,t);YQ(n,t),zve(t);let i="";for(let r=t.length-1;r>=0;--r)i=`${i+t[r].glslSource}
`;return i.replace(n.glslSource,"")}function XQ(e,t,n){let i,r,o="",s=e.sources;if(u(s))for(i=0,r=s.length;i<r;++i)o+=`
#line 0
${s[i]}`;o=jQ(o);let a;o=o.replace(/#version\s+(.*?)\n/gm,function(A,x){return a=x,`
`});let c=[];o=o.replace(/#extension.*\n/gm,function(A){return c.push(A),`
`}),o=o.replace(/precision\s(lowp|mediump|highp)\s(float|int);/,"");let l=e.pickColorQualifier;u(l)&&(o=Ts.createPickFragmentShaderSource(o,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,r=p.length;i<r;++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=Hve(o)),f+=`
#line 0
`;let m=g+o;return n.webgl2&&t&&!/layout\s*\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g.test(m)&&!/czm_out_FragColor/g.test(m)&&/out_FragColor/g.test(m)&&(f+=`layout(location = 0) out vec4 out_FragColor;
`),f+=g,f+=o,n.webgl2?f=`#version 300 es
${f}`:f=NI(f,t),f}function Ts(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)}Ts.prototype.clone=function(){return new Ts({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};Ts.replaceMain=function(e,t){return t=`void ${t}()`,e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g,t)};Ts.prototype.getCacheKey=function(){let t=this.defines.slice().sort().join(","),n=this.pickColorQualifier,i=this.includeBuiltIns,r=this.sources.join(`
`);return`${t}:${n}:${i}:${r}`};Ts.prototype.createCombinedVertexShader=function(e){return XQ(this,!1,e)};Ts.prototype.createCombinedFragmentShader=function(e){return XQ(this,!0,e)};Ts._czmBuiltinsAndUniforms={};for(let e in k0)k0.hasOwnProperty(e)&&(Ts._czmBuiltinsAndUniforms[e]=k0[e]);for(let e in rp)if(rp.hasOwnProperty(e)){let t=rp[e];typeof t.getDeclaration=="function"&&(Ts._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}Ts.createPickVertexShaderSource=function(e){return`${Ts.replaceMain(e,"czm_old_main")}
in vec4 pickColor;
out vec4 czm_pickColor;
void main()
{
czm_old_main();
czm_pickColor = pickColor;
}`};Ts.createPickFragmentShaderSource=function(e,t){let n=Ts.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 Gve(e,t){let n=e.defines,i=n.length;for(let r=0;r<i;++r)if(n[r]===t)return!0;return!1}function KQ(e,t){let n=e.sources,i=n.length;for(let r=0;r<i;++r)if(n[r].indexOf(t)!==-1)return!0;return!1}function JQ(e,t){let n=t.length;for(let i=0;i<n;++i){let r=t[i];if(KQ(e,r))return r}}var Wve=["v_normalEC","v_normal"];Ts.findNormalVarying=function(e){return KQ(e,"#ifdef HAS_NORMALS")?Gve(e,"HAS_NORMALS")?"v_normalEC":void 0:JQ(e,Wve)};var jve=["v_positionEC"];Ts.findPositionVarying=function(e){return JQ(e,jve)};var He=Ts;var FI=`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 ug=`#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 ZQ={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};ZQ.NUMBER_OF_CLASSIFICATION_TYPES=3;var kn=Object.freeze(ZQ);var qve={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},Ga=Object.freeze(qve);function kh(){this.high=h.clone(h.ZERO),this.low=h.clone(h.ZERO)}kh.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 sp={high:0,low:0};kh.fromCartesian=function(e,t){u(t)||(t=new kh);let n=t.high,i=t.low;return kh.encode(e.x,sp),n.x=sp.high,i.x=sp.low,kh.encode(e.y,sp),n.y=sp.high,i.y=sp.low,kh.encode(e.z,sp),n.z=sp.high,i.z=sp.low,t};var x8=new kh;kh.writeElements=function(e,t,n){kh.fromCartesian(e,x8);let i=x8.high,r=x8.low;t[n]=i.x,t[n+1]=i.y,t[n+2]=i.z,t[n+3]=r.x,t[n+4]=r.y,t[n+5]=r.z};var Gn=kh;function Yve(e,t){let n=[],i=e.length,r=0;for(;r<i;){let o=Math.ceil((i-r)/t--);n.push(e.slice(r,r+o)),r+=o}return n}var UI=Yve;var Z3={STREAM_DRAW:te.STREAM_DRAW,STATIC_DRAW:te.STATIC_DRAW,DYNAMIC_DRAW:te.DYNAMIC_DRAW,validate:function(e){return e===Z3.STREAM_DRAW||e===Z3.STATIC_DRAW||e===Z3.DYNAMIC_DRAW}},Fe=Object.freeze(Z3);var Es={UNSIGNED_BYTE:te.UNSIGNED_BYTE,UNSIGNED_SHORT:te.UNSIGNED_SHORT,UNSIGNED_INT:te.UNSIGNED_INT};Es.getSizeInBytes=function(e){switch(e){case Es.UNSIGNED_BYTE:return Uint8Array.BYTES_PER_ELEMENT;case Es.UNSIGNED_SHORT:return Uint16Array.BYTES_PER_ELEMENT;case Es.UNSIGNED_INT:return Uint32Array.BYTES_PER_ELEMENT}};Es.fromSizeInBytes=function(e){switch(e){case 2:return Es.UNSIGNED_SHORT;case 4:return Es.UNSIGNED_INT;case 1:return Es.UNSIGNED_BYTE}};Es.validate=function(e){return u(e)&&(e===Es.UNSIGNED_BYTE||e===Es.UNSIGNED_SHORT||e===Es.UNSIGNED_INT)};Es.createTypedArray=function(e,t){return e>=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t):new Uint16Array(t)};Es.createTypedArrayFromArrayBuffer=function(e,t,n,i){return e>=P.SIXTY_FOUR_KILOBYTES?new Uint32Array(t,n,i):new Uint16Array(t,n,i)};Es.fromTypedArray=function(e){if(e instanceof Uint8Array)return Es.UNSIGNED_BYTE;if(e instanceof Uint16Array)return Es.UNSIGNED_SHORT;if(e instanceof Uint32Array)return Es.UNSIGNED_INT};var Ue=Object.freeze(Es);function Ju(e){e=y(e,y.EMPTY_OBJECT);let t=e.context._gl,n=e.bufferTarget,i=e.typedArray,r=e.sizeInBytes,o=e.usage,s=u(i);s&&(r=i.byteLength);let a=t.createBuffer();t.bindBuffer(n,a),t.bufferData(n,s?i:r,o),t.bindBuffer(n,null),this._id=Hn(),this._gl=t,this._webgl2=e.context._webgl2,this._bufferTarget=n,this._sizeInBytes=r,this._usage=o,this._buffer=a,this.vertexArrayDestroyable=!0}Ju.createVertexBuffer=function(e){return new Ju({context:e.context,bufferTarget:te.ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage})};Ju.createIndexBuffer=function(e){let t=e.context,n=e.indexDatatype,i=Ue.getSizeInBytes(n),r=new Ju({context:t,bufferTarget:te.ELEMENT_ARRAY_BUFFER,typedArray:e.typedArray,sizeInBytes:e.sizeInBytes,usage:e.usage}),o=r.sizeInBytes/i;return Object.defineProperties(r,{indexDatatype:{get:function(){return n}},bytesPerIndex:{get:function(){return i}},numberOfIndices:{get:function(){return o}}}),r};Object.defineProperties(Ju.prototype,{sizeInBytes:{get:function(){return this._sizeInBytes}},usage:{get:function(){return this._usage}}});Ju.prototype._getBuffer=function(){return this._buffer};Ju.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)};Ju.prototype.copyFromBuffer=function(e,t,n,i){let r=te.COPY_READ_BUFFER,o=te.COPY_WRITE_BUFFER,s=this._gl;s.bindBuffer(o,this._buffer),s.bindBuffer(r,e._buffer),s.copyBufferSubData(r,o,t,n,i),s.bindBuffer(o,null),s.bindBuffer(r,null)};Ju.prototype.getBufferData=function(e,t,n,i){t=y(t,0),n=y(n,0);let r=this._gl,o=te.COPY_READ_BUFFER;r.bindBuffer(o,this._buffer),r.getBufferSubData(o,t,e,n,i),r.bindBuffer(o,null)};Ju.prototype.isDestroyed=function(){return!1};Ju.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 lwe(e){return e===1?"float":`vec${e}`}function uwe(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function fwe(e,t){let i=e._attributes[t],r=i.componentsPerAttribute,o=i.functionName,s=lwe(r),a=uwe(r),c=e._offsets[t],l=`${s} ${o}(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}cp.prototype.getVertexShaderCallback=function(){let e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture;
`;t+=`${cwe(this)}
`;let n=e.length;for(let i=0;i<n;++i)t+=fwe(this,i);return function(i){let r=i.indexOf("void main"),o=i.substring(0,r),s=i.substring(r);return`${o}
${t}
${s}`}};cp.prototype.isDestroyed=function(){return!1};cp.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),ue(this)};var z0=cp;var or={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};or.getMathType=function(e){switch(e){case or.SCALAR:return Number;case or.VEC2:return H;case or.VEC3:return h;case or.VEC4:return oe;case or.MAT2:return nr;case or.MAT3:return Z;case or.MAT4:return N}};or.getNumberOfComponents=function(e){switch(e){case or.SCALAR:return 1;case or.VEC2:return 2;case or.VEC3:return 3;case or.VEC4:case or.MAT2:return 4;case or.MAT3:return 9;case or.MAT4:return 16}};or.getAttributeLocationCount=function(e){switch(e){case or.SCALAR:case or.VEC2:case or.VEC3:case or.VEC4:return 1;case or.MAT2:return 2;case or.MAT3:return 3;case or.MAT4:return 4}};or.getGlslType=function(e){switch(e){case or.SCALAR:return"float";case or.VEC2:return"vec2";case or.VEC3:return"vec3";case or.VEC4:return"vec4";case or.MAT2:return"mat2";case or.MAT3:return"mat3";case or.MAT4:return"mat4"}};var on=Object.freeze(or);var n$=1/256,i$=256,Er={};Er.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,r=n.y;n.x=(1-Math.abs(r))*P.signNotZero(i),n.y=(1-Math.abs(i))*P.signNotZero(r)}return n.x=P.toSNorm(n.x,t),n.y=P.toSNorm(n.y,t),n};Er.octEncode=function(e,t){return Er.octEncodeInRange(e,255,t)};var kI=new H,r$=new Uint8Array(1);function Q3(e){return r$[0]=e,r$[0]}Er.octEncodeToCartesian4=function(e,t){return Er.octEncodeInRange(e,65535,kI),t.x=Q3(kI.x*n$),t.y=Q3(kI.x),t.z=Q3(kI.y*n$),t.w=Q3(kI.y),t};Er.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 r=i.x;i.x=(1-Math.abs(i.y))*P.signNotZero(r),i.y=(1-Math.abs(r))*P.signNotZero(i.y)}return h.normalize(i,i)};Er.octDecode=function(e,t,n){return Er.octDecodeInRange(e,t,255,n)};Er.octDecodeFromCartesian4=function(e,t){let n=e.x,i=e.y,r=e.z,o=e.w,s=n*i$+i,a=r*i$+o;return Er.octDecodeInRange(s,a,65535,t)};Er.octPackFloat=function(e){return 256*e.x+e.y};var T8=new H;Er.octEncodeFloat=function(e){return Er.octEncode(e,T8),Er.octPackFloat(T8)};Er.octDecodeFloat=function(e,t){let n=e/256,i=Math.floor(n),r=(n-i)*256;return Er.octDecode(i,r,t)};Er.octPack=function(e,t,n,i){let r=Er.octEncodeFloat(e),o=Er.octEncodeFloat(t),s=Er.octEncode(n,T8);return i.x=65536*s.x+r,i.y=65536*s.y+o,i};Er.octUnpack=function(e,t,n,i){let r=e.x/65536,o=Math.floor(r),s=(r-o)*65536;r=e.y/65536;let a=Math.floor(r),c=(r-a)*65536;Er.octDecodeFloat(s,t),Er.octDecodeFloat(c,n),Er.octDecode(o,a,i)};Er.compressTextureCoordinates=function(e){let t=e.x*4095|0,n=e.y*4095|0;return 4096*t+n};Er.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)}Er.zigZagDeltaDecode=function(e,t,n){let i=e.length,r=0,o=0,s=0;for(let a=0;a<i;++a)r+=C8(e[a]),o+=C8(t[a]),e[a]=r,t[a]=o,u(n)&&(s+=C8(n[a]),n[a]=s)};Er.dequantize=function(e,t,n,i){let r=on.getNumberOfComponents(n),o;switch(t){case X.BYTE:o=127;break;case X.UNSIGNED_BYTE:o=255;break;case X.SHORT:o=32767;break;case X.UNSIGNED_SHORT:o=65535;break;case X.INT:o=2147483647;break;case X.UNSIGNED_INT:o=4294967295;break}let s=new Float32Array(i*r);for(let a=0;a<i;a++)for(let c=0;c<r;c++){let l=a*r+c;s[l]=Math.max(e[l]/o,-1)}return s};Er.decodeRGB565=function(e,t){let n=e.length;u(t)||(t=new Float32Array(n*3));let i=(1<<5)-1,r=(1<<6)-1,o=1/31,s=1/63;for(let a=0;a<n;a++){let c=e[a],l=c>>11,f=c>>5&r,d=c&i,p=3*a;t[p]=l*o,t[p+1]=f*s,t[p+2]=d*o}return t};var Wn=Er;var o$=new h,s$=new h,a$=new h;function dwe(e,t,n,i,r){u(r)||(r=new h);let o,s,a,c,l,f,d,p;if(u(t.z)){if(h.equalsEpsilon(e,t,P.EPSILON14))return h.clone(h.UNIT_X,r);if(h.equalsEpsilon(e,n,P.EPSILON14))return h.clone(h.UNIT_Y,r);if(h.equalsEpsilon(e,i,P.EPSILON14))return h.clone(h.UNIT_Z,r);o=h.subtract(n,t,o$),s=h.subtract(i,t,s$),a=h.subtract(e,t,a$),c=h.dot(o,o),l=h.dot(o,s),f=h.dot(o,a),d=h.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,""),r+=`uniform mat4 u_modifiedModelView;
`,o+=`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);
}
`:(o+=`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[r,o,t,s].join(`
`)};po._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};po._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 v$(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 w$(e){return`in vec4 v_pickColor;
${e}`}po._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};po._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),r=`vec4 $1 = czm_computePosition();
`;return r+=` if (czm_sceneMode == czm_sceneMode3D)
`,r+=` {
`,r+=" $1 = $1 + vec4(czm_batchTable_offset(batchId) * applyOffset, 0.0);",r+=` }
`,r+=` else
`,r+=` {
`,r+=" $1 = $1 + vec4(czm_batchTable_offset2D(batchId) * applyOffset, 0.0);",r+=` }
`,i=i.replace(/vec4\s+([A-Za-z0-9_]+)\s+=\s+czm_computePosition\(\);/g,r),i};po._appendDistanceDisplayConditionToShader=function(e,t,n){if(!u(e._batchTableAttributeIndices.distanceDisplayCondition))return t;let i=He.replaceMain(t,"czm_non_distanceDisplayCondition_main"),r=`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?r+=` vec4 centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);
`:r+=` 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);
}
`,r+=` 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}
${r}`};function D$(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 r=t.search(/in\s+vec3\s+tangent;/g)!==-1,o=t.search(/in\s+vec3\s+bitangent;/g)!==-1,s=i&&n?2:1;s+=r||o?1:0;let a=s>1?`vec${s}`:"float",c="compressedAttributes",l=`in ${a} ${c};`,f="",d="";if(i){f+=`vec2 st;
`;let m=s>1?`${c}.x`:c;d+=` st = czm_decompressTextureCoordinates(${m});
`}n&&r&&o?(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"}`:""});
`),r&&(f+=`vec3 tangent;
`,d+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"});
`),o&&(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 cDe(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 lDe(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 I$(e,t){let n=e.vertexAttributes}function uDe(e,t){return function(){return e[t]}}var N8=Math.max(kt.hardwareConcurrency-1,1),aU,fDe=new yi("combineGeometry");function dDe(e,t){let n,i,r,o,s=e._instanceIds;if(e._state===mo.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let a=e._numberOfInstances=n.length,c=[],l=[];for(r=0;r<a;++r)i=n[r].geometry,s.push(n[r].id),l.push({moduleName:i._workerName,geometry:i});if(!u(aU))for(aU=new Array(N8),r=0;r<N8;r++)aU[r]=new yi("createGeometry");let f;for(l=UI(l,N8),r=0;r<l.length;r++){let d=0,p=l[r],g=p.length;for(o=0;o<g;++o)f=p[o],i=f.geometry,u(i.constructor.pack)&&(f.offset=d,d+=y(i.constructor.packedLength,i.packedLength));let m;if(d>0){let A=new Float64Array(d);for(m=[A.buffer],o=0;o<g;++o)f=p[o],i=f.geometry,u(i.constructor.pack)&&(i.constructor.pack(i,A,f.offset),f.geometry=A)}c.push(aU[r].scheduleTask({subTasks:l[r]},m))}e._state=mo.CREATING,Promise.all(c).then(function(d){e._createGeometryResults=d,e._state=mo.CREATED}).catch(function(d){qI(e,t,mo.FAILED,d)})}else if(e._state===mo.CREATED){let a=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let c=t.scene3DOnly,l=t.mapProjection,f=fDe.scheduleTask(Y0.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=mo.COMBINING,Promise.resolve(f).then(function(d){let p=Y0.unpackCombineGeometryResults(d);e._geometries=p.geometries,e._attributeLocations=p.attributeLocations,e.modelMatrix=N.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=mo.COMBINED):qI(e,t,mo.FAILED,void 0)}).catch(function(d){qI(e,t,mo.FAILED,d)})}}function hDe(e,t){let n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,r=new Array(i),o=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=oDe(p):g=p.constructor.createGeometry(p),r[c++]=sDe(s,g),o.push(s.id)}r.length=c;let l=t.scene3DOnly,f=t.mapProjection,d=Y0.combineGeometry({instances:r,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=N.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=mo.COMBINED):qI(e,t,mo.FAILED,void 0)}function mDe(e,t){let n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!u(n)){e._recomputeBoundingSpheres=!1;return}let i,r=e._offsetInstanceExtend,o=e._instanceBoundingSpheres,s=o.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 h);A=o[i].clone(A),V$(A,x,r[i])}let c=[],l=[],f=[];for(i=0;i<s;++i){let A=a[i];A.center.x-A.radius>0||ae.intersectPlane(A,cn.ORIGIN_ZX_PLANE)!==Qt.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 m=[];for(u(d)&&m.push(d),u(p)&&m.push(p),u(g)&&m.push(g),i=0;i<m.length;i++){let A=m[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 $u(e,t,n){this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};let i=new U8;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;let r=new U8;if(r.requiresTextureCoordinates=e,n instanceof rn)i.requiresNormalEC=!n.flat;else{let o=`${n.material.shaderSource}
${n.fragmentShaderSource}`;i.normalEC=o.indexOf("materialInput.normalEC")!==-1||o.indexOf("czm_getDefaultMaterial")!==-1,i.positionToEyeEC=o.indexOf("materialInput.positionToEyeEC")!==-1,i.tangentToEyeMatrix=o.indexOf("materialInput.tangentToEyeMatrix")!==-1,i.st=o.indexOf("materialInput.st")!==-1}this._colorShaderDependencies=i,this._pickShaderDependencies=r,this._appearance=n,this._extentsCulling=e,this._planarExtents=t}$u.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 rn&&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 r="";return t instanceof rn||(r=t.material.shaderSource),new He({defines:i,sources:[r,TT]})};$u.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:[TT],pickColorQualifier:"in"})};$u.prototype.createVertexShader=function(e,t,n,i){return Y$(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};$u.prototype.createPickVertexShader=function(e,t,n,i){return Y$(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};var k$=new h,z$=new me,H$={high:0,low:0};function Y$(e,t,n,i,r,o,s,a){let c=i.slice();if(a.eastMostYhighDefine===""){let l=z$;l.longitude=P.PI,l.latitude=0,l.height=0;let f=s.project(l,k$),d=Gn.encode(f.x,H$);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=z$;p.longitude=-P.PI,p.latitude=0,p.height=0;let g=s.project(p,k$);d=Gn.encode(g.x,H$),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(o)&&o instanceof rn&&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:[r]})}function U8(){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(U8.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
`,o=` 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()
{
${o} czm_non_compressed_main();
}`;return[i,r,s,a].join(`
`)}}function XDe(e,t){let n=t.context,i=e._primitive,r=FI;r=e._primitive._batchTable.getVertexShaderCallback()(r),r=bn._appendDistanceDisplayConditionToShader(i,r),r=bn._modifyShaderPosition(e,r,t.scene3DOnly),r=bn._updateColorAttribute(i,r);let o=e._hasPlanarExtentsAttributes,s=o||e._hasSphericalExtentsAttribute;e._extruded&&(r=YDe(i,r));let a=e._extruded?"EXTRUDED_GEOMETRY":"",c=new He({defines:[a],sources:[r]}),l=new He({sources:[ug]}),f=e._primitive._attributeLocations,d=new nu(s,o,e.appearance);if(e._spStencil=Xt.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f}),e._primitive.allowPicking){let m=He.createPickVertexShaderSource(r);m=bn._appendShowToShader(i,m),m=bn._updatePickColorAttribute(m);let A=d.createPickFragmentShader(!1),x=d.createPickVertexShader([a],m,!1,t.mapProjection);if(e._spPick=Xt.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 E=d.createPickFragmentShader(!0),T=d.createPickVertexShader([a],m,!0,t.mapProjection);C=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:T,fragmentShaderSource:E,attributeLocations:f})}e._spPick2D=C}}else e._spPick=Xt.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f});r=bn._appendShowToShader(i,r),c=new He({defines:[a],sources:[r]}),e._sp=Xt.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:f});let p=d.createFragmentShader(!1),g=d.createVertexShader([a],r,!1,t.mapProjection);if(e._spColor=Xt.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:g,fragmentShaderSource:p,attributeLocations:f}),s){let m=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!u(m)){let A=d.createFragmentShader(!0),x=d.createVertexShader([a],r,!0,t.mapProjection);m=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:x,fragmentShaderSource:A,attributeLocations:f})}e._spColor2D=m}}function KDe(e,t){let n=e._primitive,i=n._va.length*2;t.length=i;let r,o,s,a=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap),l=e._needs2DShader;for(r=0;r<i;r+=2){let g=n._va[a++];o=t[r],u(o)||(o=t[r]=new nt({owner:e,primitiveType:n._primitiveType})),o.vertexArray=g,o.renderState=e._rsStencilDepthPass,o.shaderProgram=e._sp,o.uniformMap=c,o.pass=be.TERRAIN_CLASSIFICATION,s=nt.shallowClone(o,o.derivedCommands.tileset),s.renderState=e._rsStencilDepthPass3DTiles,s.pass=be.CESIUM_3D_TILE_CLASSIFICATION,o.derivedCommands.tileset=s,o=t[r+1],u(o)||(o=t[r+1]=new nt({owner:e,primitiveType:n._primitiveType})),o.vertexArray=g,o.renderState=e._rsColorPass,o.shaderProgram=e._spColor,o.pass=be.TERRAIN_CLASSIFICATION;let A=e.appearance.material;if(u(A)&&(c=mt(c,A._uniforms)),o.uniformMap=c,s=nt.shallowClone(o,o.derivedCommands.tileset),s.pass=be.CESIUM_3D_TILE_CLASSIFICATION,o.derivedCommands.tileset=s,l){let x=nt.shallowClone(o,o.derivedCommands.appearance2D);x.shaderProgram=e._spColor2D,o.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 m=f[g]=nt.shallowClone(t[p],f[g]);m.shaderProgram=d,m.pass=be.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,p+=2}}function JDe(e,t){let n=e._usePickOffsets,i=e._primitive,r=i._va.length*2,o,s=0,a;n&&(o=i._pickOffsets,r=o.length*2),t.length=r;let c,l,f,d=0,p=i._batchTable.getUniformMapCallback()(e._uniformMap),g=e._needs2DShader;for(c=0;c<r;c+=2){let m=i._va[d++];if(n&&(a=o[s++],m=i._va[a.index]),l=t[c],u(l)||(l=t[c]=new nt({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),l.vertexArray=m,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 JI=`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 QI=`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 $I=`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 iu=`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 e5=`${iu}
${$I}`,sPe=N0;kt.isInternetExplorer()||(e5=`#define CLIP_POLYLINE
${e5}`);function Z0(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=!1,i=Z0.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,e5),this._fragmentShaderSource=y(e.fragmentShaderSource,sPe),this._renderState=rr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Z0.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}}});Z0.VERTEX_FORMAT=Pe.POSITION_ONLY;Z0.prototype.getFragmentShaderSource=rr.prototype.getFragmentShaderSource;Z0.prototype.isTranslucent=rr.prototype.isTranslucent;Z0.prototype.getRenderState=rr.prototype.getRenderState;var Vo=Z0;var eP=`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 Q0=`#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 t5=`${iu}
${eP}`,aPe=Q0;kt.isInternetExplorer()||(t5=`#define CLIP_POLYLINE
${t5}`);function $0(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.translucent,!0),n=!1,i=$0.VERTEX_FORMAT;this.material=u(e.material)?e.material:qi.fromType(qi.ColorType),this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,t5),this._fragmentShaderSource=y(e.fragmentShaderSource,aPe),this._renderState=rr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties($0.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}}});$0.VERTEX_FORMAT=Pe.POSITION_AND_ST;$0.prototype.getFragmentShaderSource=rr.prototype.getFragmentShaderSource;$0.prototype.isTranslucent=rr.prototype.isTranslucent;$0.prototype.getRenderState=rr.prototype.getRenderState;var Ws=$0;function dp(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,r)=>{n._completeLoad=()=>{this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0);let o=this._error;u(o)?r(o):i(this)}}),this._primitive=void 0,this._sp=void 0,this._sp2D=void 0,this._spMorph=void 0,this._renderState=Bee(!1),this._renderState3DTiles=Bee(!0),this._renderStateMorph=Ve.fromCache({cull:{enabled:!0,face:gi.FRONT},depthTest:{enabled:!0},blending:ln.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(dp.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}}});dp.initializeTerrainHeights=function(){return oi.initialize()};function cPe(e,t,n){let i=t.context,r=e._primitive,o=r._attributeLocations,s=r._batchTable.getVertexShaderCallback()(QI);s=bn._appendShowToShader(r,s),s=bn._appendDistanceDisplayConditionToShader(r,s),s=bn._modifyShaderPosition(e,s,t.scene3DOnly);let a=r._batchTable.getVertexShaderCallback()(ZI);a=bn._appendShowToShader(r,a),a=bn._appendDistanceDisplayConditionToShader(r,a),a=bn._modifyShaderPosition(e,a,t.scene3DOnly);let c=r._batchTable.getVertexShaderCallback()(KI),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]}),m=new He({defines:p,sources:[d,c]});e._sp=Xt.replaceCache({context:i,shaderProgram:r._sp,vertexShaderSource:g,fragmentShaderSource:m,attributeLocations:o});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:m,attributeLocations:o})}e._sp2D=A;let x=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!u(x)){let C=new He({defines:l.concat([`MAX_TERRAIN_HEIGHT ${oi._defaultMaxTerrainHeight.toFixed(1)}`]),sources:[a]});c=r._batchTable.getVertexShaderCallback()(JI
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 TP=`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 EP=`in vec4 position;
in vec3 cubeMapCoordinates;
out vec3 v_cubeMapCoordinates;
void main()
{
gl_Position = position;
v_cubeMapCoordinates = cubeMapCoordinates;
}
`;function dA(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 ge}Object.defineProperties(dA.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}}});dA.isSupported=function(e){return e.colorBufferHalfFloat&&e.halfFloatingPointTexture||e.floatingPointTexture&&e.colorBufferFloat};var A1e=new h(1,0,0),x1e=new h(0,0,1),C1e=new h(-1,0,0),T1e=new h(0,0,-1),xU=new h(0,1,0),E1e=new h(0,-1,0),ote=[xU,C1e,x1e,E1e,A1e,xU,T1e,xU,xU],ste=ote.length,ate=new Float32Array(ste*3),ite=0;for(let e=0;e<ste;++e,ite+=3)h.pack(ote[e],ate,ite);var b1e=new Float32Array([-1,1,-1,0,0,1,0,0,1,0,1,1,0,-1,-1,-1,1,-1]),S1e=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 v1e(e){let t=ft.createVertexBuffer({context:e,typedArray:b1e,usage:Fe.STATIC_DRAW}),n=ft.createVertexBuffer({context:e,typedArray:ate,usage:Fe.STATIC_DRAW}),i=ft.createIndexBuffer({context:e,typedArray:S1e,usage:Fe.STATIC_DRAW,indexDatatype:Ue.UNSIGNED_SHORT}),r=[{index:0,vertexBuffer:t,componentsPerAttribute:2,componentDatatype:X.FLOAT},{index:1,vertexBuffer:n,componentsPerAttribute:3,componentDatatype:X.FLOAT}];return new si({context:e,attributes:r,indexBuffer:i})}function rte(e){return function(){return e}}function p5(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 r=e._mipTextures;if(u(r))for(n=r.length,t=0;t<n;++t)r[t].destroy();e._va=void 0,e._sp=void 0,e._cubeMaps=void 0,e._cubeMapBuffers=void 0,e._mipTextures=void 0}dA.prototype.update=function(e){let t=e.context;if(!dA.isSupported(t)||(u(this._texture)&&u(this._va)&&p5(this),u(this._texture)))return;if(!u(this._texture)&&!this._loading){let g=e.context.textureCache.getTexture(this._url);u(g)&&(p5(this),this._texture=g,this._maximumMipmapLevel=this._texture.maximumMipmapLevel,this._ready=!0)}let n=this._cubeMapBuffers;if(!u(n)&&!this._loading){let g=this;ml(this._url).then(function(m){g._cubeMapBuffers=m,g._loading=!1}).catch(function(m){g.isDestroyed()||g._errorEvent.raiseEvent(m)}),this._loading=!0}if(!u(this._cubeMapBuffers))return;let i=[],r=n[0].positiveX.pixelDatatype;u(r)?i.push("RGBA_NORMALIZED"):r=t.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT;let o=st.RGBA,s=new He({defines:i,sources:[TP]});this._va=v1e(t),this._sp=Xt.fromCache({context:t,vertexShaderSource:EP,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 m=n[g].positiveY;n[g].positiveY=n[g].negativeY,n[g].negativeY=m;let A=c[g]=new za({context:t,source:n[g],pixelDatatype:r}),x=c[g].width*2,C=l[g]=new Ot({context:t,width:x,height:x,pixelDatatype:r,pixelFormat:o}),E=new nf({vertexArray:this._va,shaderProgram:this._sp,uniformMap:{cubeMap:rte(A)},outputTexture:C,persists:!0,owner:this});e.commandList.push(E),d[`texture${g}`]=rte(C)}this._texture=new Ot({context:t,width:f*1.5+2,height:f,pixelDatatype:r,pixelFormat:o}),this._texture.maximumMipmapLevel=this._maximumMipmapLevel,t.textureCache.addTexture(this._url,this._texture);let p=new nf({fragmentShaderSource:CP,uniformMap:d,outputTexture:this._texture,persists:!1,owner:this});e.commandList.push(p),this._ready=!0};dA.prototype.isDestroyed=function(){return!1};dA.prototype.destroy=function(){return p5(this),this._texture=this._texture&&this._texture.destroy(),ue(this)};var Ad=dA;function bP(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));
}
`}pr.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;let i=this;return function(r){let o=yte(r,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});
}`,`${o}
${oOe(i)}${s}`}};function _te(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 sOe(e,t){let n=`texture(${t}`,i=0,r=e.indexOf(n,i),o;for(;r>-1;){let s=0;for(let l=r;l<e.length;++l){let f=e.charAt(l);if(f==="(")++s;else if(f===")"&&(--s,s===0)){o=l+1;break}}let c=`tile_diffuse_final(${e.slice(r,o)}, tile_diffuse)`;e=e.slice(0,r)+c+e.slice(o),i=r+c.length,r=e.indexOf(n,i)}return e}function yte(e,t,n){if(!u(t))return _te(e,n);let i=new RegExp(`(uniform|attribute|in)\\s+(vec[34]|sampler2D)\\s+${t};`),r=e.match(i);if(!u(r))return _te(e,n);let o=r[0],s=r[2];e=He.replaceMain(e,"tile_main"),e=e.replace(o,"");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=sOe(e,t),l=` tile_diffuse = tile_featureColor;
tile_main();
`);return e=`uniform float tile_colorBlend;
vec4 tile_diffuse = vec4(1.0);
${a}${o}
${e}
void tile_color(vec4 tile_featureColor)
{
${l}`,n&&(e+=c),e+=`}
`,e}pr.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=yte(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}};pr.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 aOe(e){let t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n===Cl.HIGHLIGHT)return 0;if(n===Cl.REPLACE)return 1;if(n===Cl.MIX)return P.clamp(i,P.EPSILON4,1)}pr.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;let e=this;return function(t){return mt(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 aOe(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};pr.prototype.getPickId=function(){return"texture(tile_pickTexture, tile_featureSt)"};var Ag={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};pr.prototype.addDerivedCommands=function(e,t){let n=e.commandList,i=n.length,r=this._content._tile,o=r._finalResolution,s=r.tileset,a=s.isSkippingLevelOfDetail&&s.hasMixedContent&&e.context.stencilBuffer,c=cOe(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=lOe(f),f.dirty=!1);let p=d.originalCommand;c!==Ag.ALL_OPAQUE&&f.pass!==be.TRANSLUCENT&&(u(d.translucent)||(d.translucent=uOe(p))),c!==Ag.ALL_TRANSLUCENT&&f.pass!==be.TRANSLUCENT&&(u(d.opaque)||(d.opaque=fOe(p)),a&&(o||(u(d.zback)||(d.zback=hOe(e.context,p)),s._backfaceCommands.push(d.zback)),(!u(d.stencil)||r._selectionDepth!==pOe(d.stencil))&&(f.renderState.depthMask?d.stencil=mOe(p,r._selectionDepth):d.stencil=d.opaque)));let g=a?d.stencil:d.opaque,m=d.translucent;f.pass!==be.TRANSLUCENT?(c===Ag.ALL_OPAQUE&&(n[l]=g),c===Ag.ALL_TRANSLUCENT&&(n[l]=m),c===Ag.OPAQUE_AND_TRANSLUCENT&&(n[l]=g,n.push(m))):n[l]=p}};function cOe(e){let t=e._batchTexture.translucentFeaturesLength;return t===0?Ag.ALL_OPAQUE:t===e.featuresLength?Ag.ALL_TRANSLUCENT:Ag.OPAQUE_AND_TRANSLUCENT}function lOe(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 uOe(e){let t=nt.shallowClone(e);return t.pass=be.TRANSLUCENT,t.renderState=_Oe(e.renderState),t}function fOe(e){let t=nt.shallowClone(e);return t.renderState=gOe(e.renderState),t}function dOe(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 hOe(e,t){let n=nt.shallowClone(t),i=je(n.renderState,!0);i.cull.enabled=!0,i.cull.face=gi.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=Ve.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=je(t.uniformMap);let r=new H(5,5);return n.uniformMap.u_polygonOffset=function(){return r},n.shaderProgram=dOe(e,t.shaderProgram),n}function mOe(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=dt.REPLACE,i.stencilTest.backFunction=zn.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=dt.REPLACE,i.stencilMask=Lt.CESIUM_3D_TILE_MASK|Lt.SKIP_LOD_MASK,n.renderState=Ve.fromCache(i),n}function pOe(e){return(e.renderState.stencilTest.reference&Lt.SKIP_LOD_MASK)>>>Lt.SKIP_LOD_BIT_SHIFT}function _Oe(e){let t=je(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=ln.ALPHA_BLEND,t.stencilTest=Lt.setCesium3DTileBit(),t.stencilMask=Lt.CESIUM_3D_TILE_MASK,Ve.fromCache(t)}function gOe(e){let t=je(e,!0);return t.stencilTest=Lt.setCesium3DTileBit(),t.stencilMask=Lt.CESIUM_3D_TILE_MASK,Ve.fromCache(t)}pr.prototype.update=function(e,t){this._batchTexture.update(e,t)};pr.prototype.isDestroyed=function(){return!1};pr.prototype.destroy=function(){return this._batchTexture=this._batchTexture&&this._batchTexture.destroy(),ue(this)};var Tp=pr;function yOe(e){this.offset=e.offset,this.count=e.count,this.color=e.color,this.batchIds=e.batchIds}var jh=yOe;var MT=`in vec3 position;
in float a_batchId;
uniform mat4 u_modifiedModelViewProjection;
void main()
{
gl_Position = czm_depthClamp(u_modifiedModelViewProjection * vec4(position, 1.0));
}
`;function of(e,t){this._content=e,this._batchId=t,this._color=void 0}Object.defineProperties(of.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 z),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)}}});of.prototype.hasProperty=function(e){return this._content.batchTable.hasProperty(this._batchId,e)};of.prototype.getPropertyIds=function(e){return this._content.batchTable.getPropertyIds(this._batchId,e)};of.prototype.getProperty=function(e){return this._content.batchTable.getProperty(this._batchId,e)};of.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 r=e.metadata;if(u(r)){if(r.hasPropertyBySemantic(n))return r.getPropertyBySemantic(n);if(r.hasProperty(n))return r.getProperty(n)}let o=e.tile,s=o.metadata;if(u(s)){if(s.hasPropertyBySemantic(n))return s.getPropertyBySemantic(n);if(s.hasProperty(n))return s.getProperty(n)}let a;if(u(o.implicitSubtree)&&(a=o.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)}};of.prototype.getPropertyInherited=function(e){return of.getPropertyInherited(this._content,this._batchId,e)};of.prototype.setProperty=function(e,t){this._content.batchTable.setProperty(this._batchId,e,t),this._content.featurePropertiesDirty=!0};of.prototype.isExactClass=function(e){return this._content.batchTable.isExactClass(this._batchId,e)};of.prototype.isClass=function(e){return this._content.batchTable.isClass(this._batchId,e)};of.prototype.getExactClassName=function(){return this._content.batchTable.getExactClassName(this._batchId)};var bs=of;var C5=class{add(t,n,i){if(typeof arguments[0]!="string")for(let r in arguments[0])this.add(r,arguments[0][r],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(r){this[r]=this[r]||[],n&&this[r][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)})}},T5=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+=o}else t+=o}return r||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,r=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===t){i=!0,this.index++,t===Ge.CPAREN_CODE&&r&&r>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(o===Ge.COMMA_CODE){if(this.index++,r++,r!==n.length){if(t===Ge.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===Ge.CBRACK_CODE)for(let s=n.length;s<r;s++)n.push(null)}}else if(n.length!==r&&r!==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)}}},AOe=new C5;Object.assign(Ge,{hooks:AOe,plugins:new T5(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 xg=e=>new Ge(e).parse(),xOe=Object.getOwnPropertyNames(Ge);xOe.forEach(e=>{xg[e]===void 0&&e!=="prototype"&&(xg[e]=Ge[e])});xg.Jsep=Ge;var COe="ConditionalExpression",TOe={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,r=this.gobbleExpression();if(r||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),n.node={type:COe,test:i,consequent:r,alternate:o},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 :")}})}};xg.plugins.register(TOe);var EOe={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(EOe);function Ed(e,t){this._expression=e,e=NOe(e,t),e=UOe(FOe(e)),xg.addBinaryOp("=~",0),xg.addBinaryOp("!~",0);let n;try{n=xg(e)}catch(i){throw new de(i)}this._runtimeAst=Ei(this,n)}Object.defineProperties(Ed.prototype,{expression:{get:function(){return this._expression}}});var On={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new H],cartesian3Array:[new h],cartesian4Array:[new oe],reset:function(){this.arrayIndex=0,this.cartesian2Index=0,this.cartesian3Index=0,this.cartesian4I
{
return ${r};
}
`,r};Ed.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};Ed.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};var bOe=["!","-","+"],Ate=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],SU=/\${(.*?)}/g,SOe=/\\/g,vOe="@#%",wOe=/@#%/g,vU=new z,wU={abs:Ss(Math.abs),sqrt:Ss(Math.sqrt),cos:Ss(Math.cos),sin:Ss(Math.sin),tan:Ss(Math.tan),acos:Ss(Math.acos),asin:Ss(Math.asin),atan:Ss(Math.atan),radians:Ss(P.toRadians),degrees:Ss(P.toDegrees),sign:Ss(P.sign),floor:Ss(Math.floor),ceil:Ss(Math.ceil),round:Ss(Math.round),exp:Ss(Math.exp),exp2:Ss(IOe),log:Ss(Math.log),log2:Ss(POe),fract:Ss(DOe),length:OOe,normalize:MOe},DU={atan2:EU(Math.atan2,!1),pow:EU(Math.pow,!1),min:EU(Math.min,!0),max:EU(Math.max,!0),distance:ROe,dot:BOe,cross:LOe},S5={clamp:xte(P.clamp,!0),mix:xte(P.lerp,!0)};function DOe(e){return e-Math.floor(e)}function IOe(e){return Math.pow(2,e)}function POe(e){return P.log2(e)}function Ss(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),On.getCartesian2());if(n instanceof h)return h.fromElements(e(n.x),e(n.y),e(n.z),On.getCartesian3());if(n instanceof oe)return oe.fromElements(e(n.x),e(n.y),e(n.z),e(n.w),On.getCartesian4());throw new de(`Function "${t}" requires a vector or number argument. Argument is ${n}.`)}}function EU(e,t){return function(n,i,r){if(t&&typeof r=="number"){if(typeof i=="number")return e(i,r);if(i instanceof H)return H.fromElements(e(i.x,r),e(i.y,r),On.getCartesian2());if(i instanceof h)return h.fromElements(e(i.x,r),e(i.y,r),e(i.z,r),On.getCartesian3());if(i instanceof oe)return oe.fromElements(e(i.x,r),e(i.y,r),e(i.z,r),e(i.w,r),On.getCartesian4())}if(typeof i=="number"&&typeof r=="number")return e(i,r);if(i instanceof H&&r instanceof H)return H.fromElements(e(i.x,r.x),e(i.y,r.y),On.getCartesian2());if(i instanceof h&&r instanceof h)return h.fromElements(e(i.x,r.x),e(i.y,r.y),e(i.z,r.z),On.getCartesian3());if(i instanceof oe&&r instanceof oe)return oe.fromElements(e(i.x,r.x),e(i.y,r.y),e(i.z,r.z),e(i.w,r.w),On.getCartesian4());throw new de(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i} and ${r}.`)}}function xte(e,t){return function(n,i,r,o){if(t&&typeof o=="number"){if(typeof i=="number"&&typeof r=="number")return e(i,r,o);if(i instanceof H&&r instanceof H)return H.fromElements(e(i.x,r.x,o),e(i.y,r.y,o),On.getCartesian2());if(i instanceof h&&r instanceof h)return h.fromElements(e(i.x,r.x,o),e(i.y,r.y,o),e(i.z,r.z,o),On.getCartesian3());if(i instanceof oe&&r instanceof oe)return oe.fromElements(e(i.x,r.x,o),e(i.y,r.y,o),e(i.z,r.z,o),e(i.w,r.w,o),On.getCartesian4())}if(typeof i=="number"&&typeof r=="number"&&typeof o=="number")return e(i,r,o);if(i instanceof H&&r instanceof H&&o instanceof H)return H.fromElements(e(i.x,r.x,o.x),e(i.y,r.y,o.y),On.getCartesian2());if(i instanceof h&&r instanceof h&&o instanceof h)return h.fromElements(e(i.x,r.x,o.x),e(i.y,r.y,o.y),e(i.z,r.z,o.z),On.getCartesian3());if(i instanceof oe&&r instanceof oe&&o instanceof oe)return oe.fromElements(e(i.x,r.x,o.x),e(i.y,r.y,o.y),e(i.z,r.z,o.z),e(i.w,r.w,o.w),On.getCartesian4());throw new de(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i}, ${r}, and ${o}.`)}}function OOe(e,t){if(typeof t=="number")return Math.abs(t);if(t instanceof H)return H.magnitude(t);if(t instanceof h)return h.magnitude(t);if(t instanceof oe)return oe.magnitude(t);throw new de(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function MOe(e,t){if(typeof t=="number")return 1;if(t instanceof H)return H.normalize(t,On.getCartesian2());if(t instanceof h)return h.normalize(t,On.getCartesian3());if(t instanceof oe)return oe.normalize(t,On.getCartesian4());throw new de(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function ROe(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 = ${r};
}
`,e._spPick=Xt.fromCache({context:t,vertexShaderSource:o,fragmentShaderSource:s,attributeLocations:i});return}let a=n.getVertexShaderCallback(!1,"a_batchId",void 0)(MT),c=n.getFragmentShaderCallback(!1,void 0,!0)(ug);r=n.getPickId();let l=new He({sources:[a]}),f=new He({defines:["VECTOR_TILE"],sources:[c]});e._sp=Xt.fromCache({context:t,vertexShaderSource:l,fragmentShaderSource:f,attributeLocations:i}),l=new He({sources:[MT]}),f=new He({defines:["VECTOR_TILE"],sources:[ug]}),e._spStencil=Xt.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 = ${r};
}
`;let d=new He({sources:[a]}),p=new He({defines:["VECTOR_TILE"],sources:[c]});e._spPick=Xt.fromCache({context:t,vertexShaderSource:d,fragmentShaderSource:p,attributeLocations:i})}function Ste(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:dt.KEEP,zFail:dt.DECREMENT_WRAP,zPass:dt.KEEP},backFunction:t,backOperation:{fail:dt.KEEP,zFail:dt.INCREMENT_WRAP,zPass:dt.KEEP},reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Ga.LESS_OR_EQUAL},depthMask:!1}}var iMe={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:ln.PRE_MULTIPLIED_ALPHA_BLEND},rMe={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function oMe(e){u(e._rsStencilDepthPass)||(e._rsStencilDepthPass=Ve.fromCache(Ste(!1)),e._rsStencilDepthPass3DTiles=Ve.fromCache(Ste(!0)),e._rsColorPass=Ve.fromCache(iMe),e._rsPickPass=Ve.fromCache(rMe))}var yA=new N,vte=new h;function sMe(e,t){if(u(e._uniformMap))return;let n={u_modifiedModelViewProjection:function(){let i=t.uniformState.view,r=t.uniformState.projection;return N.clone(i,yA),N.multiplyByPoint(yA,e._center,vte),N.setTranslation(yA,vte,yA),N.multiply(r,yA,yA),yA},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function v5(e,t,n,i,r,o,s){let a=e.constructor.BYTES_PER_ELEMENT,c=o.length;for(let l=0;l<c;++l){let f=o[l],d=s[f],p=i[d],g=r[d],m=new e.constructor(e.buffer,a*p,g);t.set(m,n),i[d]=n,n+=g}return n}function aMe(e,t){let n=e._indices,i=e._indexOffsets,r=e._indexCounts,o=e._batchIdLookUp,s=new n.constructor(n.length),a=t.pop(),c=[a],l=v5(n,s,0,i,r,a.batchIds,o);for(a.offset=0,a.count=l;t.length>0;){let f=t.pop();if(z.equals(f.color,a.color))l=v5(n,s,l,i,r,f.batchIds,o),a.batchIds=a.batchIds.concat(f.batchIds),a.count=l-a.offset;else{let d=l;l=v5(n,s,l,i,r,f.batchIds,o),f.offset=d,f.count=l-d,c.push(f),a=f}}e._va.indexBuffer.copyFromArrayView(s),e._indices=s,e._batchedIndices=c}function w5(e,t,n,i,r,o,s){let a=e.bytesPerIndex,c=o.length;for(let l=0;l<c;++l){let f=o[l],d=s[f],p=i[d],g=r[d];t.copyFromBuffer(e,p*a,n*a,g*a),i[d]=n,n+=g}return n}function cMe(e,t){let n=e._indexOffsets,i=e._indexCounts,r=e._batchIdLookUp,o=t.pop(),s=[o],a=e._va.indexBuffer,c=e._vaSwap.indexBuffer,l=w5(a,c,0,n,i,o.batchIds,r);for(o.offset=0,o.count=l;t.length>0;){let d=t.pop();if(z.equals(d.color,o.color))l=w5(a,c,l,n,i,d.batchIds,r),o.batchIds=o.batchIds.concat(d.batchIds),o.count=l-o.offset;else{let p=l;l=w5(a,c,l,n,i,d.batchIds,r),d.offset=p,d.count=l-p,s.push(d),o=d}}let f=e._va;e._va=e._vaSwap,e._vaSwap=f,e._batchedIndices=s}function lMe(e,t){return t.color.toRgba()-e.color.toRgba()}function uMe(e,t){if(!e._batchDirty)return!1;let n=e._batchedIndices,i=n.length,r=!1,o={};for(let s=0;s<i;++s){let c=n[s].color.toRgba();if(u(o[c])){r=!0;break}else o[c]=!0}if(!r)return e._batchDirty=!1,!1;if(r&&!e.forceRebatch&&e._framesSinceLastRebatch<120){++e._framesSinceLastRebatch;return}return n.sort(lMe),t.webgl2?cMe(e,n):aMe(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function fMe(e,t){let n=uMe(e,t),i=e._commands,r=e._batchedIndices,o=r.length,s=o*2;if(u(i)&&!n&&i.length===s)return;i.length=s;let a=e._va,c=e._sp,l=y(e._modelMatrix,N.IDENTITY),f=e._uniformMap,d=e._boundingVolume;for(let p=0;p<o;++p){let g=r[p].offset,m=r[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=m,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};vg.prototype.isDestroyed=function(){return!1};vg.prototype.destroy=function(){return this.unload(),ue(this)};var ar=vg;var pRe={UNLOADED:0,LOADING:1,LOADED:2,PROCESSING:3,READY:4,FAILED:5},St=Object.freeze(pRe);function Ip(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)&&(Ip.prototype=Object.create(ar.prototype),Ip.prototype.constructor=Ip);Object.defineProperties(Ip.prototype,{cacheKey:{get:function(){return this._cacheKey}},typedArray:{get:function(){return this._typedArray}}});Ip.prototype.load=async function(){return u(this._promise)?this._promise:u(this._typedArray)?(this._promise=Promise.resolve(this),this._promise):(this._promise=_Re(this),this._promise)};async function _Re(e){let t=e._resource;e._state=St.LOADING;try{let n=await Ip._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)}}Ip._fetchArrayBuffer=function(e){return e.fetchArrayBuffer()};Ip.prototype.unload=function(){this._typedArray=void 0};var TA=Ip;var Zte=Wi(Jte(),1);function EA(e){e=y(e,y.EMPTY_OBJECT);let t=e.resourceCache,n=e.gltf,i=e.bufferViewId,r=e.gltfResource,o=e.baseResource,s=e.cacheKey,a=n.bufferViews[i],c=a.buffer,l=a.byteOffset,f=a.byteLength,d=!1,p,g,m,A;if(ni(a,"EXT_meshopt_compression")){let C=a.extensions.EXT_meshopt_compression;c=C.buffer,l=y(C.byteOffset,0),f=C.byteLength,d=!0,p=C.byteStride,g=C.count,m=C.mode,A=y(C.filter,"NONE")}let x=n.buffers[c];this._hasMeshopt=d,this._meshoptByteStride=p,this._meshoptCount=g,this._meshoptMode=m,this._meshoptFilter=A,this._resourceCache=t,this._gltfResource=r,this._baseResource=o,this._buffer=x,this._bufferId=c,this._byteOffset=l,this._byteLength=f,this._cacheKey=s,this._bufferLoader=void 0,this._typedArray=void 0,this._state=St.UNLOADED,this._promise=void 0}u(Object.create)&&(EA.prototype=Object.create(ar.prototype),EA.prototype.constructor=EA);Object.defineProperties(EA.prototype,{cacheKey:{get:function(){return this._cacheKey}},typedArray:{get:function(){return this._typedArray}}});async function xRe(e){try{let t=CRe(e);if(e._bufferLoader=t,await t.load(),e.isDestroyed())return;let n=t.typedArray,i=new Uint8Array(n.buffer,n.byteOffset+e._byteOffset,e._byteLength);if(e.unload(),e._typedArray=i,e._hasMeshopt){let r=e._meshoptCount,o=e._meshoptByteStride,s=new Uint8Array(r*o);Zte.MeshoptDecoder.decodeGltfBuffer(s,r,o,e._typedArray,e._meshoptMode,e._meshoptFilter),e._typedArray=s}return e._state=St.READY,e}catch(t){if(e.isDestroyed())return;e.unload(),e._state=St.FAILED;let n="Failed to load buffer view";throw e.getError(n,t)}}EA.prototype.load=async function(){return u(this._promise)?this._promise:(this._state=St.LOADING,this._promise=xRe(this),this._promise)};function CRe(e){let t=e._resourceCache,n=e._buffer;if(u(n.uri)){let r=e._baseResource.getDerivedResource({url:n.uri});return t.getExternalBufferLoader({resource:r})}return t.getEmbeddedBufferLoader({parentResource:e._gltfResource,bufferId:e._bufferId})}EA.prototype.unload=function(){u(this._bufferLoader)&&!this._bufferLoader.isDestroyed()&&this._resourceCache.unload(this._bufferLoader),this._bufferLoader=void 0,this._typedArray=void 0};var FT=EA;function Ya(){}Ya._maxDecodingConcurrency=Math.max(kt.hardwareConcurrency-1,1);Ya._decoderTaskProcessor=void 0;Ya._taskProcessorReady=!1;Ya._getDecoderTaskProcessor=function(){if(!u(Ya._decoderTaskProcessor)){let e=new yi("decodeDraco",Ya._maxDecodingConcurrency);e.initWebAssemblyModule({modulePath:"ThirdParty/Workers/draco_decoder_nodejs.js",wasmBinaryFile:"ThirdParty/draco_decoder.wasm"}).then(function(){Ya._taskProcessorReady=!0}),Ya._decoderTaskProcessor=e}return Ya._decoderTaskProcessor};Ya.decodePointCloud=function(e){let t=Ya._getDecoderTaskProcessor();if(Ya._taskProcessorReady)return t.scheduleTask(e,[e.buffer.buffer])};Ya.decodeBufferView=function(e){let t=Ya._ge
${n.message}`);let r=new de(i);return u(n)&&(r.stack=`Original stack:
${n.stack}
Handler stack:
${r.stack}`),r};Qa.getNodeTransform=function(e){return u(e.matrix)?e.matrix:N.fromTranslationQuaternionRotationScale(u(e.translation)?e.translation:h.ZERO,u(e.rotation)?e.rotation:Le.IDENTITY,u(e.scale)?e.scale:h.ONE)};Qa.getAttributeBySemantic=function(e,t,n){let i=e.attributes,r=i.length;for(let o=0;o<r;++o){let s=i[o],a=u(n)?s.setIndex===n:!0;if(s.semantic===t&&a)return s}};Qa.getAttributeByName=function(e,t){let n=e.attributes,i=n.length;for(let r=0;r<i;++r){let o=n[r];if(o.name===t)return o}};Qa.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}};Qa.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};Qa.getAttributeInfo=function(e){let t=e.semantic,n=e.setIndex,i,r=!1;u(t)?(i=Tt.getVariableName(t,n),r=!0):(i=e.name,i=i.replace(/^_/,""),i=i.toLowerCase());let o=/^color_\d+$/.test(i),s=e.type,a=on.getGlslType(s);o&&(a="vec4");let c=u(e.quantization),l;return c&&(l=o?"vec4":on.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:r,glslType:a,quantizedGlslType:l}};var BNe=new h,LNe=new h;Qa.getPositionMinMax=function(e,t,n){let i=Qa.getAttributeBySemantic(e,"POSITION"),r=i.max,o=i.min;return u(n)&&u(t)&&(o=h.add(o,t,LNe),r=h.add(r,n,BNe)),{min:o,max:r}};Qa.getAxisCorrectionMatrix=function(e,t,n){return n=N.clone(N.IDENTITY,n),e===mr.Y?n=N.clone(mr.Y_UP_TO_Z_UP,n):e===mr.X&&(n=N.clone(mr.X_UP_TO_Z_UP,n)),t===mr.Z&&(n=N.multiplyTransformation(n,mr.Z_UP_TO_X_UP,n)),n};var NNe=new Z;Qa.getCullFace=function(e,t){if(!Be.isTriangles(t))return gi.BACK;let n=N.getMatrix3(e,NNe);return Z.determinant(n)<0?gi.FRONT:gi.BACK};Qa.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^\d/.test(t)&&(t=`_${t}`),t};Qa.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};Qa.checkSupportedExtensions=function(e){let t=e.length;for(let n=0;n<t;n++){let i=e[n];if(!Qa.supportedExtensions[i])throw new de(`Unsupported glTF Extension: ${i}`)}};var Jt=Qa;var XT={TRANSLATION:"TRANSLATION",ROTATION:"ROTATION",SCALE:"SCALE",FEATURE_ID:"_FEATURE_ID"};XT.fromGltfSemantic=function(e){let t=e,i=/^(\w+)_\d+$/.exec(e);switch(i!==null&&(t=i[1]),t){case"TRANSLATION":return XT.TRANSLATION;case"ROTATION":return XT.ROTATION;case"SCALE":return XT.SCALE;case"_FEATURE_ID":return XT.FEATURE_ID}};var Go=Object.freeze(XT);var FNe=65534,UNe=255;function KU(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 jne(n,i),this._outlineCoordinatesTypedArray=void 0,this._extraVertices=[],VNe(this)}Object.defineProperties(KU.prototype,{updatedTriangleIndices:{get:function(){return this._triangleIndices}},outlineCoordinates:{get:function(){return this._outlineCoordinatesTypedArray}}});function VNe(e){let t=e._triangleIndices,n=e._edges,i=[],r=e._extraVertices,o=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),m=d||n.hasEdge(f,c),A=Gne(i,c,l,f,p,g,m);for(;u(A);){let x=s[A];if(!u(x)){x=o+r.length;let C=A;for(;C>=o;)C=r[C-o];r.push(C),s[A]=x}x>FNe&&(t instanceof Uint16Array||t instanceof Uint8Array)?t=new Uint32Array(t):x>UNe&&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=Gne(i,c,l,f,p,g,m)}}e._triangleIndices=t,e._outlineCoordinatesTypedArray=new Float32Array(i)}function Gne(e,t,n,i,r,o,s){let a=s?1:0,c=r?1:0,l=0,f=$5(e,t,a,c,l);if(f===0)return t;let d
Unsupported glTF version: ${i}`)}let r=n.extensionsRequired;return u(r)&&(Jt.checkSupportedExtensions(r),e._hasKhrMeshQuantization=r.includes("KHR_mesh_quantization")),e._state=Rr.LOADED,e._textureState=Rr.LOADED,e}catch(t){if(e.isDestroyed())return;e._state=Rr.FAILED,e._textureState=Rr.FAILED,ZU(e,t)}}async function mFe(e,t){kt.supportsWebP.initialized||await kt.supportsWebP.initialize();let n=new d1({webp:kt.supportsWebP(),basis:t.context.supportsBasis}),i=e.gltfJson,r=f2e(e,i,n,t);return e._state=Rr.PROCESSING,e._textureState=Rr.PROCESSING,u(e._gltfJsonLoader)&&e._releaseGltfJson&&(Vi.unload(e._gltfJsonLoader),e._gltfJsonLoader=void 0),r}Id.prototype.load=async function(){return u(this._promise)?this._promise:(this._promise=hFe(this),this._promise)};function ZU(e,t){e.unload();let n="Failed to load glTF";throw e.getError(n,t)}function pFe(e,t){let n,i=!0,r=e._geometryLoaders,o=r.length;for(n=0;n<o;++n){let a=r[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=Rr.POST_PROCESSING)}function _Fe(e,t){let n=e._primitiveLoadPlans,i=n.length;for(let r=0;r<i;r++){let o=n[r];o.postProcess(t),o.needsOutlines&&gFe(e,o)}}function gFe(e,t){let n=e._postProcessBuffers,i=t.primitive,r=i.outlineCoordinates;u(r)&&n.push(r.buffer);let o=i.attributes,s=o.length;for(let c=0;c<s;c++){let l=o[c];u(l.buffer)&&n.push(l.buffer)}let a=i.indices;u(a)&&u(a.buffer)&&n.push(a.buffer)}Id.prototype._process=function(e){return this._state===Rr.READY?!0:(this._state===Rr.PROCESSING&&pFe(this,e),this._resourcesLoaded&&this._state===Rr.POST_PROCESSING&&(_Fe(this,e.context),this._state=Rr.PROCESSED),this._resourcesLoaded&&this._state===Rr.PROCESSED?(rie(this),this._typedArray=void 0,this._state=Rr.READY,!0):!1)};Id.prototype._processTextures=function(e){if(this._textureState===Rr.READY)return!0;if(this._textureState!==Rr.PROCESSING)return!1;let t,n=!0,i=this._textureLoaders,r=i.length;for(t=0;t<r;++t){let o=i[t].process(e);o&&u(this._textureCallbacks[t])&&(this._textureCallbacks[t](),this._textureCallbacks[t]=void 0),n=n&&o}return n?(this._textureState=Rr.READY,this._texturesLoaded=!0,!0):!1};Id.prototype.process=function(e){if(this._state===Rr.LOADED&&!u(this._loadResourcesPromise)&&(this._loadResourcesPromise=mFe(this,e).then(()=>{this._resourcesLoaded=!0}).catch(r=>{this._processError=r})),u(this._processError)){this._state=Rr.FAILED;let r=this._processError;this._processError=void 0,ZU(this,r)}let t=this._textureErrors.pop();if(u(t)){let r=this.getError("Failed to load glTF texture",t);throw r.name="TextureError",r}if(this._state===Rr.FAILED)return!1;let n=!1;try{n=this._process(e)}catch(r){this._state=Rr.FAILED,ZU(this,r)}let i=!1;try{i=this._processTextures(e)}catch(r){this._textureState=Rr.FAILED,ZU(this,r)}return this._incrementallyLoadTextures?n:n&&i};function yFe(e,t,n,i,r,o,s,a){let l=t.accessors[n].bufferView;return Vi.getVertexBufferLoader({gltf:t,gltfResource:e._gltfResource,baseResource:e._baseResource,frameState:a,bufferViewId:l,draco:r,attributeSemantic:i,accessorId:n,asynchronous:e._asynchronous,loadBuffer:o,loadTypedArray:s})}function AFe(e,t,n,i,r,o,s){return Vi.getIndexBufferLoader({gltf:t,accessorId:n,gltfResource:e._gltfResource,baseResource:e._baseResource,frameState:s,draco:i,asynchronous:e._asynchronous,loadBuffer:r,loadTypedArray:o})}function xFe(e,t,n){let i=Vi.getBufferViewLoader({gltf:t,bufferViewId:n,gltfResource:e._gltfResource,baseResource:e._baseResource});return e._bufferViewLoaders.push(i),i}function Jne(e,t,n){let i=t.byteOffset,r=El(e,t),o=t.count,s=au(t.type),a=t.componentType,c=X.getSizeInBytes(a),l=c*s,f=o*s;if(r===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),m=Mp(t.componentType);i=n.byteOffset+i;for(let A=0;A<o;++A){m(p,i,s,c,g);for(let x=0;x<s;++x)d[A*s+x]=g[x];i+=r}return d}function CFe(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 JT(){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(JT.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 _2e(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}var i6=new H;function g2e(e,t){let n=new He({defines:["LOG_DEPTH_WRITE"],sources:[p1]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return i6.x=e._radius,i6.y=e._strength,i6}},r=Ve.fromCache({blending:ln.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:Lt.setCesium3DTileBit(),stencilMask:Lt.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:r,pass:be.CESIUM_3D_TILE,owner:e}),e._clearCommand=new li({framebuffer:e.framebuffer,color:new z(0,0,0,0),depth:1,renderState:Ve.fromCache(),pass:be.CESIUM_3D_TILE,owner:e})}function y2e(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),g2e(e,t)}function oie(e){return e.drawBuffers&&e.fragmentDepth}JT.isSupported=oie;function A2e(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"EC");if(!u(n)){let i=t._attributeLocations,r=t.fragmentShaderSource.clone();r.sources.splice(0,0,`layout (location = 0) out vec4 out_FragData_0;
layout (location = 1) out vec4 out_FragData_1;`),r.sources=r.sources.map(function(o){return o=He.replaceMain(o,"czm_point_cloud_post_process_main"),o=o.replaceAll(/out_FragColor/g,"out_FragData_0"),o}),r.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:r,attributeLocations:i})}return n}JT.prototype.update=function(e,t,n,i){if(!oie(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,y2e(this,e.context);let r,o=e.commandList,s=o.length;for(r=t;r<s;++r){let l=o[r];if(l.primitiveType!==Be.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=A2e(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),o[r]=f}let a=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,o.push(c),o.push(a)};JT.prototype.isDestroyed=function(){return!1};JT.prototype.destroy=function(){return _2e(this),ue(this)};var Lp=JT;function sie(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)}sie.isSupported=function(e){return Lp.isSupported(e.context)};var Jh=sie;var xa={},x2e=new oe(0,0,0,1),$a=new oe,C2e=new Xe,r6=new H,o6=new H;xa.wgs84ToWindowCoordinates=function(e,t,n){return xa.wgs84WithEyeOffsetToWindowCoordinates(e,t,h.ZERO,n)};var aie=new oe,cie=new h;function _1(e,t,n,i){let r=n.viewMatrix,o=N.multiplyByVector(r,oe.fromElements(e.x,e.y,e.z,1,aie),aie),s=h.multiplyComponents(t,h.normalize(o,cie),cie);return o.x+=t.x+s.x,o.y+=t.y+s.y,o.z+=s.z,N.multiplyByVector(n.frustum.projectionMatrix,o,i)}var T2e=new me(Math.PI,P.PI_OVER_TWO),E2e=new h,b2e=new h;xa.wgs84WithEyeOffsetToWindowCoordinates=function(e,t,n,i){let r=e.frameState,o=xa.computeActualWgs84Position(r,t,x2e);if(!u(o))return;let s=e.canvas,a=C2e;a.x=0,a.y=0,a.width=s.clientWidth,a.height=s.clientHeight;let c=e.camera,l=!1;if(r.mode===ne.SCENE2D){let f=e.mapProjection,d=T2e,p=f.project(d,E2e),g=h.clone(c.position,b2e),m=c.frustum.clone(),A=N.computeViewportTransformation(a,0,1,new N),x=c.frustum.projectionMatrix,C=c.positionWC.y,E=h.fromElements(P.sign(C)*p.x-C,0,-c.positionWC.x),T=Pt.pointToGLWindowCoordinates(x,A,E);if(C===0||T.x<=0||T.x>=s.clientWidth)l=!0;else{if(T.x>s.clientWidth*.5){a.width=T.x,c.frustum.right=p.x-C,$a=_1(o,n,c,$a),xa.clipToGLWindowCoordinates(a,$a,r6),a.x+=T.x,c.position.x=-c.position.x;let S=c.frustum.right;c.frustum.right=-c.frustum.left,c.frustum.left=-S,$a=_1(o,n,c,$a),xa.clipToGLWindowCoordinates(a,$a,o6)}else{a.x+=T.x,a.width-=T.x,c.frustum.left=-p.x-C,$a=_1(o,n,c,$a),xa.clipToGLWindowCoordinates(a,$a,r6),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,$a=_1(o,n,c,$a),xa.clipToGLWindowCoordinates(a,$a,o6)}h.clone(g,c.position),c.frustum=m.clone(),i=H.clone(r6,i),(i.x<0||i.x>s.clientWidth)&&(i.x=o6.x)}}if(r.mode!==ne.SCENE2D||l){if($a=_1(o,n,c,$a),$a.z<0&&!(c.frustum instanceof en)&&!(c.frustum instanceof bo))return;i=xa.clipToGLWindowCoordinates(a,$a,i)}return i.y=s.clientHeight-i.y,i};xa.wgs84ToDrawingBufferCoordinates=function(e,t,n){if(n=xa.wgs84ToWindowCoordinates(e,t,n),!!u(n))return xa.transformWindowToDrawingBuffer(e,n,n)};var Np=new h,S2e=new me;xa.computeActualWgs84Position=function(e,t,n){let i=e.mode;if(i===ne.SCENE3D)return h.clone(t,n);let r=e.mapProjection,o=r.ellipsoid.cartesianToCartographic(t,S2e);if(!u(o))return;if(r.project(o,Np),i===ne.COLUMBUS_VIEW)return h.fromElements(Np.z,Np.x,Np.y,n);if(i===ne.SCENE2D)return h.fromElements(0,Np.x,Np.y,n);let s=e.morphTime;return h.fromElements(P.lerp(Np.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 B1=`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 m6(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 r=i.classificationType;this._classificationType=r,this._classifiesTerrain=r!==kn.CESIUM_3D_TILE,this._classifies3DTiles=r!==kn.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[],x3e(this)}function g3e(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:dt.KEEP,zFail:dt.DECREMENT_WRAP,zPass:dt.KEEP},backFunction:e,backOperation:{fail:dt.KEEP,zFail:dt.INCREMENT_WRAP,zPass:dt.KEEP},reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Ga.LESS_OR_EQUAL},depthMask:!1}}var y3e={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:ln.PRE_MULTIPLIED_ALPHA_BLEND},A3e={stencilTest:{enabled:!0,frontFunction:zn.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:zn.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:Lt.CLASSIFICATION_MASK},stencilMask:Lt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},Die=[];function x3e(e){let t=e._command,n=Die;if(e._useDebugWireframe){t.pass=be.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=L1(e,n,e._commandListDebugWireframe);let o=e._commandListDebugWireframe,s=o.length;for(let a=0;a<s;a++){let c=o[a];c.count*=2,c.offset*=2}return}let r=e.model.allowPicking;if(e._classifiesTerrain){let o=be.TERRAIN_CLASSIFICATION,s=h6(t,o),a=vie(t,o);n.length=0,n.push(s,a),e._commandListTerrain=L1(e,n,e._commandListTerrain),r&&(e._commandListTerrainPicking=wie(e,n,e._commandListTerrainPicking))}if(e._classifies3DTiles){let o=be.CESIUM_3D_TILE_CLASSIFICATION,s=h6(t,o),a=vie(t,o);n.length=0,n.push(s,a),e._commandList3DTiles=L1(e,n,e._commandList3DTiles),r&&(e._commandList3DTilesPicking=wie(e,n,e._commandList3DTilesPicking))}}function L1(e,t,n){let i=e._runtimePrimitive,r=i.batchLengths,o=i.batchOffsets,s=r.length,a=t.length;for(let c=0;c<s;c++){let l=r[c],f=o[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 h6(e,t){let n=nt.shallowClone(e);n.cull=!1,n.pass=t;let i=t===be.TERRAIN_CLASSIFICATION?zn.ALWAYS:zn.EQUAL,r=g3e(i);return n.renderState=Ve.fromCache(r),n}function vie(e,t){let n=nt.shallowClone(e);return n.cull=!1,n.pass=t,n.renderState=Ve.fromCache(y3e),n}var C3e=[];function wie(e,t,n){let i=Ve.fromCache(A3e),r=t[0],o=t[1],s=nt.shallowClone(r);s.cull=!0,s.pickOnly=!0;let a=nt.shallowClone(o);a.cull=!0,a.pickOnly=!0,a.renderState=i,a.pickId=e._pickId;let c=C3e;return c.length=0,c.push(s,a),L1(e,c,n)}Object.defineProperties(m6.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=N.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}}});m6
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 Oie={name:"ImageBasedLightingPipelineStage"};Oie.process=function(e,t,n){let i=t.imageBasedLighting,r=e.shaderBuilder;r.addDefine("USE_IBL_LIGHTING",void 0,Te.FRAGMENT),r.addUniform("vec2","model_iblFactor",Te.FRAGMENT),Ad.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&r.addUniform("mat3","model_iblReferenceFrameMatrix",Te.FRAGMENT),u(i.sphericalHarmonicCoefficients)?(r.addDefine("DIFFUSE_IBL",void 0,Te.FRAGMENT),r.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,Te.FRAGMENT),r.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",Te.FRAGMENT)):i.useDefaultSphericalHarmonics&&r.addDefine("DIFFUSE_IBL",void 0,Te.FRAGMENT),u(i.specularEnvironmentMapAtlas)&&i.specularEnvironmentMapAtlas.ready?(r.addDefine("SPECULAR_IBL",void 0,Te.FRAGMENT),r.addDefine("CUSTOM_SPECULAR_IBL",void 0,Te.FRAGMENT),r.addUniform("sampler2D","model_specularEnvironmentMaps",Te.FRAGMENT),r.addUniform("vec2","model_specularEnvironmentMapsSize",Te.FRAGMENT),r.addUniform("float","model_specularEnvironmentMapsMaximumLOD",Te.FRAGMENT)):t.useDefaultSpecularMaps&&r.addDefine("SPECULAR_IBL",void 0,Te.FRAGMENT)),u(i.luminanceAtZenith)&&(r.addDefine("USE_SUN_LUMINANCE",void 0,Te.FRAGMENT),r.addUniform("float","model_luminanceAtZenith",Te.FRAGMENT)),r.addFragmentLines(k1);let o={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=mt(o,e.uniformMap)};var z1=Oie;var V3e=P.EPSILON16;function _6(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(_6.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,V3e)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});var k3e=new h,p6=new Z;_6.prototype.applyStageToMatrix=function(e){let t=this.type,n=this.currentValue,i=k3e,r;switch(t){case Ja.XROTATE:r=Z.fromRotationX(P.toRadians(n),p6),e=N.multiplyByMatrix3(e,r,e);break;case Ja.YROTATE:r=Z.fromRotationY(P.toRadians(n),p6),e=N.multiplyByMatrix3(e,r,e);break;case Ja.ZROTATE:r=Z.fromRotationZ(P.toRadians(n),p6),e=N.multiplyByMatrix3(e,r,e);break;case Ja.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=N.multiplyByTranslation(e,i,e);break;case Ja.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=N.multiplyByTranslation(e,i,e);break;case Ja.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=N.multiplyByTranslation(e,i,e);break;case Ja.XSCALE:i.x=n,i.y=1,i.z=1,e=N.multiplyByScale(e,i,e);break;case Ja.YSCALE:i.x=1,i.y=n,i.z=1,e=N.multiplyByScale(e,i,e);break;case Ja.ZSCALE:i.x=1,i.y=1,i.z=n,e=N.multiplyByScale(e,i,e);break;case Ja.UNIFORMSCALE:e=N.multiplyByUniformScale(e,n,e);break;default:break}return e};var H1=_6;function sV(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,z3e(this)}Object.defineProperties(sV.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 aE={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};aE.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,Te.FRAGMENT),i.addFragmentLines(W1);let r={},o=t.color;o.alpha===0&&!t.hasSilhouette(n)&&(e.renderStateOptions.colorMask={red:!1,green:!1,blue:!1,alpha:!1}),o.alpha<1&&(e.alphaOptions.pass=be.TRANSLUCENT),i.addUniform("vec4",aE.COLOR_UNIFORM_NAME,Te.FRAGMENT),r[aE.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",aE.COLOR_BLEND_UNIFORM_NAME,Te.FRAGMENT),r[aE.COLOR_BLEND_UNIFORM_NAME]=function(){return Ka.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=mt(r,e.uniformMap)};var Hg=aE;var j1=`#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 Mie={name:"ModelClippingPlanesPipelineStage"},W3e=new H;Mie.process=function(e,t,n){let i=t.clippingPlanes,r=n.context,o=e.shaderBuilder;o.addDefine("HAS_CLIPPING_PLANES",void 0,Te.FRAGMENT),o.addDefine("CLIPPING_PLANES_LENGTH",i.length,Te.FRAGMENT),i.unionClippingRegions&&o.addDefine("UNION_CLIPPING_REGIONS",void 0,Te.FRAGMENT),as.useFloatTexture(r)&&o.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,Te.FRAGMENT);let s=as.getTextureResolution(i,r,W3e);o.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",s.x,Te.FRAGMENT),o.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",s.y,Te.FRAGMENT),o.addUniform("sampler2D","model_clippingPlanes",Te.FRAGMENT),o.addUniform("vec4","model_clippingPlanesEdgeStyle",Te.FRAGMENT),o.addUniform("mat4","model_clippingPlanesMatrix",Te.FRAGMENT),o.addFragmentLines(j1);let a={model_clippingPlanes:function(){return i.texture},model_clippingPlanesEdgeStyle:function(){let c=z.clone(i.edgeColor);return c.alpha=i.edgeWidth,c},model_clippingPlanesMatrix:function(){return t._clippingPlanesMatrix}};e.uniformMap=mt(a,e.uniformMap)};var q1=Mie;function Rie(e,t){this._model=e,this._runtimeNode=t}Object.defineProperties(Rie.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 Y1=Rie;var X1=`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 K1=`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 J1=`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 aV=new N,j3e=new N,q3e=new N,Lie={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:kie,_transformsToTypedArray:y6};Lie.process=function(e,t,n){let i=t.instances,r=i.attributes[0].count,o=e.shaderBuilder;o.addDefine("HAS_INSTANCING"),o.addVertexLines(X1);let s=e.model,a=s.sceneGraph,c=e.runtimeNode,l=n.mode!==ne.SCENE3D&&!n.scene3DOnly&&s._projectTo2D,f=[];aUe(e,n,i,f,l),uUe(e,n,i,f);let d={};if(i.transformInWorldSpace?(o.addDefine("USE_LEGACY_INSTANCING",void 0,Te.VERTEX),o.addUniform("mat4","u_instance_modifiedModelView",Te.VERTEX),o.addUniform("mat4","u_instance_nodeTransform",Te.VERTEX),d.u_instance_modifiedModelView=function(){let p=N.multiplyTransformation(s.modelMatrix,a.components.transform,aV);return l?N.multiplyTransformation(n.context.uniformState.view3D,p,aV):(n.mode!==ne.SCENE3D&&(p=Pt.basisTo2D(n.mapProjection,p,aV)),N.multiplyTransformation(n.context.uniformState.view,p,aV))},d.u_instance_nodeTransform=function(){return N.multiplyTransformation(a.axisCorrectionMatrix,c.computedTransform,j3e)},o.addVertexLines(J1)):o.addVertexLines(K1),l){o.addDefine("USE_2D_INSTANCING",void 0,Te.VERTEX),o.addUniform("mat4","u_modelView2D",Te.VERTEX);let p=n.context,g=N.fromTranslation(c.instancingReferencePoint2D,new N);d.u_modelView2D=function(){return N.multiplyTransformation(p.uniformState.view,g,q3e)}}e.uniformMap=mt(d,e.uniformMap),e.instanceCount=r,e.attributes.push.apply(e.attributes,f)};var Z1=new N,Y3e=new h;function X3e(e,t,n,i,r){let o=N.multiplyTransformation(t,e,Z1);return o=N.multiplyTransformation(o,n,Z1),r=Pt.basisTo2D(i.mapProjection,o,r),r}function K3e(e,t,n,i,r){let o=N.fromTranslation(e,Z1),s=N.multiplyTransformation(t,o,Z1);s=N.multiplyTransformation(s,n,Z1);let a=N.getTranslation(s,Y3e);return r=$i.computeActualWgs84Position(i,a,r),r}function Nie(e,t,n){let i=e.model,r=i.sceneGraph;e.runtimeNode.node.instances.transformInWorldSpace?(t=N.multiplyTransformation(i.modelMatrix,r.components.transform,t),n=N.multiplyTransformation(r.axisCorrectionMatrix,e.runtimeNode.computedTransform,n)):(t=N.clone(r.computedModelMatrix,t),t=N.multiplyTransformation(t,e.runtimeNode.computedTransform,t),n=N.clone(N.IDENTITY,n))}var Fie=new N,Uie=new N,J3e=new N,Z3e=new h;function Q3e(e,t,n,i){let r=Fie,o=Uie;Nie(t,r,o);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let l=0;l<c;l++){let f=e[l],d=X3e(f,r,o,n,J3e),p=N.getTranslation(d,Z3e),g=h.subtract(p,a,p);i[l]=N.setTranslation(d,g,i[l])}return i}function $3e(e,t,n,i){let r=Fie,o=Uie;Nie(t,r,o);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let l=0;l<c;l++){let f=e[l],d=K3e(f,r,o,n,f);i[l]=h.subtract(d,a,i[l])}return i}var eUe=new h,tUe=new h;function Vie(e,t){let n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,r=N.multiplyByPoint(i,n.instancingTranslationMin,eUe),o=$i.computeActualWgs84Position(t,r,r),s=N.multiplyByPoint(i,n.instancingTranslationMax,tUe),a=$i.computeActualWgs84Position(t,s,s);n.instancingReferencePoint2D=h.lerp(o,a,.5,new h)}function y6(e){let n=e.length,i=new Float32Array(n*12);for(let r=0;r<n;r++){let o=e[r],s=12*r;i[s+0]=o[0],i[s+1]=o[4],i[s+2]=o[8],i[s+3]=o[12],i[s+4]=o[1],i[s+5]=o[5],i[s+6]=o[9],i[s+7]=o[13],i[s+8]=o[2],i[s+9]=o[6],i[s+10]=o[10],i[s+11]=o[14]}return i}function nUe(e){let n=e.length,i=new Float32Array(n*3);for(let r=0;r<n;r++){let o=e[r],s=3*r;i[s+0]=o[0],i[s+1]=o[4],i[s+2]=o[8]}return i}var iUe=new h,rUe=new Le,oUe=new h;function kie(e,t,n){let i=new Array(t),r=Jt.getAttributeBySemantic(e,Go.TRANSLATION),o=Jt.getAttributeBySemantic(e,Go.ROTATION),s=Jt.getAttributeBySemantic(e,Go.SCALE),a=new h(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=new h(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),l=u(r),f=u(o),d=u(s),p=l?r.typedArray:new Float32Array(t*3),g=f?o.typedArray:new Float32Array(t*4);f&&o.normalized&&(g=Wn.dequantize(g,o.componentDatatype,o.type,t));let m;d?m=s.typedArray:(m=new Float32Array(t*3),m.fill(1));for(let x=0;x<t;x++){let C=new h(p[x*3],p[x*3+1],p[x*3+2],iUe);h.maximumByComponent(a,C,a),h.minimumByComponent(c,C,c);let E=new Le(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 sO=`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 Xie={name:"CPUStylingPipelineStage"};Xie.process=function(e,t,n){let i=e.model,r=e.shaderBuilder;r.addVertexLines(oO),r.addFragmentLines(sO),r.addDefine("USE_CPU_STYLING",void 0,Te.BOTH),u(i.color)||(r.addUniform("float",Hg.COLOR_BLEND_UNIFORM_NAME,Te.FRAGMENT),e.uniformMap[Hg.COLOR_BLEND_UNIFORM_NAME]=function(){return Ka.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),r.addUniform("bool","model_commandTranslucent",Te.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===be.TRANSLUCENT}};var aO=Xie;var Kie={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};Kie.getDefineName=function(e){return`CUSTOM_SHADER_${e}`};var Gp=Object.freeze(Kie);var cO=`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 lO=`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 uO=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) {
initializeFeatureIds(featureIds, attributes);
initializeFeatureIdAliases(featureIds);
}
`;var fO=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes)
{
initializeFeatureIds(featureIds, attributes);
initializeFeatureIdAliases(featureIds);
setFeatureIdVaryings();
}
`;var ki={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()"};ki.process=function(e,t,n){let i=e.shaderBuilder;hUe(i);let r=e.runtimeNode.node.instances;u(r)&&mUe(e,r,n),pUe(e,t,n),i.addVertexLines(fO),i.addFragmentLines(uO)};function hUe(e){e.addStruct(ki.STRUCT_ID_FEATURE_IDS_VS,ki.STRUCT_NAME_FEATURE_IDS,Te.VERTEX),e.addStruct(ki.STRUCT_ID_FEATURE_IDS_FS,ki.STRUCT_NAME_FEATURE_IDS,Te.FRAGMENT),e.addFunction(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,ki.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,Te.VERTEX),e.addFunction(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,ki.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,Te.FRAGMENT),e.addFunction(ki.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,ki.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,Te.VERTEX),e.addFunction(ki.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,ki.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,Te.FRAGMENT),e.addFunction(ki.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,ki.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,Te.VERTEX)}function mUe(e,t,n){let i=t.featureIds,r=t.attributes[0].count;for(let o=0;o<i.length;o++){let s=i[o],a=s.positionalLabel;s instanceof Bt.FeatureIdAttribute?_Ue(e,s,a):Jie(e,s,a,r,1,n);let c=s.label;u(c)&&Zie(e,a,c,Te.BOTH)}}function pUe(e,t,n){let i=t.featureIds,o=Jt.getAttributeBySemantic(t,Tt.POSITION).count;for(let s=0;s<i.length;s++){let a=i[s],c=a.positionalLabel,l=Te.BOTH;a instanceof Bt.FeatureIdAttribute?gUe(e,a,c):a instanceof Bt.FeatureIdImplicitRange?Jie(e,a,c,o,void 0,n):(yUe(e,a,c,s,n),l=Te.FRAGMENT);let f=a.label;u(f)&&Zie(e,c,f,l)}}function _Ue(e,t,n){let i=e.shaderBuilder;i.addStructField(ki.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ki.STRUCT_ID_FEATURE_IDS_FS,"int",n);let r=t.setIndex,o=n.replace(/_\d+$/,"_"),s=`a_${o}${r}`,a=`v_${o}${r}`,c=`featureIds.${n} = int(czm_round(${s}));`,l=`featureIds.${n} = int(czm_round(${a}));`;i.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[l]),i.addVarying("float",a),i.addFunctionLines(ki.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${a} = ${s};`])}function gUe(e,t,n){let i=e.shaderBuilder;i.addStructField(ki.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ki.STRUCT_ID_FEATURE_IDS_FS,"int",n);let r=t.setIndex,o=n.replace(/_\d+$/,"_"),s=[`featureIds.${n} = int(czm_round(attributes.${o}${r}));`];i.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,s),i.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,s)}function Jie(e,t,n,i,r,o){AUe(e,t,i,r,o);let s=e.shaderBuilder,a=`a_implicit_${n}`;s.addAttribute("float",a);let c=`v_implicit_${n}`;s.addVarying("float",c),s.addStructField(ki.STRUCT_ID_FEATURE_IDS_VS,"int",n),s.addStructField(ki.STRUCT_ID_FEATURE_IDS_FS,"int",n),s.addFunctionLines(ki.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${c} = ${a};`]),s.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[`featureIds.${n} = int(czm_round(${a}));`]),s.addFunctionLines(ki.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[`featureIds.${n} = int(czm_round(${c}));`])}function yUe(e,t,n,i,r){let o=`u_featureIdTexture_${i}`,s=e.uniformMap,a=t.textureReader;s[o]=function(){return y(a.texture,r.context.defaultTexture)};let c=a.channels,l=e.shaderBuilder;l.addStructField(ki.STRUCT_ID_FEATURE_IDS_FS,"int",n),l.addUniform("sampler2D",o,Te.FRAGMENT);let f=`v_texCoord_${a.texCoord}`,d=`texture(${o}, ${f}).${
out Metadata metadata,
out MetadataClass metadataClass,
out MetadataStatistics metadataStatistics,
ProcessedAttributes attributes
)
{
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
}
`;var hO=`void metadataStage(
out Metadata metadata,
out MetadataClass metadataClass,
out MetadataStatistics metadataStatistics,
ProcessedAttributes attributes
)
{
initializeMetadata(metadata, metadataClass, metadataStatistics, attributes);
setMetadataVaryings();
}
`;var bi={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"}]};bi.process=function(e,t,n){let{shaderBuilder:i,model:r}=e,{structuralMetadata:o={},content:s}=r,a=s?.tileset.metadataExtension?.statistics,c=CUe(o.propertyAttributes,t,a),l=EUe(o.propertyTextures,a),f=c.concat(l);SUe(i,f),DUe(i),i.addVertexLines(hO),i.addFragmentLines(dO);for(let d=0;d<c.length;d++){let p=c[d];IUe(e,p)}for(let d=0;d<l.length;d++){let p=l[d];OUe(e,p)}};function CUe(e,t,n){return u(e)?e.flatMap(i=>TUe(i,t,n)):[]}function TUe(e,t,n){let{getAttributeByName:i,getAttributeInfo:r,sanitizeGlslIdentifier:o}=Jt,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:m,variableName:A}=r(g);l[f]={metadataVariable:o(d),property:p,type:p.classProperty.type,glslType:m,variableName:A,propertyStatistics:a?.properties[d],shaderDestination:Te.BOTH}}return l}function EUe(e,t){return u(e)?e.flatMap(n=>bUe(n,t)):[]}function bUe(e,t){let{sanitizeGlslIdentifier:n}=Jt,i=e.class.id,r=t?.classes[i],o=Object.entries(e.properties).filter(([a,c])=>c.isGpuCompatible()),s=new Array(o.length);for(let a=0;a<o.length;a++){let[c,l]=o[a];s[a]={metadataVariable:n(c),property:l,type:l.classProperty.type,glslType:l.getGlslType(),propertyStatistics:r?.properties[c],shaderDestination:Te.FRAGMENT}}return s}function SUe(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 r=bi.METADATA_CLASS_FIELDS;for(let a of n){let c=`${a}MetadataClass`;s(c,a,r)}let o=bi.METADATA_STATISTICS_FIELDS;for(let a of i){let c=`${a}MetadataStatistics`;s(c,a,o)}function s(a,c,l){e.addStruct(a,a,Te.BOTH);for(let f=0;f<l.length;f++){let{shaderName:d}=l[f],p=l[f].type==="float"?wUe(c):c;e.addStructField(a,p,d)}}}var vUe={int:"float",ivec2:"vec2",ivec3:"vec3",ivec4:"vec4"};function wUe(e){let t=vUe[e];return u(t)?t:e}function DUe(e){e.addStruct(bi.STRUCT_ID_METADATA_VS,bi.STRUCT_NAME_METADATA,Te.VERTEX),e.addStruct(bi.STRUCT_ID_METADATA_FS,bi.STRUCT_NAME_METADATA,Te.FRAGMENT),e.addStruct(bi.STRUCT_ID_METADATA_CLASS_VS,bi.STRUCT_NAME_METADATA_CLASS,Te.VERTEX),e.addStruct(bi.STRUCT_ID_METADATA_CLASS_FS,bi.STRUCT_NAME_METADATA_CLASS,Te.FRAGMENT),e.addStruct(bi.STRUCT_ID_METADATA_STATISTICS_VS,bi.STRUCT_NAME_METADATA_STATISTICS,Te.VERTEX),e.addStruct(bi.STRUCT_ID_METADATA_STATISTICS_FS,bi.STRUCT_NAME_METADATA_STATISTICS,Te.FRAGMENT),e.addFunction(bi.FUNCTION_ID_INITIALIZE_METADATA_VS,bi.FUNCTION_SIGNATURE_INITIALIZE_METADATA,Te.VERTEX),e.addFunction(bi.FUNCTION_ID_INITIALIZE_METADATA_FS,bi.FUNCTION_SIGNATURE_INITIALIZE_METADATA,Te.FRAGMENT),e.addFunction(bi.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 yO=`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 lE=`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 AO={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)"};AO.process=function(e,t,n){let i=e.shaderBuilder;e.hasPropertyTable=!0;let r=e.model,o=e.runtimeNode.node,s=JUe(r,o,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),ZUe(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===Te.BOTH&&i.addVertexLines(lE),i.addFragmentLines(lE)};function ore(e){return e instanceof Bt.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function sre(e){return e instanceof Bt.FeatureIdTexture?Te.FRAGMENT:Te.BOTH}function JUe(e,t,n){let i,r;return u(t.instances)&&(r=Jt.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),u(r))?(i=y(r.label,r.positionalLabel),{featureIds:r,variableName:i,shaderDestination:sre(r),featureIdDefine:ore(r)}):(r=Jt.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=y(r.label,r.positionalLabel),{featureIds:r,variableName:i,shaderDestination:sre(r),featureIdDefine:ore(r)})}function ZUe(e){e.addStructField(AO.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(AO.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(AO.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}var jg=AO;var vs={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)"};vs.process=function(e,t,n){let i=e.shaderBuilder,r=e.model;i.addStruct(vs.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",Te.VERTEX),i.addStruct(vs.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",Te.FRAGMENT),i.addStruct(jg.STRUCT_ID_SELECTED_FEATURE,jg.STRUCT_NAME_SELECTED_FEATURE,Te.BOTH),i.addFunction(vs.FUNCTION_ID_INITIALIZE_ATTRIBUTES,vs.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,Te.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(vs.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(vs.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(vs.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,vs.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,Te.VERTEX),i.addFunction(vs.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,vs.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,Te.FRAGMENT),r.type===Nr.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,Te.FRAGMENT);let s=n.mode!==ne.SCENE3D&&!n.scene3DOnly&&r._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=on.getAttributeLocationCount(d.type),g=d.semantic===Tt.POSITION,m;p>1?(m=e.attributeIndex,e.attributeIndex+=p):g&&!c?m=0:m=e.attributeIndex++,QUe(e,d,m,p,s,a)}aVe(i,t.attributes),t.primitiveType===Be.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines(yO),i.addFragmentLines(gO)};function QUe(e,t,n,i,r,o){let s=e.shaderBuilder,a=Jt.getAttributeInfo(t),c=r&&!o;i>1?tVe(e,t,n,i):eVe(e,t,n,c),iVe(s,a,c),nVe(s,a),u(t.semantic)&&$Ue(s,t),rVe(s,a,r),oVe(s,a,c),sVe(s,a)}function $Ue(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 cVe={UNLIT:0,PBR:1},Zh=Object.freeze(cVe);var are={name:"LightingPipelineStage"};are.process=function(e,t){let n=e.model,i=e.lightingOptions,r=e.shaderBuilder;if(u(n.lightColor)){r.addDefine("USE_CUSTOM_LIGHT_COLOR",void 0,Te.FRAGMENT),r.addUniform("vec3","model_lightColorHdr",Te.FRAGMENT);let s=e.uniformMap;s.model_lightColorHdr=function(){return n.lightColor}}i.lightingModel===Zh.PBR?r.addDefine("LIGHTING_PBR",void 0,Te.FRAGMENT):r.addDefine("LIGHTING_UNLIT",void 0,Te.FRAGMENT),r.addFragmentLines(CO)};var TO=are;var EO=`// 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 lVe=Bt.Material,T6=Bt.MetallicRoughness,E6=Bt.SpecularGlossiness,cre={name:"MaterialPipelineStage",_processTexture:qg,_processTextureTransform:lre};cre.process=function(e,t,n){let i=t.material,r=e.model,o=u(r.classificationType),s=o,a=e.uniformMap,c=e.shaderBuilder,l=n.context.defaultTexture,f=n.context.defaultNormalTexture,d=n.context.defaultEmissiveTexture;uVe(i,a,c,l,f,d,s),u(i.specularGlossiness)?fVe(i,a,c,l,s):dVe(i,a,c,l,s);let p=Jt.getAttributeBySemantic(t,Tt.NORMAL),g=e.lightingOptions;i.unlit||!p||o?g.lightingModel=Zh.UNLIT:g.lightingModel=Zh.PBR;let m=r.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=m;let A=e.alphaOptions;i.alphaMode===Xh.BLEND?A.pass=be.TRANSLUCENT:i.alphaMode===Xh.MASK&&(A.alphaCutoff=i.alphaCutoff),c.addFragmentLines(EO),i.doubleSided&&c.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,Te.BOTH)};function lre(e,t,n,i,r){let o=`HAS_${r}_TEXTURE_TRANSFORM`;e.addDefine(o,void 0,Te.FRAGMENT);let s=`${i}Transform`;e.addUniform("mat3",s,Te.FRAGMENT),t[s]=function(){return n.transform}}function qg(e,t,n,i,r,o){e.addUniform("sampler2D",i,Te.FRAGMENT),t[i]=function(){return y(n.texture,o)};let s=`HAS_${r}_TEXTURE`;e.addDefine(s,void 0,Te.FRAGMENT);let c=`v_texCoord_${n.texCoord}`,l=`TEXCOORD_${r}`;e.addDefine(l,c,Te.FRAGMENT);let f=n.transform;u(f)&&!Z.equals(f,Z.IDENTITY)&&lre(e,t,n,i,r)}function uVe(e,t,n,i,r,o,s){let a=e.emissiveTexture;u(a)&&!s&&qg(n,t,a,"u_emissiveTexture","EMISSIVE",o);let c=e.emissiveFactor;u(c)&&!h.equals(c,lVe.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",Te.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,Te.FRAGMENT));let l=e.normalTexture;u(l)&&!s&&qg(n,t,l,"u_normalTexture","NORMAL",r);let f=e.occlusionTexture;u(f)&&!s&&qg(n,t,f,"u_occlusionTexture","OCCLUSION",i)}function fVe(e,t,n,i,r){let o=e.specularGlossiness;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,Te.FRAGMENT);let s=o.diffuseTexture;u(s)&&!r&&qg(n,t,s,"u_diffuseTexture","DIFFUSE",i);let a=o.diffuseFactor;u(a)&&!oe.equals(a,E6.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",Te.FRAGMENT),t.u_diffuseFactor=function(){return o.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,Te.FRAGMENT));let c=o.specularGlossinessTexture;u(c)&&!r&&qg(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i);let l=o.specularFactor;u(l)&&!h.equals(l,E6.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_specularFactor",Te.FRAGMENT),t.u_specularFactor=function(){return o.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,Te.FRAGMENT));let f=o.glossinessFactor;u(f)&&f!==E6.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",Te.FRAGMENT),t.u_glossinessFactor=function(){return o.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,Te.FRAGMENT))}function dVe(e,t,n,i,r){let o=e.metallicRoughness;n.addDefine("USE_METALLIC_ROUGHNESS",void 0,Te.FRAGMENT);let s=o.baseColorTexture;u(s)&&!r&&qg(n,t,s,"u_baseColorTexture","BASE_COLOR",i);let a=o.baseColorFactor;u(a)&&!oe.equals(a,T6.DEFAULT_BASE_COLOR_FACTOR)&&(n.addUniform("vec4","u_baseColorFactor",Te.FRAGMENT),t.u_baseColorFactor=function(){return o.baseColorFactor},n.addDefine("HAS_BASE_COLOR_FACTOR",void 0,Te.FRAGMENT));let c=o.metallicRoughnessTexture;u(c)&&!r&&qg(n,t,c,"u_metallicRoughnessTexture","METALLIC_ROUGHNESS",i);let l=o.metallicFactor;u(l)&&l!==T6.DEFAULT_METALLIC_FACTOR&&(n.addUniform("float","u_metallicFactor",Te.FRAGMENT),t.u_metallicFactor=function(){return o.metallicFactor},n.addDefine("HAS_METALLIC_FACTOR",void 0,Te.FRAGMENT));let f=o.roughnessFactor;u(f)&&f!==T6.DEFAULT_ROUGHNESS_FACTOR&&(n.addUniform("float","u_roughnessFactor",Te.FRAGMENT),t.u_roughnessFactor=function(){return o.roughnessFactor},n.addDefine("HAS_ROUGHNESS_FACTOR",void 0,Te.FRAGMENT))}var bO=cre;var SO=`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 Ca={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)"};Ca.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,Te.VERTEX),yVe(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||(mVe(e,d,e.attributeIndex,a),e.attributeIndex++)}}AVe(n);let o=e.runtimeNode.morphWeights.length;n.addUniform("float",`u_morphWeights[${o}]`,Te.VERTEX),n.addVertexLines(SO);let s={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=mt(s,e.uniformMap)};var hVe={attributeString:void 0,functionId:void 0};function mVe(e,t,n,i){let r=e.shaderBuilder;pVe(e,t,n);let o=_Ve(t,hVe);gVe(r,o,i)}function pVe(e,t,n){let i={index:n,value:u(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:on.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function _Ve(e,t){switch(e.semantic){case Tt.POSITION:t.attributeString="Position",t.functionId=Ca.FUNCTION_ID_GET_MORPHED_POSITION;break;case Tt.NORMAL:t.attributeString="Normal",t.functionId=Ca.FUNCTION_ID_GET_MORPHED_NORMAL;break;case Tt.TANGENT:t.attributeString="Tangent",t.functionId=Ca.FUNCTION_ID_GET_MORPHED_TANGENT;break;default:break}return t}function gVe(e,t,n){let i=t.attributeString,r=`a_target${i}_${n}`,o=`morphed${i} += u_morphWeights[${n}] * a_target${i}_${n};`;e.addAttribute("vec3",r),e.addFunctionLines(t.functionId,[o])}function yVe(e){e.addFunction(Ca.FUNCTION_ID_GET_MORPHED_POSITION,Ca.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,Te.VERTEX);let t="vec3 morphedPosition = position;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_POSITION,[t]),e.addFunction(Ca.FUNCTION_ID_GET_MORPHED_NORMAL,Ca.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,Te.VERTEX);let n="vec3 morphedNormal = normal;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_NORMAL,[n]),e.addFunction(Ca.FUNCTION_ID_GET_MORPHED_TANGENT,Ca.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,Te.VERTEX);let i="vec3 morphedTangent = tangent;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}function AVe(e){let t="return morphedPosition;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_POSITION,[t]);let n="return morphedNormal;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_NORMAL,[n]);let i="return morphedTangent;";e.addFunctionLines(Ca.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}var vO=Ca;var ure={name:"PickingPipelineStage"};ure.process=function(e,t,n){let i=n.context,r=e.runtimeNode,o=e.shaderBuilder,s=e.model,a=r.node.instances;if(e.hasPropertyTable)xVe(e,t,a,i);else if(u(a))CVe(e,i);else{let c=fre(e),l=i.createPickId(c);s._pipelineResources.push(l),s._pickIds.push(l),o.addUniform("vec4","czm_pickColor",Te.FRAGMENT);let f=e.uniformMap;f.czm_pickColor=function(){return l.color},e.pickId="czm_pickColor"}};function fre(e,t){let n=e.model;if(u(n.pickObject))return n.pickObject;let i={model:n,node:e.runtimeNode,primitive:e.runtimePrimitive},r;if(Nr.is3DTiles(n.type)){let o=n.content;r={content:o,primitive:o.tileset,detail:i}}else r={primitive:n,detail:i};return r.id=n.id,u(t)&&(r.instanceId=t),r}function xVe(e,t,n){let i=e.model,r,o,s=i.featureIdLabel,a=i.instanceFeatureIdLabel;u(i.featureTableId)?r=i.featureTableId:u(n)?(o=Jt.getFeatureIdsByLabel(n.featureIds,a),r=o.propertyTableId):(o=Jt.getFeatureIdsByLabel(t.featureIds,s),r=o.propertyTableId);let c=i.featureTables[r];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",Te.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 EVe=new oe,hre={name:"PointCloudStylingPipelineStage"};hre.process=function(e,t,n){let i=e.shaderBuilder,r=e.model,o=r.style,s=r.structuralMetadata,a=u(s)?s.propertyAttributes:void 0,c=u(r.featureTableId)&&r.featureTables[r.featureTableId].featuresLength>0,l=!u(a)&&c;if(u(o)&&!l){let A=wVe(a),x=DVe(o,A);IVe(i,x);let E=PVe(x).indexOf("normalMC")>=0,T=Jt.getAttributeBySemantic(t,Tt.NORMAL);if(E&&!T)throw new de("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,Te.VERTEX),x.styleTranslucent&&(e.alphaOptions.pass=be.TRANSLUCENT)}let f=r.pointCloudShading;f.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,Te.VERTEX),f.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,Te.VERTEX);let d,p,g;Nr.is3DTiles(r.type)&&(p=!0,d=r.content,g=d.tile.refine===Fr.ADD),i.addUniform("vec4","model_pointCloudParameters",Te.VERTEX),i.addVertexLines(DO);let m=e.uniformMap;m.model_pointCloudParameters=function(){let A=EVe,x=1;p&&(x=g?5:d.tileset.maximumScreenSpaceError),A.x=y(f.maximumAttenuation,x),A.x*=n.pixelRatio;let C=bVe(e,t,f,d);A.y=C*f.geometricErrorScale;let E=n.context,T=n.camera.frustum,S;return n.mode===ne.SCENE2D||T instanceof en?S=Number.POSITIVE_INFINITY:S=E.drawingBufferHeight/n.camera.frustum.sseDenominator,A.z=S,p&&(A.w=d.tileset.timeSinceLoad),A}};var dre=new h;function bVe(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 r=Jt.getAttributeBySemantic(t,Tt.POSITION),o=r.count,s=e.runtimeNode.transform,a=h.subtract(r.max,r.min,dre);a=N.multiplyByPointAsVector(s,a,dre);let c=a.x*a.y*a.z;return P.cbrt(c/o)}var SVe={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},vVe={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function wVe(e){let t=je(vVe);if(!u(e))return t;for(let n=0;n<e.length;n++){let r=e[n].properties;for(let o in r)r.hasOwnProperty(o)&&(t[o]=`metadata.${o}`)}return t}var b6="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function DVe(e,t){let n=SVe,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction(`getColorFromStyle(${b6})`,t,i),n.showStyleFunction=e.getShowShaderFunction(`getShowFromStyle(${b6})`,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction(`getPointSizeFromStyle(${b6})`,t,i),n.styleTranslucent=u(n.colorStyleFunction)&&i.translucent,n}function IVe(e,t){let n=t.colorStyleFunction;u(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,Te.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));let i=t.showStyleFunction;u(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,Te.VERTEX),e.addVertexLines(i));let r=t.pointSizeStyleFunction;u(r)&&(e.addDefine("HAS_POINT_CLOUD_POINT_SIZE_STYLE",void 0,Te.VERTEX),e.addVertexLines(r))}function S6(e,t){let n=/attributes\.(\w+)/g,i=n.exec(e);for(;i!==null;){let r=i[1];t.indexOf(r)===-1&&t.push(r),i=n.exec(e)}}function PVe(e){let t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,r=[];return u(t)&&S6(t,r),u(n)&&S6(n,r),u(i)&&S6(i,r),r}var IO=hre;var PO=`void primitiveOutlineStage() {
v_outlineCoordinates = a_outlineCoordinates;
}
`;var OO=`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 mre={name:"PrimitiveOutlinePipelineStage"};mre.process=function(e,t,n){let i=e.shaderBuilder,r=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,Te.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");let o=t.outlineCoordinates,s={index:e.attributeIndex++,vertexBuffer:o.buffer,componentsPerAttribute:on.getNumberOfComponents(o.type),componentDatatype:o.componentDatatype,offsetInBytes:o.byteOffset,strideInBytes:o.byteStride,normalize:o.normalized};e.attributes.push(s),i.addUniform("sampler2D","model_outlineTexture",Te.FRAGMENT);let a=NA.createTexture(n.context);r.model_outlineTexture=function(){return a};let c=e.model;i.addUniform("vec4","model_outlineColor",Te.FRAGMENT),r.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",Te.FRAGMENT),r.model_showOutline=function(){return c.showOutline},i.addVertexLines(PO),i.addFragmentLines(OO)};var MO=mre;var pre={name:"PrimitiveStatisticsPipelineStage",_countGeometry:_re,_count2DPositions:gre,_countMorphTargetAttributes:yre,_countMaterialTextures:Are,_countFeatureIdTextures:xre,_countBinaryMetadata:Cre};pre.process=function(e,t,n){let i=e.model,r=i.statistics;_re(r,t),gre(r,e.runtimePrimitive),yre(r,t),Are(r,t.material),xre(r,t.featureIds),Cre(r,i)};function _re(e,t){let n=u(t.indices)?t.indices.count:Jt.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===Be.POINTS?e.pointsLength+=n:Be.isTriangles(i)&&(e.trianglesLength+=OVe(i,n));let r=t.attributes,o=r.length;for(let c=0;c<o;c++){let l=r[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 OVe(e,t){switch(e){case Be.TRIANGLES:return t/3;case Be.TRIANGLE_STRIP:case Be.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function gre(e,t){let n=t.positionBuffer2D;u(n)&&e.addBuffer(n,!0)}function yre(e,t){let n=t.morphTargets;if(!u(n))return;let i=!1,r=n.length;for(let o=0;o<r;o++){let s=n[o].attributes,a=s.length;for(let c=0;c<a;c++){let l=s[c];u(l.buffer)&&e.addBuffer(l.buffer,i)}}}function Are(e,t){let n=MVe(t),i=n.length;for(let r=0;r<i;r++){let o=n[r];u(o)&&u(o.texture)&&e.addTexture(o.texture)}}function MVe(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 xre(e,t){let n=t.length;for(let i=0;i<n;i++){let r=t[i];if(r instanceof Bt.FeatureIdTexture){let o=r.textureReader;u(o.texture)&&e.addTexture(o.texture)}}}function Cre(e,t){let n=t.structuralMetadata;u(n)&&(RVe(e,n),e.propertyTablesByteLength+=n.propertyTablesByteLength);let i=t.featureTables;if(!u(i))return;let r=i.length;for(let o=0;o<r;o++){let s=i[o];e.addBatchTexture(s.batchTexture)}}function RVe(e,t){let n=t.propertyTextures;if(!u(n))return;let i=n.length;for(let r=0;r<i;r++){let s=n[r].properties;for(let a in s)if(s.hasOwnProperty(a)){let l=s[a].textureReader;u(l.texture)&&e.addTexture(l.texture)}}}var RO=pre;var BVe=new N,LVe=new N,Tre={name:"SceneMode2DPipelineStage"};Tre.process=function(e,t,n){let i=Jt.getAttributeBySemantic(t,Tt.POSITION),r=e.shaderBuilder,o=e.model,s=o.sceneGraph.computedModelMatrix,a=e.runtimeNode.computedTransform,c=N.multiplyTransformation(s,a,BVe),l=UVe(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=zVe(i,c,l,n);f.positionBuffer2D=A,o._modelResources.push(A),i.typedArray=void 0}r.addDefine("USE_2D_POSITIONS",void 0,Te.VERTEX),r.addUniform("mat4","u_modelView2D",Te.VERTEX);let p=N.fromTranslation(l.center,new N),g=n.context,m={u_modelView2D:function(){return N.multiplyTransformation(g.uniformState.view,p,LVe)}};e.uniformMap=mt(m,e.uniformMap)};var NVe=new h,FVe=new h;function UVe(e,t,n){let i=N.multiplyByPoint(t,e.positionMin,NVe),r=$i.computeActualWgs84Position(n,i,i),o=N.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 HA={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};HA.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,Te.VERTEX),GVe(n,t);let i=e.runtimeNode,r=i.computedJointMatrices;n.addUniform("mat4",`u_jointMatrices[${r.length}]`,Te.VERTEX),n.addVertexLines(LO);let o={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=mt(o,e.uniformMap)};function HVe(e){let t=-1,n=e.attributes,i=n.length;for(let r=0;r<i;r++){let o=n[r];(o.semantic===Tt.JOINTS||o.semantic===Tt.WEIGHTS)&&(t=Math.max(t,o.setIndex))}return t}function GVe(e,t){e.addFunction(HA.FUNCTION_ID_GET_SKINNING_MATRIX,HA.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,Te.VERTEX);let n="mat4 skinnedMatrix = mat4(0);";e.addFunctionLines(HA.FUNCTION_ID_GET_SKINNING_MATRIX,[n]);let i,r,o=["x","y","z","w"],s=HVe(t);for(i=0;i<=s;i++)for(r=0;r<=3;r++){let c=o[r],l=`skinnedMatrix += a_weights_${i}.${c} * u_jointMatrices[int(a_joints_${i}.${c})];`;e.addFunctionLines(HA.FUNCTION_ID_GET_SKINNING_MATRIX,[l])}let a="return skinnedMatrix;";e.addFunctionLines(HA.FUNCTION_ID_GET_SKINNING_MATRIX,[a])}var NO=HA;var v6={};function WVe(e){let t=Ue.createTypedArray(e,e*2),n=e,i=0;for(let r=0;r<n;r+=3)t[i++]=r,t[i++]=r+1,t[i++]=r+1,t[i++]=r+2,t[i++]=r+2,t[i++]=r;return t}function jVe(e,t){let n=t.length,i=Ue.createTypedArray(e,n*2),r=0;for(let o=0;o<n;o+=3){let s=t[o],a=t[o+1],c=t[o+2];i[r++]=s,i[r++]=a,i[r++]=a,i[r++]=c,i[r++]=c,i[r++]=s}return i}function qVe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),r=0;i[r++]=0,i[r++]=1;for(let o=0;o<t;o++)i[r++]=o+1,i[r++]=o+2,i[r++]=o+2,i[r++]=o;return i}function YVe(e,t){let i=t.length-2,r=2+i*4,o=Ue.createTypedArray(e,r),s=0;o[s++]=t[0],o[s++]=t[1];for(let a=0;a<i;a++){let c=t[a],l=t[a+1],f=t[a+2];o[s++]=l,o[s++]=f,o[s++]=f,o[s++]=c}return o}function XVe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),r=0;i[r++]=0,i[r++]=1;for(let o=0;o<t;o++)i[r++]=o+1,i[r++]=o+2,i[r++]=o+2,i[r++]=0;return i}function KVe(e,t){let i=t.length-2,r=2+i*4,o=Ue.createTypedArray(e,r),s=0,a=t[0];o[s++]=a,o[s++]=t[1];for(let c=0;c<i;c++){let l=t[c+1],f=t[c+2];o[s++]=l,o[s++]=f,o[s++]=f,o[s++]=a}return o}v6.createWireframeIndices=function(e,t,n){let i=u(n);if(e===Be.TRIANGLES)return i?jVe(t,n):WVe(t);if(e===Be.TRIANGLE_STRIP)return i?YVe(t,n):qVe(t);if(e===Be.TRIANGLE_FAN)return i?KVe(t,n):XVe(t)};v6.getWireframeIndicesCount=function(e,t){return e===Be.TRIANGLES?t*2:e===Be.TRIANGLE_STRIP||e===Be.TRIANGLE_FAN?2+(t-2)*4:t};var uE=v6;var bre={name:"WireframePipelineStage"};bre.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,Te.FRAGMENT);let r=e.model,o=JVe(t,e.indices,n);r._pipelineResources.push(o),e.wireframeIndexBuffer=o;let s=!1;r.statistics.addBuffer(o,s);let a=e.primitiveType,c=e.count;e.primitiveType=Be.LINES,e.count=uE.getWireframeIndicesCount(a,c)};function JVe(e,t,n){let r=Jt.getAttributeBySemantic(e,Tt.POSITION).count,o=n.context.webgl2,s;if(u(t)){let f=t.buffer,d=t.count;u(f)&&o?(s=f.sizeInBytes===d?new Uint8Array(d):Ue.createTypedArray(r,d),f.getBufferData(s)):s=t.typedArray}let a=e.primitiveType,c=uE.createWireframeIndices(a,r,s),l=Ue.fromSizeInBytes(c.BYTES_PER_ELEMENT);return ft.createIndexBuffer({context:n.context,typedArray:c,usage:Fe.STATIC_DRAW,indexDatatype:l})}var FO=bre;function Sre(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=[]}Sre.prototype.configurePipeline=function(e){let t=this.pipelineStages;t.length=0;let n=this.primitive,i=this.node,r=this.model,o=r.customShader,s=r.style,a=e.context.webgl2,l=e.mode!==ne.SCENE3D&&!e.scene3DOnly&&r._projectTo2D,f=u(n.morphTargets)&&n.morphTargets.length>0,d=u(i.skin),p=u(o),m=!(p&&u(o.fragmentShaderText))||o.mode!==Gp.REPLACE_MATERIAL,A=Jt.hasQuantizedAttributes(n.attributes),x=r.debugWirefra
`),o=new He({defines:this._vertexShaderParts.defineLines,sources:[r]}),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 Xt.fromCache({context:e,vertexShaderSource:o,fragmentShaderSource:a,attributeLocations:this._attributeLocations})};zc.prototype.clone=function(){return je(this,!0)};function eke(e){let t=[],n=[],i,r=e._vertexShaderParts.structIds,o,s,a;for(i=0;i<r.length;i++)o=r[i],s=e._structs[o],a=s.generateGlslLines(),t.push.apply(t,a);for(r=e._fragmentShaderParts.structIds,i=0;i<r.length;i++)o=r[i],s=e._structs[o],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}function tke(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function nke(e){let t=[],n=[],i,r=e._vertexShaderParts.functionIds,o,s,a;for(i=0;i<r.length;i++)o=r[i],s=e._functions[o],a=s.generateGlslLines(),t.push.apply(t,a);for(r=e._fragmentShaderParts.functionIds,i=0;i<r.length;i++)o=r[i],s=e._functions[o],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}var GA=zc;function ike(e){this.shaderBuilder=new GA,this.model=e,this.uniformMap={},this.alphaOptions=new kO,this.renderStateOptions=Ve.getState(Ve.fromCache({depthTest:{enabled:!0,func:Ga.LESS_OR_EQUAL}})),this.hasSilhouette=!1,this.hasSkipLevelOfDetail=!1}var GO=ike;var WO=`void silhouetteStage(inout vec4 color) {
if(model_silhouettePass) {
color = czm_gammaCorrect(model_silhouetteColor);
}
}`;var jO=`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 cV={name:"ModelSilhouettePipelineStage"};cV.silhouettesLength=0;cV.process=function(e,t,n){u(t._silhouetteId)||(t._silhouetteId=++cV.silhouettesLength);let i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,Te.BOTH),i.addVertexLines(jO),i.addFragmentLines(WO),i.addUniform("vec4","model_silhouetteColor",Te.FRAGMENT),i.addUniform("float","model_silhouetteSize",Te.VERTEX),i.addUniform("bool","model_silhouettePass",Te.BOTH);let r={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=mt(r,e.uniformMap),e.hasSilhouette=!0};var qO=cV;var YO=`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 lV={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};lV.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,Te.FRAGMENT),i.addFragmentLines(YO);let r={};i.addUniform("float",lV.SPLIT_DIRECTION_UNIFORM_NAME,Te.FRAGMENT),r[lV.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=mt(r,e.uniformMap)};var XO=lV;function rke(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 KO=rke;function oke(e){e=y(e,y.EMPTY_OBJECT),this.lightingModel=y(e.lightingModel,Zh.UNLIT)}var JO=oke;function ske(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:Jt.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;let i=Jt.getPositionMinMax(n,this.runtimeNode.instancingTranslationMin,this.runtimeNode.instancingTranslationMax);this.positionMin=h.clone(i.min,new h),this.positionMax=h.clone(i.max,new h),this.boundingSphere=ae.fromCornerPoints(this.positionMin,this.positionMax,new ae),this.lightingOptions=new JO,this.pickId=void 0}var ZO=ske;function lu(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=N.clone(N.IDENTITY),this._computedModelMatrix2D=N.clone(N.IDENTITY),this._axisCorrectionMatrix=Jt.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new N),this._runtimeArticulations={},ake(this)}Object.defineProperties(lu.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 ake(e){let t=e._components,n=t.scene,r=e._model.modelMatrix;wre(e,r);let o=t.articulations,s=o.length,a=e._runtimeArticulations;for(let E=0;E<s;E++){let T=o[E],S=new G1({articulation:T,sceneGraph:e}),v=S.name;a[v]=S}let c=t.nodes,l=c.length;e._runtimeNodes=new Array(l);let d=n.nodes.length,p=N.IDENTITY;for(let E=0;E<d;E++){let T=n.nodes[E],S=Dre(e,T,p);e._rootNodes.push(S)}let g=t.skins,m=e._runtimeSkins,A=g.length;for(let E=0;E<A;E++){let T=g[E];m.push(new VO({skin:T,sceneGraph:e}))}let x=e._skinnedNodes,C=x.length;for(let E=0;E<C;E++){let T=x[E],S=e._runtimeNodes[T],D=c[T].skin.index;S._runtimeSkin=m[D],S.updateJointMatrices()}e.applyArticulations()}function wre(e,t){let n=e._components,i=e._model;e._computedModelMatrix=N.multiplyTransformation(t,n.transform,e._computedModelMatrix),e._computedModelMatrix=N.multiplyTransformation(e._computedModelMatrix,e._axisCorrectionMatrix,e._computedModelMatrix),e._computedModelMatrix=N.multiplyByUniformScale(e._computedModelMatrix,i.computedScale,e._computedModelMatrix)}var cke=new h;function lke(e,t){let n=e._computedModelMatrix,i=N.getTranslation(n,cke);if(!h.equals(i,h.ZERO))e._computedModelMatrix2D=Pt.basisTo2D(t.mapProjection,n,e._computedModelMatrix2D);else{let r=e.boundingSphere.center,o=P
#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 rM=`#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 Si(e,t){e=y(e,y.EMPTY_OBJECT);let n=e.translucencyByDistance,i=e.pixelOffsetScaleByDistance,r=e.scaleByDistance,o=e.distanceDisplayCondition;u(n)&&(n=It.clone(n)),u(i)&&(i=It.clone(i)),u(r)&&(r=It.clone(r)),u(o)&&(o=vt.clone(o)),this._show=y(e.show,!0),this._position=h.clone(y(e.position,h.ZERO)),this._actualPosition=h.clone(this._position),this._pixelOffset=H.clone(y(e.pixelOffset,H.ZERO)),this._translate=new H(0,0),this._eyeOffset=h.clone(y(e.eyeOffset,h.ZERO)),this._heightReference=y(e.heightReference,We.NONE),this._verticalOrigin=y(e.verticalOrigin,In.CENTER),this._horizontalOrigin=y(e.horizontalOrigin,_i.CENTER),this._scale=y(e.scale,1),this._color=z.clone(y(e.color,z.WHITE)),this._rotation=y(e.rotation,0),this._alignedAxis=h.clone(y(e.alignedAxis,h.ZERO)),this._width=e.width,this._height=e.height,this._scaleByDistance=r,this._translucencyByDistance=n,this._pixelOffsetScaleByDistance=i,this._sizeInMeters=y(e.sizeInMeters,!1),this._distanceDisplayCondition=o,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=z.clone(y(e.outlineColor,z.BLACK)),this._outlineWidth=y(e.outlineWidth,0),this._updateClamping()}var Vre=Si.SHOW_INDEX=0,pV=Si.POSITION_INDEX=1,Wre=Si.PIXEL_OFFSET_INDEX=2,D4e=Si.EYE_OFFSET_INDEX=3,I4e=Si.HORIZONTAL_ORIGIN_INDEX=4,P4e=Si.VERTICAL_ORIGIN_INDEX=5,O4e=Si.SCALE_INDEX=6,_V=Si.IMAGE_INDEX_INDEX=7,kre=Si.COLOR_INDEX=8,M4e=Si.ROTATION_INDEX=9,R4e=Si.ALIGNED_AXIS_INDEX=10,B4e=Si.SCALE_BY_DISTANCE_INDEX=11,L4e=Si.TRANSLUCENCY_BY_DISTANCE_INDEX=12,N4e=Si.PIXEL_OFFSET_SCALE_BY_DISTANCE_INDEX=13,F4e=Si.DISTANCE_DISPLAY_CONDITION=14,U4e=Si.DISABLE_DEPTH_DISTANCE=15;Si.TEXTURE_COORDINATE_BOUNDS=16;var zre=Si.SDF_INDEX=17;Si.NUMBER_OF_PROPERTIES=18;function Ur(e,t){let n=e._billboardCollection;u(n)&&(n._updateBillboard(e,t),e._dirty=!0)}Object.defineProperties(Si.prototype,{show:{get:function(){return this._show},set:function(e){this._show!==e&&(this._show=e,Ur(this,Vre))}},position:{get:function(){return this._position},set:function(e){let t=this._position;h.equals(t,e)||(h.clone(e,t),h.clone(e,this._actualPosition),this._updateClamping(),Ur(this,pV))}},heightReference:{get:function(){return this._heightReference},set:function(e){let t=this._heightReference;e!==t&&(this._heightReference=e,this._updateClamping(),Ur(this,pV))}},pixelOffset:{get:function(){return this._pixelOffset},set:function(e){let t=this._pixelOffset;H.equals(t,e)||(H.clone(e,t),Ur(this,Wre))}},scaleByDistance:{get:function(){return this._scaleByDistance},set:function(e){let t=this._scaleByDistance;It.equals(t,e)||(this._scaleByDistance=It.clone(e,t),Ur(this,B4e))}},translucencyByDistance:{get:function(){return this._translucencyByDistance},set:function(e){let t=this._translucencyByDistance;It.equals(t,e)||(this._translucencyByDistance=It.clone(e,t),Ur(this,L4e))}},pixelOffsetScaleByDistance:{get:function(){return this._pixelOffsetScaleByDistance},set:function(e){let t=this._pixelOffsetScaleByDistance;It.equals(t,e)||(this._pixelOffsetScaleByDistance=It.clone(e,t),Ur(this,N4e))}},eyeOffset:{get:function(){return this._eyeOffset},set:function(e){let t=this._eyeOffset;h.equals(t,e)||(h.clone(e,t),Ur(this,D4e))}},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 dze=[];df.prototype.update=function(e){if(k6(this),!this.show)return;let t=this._billboards,n=t.length,i=e.context;this._instanced=i.instancedArrays,Sr=this._instanced?Q4e:Z4e,R6=this._instanced?eze:$4e;let r=this._textureAtlas;if(!u(r)){r=this._textureAtlas=new Kg({context:i});for(let O=0;O<n;++O)t[O]._loadImage()}let o=r.textureCoordinates;if(o.length===0)return;lze(this,e),t=this._billboards,n=t.length;let s=this._billboardsToUpdate,a=this._billboardsToUpdateIndex,c=this._propertiesChanged,l=r.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<V6;++O)c[O]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),n>0){this._vaf=nze(i,n,this._buffersUsage,this._instanced,this._batchTable,this._sdf),d=this._vaf.writers;for(let O=0;O<n;++O){let B=this._billboards[O];B._dirty=!1,cze(this,e,o,d,B)}this._vaf.commit(R6(i))}this._billboardsToUpdateIndex=0}else if(a>0){let O=dze;O.length=0,(c[aM]||c[Y4e]||c[q4e])&&O.push(ioe),(c[sM]||c[Xre]||c[W4e]||c[j4e]||c[G4e])&&(O.push(loe),this._instanced&&O.push(U6)),(c[sM]||c[X4e]||c[Qre])&&(O.push(uoe),O.push(F6)),(c[sM]||c[Jre])&&O.push(F6),c[Kre]&&O.push(U6),c[Zre]&&O.push(foe),c[$re]&&O.push(doe),(c[eoe]||c[K4e]||c[sM]||c[aM])&&O.push(hoe),(c[sM]||c[aM])&&O.push(moe),c[toe]&&O.push(poe);let B=O.length;if(d=this._vaf.writers,a/n>.1){for(let L=0;L<a;++L){let _=s[L];_._dirty=!1;for(let b=0;b<B;++b)O[b](this,e,o,d,_)}this._vaf.commit(R6(i))}else{for(let L=0;L<a;++L){let _=s[L];_._dirty=!1;for(let b=0;b<B;++b)O[b](this,e,o,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 m,A=N.IDENTITY;e.mode===ne.SCENE3D?(A=this.modelMatrix,m=ae.clone(this._baseVolumeWC,this._boundingVolume)):m=ae.clone(this._baseVolume2D,this._boundingVolume),uze(this,e,m);let x=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,x){this._blendOption===wr.OPAQUE||this._blendOption===wr.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=Ve.fromCache({depthTest:{enabled:!0,func:te.LESS},depthMask:!0}):this._rsOpaque=void 0;let O=this._blendOption===wr.TRANSLUCENT;this._blendOption===wr.TRANSLUCENT||this._blendOption===wr.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=Ve.fromCache({depthTest:{enabled:!0,func:O?te.LEQUAL:te.LESS},depthMask:O,blending:ln.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let C,E,T,S,v,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=rM,E=iM,v=[],u(this._batchTable)&&(v.push("VECTOR_TILE"),C=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(C),E=this._batchTable.getFragmentShaderCallback(!1,void 0)(E)),T=new He({defines:v,sources:[C]}),this._instanced&&T.defines.push("INSTANCED"),this._shaderRotation&&T.defines.push("ROTATION"),this._shaderAlignedAxis&&T.defines.push("ALIGNED_AXIS"),this._shaderScaleByDistance&&T.defines.push("EYE_DISTANCE_SCALING"),this._shaderTranslucencyByDistance&&T.defines.push("EYE_DISTANCE_TRANSLUCENCY"),this._shad
`),n="";for(let i=0;i<t.length;i++){let r=t[i],o=Toe.test(r.charAt(0)),s=Tze(r,Toe),a=0,c="";for(let l=0;l<s.length;++l){let f=s[l],d=f.Type===$o.BRACKETS?bze(f.Word):Eze(f.Word);o?f.Type===$o.RTL?(c=d+c,a=0):f.Type===$o.LTR?(c=fM(c,a,f.Word),a+=f.Word.length):(f.Type===$o.WEAK||f.Type===$o.BRACKETS)&&(f.Type===$o.WEAK&&s[l-1].Type===$o.BRACKETS?c=d+c:s[l-1].Type===$o.RTL?(c=d+c,a=0):s.length>l+1?s[l+1].Type===$o.RTL?(c=d+c,a=0):(c=fM(c,a,f.Word),a+=f.Word.length):c=fM(c,0,d)):f.Type===$o.RTL?c=fM(c,a,d):f.Type===$o.LTR?(c+=f.Word,a=c.length):(f.Type===$o.WEAK||f.Type===$o.BRACKETS)&&(l>0&&s[l-1].Type===$o.RTL?s.length>l+1?s[l+1].Type===$o.RTL?c=fM(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 Jg=Yp;var woe=Wi(boe(),1);function Ize(){this.textureInfo=void 0,this.dimensions=void 0,this.billboard=void 0}function Pze(e,t,n){this.labelCollection=e,this.index=t,this.dimensions=n}var Oze=1.2,Doe="ID_WHITE_PIXEL",z6=new H(4,4),Mze=new Xe(1,1,1,1);function Rze(e){let t=document.createElement("canvas");t.width=z6.x,t.height=z6.y;let n=t.getContext("2d");n.fillStyle="#fff",n.fillRect(0,0,t.width,t.height),e.addImage(Doe,t)}var hf={};function Bze(e,t,n,i,r,o,s){return hf.font=t,hf.fillColor=n,hf.strokeColor=i,hf.strokeWidth=r,hf.padding=Is.PADDING,s===In.CENTER?hf.textBaseline="middle":s===In.TOP?hf.textBaseline="top":hf.textBaseline="bottom",hf.fill=o===Vr.FILL||o===Vr.FILL_AND_OUTLINE,hf.stroke=o===Vr.OUTLINE||o===Vr.FILL_AND_OUTLINE,hf.backgroundColor=z.BLACK,XA(e,hf)}function H6(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 Lze(e,t,n,i){i.index=e.addImageSync(t,n)}var Nze=new woe.default;function Fze(e,t){let n=t._renderedText,i=Nze.splitGraphemes(n),r=i.length,o=t._glyphs,s=o.length,a,c,l;if(t._relativeSize=t._fontSize/Is.FONT_SIZE,r<s)for(c=r;c<s;++c)H6(e,o[c]);o.length=r;let f=t._showBackground&&n.split(`
`).join("").length>0,d=t._backgroundBillboard,p=e._backgroundBillboardCollection;f?(u(d)||(d=p.add({collection:e,image:Doe,imageSubRegion:Mze}),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=_i.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<r;++l){let m=i[l],A=t._verticalOrigin,x=JSON.stringify([m,t._fontFamily,t._fontStyle,t._fontWeight,+A]),C=g[x];if(!u(C)){let E=`${t._fontStyle} ${t._fontWeight} ${Is.FONT_SIZE}px ${t._fontFamily}`,T=Bze(m,E,z.WHITE,z.WHITE,0,Vr.FILL,A);if(C=new Pze(e,-1,T.dimensions),g[x]=C,T.width>0&&T.height>0){let S=(0,voe.default)(T,{cutoff:Is.CUTOFF,radius:Is.RADIUS}),v=T.getContext("2d"),D=T.width,M=T.height,O=v.getImageData(0,0,D,M);for(let B=0;B<D;B++)for(let L=0;L<M;L++){let _=L*D+B,b=S[_]*255,w=_*4;O.data[w+0]=b,O.data[w+1]=b,O.data[w+2]=b,O.data[w+3]=b}v.putImageData(O,0,0),m!==" "&&Lze(e._textureAtlas,x,T,C)}}if(a=o[l],u(a)?C.index===-1?H6(e,a):u(a.textureInfo)&&(a.textureInfo=void 0):(a=new Ize,o[l]=a),a.textureInfo=C,a.dimensions=C.dimensions,C.index!==-1){let E=a.billboard,T=e._spareBillboards;u(E)||(T.length>0?E=T.pop():(E=e._billboardCollection.add({collection:e}),E._labelDimensions=new H,E._labelTranslate=new H),a.billboard=E),E.show=t._show,E.position=t._position,E.eyeOffset=t._eyeOffset,E.pixelOffset=t._pixelOffset,E.horizontalOrigin=_i.LEFT,E.verticalOrigin=t._verticalOrigin,E.heightReference=t._heightReference,E.scale=t.totalScale,E.pickPrimitive=t,E.id=t._id,E.image=x,E.translucencyByDistance=t._translucencyByDistance,E.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,E.scaleByDistance=t._scaleByDistance,E.distanceDisplayCondition=t._distanceDisplayCondition,E.disableDepthTestDistance=t._disableDepthTestDistance,E._batchIndex=t._batchIndex,E.outlineColor=t.outlineColor,t.style===Vr.FILL_AND_OUTLINE?(E.color=t._fillColor,E.outlineWidth=t.outlineWidth):t.style===Vr.FILL?(E.color=t._fillColor,E.outlineWidth=0):t.style===Vr.OUTLINE&&(E.color=z.TRANSPARENT,E.outlineWidth=t.outlineWidth)}}t._repositionAllGlyphs=!0}function Soe(e,t,n){return t===_i.CENTER?-e/2:t===_i.RIGHT?-(e+n.x):n.x}var io=new H,Uze=new H;function Vze(e){let t=e._glyphs,n=e._renderedText,i,r,o=0,s=0,a=[],c=Number.NEGATIVE_INFINITY,l=0,f=1,d,p=t.length,g=e._backgroundBillboard,m=H.clone(u(g)?e._backgroundPadding:H.ZERO,Uze);for(m.x/=e._relativeSize,m.y/=e._relativeSize,d=0;d<p;++d)n.charAt(d)===`
`?(a.push(o),++f,o=0):(i=t[d],r=i.dimensions,l=Math.max(l,r.height-r.descent),c=Math.max(c,r.descent),o+=r.width-r.minx,d<p-1&&(o+=t[d+1].dimensions.minx),s=Math.max(s,o));a.push(o);let A=l+c,x=e.totalScale,C=e._horizontalOrigin,E=e._verticalOrigin,T=0,S=a[T],v=Soe(S,C,m),D=(u(e._lineHeight)?e._lineHeight:Oze*e._fontSize)/e._relativeSize,M=D*(f-1),O=s,B=A+M;u(g)&&(O+=m.x*2,B+=m.y*2,g._labelHorizontalOrigin=C),io.x=v*x,io.y=0;let L=!0,_=0;for(d=0;d<p;++d)if(n.charAt(d)===`
`)++T,_+=D,S=a[T],v=Soe(S,C,m),io.x=v*x,L=!0;else if(i=t[d],r=i.dimensions,E===In.TOP?(io.y=r.height-l-m.y,io.y+=Is.PADDING):E===In.CENTER?io.y=(M+r.height-l)/2:E===In.BASELINE?(io.y=M,io.y-=Is.PADDING):(io.y=M+c+m.y,io.y-=Is.PADDING),io.y=(io.y-r.descent-_)*x,L&&(io.x-=Is.PADDING*x,L=!1),u(i.billboard)&&(i.billboard._setTranslate(io),i.billboard._labelDimensions.x=O,i.billboard._labelDimensions.y=B,i.billboard._labelHorizontalOrigin=C),d<p-1){let b=t[d+1];io.x+=(r.width-r.minx+b.dimensions.minx)*x}if(u(g)&&n.split(`
`).join("").length>0&&(C===_i.CENTER?v=-s/2-m.x:C===_i.RIGHT?v=-(s+m.x*2):v=0,io.x=v*x,E===In.TOP?io.y=A-l-c:E===In.CENTER?io.y=(A-l)/2-c:E===In.BASELINE?io.y=-m.y-c:io.y=0,io.y=io.y*x,g.width=O,g.height=B,g._setTranslate(io),g._labelTranslate=H.clone(io,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(io,b._labelTranslate))}}function Ioe(e,t){let n=t._glyphs;for(let i=0,r=n.length;i<r;++i)H6(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 tm(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 uu({scene:this._scene}),this._backgroundBillboardCollection.destroyTextureAtlas=!1,this._billboardCollection=new uu({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=z.clone(z.WHITE),this.show=y(e.show,!0),this.modelMatrix=N.clone(y(e.modelMatrix,N.IDENTITY)),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.blendOption=y(e.blendOption,wr.OPAQUE_AND_TRANSLUCENT)}Object.defineProperties(tm.prototype,{length:{get:function(){return this._labels.length}}});tm.prototype.add=function(e){let t=new Jg(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};tm.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),Ioe(this,e),!0}return!1};tm.prototype.removeAll=function(){let e=this._labels;for(let t=0,n=e.length;t<n;++t)Ioe(this,e[t]);e.length=0};tm.prototype.contains=function(e){return u(e)&&e._labelCollection===this};tm.prototype.get=function(e){return this._labels[e]};tm.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 Kg({context:i}),t.textureAtlas=this._textureAtlas),u(this._backgroundTextureAtlas)||(this._backgroundTextureAtlas=new Kg({context:i,initialSize:z6}),n.textureAtlas=this._backgroundTextureAtlas,Rze(this._backgroundTextureAtlas));let r=this._labelsToUpdate.length;for(let s=0;s<r;++s){let a=this._labelsToUpdate[s];if(a.isDestroyed())continue;let c=a._glyphs.length;a._rebindAllGlyphs&&(Fze(this,a),a._rebindAllGlyphs=!1),a._repositionAllGlyphs&&(Vze(a),a._repositionAllGlyphs=!1);let l=a._glyphs.length-c;this._totalGlyphCount+=l}let o=n.length>0?wr.TRANSLUCENT:this.blendOption;t.blendOption=o,n.blendOption=o,t._highlightColor=this._highlightColor,n._highlightColor=this._highlightColor,this._labelsToUpdate.length=0,n.update(e),t.update(e)};tm.prototype.isDestroyed=function(){return!1};tm.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 nm=tm;var dM=`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 Hc={};Hc.numberOfPoints=function(e,t,n){let i=h.distance(e,t);return Math.ceil(i/n)};Hc.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 kze=new me;Hc.extractHeights=function(e,t){let n=e.length,i=new Array(n);for(let r=0;r<n;r++){let o=e[r];i[r]=t.cartesianToCartographic(o,kze).height}return i};var zze=new N,Hze=new h,Poe=new h,Gze=new cn(h.UNIT_X,0),Ooe=new h,Wze=new cn(h.UNIT_X,0),jze=new h,qze=new h,W6=[];function Roe(e,t,n){let i=W6;i.length=e;let r;if(t===n){for(r=0;r<e;r++)i[r]=t;return i}let s=(n-t)/e;for(r=0;r<e;r++){let a=t+r*s;i[r]=a}return i}var xV=new me,AV=new me,Zg=new h,j6=new h,Yze=new h,G6=new ef,hM=new _a;function Xze(e,t,n,i,r,o,s,a){let c=i.scaleToGeodeticSurface(e,j6),l=i.scaleToGeodeticSurface(t,Yze),f=Hc.numberOfPoints(e,t,n),d=i.cartesianToCartographic(c,xV),p=i.cartesianToCartographic(l,AV),g=Roe(f,r,o);G6.setEndPoints(d,p);let m=G6.surfaceDistance/f,A=a;d.height=r;let x=i.cartographicToCartesian(d,Zg);h.pack(x,s,A),A+=3;for(let C=1;C<f;C++){let E=G6.interpolateUsingSurfaceDistance(C*m,AV);E.height=g[C],x=i.cartographicToCartesian(E,Zg),h.pack(x,s,A),A+=3}return A}function Kze(e,t,n,i,r,o,s,a){let c=i.cartesianToCartographic(e,xV),l=i.cartesianToCartographic(t,AV),f=Hc.numberOfPointsRhumbLine(c,l,n);c.height=0,l.height=0;let d=Roe(f,r,o);hM.ellipsoid.equals(i)||(hM=new _a(void 0,void 0,i)),hM.setEndPoints(c,l);let p=hM.surfaceDistance/f,g=a;c.height=r;let m=i.cartographicToCartesian(c,Zg);h.pack(m,s,g),g+=3;for(let A=1;A<f;A++){let x=hM.interpolateUsingSurfaceDistance(A*p,AV);x.height=d[A],m=i.cartographicToCartesian(x,Zg),h.pack(m,s,g),g+=3}return g}Hc.wrapLongitude=function(e,t){let n=[],i=[];if(u(e)&&e.length>0){t=y(t,N.IDENTITY);let r=N.inverseTransformation(t,zze),o=N.multiplyByPoint(r,h.ZERO,Hze),s=h.normalize(N.multiplyByPointAsVector(r,h.UNIT_Y,Poe),Poe),a=cn.fromPointNormal(o,s,Gze),c=h.normalize(N.multiplyByPointAsVector(r,h.UNIT_X,Ooe),Ooe),l=cn.fromPointNormal(o,c,Wze),f=1;n.push(h.clone(e[0]));let d=n[0],p=e.length;for(let g=1;g<p;++g){let m=e[g];if(cn.getPointDistance(l,d)<0||cn.getPointDistance(l,m)<0){let A=Qi.lineSegmentPlane(d,m,a,jze);if(u(A)){let x=h.multiplyByScalar(s,5e-9,qze);cn.getPointDistance(a,d)<0&&h.negate(x,x),n.push(h.add(A,x,new h)),i.push(f+1),h.negate(x,x),n.push(h.add(A,x,new h)),f=1}}n.push(h.clone(e[g])),f++,d=m}i.push(f)}return{positions:n,lengths:i}};Hc.generateArc=function(e){u(e)||(e={});let t=e.positions,n=t.length,i=y(e.ellipsoid,re.WGS84),r=y(e.height,0),o=Array.isArray(r);if(n<1)return[];if(n===1){let A=i.scaleToGeodeticSurface(t[0],j6);if(r=o?r[0]:r,r!==0){let x=i.geodeticSurfaceNormal(A,Zg);h.multiplyByScalar(x,r,x),h.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+=Hc.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=o?r[c]:r,E=o?r[c+1]:r;d=Xze(A,x,s,i,C,E,f,d)}W6.length=0;let p=t[n-1],g=i.cartesianToCartographic(p,xV);g.height=o?r[n-1]:r;let m=i.cartographicToCartesian(g,Zg);return h.pack(m,f,l-3),f};var Moe=new me,Jze=new me;Hc.generateRhumbArc=function(e){u(e)||(e={});let t=e.positions,n=t.length,i=y(e.ellipsoid,re.WGS84),r=y(e.height,0),o=Array.isArray(r);if(n<1)return[];if(n===1){let C=i.scaleToGeodeticSurface(t[0],j6);if(r=o?r[0]:r,r!==0){let E=i.geodeticSurfaceNormal(C,Zg);h.multiplyByScalar(E,r,E),h.add(C,E,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],Moe),f;for(c=0;c<n-1;c++)f=i.cartesianToCartographic(t[c+1],Jze),a+=Hc.numberOfPointsRhumbLine(l,f,s),l=me.clone(f,Moe);let d=(a+1)*3,p=new Array(d),g=0;for(c=0;c<n-1;c++){let C=t[c],E=t[c+1],T=o?r[c]:r,S=o?r[c+1]:r;g=Kze(C,E,s,i,T,S,p,g)}W6.length=0;let m=t[n-1],A=i.cartesianToCartographic(m,xV);A.height=o?r[n-1]:r;let x=i.cartographicToCartesian(A,Zg);return h.pack(x,p,d-3),p};Hc.generateCartesianArc=function(e){let t=Hc.generateArc(
`,this.material.shaderSource,Q0]}),o=t.getVertexShaderCallback()(dM),s=new He({defines:i,sources:[iu,o]});this.shaderProgram=Xt.fromCache({context:e,vertexShaderSource:s,fragmentShaderSource:r,attributeLocations:Pl})};function Koe(e){return h.dot(h.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(cn.ORIGIN_ZX_PLANE)===Qt.INTERSECTING}im.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===ne.SCENE3D||!Koe(e))return t=e._actualPositions.length,t*4-4;let n=0,i=e._segments.lengths;t=i.length;for(let r=0;r<t;++r)n+=i[r]*4-4;return n};var ls=new h,pf=new h,_f=new h,TV=new h,dHe=new oe,hHe=new H;im.prototype.write=function(e,t,n,i,r,o,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],m=g.width,A=g.show&&m>0,x=g._index,C=this.getSegments(g,a),E=C.positions,T=C.lengths,S=E.length,v=g.getPickId(s).color,D=0,M=0,O;for(let k=0;k<S;++k){k===0?g._loop?O=E[S-2]:(O=TV,h.subtract(E[0],E[1],O),h.add(E[0],O,O)):O=E[k-1],h.clone(O,pf),h.clone(E[k],ls),k===S-1?g._loop?O=E[1]:(O=TV,h.subtract(E[S-1],E[S-2],O),h.add(E[S-1],O,O)):O=E[k+1],h.clone(O,_f);let V=T[D];k===M+V&&(M+=V,++D);let G=k-M===0,U=k===M+T[D]-1;c===ne.SCENE2D&&(pf.z=0,ls.z=0,_f.z=0),(c===ne.SCENE2D||c===ne.MORPHING)&&(G||U)&&l-Math.abs(ls.x)<1&&((ls.x<0&&pf.x>0||ls.x>0&&pf.x<0)&&h.clone(ls,pf),(ls.x<0&&_f.x>0||ls.x>0&&_f.x<0)&&h.clone(ls,_f));let Y=G?2:0,j=U?2:4;for(let Q=Y;Q<j;++Q){Gn.writeElements(ls,e,n),Gn.writeElements(pf,e,n+6),Gn.writeElements(_f,e,n+12);let W=Q-2<0?-1:1;t[r]=k/(S-1),t[r+1]=2*(Q%2)-1,t[r+2]=W,t[r+3]=x,n+=6*3,r+=4}}let B=dHe;B.x=z.floatToByte(v.red),B.y=z.floatToByte(v.green),B.z=z.floatToByte(v.blue),B.w=z.floatToByte(v.alpha);let L=hHe;L.x=m,L.y=A?1:0;let _=c===ne.SCENE2D?g._boundingVolume2D:g._boundingVolumeWC,b=Gn.fromCartesian(_.center,Woe),w=b.high,I=oe.fromElements(b.low.x,b.low.y,b.low.z,_.radius,joe),R=qoe;R.x=0,R.y=Number.MAX_VALUE;let F=g.distanceDisplayCondition;u(F)&&(R.x=F.near,R.y=F.far),o.setBatchedAttribute(x,0,L),o.setBatchedAttribute(x,1,B),o.attributes.length>2&&(o.setBatchedAttribute(x,2,w),o.setBatchedAttribute(x,3,I),o.setBatchedAttribute(x,4,R))}};var mHe=new h,pHe=new h,_He=new h,koe=new h;im.prototype.writeForMorph=function(e,t){let n=this.modelMatrix,i=this.polylines,r=i.length;for(let o=0;o<r;++o){let s=i[o],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=koe,h.subtract(a[0],a[1],g),h.add(a[0],g,g)):g=a[p-1],g=N.multiplyByPoint(n,g,pHe);let m=N.multiplyByPoint(n,a[p],mHe),A;p===l-1?s._loop?A=a[1]:(A=koe,h.subtract(a[l-1],a[l-2],A),h.add(a[l-1],A,A)):A=a[p+1],A=N.multiplyByPoint(n,A,_He);let x=c[f];p===d+x&&(d+=x,++f);let C=p-d===0,E=p===d+c[f]-1,T=C?2:0,S=E?2:4;for(let v=T;v<S;++v)Gn.writeElements(m,e,t),Gn.writeElements(g,e,t+6),Gn.writeElements(A,e,t+12),t+=6*3}}};var gHe=new Array(1);im.prototype.updateIndices=function(e,t,n,i){let r=n.length-1,o=new q6(0,i,this);n[r].push(o);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=gHe;let A=p._actualPositions.length;if(A>0)g[0]=A;else continue}else g=p._segments.lengths;let m=g.length;if(m>0){let A=0;for(let x=0;x<m;++x){let C=g[x]-1;for(let E=0;E<C;++E)c+4>P.SIXTY_FOUR_KILOBYTES&&(p._locatorBuckets.push({locator:o,count:A}),A=0,t.push(4),a=[],e.push(a),c=0,o.count=s,s=0,i=0,o=new q6(0,0,this),n[++r]=[o]),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:o,count:A}),c+4>P.SIXTY_FOUR_KILOBYTES&&(t.push(0),a=[],e.push(a),c=0,o.count=s,i=0,s=0,o=new q6(0,0,this),n[++r]=[o])}p._clean()}return o.count=s,i};im.prototype.getPolylineStartIndex=function(e){let t=this.polylines,n=0,i=t.length;for(let r=0;r<i;++r){let o=t[r];if(o===e)break;n+=o._actualLength}return n};var _E={positions:void 0,lengths:void 0},zoe=new Array(1),yHe=new h,AHe=new me;im.prototype.getSegments=function(e,t){let n=e._actualPositions;if(this.mode===ne.SCENE3D)return zoe[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 Ud(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=y(e.ellipsoid,re.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=z.clone(z.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(Ud.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function FHe(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,r=e._ellipsoid,o=e._center,s=2+le.packedLength+re.packedLength+h.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,le.pack(t,a,c),c+=le.packedLength,re.pack(r,a,c),c+=re.packedLength,h.pack(o,a,c),a}var UHe=new yi("createVectorTilePolylines",5),gE={previousPosition:0,currentPosition:1,nextPosition:2,expandAndWidth:3,a_batchId:4};function VHe(e,t){if(u(e._va))return;let n=e._positions,i=e._widths,r=e._counts,o=e._transferrableBatchIds,s=e._packedBuffer;u(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),r=e._counts=r.slice(),o=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=FHe(e));let a=[n.buffer,i.buffer,r.buffer,o.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:r.buffer,batchIds:o.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},l=UHe.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),kHe(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function kHe(e,t){if(!u(e._va)){let n=e._currentPositions,i=e._previousPositions,r=e._nextPositions,o=e._expandAndWidth,s=e._vertexBatchIds,a=e._indices,c=i.byteLength+n.byteLength+r.byteLength;c+=o.byteLength+s.byteLength+a.byteLength,e._trianglesLength=a.length/3,e._geometryByteLength=c;let l=ft.createVertexBuffer({context:t,typedArray:i,usage:Fe.STATIC_DRAW}),f=ft.createVertexBuffer({context:t,typedArray:n,usage:Fe.STATIC_DRAW}),d=ft.createVertexBuffer({context:t,typedArray:r,usage:Fe.STATIC_DRAW}),p=ft.createVertexBuffer({context:t,typedArray:o,usage:Fe.STATIC_DRAW}),g=ft.createVertexBuffer({context:t,typedArray:s,usage:Fe.STATIC_DRAW}),m=ft.createIndexBuffer({context:t,typedArray:a,usage:Fe.STATIC_DRAW,indexDatatype:a.BYTES_PER_ELEMENT===2?Ue.UNSIGNED_SHORT:Ue.UNSIGNED_INT}),A=[{index:gE.previousPosition,vertexBuffer:l,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:gE.currentPosition,vertexBuffer:f,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:gE.nextPosition,vertexBuffer:d,componentDatatype:X.FLOAT,componentsPerAttribute:3},{index:gE.expandAndWidth,vertexBuffer:p,componentDatatype:X.FLOAT,componentsPerAttribute:2},{index:gE.a_batchId,vertexBuffer:g,componentDatatype:X.UNSIGNED_SHORT,componentsPerAttribute:1}];e._va=new si({context:t,attributes:A,indexBuffer:m}),e._positions=void 0,e._widths=void 0,e._co
void main()
{
out_FragColor = u_highlightColor;
}
`;function WHe(e,t){if(u(e._sp))return;let n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(xM),r=n.getFragmentShaderCallback(!1,void 0,!1)(GHe),o=new He({defines:["VECTOR_TILE",kt.isInternetExplorer()?"":"CLIP_POLYLINE"],sources:[iu,i]}),s=new He({defines:["VECTOR_TILE"],sources:[r]});e._sp=Xt.fromCache({context:t,vertexShaderSource:o,fragmentShaderSource:s,attributeLocations:gE})}function jHe(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)}Ud.getPolylinePositions=function(e,t){let n=e._batchIds,i=e._decodedPositions,r=e._decodedPositionOffsets;if(!u(n)||!u(i))return;let o,s,a=n.length,c=0,l=0;for(o=0;o<a;++o)n[o]===t&&(c+=r[o+1]-r[o]);if(c===0)return;let f=new Float64Array(c*3);for(o=0;o<a;++o)if(n[o]===t){let d=r[o],p=r[o+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};Ud.prototype.getPositions=function(e){return Ud.getPolylinePositions(this,e)};Ud.prototype.createFeatures=function(e,t){let n=this._batchIds,i=n.length;for(let r=0;r<i;++r){let o=n[r];t[o]=new bs(e,o)}};Ud.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function qHe(e,t){let n=e._batchIds,i=n.length;for(let r=0;r<i;++r){let o=n[r],s=t[o];s.show=!0,s.color=z.WHITE}}var YHe=new z,XHe=z.WHITE,KHe=!0;Ud.prototype.applyStyle=function(e,t){if(!u(e)){qHe(this,t);return}let n=this._batchIds,i=n.length;for(let r=0;r<i;++r){let o=n[r],s=t[o];s.color=u(e.color)?e.color.evaluateColor(s,YHe):XHe,s.show=u(e.show)?e.show.evaluate(s):KHe}};Ud.prototype.update=function(e){let t=e.context;if(!this._ready){if(u(this._promise)||(this._promise=VHe(this,t)),u(this._error)){let i=this._error;throw this._error=void 0,i}return}zHe(this,t),WHe(this,t),HHe(this);let n=e.passes;(n.render||n.pick)&&jHe(this,e)};Ud.prototype.isDestroyed=function(){return!1};Ud.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),ue(this)};var JA=Ud;var TM=`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 EM=`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 Jp(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=y(e.ellipsoid,re.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(oi._defaultMinTerrainHeight,oi._defaultMaxTerrainHeight),this._boundingVolume=Pn.fromRectangle(e.rectangle,oi._defaultMinTerrainHeight,oi._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=z.clone(z.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(Jp.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function JHe(e,t,n){let i=oi.getMinimumMaximumHeights(t,n),r=i.minimumTerrainHeight,o=i.maximumTerrainHeight,s=e._minimumMaximumVectorHeights;s.x=r,s.y=o;let a=e._boundingVolume,c=e._rectangle;Pn.fromRectangle(c,r,o,n,a)}function ZHe(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,r=e._ellipsoid,o=e._center,s=2+le.packedLength+re.packedLength+h.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,le.pack(t,a,c),c+=le.packedLength,re.pack(r,a,c),c+=re.packedLength,h.pack(o,a,c),a}var QHe=new yi("createVectorTileClampedPolylines"),$g={startEllipsoidNormal:0,endEllipsoidNormal:1,startPositionAndHeight:2,endPositionAndHeight:3,startFaceNormalAndVertexCorner:4,endFaceNormalAndHalfWidth:5,a_batchId:6};function $He(e,t){if(u(e._va))return;let n=e._positions,i=e._widths,r=e._counts,o=e._transferrableBatchIds,s=e._packedBuffer;u(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),r=e._counts=r.slice(),o=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=ZHe(e));let a=[n.buffer,i.buffer,r.buffer,o.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:r.buffer,batchIds:o.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},l=QHe.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),eGe(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function eGe(e,t){if(!u(e._va)){let n=e._startEllipsoidNormals,i=e._endEllipsoidNormals,r=e._startPositionAndHeights,o=e._endPositionAndHeights,s=e._startFaceNormalAndVertexCornerIds,a=e._endFaceNormalAndHalfWidths,c=e._vertexBatchIds,l=e._indices,f=n.byteLength+i.byteLength;f+=r.byteLength+o.byteLength,f+=s.byteLength+a.byteLength,f+=c.byteLength+l.byteLength,e._trianglesLength=l.length/3,e._geometryByteLength=f;let d=ft.createVertexBuffer({context:t,typedArray:n,usage:Fe.STATIC
Geometric error: ${e.geometricError}`,r++),t.debugShowRenderingStatistics&&(i+=`
Commands: ${e.commandsLength}`,r++,e.content.pointsLength>0&&(i+=`
Points: ${e.content.pointsLength}`,r++),e.content.trianglesLength>0&&(i+=`
Triangles: ${e.content.trianglesLength}`,r++),i+=`
Features: ${e.content.featuresLength}`,r++),t.debugShowMemoryUsage&&(i+=`
Texture Memory: ${aae(e.content.texturesByteLength)}`,i+=`
Geometry Memory: ${aae(e.content.geometryByteLength)}`,r+=2),t.debugShowUrl)if(e.hasMultipleContents){i+=`
Urls:`;let s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+=`
- ${s[a]}`;r+=s.length}else i+=`
Url: ${e._contentHeader.uri}`,r++;let o={text:i.substring(1),position:n,font:`${19-r}px sans-serif`,showBackground:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY};return t._tileDebugLabels.add(o)}function t6e(e,t){let n=e._selectedTiles,i=n.length,r=e._emptyTiles,o=r.length;if(e._tileDebugLabels.removeAll(),e.debugPickedTileLabelOnly){if(u(e.debugPickedTile)){let s=u(e.debugPickPosition)?e.debugPickPosition:I9(e.debugPickedTile),a=P9(e.debugPickedTile,e,s);a.pixelOffset=new H(15,-15)}}else{for(let s=0;s<i;++s){let a=n[s];P9(a,e,I9(a))}for(let s=0;s<o;++s){let a=r[s];(a.hasTilesetContent||a.hasImplicitContent)&&P9(a,e,I9(a))}}e._tileDebugLabels.update(t)}function n6e(e,t,n){e._styleEngine.applyStyle(e),e._styleApplied=!0;let{commandList:i,context:r}=t,o=i.length,s=e._selectedTiles,a=e.isSkippingLevelOfDetail&&e._hasMixedContent&&r.stencilBuffer&&s.length>0;e._backfaceCommands.length=0,a&&(u(e._stencilClearCommand)||(e._stencilClearCommand=new li({stencil:0,pass:be.CESIUM_3D_TILE,renderState:Ve.fromCache({stencilMask:Lt.SKIP_LOD_MASK})})),i.push(e._stencilClearCommand));let{statistics:c,tileVisible:l}=e,f=n.isRender,d=i.length;for(let m=0;m<s.length;++m){let A=s[m];f&&l.raiseEvent(A),A.update(e,t,n),c.incrementSelectionCounts(A.content),++c.selected}let p=e._emptyTiles;for(let m=0;m<p.length;++m)p[m].update(e,t,n);let g=i.length-d;if(e._backfaceCommands.trim(),a){let m=e._backfaceCommands.values,A=m.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]=m[x]}g=i.length-o,c.numberOfCommands=g,f&&(e.pointCloudShading.attenuation&&e.pointCloudShading.eyeDomeLighting&&g>0&&e._pointCloudEyeDomeLighting.update(t,o,e.pointCloudShading,e.boundingSphere),e.debugShowGeometricError||e.debugShowRenderingStatistics||e.debugShowMemoryUsage||e.debugShowUrl?(u(e._tileDebugLabels)||(e._tileDebugLabels=new nm),t6e(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}var uae=[];function i6e(e,t){let n=t,i=uae;for(i.push(t);i.length>0;){t=i.pop();let r=t.children;for(let o=0;o<r.length;++o)i.push(r[o]);t!==n&&(r6e(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function fae(e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function r6e(e,t){e._cache.unloadTile(e,t,fae),t.destroy()}go.prototype.trimLoadedTiles=function(){this._cache.trim()};function o6e(e,t){let n=e._statistics,i=e._statisticsLast,r=n.numberOfPendingRequests,o=n.numberOfTilesProcessing,s=i.numberOfPendingRequests,a=i.numberOfTilesProcessing;c_.clone(n,i);let c=r!==s||o!==a;c&&t.afterRender.push(function(){return e.loadProgress.raiseEvent(r,o),!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 s6e(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 a6e(e,t){t.frameNumber===e._updatedModelMatrixFrame&&u(e._previousModelMatrix)||(e._updatedModelMatrixFrame=t.frameNumber,e._modelMatrixChanged=!N.equals(e.modelMatrix,e._previousModelMatrix),e._modelMatrixChanged&&(e._previousModelMatrix=N.clone(e.modelMatrix,e._previousModelMatrix)))}function c6e(e,t,n,i){if(t.mode===ne.MORPHING||!u(e._root))return!1;let r=e._statistics;r.clear(),++e._updatedVisibilityFrame,s6e(e),a6e(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;let o=e.getTraversal(i).selectTiles(e,t);if(i.requestTiles&&Z5e(e),n6e(e,t,i),c_.clone(r,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 fR=`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 _9e=Rs.SHOW_INDEX,K9=Rs.POSITION_INDEX,ace=Rs.COLOR_INDEX,g9e=Rs.OUTLINE_COLOR_INDEX,y9e=Rs.OUTLINE_WIDTH_INDEX,A9e=Rs.PIXEL_SIZE_INDEX,cce=Rs.SCALE_BY_DISTANCE_INDEX,lce=Rs.TRANSLUCENCY_BY_DISTANCE_INDEX,uce=Rs.DISTANCE_DISPLAY_CONDITION_INDEX,x9e=Rs.DISABLE_DEPTH_DISTANCE_INDEX,J9=Rs.NUMBER_OF_PROPERTIES,ic={positionHighAndSize:0,positionLowAndOutline:1,compressedAttribute0:2,compressedAttribute1:3,scaleByDistance:4,distanceDisplayConditionAndDisableDepth:5};function wf(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(J9),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=N.clone(y(e.modelMatrix,N.IDENTITY)),this._modelMatrix=N.clone(N.IDENTITY),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.blendOption=y(e.blendOption,wr.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(wf.prototype,{length:{get:function(){return Z9(this),this._pointPrimitives.length}}});function fce(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}wf.prototype.add=function(e){let t=new Rs(e,this);return t._index=this._pointPrimitives.length,this._pointPrimitives.push(t),this._createVertexArray=!0,t};wf.prototype.remove=function(e){return this.contains(e)?(this._pointPrimitives[e._index]=null,this._pointPrimitivesRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};wf.prototype.removeAll=function(){fce(this._pointPrimitives),this._pointPrimitives=[],this._pointPrimitivesToUpdate=[],this._pointPrimitivesToUpdateIndex=0,this._pointPrimitivesRemoved=!1,this._createVertexArray=!0};function Z9(e){if(e._pointPrimitivesRemoved){e._pointPrimitivesRemoved=!1;let t=[],n=e._pointPrimitives,i=n.length;for(let r=0,o=0;r<i;++r){let s=n[r];s&&(s._index=o++,t.push(s))}e._pointPrimitives=t}}wf.prototype._updatePointPrimitive=function(e,t){e._dirty||(this._pointPrimitivesToUpdate[this._pointPrimitivesToUpdateIndex++]=e),++this._propertiesChanged[t]};wf.prototype.contains=function(e){return u(e)&&e._pointPrimitiveCollection===this};wf.prototype.get=function(e){return Z9(this),this._pointPrimitives[e]};wf.prototype.computeNewBuffersUsage=function(){let e=this._buffersUsage,t=!1,n=this._propertiesChanged;for(let i=0;i<J9;++i){let r=n[i]===0?Fe.STATIC_DRAW:Fe.STREAM_DRAW;t=t||e[i]!==r,e[i]=r}return t};function C9e(e,t,n){return new Wp(e,[{index:ic.positionHighAndSize,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[K9]},{index:ic.positionLowAndShow,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[K9]},{index:ic.compressedAttribute0,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[ace]},{index:ic.compressedAttribute1,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[lce]},{index:ic.scaleByDistance,componentsPerAttribute:4,componentDatatype:X.FLOAT,usage:n[cce]},{index:ic.distanceDisplayConditionAndDisableDepth,componentsPerAttribute:3,componentDatatype:X.FLOAT,usage:n[uce]}],t)}var Y9=new Gn;function dce(e,t,n,i){let r=i._index,o=i._getActualPosition();e._mode===ne.SCENE3D&&(ae.expand(e._baseVolume,o,e._baseVolume),e._boundingVolume
in vec2 textureCoordinates;
out vec2 v_textureCoordinates;
void main()
{
gl_Position = position;
v_textureCoordinates = textureCoordinates;
}
`;function z4(e){this._context=e}var HB,A$e=new nt({primitiveType:Be.TRIANGLES}),x$e=new li({color:new z(0,0,0,0)});function C$e(e,t){return new Ks({context:e,colorTextures:[t],destroyAttachments:!1})}function T$e(e,t){return Xt.fromCache({context:e,vertexShaderSource:Kx,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function E$e(e,t){return(!u(HB)||HB.viewport.width!==e||HB.viewport.height!==t)&&(HB=Ve.fromCache({viewport:new Xe(0,0,e,t)})),HB}z4.prototype.execute=function(e){u(e.preExecute)&&e.preExecute(e);let t=e.outputTexture,n=t.width,i=t.height,r=this._context,o=u(e.vertexArray)?e.vertexArray:r.getViewportQuadVertexArray(),s=u(e.shaderProgram)?e.shaderProgram:T$e(r,e.fragmentShaderSource),a=C$e(r,t),c=E$e(n,i),l=e.uniformMap,f=x$e;f.framebuffer=a,f.renderState=c,f.execute(r);let d=A$e;d.vertexArray=o,d.renderState=c,d.shaderProgram=s,d.uniformMap=l,d.framebuffer=a,d.execute(r),a.destroy(),e.persists||(s.destroy(),u(e.vertexArray)&&o.destroy()),u(e.postExecute)&&e.postExecute(t)};z4.prototype.isDestroyed=function(){return!1};z4.prototype.destroy=function(){return ue(this)};var GB=z4;function b$e(e){this.context=e,this.framebuffer=void 0,this.blendingEnabled=void 0,this.scissorTest=void 0,this.viewport=void 0}var uc=b$e;function fh(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(fh.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});fh.prototype.replaceShaderProgram=function(e){return u(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function S$e(e){let t=Object.keys(e).sort();return JSON.stringify(e,t)}fh.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 r=t.getCacheKey(),o=n.getCacheKey(),s=u(i)?S$e(i):"",a=`${r}:${o}:${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 Xt({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};fh.prototype.replaceDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,r=t+i.keyword,o=this._shaders[r];if(u(o)){Bj(this,o);let s=i.derivedKeywords.indexOf(t);s>-1&&i.derivedKeywords.splice(s,1)}return this.createDerivedShaderProgram(e,t,n)};fh.prototype.getDerivedShaderProgram=function(e,t){let n=e._cachedShader,i=t+n.keyword,r=this._shaders[i];if(u(r))return r.shaderProgram};fh.prototype.createDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,r=t+i.keyword,o=n.vertexShaderSource,s=n.fragmentShaderSource,a=n.attributeLocations;typeof o=="string"&&(o=new He({sources:[o]})),typeof s=="string"&&(s=new He({sources:[s]}));let c=this._context,l=o.createCombinedVertexShader(c),f=s.createCombinedFragmentShader(c),d=new Xt({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:o,vertexShaderText:l,fragmentShaderSource:s,fragmentShaderText:f,attributeLocations:a}),p={cache:this,shaderProgram:d,keyword:r,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),d._cachedShader=p,this._shaders[r]=p,d};function Bj(e,t){let n=t.derivedKeywords,i=n.length;for(let r=0;r<i;++r){let o=n[r]+t.keyword,s=e._shaders[o];Bj(e,s)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}fh.prototype.destroyReleasedShaderPrograms=function(){let e=this._shadersToRelease;for(let t in e)if(e.hasOwnProperty(t)){let n=e[t];Bj(this,n),--this._numberOfShaders}this._shadersToRelease={}};fh.prototype.releaseShaderProgram=function(e){if(u(e)){let t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};fh.prototype.isDestroyed=
${r}`),t}var vm=Ftt;function K4(e,t,n,i,r,o,s){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=r,this.timesRetried=y(o,0),this.retry=!1,this.error=s}K4.reportError=function(e,t,n,i,r,o,s,a){let c=e;return u(e)?(c.provider=t,c.message=i,c.x=r,c.y=o,c.level=s,c.retry=!1,c.error=a,++c.timesRetried):c=new K4(t,i,r,o,s,0,a),u(n)&&n.numberOfListeners>0?n.raiseEvent(c):u(t)&&console.log(`An error occurred in "${t.constructor.name}": ${vm(i)}`),c};K4.reportSuccess=function(e){u(e)&&(e.timesRetried=-1)};var xi=K4;function Wy(e){if(e=y(e,y.EMPTY_OBJECT),this._ellipsoid=y(e.ellipsoid,re.WGS84),this._numberOfLevelZeroTilesX=y(e.numberOfLevelZeroTilesX,1),this._numberOfLevelZeroTilesY=y(e.numberOfLevelZeroTilesY,1),this._projection=new Pi(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(Wy.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});Wy.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};Wy.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};Wy.prototype.rectangleToNativeRectangle=function(e,t){let n=this._projection,i=n.project(le.southwest(e)),r=n.project(le.northeast(e));return u(t)?(t.west=i.x,t.south=i.y,t.east=r.x,t.north=r.y,t):new le(i.x,i.y,r.x,r.y)};Wy.prototype.tileXYToNativeRectangle=function(e,t,n,i){let r=this.getNumberOfXTilesAtLevel(n),o=this.getNumberOfYTilesAtLevel(n),s=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/r,a=this._rectangleSouthwestInMeters.x+e*s,c=this._rectangleSouthwestInMeters.x+(e+1)*s,l=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/o,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)};Wy.prototype.tileXYToRectangle=function(e,t,n,i){let r=this.tileXYToNativeRectangle(e,t,n,i),o=this._projection,s=o.unproject(new H(r.west,r.south)),a=o.unproject(new H(r.east,r.north));return r.west=s.longitude,r.south=s.latitude,r.east=a.longitude,r.north=a.latitude,r};Wy.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!le.contains(i,e))return;let r=this.getNumberOfXTilesAtLevel(t),o=this.getNumberOfYTilesAtLevel(t),a=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/r,l=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/o,d=this._projection.project(e),p=d.x-this._rectangleSouthwestInMeters.x,g=this._rectangleNortheastInMeters.y-d.y,m=p/a|0;m>=r&&(m=r-1);let A=g/l|0;return A>=o&&(A=o-1),u(n)?(n.x=m,n.y=A,n):new H(m,A)};var No=Wy;var Utt=15;function Hj(e){this.ellipsoid=y(e.ellipsoid,re.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}Hj.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 Vtt(e,t){let n=t.copyrightText;u(n)&&(e.credit=new Yt(n));let i=t.s
${t.message}`),e.previousError=xi.reportError(e.previousError,n,u(n)?n._errorEvent:void 0,i),e.previousError.retry)return $4(e,n);throw new de(i)}async function nnt(e,t,n){await Cpe(e,t,n);let i=e.overallAvailability.length;if(i>0){let r=e.availability=new hh(e.tilingScheme,e.overallMaxZoom);for(let o=0;o<i;++o){let s=e.overallAvailability[o];for(let a=0;a<s.length;++a){let c=s[a];r.addAvailableTileRange(o,c[0],c[1],c[2],c[3])}}}if(e.attribution.length>0){let r=new Yt(e.attribution);e.tileCredits.push(r)}return!0}async function $4(e,t){try{let n=await e.layerJsonResource.fetchJson();return nnt(e,n,t)}catch(n){return u(n)&&n.statusCode===404?(await Cpe(e,{tilejson:"2.1.0",format:"heightmap-1.0",version:"1.0.0",scheme:"tms",tiles:["{z}/{x}/{y}.terrain?v={version}"]},t),!0):tnt(e,n,t)}}function Mu(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 ge;let t=e.credit;typeof t=="string"&&(t=new Yt(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=Mu._initializeReadyPromise(e,this))}Mu._initializeReadyPromise=async function(e,t){let n=await Promise.resolve(e.url),i=new Zj(e),r=De.createIfNeeded(n);return r.appendForwardSlash(),i.lastResource=r,i.layerJsonResource=i.lastResource.getDerivedResource({url:"layer.json"}),await $4(i,t),i.build(t),!0};var Kj={OCT_VERTEX_NORMALS:1,WATER_MASK:2,METADATA:4};function xpe(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 int(e,t,n,i,r){let o=new Uint16Array(t,0,e._heightmapWidth*e._heightmapWidth);return new wa({buffer:o,childTileMask:new Uint8Array(t,o.byteLength,1)[0],waterMask:new Uint8Array(t,o.byteLength+1,t.byteLength-o.byteLength-1),width:e._heightmapWidth,height:e._heightmapWidth,structure:e._heightmapStructure,credits:e._tileCredits})}function rnt(e,t,n,i,r,o){let s=o.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,m=3,A=Uint16Array.BYTES_PER_ELEMENT,x=A*m,C=new DataView(t),E=new h(C.getFloat64(a,!0),C.getFloat64(a+8,!0),C.getFloat64(a+16,!0));a+=f;let T=C.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let S=C.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let v=new ae(new h(C.getFloat64(a,!0),C.getFloat64(a+8,!0),C.getFloat64(a+16,!0)),C.getFloat64(a+f,!0));a+=d;let D=new h(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*m);let B=O.subarray(0,M),L=O.subarray(M,2*M),_=O.subarray(M*2,3*M);Wn.zigZagDeltaDecode(B,L,_),a%A!==0&&(a+=A-a%A);let b=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let w=Ue.createTypedArrayFromArrayBuffer(M,t,a,b*m);a+=b*x;let I=0,R=w.length;for(let se=0;se<R;++se){let Ae=w[se];w[se]=I-Ae,Ae===0&&++I}let F=C.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let k=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 Y=Ue.createTypedArrayFromArrayBuffer(M,t,a,U);a+=U*A;let j=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 Bu(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 De)&&(t=e.url);let n=De.createIfNeeded(t);n.appendForwardSlash(),this._resource=n;let i=this;this._readyPromise=Lpe(this).then(function(){return i.getQuadTreePacket("",i._quadPacketVersion)}).then(function(){return!0}).catch(function(r){let o=`An error occurred while accessing ${dq(i,"",1).url}.`;return Promise.reject(new de(o))})}}Object.defineProperties(Bu.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}}});Bu.fromUrl=async function(e){let t=e;typeof t!="string"&&!(t instanceof De)&&(t=e.url);let n=De.createIfNeeded(t);n.appendForwardSlash();let i=new Bu;i._resource=n;try{await Lpe(i),await i.getQuadTreePacket("",i._quadPacketVersion)}catch(r){let o=`An error occurred while accessing ${dq(i,"",1).url}: ${r}`;throw new de(o)}return i};Bu.tileXYToQuadKey=function(e,t,n){let i="";for(let r=n;r>=0;--r){let o=1<<r,s=0;mc(t,o)?mc(e,o)&&(s|=1):(s|=2,mc(e,o)||(s|=1)),i+=s}return i};Bu.quadKeyToTileXY=function(e){let t=0,n=0,i=e.length-1;for(let r=i;r>=0;--r){let o=1<<r,s=+e[i-r];mc(s,2)?mc(s,1)||(t|=o):(n|=o,mc(s,1)&&(t|=o))}return{x:t,y:n,level:i}};Bu.prototype.isValid=function(e){let t=this.getTileInformationFromQuadKey(e);if(u(t))return t!==null;let n=!0,i=e,r;for(;i.length>1;)if(r=i.substring(i.length-1),i=i.substring(0,i.length-1),t=this.getTileInformationFromQuadKey(i),u(t)){!t.hasSubtree()&&!t.hasChild(parseInt(r))&&(n=!1);break}else if(t===null){n=!1;break}return n};var Bpe=new yi("decodeGoogleEarthEnterprisePacket");Bu.prototype.getQuadTreePacket=function(e,t,n){t=y(t,1),e=y(e,"");let r=dq(this,e,t,n).fetchArrayBuffer();if(!u(r))return;let o=this._tileInfo,s=this.key;return r.then(function(a){return Bpe.scheduleTask({buffer:a,quadKey:e,type:"Metadata",key:s},[a]).then(function(l){let f,d=-1;if(e!==""){d=e.length+1;let m=l[e];f=o[e],f._bits|=m._bits,delete l[e]}let p=Object.keys(l);p.sort(function(m,A){return m.length-A.length});let g=p.length;for(let m=0;m<g;++m){let A=p[m];if(l[A]!==null){let C=rL.clone(l[A]),E=A.length;if(E===d)C.setParent(f);else if(E>1){let T=o[A.substring(0,A.length-1)];C.setParent(T)}o[A]=C}else o[A]=null}})})};Bu.prototype.populateSubtree=function(e,t,n,i){let r=Bu.tileXYToQuadKey(e,t,n);return fq(this,r,i)};function fq(e,t,n){let i=e._tileInfo,r=t,o=i[r];if(u(o)&&(!o.hasSubtree()||o.hasChildren()))return o;for(;o===void 0&&r.length>1;)r=r.substring(0,r.length-1),o=i[r];let s,a=e._subtreePromises,c=a[r];if(u(c))return c.then(function(){return s=new Gr({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),fq(e,t,s)});if(!u(o)||!o.hasSubtree())return Promise.reject(new de(`Couldn't load metadata for tile ${t}`));if(c=e.getQuadTreePacket(r,o.cnodeVersion,n),!!u(c))return a[r]=c,c.then(function(){return s=new Gr({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),fq(e,t,s)}).finally(function(){delete a[r]})}Bu.prototype.getTileInformation=function(e,t,n){let i=Bu.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 Kit(e,t){S_e(e);let n=e._framebuffers,i=n.length,r=new Array(i);for(let o=0;o<i;++o)r[o]=t.createViewportQuadCommand(Xit(o,i),{framebuffer:n[o].framebuffer,uniformMap:Yit(e,o)});e._commands=r}cC.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 z(0,0,0,0),framebuffer:void 0}));let i=t.length;for(let r=0;r<i;++r)t[r].clear(e,n)};cC.prototype.update=function(e){let t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,qit(this,e),Kit(this,e),this._ready||(this._ready=!0)),this._minMaxLuminance.x=this.minimumLuminance,this._minMaxLuminance.y=this.maximumLuminance;let i=this._framebuffers,r=i[i.length-1];i[i.length-1]=this._previousLuminance,this._commands[this._commands.length-1].framebuffer=this._previousLuminance.framebuffer,this._previousLuminance=r};cC.prototype.execute=function(e,t){this._colorTexture=t;let n=this._commands;if(!u(n))return;let i=n.length;for(let r=0;r<i;++r)n[r].execute(e)};cC.prototype.isDestroyed=function(){return!1};cC.prototype.destroy=function(){return b_e(this),S_e(this),ue(this)};var yL=cC;var Jit={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"},lS=Object.freeze(Jit);function AL(e){}AL.prototype.isReady=function(){return!0};AL.prototype.shouldDiscardImage=function(e){return AL.EMPTY_IMAGE===e};var dz;Object.defineProperties(AL,{EMPTY_IMAGE:{get:function(){return u(dz)||(dz=new Image,dz.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),dz}}});var uS=AL;function $q(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}$q.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 r=t[n];if(r.credit instanceof Yt)break;r.credit=new Yt(r.attribution);let o=r.coverageAreas;for(let s=0,a=r.coverageAreas.length;s<a;++s){let c=o[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 Zit(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 Qit(e,t,n){let i=`An error occurred while accessing ${e.url}`;throw u(t)&&u(t.message)&&(i+=`: ${t.message}`),xi.reportError(void 0,n,u(n)?n._errorEvent:void 0,i,void 0,void 0,void 0,t),new de(i)}async function v_e(e,t,n){let i=e.url,r=_s._metadataCache[i];u(r)||(r=e.fetchJsonp("jsonp"),_s._metadataCache[i]=r);try{let o=await r;return Zit(o,t)}catch(o){Qit(e,o,n)}}function _s(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,lS.AERIAL),this._culture=y(e.culture,""),this._key=e.key,this._tileDiscardPolicy=e.tileDiscardPolicy,u(this._tileDiscardPolicy)||(this._tileDiscardPolicy=new uS),this._proxy=e.proxy,this._credit=new Yt(`<a href="https://www.microsoft.com/en-us/maps/product/enduserterms"><img src="${_s.logoUrl}" title="Bing Imagery"/></a>`),this._tilingScheme=new No({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 CL(){this._colorTexture=void 0,this._drawCommand=void 0}Object.defineProperties(CL.prototype,{colorTexture:{get:function(){return this._colorTexture}}});function ort(e,t,n){let i=t.createViewportQuadCommand(xL,{framebuffer:n,renderState:Ve.fromCache({viewport:new Xe(0,0,256,256)})});e._drawCommand=i}CL.prototype.update=function(e){if(!u(this._colorTexture)){let t=e.context,n=new Ot({context:t,width:256,height:256,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,sampler:un.NEAREST});this._colorTexture=n;let i=new Ks({context:t,colorTextures:[n],destroyAttachments:!1});ort(this,t,i),this._drawCommand.execute(t),i.destroy(),this._drawCommand.shaderProgram=this._drawCommand.shaderProgram&&this._drawCommand.shaderProgram.destroy()}};CL.prototype.isDestroyed=function(){return!1};CL.prototype.destroy=function(){return this._colorTexture=this._colorTexture&&this._colorTexture.destroy(),ue(this)};var TL=CL;var P_e={};function srt(e,t,n){let i,r,o;if(e instanceof wi){let s=Math.tan(.5*e.fovy);return i=e.near,r=e.near*s,o=e.aspectRatio*r,Math.max(t*i/o,n*i/r)}else if(e instanceof Qc)return i=e.near,r=e.top,o=e.right,Math.max(t*i/o,n*i/r);return Math.max(t,n)}var art=new h,w_e=new h;function O_e(e,t,n,i){if(u(i)&&n(.5)>i){let r=n(0),o=n(1),s=n(.5),a=s-r,c=s-o;return function(l){let f=n(l);if(l<=.5){let p=(f-r)/a;return P.lerp(e,-P.PI_OVER_TWO,p)}let d=(f-o)/c;return P.lerp(-P.PI_OVER_TWO,t,1-d)}}return function(r){return P.lerp(e,t,r)}}function iY(e,t,n,i,r){let o=r,s=Math.max(n,i);if(!u(o)){let a=e.position,c=t,l=e.up,f=e.right,d=e.frustum,p=h.subtract(a,c,art),g=h.magnitude(h.multiplyByScalar(l,h.dot(p,l),w_e)),m=h.magnitude(h.multiplyByScalar(f,h.dot(p,f),w_e));o=Math.min(srt(d,g,m)*.2,1e9)}if(s<o){let l=-Math.pow((o-n)*1e6,.125),f=Math.pow((o-i)*1e6,1/8);return function(d){let p=d*(f-l)+l;return-Math.pow(p,8)/1e6+o}}return function(a){return P.lerp(n,i,a)}}function EL(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 M_e=new h;function crt(e,t,n,i,r,o,s,a){let c=e.camera,l=h.clone(c.position,M_e),f=c.pitch,d=EL(c.heading,i),p=EL(c.roll,o),g=iY(c,n,l.z,n.z,s),m=O_e(f,r,g,a);function A(x){let C=x.time/t;c.setView({orientation:{heading:P.lerp(d,i,C),pitch:m(C),roll:P.lerp(p,o,C)}}),H.lerp(l,n,C,c.position),c.position.z=g(C)}return A}function lrt(e,t){e.longitude<t.longitude?e.longitude+=P.TWO_PI:t.longitude+=P.TWO_PI}function urt(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 frt=new me,drt=new me;function hrt(e,t,n,i,r,o,s,a,c,l){let f=e.camera,p=e.mapProjection.ellipsoid,g=me.clone(f.positionCartographic,frt),m=f.pitch,A=EL(f.heading,i),x=EL(f.roll,o),C=p.cartesianToCartographic(n,drt);g.longitude=P.zeroToTwoPi(g.longitude),C.longitude=P.zeroToTwoPi(C.longitude);let E=!1;if(u(a)){let D=P.zeroToTwoPi(a),M=Math.min(g.longitude,C.longitude),O=Math.max(g.longitude,C.longitude),B=D>=M&&D<=O;if(u(c)){let L=Math.abs(g.longitude-C.longitude),_=P.TWO_PI-L;(B?L:_)<(B?_:L)*c&&!B&&(E=!0)}else B||(E=!0)}E?lrt(g,C):urt(g,C);let T=iY(f,n,g.height,C.height,s),S=O_e(m,r,T,l);function v(){let D=g.longitude,M=C.longitude,O=g.latitude,B=C.latitude;return function(_){let b=_.time/t,w=h.fromRadians(P.lerp(D,M,b),P.lerp(O,B,b),T(b),p);f.setView({destination:w,orientation:{heading:P.lerp(A,i,b),pitch:S(b),roll:P.lerp(x,o,b)}})}}return v()}function mrt(e,t,n,i,r,o,s){let a=e.camera,c=h.clone(a.position,M_e),l=EL(a.heading,i),f=a.frustum.right-a.frustum.left,d=iY(a,n,f,n.z,s);function p(g){let m=g.time/t;a.setView({orientation:{heading:P.lerp(l,i,m)}}),H.lerp(c,n,m,a.position);let A=d(m),x=a.frustum,C=x.top/x.right,E=(A-(x.right-x.left))*.5;x.right+=E,x.left-=E,x.top=C*x.right,x.bottom=-x.top}return p}var D_e=new me,prt=new h;function nY(e,t){return{startObject:{},stopObject:{},duration:0,complete:e,cancel:t}}function I_e(e,t){function n(){typeof t=="function"&&t(),e.enableInputs=!0}return n}P_e.createTween=function(e,t){t=y(t,y.EMPTY_OBJECT);let n=t.destination,i=e.mode;if(i===ne.MORPHING)return nY();let r=y(t.convert,!0),
{
return ${f};
}
`}return o=`${i} ${e}
{
${o} return ${i}(1.0);
}
`,o};mS.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 r=t[i];e.push.apply(e,r.condition.getVariables()),e.push.apply(e,r.expression.getVariables())}return e=e.filter(function(i,r,o){return o.indexOf(i)===r}),e};var DL=mS;function i0(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,tst(this,e)}function tst(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,r=y(t.meta,y.EMPTY_OBJECT);for(let o in r)r.hasOwnProperty(o)&&(n[o]=new sf(r[o],i))}e._meta=n,e._ready=!0}function Zr(e,t){let n=y(e._style,y.EMPTY_OBJECT).defines;if(u(t)){if(typeof t=="boolean"||typeof t=="number")return new sf(String(t));if(typeof t=="string")return new sf(t,n);if(u(t.conditions))return new DL(t,n)}else return;return t}function Qr(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(i0.prototype,{style:{get:function(){return this._style}},show:{get:function(){return this._show},set:function(e){this._show=Zr(this,e),this._style.show=Qr(this._show),this._showShaderFunctionReady=!1}},color:{get:function(){return this._color},set:function(e){this._color=Zr(this,e),this._style.color=Qr(this._color),this._colorShaderFunctionReady=!1}},pointSize:{get:function(){return this._pointSize},set:function(e){this._pointSize=Zr(this,e),this._style.pointSize=Qr(this._pointSize),this._pointSizeShaderFunctionReady=!1}},pointOutlineColor:{get:function(){return this._pointOutlineColor},set:function(e){this._pointOutlineColor=Zr(this,e),this._style.pointOutlineColor=Qr(this._pointOutlineColor)}},pointOutlineWidth:{get:function(){return this._pointOutlineWidth},set:function(e){this._pointOutlineWidth=Zr(this,e),this._style.pointOutlineWidth=Qr(this._pointOutlineWidth)}},labelColor:{get:function(){return this._labelColor},set:function(e){this._labelColor=Zr(this,e),this._style.labelColor=Qr(this._labelColor)}},labelOutlineColor:{get:function(){return this._labelOutlineColor},set:function(e){this._labelOutlineColor=Zr(this,e),this._style.labelOutlineColor=Qr(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 LL=`#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 NL=`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 FL=`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 yh(e,t){if(e=y(e,y.EMPTY_OBJECT),this._show=y(e.show,!0),this._position=h.clone(y(e.position,h.ZERO)),!u(e.scale)&&u(e.maximumSize))this._maximumSize=h.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 h(this._scale.x,this._scale.y,Math.min(this._scale.x,this._scale.y)/1.5);this._maximumSize=h.clone(y(e.maximumSize,n))}this._slice=y(e.slice,-1),this._color=z.clone(y(e.color,z.WHITE)),this._brightness=y(e.brightness,1),this._cloudCollection=t,this._index=-1}var Wst=yh.SHOW_INDEX=0,jst=yh.POSITION_INDEX=1,qst=yh.SCALE_INDEX=2,Yst=yh.MAXIMUM_SIZE_INDEX=3,Xst=yh.SLICE_INDEX=4,Kst=yh.BRIGHTNESS_INDEX=5,Jst=yh.COLOR_INDEX=6;yh.NUMBER_OF_PROPERTIES=7;function uC(e,t){let n=e._cloudCollection;u(n)&&(n._updateCloud(e,t),e._dirty=!0)}Object.defineProperties(yh.prototype,{show:{get:function(){return this._show},set:function(e){this._show!==e&&(this._show=e,uC(this,Wst))}},position:{get:function(){return this._position},set:function(e){let t=this._position;h.equals(t,e)||(h.clone(e,t),uC(this,jst))}},scale:{get:function(){return this._scale},set:function(e){let t=this._scale;H.equals(t,e)||(H.clone(e,t),uC(this,qst))}},maximumSize:{get:function(){return this._maximumSize},set:function(e){let t=this._maximumSize;h.equals(t,e)||(h.clone(e,t),uC(this,Yst))}},color:{get:function(){return this._color},set:function(e){let t=this._color;z.equals(t,e)||(z.clone(e,t),uC(this,Jst))}},slice:{get:function(){return this._slice},set:function(e){this._slice!==e&&(this._slice=e,uC(this,Xst))}},brightness:{get:function(){return this._brightness},set:function(e){this._brightness!==e&&(this._brightness=e,uC(this,Kst))}}});yh.prototype._destroy=function(){this._cloudCollection=void 0};var Uu=yh;var Vu,Cz=new h,Zst={positionHighAndScaleX:0,positionLowAndScaleY:1,packedAttribute0:2,packedAttribute1:3,color:4},Qst={direction:0,positionHighAndScaleX:1,positionLowAndScaleY:2,packedAttribute0:3,packedAttribute1:4,color:5},$st=Uu.SHOW_INDEX,eat=Uu.POSITION_INDEX,tat=Uu.SCALE_INDEX,nat=Uu.MAXIMUM_SIZE_INDEX,iat=Uu.SLICE_INDEX,rat=Uu.BRIGHTNESS_INDEX,oat=Uu.NUMBER_OF_PROPERTIES,sat=Uu.COLOR_INDEX;function Ah(e){e=y(e,y.EMPTY_OBJECT),this._clouds=[],this._cloudsToUpdate=[],this._cloudsToUpdateIndex=0,this._cloudsRemoved=!1,this._createVertexArray=!1,this._propertiesChanged=new Uint32Array(oat),this._noiseTexture=void 0,this._textureSliceWidth=128,this._noiseTextureRows=4,this.noiseDetail=y(e.noiseDetail,16),this.noiseOffset=h.clone(y(e.noiseOffset,h.ZERO)),this._loading=!1,this._ready=!1;let t=this;this._uniforms={u_noiseTexture:function(){return t._noiseTexture},u_noiseTextureDimensions:xge(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 xge(e){return function(){return Cz.x=e._textureSliceWidth,Cz.y=e._noiseTextureRows,Cz.z=1/e._noiseTextureRows,Cz}}Object.defineProperties(Ah.prototype,{length:{get:function(){return xY(this),this._clouds.length}}});function Cge(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}Ah.prototype.add=function(e){e=y(e,y.EMPTY_OBJECT);let t=y(e.cloudType,pS.CUMULUS),n;return t===pS.CUMULUS&&(n=new Uu(e,this),n._index=this._clouds.length,this._clouds.push(n),this._createVertexArray=!0),n};Ah.prototype.remove=function(e){return this.contains(e)?(this._clouds[e._index]=void 0,this._cloudsRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};Ah.prototype.removeAll=function(){Cge(this._clouds),this._clouds=[],this._cloudsToUpdate=[],this._cloudsToUpdateIndex=0,this._cloudsRemoved=!1,this._createVertexArray=!0};function xY(e){if(e._cloudsRemoved){e._cloudsRemoved=!1;let t=[],n=e._clouds,i=n.length;for(let r=0,o=0;r<i;++r){let s=n[r];u(s)&&(n._index=o++,t.push(s))}e._clouds=t}}Ah.prototype._updateCloud=function(e,t){e._dirty||
`,n}function vat(e){let t="";t+=Ac(".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+=Ac(".cesium-credit-lightbox",{"background-color":"#303336",color:UL,position:"relative","min-height":`${Tat}px`,margin:"auto"}),t+=Ac(".cesium-credit-lightbox > ul > li a, .cesium-credit-lightbox > ul > li a:visited",{color:UL}),t+=Ac(".cesium-credit-lightbox > ul > li a:hover",{color:SY}),t+=Ac(".cesium-credit-lightbox.cesium-credit-lightbox-expanded",{border:"1px solid #444","border-radius":"5px","max-width":"370px"}),t+=Ac(".cesium-credit-lightbox.cesium-credit-lightbox-mobile",{height:"100%",width:"100%"}),t+=Ac(".cesium-credit-lightbox-title",{padding:"20px 20px 0 20px"}),t+=Ac(".cesium-credit-lightbox-close",{"font-size":"18pt",cursor:"pointer",position:"absolute",top:"0",right:"6px",color:UL}),t+=Ac(".cesium-credit-lightbox-close:hover",{color:SY}),t+=Ac(".cesium-credit-lightbox > ul",{margin:"0",padding:"12px 20px 12px 40px","font-size":"13px"}),t+=Ac(".cesium-credit-lightbox > ul > li",{"padding-bottom":"6px"}),t+=Ac(".cesium-credit-lightbox > ul > li *",{padding:"0",margin:"0"}),t+=Ac(".cesium-credit-expand-link",{"padding-left":"5px",cursor:"pointer","text-decoration":"underline",color:UL}),t+=Ac(".cesium-credit-expand-link:hover",{color:SY}),t+=Ac(".cesium-credit-text",{color:UL}),t+=Ac(".cesium-credit-textContainer *, .cesium-credit-logoContainer *",{display:"inline"});function n(o){if(o.shadowRoot)return o.shadowRoot;if(o.getRootNode){let s=o.getRootNode();if(s instanceof ShadowRoot)return s}}let i=y(n(e),document.head),r=document.createElement("style");r.innerHTML=t,i.appendChild(r)}function Ao(e,t,n){let i=this;n=y(n,document.body);let r=document.createElement("div");r.className="cesium-credit-lightbox-overlay",n.appendChild(r);let o=document.createElement("div");o.className="cesium-credit-lightbox",r.appendChild(o);function s(m){o.contains(m.target)||i.hideLightbox()}r.addEventListener("click",s,!1);let a=document.createElement("div");a.className="cesium-credit-lightbox-title",a.textContent="Data provided by:",o.appendChild(a);let c=document.createElement("a");c.onclick=this.hideLightbox.bind(this),c.innerHTML="&times;",c.className="cesium-credit-lightbox-close",o.appendChild(c);let l=document.createElement("ul");o.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),vat(e);let g=Yt.clone(Ao.cesiumCredit);this._delimiter=y(t," \u2022 "),this._screenContainer=d,this._cesiumCreditContainer=f,this._lastViewportHeight=void 0,this._lastViewportWidth=void 0,this._lightboxCredits=o,this._creditList=l,this._lightbox=r,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 Rge(e,t,n,i){i=y(i,1);let r=t.get(n.id);if(u(r))r.count<Number.MAX_VALUE&&(r.count+=i);else{let o=e._creditDisplayElementPool,s=e._creditDisplayElementPoolIndex;s<o.length?(r=o[s],r.credit=n,r.count=i):(r=new Oge(n,i),o.push(r)),++e._creditDisplayElementPoolIndex,t.set(n.id,r)}}Ao.prototype.addCredit=function(e){if(e._isIon){u(this._defaultCredit)||(this._defaultCredit=Yt.clone(Bge())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,Rge(this,t,e)};Ao.prototype.addDefaultCredit=function(e){let t=this._defaultCredits;Eat(t,e)||t.push(e)};Ao.prototype.removeD
`;else switch(t==="st"&&(i="vec2"),i){case"float":o=`vec4 getColor() { return vec4(vec3(${r}), 1.0); }
`;break;case"vec2":o=`vec4 getColor() { return vec4(${r}, 0.0, 1.0); }
`;break;case"vec3":o=`vec4 getColor() { return vec4(${r}, 1.0); }
`;break;case"vec4":o=`vec4 getColor() { return ${r}; }
`;break}let s=`in vec3 position3DHigh;
in vec3 position3DLow;
in float batchId;
${n?"":`in ${i} ${t};
`}out ${i} ${r};
void main()
{
vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);
${n?`${r} = czm_batchTable_${t}(batchId);
`:`${r} = ${t};
`}gl_Position = czm_modelViewProjectionRelativeToEye * p;
}`,a=`in ${i} ${r};
${o}
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=rr.getDefaultRenderState(!1,!1,e.renderState),this._closed=y(e.closed,!1),this._attributeName=t,this._glslDatatype=i}Object.defineProperties(kL.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}}});kL.prototype.getFragmentShaderSource=rr.prototype.getFragmentShaderSource;kL.prototype.isTranslucent=rr.prototype.isTranslucent;kL.prototype.getRenderState=rr.prototype.getRenderState;var vY=kL;function Ez(e){e=y(e,y.EMPTY_OBJECT),this._camera=e.camera,this._frustumSplits=e.frustumSplits,this._color=y(e.color,z.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 wat=new h,Dat=new Z,Iat=new Le,Pat=new wi,Oat=new Qc,Mat=new en,Rat=new bo,Bat=new z,Lat=[1,1e5];Ez.prototype.update=function(e){if(!this.show)return;let t=this._planesPrimitives,n=this._outlinePrimitives,i,r;if(this._updateOnChange){for(r=t.length,i=0;i<r;++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 o=this._camera,s=o.frustum,a;s instanceof wi?a=Pat:s instanceof Qc?a=Oat:s instanceof en?a=Mat:a=Rat,a=s.clone(a);let c,l=this._frustumSplits;!u(l)||l.length<=1?(l=Lat,l[0]=this._camera.frustum.near,l[1]=this._camera.frustum.far,c=1):c=l.length-1;let f=o.positionWC,d=o.directionWC,p=o.upWC,g=o.rightWC;g=h.negate(g,wat);let m=Dat;Z.setColumn(m,0,g,m),Z.setColumn(m,1,p,m),Z.setColumn(m,2,d,m);let A=Le.fromRotationMatrix(m,Iat);for(t.length=n.length=c,i=0;i<c;++i)a.near=l[i],a.far=l[i+1],t[i]=new bn({geometryInstances:new xt({geometry:new nC({origin:f,orientation:A,frustum:a,_drawNearPlane:i===0}),attributes:{color:Ut.fromColor(z.fromAlpha(this._color,.1,Bat))},id:this.id,pickPrimitive:this}),appearance:new rn({translucent:!0,flat:!0}),asynchronous:!1}),n[i]=new bn({geometryInstances:new xt({geometry:new iL({origin:f,orientation:A,frustum:a,_drawNearPlane:i===0}),attributes:{color:Ut.fromColor(this._color)},id:this.id,pickPrimitive:this}),appearance:new rn({translucent:!1,flat:!0}),asynchronous:!1})}for(r=t.length,i=0;i<r;++i)n[i].update(e),t[i].update(e)};Ez.prototype.isDestroyed=function(){return!1};Ez.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 Rm=Ez;function Lge(){this._cachedShowFrustumsShaders={}}function Nat(e){let t={},n=e.vertexAttributes;for(let i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function Fat(e,t){let n=e.context,i=t,r=i.fragmentShaderSource.clone(),o=[];r.sources=r.sources.map(function(f){f=He.replaceMain(f,"czm_Debug_main");let d=/out_FragData_(\d+)/g,p;for(;(p=d.exec(f))!==null;)o.indexOf(p[1])===-1&&o.push(p[1]);return f});let s=o.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_${o[c]}.rgb *= debugShowCommandsColor;
`,a+=` out_FragData_${o[c]}.rgb *= debugShowFrustumsColor;
`;else a+=` out_FragColor.rgb *= debugShowCommandsColor;
`,a+=` out_FragColor.rgb *= debugShowFrustumsColor;
`;a+="}",r.sources.push(a);let l=Nat(i);return Xt.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:r,attributeLocations:l})}var zL=new z;function Uat(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=z.fromRandom()),t._debugColor):z.WHITE},n.debugShowFrustumsColor=function(){return e.debugShowFrustums?(zL.red=t.debugOverlappingFrustums&1<<0?1:0,zL.green=t.debugOverlappingFrustums&1<<1?1:0,zL.blue=t.debugOverlappingFrustums&1<<2?1:0,zL.alpha=1,zL):z.WHITE}),n}var Vat=new nt;Lge.prototype.executeDebugShowFrustumsCommand=function(e,t,n){let i=t.shaderProgram.id,r=this._cachedShowFrustumsShaders[i];u(r)||(r=Fat(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=r);let o=nt.shallowClone(t,Vat);o.shaderProgram=r,o.uniformMap=Uat(e,t),o.execute(e.context,n)};var HL=Lge;function bz(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=N.clone(y(e.modelMatrix,N.IDENTITY)),this._modelMatrix=new N,this.id=e.id,this._id=void 0,this._primitive=void 0}bz.prototype.update=function(e){if(this.show){if(!u(this._primitive)||!N.equals(this._modelMatrix,this.modelMatrix)||this._length!==this.length||this._width!==this.width||this._id!==this.id){this._modelMatrix=N.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 w_({positions:[h.ZERO,h.UNIT_X],width:this.width,vertexFormat:Vo.VERTEX_FORMAT,colors:[z.RED,z.RED],arcType:Kt.NONE}),modelMatrix:N.multiplyByUniformScale(this.modelMatrix,this.length,new N),id:this.id,pickPrimitive:this}),n=new xt({geometry:new w_({positions:[h.ZERO,h.UNIT_Y],width:this.width,vertexFormat:Vo.VERTEX_FORMAT,colors:[z.GREEN,z.GREEN],arcType:Kt.NONE}),modelMatrix:N.multiplyByUniformScale(this.modelMatrix,this.length,new N),id:this.id,pickPrimitive:this}),i=new xt({geometry:new w_({positions:[h.ZERO,h.UNIT_Z],width:this.width,vertexFormat:Vo.VERTEX_FORMAT,colors:[z.BLUE,z.BLUE],arcType:Kt.NONE}),modelMatrix:N.multiplyByUniformScale(this.modelMatrix,this.length,new N),id:this.id,pickPrimitive:this});this._primitive=new bn({geometryInstances:[t,n,i],appearance:new Vo,asynchronous:!1})}this._primitive.update(e)}};bz.prototype.isDestroyed=function(){return!1};bz.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),ue(this)};var GL=bz;var WL=`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 jL=`in vec4 position;
out vec4 positionEC;
void main()
{
positionEC = czm_modelView * position;
gl_Position = czm_projection * positionEC;
czm_vertexLogDepth();
}
`;function YL(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 qL=kt.supportsTypedArrays()?new Float32Array(12):[],Nge=new h,Fge=new h,wY=new h,Uge=new h,Sz=new h;function kat(e,t){let n=e.radii,i=t.camera,r,o,s;if(i.frustum instanceof en)r=h.ZERO,o=i.rightWC,s=i.upWC;else{let d=i.positionWC,p=h.multiplyComponents(e.oneOverRadii,d,Nge),g=h.normalize(p,Fge),m=h.normalize(h.cross(h.UNIT_Z,p,wY),wY),A=h.normalize(h.cross(g,m,Uge),Uge),x=h.magnitude(p),C=Math.sqrt(x*x-1);r=h.multiplyByScalar(g,1/x,Nge);let E=C/x;o=h.multiplyByScalar(m,E,Fge),s=h.multiplyByScalar(A,E,wY)}let a=h.add(r,s,Sz);h.subtract(a,o,a),h.multiplyComponents(n,a,a),h.pack(a,qL,0);let c=h.subtract(r,s,Sz);h.subtract(c,o,c),h.multiplyComponents(n,c,c),h.pack(c,qL,3);let l=h.add(r,s,Sz);h.add(l,o,l),h.multiplyComponents(n,l,l),h.pack(l,qL,6);let f=h.subtract(r,s,Sz);return h.add(f,o,f),h.multiplyComponents(n,f,f),h.pack(f,qL,9),qL}YL.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 re(n.x+this._ellipsoidOffset,n.y+this._ellipsoidOffset,n.z+this._ellipsoidOffset),r=e.useLogDepth;if(u(this._command)||(this._rs=Ve.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(h.ZERO,i.maximumRadius),pass:be.OPAQUE,owner:this})),!u(this._sp)||this._useLogDepth!==r){this._useLogDepth=r;let s=new He({sources:[jL]}),a=new He({sources:[WL]});r&&(a.defines.push("LOG_DEPTH"),s.defines.push("LOG_DEPTH")),this._sp=Xt.replaceCache({shaderProgram:this._sp,context:t,vertexShaderSource:s,fragmentShaderSource:a,attributeLocations:{position:0}}),this._command.shaderProgram=this._sp}let o=kat(i,e);if(u(this._va))this._va.getAttribute(0).vertexBuffer.copyFromArrayView(o);else{let s=new lt({attributes:{position:new we({componentDatatype:X.FLOAT,componentsPerAttribute:3,values:o})},indices:[0,1,2,2,1,3],primitiveType:Be.TRIANGLES});this._va=si.fromGeometry({context:t,geometry:s,attributeLocations:{position:0},bufferUsage:Fe.DYNAMIC_DRAW}),this._command.vertexArray=this._va}};YL.prototype.execute=function(e,t){this._mode===ne.SCENE3D&&this._command.execute(e,t)};YL.prototype.isDestroyed=function(){return!1};YL.prototype.destroy=function(){this._sp=this._sp&&this._sp.destroy(),this._va=this._va&&this._va.destroy()};var XL=YL;function KL(){}var zat=/\bgl_FragDepth\b/,Hat=/\bdiscard\b/;function Gat(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"depthOnly");if(!u(n)){let i=t._attributeLocations,r=t.fragmentShaderSource,o,s=!1,a=r.sources,c=a.length;for(o=0;o<c;++o)if(zat.test(a[o])||Hat.test(a[o])){s=!0;break}let l=!1,f=r.defines;for(c=f.length,o=0;o<c;++o)if(f[o]==="LOG_DEPTH"){l=!0;break}let d;!s&&!l?(d=`void main()
{
out_FragColor = vec4(1.0);
}
`,r=new He({sources:[d]})):!s&&l&&(d=`void main()
{
out_FragColor = vec4(1.0);
czm_writeLogDepth();
}
`,r=new He({defines:["LOG_DEPTH"],sources:[d]})),n=e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:r,attributeLocations:i})}return n}function Wat(e,t){let n=e._depthOnlyRenderStateCache,i=n[t.id];if(!u(i)){let r=Ve.getState(t);r.depthMask=!0,r.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i=Ve.fromCache(r),n[t.id]=i}return i}KL.createDepthOnlyDerivedCommand=function(e,t,n,i){u(i)||(i={});let r,o;return u(i.depthOnlyCommand)&&(r=i.depthOnlyCommand.shaderProgram,o=i.depthOnlyCommand.renderState),i.depthOnlyCommand=nt.shallowClone(t,i.depthOnlyCommand),!u(r)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=Gat(n,t.shaderProgram),i.depthOnlyCommand.renderState=Wat(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=r,i.depthOnlyCommand.renderState=o),i};var jat=/\s+czm_writeLogDepth\(/,qat=/\s+czm_vertexLogDepth\(/;function Yat(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 r=t._attributeLocations,o=t.vertexShaderSource.clone(),s=t.fragmentShaderSource.clone();o.defines=u(o.defines)?o.defines.slice(0):[],o.defines.push("LOG_DEPTH"),s.defines=u(s.defines)?s.defines.slice(0):[],s.defines.push("LOG_DEPTH");let a,c,l=!1,f=o.sources,d=f.length;for(a=0;a<d;++a)if(qat.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)jat.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:o,fragmentShaderSource:s,attributeLocations:r})}return i}KL.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=Yat(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function Xat(e,t,n){let i=e.shaderCache.getDerivedShaderProgram(t,"pick");if(!u(i)){let r=t._attributeLocations,o=t.fragmentShaderSource,s=o.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,o=new He({sources:l,defines:o.defines}),i=e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:r})}return i}function Kat(e,t){let n=e.picking.pickRenderStateCache,i=n[t.id];if(!u(i)){let r=Ve.getState(t);r.blending.enabled=!1,r.depthMask=!0,i=Ve.fromCache(r),n[t.id]=i}return i}KL.createPickDerivedCommand=function(e,t,n,i){u(i)||(i={});let r,o;return u(i.pickCommand)&&(r=i.pickCommand.shaderProgram,o=i.pickCommand.renderState),i.pickCommand=nt.shallowClone(t,i.pickCommand),!u(r)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=Xat(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=Kat(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=r,i.pickCommand.renderState=o),i};function Jat(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"HDR");if(!u(n)){let i=t._attributeLocations,r=t.vertexShaderSource.clone(),o=t.fragmentShaderSource.clone();r.defines=u(r.defines)?r.defines.slice(0):[],r.defines.push("HDR"),o.defines=u(o.defines)?o.defines.slice(0):[],o.defines.push("HDR"),n=e.shaderCache.createDerivedShaderProgram(t,"HDR",{vertexShaderSource:r,fragmentShaderSource:o,attributeLocations:i})}return n}KL.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=Jat(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};var V_=KL;function vz(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 r=i.alpha;if(!u(r)){t._alpha=void 0,t._beta=void 0,t._gamma=void 0;return}t._alpha=P.toRadians(r),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 Zat=new Le,Vge=new Le,Qat=new Z;function $at(e,t,n,i){let r=e.direction,o=e.right,s=e.up,a=Le.fromAxisAngle(r,n,Vge),c=Le.fromAxisAngle(o,i,Zat),l=Le.multiply(c,a,c),f=Le.fromAxisAngle(s,t,Vge);Le.multiply(f,l,l);let d=Z.fromQuaternion(l,Qat);Z.multiplyByVector(d,o,o),Z.multiplyByVector(d,s,s),Z.multiplyByVector(d,r,r)}vz.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;$at(this._scene.camera,-e,t,n),this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma};vz.prototype.isDestroyed=function(){return!1};vz.prototype.destroy=function(){return this._removeListener(),ue(this)};var JL=vz;function ect(e){this.direction=h.clone(e.direction),this.color=z.clone(y(e.color,z.WHITE)),this.intensity=y(e.intensity,1)}var DY=ect;var _S=`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 gS=`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 IY={position:0};function wz(e){e=y(e,y.EMPTY_OBJECT),this.center=h.clone(y(e.center,h.ZERO)),this._center=new h,this.radii=h.clone(e.radii),this._radii=new h,this._oneOverEllipsoidRadiiSquared=new h,this._boundingSphere=new ae,this.modelMatrix=N.clone(y(e.modelMatrix,N.IDENTITY)),this._modelMatrix=new N,this._computedModelMatrix=new N,this.show=y(e.show,!0),this.material=y(e.material,qi.fromType(qi.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 tct(e){let t=e.cache.ellipsoidPrimitive_vertexArray;if(u(t))return t;let n=hl.createGeometry(hl.fromDimensions({dimensions:new h(2,2,2),vertexFormat:Pe.POSITION_ONLY}));return t=si.fromGeometry({context:e,geometry:n,attributeLocations:IY,bufferUsage:Fe.STATIC_DRAW,interleave:!0}),e.cache.ellipsoidPrimitive_vertexArray=t,t}wz.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=Ve.fromCache({cull:{enabled:!0,face:gi.FRONT},depthTest:{enabled:this._depthTestEnabled},depthMask:!n&&t.fragmentDepth,blending:n?ln.ALPHA_BLEND:void 0})),u(this._va)||(this._va=tct(t));let r=!1,o=this.radii;if(!h.equals(this._radii,o)){h.clone(o,this._radii);let A=this._oneOverEllipsoidRadiiSquared;A.x=1/(o.x*o.x),A.y=1/(o.y*o.y),A.z=1/(o.z*o.z),r=!0}(!N.equals(this.modelMatrix,this._modelMatrix)||!h.equals(this.center,this._center))&&(N.clone(this.modelMatrix,this._modelMatrix),h.clone(this.center,this._center),N.multiplyByTranslation(this.modelMatrix,this.center,this._computedModelMatrix),r=!0),r&&(h.clone(h.ZERO,this._boundingSphere.center),this._boundingSphere.radius=h.maximumComponent(o),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:[gS]}),p=new He({sources:[this.material.shaderSource,_S]}),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=Xt.replaceCache({context:t,shaderProgram:this._sp,vertexShaderSource:d,fragmentShaderSource:p,attributeLocations:IY}),f.vertexArray=this._va,f.renderState=this._rs,f.shaderProgram=this._sp,f.uniformMap=mt(this._uniforms,this.material._uniforms),f.executeInClosestFrustum=n);let g=e.commandList,m=e.passes;if(m.render&&(f.boundingVolume=this._boundingSphere,f.debugShowBoundingVolume=this.debugShowBoundingVolume,f.modelMatrix=this._computedModelMatrix,f.pass=n?be.TRANSLUCENT:be.OPAQUE,g.push(f)),m.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:[gS]}),p=new He({sources:[this.material.shaderSource,_S],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=Xt.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 $L=`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 fC(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:qi.fromType(qi.ColorType),this.translucent=y(e.translucent,!0),this._vertexShaderSource=y(e.vertexShaderSource,$L),this._fragmentShaderSource=y(e.fragmentShaderSource,QL),this._renderState=rr.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(fC.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 fC.VERTEX_FORMAT}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}},aboveGround:{get:function(){return this._aboveGround}}});fC.VERTEX_FORMAT=Pe.POSITION_AND_ST;fC.prototype.getFragmentShaderSource=rr.prototype.getFragmentShaderSource;fC.prototype.isTranslucent=rr.prototype.isTranslucent;fC.prototype.getRenderState=rr.prototype.getRenderState;var PY=fC;function kge(){this.enabled=!0,this.renderable=!0,this.density=2e-4,this.screenSpaceErrorFactor=2,this.minimumBrightness=.03}var Dz=[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],Bm=[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<Bm.length;++e)Bm[e]*=1e6;var zge=Bm[1],OY=Bm[Bm.length-1];for(let e=0;e<Bm.length;++e)Bm[e]=(Bm[e]-OY)/(zge-OY);var sa=0;function nct(e){let t=Dz,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 ict=new h;kge.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 r=i.height,o=nct(r),s=P.clamp((r-Dz[o])/(Dz[o+1]-Dz[o]),0,1),a=P.lerp(Bm[o],Bm[o+1],s),c=this.density*1e6,l=c/zge*OY;a=a*(c-l)*1e-6;let f=h.normalize(n.positionWC,ict),d=Math.abs(h.dot(n.directionWC,f));a*=1-d,e.fog.density=a,e.fog.sse=this.screenSpaceErrorFactor,e.fog.minimumBrightness=this.minimumBrightness};var eN=kge;function jl(e){this._scene=e.scene,this.samplingWindow=y(e.samplingWindow,jl.defaultSettings.samplingWindow),this.quietPeriod=y(e.quietPeriod,jl.defaultSettings.quietPeriod),this.warmupPeriod=y(e.warmupPeriod,jl.defaultSettings.warmupPeriod),this.minimumFrameRateDuringWarmup=y(e.minimumFrameRateDuringWarmup,jl.defaultSettings.minimumFrameRateDuringWarmup),this.minimumFrameRateAfterWarmup=y(e.minimumFrameRateAfterWarmup,jl.defaultSettings.minimumFrameRateAfterWarmup),this._lowFrameRate=new ge,this._nominalFrameRate=new ge,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(r,o){rct(t,o)}),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(){oct(t)}this._visibilityChangeRemoveListener=void 0,u(n)&&(document.addEventListener(n,i,!1),this._visibilityChangeRemoveListener=function(){document.removeEventListener(n,i,!1)})}jl.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 oN=`#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 k_=`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 yS=`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 Tct=new H;function Ect(e,t){let n=e.unionClippingRegions,i=e.length,r=as.useFloatTexture(t),o=as.getTextureResolution(e,t,Tct),s=o.x,a=o.y,c=r?vct(s,a):wct(s,a);return c+=`
`,c+=n?bct(i):Sct(i),c}function bct(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 Sct(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 vct(e,t){let n=1/e,i=1/t,r=`${n}`;r.indexOf(".")===-1&&(r+=".0");let o=`${i}`;return o.indexOf(".")===-1&&(o+=".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) * ${r};
float v = (float(pixY) + 0.5) * ${o};
vec4 plane = texture(packedClippingPlanes, vec2(u, v));
return czm_transformPlane(plane, transform);
}
`}function wct(e,t){let n=1/e,i=1/t,r=`${n}`;r.indexOf(".")===-1&&(r+=".0");let o=`${i}`;return o.indexOf(".")===-1&&(o+=".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) * ${r};
float v = (float(pixY) + 0.5) * ${o};
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 + ${r}, v)));
return czm_transformPlane(plane, transform);
}
`}var z_=Ect;function Dct(e,t,n,i,r){this.numberOfDayTextures=e,this.flags=t,this.material=n,this.shaderProgram=i,this.clippingShaderState=r}function BY(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function Ict(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); }",r;switch(e){case ne.SCENE3D:r=t;break;case ne.SCENE2D:case ne.COLUMBUS_VIEW:r=n;break;case ne.MORPHING:r=i;break}return r}function Pct(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}BY.prototype.getShaderProgram=function(e){let t=e.frameState,n=e.surfaceTile,i=e.numberOfDayTextures,r=e.applyBrightness,o=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,m=e.enableLighting,A=e.dynamicAtmosphereLighting,x=e.dynamicAtmosphereLightingFromSun,C=e.showGroundAtmosphere,E=e.perFragmentGroundAtmosphere,T=e.hasVertexNormals,S=e.useWebMercatorProjection,v=e.enableFog,D=e.enableClippingPlanes,M=e.clippingPlanes,O=e.clippedByBoundaries,B=e.hasImageryLayerCutout,L=e.colorCorrect,_=e.highlightFillTile,b=e.colorToAlpha,w=e.hasGeodeticSurfaceNormals,I=e.hasExaggeration,R=e.showUndergroundColor,F=e.translucent,k=0,V="",U=n.renderedMesh.encoding;U.quantization===Ls.BITS12&&(k=1,V="QUANTIZATION_BITS12");let j=0,Q="";O&&(j=1,Q="TILE_LIMIT_RECTANGLE");let W=0,K="";B&&(W=1,K="APPLY_IMAGERY_CUTOUT");let J=t.mode,_e=J|r<<2|o<<3|s<<4|a<<5|c<<6|l<<7|p<<8|g<<9|m<<10|A<<11|x<<12|C<<13|E<<14|T<<15|S<<16|v<<17|k<<18|d<<19|D<<20|j<<21|W<<22|L<<23|_<<24|b<<25|w<<26|I<<27|R<<28|F<<29|f<<30,xe=0;u(M)&&M.length>0&&(xe=D?M.clippingPlanesState:0);let se=n.surfaceShader;if(u(se)&&se.numberOfDayTextures===i&&se.flags===_e&&se.material===this.material&&se.clippingShaderState===xe)return se.shaderProgram;let Ae=this._shadersByTexturesFlags[i];if(u(Ae)||(Ae=this._shadersByTexturesFlags[i]=[]),se=Ae[_e],!u(se)||se.material!==this.material||se.clippingShaderState!==xe){let he=this.baseVertexShaderSource.clone(),Se=this.baseFragmentShaderSource.clone();xe!==0&&Se.sources.unshift(z_(M,t.context)),he.defines.push(V),Se.defines.push(`TEXTURE_UNITS ${i}`,Q,K),r&&Se.defines.push("APPLY_BRIGHTNESS"),o&&Se.defines.push("APPLY_CONTRAST"),s&&Se.defines.push("APPLY_HUE"),a&&Se.defines.push("APPLY_SATURATION"),c&&Se.defines.push("APPLY_GAMMA"),l&&Se.defines.push("APPLY_ALPHA"),f&&Se.defines.push("APPLY_DAY_NIGHT_ALPHA"),p&&(Se.defines.push("SHOW_REFLECTIVE_OCEAN"),he.defines.push("SHOW_REFLECTIVE_OCEAN")),g&&Se.defines.push("SHOW_OCEAN_WAVES"),b&&Se.defines.push("APPLY_COLOR_TO_ALPHA"),R&&(he.defines.push("UNDERGROUND_COLOR"),Se.defines.push("UNDERGROUND_COLOR")),F&&(he.defines.push("TRANSLUCENT"),Se.defines.push("TRANSLUCENT")),m&&(T?(he.defines.push("ENABLE_VERTEX_LIGHTING"),Se.defines.push("ENABLE_VERTEX_LIGHTING")):(he.defines.push("ENABLE_DAYNIGHT_SHADING"),Se.defines.push("ENABLE_DAYNIGHT_SHADING"))),A&&(he.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),Se.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),x&&(he.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),Se.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),C&&(he.defines.push("GROUND_ATMOSPHERE"),Se.defines.push("GROUND_ATMOSPHERE"),E&&(he.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"),Se.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"))),he.defines.push("INCLUDE_WEB_MERCATOR_Y"),Se.defines.push("INCLUDE_WEB_MERCATOR_Y"),v&&(he.defines.push("FOG"),Se.defines.push("FOG")),d&&Se.
{
vec4 color = initialColor;
`;B&&(Ie+=` vec4 cutoutAndColorResult;
bool texelUnclipped;
`);for(let Ye=0;Ye<i;++Ye)B?Ie+=` cutoutAndColorResult = u_dayTextureCutoutRectangles[${Ye}];
texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y;
cutoutAndColorResult = sampleAndBlend(
`:Ie+=` color = sampleAndBlend(
`,Ie+=` color,
u_dayTextures[${Ye}],
u_dayTextureUseWebMercatorT[${Ye}] ? textureCoordinates.xz : textureCoordinates.xy,
u_dayTextureTexCoordsRectangle[${Ye}],
u_dayTextureTranslationAndScale[${Ye}],
${l?`u_dayTextureAlpha[${Ye}]`:"1.0"},
${f?`u_dayTextureNightAlpha[${Ye}]`:"1.0"},
${f?`u_dayTextureDayAlpha[${Ye}]`:"1.0"},
${r?`u_dayTextureBrightness[${Ye}]`:"0.0"},
${o?`u_dayTextureContrast[${Ye}]`:"0.0"},
${s?`u_dayTextureHue[${Ye}]`:"0.0"},
${a?`u_dayTextureSaturation[${Ye}]`:"0.0"},
${c?`u_dayTextureOneOverGamma[${Ye}]`:"0.0"},
${d?`u_dayTextureSplit[${Ye}]`:"0.0"},
${b?`u_colorsToAlpha[${Ye}]`:"vec4(0.0)"},
nightBlend );
`,B&&(Ie+=` color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);
`);Ie+=` return color;
}`,Se.sources.push(Ie),he.sources.push(Ict(J)),he.sources.push(Pct(S));let Ne=Xt.fromCache({context:t.context,vertexShaderSource:he,fragmentShaderSource:Se,attributeLocations:U.getAttributeLocations()});se=Ae[_e]=new Dct(i,_e,this.material,Ne,xe)}return n.surfaceShader=se,se.shaderProgram};BY.prototype.destroy=function(){let e,t,n=this._shadersByTexturesFlags;for(let i in n)if(n.hasOwnProperty(i)){let r=n[i];if(!u(r))continue;for(e in r)r.hasOwnProperty(e)&&(t=r[e],u(t)&&t.shaderProgram.destroy())}return ue(this)};var sN=BY;var Oct={UNLOADED:0,TRANSITIONING:1,RECEIVED:2,TEXTURE_LOADED:3,READY:4,FAILED:5,INVALID:6,PLACEHOLDER:7},di=Object.freeze(Oct);var Mct={START:0,LOADING:1,DONE:2,FAILED:3},Fs=Object.freeze(Mct);var Rct={FAILED:0,UNLOADED:1,RECEIVING:2,RECEIVED:3,TRANSFORMING:4,TRANSFORMED:5,READY:6},Cr=Object.freeze(Rct);function $r(){this.imagery=[],this.waterMaskTexture=void 0,this.waterMaskTranslationAndScale=new oe(0,0,1,1),this.terrainData=void 0,this.vertexArray=void 0,this.tileBoundingRegion=void 0,this.occludeePointInScaledSpace=new h,this.boundingVolumeSourceTile=void 0,this.boundingVolumeIsFromMesh=!1,this.terrainState=Cr.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($r.prototype,{eligibleForUnloading:{get:function(){let e=this.terrainState,n=!(e===Cr.RECEIVING||e===Cr.TRANSFORMING),i=this.imagery;for(let r=0,o=i.length;n&&r<o;++r){let s=i[r];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 Bct=new me;function LY(e,t,n,i,r,o){let s=e.getExaggeratedPosition(i,r,o);if(u(t)&&t!==ne.SCENE3D){let c=n.ellipsoid.cartesianToCartographic(s,Bct);s=n.project(c,o),s=h.fromElements(s.z,s.x,s.y,o)}return s}var Lct=new h,Nct=new h,Fct=new h;$r.prototype.pick=function(e,t,n,i,r){let o=this.renderedMesh;if(!u(o))return;let s=o.vertices,a=o.indices,c=o.encoding,l=a.length,f=Number.MAX_VALUE;for(let d=0;d<l;d+=3){let p=a[d],g=a[d+1],m=a[d+2],A=LY(c,t,n,s,p,Lct),x=LY(c,t,n,s,g,Nct),C=LY(c,t,n,s,m,Fct),E=Qi.rayTriangleParametric(e,A,x,C,i);u(E)&&E<f&&E>=0&&(f=E)}return f!==Number.MAX_VALUE?vn.getPoint(e,f,r):void 0};$r.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=Cr.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()};$r.prototype.freeVertexArray=function(){$r._freeVertexArray(this.vertexArray),this.vertexArray=void 0,$r._freeVertexArray(this.wireframeVertexArray),this.wireframeVertexArray=void 0};$r.initialize=function(e,t,n){let i=e.data;u(i)||(i=e.data=new $r),e.state===Fs.START&&(Uct(e,t,n),e.state=Fs.LOADING)};$r.processStateMachine=function(e,t,n,i,r,o,s){$r.initialize(e,n,i);let a=e.data;if(e.state===Fs.LOADING&&Vct(e,t,n,i,r,o),s)return;let c=e.renderable;e.renderable=u(a.vertexArray);let l=a.terrainState===Cr.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=Fs.DONE}c&&(e.renderable=!0)};$r.prototype.processImagery=function(e,t,n,i){let r=e.data,o=e.upsampledFromParent,s=!1,a=!0,c=r.imagery,l,f;for(l=0,f=c.length;l<f;++l){let d=c[l];if(!u(d.loadingImagery)){o=!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 o=!1}let p=d.processStateMachine(e,n,i);a=a&&p,s=s||p||u(d.readyImagery),o=o&&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 fN=`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 DS(e,t,n,i,r){if(this.imageryLayer=e,this.x=t,this.y=n,this.level=i,this.request=void 0,i!==0){let o=t/2|0,s=n/2|0,a=i-1;this.parent=e.getImageryFromCache(o,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(r)&&e.ready&&e.imageryProvider._ready&&(r=e.imageryProvider.tilingScheme.tileXYToRectangle(t,n,i)),this.rectangle=r}DS.createPlaceholder=function(e){let t=new DS(e,0,0,0);return t.addReference(),t.state=di.PLACEHOLDER,t};DS.prototype.addReference=function(){++this.referenceCount};DS.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};DS.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 IS=DS;function zY(e,t,n){this.readyImagery=void 0,this.loadingImagery=e,this.textureCoordinateRectangle=t,this.textureTranslationAndScale=void 0,this.useWebMercatorT=n}zY.prototype.freeResources=function(){u(this.readyImagery)&&this.readyImagery.releaseReference(),u(this.loadingImagery)&&this.loadingImagery.releaseReference()};zY.prototype.processStateMachine=function(e,t,n){let i=this.loadingImagery,r=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=r._calculateTextureTranslationAndScale(e,this),!0;let o=i.parent,s;for(;u(o)&&(o.state!==di.READY||!this.useWebMercatorT&&!u(o.texture));)o.state!==di.FAILED&&o.state!==di.INVALID&&(s=s||o),o=o.parent;return this.readyImagery!==o&&(u(this.readyImagery)&&this.readyImagery.releaseReference(),this.readyImagery=o,u(o)&&(o.addReference(),this.textureTranslationAndScale=r._calculateTextureTranslationAndScale(e,this))),i.state===di.FAILED||i.state===di.INVALID?u(s)?(s.processStateMachine(t,!this.useWebMercatorT,n),!1):!0:!1};var PS=zY;function pi(e,t){this._imageryProvider=e,this._readyEvent=new ge,this._errorEvent=new ge,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,pi.DEFAULT_BRIGHTNESS)),this.contrast=y(t.contrast,y(e._defaultContrast,pi.DEFAULT_CONTRAST)),this.hue=y(t.hue,y(e._defaultHue,pi.DEFAULT_HUE)),this.saturation=y(t.saturation,y(e._defaultSaturation,pi.DEFAULT_SATURATION)),this.gamma=y(t.gamma,y(e._defaultGamma,pi.DEFAULT_GAMMA)),this.splitDirection=y(t.splitDirection,pi.DEFAULT_SPLIT),this.minificationFilter=y(t.minificationFilter,y(e._defaultMinificationFilter,pi.DEFAULT_MINIFICATION_FILTER)),this.magnificationFilter=y(t.magnificationFilter,y(e._defaultMagnificationFilter,pi.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 PS(IS.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,pi.DEFAULT_APPLY
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = texture(colorTexture, v_textureCoordinates);
}
`;var o0=`uniform highp sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main()
{
out_FragColor = czm_packDepth(texture(u_depthTexture, v_textureCoordinates).r);
}
`;function Nm(){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 Xe,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(Nm.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 Zut(e){e._pickColorFramebuffer.destroy(),e._outputFramebuffer.destroy(),e._copyDepthFramebuffer.destroy(),e._tempCopyDepthFramebuffer.destroy(),e._updateDepthFramebuffer.destroy()}function Bye(e,t,n,i,r){e._viewport.width=n,e._viewport.height=i;let o=!Xe.equals(e._viewport,r.viewport),s=o!==e._useScissorTest;e._useScissorTest=o,Xe.equals(e._scissorRectangle,r.viewport)||(e._scissorRectangle=Xe.clone(r.viewport,e._scissorRectangle),s=!0),(!u(e._rs)||!Xe.equals(e._viewport,e._rs.viewport)||s)&&(e._rs=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:ln.ALPHA_BLEND}),e._rsUpdate=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:zn.EQUAL,frontOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.KEEP},backFunction:zn.NEVER,reference:Lt.CESIUM_3D_TILE_MASK,mask:Lt.CESIUM_3D_TILE_MASK}})),u(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(o0,{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(Xl,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,u(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(o0,{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(Xl,{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 z(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}Nm.prototype.update=function(e,t,n,i,r,o){let s=n.width,a=n.height,c=r?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),Bye(this,e,s,a,t),e.uniformState.globeDepthTexture=void 0,this._useHdr=r,this._clearGlobeDepth=o};Nm.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};Nm.prototype.executeCopyDepth=function(e,t){u(this._copyDepthCommand)&&(this.p
{
out_FragColor = vec4(1.0);
}
`;t.sources=[n]}function tX(e,t){let n=t.sources,i=n.length;for(let o=0;o<i;++o)n[o]=He.replaceMain(n[o],"czm_globe_translucency_main");let r=`
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(r)}function jye(e,t){tX(e,t),Xf(e.defines,"GROUND_ATMOSPHERE"),Xf(t.defines,"GROUND_ATMOSPHERE"),Xf(e.defines,"FOG"),Xf(t.defines,"FOG")}function lft(e,t){tX(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function uft(e,t){jye(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function Uye(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 fft(e,t,n,i,r,o){if(!u(r))return t;if(!i&&u(n))return n;let s=e.shaderCache.getDerivedShaderProgram(t,o);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):[],r(c,l),s=e.shaderCache.createDerivedShaderProgram(t,o,{vertexShaderSource:c,fragmentShaderSource:l,attributeLocations:a})}return s}function dft(e){e.cull.face=gi.BACK,e.cull.enabled=!0}function hft(e){e.cull.face=gi.FRONT,e.cull.enabled=!0}function mft(e){e.cull.face=gi.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function pft(e){e.cull.face=gi.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function _ft(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function Vye(e){e.cull.face=gi.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=ln.ALPHA_BLEND}function kye(e){e.cull.face=gi.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=ln.ALPHA_BLEND}function gft(e){e.cull.face=gi.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function yft(e){e.cull.face=gi.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function Aft(e,t,n,i,r){if(!u(i))return e;if(!n&&u(t))return t;let o=r[e.id];if(!u(o)){let s=Ve.getState(e);i(s),o=Ve.fromCache(s),r[e.id]=o}return o}function LS(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function xft(e,t,n,i,r){return u(r)?!i&&u(n)?n:mt(t,r(e),!1):t}function Eh(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function Cft(){return[new Eh({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:aft,getRenderStateFunction:dft,getUniformMapFunction:void 0}),new Eh({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:cft,getRenderStateFunction:hft,getUniformMapFunction:void 0}),new Eh({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:eX,getRenderStateFunction:mft,getUniformMapFunction:void 0}),new Eh({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:eX,getRenderStateFunction:pft,getUniformMapFunction:void 0}),new Eh({pass:be.GLOBE,pickOnly:!1,getShaderProgramFunction:eX,getRenderStateFunction:_ft,getUniformMapFunction:void 0}),new Eh({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:tX,getRenderStateFunction:Vye,getUniformMapFunction:LS}),new Eh({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:jye,getRenderStateFunction:kye,getUniformMapFunction:LS}),new Eh({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:lft,getRenderStateFunction:Vye,getUniformMapFunction:LS}),new Eh({pass:be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:uft,getRenderStateFunction:kye,getUniformMapFunction:LS}),new Eh({pass:be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:Uye,getRenderStateFunction:gft,getUniformMapFunction:LS}),new Eh({pass:be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:Uye,getRenderStateFunction:yft,getUniformMapFunction:LS})]}var zye=new Array(yC),Hye=new Array(yC);AC.prototype.updateDerivedCommands=function(e,t){let n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let r=0;r<i;++r)Hye[r]=this._derivedCommandPacks[n[r]],zye[r]=Wye[n[r]];Tft(this,e,i,n,zye,Hye,t)}};function Tft(e,t,n,i,r,o,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,m=a.shaderProgramId!==t.shaderProgram.id,A=a.renderStateId!==t.renderState.id;g&&(a.uniformMapDirtyFrame=l),m&&(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=o[x],E=i[x],T=r[x],S=a[T],v,D,M;u(S)?(v=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;
}
`,idt=`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
}
`;Fm.prototype.update=function(e,t,n){let i=this._fbo.getColorTexture(),r=this.previousFramebuffer!==this._previousFramebuffer;this._previousFramebuffer=this.previousFramebuffer;let o=this._numSamples!==t,s=e.drawingBufferWidth,a=e.drawingBufferHeight,c=!u(i)||i.width!==s||i.height!==a;if((c||r||o)&&(this._numSamples=t,this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),u(this._previousFramebuffer)||(this._depthStencilTexture=new Ot({context:e,width:s,height:a,pixelFormat:st.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new cu({context:e,width:s,height:a,format:Vc.DEPTH24_STENCIL8,numSamples:t})))),!u(this._fbo.framebuffer)||c||r||o){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=Ve.fromCache($ft),this._rsClassified=Ve.fromCache(edt),this._rsDefault=Ve.fromCache(tdt)),!u(this._unclassifiedCommand)||r||o){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)?idt:ndt,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(Xl,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};Fm.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};Fm.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))};Fm.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)};Fm.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};Fm.prototype.isDestroyed=function(){return!1};Fm.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=Fm;function $z(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties($z.prototype,{total:{get:function(){return this._total}}});function a0(e){let t=new Array(ya.NUMBER_OF_JOB_TYPES);t[ya.TEXTURE]=new $z(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 RN=`/**
* 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 j_(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 z(0,0,0,0),owner:this}),this._translucentMRTClearCommand=new li({color:new z(0,0,0,1),owner:this}),this._translucentMultipassClearCommand=new li({color:new z(0,0,0,0),owner:this}),this._alphaClearCommand=new li({color:new z(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 Xe,this._rs=void 0,this._useScissorTest=!1,this._scissorRectangle=void 0,this._useHDR=!1}function $ye(e){e._accumulationTexture=e._accumulationTexture&&!e._accumulationTexture.isDestroyed()&&e._accumulationTexture.destroy(),e._revealageTexture=e._revealageTexture&&!e._revealageTexture.isDestroyed()&&e._revealageTexture.destroy()}function fX(e){e._translucentFBO.destroy(),e._alphaFBO.destroy(),e._adjustTranslucentFBO.destroy(),e._adjustAlphaFBO.destroy()}function e0e(e){$ye(e),fX(e)}function cdt(e,t,n,i){$ye(e),e._accumulationTexture=new Ot({context:t,width:n,height:i,pixelFormat:st.RGBA,pixelDatatype:Ke.FLOAT});let r=new Float32Array(n*i*4);e._revealageTexture=new Ot({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.FLOAT,source:{arrayBufferView:r,width:n,height:i},flipY:!1})}function ldt(e,t){fX(e);let n=te.FRAMEBUFFER_COMPLETE,i=!0,{width:r,height:o}=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,r,o),e._adjustTranslucentFBO.setColorTexture(e._accumulationTexture,0),e._adjustTranslucentFBO.setColorTexture(e._revealageTexture,1),e._adjustTranslucentFBO.update(t,r,o),(e._translucentFBO.status!==n||e._adjustTranslucentFBO.status!==n)&&(fX(e),e._translucentMRTSupport=!1)),!e._translucentMRTSupport){e._translucentFBO.setColorTexture(e._accumulationTexture),e._translucentFBO.setDepthStencilTexture(e._depthStencilTexture),e._translucentFBO.update(t,r,o),e._alphaFBO.setColorTexture(e._revealageTexture),e._alphaFBO.setDepthStencilTexture(e._depthStencilTexture),e._alphaFBO.update(t,r,o),e._adjustTranslucentFBO.setColorTexture(e._accumulationTexture),e._adjustTranslucentFBO.update(t,r,o),e._adjustAlphaFBO.setColorTexture(e._revealageTexture),e._adjustAlphaFBO.update(t,r,o);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)&&(e0e(e),e._translucentMultipassSupport=!1,i=!1)}return i}j_.prototype.update=function(e,t,n,i,r){if(!this.isSupported())return;this._opaqueFBO=n,this._opaqueTexture=n.getColorTexture(0),this._depthStencilTexture=n.getDepthStencilTexture();let{width:o,height:s}=this._opaqueTexture,a=this._accumulationTexture,c=!u(a)||a.width!==o||a.height!==s||i!==this._useHDR,l=this._numSamples!==r;if((c||l)&&(this._numSamples=r,cdt(this,e,o,s)),(!u(this._translucentFBO.framebuffer)||c||l)&&!ldt(this,e))return;this._useHDR=i;let f=this,d,p;u(this._compositeCommand)||(d=new He({sources:[RN]}),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);
`,gdt=` 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;
`,ydt=` float ai = czm_out_FragColor.a;
out_FragColor = vec4(ai);
`;function hX(e,t,n,i){let{shaderCache:r}=e,o=r.getDerivedShaderProgram(t,n);if(u(o))return o;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}}
`),r.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:a,attributeLocations:s})}function Adt(e,t){return hX(e,t,"translucentMRT",_dt)}function xdt(e,t){return hX(e,t,"translucentMultipass",gdt)}function Cdt(e,t){return hX(e,t,"alphaMultipass",ydt)}j_.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=Adt(t,e.shaderProgram),n.translucentCommand.renderState=hdt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=a,n.translucentCommand.renderState=c),n}let i,r,o,s;return u(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,r=n.translucentCommand.renderState,o=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=xdt(t,e.shaderProgram),n.translucentCommand.renderState=mdt(this,t,e.renderState),n.alphaCommand.shaderProgram=Cdt(t,e.shaderProgram),n.alphaCommand.renderState=pdt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=i,n.translucentCommand.renderState=r,n.alphaCommand.shaderProgram=o,n.alphaCommand.renderState=s),n};function Tdt(e,t,n,i,r,o){let s,a,c,{context:l,frameState:f}=t,{useLogDepth:d,shadowState:p}=f,g=t._hdr,m=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<r.length;++c)s=r[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(o)&&(s=o.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<r.length;++c)s=r[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(o)&&(s=o.unclassifiedCommand,a=A&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,l,i,x)),i.framebuffer=m}function Edt(e,t,n,i,r,o){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 m,A;for(let x=0;x<r.length;++x)m=r[x],m=c?m.derivedCommands.logDepth.command:m,m=f?m.derivedCommands.hdr.command:m,A=p&&m.receiveShadows?m.derivedCommands.oit.shadows.translucentCommand:m.derivedCommands.oit.translucentCommand,n(A,t,s,i,g);u(o)&&(m=o.unclassifiedCommand,A=p&&m.receiveShadows?m.derivedCommands.oit.shadows.translucentCommand:m.derivedCommands.oit.translucentCommand,n(A,t,s,i,g)),i.framebuffer=d}j_.prototype.executeCommands=function(e,t,n,i,r){if(this._translucentMRTSupport){Edt(this,e,t,n,i,r);return}Tdt(this,e,t,n,i,r)};j_.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};j_.prototype.clear=function(e,t,n){let i=t.framebuffer;t.framebuffer=this._opaqueFBO.framebuffer,z.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:Ve.fromCache(),uniformMap:{u_texture:function(){return e._textureToCopy}},owner:e})}e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}bC.prototype.update=function(e,t){Rdt(this,e,t),Bdt(this,e,t)};var Ldt=new oe,Ndt=new oe(1,1/255,1/65025,1/16581375);bC.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}),r=oe.unpack(i,0,Ldt);return oe.divideByScalar(r,255,r),oe.dot(r,Ndt)};bC.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};bC.prototype.isDestroyed=function(){return!1};bC.prototype.destroy=function(){return this._framebuffer.destroy(),u(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=u(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),ue(this)};var NN=bC;function FN(){this._framebuffer=new mi({color:!1,depthStencil:!0,supportsDepthTexture:!0}),this._passState=void 0}Object.defineProperties(FN.prototype,{framebuffer:{get:function(){return this._framebuffer.framebuffer}}});function Fdt(e){e._framebuffer.destroy()}function Udt(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i);let r=new uc(t);r.blendingEnabled=!1,r.scissorTest={enabled:!0,rectangle:new Xe},r.viewport=new Xe,e._passState=r}FN.prototype.update=function(e,t,n){let i=n.width,r=n.height;this._framebuffer.isDirty(i,r)&&Udt(this,e);let o=this.framebuffer,s=this._passState;return s.framebuffer=o,s.viewport.width=i,s.viewport.height=r,s.scissorTest.rectangle.x=t.x,s.scissorTest.rectangle.y=r-t.y,s.scissorTest.rectangle.width=1,s.scissorTest.rectangle.height=1,s};FN.prototype.isDestroyed=function(){return!1};FN.prototype.destroy=function(){return Fdt(this),ue(this)};var UN=FN;function kN(e){let t=new uc(e);t.blendingEnabled=!1,t.scissorTest={enabled:!0,rectangle:new Xe},t.viewport=new Xe,this._context=e,this._fb=new mi({depthStencil:!0}),this._passState=t,this._width=0,this._height=0}kN.prototype.begin=function(e,t){let n=this._context,i=t.width,r=t.height;return Xe.clone(e,this._passState.scissorTest.rectangle),this._width=i,this._height=r,this._fb.update(n,i,r),this._passState.framebuffer=this._fb.framebuffer,this._passState.viewport.width=i,this._passState.viewport.height=r,this._passState};var VN=new z;kN.prototype.end=function(e){let t=y(e.width,1),n=y(e.height,1),i=this._context,r=i.readPixels({x:e.x,y:e.y,width:t,height:n,framebuffer:this._fb.framebuffer}),o=Math.max(t,n),s=o*o,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 m=4*((c-f)*t+l+a);VN.red=z.byteToFloat(r[m]),VN.green=z.byteToFloat(r[m+1]),VN.blue=z.byteToFloat(r[m+2]),VN.alpha=z.byteToFloat(r[m+3]);let A=i.getObjectByPickColor(VN);if(u(A))return A}if(l===f||l<0&&-l===f||l>0&&l===1-f){let m=d;d=-p,p=m}l+=d,f+=p}};kN.prototype.isDestroyed=function(){return!1};kN.prototype.destroy=function(){return this._fb.destroy(),ue(this)};var zN=kN;function Y_(){this._numSamples=1,this._colorFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._idFramebuffer=new mi({depthStencil:!0,supportsDepthTexture:!0}),this._idClearColor=new z(0,0,0,0),this._clearCommand=new li({color:new z(0,0,0,0),depth:1,owner:this})}function Vdt(e){e._colorFramebuffer.destroy(),e._idFramebuffer.destroy()}Object.defineProperties(Y_.prototype,{framebuffer:{get:function(){return this._colorFramebuffer.framebuffer}},idFramebuffer:{get:function(){return this._idFramebuffer.framebuffer}},depthStencilTexture:{get:function(){return this._colorFramebuffer.getDepthStencilTexture()}}});Y_.prototype.update=function(e,t,n,i){let r=t.width,o=t.height,s=n?e.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._numSamples=i,this._colorFramebuffer.update(e,r,o,i,s),this._idFramebuffer.update(e,r,o)};Y_.prototype.clear=function(e,t,n){z.clone(n,this._clearCommand.color),z.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;
}`;r.push(c)}return new He({defines:i,sources:r})};vC.createShadowCastFragmentShader=function(e,t,n,i){let r=e.defines.slice(0),o=e.sources.slice(0);r.push("SHADOW_MAP");let s=He.findPositionVarying(e),a=u(s);a||(s="v_positionEC");let c=o.length;for(let f=0;f<c;++f)o[f]=He.replaceMain(o[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+=`}
`,o.push(l),new He({defines:r,sources:o})};vC.getShadowReceiveShaderKeyword=function(e,t,n,i){let r=e._usesDepthTexture,o=e._polygonOffsetSupported,s=e._isPointLight,a=e._isSpotLight,c=e._numberOfCascades>1,l=e.debugCascadeColors,f=e.softShadows;return`receiveShadow ${r}${o}${s}${a}${c}${l}${f}${t}${n}${i}`};vC.createShadowReceiveVertexShader=function(e,t,n){let i=e.defines.slice(0),r=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:r})};vC.createShadowReceiveFragmentShader=function(e,t,n,i,r){let o=He.findNormalVarying(e),s=!i&&u(o)||i&&r,a=He.findPositionVarying(e),c=u(a),l=t._usesDepthTexture,f=t._polygonOffsetSupported,d=t._isPointLight,p=t._isSpotLight,g=t._numberOfCascades>1,m=t.debugCascadeColors,A=t.softShadows,x=d?t._pointBias:i?t._terrainBias:t._primitiveBias,C=e.defines.slice(0),E=e.sources.slice(0),T=E.length;for(let D=0;D<T;++D)E[D]=He.replaceMain(E[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 v;return c?v=` return vec4(${a}, 1.0);
`:v=`#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()
{
${v}}
vec3 getNormalEC()
{
${s?` return normalize(${o});
`:` 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);
${m?` // 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;
}
`,E.push(S),new He({defines:C,sources:E})};var Um=vC;function Vm(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 N,this._shadowMapTexture=void 0,this._lightDirectionEC=new h,this._lightPositionEC=new oe,this._distance=0,this._lightCamera=e.lightCamera,this._shadowMapCamera=new sH,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 bo:u(this._lightCamera.frustum.fov)&&(this._isSpotLight=!0),this._cascadeSplits=[new oe,new oe],this._cascadeMatrices=[new N,new N,new N,new N],this._cascadeDistances=new oe;let i;this._isPointLight?i=6:this._cascadesEnabled?i=this._numberOfCascades:i=1,this._passes=new Array(i);for(let r=0;r<i;++r)this._passes[r]=new kdt(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,AX(this),this._clearCommand=new li({depth:1,color:new z}),this._clearPassState=new uc(t),this._size=y(e.size,2048),this.size=this._size}Vm.MAXIMUM_DISTANCE=2e4;function kdt(e){this.camera=new sH,this.passState=new uc(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function yX(e,t){return Ve.fromCache({cull:{enabled:!0,face:gi.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 AX(e){let t=!e._usesDepthTexture;e._primitiveRenderState=yX(t,e._primitiveBias),e._terrainRenderState=yX(t,e._terrainBias),e._pointRenderState=yX(t,e._pointBias)}Vm.prototype.debugCreateRenderStates=function(){AX(this)};Object.defineProperties(Vm.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){qdt(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 Kdt(e,t){let n=t.context,i=t.context.drawingBufferWidth,r=t.context.drawingBufferHeight,o=Math.min(i,r)*.3,s=Ydt;s.x=i-o,s.y=0,s.width=o,s.height=o;let a=e._debugShadowViewCommand;u(a)||(a=Xdt(e,n),e._debugShadowViewCommand=a),(!u(a.renderState)||!Xe.equals(a.renderState.viewport,s))&&(a.renderState=Ve.fromCache({viewport:Xe.clone(s)})),t.commandList.push(e._debugShadowViewCommand)}var km=new Array(8);km[0]=new oe(-1,-1,-1,1);km[1]=new oe(1,-1,-1,1);km[2]=new oe(1,1,-1,1);km[3]=new oe(-1,1,-1,1);km[4]=new oe(-1,-1,1,1);km[5]=new oe(1,-1,1,1);km[6]=new oe(1,1,1,1);km[7]=new oe(-1,1,1,1);var l0=new N,CX=new Array(8);for(let e=0;e<8;++e)CX[e]=new oe;function Jdt(e,t){let n=new xt({geometry:new sd({minimum:new h(-.5,-.5,-.5),maximum:new h(.5,.5,.5)}),attributes:{color:Ut.fromColor(t)}}),i=new xt({geometry:new r_({radius:.5}),attributes:{color:Ut.fromColor(t)}});return new bn({geometryInstances:[n,i],appearance:new rn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}var Zdt=[z.RED,z.GREEN,z.BLUE,z.MAGENTA],Qdt=new h;function $dt(e,t){Kdt(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 Rm({camera:e._sceneCamera,color:z.CYAN,updateOnChange:!1})),e._debugCameraFrustum.update(t)),e._cascadesEnabled){if(e.debugFreezeFrame){n&&(e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=new Rm({camera:e._shadowMapCamera,color:z.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 Rm({camera:e._passes[i].camera,color:Zdt[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!u(e._debugLightFrustum)||e._needsUpdate){let i=e._shadowMapCamera.positionWC,r=Le.IDENTITY,o=e._pointLightRadius*2,s=h.fromElements(o,o,o,Qdt),a=N.fromTranslationQuaternionRotationScale(i,r,s,l0);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=Jdt(a,z.YELLOW)}e._debugLightFrustum.update(t)}else(!u(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new Rm({camera:e._shadowMapCamera,color:z.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function sH(){this.viewMatrix=new N,this.inverseViewMatrix=new N,this.frustum=void 0,this.positionCartographic=new me,this.positionWC=new h,this.directionWC=h.clone(h.UNIT_Z),this.upWC=h.clone(h.UNIT_Y),this.rightWC=h.clone(h.UNIT_X),this.viewProjectionMatrix=new N}sH.prototype.clone=function(e){N.clone(e.viewMatrix,this.viewMatrix),N.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),me.clone(e.positionCartographic,this.positionCartographic),h.clone(e.positionWC,this.positionWC),h.clone(e.directionWC,this.directionWC),h.clone(e.upWC,this.upWC),h.clone(e.rightWC,this.rightWC)};var eht=new N(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);sH.prototype.getViewProjection=function(){let e=this.viewMatrix,t=this.frustum.projectionMatrix;return N.multiply(t,e,this.viewProjectionMatrix),N.multiply(eht,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};var tht=new Array(5),nht=new wi,iht=new Array(4),u0e=new h,f0e=new h;function rht(e,t){let n=e._shadowMapCamera,i=e._sceneCamera,r=i.frustum.near,o=i.frustum.far,s=e._numberOfCascades,a,c=o-r,l=o/r,f=.9,d=!1;t.shadowState.closestObjectSize<200&&(d=!0,f=.9);let p=iht,g=tht;for(g[0]=r,g[s]=o,a=0;a<s;++a){let L=(a+1)/s,_=r*Math.pow(l,L),b=r+c*L,w=P.lerp(b,_,f);g[a+1]=w,p[a]=w-g[a]}if(d){for(a=0;a<s;++a)p[a]=Math.min(p[a],e._maximumCascadeDistances[a]);let L=g[0];for(a=0;a<s-1;++a)L+=p[a],g[a+1]=L}oe.unpack(g,0,e._cascadeSplits[0]),oe.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 wC=`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 Aht=!1;function u0(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 z(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new li({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new Xe,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(u0.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function m0e(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function p0e(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function xht(e,t,n,i){m0e(e),e._translucentDepthStencilTexture=new Ot({context:t,width:n,height:i,pixelFormat:st.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8,sampler:un.NEAREST})}function Cht(e,t,n,i){p0e(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 Tht(e,t,n,i){if(!e.isSupported())return;e._opaqueDepthStencilTexture=i;let r=e._opaqueDepthStencilTexture.width,o=e._opaqueDepthStencilTexture.height;e._drawClassificationFBO.isDirty(r,o)&&(xht(e,t,r,o),Cht(e,t,r,o));let s,a;if(u(e._packDepthCommand)||(s=new He({sources:[HN]}),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:[wC]}),a={colorTexture:function(){return e._textureToComposite}},Aht&&(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:[wC]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),u(e._accumulateCommand)||(s=new He({sources:[wC]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._accumulateCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),e._viewport.width=r,e._viewport.height=o;let c=!Xe.equals(e._viewport,n.viewport),l=c!==e._useScissorTest;e._useScissorTest=c,Xe.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle=Xe.clone(n.viewport,e._scissorRectangle),l=!0),(!u(e._rsDepth)||!Xe.equals(e._viewport,e._rsDepth.viewport)||l)&&(e._rsDepth=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}})),u(e._packDepthCommand)&&(e._packDepthCommand.renderState=e._rsDepth),(!u(e._rsAccumulate)||!Xe.equals(e._viewport,e._rsAccumulate.viewport)||l)&&(e._rsAccumulate=Ve.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)||!Xe.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 qN=nmt;var imt={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}}},qS=imt;var IC={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function YN(e){this._parsedContent=void 0,this._drawCommand=void 0,this._isTranslucent=!1,this._styleTranslucent=!1,this._constantColor=z.clone(z.DARKGRAY),this._highlightColor=z.clone(z.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=IC.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=N.clone(N.IDENTITY),this._modelMatrix=N.clone(N.IDENTITY),this.time=0,this.shadows=gn.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,kc.NONE),this._splittingEnabled=!1,this._error=void 0,rmt(this,e)}Object.defineProperties(YN.prototype,{pointsLength:{get:function(){return this._pointsLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}},color:{get:function(){return z.clone(this._highlightColor)},set:function(e){this._highlightColor=z.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 rmt(e,t){let n=jA.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=Tp.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),u(n.draco)){let a=n.draco;e._decodingState=IC.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 r=n.normals;u(r)&&(e._isOctEncoded16P=r.octEncoded);let o=n.colors;u(o)&&(u(o.constantColor)&&(e._constantColor=z.clone(o.constantColor,e._constantColor),e._hasColors=!1),e._isRGB565=o.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 omt=new h,smt=new h,amt=new h,O0e,fH;function cmt(e){if(!u(fH)){O0e=new R0e.default(0),fH=new Array(e);for(let t=0;t<e;++t)fH[t]=O0e.random()}return fH}function lmt(e){let n=e.length/3,i=Math.min(n,20),r=cmt(20),o=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=h.fromElements(o,o,o,omt),c=h.fromElements(s,s,s,smt);for(let f=0;f<i;++f){let d=Math.floor(r[f]*n),p=h.unpack(e,d*3,amt);h.minimumByComponent(a,p,a),h.maximumByComponent(c,p,c)}let l=ae.fromCornerPoints(a,c);return l.radius+=P.EPSILON2,l}function M0e(e,t){let n=X.fromTypedArray(e);return n===X.INT||n===X.UNSIGNED_INT||n===X.DOUBLE?(Mt("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 r=i[1];t.indexOf(r)===-1&&t.push(r),i=n.exec(e)}}function DX(e,t){let n=e.numberOfAttributes;for(let i=0;i<n;++i){let r=e.getAttribute(i);if(r.index===t)return r}}var gmt={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 ymt(e,t,n){let i,r,o,s=t.context,a=u(n),c=e._isQuantized,l=e._isQuantizedDraco,f=e._isOctEncoded16P,d=e._isOctEncodedDraco,p=e._isRGB565,g=e._isTranslucent,m=e._hasColors,A=e._hasNormals,x=e._hasBatchIds,C=e._backFaceCulling,E=e._normalShading,T=e._drawCommand.vertexArray,S=e.clippingPlanes,v=e._attenuation,D,M,O,B=g,L=je(gmt),_={},b=e._styleableShaderAttributes;for(r in b)b.hasOwnProperty(r)&&(o=b[r],L[r]=`czm_3dtiles_property_${o.location}`,_[o.location]=o);if(a){let se={translucent:!1},Ae="(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${Ae}`,L,se),M=n.getShowShaderFunction(`getShowFromStyle${Ae}`,L,se),O=n.getPointSizeShaderFunction(`getPointSizeFromStyle${Ae}`,L,se),u(D)&&se.translucent&&(B=!0)}e._styleTranslucent=B;let w=u(D),I=u(M),R=u(O),F=e.isClipped,k=[],V=[];w&&(vX(D,k),wX(D,V)),I&&(vX(M,k),wX(M,V)),R&&(vX(O,k),wX(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(r in b)if(b.hasOwnProperty(r)){o=b[r];let se=k.indexOf(o.location)>=0,Ae=DX(T,o.location);Ae.enabled=se}let Y=m&&(!w||G);if(m){let se=DX(T,dH);se.enabled=Y}let j=A&&(E||C||U);if(A){let se=DX(T,IX);se.enabled=j}let Q={a_position:B0e};Y&&(Q.a_color=dH),j&&(Q.a_normal=IX),x&&(Q.a_batchId=L0e);let W="",K=k.length;for(i=0;i<K;++i){let se=k[i];o=_[se];let Ae=o.componentCount,he=`czm_3dtiles_property_${se}`,Se;Ae===1?Se="float":Se=`vec${Ae}`,W+=`in ${Se} ${he};
`,Q[he]=o.location}_mt(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;
`,v&&(J+=`float u_geometricError;
float u_depthMultiplier;
`),J+=W,Y&&(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;
`),j&&(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;
`),w&&(J+=D),I&&(J+=M),R&&(J+=O),J+=`void main()
{
u_pointSize = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.x;
tiles3d_tileset_time = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.y;
`,v&&(J+=` u_geometricError = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.z;
u_depthMultiplier = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.w;
`),Y?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));
`,j?(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);
`,w&&(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;
`:v?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;
`,j&&E&&(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);
`,j&&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 _e=`in vec4 v_color;
`;F&&(_e+=`uniform highp sampler2D u_clippingPlanes;
uniform mat4 u_clippingPlanesMatrix;
uniform vec4 u_clippingPlanesEdgeStyle;
`,_e+=`
`,_e+=z_(S,s),_e+=`
`),_e+=`void main()
{
out_FragColor = czm_gammaCorrect(v_color);
`,F&&(_e+=qN("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),_e+=`}
`,e.splitDirection!==kc.NONE&&(_e=qS.modifyFragmentShader(_e)),u(e._vertexShaderLoaded)&&(J=e._vertexShaderLoaded(J)),u(e._fragmentShaderLoaded)&&(_e=e._fragmentShaderLoaded(_e));let xe=e._drawCommand;u(xe.shaderProgram)&&xe.shaderProgram.destroy(),xe.shaderProgram=Xt.fromCache({context:s,vertexShaderSource:J,fragmentShaderSource:_e,attributeLocations:Q});try{xe.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 Amt(e,t){if(e._decodingState===IC.READY)return!1;if(e._decodingState===IC.NEEDS_DECODE){let n=e._parsedContent,i=n.draco,r=Pp.decodePointCloud(i,t);u(r)&&(e._decodingState=IC.DECODING,r.then(function(o){e._decodingState=IC.READY;let s=u(o.POSITION)?o.POSITION.array:void 0,a=u(o.RGB)?o.RGB.array:void 0,c=u(o.RGBA)?o.RGBA.array:void 0,l=u(o.NORMAL)?o.NORMAL.array:void 0,f=u(o.BATCH_ID)?o.BATCH_ID.array:void 0,d=u(s)&&u(o.POSITION.data.quantization),p=u(l)&&u(o.NORMAL.data.quantization);if(d){let x=o.POSITION.data.quantization,C=x.range;e._quantizedVolumeScale=h.fromElements(C,C,C),e._quantizedVolumeOffset=h.unpack(x.minValues),e._quantizedRange=(1<<x.quantizationBits)-1,e._isQuantizedDraco=!0}p&&(e._octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let g=n.styleableProperties,m=i.batchTableProperties;for(let x in m)if(m.hasOwnProperty(x)){let C=o[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(o){e._decodingState=IC.FAILED,e._error=o}))}return!0}var xmt=new oe,Cmt=new h;YN.prototype.update=function(e){let t=e.context;if(u(this._error)){let l=this._error;throw this._error=void 0,l}if(Amt(this,t))return;let i=!1,r=!N.equals(this._modelMatrix,this.modelMatrix);if(this._mode!==e.mode&&(this._mode=e.mode,r=!0),u(this._drawCommand)||(pmt(this,e),r=!0,i=!0,this._ready=!0,this._parsedContent=void 0),r){N.clone(this.modelMatrix,this._modelMatrix);let l=this._drawCommand.modelMatrix;if(N.clone(this._modelMatrix,l),u(this._rtcCenter)&&N.multiplyByTranslation(l,this._rtcCenter,l),u(this._quantizedVolumeOffset)&&N.multiplyByTranslation(l,this._quantizedVolumeOffset,l),e.mode!==ne.SCENE3D){let d=e.mapProjection,p=N.getColumn(l,3,xmt);oe.equals(p,oe.UNIT_W)||Pt.basisTo2D(d,l,l)}let f=this._drawCommand.boundingVolume;if(ae.clone(this._boundingSphere,f),this._cull){let d=f.center;N.multiplyByPoint(l,d,d);let p=N.getScale(l,Cmt);f.radius*=h.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 o=this.splitDirection!==kc.NONE;this._splittingEnabled!==o&&(this._splittingEnabled=o,i=!0),i&&ymt(this,e,this._style),this._drawCommand.castShadows=gn.castShadows(this.shadows),this._drawCommand.receiveShadows=gn.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)};YN.prototype.isDestroyed=function(){return!1};YN.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 XN=YN;var Tmt={NEAREST:0,LINEAR:1},Gu=Tmt;function PC(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 < ${r}; ++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 Imt(e){let t=e._sampleMode,n,i;t===Gu.LINEAR?(n=an.LINEAR,i=Ti.LINEAR):(n=an.NEAREST,i=Ti.NEAREST);let r=e._sampler;(!u(r)||r.minificationFilter!==n||r.magnificationFilter!==i)&&(e._sampler=new un({wrapS:Sn.CLAMP_TO_EDGE,wrapT:Sn.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function Pmt(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function Omt(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function Mmt(e,t){let n,i,r,o=e._texturesToRelease,s=o.length;for(n=0;n<s;++n)i=o[n],i=i&&i.destroy();o.length=0;let a=e._texturesToCreate;for(s=a.length,n=0;n<s;++n){let d=a[n];r=d.name;let p=d.source;e._actualUniforms[r]=new Ot({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){r=c[n];let d=l[r],p=e._textureCache.getStageByName(d);if(u(p))e._actualUniforms[r]=Omt(e,d);else if(typeof d=="string"){let g=new De({url:d});f.push(g.fetchImage().then(Pmt(e,r)))}else e._texturesToCreate.push({name:r,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 N0e(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 r in i)i.hasOwnProperty(r)&&i[r]instanceof Ot&&(u(t.getStageByName(n[r]))||i[r].destroy(),e._dirtyUniforms.push(r))}function Rmt(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 r=0;r<t;++r)if(e._combinedSelected[r]!==e._combinedSelectedShadow[r])return!0}return i}function Bmt(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,r,o=0,s=n.length;for(i=0;i<s;++i)r=n[i],u(r.pickIds)?o+=r.pickIds.length:u(r.pickId)&&++o;if(s===0||o===0){let f=new Uint8Array(4);f[0]=255,f[1]=255,f[2]=255,f[3]=255,e._selectedIdTexture=new Ot({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:f,width:1,height:1},sampler:un.NEAREST});return}let a,c=0,l=new Uint8Array(o*4);for(i=0;i<s;++i)if(r=n[i],u(r.pickIds)){let f=r.pickIds,d=f.length;for(let p=0;p<d;++p)a=f[p].color,l[c]=z.floatToByte(a.red),l[c+1]=z.floatToByte(a.green),l[c+2]=z.floatToByte(a.blue),l[c+3]=z.floatToByte(a.alpha),c+=4}else u(r.pickId)&&(a=r.pickId.color,l[c]=z.floatToByte(a.red),l[c+1]=z.floatToByte(a.green),l[c+2]=z.floatToByte(a.blue),l[c+3]=z.floatToByte(a.alpha),c+=4);e._selectedIdTexture=new Ot({context:t,pixelFormat:st.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:l,width:o,height:1},sampler:un.NEAREST})}PC.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&N0e(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=Rmt(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,Bmt(this,e),wmt(this),Mmt(this,e),Dmt(this,e),Im
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 JN=`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 ZN=`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 QN=`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 $N=`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 eF=`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 tF=`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 nF=`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 iF=`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 rF=`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 oF=`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 sF=`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 f0=`#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 aF=`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 cF=`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 lF=`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 uF=`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 fF=`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 dF=`/**
* @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 OC(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(OC.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}}});OC.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};OC.prototype.get=function(e){return this._stages[e]};function Lmt(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 r=0;r<t;++r)if(e._combinedSelected[r]!==e._combinedSelectedShadow[r])return!0}return i}OC.prototype.update=function(e,t){this._selectedDirty=Lmt(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 r=0;r<i;++r){let o=n[r];this._selectedDirty&&(o.parentSelected=this._combinedSelected),o.update(e,t)}};OC.prototype.isDestroyed=function(){return!1};OC.prototype.destroy=function(){let e=this._stages,t=e.length;for(let n=0;n<t;++n)e[n].destroy();return ue(this)};var tl=OC;var Fo={};function hH(e){let r=`#define USE_STEP_SIZE
${f0}`,o=new Tr({name:`${e}_x_direction`,fragmentShader:r,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:Gu.LINEAR}),s=new Tr({name:`${e}_y_direction`,fragmentShader:r,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:Gu.LINEAR}),a={};return Object.defineProperties(a,{delta:{get:function(){return o.uniforms.delta},set:function(c){let l=o.uniforms,f=s.uniforms;l.delta=f.delta=c}},sigma:{get:function(){return o.uniforms.sigma},set:function(c){let l=o.uniforms,f=s.uniforms;l.sigma=f.sigma=c}},stepSize:{get:function(){return o.uniforms.stepSize},set:function(c){let l=o.uniforms,f=s.uniforms;l.stepSize=f.stepSize=c}}}),new tl({name:e,stages:[o,s],uniforms:a})}Fo.createBlurStage=function(){return hH("czm_blur")};Fo.createDepthOfFieldStage=function(){let e=hH("czm_depth_of_field_blur"),t=new Tr({name:"czm_depth_of_field_composite",fragmentShader:nF,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 tl({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};Fo.isDepthOfFieldSupported=function(e){return e.context.depthTexture};Fo.createEdgeDetectionStage=function(){let e=Hn();return new Tr({name:`czm_edge_detection_${e}`,fragmentShader:rF,uniforms:{length:.25,color:z.clone(z.BLACK)}})};Fo.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function Nmt(e){if(!u(e))return Fo.createEdgeDetectionStage();let t=new tl({name:"czm_edge_detection_multiple",stages:e,inputPreviousStageTexture:!1}),n={},i="",r="";for(let a=0;a<e.length;++a)i+=`uniform sampler2D edgeTexture${a};
`,r+=` 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 o=`${i}in vec2 v_textureCoordinates;
void main() {
vec4 color = vec4(0.0);
for (int i = 0; i < ${e.length}; i++)
{
${r} }
out_FragColor = color;
}
`,s=new Tr({name:"czm_edge_detection_combine",fragmentShader:o,uniforms:n});return new tl({name:"czm_edge_detection_composite",stages:[t,s]})}Fo.createSilhouetteStage=function(e){let t=Nmt(e),n=new Tr({name:"czm_silhouette_color_edges",fragmentShader:fF,uniforms:{silhouetteTexture:t.name}});return new tl({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};Fo.isSilhouetteSupported=function(e){return e.context.depthTexture};Fo.createBloomStage=function(){let e=new Tr({name:"czm_bloom_contrast_bias",fragmentShader:tF,uniforms:{contrast:128,brightness:-.3}}),t=hH("czm_bloom_blur"),n=new tl({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new Tr({name:"czm_bloom_generate_composite",fragmentShader:$N,uniforms:{glowOnly:!1,bloomTexture:n.name}}),r={};return Object.defineProperties(r,{glowOnly:{get:function(){return i.uniforms.glowOnly},set:function(o){i.uniforms.glowOnly=o}},contrast:{get:function(){return e.uniforms.contrast},set:function(o){e.uniforms.contrast=o}},brightness:{get:function(){return e.uniforms.brightness},set:function(o){e.uniforms.brightness=o}},delta:{get:function(){return t.uniforms.delta},set:function(o){t.uniforms.delta=o}},sigma:{get:function(){return t.uniforms.sigma},set:function(o){t.uniforms.sigma=o}},stepSize:{get:function(){return t.uniforms.stepSize},set:function(o){t.uniforms.stepSize=o}}}),new tl({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:r})};Fo.createAmbientOcclusionStage=function(){let e=new Tr({name:"czm_ambient_occlusion_generate",fragmentShader:JN,uniforms:{intensity:3,bias:.1,lengthCap:.26,stepSize:1.95,frustumLength:1e3,randomTexture:void 0}}),t=hH("czm_ambient_occlusion_blur");t.uniforms.stepSize=.86;let n=new tl({name:"czm_ambient_occlusion_generate_blur",stages:[e,t]}),i=new Tr({name:"czm_ambient_occlusion_composite",fragmentShader:ZN,uniforms:{ambientOcclusionOnly:!1,ambientOcclusionTexture:n.name}}),r={};return Object.defineProperties(r,{intensity:{get:function(){return e.uniforms.intensity},set:function(o){e.uniforms.intensity=o}},bias:{get:function(){return e.uniforms.bias},set:function(o){e.uniforms.bias=o}},lengthCap:{get:function(){return e.uniforms.lengthCap},set:function(o){e.uniforms.lengthCap=o}},stepSize:{get:function(){return e.uniforms.stepSize},set:function(o){e.uniforms.stepSize=o}},frustumLength:{get:function(){return e.uniforms.frustumLength},set:function(o){e.uniforms.frustumLength=o}},randomTexture:{get:function(){return e.uniforms.randomTexture},set:function(o){e.uniforms.randomTexture=o}},delta:{get:function(){return t.uniforms.delta},set:function(o){t.uniforms.delta=o}},sigma:{get:function(){return t.uniforms.sigma},set:function(o){t.uniforms.sigma=o}},blurStepSize:{get:function(){return t.uniforms.stepSize},set:function(o){t.uniforms.stepSize=o}},ambientOcclusionOnly:{get:function(){return i.uniforms.ambientOcclusionOnly},set:function(o){i.uniforms.ambientOcclusionOnly=o}}}),new tl({name:"czm_ambient_occlusion",stages:[n,i],inputPreviousStageTexture:!1,uniforms:r})};Fo.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};var Fmt=`#define FXAA_QUALITY_PRESET 39
${dF}
${sF}`;Fo.createFXAAStage=function(){return new Tr({name:"czm_FXAA",fragmentShader:Fmt,sampleMode:Gu.LINEAR})};Fo.createAcesTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=KN,new Tr({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fo.createFilmicTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=oF,new Tr({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fo.createReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=uF,new Tr({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0}})};Fo.createModifiedReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE
`:"";return t+=cF,new Tr({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:z.WHITE,autoExposure:void 0}})};Fo.createAutoExposureStage=function(){return new yL};Fo.createBlackAndWhiteStage=function(){return new Tr({name:"czm_black_and_white",fragmentShader:QN,uniforms:{gradations:5}})};Fo.createBrightnessStage=function(){return new Tr({name:"czm_brightness",fragmentShader:eF,uniforms:{brightness:.5}})};Fo.createNightVisionStage=function(){return new Tr({name:"czm_night_vision",fragmentShader:lF})};Fo.createDepthViewStage=function(){return new Tr({name:"czm_depth_view",fragmentShader:iF})};Fo.createLensFlareStage=function(){return new Tr({name:"czm_lens_flare",fragmentShader:aF,uniforms:{dirtTexture:$t("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:$t("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:re.WGS84.maximumRadius}})};var Jf=Fo;function K_(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function mF(e){for(;u(e.length);)e=e.get(e.length-1);return e.name}function PX(e,t,n,i,r){if(!i.enabled||!i._isSupported(t))return r;let o=n[i.name]={};if(u(r)){let a=e.getStageByName(r);o[mF(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)&&(o[mF(d)]=!0)}}}return i.name}function hF(e,t,n,i,r){if(u(i.enabled)&&!i.enabled||u(i._isSupported)&&!i._isSupported(t))return r;let o=r,s=!u(i.inputPreviousStageTexture)||i.inputPreviousStageTexture,a=r,c=i.length;for(let d=0;d<c;++d){let p=i.get(d);u(p.length)?a=hF(e,t,n,p,r):a=PX(e,t,n,p,r),s&&(r=a)}let l,f;if(s)for(l=1;l<c;++l)f=mF(i.get(l)),u(n[f])||(n[f]={}),n[f][o]=!0;else for(l=1;l<c;++l){f=mF(i.get(l));let d=n[f];for(let p=0;p<l;++p)d[mF(i.get(p))]=!0}return a}function Umt(e,t){let n={};if(u(e.ambientOcclusion)){let i=e.ambientOcclusion,r=e.bloom,o=e._tonemapping,s=e.fxaa,a=hF(e,t,n,i,void 0);a=hF(e,t,n,r,a),a=PX(e,t,n,o,a),a=hF(e,t,n,e,a),PX(e,t,n,s,a)}else hF(e,t,n,e,void 0);return n}function Vmt(e,t,n){let r=e._collection.getStageByName(t),o=r._textureScale,s=r._forcePowerOfTwo,a=r._pixelFormat,c=r._pixelDatatype,l=r._clearColor,f,d,p=e._framebuffers,g=p.length;for(f=0;f<g;++f){if(d=p[f],o!==d.textureScale||s!==d.forcePowerOfTwo||a!==d.pixelFormat||c!==d.pixelDatatype||!z.equals(l,d.clearColor))continue;let m=d.stages,A=m.length,x=!1;for(let C=0;C<A;++C)if(n[m[C]]){x=!0;break}if(!x)break}return u(d)&&f<g?(d.stages.push(t),d):(d={textureScale:o,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 kmt(e,t){let n=Umt(e._collection,t);for(let i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=Vmt(e,i,n[i]))}function OX(e){let t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function zmt(e,t){let n=e._width,i=e._height,r=e._framebuffers,o=r.length;for(let s=0;s<o;++s){let a=r[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),r=u(t.bloom)&&t.bloom.enabled&&t.bloom._isSupported(e),o=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||r||o||s;if((n||!a&&this._framebuffers.length>0)&&(OX(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!a)return;this._framebuffers.length===0&&kmt(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 EF=`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 J_(){this._sceneFramebuffer=new SC;let e=.125,t=new Array(6);t[0]=new Tr({fragmentShader:Xl,textureScale:e,forcePowerOfTwo:!0,sampleMode:Gu.LINEAR});let n=t[1]=new Tr({fragmentShader:EF,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 Tr({fragmentShader:f0,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 Tr({fragmentShader:f0,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 Tr({fragmentShader:Xl,sampleMode:Gu.LINEAR}),this._uCenter=new H,this._uRadius=void 0,t[5]=new Tr({fragmentShader:TF,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new tl({stages:t});let r=new MC(this),o=t.length;for(let s=0;s<o;++s)t[s]._textureCache=r;this._textureCache=r,this.length=t.length}J_.prototype.get=function(e){return this._stages.get(e)};J_.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 dgt=new oe,EAe=new H,hgt=new H,bAe=new N;function mgt(e,t,n){let i=t.uniformState,r=i.sunPositionWC,o=i.view,s=i.viewProjection,a=i.projection,c=N.computeViewportTransformation(n,0,1,bAe),l=N.multiplyByPoint(o,r,dgt),f=Pt.pointToGLWindowCoordinates(s,c,r,EAe);l.x+=P.SOLAR_RADIUS;let d=Pt.pointToGLWindowCoordinates(a,c,l,l),p=H.magnitude(H.subtract(d,f,d))*30*2,g=hgt;g.x=p,g.y=p,e._uCenter=H.clone(f,e._uCenter),e._uRadius=Math.max(g.x,g.y)*.15;let m=t.drawingBufferWidth,A=t.drawingBufferHeight,x=e._stages,C=x.get(0),E=C.outputTexture.width,T=C.outputTexture.height,S=new Xe;S.width=E,S.height=T,c=N.computeViewportTransformation(S,0,1,bAe),f=Pt.pointToGLWindowCoordinates(s,c,r,EAe),g.x*=E/m,g.y*=T/A;let v=C.scissorRectangle;v.x=Math.max(f.x-g.x*.5,0),v.y=Math.max(f.y-g.y*.5,0),v.width=Math.min(g.x,m),v.height=Math.min(g.y,A);for(let D=1;D<4;++D)Xe.clone(v,x.get(D).scissorRectangle)}J_.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)};J_.prototype.update=function(e){let t=e.context,n=e.viewport,i=this._sceneFramebuffer;i.update(t,n);let r=i.framebuffer;return this._textureCache.update(t),this._stages.update(t,!1),mgt(this,t,n),r};J_.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 r=1;r<i;++r)n.get(r).execute(e,n.get(r-1).outputTexture)};J_.prototype.copy=function(e,t){if(!u(this._copyColorCommand)){let n=this;this._copyColorCommand=e.createViewportQuadCommand(Xl,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)};J_.prototype.isDestroyed=function(){return!1};J_.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),ue(this)};var bF=J_;var bH=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function Ki(e){e=y(e,y.EMPTY_OBJECT);let t=e.canvas,n=e.creditContainer,i=e.creditViewport,r=je(e.contextOptions),o=u(n),s=new KB(t,r);o||(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 PN,this._frameState=new nN(s,new VL(n," \u2022 ",i),this._jobScheduler),this._frameState.scene3DOnly=y(e.scene3DOnly,!1),this._removeCreditContainer=!o,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 wF=`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 DF=`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 XS(e){e=y(e,re.WGS84),this.show=!0,this.perFragmentAtmosphere=!1,this._ellipsoid=e;let t=1.025,n=h.multiplyByScalar(e.radii,t,new h);this._scaleMatrix=N.fromScale(n),this._modelMatrix=new N,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 h(55e-7,13e-6,284e-7),this.atmosphereMieCoefficient=new h(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 h;let i=new h;i.x=e.maximumRadius*t,i.y=e.maximumRadius,i.z=0,this._radiiAndDynamicAtmosphereColor=i;let r=this;this._command.uniformMap={u_radiiAndDynamicAtmosphereColor:function(){return r._radiiAndDynamicAtmosphereColor},u_hsbShift:function(){return r._hueSaturationBrightness.x=r.hueShift,r._hueSaturationBrightness.y=r.saturationShift,r._hueSaturationBrightness.z=r.brightnessShift,r._hueSaturationBrightness},u_atmosphereLightIntensity:function(){return r.atmosphereLightIntensity},u_atmosphereRayleighCoefficient:function(){return r.atmosphereRayleighCoefficient},u_atmosphereMieCoefficient:function(){return r.atmosphereMieCoefficient},u_atmosphereRayleighScaleHeight:function(){return r.atmosphereRayleighScaleHeight},u_atmosphereMieScaleHeight:function(){return r.atmosphereMieScaleHeight},u_atmosphereMieAnisotropy:function(){return r.atmosphereMieAnisotropy}}}Object.defineProperties(XS.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});XS.prototype.setDynamicAtmosphereColor=function(e,t){let n=e?t?2:1:0;this._radiiAndDynamicAtmosphereColor.z=n};var iK=new N;XS.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=N.fromRotationTranslation(e.context.uniformState.inverseViewRotation,h.ZERO,iK),r=N.multiplyTransformation(i,mr.Y_UP_TO_Z_UP,iK),o=N.multiply(this._scaleMatrix,r,iK);N.clone(o,this._modelMatrix);let s=e.context,a=nyt(this),c=e.globeTranslucencyState.translucent,l=this.perFragmentAtmosphere||c||!u(t)||!t.show,f=this._command;if(!u(f.vertexArray)){let p=Bs.createGeometry(new Bs({radii:new h(1,1,1),slicePartitions:256,stackPartitions:256,vertexFormat:Pe.POSITION_ONLY}));f.vertexArray=si.fromGeometry({context:s,geometry:p,attributeLocations:Rn.createAttributeLocations(p),bufferUsage:Fe.STATIC_DRAW}),f.renderState=Ve.fromCache({cull:{enabled:!0,face:gi.FRONT},blending:ln.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:[k_,YS,DF]}),m=new He({defines:p,sources:[k_,YS,wF]});this._spSkyAtmosphere=Xt.fromCache({context:s,vertexShaderSource:g,fragmentShaderSource:m}),f.shaderProgram=this._spSkyAtmosphere}return f};function nyt(e){return!(P.equalsEpsilon(e.hueShift,0,P.EPSILON7)&&P.equalsEpsilon(e.saturationShift,0,P.EPSILON7)&&P.equalsEpsilon(e.brightnessShift,0,P.EPSILON7))}XS.prototype.isDestroyed=function(){return!1};XS.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 IF=XS;var PF=`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 OF=`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 SH(e){this.sources=e.sources,this._sources=void 0,this.show=y(e.show,!0),this._command=new nt({modelMatrix:N.clone(N.IDENTITY),owner:this}),this._cubeMap=void 0,this._attributeLocations=void 0,this._useHdr=void 0}SH.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 o=this.sources;typeof o.positiveX=="string"?JB(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 za({context:i,source:o}))}let r=this._command;if(!u(r.vertexArray)){r.uniformMap={u_cubeMap:function(){return n._cubeMap}};let o=hl.createGeometry(hl.fromDimensions({dimensions:new h(2,2,2),vertexFormat:Pe.POSITION_ONLY})),s=this._attributeLocations=Rn.createAttributeLocations(o);r.vertexArray=si.fromGeometry({context:i,geometry:o,attributeLocations:s,bufferUsage:Fe.STATIC_DRAW}),r.renderState=Ve.fromCache({blending:ln.ALPHA_BLEND})}if(!u(r.shaderProgram)||this._useHdr!==t){let o=new He({defines:[t?"HDR":""],sources:[PF]});r.shaderProgram=Xt.fromCache({context:i,vertexShaderSource:OF,fragmentShaderSource:o,attributeLocations:this._attributeLocations}),this._useHdr=t}if(u(this._cubeMap))return r};SH.prototype.isDestroyed=function(){return!1};SH.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 MF=SH;function Qf(e,t,n,i,r,o,s){this.children=void 0,this.parent=r,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 Pn,this.approximateVoxelSize=0,this.screenSpaceError=0,this.visitedFrameNumber=-1,this.computeBoundingVolumes(o,s)}var iyt=new h;Qf.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,iyt),i=2*h.maximumComponent(n);this.approximateVoxelSize=i/h.minimumComponent(t)};Qf.prototype.constructChildNodes=function(e,t){let{level:n,x:i,y:r,z:o}=this,s=i*2,a=r*2,c=o*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(([m,A,x,C])=>new Qf(m,A,x,C,this,e,t))};Qf.prototype.visibility=function(e,t){let n=this.orientedBoundingBox;return e.cullingVolume.computeVisibilityWithPlaneMask(n,t)};Qf.prototype.computeScreenSpaceError=function(e,t){let n=this.orientedBoundingBox,i=Math.sqrt(n.distanceSquaredTo(e));i=Math.max(i,P.EPSILON7);let r=this.approximateVoxelSize,o=t*(r/i);this.screenSpaceError=o};var RAe={keyframe:0};function RF(e,t){return RAe.keyframe=e,Pr(t,RAe,er.searchComparator)}Qf.prototype.computeSurroundingRenderableKeyframeNodes=function(e){let t=this,n=t.level,i=Math.floor(e),r=Math.ceil(e),o,s,a=+Number.MAX_VALUE,c=+Number.MAX_VALUE;for(;u(t);){let{renderableKeyframeNodes:d}=t;if(d.length>=1){let p=ryt(i,d),g=d[p],m=r===i||i<g.keyframe?p:Math.min(p+1,d.length-1),A=d[m],x=i-g.keyframe,C=BAe(n-t.level,x);C<a&&(a=C,o=g);let E=A.keyframe-r,T=BAe(n-t.level,E);if(T<c&&(c=T,s=A),x===0&&E===0)break}t=t.parent}if(this.renderableKeyframeNodePrevious=o,this.renderableKeyframeNodeNext=s,!u(o)||!u(s))return;let l=o.keyframe,f=s.keyframe;this.renderableKeyframeNodeLerp=l===f?0:P.clamp((e-l)/(f-l),0,1)};function ryt(e,t){let n=RF(e,t);return n<0?P.clamp(~n-1,0,t.length-1):n}function BAe(e,t){let n=Math.exp(e*4),i=t>=0?1:-200;return e*n+t*i}Qf.prototype.isVisited=function(e){return this.visitedFrameNumber===e};Qf.prototype.createKeyframeNode=function(e){let t=RF(e,this.keyframeNodes);if(t<0){t=~t;let n=new er(this,e);this.keyframeNodes.splice(t,0,n)}};Qf.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 FF=`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 UF=`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 kF(){this.show=!0,this._drawCommand=new nt({primitiveType:Be.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(kF.prototype,{glowFactor:{get:function(){return this._glowFactor},set:function(e){e=Math.max(e,0),this._glowFactor=e,this._glowFactorDirty=!0}}});var oyt=new H,syt=new H,ayt=new oe,VF=new oe;kF.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 r=e.context,o=t.viewport.width,s=t.viewport.height;if(!u(this._texture)||o!==this._drawingBufferWidth||s!==this._drawingBufferHeight||this._glowFactorDirty||n!==this._useHdr){this._texture=this._texture&&this._texture.destroy(),this._drawingBufferWidth=o,this._drawingBufferHeight=s,this._glowFactorDirty=!1,this._useHdr=n;let S=Math.max(o,s);S=Math.pow(2,Math.ceil(Math.log(S)/Math.log(2))-2),S=Math.max(1,S);let v=n?r.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._texture=new Ot({context:r,width:S,height:S,pixelFormat:st.RGBA,pixelDatatype:v}),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 nf({fragmentShaderSource:FF,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},v=new Uint8Array(4*2);v[0]=0,v[1]=0,v[2]=255,v[3]=0,v[4]=255,v[5]=255,v[6]=0,v[7]=255;let D=ft.createVertexBuffer({context:r,typedArray:v,usage:Fe.STATIC_DRAW}),M=[{index:S.direction,vertexBuffer:D,componentsPerAttribute:2,normalize:!0,componentDatatype:X.UNSIGNED_BYTE}],O=ft.createIndexBuffer({context:r,typedArray:new Uint16Array([0,1,2,0,2,3]),usage:Fe.STATIC_DRAW,indexDatatype:Ue.UNSIGNED_SHORT});a.vertexArray=new si({context:r,attributes:M,indexBuffer:O}),a.shaderProgram=Xt.fromCache({context:r,vertexShaderSource:UF,fragmentShaderSource:NF,attributeLocations:S}),a.renderState=Ve.fromCache({blending:ln.ALPHA_BLEND}),a.uniformMap=this._uniformMap}let c=r.uniformState.sunPositionWC,l=r.uniformState.sunPositionColumbusView,f=this._boundingVolume,d=this._boundingVolume2D;h.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=$i.computeActualWgs84Position(e,c,VF),g=h.magnitude(h.subtract(p,e.camera.position,VF)),m=r.uniformState.projection,A=ayt;A.x=0,A.y=0,A.z=-g,A.w=1;let x=N.multiplyByVector(m,A,VF),C=$i.clipToGLWindowCoordinates(t.viewport,x,oyt);A.x=P.SOLAR_RADIUS;let E=N.multiplyByVector(m,A,VF),T=$i.clipToGLWindowCoordinates(t.viewport,E,syt);return this._size=H.magnitude(H.subtract(T,C,VF)),this._size=2*this._size*(1+2*this._glowLengthTS),this._size=Math.ceil(this._size),this._commands};kF.prototype.isDestroyed=function(){return!1};kF.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 zF=kF;function vH(e){this._ready=!1,this._provider=void 0,this._errorEvent=new ge,this._readyEvent=new ge,lyt(this,e)}Object.defineProperties(vH.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}}});vH.fromWorldTerrain=function(e){return new vH(sC(e))};function cyt(e,t){e.numberOfListeners>0?e.rais
${e}`}function dyt(e){return function(t){return mt(t,{czm_pickColor:function(){return e._pickId.color}})}}function hyt(){return"czm_pickColor"}VC.prototype.makeStyleDirty=function(){this._styleDirty=!0};VC.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};var myt=new ee;function dK(e){let t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function UC(e,t){return e._intervals.indexOf(t.start)}function pyt(e,t){let n=e._intervals,i=e._clock,r=dK(e);if(r===0)return;let o=e._getAverageLoadTime(),s=ee.addSeconds(i.currentTime,o*r,myt),a=n.indexOf(s),c=UC(e,t);return a===c&&(r>=0?++a:--a),n.get(a)}function _yt(e){let t=e._intervals,i=e._clock.currentTime,r=t.indexOf(i);return t.get(r)}function gyt(e,t,n){let i=dK(e),r=UC(e,t),o=UC(e,n);return i>=0?r>=o:r<=o}function NAe(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 yyt(e,t,n){let i=UC(e,t),r=e._frames,o=r[i];if(!u(o)){let s=t.data.transform,a=u(s)?N.fromArray(s):void 0,c=t.data.uri;o={pointCloud:void 0,transform:a,timestamp:Ai(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber,uri:c},r[i]=o,De.fetchArrayBuffer({url:c}).then(function(l){o.pointCloud=new XN({arrayBuffer:l,cull:!0,fragmentShaderLoaded:fyt,uniformMapLoaded:dyt(e),pickIdLoaded:hyt})}).catch(NAe(e,c))}return o}function Ayt(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 xyt(e,t,n,i){t.touchedFrameNumber<i.frameNumber-1&&(t.sequential=!1);let r=t.pointCloud;if(u(r)&&!t.ready){let o=i.commandList,s=o.length;if(FAe(e,t,n,i),r.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=r.geometryByteLength,o.length=s,t.sequential)){let a=(Ai()-t.timestamp)/1e3;Ayt(e,a)}}t.touchedFrameNumber=i.frameNumber}var Cyt=new N;function Tyt(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 Eyt(e){let t=e.shading;return u(t)&&u(t.maximumAttenuation)?t.maximumAttenuation:10}var byt=new Jh;function FAe(e,t,n,i){let r=y(e.shading,byt),o=t.pointCloud,s=y(t.transform,N.IDENTITY);o.modelMatrix=N.multiplyTransformation(e.modelMatrix,s,Cyt),o.style=e.style,o.time=n.timeSinceLoad,o.shadows=e.shadows,o.clippingPlanes=e._clippingPlanes,o.isClipped=n.isClipped,o.attenuation=r.attenuation,o.backFaceCulling=r.backFaceCulling,o.normalShading=r.normalShading,o.geometricError=Tyt(e,o),o.geometricErrorScale=r.geometricErrorScale,o.maximumAttenuation=Eyt(e);try{o.update(i)}catch(a){NAe(e,t.uri)(a)}t.touchedFrameNumber=i.frameNumber}function fK(e,t,n,i){let r=yyt(e,t,i);xyt(e,r,n,i)}function Syt(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function UAe(e,t){let n=e._frames,i=n.length;for(let r=0;r<i;++r){let o=n[r];if(u(o)&&(!u(t)||t(o))){let s=o.pointCloud;o.ready&&(e._totalMemoryUsageInBytes-=s.geometryByteLength),u(s)&&s.destroy(),o===e._lastRenderedFrame&&(e._lastRenderedFrame=void 0),n[r]=void 0}}}function vyt(e,t){let n=UC(e,t),i=e._frames[n];if(u(i)&&i.ready)return i}function LAe(e,t,n,i,r){return u(n)?n.ready?!0:(fK(e,t,i,r),n.ready):!1}function wyt(e,t,n,i,r){let o,s,a,c=e._intervals,l=e._frames,f=UC(e,n),d=UC(e,t);if(f>=d){for(o=f;o>=d;--o)if(s=c.get(o),a=l[o],LAe(e,s,a,i,r))return s}else for(o=f;o<=d;++o)if(s=c.get(o),a=l[o],LAe(e,s,a,i,r))return s;return t}function Dyt(e,t,n){let i=e._frames,r=i.length;for(let o=0;o<r;++o){let s=i[o];u(s)&&u(s.pointCloud)&&(s.pointCloud.clippingPlanesDirty=t,s.pointCloud.styleDirty=n)}}var JS={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 wH(e,t){this.show=!0,u(e)||(e=new Xe),this.rectangle=Xe.clone(e),u(t)||(t=qi.fromType(qi.ColorType,{color:new z(1,1,1,1)})),this.material=t,this._material=void 0,this._overlayCommand=void 0,this._rs=void 0}wH.prototype.update=function(e){if(!this.show)return;let t=this._rs;if((!u(t)||!Xe.equals(t.viewport,this.rectangle))&&(this._rs=Ve.fromCache({blending:ln.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 r=new He({sources:[this._material.shaderSource,jF]});this._overlayCommand=i.createViewportQuadCommand(r,{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)}};wH.prototype.isDestroyed=function(){return!1};wH.prototype.destroy=function(){return u(this._overlayCommand)&&(this._overlayCommand.shaderProgram=this._overlayCommand.shaderProgram&&this._overlayCommand.shaderProgram.destroy()),ue(this)};var hK=wH;var qF=`// 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 YF=`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 XF=`/* 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 KF=`// 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 JF=`// 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 ZF=`// 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 QF=`// 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 $F=`// 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 kC=`// 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 e2=`/* 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 t2=`/* 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 n2=`/* 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 i2=`// 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 r2=`// 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 Iyt(e){let t=new GA;this.shaderBuilder=t;let n=e._customShader,i=mt(e._uniformMap,n.uniformMap);e._uniformMap=i;let r=n.uniforms;for(let p in r)if(r.hasOwnProperty(p)){let g=r[p];t.addUniform(g.type,p,Te.FRAGMENT)}t.addUniform("sampler2D","u_megatextureTextures[METADATA_COUNT]",Te.FRAGMENT),this.uniformMap=i;let o=e._clippingPlanes,s=u(o)&&o.enabled?o.length:0;this.clippingPlanes=o,this.clippingPlanesLength=s,t.addVertexLines([YF]),t.addFragmentLines([n.fragmentShaderText,"#line 0",i2,XF,r2]),s>0&&(t.addDefine("CLIPPING_PLANES",void 0,Te.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",s,Te.FRAGMENT),o.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,Te.FRAGMENT),t.addFragmentLines([JF])),e._depthTest&&(t.addDefine("DEPTH_TEST",void 0,Te.FRAGMENT),t.addFragmentLines([KF]));let a=e._provider.shape;a==="BOX"?(t.addDefine("SHAPE_BOX",void 0,Te.FRAGMENT),t.addFragmentLines([e2,ZF,kC])):a==="CYLINDER"?t.addFragmentLines([QF,kC,t2]):a==="ELLIPSOID"&&t.addFragmentLines([$F,kC,n2]),t.addFragmentLines([qF]);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,Te.FRAGMENT))}let f=c.shaderMaximumIntersectionsLength;s>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",f,Te.FRAGMENT),s===1?f+=1:o.unionClippingRegions?f+=2:f+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",f,Te.FRAGMENT),f+=1),t.addDefine("INTERSECTION_COUNT",f,Te.FRAGMENT),(!h.equals(e.paddingBefore,h.ZERO)||!h.equals(e.paddingAfter,h.ZERO))&&t.addDefine("PADDING",void 0,Te.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,Te.FRAGMENT),e._jitter&&t.addDefine("JITTER",void 0,Te.FRAGMENT),e._nearestSampling&&t.addDefine("NEAREST_SAMPLING",void 0,Te.FRAGMENT);let d=e._traversal;t.addDefine("SAMPLE_COUNT",`${d._sampleCount}`,Te.FRAGMENT)}var o2=Iyt;function Pyt(e,t){let{shaderBuilder:n}=e,{names:i,types:r,componentTypes:o,minimumValues:s,maximumValues:a}=t._provider,c=r.length,l=u(s)&&u(a);n.addDefine("METADATA_COUNT",c,Te.FRAGMENT),l&&n.addDefine("STATISTICS",void 0,Te.FRAGMENT);for(let O=0;O<c;O++){let B=i[O],L=r[O],_=`PropertyStatistics_${B}`,b=`PropertyStatistics_${B}`;n.addStruct(_,b,Te.FRAGMENT);let w=DH(L);n.addStructField(_,w,"min"),n.addStructField(_,w,"max")}let f="Statistics",d="Statistics",p="statistics";n.addStruct(f,d,Te.FRAGMENT);for(let O=0;O<c;O++){let B=i[O],L=`PropertyStatistics_${B}`,_=B;n.addStructField(f,L,_)}let g="Metadata",m="Metadata",A="metadata";n.addStruct(g,m,Te.FRAGMENT),n.addStructField(g,d,p);for(let O=0;O<c;O++){let B=i[O],L=r[O],_=DH(L);n.addStructField(g,_,B)}for(let O=0;O<c;O++){let B=i[O],L=r[O],_=Myt(L),b=`VoxelProperty_${B}`,w=`VoxelProperty_${B}`;n.addStruct(b,w,Te.FRAGMENT),n.addStructField(b,_,"partialDerivativeLocal"),n.addStructField(b,_,"partialDerivativeWorld"),n.addStructField(b,_,"partialDerivativeView"),n.addStructField(b,_,"partialDerivativeValid")}let x="Voxel",C="Voxel",E="voxel";n.addStruct(x,C,Te.FRAGMENT);for(let O=0;O<c;O++){let B=i[O],L=`VoxelProperty_${B}`;n.addStructField(x,L,B)}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 T="FragmentInput",S="FragmentInput";n.addStruct(T,S,Te.FRAGMENT),n.addStructField(T,m,A),n.addStructField(T,C,E);let v="Properties",D="Properties",M="properties";n.addStruct(v,D,Te.FRAGMENT);for(let O=0;O<c;O++){let B=i[O],L=r[O],_=DH(L);n.addStructField(v,_,B)}{let O="clearProperties";n.addFunction(O,`${D} clearProperties()`,Te.FRAGMENT),n.addFunctionLines(O,[`${D} ${M};`]);for(let B=0;B<c;B++){let L=i[B],_=r[B],b=o[B],w=DH(_,b);n.addFunctionLines(O,[`${M}.${L} = ${w}(0.0);`])}n.addFunctionLines(O,[`return ${M};`])}{let O="sumProperties";n.addFunction(O,`${D} sumProperties(${D} propertiesA, ${D} propertiesB)`,Te.FRAGMENT),n.addFunctionLines(O,[`${D} ${M};`]);for(let B=0;B<c;B++)
{
material.diffuse = vec3(1.0);
material.alpha = 1.0;
}`});function YAe(){this.ready=!0,this.shape=Xi.BOX,this.dimensions=new h(1,1,1),this.names=["data"],this.types=[Ht.SCALAR],this.componentTypes=[tn.FLOAT32],this.maximumTileCount=1}YAe.prototype.requestData=function(e){if(!((u(e)?y(e.tileLevel,0):0)>=1))return Promise.resolve([new Float32Array(1)])};Gm.DefaultProvider=new YAe;var tv=Gm;function _K(){fe.throwInstantiationError()}Object.defineProperties(_K.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}});_K.prototype.requestData=fe.throwInstantiationError;var gK=_K;function GC(){fe.throwInstantiationError()}Object.defineProperties(GC.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}});GC.prototype.update=fe.throwInstantiationError;GC.prototype.computeOrientedBoundingBoxForTile=fe.throwInstantiationError;GC.prototype.computeApproximateStepSize=fe.throwInstantiationError;GC.DefaultMinBounds=fe.throwInstantiationError;GC.DefaultMaxBounds=fe.throwInstantiationError;var yK=GC;async function AK(e,t){let n=t.terrainProvider,i=t.mapProjection,r=i.ellipsoid,o,s=t.camera.getRectangleCameraCoordinates(e);if(t.mode===ne.SCENE3D?o=r.cartesianToCartographic(s):o=i.unproject(s),!u(n))return o;await n._readyPromise;let a=n.availability;if(!u(a)||t.mode===ne.SCENE2D)return o;let c=[le.center(e),le.southeast(e),le.southwest(e),le.northeast(e),le.northwest(e)],l=await AK._sampleTerrainMostDetailed(n,c),f=!1,d=l.reduce(function(g,m){return u(m.height)?(f=!0,Math.max(m.height,g)):g},-Number.MAX_VALUE),p=o;return f&&(p.height+=d),p}AK._sampleTerrainMostDetailed=v_;var WC=AK;var b0t=new z,S0t=new z,v0t=new z,w0t=new z,XAe=new oe,f2=new Uint8Array(4);function KAe(e,t,n,i){let r=t.height===n.height?0:(e-t.height)/(n.height-t.height);return z.lerp(t.color,n.color,r,i)}function OH(e,t){return{height:e,color:z.clone(t)}}function JAe(e){return e=e.filter(function(t,n,i){let r=n>0,o=n<i.length-1,s=r?t.height===i[n-1].height:!0,a=o?t.height===i[n+1].height:!0;return!s||!a}),e=e.filter(function(t,n,i){let r=n>0,o=n<i.length-1,s=r?z.equals(t.color,i[n-1].color):!1,a=o?z.equals(t.color,i[n+1].color):!1;return!s||!a}),e=e.filter(function(t,n,i){let r=n>0,o=r?z.equals(t.color,i[n-1].color):!1,s=r?t.height===i[n-1].height:!0;return!o||!s}),e}function D0t(e){let t,n,i=[],r=e.length;for(t=0;t<r;t++){let o=e[t],s=o.entries,a=s.length,c=[];for(n=0;n<a;n++){let g=s[n],m=P.clamp(g.height,Jl._minimumHeight,Jl._maximumHeight),A=z.clone(g.color,b0t);A.red*=A.alpha,A.green*=A.alpha,A.blue*=A.alpha,c.push(OH(m,A))}let l=!0,f=!0;for(n=0;n<a-1;n++){let g=c[n+0],m=c[n+1];l=l&&g.height<=m.height,f=f&&g.height>=m.height}f?c=c.reverse():l||N_(c,function(g,m){return P.sign(g.height-m.height)});let d=y(o.extendDownwards,!1),p=y(o.extendUpwards,!1);c.length===1&&!d&&!p&&(d=!0,p=!0),d&&c.splice(0,0,OH(Jl._minimumHeight,c[0].color)),p&&c.splice(c.length,0,OH(Jl._maximumHeight,c[c.length-1].color)),c=JAe(c),i.push(c)}return i}function I0t(e){let t=D0t(e),n=[],i=[],r;function o(l,f){n.push(OH(l,f))}function s(l,f,d){let p=z.multiplyByScalar(d,1-f.alpha,
${t}
${m}`);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(m)),A.className="cesium-widget-errorPanel-message-details",o.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",o.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(r)},d.appendChild(p),i.appendChild(r)};jC.prototype.isDestroyed=function(){return!1};jC.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)};jC.prototype.resize=function(){let e=this._canvas;!this._forceResize&&this._canvasClientWidth===e.clientWidth&&this._canvasClientHeight===e.clientHeight&&this._lastDevicePixelRatio===window.devicePixelRatio||(this._forceResize=!1,QAe(this),$Ae(this),this._scene.requestRender())};jC.prototype.render=function(){if(this._canRender){this._scene.initializeFrame();let e=this._clock.tick();this._scene.render(e)}else this._clock.tick()};var d2=jC;function L0t(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=De.createIfNeeded(t)),this.resource=t;let i=y(e.repeat,!0)?Sn.REPEAT:Sn.CLAMP_TO_EDGE;this.sampler=new un({wrapS:i,wrapT:i,minificationFilter:e.minificationFilter,magnificationFilter:e.magnificationFilter,maximumAnisotropy:e.maximumAnisotropy})}var SK=L0t;var N0t={FLOAT:"float",VEC2:"vec2",VEC3:"vec3",VEC4:"vec4",MAT2:"mat2",MAT3:"mat2",MAT4:"mat4"},vK=Object.freeze(N0t);var wK=`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 F0t(e,t,n){let i;try{return i=e(t,n),i}catch(r){return Promise.reject(r)}}function U0t(e){let t;return function(n){let i=n.data,r=[],o={id:i.id,result:void 0,error:void 0};return Promise.resolve(F0t(e,i.parameters,r)).then(function(s){o.result=s}).catch(function(s){s instanceof Error?o.error={name:s.name,message:s.message,stack:s.stack}:o.error=s}).finally(function(){u(t)||(t=y(self.webkitPostMessage,self.postMessage)),i.canTransferArrayBuffer||(r.length=0);try{t(o,r)}catch(s){o.result=void 0,o.error=`postMessage failed with error: ${vm(s)}
with responseMessage: ${JSON.stringify(o)}`,t(o)}})}}var DK=U0t;globalThis.CESIUM_VERSION="1.104";var h2;typeof ko<"u"&&(h2=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,r=t.jQuery,o=t.JSON;r||typeof jQuery>"u"||(r=jQuery),function(s){s(t.ko={})}(function(s,a){function c(_,b){return _===null||typeof _ in A?_===b:!1}function l(_,b){var w;return function(){w||(w=m.a.setTimeout(function(){w=e,_()},b))}}function f(_,b){var w;return function(){clearTimeout(w),w=m.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 w=this.qd,I=w[S];I.ra||(this.Qb&&this.mb[b]?(w.uc(b,_,this.mb[b]),this.mb[b]=null,--this.Qb):I.I[b]||w.uc(b,_,I.J?{da:_}:w.$c(_)),_.Ja&&_.gd())}var m=typeof s<"u"?s:{};m.b=function(_,b){for(var w=_.split("."),I=m,R=0;R<w.length-1;R++)I=I[w[R]];I[w[w.length-1]]=b},m.L=function(_,b,w){_[b]=w},m.version="3.5.1",m.b("version",m.version),m.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},m.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 w(W,K){return W.__proto__=K,W}function I(W,K,J,_e){var xe=W[K].match(j)||[];m.a.D(J.match(j),function(se){m.a.Na(xe,se,_e)}),W[K]=xe.join(" ")}var R=Object.prototype.hasOwnProperty,F={__proto__:[]}instanceof Array,k=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,_e=K.length;J<_e;J++)G[K[J]]=W});var U={propertychange:!0},Y=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}(),j=/\S+/g,Q;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],D:function(W,K,J){for(var _e=0,xe=W.length;_e<xe;_e++)K.call(J,W[_e],_e,W)},A:typeof Array.prototype.indexOf=="function"?function(W,K){return Array.prototype.indexOf.call(W,K)}:function(W,K){for(var J=0,_e=W.length;J<_e;J++)if(W[J]===K)return J;return-1},Lb:function(W,K,J){for(var _e=0,xe=W.length;_e<xe;_e++)if(K.call(J,W[_e],_e,W))return W[_e];return e},Pa:function(W,K){var J=m.a.A(W,K);0<J?W.splice(J,1):J===0&&W.shift()},wc:function(W){var K=[];return W&&m.a.D(W,function(J){0>m.a.A(K,J)&&K.push(J)}),K},Mb:function(W,K,J){var _e=[];if(W)for(var xe=0,se=W.length;xe<se;xe++)_e.push(K.call(J,W[xe],xe));return _e},jb:function(W,K,J){var _e=[];if(W)for(var xe=0,se=W.length;xe<se;xe++)K.call(J,W[xe],xe)&&_e.push(W[xe]);return _e},Nb:function(W,K){if(K instanceof Array)W.push.apply(W,K);else for(var J=0,_e=K.length;J<_e;J++)W.push(K[J]);return W},Na:function(W,K,J){var _e=m.a.A(m.a.bc(W),K);0>_e?J&&W.push(K):J||W.splice(_e,1)},Ba:F,extend:b,setPrototypeOf:w,Ab:F?w:b,P:_,Ga:function(W,K,J){if(!W)return W;var _e={},xe;for(xe in W)R.call(W,xe)&&(_e[xe]=K.call(J,W[xe],xe,W));return _e},Tb:function(W){for(;W.firstChild;)m.removeNode(W.firstChild)},Yb:function(W){W=m.a.la(W);for(var K=(W[0]&&W[0].ownerDocument||n).createElement("div"),J=0,_e=W.length;J<_e;J++)K.appendChild(m.oa(W[J]));return K},Ca:function(W,K){for(var J=0,_e=W.length,xe=[];J<_e;J++){var se=W[J].cloneNode(!0);xe.push(K?m.oa(se):se)}return xe},va:function(W,K){if(m.a.Tb(W),K)for(var J=0,_e=K.length;J<_e;J++)W.appendChild(K[J])},Xc:function(W,K){var J=W.nodeType?[W]:W;if(0<J.length){for(var _e=J[0],xe=_e.parentNode,se=0,Ae=K.length;se<Ae;se++)xe.insertBefore(K[se],_e);for(se=0,Ae=J.length;se<Ae;se++)m.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],_e=W[W.length-1];for(W.length=0;J!==_e;)W.push(J),J=J.nextSibling;W.push(_e)}}return W},Zc:function(W,K){7>Y?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),Y,j=[],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(Y&&j.length?{key:Y,value:j.join("")}:{unknown:Y||j.join("")}),Y=Q=0,j=[];continue}}else if(J===58){if(!Q&&!Y&&j.length===1){Y=j.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:Y||j.length||J!==34&&J!==39||(K=K.slice(1,-1))}j.push(K)}if(0<Q)throw Error("Unbalanced parentheses, braces, or brackets")}return G}var b=["true","false","null","undefined"],w=/^(?:[$_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},k={};return{Ra:[],wa:k,ac:_,vb:function(V,G){function U(J,_e){var xe;if(!W){var se=m.getBindingHandler(J);if(se&&se.preprocess&&!(_e=se.preprocess(_e,J,U)))return;(se=k[J])&&(xe=_e,0<=m.a.A(b,xe)?xe=!1:(se=xe.match(w),xe=se===null?!1:se[1]?"Object("+se[1]+")"+se[2]:xe),se=xe),se&&j.push("'"+(typeof k[J]=="string"?k[J]:J)+"':function(_z){"+xe+"=_z}")}Q&&(_e="function(){return "+_e+" }"),Y.push("'"+J+"':"+_e)}G=G||{};var Y=[],j=[],Q=G.valueAccessors,W=G.bindingParams,K=typeof V=="string"?_(V):V;return m.a.D(K,function(J){U(J.key||J.unknown,J.value)}),j.length&&U("_ko_property_writers","{"+j.join(",")+" }"),Y.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,Y,j){V&&m.O(V)?!m.Za(V)||j&&V.v()===Y||V(Y):(V=G.get("_ko_property_writers"))&&V[U]&&V[U](Y)}}}(),m.b("expressionRewriting",m.m),m.b("expressionRewriting.bindingRewriteValidators",m.m.Ra),m.b("expressionRewriting.parseObjectLiteral",m.m.ac),m.b("expressionRewriting.preProcessBindings",m.m.vb),m.b("expressionRewriting._twoWayBindings",m.m.wa),m.b("jsonExpressionRewriting",m.m),m.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",m.m.vb),function(){function _(U){return U.nodeType==8&&F.test(R?U.text:U.nodeValue)}function b(U){return U.nodeType==8&&k.test(R?U.text:U.nodeValue)}function w(U,Y){for(var j=U,Q=1,W=[];j=j.nextSibling;){if(b(j)&&(m.a.g.set(j,G,!0),Q--,Q===0))return W;W.push(j),_(j)&&Q++}if(!Y)throw Error("Cannot find closing comment tag to match: "+U.nodeValue);return null}function I(U,Y){var j=w(U,Y);return j?0<j.length?j[j.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*$/,k=R?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,V={ul:!0,ol:!0},G="__ko_matchedEndComment__";m.h={ea:{},childNodes:function(U){return _(U)?w(U):U.childNodes},Ea:function(U){if(_(U)){U=m.h.childNodes(U);for(var Y=0,j=U.length;Y<j;Y++)m.removeNode(U[Y])}else m.a.Tb(U)},va:function(U,Y){if(_(U)){m.h.Ea(U);for(var j=U.nextSibling,Q=0,W=Y.length;Q<W;Q++)j.parentNode.insertBefore(Y[Q],j)}else m.a.va(U,Y)},Vc:function(U,Y){var j;_(U)?(j=U.nextSibling,U=U.parentNode):j=U.firstChild,j?Y!==j&&U.insertBefore(Y,j):U.appendChild(Y)},Wb:function(U,Y,j){j?(j=j.nextSibling,_(U)&&(U=U.parentNode),j?Y!==j&&U.insertBefore(Y,j):U.appendChild(Y)):m.h.Vc(U,Y)},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 Y=U.nextSibling;if(b(Y)&&!m.a.g.get(Y,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[m.a.R(U)]){var Y=U.firstChild;if(Y)do if(Y.nodeType===1){var j;j=Y.firstChild;var Q=null;if(j)do if(Q)Q.push(j);else if(_(j)){var W=I(j,!0);W?j=W:Q=[j]}else b(j)&&(Q=[j]);while(j=j.nextSibling);if(j=Q)for(Q=Y.nextSibling,W=0;W<j.length;W++)Q?U.insertBefore(j[W],Q):U.appendChild(j[W])}while(Y=Y.nextSibling)}}}}(),m.b("virtualElements",m.h),m.b("virtualElements.allowedBindings",m.h.ea),m.b("virtualElements.emptyNode",m.h.Ea),m.b("virtualElements.insertAfter",m.h.Wb),m.b("virtualElements.prepend",m.h.Vc),m.b("virtualElements.setDomNodeChildren",m.h.va),function(){m.ga=function(){this.nd={}},m.a.extend(m.ga.prototype,{nodeHasBindings:function(_){switch(_.nodeType){case 1:return _.getAttribute("data-bind")!=null||m.j.getComponentNameForNode(_);case 8:return m.h.Cd(_);default:return!1}},getBindings:function(_,b){var w=this.getBindingsString(_,b),w=w?this.parseBindingsString(w,b,_):null;return m.j.tc(w,_,b,!1)},getBindingAccessors:function(_,b){var w=this.getBindingsString(_,b),w=w?this.parseBindingsString(w,b,_,{val
Bindings value: `+_+`
Message: `+U.message,U}}}),m.ga.instance=new m.ga}(),m.b("bindingProvider",m.ga),function(){function _(se){var Ae=(se=m.a.g.get(se,xe))&&se.N;Ae&&(se.N=null,Ae.Tc())}function b(se,Ae,he){this.node=se,this.yc=Ae,this.kb=[],this.H=!1,Ae.N||m.a.K.za(se,_),he&&he.N&&(he.N.kb.push(se),this.Kb=he)}function w(se){return function(){return se}}function I(se){return se()}function R(se){return m.a.Ga(m.u.G(se),function(Ae,he){return function(){return se()[he]}})}function F(se,Ae,he){return typeof se=="function"?R(se.bind(null,Ae,he)):m.a.Ga(se,w)}function k(se,Ae){return R(this.getBindings.bind(this,se,Ae))}function V(se,Ae){var he=m.h.firstChild(Ae);if(he){var Se,Ie=m.ga.instance,Ne=Ie.preprocessNode;if(Ne){for(;Se=he;)he=m.h.nextSibling(Se),Ne.call(Ie,Se);he=m.h.firstChild(Ae)}for(;Se=he;)he=m.h.nextSibling(Se),G(se,Se)}m.i.ma(Ae,m.i.H)}function G(se,Ae){var he=se,Se=Ae.nodeType===1;Se&&m.h.Sc(Ae),(Se||m.ga.instance.nodeHasBindings(Ae))&&(he=Y(Ae,null,se).bindingContextForDescendants),he&&!J[m.a.R(Ae)]&&V(he,Ae)}function U(se){var Ae=[],he={},Se=[];return m.a.P(se,function Ie(Ne){if(!he[Ne]){var Ye=m.getBindingHandler(Ne);Ye&&(Ye.after&&(Se.push(Ne),m.a.D(Ye.after,function(ht){if(se[ht]){if(m.a.A(Se,ht)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+Se.join(", "));Ie(ht)}}),Se.length--),Ae.push({key:Ne,Mc:Ye})),he[Ne]=!0}}),Ae}function Y(se,Ae,he){var Se=m.a.g.Ub(se,xe,{}),Ie=Se.hd;if(!Ae){if(Ie)throw Error("You cannot apply bindings multiple times to the same element.");Se.hd=!0}Ie||(Se.context=he),Se.Zb||(Se.Zb={});var Ne;if(Ae&&typeof Ae!="function")Ne=Ae;else{var Ye=m.ga.instance,ht=Ye.getBindingAccessors||k,Ft=m.$(function(){return(Ne=Ae?Ae(he,se):ht.call(Ye,se,he))&&(he[Q]&&he[Q](),he[K]&&he[K]()),Ne},null,{l:se});Ne&&Ft.ja()||(Ft=null)}var sn=he,ut;if(Ne){var An=function(){return m.a.Ga(Ft?Ft():Ne,I)},Jn=Ft?function(Gt){return function(){return I(Ft()[Gt])}}:function(Gt){return Ne[Gt]};An.get=function(Gt){return Ne[Gt]&&I(Jn(Gt))},An.has=function(Gt){return Gt in Ne},m.i.H in Ne&&m.i.subscribe(se,m.i.H,function(){var Gt=(0,Ne[m.i.H])();if(Gt){var Qe=m.h.childNodes(se);Qe.length&&Gt(Qe,m.Ec(Qe[0]))}}),m.i.pa in Ne&&(sn=m.i.Cb(se,he),m.i.subscribe(se,m.i.pa,function(){var Gt=(0,Ne[m.i.pa])();Gt&&m.h.firstChild(se)&&Gt(se)})),Se=U(Ne),m.a.D(Se,function(Gt){var Qe=Gt.Mc.init,pe=Gt.Mc.update,Ee=Gt.key;if(se.nodeType===8&&!m.h.ea[Ee])throw Error("The binding '"+Ee+"' cannot be used with virtual elements");try{typeof Qe=="function"&&m.u.G(function(){var ke=Qe(se,Jn(Ee),An,sn.$data,sn);if(ke&&ke.controlsDescendantBindings){if(ut!==e)throw Error("Multiple bindings ("+ut+" and "+Ee+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");ut=Ee}}),typeof pe=="function"&&m.$(function(){pe(se,Jn(Ee),An,sn.$data,sn)},null,{l:se})}catch(ke){throw ke.message='Unable to process binding "'+Ee+": "+Ne[Ee]+`"
Message: `+ke.message,ke}})}return Se=ut===e,{shouldBindDescendants:Se,bindingContextForDescendants:Se&&sn}}function j(se,Ae){return se&&se instanceof m.fa?se:new m.fa(se,e,e,Ae)}var Q=m.a.Da("_subscribable"),W=m.a.Da("_ancestorBindingInfo"),K=m.a.Da("_dataDependency");m.c={};var J={script:!0,textarea:!0,template:!0};m.getBindingHandler=function(se){return m.c[se]};var _e={};m.fa=function(se,Ae,he,Se,Ie){function Ne(){var Jn=sn?Ft():Ft,Gt=m.a.f(Jn);return Ae?(m.a.extend(Ye,Ae),W in Ae&&(Ye[W]=Ae[W])):(Ye.$parents=[],Ye.$root=Gt,Ye.ko=m),Ye[Q]=ut,ht?Gt=Ye.$data:(Ye.$rawData=Jn,Ye.$data=Gt),he&&(Ye[he]=Gt),Se&&Se(Ye,Ae,Gt),Ae&&Ae[Q]&&!m.S.o().Vb(Ae[Q])&&Ae[Q](),An&&(Ye[K]=An),Ye.$data}var Ye=this,ht=se===_e,Ft=ht?e:se,sn=typeof Ft=="function"&&!m.O(Ft),ut,An=Ie&&Ie.dataDependency;Ie&&Ie.exportDependencies?Ne():(ut=m.xb(Ne),ut.v(),ut.ja()?ut.equalityComparer=null:Ye[Q]=e)},m.fa.prototype.createChildContext=function(se,Ae,he,Se){if(!Se&&Ae&&typeof Ae=="object"&&(Se=Ae,Ae=Se.as,he=Se.extend),Ae&&Se&&Se.noChildContext){var Ie=typeof se=="function"&&!m.O(se);return new m.fa(_e,this,null,function(Ne){he&&he(Ne),Ne[Ae]=Ie?se():se},Se)}return new m.fa(se,this,Ae,function(Ne,Ye){Ne.$parentContext=Ye,Ne.$parent=Ye.$data,Ne.$parents=(Ye.$parents||[]).slice(0),Ne.$parents.unshift(Ne.$parent),he&&he(Ne)},Se)},m.fa.prototype.extend=function(se,Ae){return new m.fa(_e,this,null,function(he){m.a.extend(he,typeof se=="function"?se(he):se)},Ae)};var xe=m.a.g.Z();b.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)},b.prototype.sd=function(se){m.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,m.a.K.yb(this.node,_),m.i.ma(this.node,m.i.pa),this.Tc())},m.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(se,Ae,he,Se,Ie){var Ne=m.a.g.Ub(se,xe,{});return Ne.Fa||(Ne.Fa=new m.T),Ie&&Ie.notifyImmediately&&Ne.Zb[Ae]&&m.u.G(he,Se,[se]),Ne.Fa.subscribe(he,Se,Ae)},ma:function(se,Ae){var he=m.a.g.get(se,xe);if(he&&(he.Zb[Ae]=!0,he.Fa&&he.Fa.notifySubscribers(se,Ae),Ae==m.i.H)){if(he.N)he.N.Cc();else if(he.N===e&&he.Fa&&he.Fa.Wa(m.i.pa))throw Error("descendantsComplete event not supported for bindings on this node")}},Cb:function(se,Ae){var he=m.a.g.Ub(se,xe,{});return he.N||(he.N=new b(se,he,Ae[W])),Ae[W]==he?Ae:Ae.extend(function(Se){Se[W]=he})}},m.Td=function(se){return(se=m.a.g.get(se,xe))&&se.context},m.ib=function(se,Ae,he){return se.nodeType===1&&m.h.Sc(se),Y(se,Ae,j(he))},m.ld=function(se,Ae,he){return he=j(he),m.ib(se,F(Ae,he,se),he)},m.Oa=function(se,Ae){Ae.nodeType!==1&&Ae.nodeType!==8||V(j(se),Ae)},m.vc=function(se,Ae,he){if(!r&&t.jQuery&&(r=t.jQuery),2>arguments.length){if(Ae=n.body,!Ae)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!Ae||Ae.nodeType!==1&&Ae.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");G(j(se,he),Ae)},m.Dc=function(se){return!se||se.nodeType!==1&&se.nodeType!==8?e:m.Td(se)},m.Ec=function(se){return(se=m.Dc(se))?se.$data:e},m.b("bindingHandlers",m.c),m.b("bindingEvent",m.i),m.b("bindingEvent.subscribe",m.i.subscribe),m.b("bindingEvent.startPossiblyAsyncContentBinding",m.i.Cb),m.b("applyBindings",m.vc),m.b("applyBindingsToDescendants",m.Oa),m.b("applyBindingAccessorsToNode",m.ib),m.b("applyBindingsToNode",m.ld),m.b("contextFor",m.Dc),m.b("dataFor",m.Ec)}(),function(_){function b(k,V){var G=Object.prototype.hasOwnProperty.call(R,k)?R[k]:_,U;G?G.subscribe(V):(G=R[k]=new m.T,G.subscribe(V),w(k,function(Y,j){var Q=!(!j||!j.synchronous);F[k]={definition:Y,Gd:Q},delete R[k],U||Q?G.notifySubscribers(Y):m.na.zb(function(){G.notifySubscribers(Y)})}),U=!0)}function w(k,V){I("getConfig",[k],function(G){G?I("loadComponent",[k,G],function(U){V(U,G)}):V(null,null)})}function I(k,V,G,U){U||(U=m.j.loaders.slice(0));var Y=U.shift();if(Y){var j=Y[k];if(j){var Q=!1;if(j.apply(Y,V.concat(function(W){Q?G(null):W!==null?G(W):I(k,V,G,U)}))!==_&&(Q=!0,!Y.suppressLoaderExceptions))throw Error("Componen
* @license
* Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5
* Copyright (c) Steve Sanderson
* MIT license
*/var IK="__knockoutObservables",PK="__knockoutSubscribable";function exe(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=txe(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(r){if(!(r===IK||r===PK)&&!(r in i)){var o=e[r],s=o instanceof Array,a=n.isObservable(o)?o:s?n.observableArray(o):n.observable(o);Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get:a,set:n.isWriteableObservable(a)?a:void 0}),i[r]=a,s&&z0t(n,a)}}),e}function txe(e,t){var n=e[IK];return!n&&t&&(n={},Object.defineProperty(e,IK,{value:n})),n}function k0t(e,t,n){var i=this,r={owner:e,deferEvaluation:!0};if(typeof n=="function")r.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".');r.read=n.get,r.write=n.set}return e[t]=i.computed(r),exe.call(i,e,[t]),e}function z0t(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=H0t(e,t,i))})}function H0t(e,t,n){var i=G0t(e,n);return i.subscribe(t)}function G0t(e,t){var n=t[PK];if(!n){n=new e.subscribable,Object.defineProperty(t,PK,{value:n});var i={};W0t(t,n,i),j0t(e,t,n,i)}return n}function W0t(e,t,n){["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){var r=e[i];e[i]=function(){var o=r.apply(this,arguments);return n.pause!==!0&&t.notifySubscribers(this),o}})}function j0t(e,t,n,i){["remove","removeAll","destroy","destroyAll","replace"].forEach(function(r){Object.defineProperty(t,r,{enumerable:!1,value:function(){var o;i.pause=!0;try{o=e.observableArray.fn[r].apply(e.observableArray(t),arguments)}finally{i.pause=!1}return n.notifySubscribers(t),o}})})}function nxe(e,t){if(!e)return null;var n=txe(e,!1);return n&&n[t]||null}function q0t(e,t){var n=nxe(e,t);n&&n.valueHasMutated()}function Y0t(e){e.track=exe,e.getObservable=nxe,e.valueHasMutated=q0t,e.defineProperty=k0t}var m2={attachToKo:Y0t};var ixe="http://www.w3.org/2000/svg",rxe="cesium-svgPath-svg",X0t={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){let i=document.createElementNS(ixe,"svg:svg");i.setAttribute("class",rxe);let r=document.createElementNS(ixe,"path");return i.appendChild(r),e.virtualElements.setDomNodeChildren(t,[i]),e.computed({read:function(){let o=e.unwrap(n());r.setAttribute("d",e.unwrap(o.path));let s=e.unwrap(o.width),a=e.unwrap(o.height);i.setAttribute("width",s),i.setAttribute("height",a),i.setAttribute("viewBox",`0 0 ${s} ${a}`),o.css&&i.setAttribute("class",`${rxe} ${e.unwrap(o.css)}`)},disposeWhenNodeIsRemoved:t}),{controlsDescendantBindings:!0}}},e.virtualElements.allowedBindings.cesiumSvgPath=!0}},p2=X0t;m2.attachToKo(qC);p2.register(qC);var Ce=qC;function _2(e){u(e)||(e=new qd),this._clock=e,this._eventHelper=new Do,this._eventHelper.add(e.onTick,this.synchronize,this),this.systemTime=Ce.observable(ee.now()),this.systemTime.equalityComparer=ee.equals,this.startTime=Ce.observable(e.startTime),this.startTime.equalityComparer=ee.equals,this.startTime.subscribe(function(t){e.startTime=t,this.synchronize()},this),this.stopTime=Ce.observable(e.stopTime),this.stopTime.equalityComparer=ee.equals,this.stopTime.subscribe(function(t){e.stopTime=t,this.synchronize()},this),this.currentTime=Ce.observable(e.currentTime),this.currentTime.equalityComparer=ee.equals,this.currentTime.subscribe(function(t){e.currentTime=t,this.synchronize()},this),this.multiplier=Ce.observable(e.multiplier),this.multiplier.subscribe(function(t){e.multiplier=t,this.synchronize()},this),this.clockStep=Ce.observable(e.clockStep),this.clockStep.subscribe(function(t){e.clockStep=t,this.synchronize()},this),this.clockRange=Ce.observable(e.clockRange),this.clockRange.subscribe(function(t){e.clockRange=t,this.synchronize()},this),this.canAnimate=Ce.observable(e.canAnimate),this.canAnimate.subscribe(function(t){e.
${m}`:u(g)?g:m}),this.buttonImageUrl=void 0,Ce.defineProperty(this,"buttonImageUrl",function(){let d=this.selectedImagery;if(u(d))return d.iconUrl}),this.selectedImagery=void 0;let c=Ce.observable();this._currentImageryLayers=[],Ce.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(d){if(c()===d){this.dropDownVisible=!1;return}let p,g=this._currentImageryLayers,m=g.length,A=this._globe.imageryLayers,x=!1;for(p=0;p<m;p++){let C=A.length;for(let E=0;E<C;E++){let T=A.get(E);if(T===g[p]){A.remove(T),x=!0;break}}}if(u(d)){let C=d.creationCommand();if(Array.isArray(C)){let E=C.length;for(this._currentImageryLayers=[],p=E-1;p>=0;p--){let T=Vs.fromProviderAsync(C[p]);A.add(T,0),this._currentImageryLayers.push(T)}}else{this._currentImageryLayers=[];let E=Vs.fromProviderAsync(C);if(E.name=d.name,x)A.add(E,0);else{let T=A.get(0);u(T)&&A.remove(T),A.add(E,0)}this._currentImageryLayers.push(E)}}c(d),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;let l=Ce.observable();Ce.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,m=this._globe.terrainProviderChanged.addEventListener(()=>{g=!0,m()}),x=new HF(Promise.resolve(p)).readyEvent.addEventListener(C=>{g||(this._globe.depthTestAgainstTerrain=!(C instanceof L_),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(uxe.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});var E2=uxe;function NH(e,t){e=wn(e);let n=new E2(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 r=document.createElement("img");r.setAttribute("draggable","false"),r.className="cesium-baseLayerPicker-selected",r.setAttribute("data-bind","attr: { src: buttonImageUrl }, visible: !!buttonImageUrl"),i.appendChild(r);let o=document.createElement("div");o.className="cesium-baseLayerPicker-dropDown",o.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }'),e.appendChild(o);let s=document.createElement("div");s.className="cesium-baseLayerPicker-sectionTitle",s.setAttribute("data-bind","visible: imageryProviderViewModels.length > 0"),s.innerHTML="Imagery",o.appendChild(s);let a=document.createElement("div");a.className="cesium-baseLayerPicker-section",a.setAttribute("data-bind","foreach: _imageryProviders"),o.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 m=document.createElement("div");m.className="cesium-baseLayerPicker-sectionTitle",m.setAttribute("data-bind","visible: terrainProviderViewModels.length > 0"),m.innerHTML="Terrain",o.appendChild(m);let A=documen
http://www.esri.com`,category:"Other",creationFunction:function(){return Pm.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",{enablePickFeatures:!1})}})),e.push(new As({name:"ESRI World Street Map",iconUrl:$t("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 Pm.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",{enablePickFeatures:!1})}})),e.push(new As({name:"ESRI National Geographic",iconUrl:$t("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 Pm.fromUrl("https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/",{enablePickFeatures:!1})}})),e.push(new As({name:"Open\xADStreet\xADMap",iconUrl:$t("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 EC({url:"https://a.tile.openstreetmap.org/"})}})),e.push(new As({name:"Stamen Watercolor",iconUrl:$t("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 EC({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 As({name:"Stamen Toner",iconUrl:$t("Widgets/Images/ImageryProviders/stamenToner.png"),tooltip:`A high contrast black and white map.
http://maps.stamen.com`,category:"Other",creationFunction:function(){return new EC({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 As({name:"Sentinel-2",iconUrl:$t("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 qf.fromAssetId(3954)}})),e.push(new As({name:"Blue Marble",iconUrl:$t("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return qf.fromAssetId(3845)}})),e.push(new As({name:"Earth at night",iconUrl:$t("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 qf.fromAssetId(3812)}})),e.push(new As({name:"Natural Earth\xA0II",iconUrl:$t("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.
http://www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return Lm.fromUrl($t("Assets/Textures/NaturalEarthII"))}})),e}var S2=sAt;function aAt(){let e=[];return e.push(new As({name:"WGS84 Ellipsoid",iconUrl:$t("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new L_}})),e.push(new As({name:"Cesium World Terrain",iconUrl:$t("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 sC({requestWaterMask:!0,requestVertexNormals:!0})}})),e}var v2=aAt;function cAt(e){let t;if(u(e)){t="Command Statistics";let n=e.commandsInFrustums;for(let i in n)if(n.hasOwnProperty(i)){let r=parseInt(i,10),o;if(r===7)o="1, 2 and 3";else{let s=[];for(let a=2;a>=0;a--){let c=Math.pow(2,a);r>=c&&(s.push(a+1),r-=c)}o=s.reverse().join(" and ")}t+=`<br>&nbsp;&nbsp;&nbsp;&nbsp;${n[i]} in frustum ${o}`}t+=`<br>Total: ${e.totalCommands}`}return t}function NK(e,t,n){let i=Math.min(n,t);return i=Math.max(i,e),i}var lAt=new vn,uAt=new h;function w2(e,t){let n=this,i=e.canvas,r=new Nu(i);this._eventHandler=r,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 o=this._scene.globe;o.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="",Ce.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=Ce.getObservable(this,"frustums").subscribe(function(l){n._scene.debugShowFrustums=l,n._scene.requestRender()}),this._frustumPlanesSubscription=Ce.getObservable(this,"frustumPlanes").subscribe(function(l){n._scene.debugShowFrustumPlanes=l,n._scene.requestRender()}),this._performanceSubscription=Ce.getObservable(this,"performance").subscribe(function(l){l?n._performanceDisplay=new q_({container:n._performanceContainer}):n._performanceContainer.innerHTML=""}),this._showPrimitiveBoundingSphere=Cn(function(){return n._primitive.debugShowBoundingVolume=n.primitiveBoundingSphere,n._scene.requestRender(),!0}),this._primitiveBoundingSphereSubscription=Ce.getObservable(this,"primitiveBoundingSphere").subscribe(function(){n._showPrimitiveBoundingSphere()}),this._showPrimitiveReferenceFrame=Cn(function(){if(n.primitiveReferenceFrame){let l=n._primitive.modelMatrix;n._modelMatrixPrimitive=new GL({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=Ce.getObservable(this,"primitiveReferenceFrame").subscribe(fun
<ul class="cesium-cesiumInspector-statistics">
<li><strong>Geometry Memory (MB): </strong>${P2(e.geometryByteLength)}</li>
<li><strong>Texture Memory (MB): </strong>${P2(e.texturesByteLength)}</li>
</ul>
`}var hAt=[{text:"Highlight",value:Cl.HIGHLIGHT},{text:"Replace",value:Cl.REPLACE},{text:"Mix",value:Cl.MIX}],dxe=new z(1,1,0,.4),mAt=new z,UH=new z;function la(e,t){let n=this,i=e.canvas;this._eventHandler=new Nu(i),this._scene=e,this._performanceContainer=t,this._canvas=i,this._performanceDisplay=new q_({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,Ce.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=Ce.observable({}),this.properties=[],Ce.defineProperty(this,"properties",function(){let U=[],Y=n._properties();for(let j in Y)Y.hasOwnProperty(j)&&U.push(j);return U});let r=Ce.observable();Ce.defineProperty(this,"dynamicScreenSpaceError",{get:function(){return r()},set:function(U){r(U),u(n._tileset)&&(n._tileset.dynamicScreenSpaceError=U)}}),this.dynamicScreenSpaceError=!1;let o=Ce.observable();Ce.defineProperty(this,"colorBlendMode",{get:function(){return o()},set:function(U){o(U),u(n._tileset)&&(n._tileset.colorBlendMode=U,n._scene.requestRender())}}),this.colorBlendMode=Cl.HIGHLIGHT;let s=Ce.observable(),a=Ce.observable();Ce.defineProperty(this,"picking",{get:function(){return a()},set:function(U){a(U),U?n._eventHandler.setInputAction(function(Y){let j=e.pick(Y.endPosition);if(j instanceof bs?(n.feature=j,n.tile=j.content.tile):u(j)&&u(j.content)?(n.feature=void 0,n.tile=j.content.tile):(n.feature=void 0,n.tile=void 0),!!u(n._tileset)){if(s&&u(j)&&u(j.content)){let Q;e.pickPositionSupported&&(Q=e.pickPosition(Y.endPosition),u(Q)&&(n._tileset.debugPickPosition=Q)),n._tileset.debugPickedTile=j.content.tile}else n._tileset.debugPickedTile=void 0;n._scene.requestRender()}},yn.MOUSE_MOVE):(n.feature=void 0,n.tile=void 0,n._eventHandler.removeInputAction(yn.MOUSE_MOVE))}}),this.picking=!0;let c=Ce.observable();Ce.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=Ce.observable();Ce.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=Ce.observable();Ce.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=Ce.observable();Ce.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=Ce.observable();Ce.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=Ce.observable();Ce.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,Ce.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),o-=2):(a[l]=a[l].substr(1),o-=1));else for(l=0;l<c;++l)a[l]=` ${a[l]}`,o+=2;let f=a.join(`
`);n.value=n.value.slice(0,i)+f+n.value.slice(r),n.selectionStart=i!==r?i:o,n.selectionEnd=o}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=O2(e,!1),this._pickStatisticsText=O2(e,!0),this._resourceCacheStatisticsText=mxe())};la.prototype.isDestroyed=function(){return!1};la.prototype.destroy=function(){this._eventHandler.destroy(),this._removePostRenderEvent();let e=this;return this._definedProperties.forEach(function(t){Ce.getObservable(e,t).dispose()}),ue(this)};la.getStatistics=O2;var M2=la;function VH(e,t){e=wn(e);let n=document.createElement("div"),i=document.createElement("div");i.setAttribute("data-bind","visible: performance");let r=new M2(t,i);this._viewModel=r,this._container=e,this._element=n;let o=document.createElement("div");o.textContent="3D Tiles Inspector",o.className="cesium-cesiumInspector-button",o.setAttribute("data-bind","click: toggleInspector"),n.appendChild(o),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=Oa.createSection,c=Oa.createCheckbox,l=Oa.createRangeInput,f=Oa.createButton,d=a(s,"Tileset","tilesetVisible","toggleTileset"),p=a(s,"Display","displayVisible","toggleDisplay"),g=a(s,"Update","updateVisible","toggleUpdate"),m=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"),E=document.createElement("div");E.className="field-group";let T=document.createElement("label");T.className="field-label",T.appendChild(document.createTextNode("Properties: "));let S=document.createElement("div");S.setAttribute("data-bind","text: properties"),E.appendChild(T),E.appendChild(S),d.appendChild(E),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 v=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.",v.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 B=document.createElement("div");B.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="",r=/^\s*/,s=t[n].match(r)[0].length;for(let a=n;a<t.length;a++){let c=t[a];c.match(r)[0].length>=s&&(c=c.slice(s)),i+=`${c}
`}return i}function td(e){this._scene=e,this._voxelPrimitive=void 0,this._customShaderCompilationRemoveCallback=void 0,this._definedProperties=[],this._getPrimitiveFunctions=[],this._modelMatrixReady=!1;let t=this;function n(r){let{name:o,initialValue:s}=r;t._definedProperties.push(o);let a=r.setPrimitiveFunction;a===!0&&(a=function(f){t._voxelPrimitive[o]=f});let c=r.getPrimitiveFunction;c===!0&&(c=function(){t[o]=t._voxelPrimitive[o]}),u(c)&&t._getPrimitiveFunctions.push(c);let l=Ce.observable();return Ce.defineProperty(t,o,{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[o]=s,l}function i(r,o){return function(s){let a=t._voxelPrimitive[r].clone();a[o]=s,t._voxelPrimitive[r]=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 r=t._voxelPrimitive.customShader.fragmentShaderText;t.shaderString=Mxe(r)}}),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 r=t._voxelPrimitive.shape;t.shapeIsBox=r===Xi.BOX}}),n({name:"shapeIsEllipsoid",getPrimitiveFunction:function(){let r=t._voxelPrimitive.shape;t.shapeIsEllipsoid=r===Xi.ELLIPSOID}}),n({name:"shapeIsCylinder",getPrimitiveFunction:function(){let r=t._voxelPrimitive.shape;t.shapeIsCylinder=r===Xi.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),o-=2):(a[l]=a[l].substr(1),o-=1));else for(l=0;l<c;++l)a[l]=` ${a[l]}`,o+=2;let f=a.join(`
`);n.value=n.value.slice(0,i)+f+n.value.slice(r),n.selectionStart=i!==r?i:o,n.selectionEnd=o}else t.ctrlKey&&(t.keyCode===10||t.keyCode===13)&&this.compileShader();return!0};td.prototype.isDestroyed=function(){return!1};td.prototype.destroy=function(){let e=this;return this._definedProperties.forEach(function(t){Ce.getObservable(e,t).dispose()}),ue(this)};var o3=td;function nG(e,t){e=wn(e);let n=document.createElement("div"),i=new o3(t);this._viewModel=i,this._container=e,this._element=n;let r=document.createElement("div");r.textContent="Voxel Inspector",r.className="cesium-cesiumInspector-button",r.setAttribute("data-bind","click: toggleInspector"),n.appendChild(r),n.className="cesium-cesiumInspector cesium-VoxelInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let o=document.createElement("div");o.className="cesium-cesiumInspector-dropDown",n.appendChild(o);let s=Oa.createSection,a=Oa.createCheckbox,c=Oa.createRangeInput,l=Oa.createButton,f=s(o,"Display","displayVisible","toggleDisplay"),d=s(o,"Transform","transformVisible","toggleTransform"),p=s(o,"Bounds","boundsVisible","toggleBounds"),g=s(o,"Clipping","clippingVisible","toggleClipping"),m=s(o,"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 E=Xi.getMinBounds(Xi.BOX),T=Xi.getMaxBounds(Xi.BOX),S=h.fromElements(Xi.getMinBounds(Xi.ELLIPSOID).x,Xi.getMinBounds(Xi.ELLIPSOID).y,-re.WGS84.maximumRadius,new h),v=h.fromElements(Xi.getMaxBounds(Xi.ELLIPSOID).x,Xi.getMaxBounds(Xi.ELLIPSOID).y,1e7,new h),D=Xi.getMinBounds(Xi.CYLINDER),M=Xi.getMaxBounds(Xi.CYLINDER);sv("Max X","Min X","Max Y","Min Y","Max Z","Min Z","boundsBoxMaxX","boundsBoxMinX","boundsBoxMaxY","boundsBoxMinY","boundsBoxMaxZ","boundsBoxMinZ",E,T,"shapeIsBox",p),sv("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","boundsEllipsoidMaxLongitude","boundsEllipsoidMinLongitude","boundsEllipsoidMaxLatitude","boundsEllipsoidMinLatitude","boundsEllipsoidMaxHeight","boundsEllipsoidMinHeight",S,v,"shapeIsEllipsoid",p),sv("Max Radius","Min Radius","Max Height","Min Height","Max Angle","Min Angle","boundsCylinderMaxRadius","boundsCylinderMinRadius","boundsCylinderMaxHeight","boundsCylinderMinHeight","boundsCylinderMaxAngle","boundsCylinderMinAngle",D,M,"shapeIsCylinder",p),sv("Max X","Min X","Max Y","Min Y","Max Z","Min Z","clippingBoxMaxX","clippingBoxMinX","clippingBoxMaxY","clippingBoxMinY","clippingBoxMaxZ","clippingBoxMinZ",E,T,"shapeIsBox",g),sv("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","clippingEllipsoidMaxLongitude","clippingEllipsoidMinLongitude","clippingEllipsoidMaxLatitude","clippingEllipsoidMinLatitude","clippingEllipsoidMaxHeight","clippingEllipsoidMinHeight",S,v,"shapeIsEllipsoid",g),sv("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");m.appendChild(O);let B=document.createElement("textarea");B.setAttribute("data-bind","textInput: shaderString, event: { keydown: shaderEdit