|
|
/** * @license * Cesium - https://github.com/CesiumGS/cesium
* Version 1.140.0 * * 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 hve=Object.create;var q5=Object.defineProperty;var mve=Object.getOwnPropertyDescriptor;var pve=Object.getOwnPropertyNames;var Ave=Object.getPrototypeOf,gve=Object.prototype.hasOwnProperty;var _ve=(e,t,n)=>t in e?q5(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var rM=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Xd=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var yve=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pve(t))!gve.call(e,o)&&o!==n&&q5(e,o,{get:()=>t[o],enumerable:!(i=mve(t,o))||i.enumerable});return e};var Na=(e,t,n)=>(n=e!=null?hve(Ave(e)):{},yve(t||!e||!e.__esModule?q5(n,"default",{value:e,enumerable:!0}):n,e));var vn=(e,t,n)=>_ve(e,typeof t!="symbol"?t+"":t,n);var aM=Xd((FLt,Kte)=>{var $p=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)};$p.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}};$p.prototype.init_by_array=function(e,t){var n,i,o;for(this.init_seed(19650218),n=1,i=0,o=this.N>t?this.N:t;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1664525<<16)+(r&65535)*1664525)+e[i]+i,this.mt[n]>>>=0,n++,i++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1),i>=t&&(i=0)}for(o=this.N-1;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1566083941<<16)+(r&65535)*1566083941)-n,this.mt[n]>>>=0,n++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1)}this.mt[0]=2147483648};$p.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};$p.prototype.random_int31=function(){return this.random_int()>>>1};$p.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};$p.prototype.random=function(){return this.random_int()*(1/4294967296)};$p.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};$p.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};Kte.exports=$p});var yne=Xd((TI,SI)=>{/*! https://mths.be/punycode v1.4.0 by @mathias */(function(e){var t=typeof TI=="object"&&TI&&!TI.nodeType&&TI,n=typeof SI=="object"&&SI&&!SI.nodeType&&SI,i=typeof global=="object"&&global;(i.global===i||i.window===i||i.self===i)&&(e=i);var o,r=2147483647,a=36,s=1,c=26,u=38,f=700,h=72,p=128,A="-",m=/^xn--/,_=/[^\x20-\x7E]/,y=/[\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=a-s,I=Math.floor,x=String.fromCharCode,S;function w(k){throw new RangeError(C[k])}function v(k,z){for(var F=k.length,H=[];F--;)H[F]=z(k[F]);return H}function R(k,z){var F=k.split("@"),H="";F.length>1&&(H=F[0]+"@",k=F[1]),k=k.replace(y,".");var Y=k.split("."),$=v(Y,z).join(".");return H+$}function N(k){for(var z=[],F=0,H=k.length,Y,$;F<H;)Y=k.charCodeAt(F++),Y>=55296&&Y<=56319&&F<H?($=k.charCodeAt(F++),($&64512)==56320?z.push(((Y&1023)<<10)+($&1023)+65536) * 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 TM=="object"&&TM.exports?TM.exports=t():typeof define=="function"&&define.amd?define(t):e.IPv6=t(e)})(Cne,function(e){"use strict";var t=e&&e.IPv6;function n(o){var r=o.toLowerCase(),a=r.split(":"),s=a.length,c=8;a[0]===""&&a[1]===""&&a[2]===""?(a.shift(),a.shift()):a[0]===""&&a[1]===""?a.shift():a[s-1]===""&&a[s-2]===""&&a.pop(),s=a.length,a[s-1].indexOf(".")!==-1&&(c=7);var u;for(u=0;u<s&&a[u]!=="";u++);if(u<c)for(a.splice(u,1,"0000");a.length<c;)a.splice(u,0,"0000");for(var f,h=0;h<c;h++){f=a[h].split("");for(var p=0;p<3&&(f[0]==="0"&&f.length>1);p++)f.splice(0,1);a[h]=f.join("")}var A=-1,m=0,_=0,y=-1,C=!1;for(h=0;h<c;h++)C?a[h]==="0"?_+=1:(C=!1,_>m&&(A=y,m=_)):a[h]==="0"&&(C=!0,y=h,_=1);_>m&&(A=y,m=_),m>1&&a.splice(A,m,""),s=a.length;var E="";for(a[0]===""&&(E=":"),h=0;h<s&&(E+=a[h],h!==s-1);h++)E+=":";return a[s-1]===""&&(E+=":"),E}function i(){return e.IPv6===this&&(e.IPv6=t),this}return{best:n,noConflict:i}})});var bne=Xd((Ine,SM)=>{/*! * 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 SM=="object"&&SM.exports?SM.exports=t():typeof define=="function"&&define.amd?define(t):e.SecondLevelDomains=t(e)})(Ine,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 * 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 wM=="object"&&wM.exports?wM.exports=t(yne(),Ene(),bne()):typeof define=="function"&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):e.URI=t(e.punycode,e.IPv6,e.SecondLevelDomains,e)})(xne,function(e,t,n,i){"use strict";var o=i&&i.URI;function r(b,T){var B=arguments.length>=1,M=arguments.length>=2;if(!(this instanceof r))return B?M?new r(b,T):new r(b):new r;if(b===void 0){if(B)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?b=location.href+"":b=""}if(b===null&&B)throw new TypeError("null is not a valid argument for URI");return this.href(b),T!==void 0?this.absoluteTo(T):this}function a(b){return/^[0-9]+$/.test(b)}r.version="1.19.11";var s=r.prototype,c=Object.prototype.hasOwnProperty;function u(b){return b.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function f(b){return b===void 0?"Undefined":String(Object.prototype.toString.call(b)).slice(8,-1)}function h(b){return f(b)==="Array"}function p(b,T){var B={},M,O;if(f(T)==="RegExp")B=null;else if(h(T))for(M=0,O=T.length;M<O;M++)B[T[M]]=!0;else B[T]=!0;for(M=0,O=b.length;M<O;M++){var G=B&&B[b[M]]!==void 0||!B&&T.test(b[M]);G&&(b.splice(M,1),O--,M--)}return b}function A(b,T){var B,M;if(h(T)){for(B=0,M=T.length;B<M;B++)if(!A(b,T[B]))return!1;return!0}var O=f(T);for(B=0,M=b.length;B<M;B++)if(O==="RegExp"){if(typeof b[B]=="string"&&b[B].match(T))return!0}else if(b[B]===T)return!0;return!1}function m(b,T){if(!h(b)||!h(T)||b.length!==T.length)return!1;b.sort(),T.sort();for(var B=0,M=b.length;B<M;B++)if(b[B]!==T[B])return!1;return!0}function _(b){var T=/^\/+|\/+$/g;return b.replace(T,"")}r._parts=function(){return{protocol:null,username:null,password:null,hostname:null,urn:null,port:null,path:null,query:null,fragment:null,preventInvalidHostname:r.preventInvalidHostname,duplicateQueryParameters:r.duplicateQueryParameters,escapeQuerySpace:r.escapeQuerySpace}},r.preventInvalidHostname=!1,r.duplicateQueryParameters=!1,r.escapeQuerySpace=!0,r.protocol_expression=/^[a-z][a-z0-9.+-]*$/i,r.idn_expression=/[^a-z0-9\._-]/i,r.punycode_expression=/(xn--)/i,r.ip4_expression=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,r.ip6_expression=/^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/,r.find_uri_expression=/\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig,r.findUri={start:/\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,end:/[\s\r\n]|$/,trim:/[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,parens:/(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g},r.leading_whitespace_expression=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,r.ascii_tab_whitespace=/[\u0009\u000A\u000D]+/g,r.defaultPorts={http:"80",https:"443",ftp:"21",gopher:"70",ws:"80",wss:"443"},r.hostProtocols=["http","https"],r.invalid_hostname_characters=/[^a-zA-Z0-9\.\-:_]/,r.domAttributes={a:"href",blockquote:"cite",link:"href",base:"href",script:"src",form:"acti * protobuf.js v8.0.1 (c) 2016, daniel wirtz * compiled sat, 04 apr 2026 19:23:15 utc * licensed under the bsd-3-clause license * see: https://github.com/dcodeio/protobuf.js for details
*/(function(undefined){"use strict";(function(t,n,i){function o(a){var s=n[a];return s||t[a][0].call(s=n[a]={exports:{}},o,s,s.exports),s.exports}var r=o(i[0]);r.util.global.protobuf=r,typeof define=="function"&&define.amd&&define(["long"],function(a){return a&&a.isLong&&(r.util.Long=a,r.configure()),r}),typeof module=="object"&&module&&module.exports&&(module.exports=r)})({1:[function(e,t,n){"use strict";t.exports=i;function i(o,r){for(var a=new Array(arguments.length-1),s=0,c=2,u=!0;c<arguments.length;)a[s++]=arguments[c++];return new Promise(function(h,p){a[s]=function(m){if(u)if(u=!1,m)p(m);else{for(var _=new Array(arguments.length-1),y=0;y<_.length;)_[y++]=arguments[y];h.apply(null,_)}};try{o.apply(r||null,a)}catch(A){u&&(u=!1,p(A))}})}},{}],2:[function(e,t,n){"use strict";var i=n;i.length=function(u){var f=u.length;if(!f)return 0;for(var h=0;--f%4>1&&u.charAt(f)==="=";)++h;return Math.ceil(u.length*3)/4-h};for(var o=new Array(64),r=new Array(123),a=0;a<64;)r[o[a]=a<26?a+65:a<52?a+71:a<62?a-4:a-59|43]=a++;i.encode=function(u,f,h){for(var p=null,A=[],m=0,_=0,y;f<h;){var C=u[f++];switch(_){case 0:A[m++]=o[C>>2],y=(C&3)<<4,_=1;break;case 1:A[m++]=o[y|C>>4],y=(C&15)<<2,_=2;break;case 2:A[m++]=o[y|C>>6],A[m++]=o[C&63],_=0;break}m>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,A)),m=0)}return _&&(A[m++]=o[y],A[m++]=61,_===1&&(A[m++]=61)),p?(m&&p.push(String.fromCharCode.apply(String,A.slice(0,m))),p.join("")):String.fromCharCode.apply(String,A.slice(0,m))};var s="invalid encoding";i.decode=function(u,f,h){for(var p=h,A=0,m,_=0;_<u.length;){var y=u.charCodeAt(_++);if(y===61&&A>1)break;if((y=r[y])===undefined)throw Error(s);switch(A){case 0:m=y,A=1;break;case 1:f[h++]=m<<2|(y&48)>>4,m=y,A=2;break;case 2:f[h++]=(m&15)<<4|(y&60)>>2,m=y,A=3;break;case 3:f[h++]=(m&3)<<6|y,A=0;break}}if(A===1)throw Error(s);return h-p},i.test=function(u){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(u)}},{}],3:[function(e,t,n){"use strict";t.exports=i;function i(){this._listeners={}}i.prototype.on=function(r,a,s){return(this._listeners[r]||(this._listeners[r]=[])).push({fn:a,ctx:s||this}),this},i.prototype.off=function(r,a){if(r===undefined)this._listeners={};else if(a===undefined)this._listeners[r]=[];else for(var s=this._listeners[r],c=0;c<s.length;)s[c].fn===a?s.splice(c,1):++c;return this},i.prototype.emit=function(r){var a=this._listeners[r];if(a){for(var s=[],c=1;c<arguments.length;)s.push(arguments[c++]);for(c=0;c<a.length;)a[c].fn.apply(a[c++].ctx,s)}return this}},{}],4:[function(e,t,n){"use strict";t.exports=i(i);function i(c){return typeof Float32Array<"u"?(function(){var u=new Float32Array([-0]),f=new Uint8Array(u.buffer),h=f[3]===128;function p(y,C,E){u[0]=y,C[E]=f[0],C[E+1]=f[1],C[E+2]=f[2],C[E+3]=f[3]}function A(y,C,E){u[0]=y,C[E]=f[3],C[E+1]=f[2],C[E+2]=f[1],C[E+3]=f[0]}c.writeFloatLE=h?p:A,c.writeFloatBE=h?A:p;function m(y,C){return f[0]=y[C],f[1]=y[C+1],f[2]=y[C+2],f[3]=y[C+3],u[0]}function _(y,C){return f[3]=y[C],f[2]=y[C+1],f[1]=y[C+2],f[0]=y[C+3],u[0]}c.readFloatLE=h?m:_,c.readFloatBE=h?_:m})():(function(){function u(h,p,A,m){var _=p<0?1:0;if(_&&(p=-p),p===0)h(1/p>0?0:2147483648,A,m);else if(isNaN(p))h(2143289344,A,m);else if(p>34028234663852886e22)h((_<<31|2139095040)>>>0,A,m);else if(p<11754943508222875e-54)h((_<<31|Math.round(p/1401298464324817e-60))>>>0,A,m);else{var y=Math.floor(Math.log(p)/Math.LN2),C=Math.round(p*Math.pow(2,-y)*8388608)&8388607;h((_<<31|y+127<<23|C)>>>0,A,m)}}c.writeFloatLE=u.bind(null,o),c.writeFloatBE=u.bind(null,r);function f(h,p,A){var m=h(p,A),_=(m>>31)*2+1,y=m>>>23&255,C=m&8388607;return y===255?C?NaN:_*(1/0):y===0?_*1401298464324817e-60*C:_*Math.pow(2,y-150)*(C+8388608)}c.readFloatLE=f.bind(null,a),c.readFloatBE=f.bind(null,s)})(),typeof Float64Array<"u"?(function(){var u=new Float64Array([-0]),f=new Uint8Array(u.buffer),h=f[7]===128;function p(y,C,E){u[0]=y,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 A(y,C,E){u[0]=y,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 NoSleep enabled for older iOS devices. This can interrupt active or long-running network requests from completing successfully. See https://github.com/richtr/NoSleep.js/issues/15 for more details.
`),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(n=>(this.enabled=!0,n)).catch(n=>{throw this.enabled=!1,n})}disable(){Qte()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):Fte()?this.noSleepTimer&&(console.warn(` NoSleep now disabled for older iOS devices. `),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}};KDe.exports=kte});var jte=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],K5=1,fw=8,wC=class e{static from(t){if(!(t instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");let[n,i]=new Uint8Array(t,0,2);if(n!==219)throw new Error("Data does not appear to be in a KDBush format.");let o=i>>4;if(o!==K5)throw new Error(`Got v${o} data when expected v${K5}.`);let r=jte[i&15];if(!r)throw new Error("Unrecognized array type.");let[a]=new Uint16Array(t,2,1),[s]=new Uint32Array(t,4,1);return new e(s,a,r,t)}constructor(t,n=64,i=Float64Array,o){if(isNaN(t)||t<0)throw new Error(`Unpexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+n,2),65535),this.ArrayType=i,this.IndexArrayType=t<65536?Uint16Array:Uint32Array;let r=jte.indexOf(this.ArrayType),a=t*2*this.ArrayType.BYTES_PER_ELEMENT,s=t*this.IndexArrayType.BYTES_PER_ELEMENT,c=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);o&&o instanceof ArrayBuffer?(this.data=o,this.ids=new this.IndexArrayType(this.data,fw,t),this.coords=new this.ArrayType(this.data,fw+s+c,t*2),this._pos=t*2,this._finished=!0):(this.data=new ArrayBuffer(fw+a+s+c),this.ids=new this.IndexArrayType(this.data,fw,t),this.coords=new this.ArrayType(this.data,fw+s+c,t*2),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,(K5<<4)+r]),new Uint16Array(this.data,2,1)[0]=n,new Uint32Array(this.data,4,1)[0]=t)}add(t,n){let i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=t,this.coords[this._pos++]=n,i}finish(){let t=this._pos>>1;if(t!==this.numItems)throw new Error(`Added ${t} items when expected ${this.numItems}.`);return J5(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(t,n,i,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:r,coords:a,nodeSize:s}=this,c=[0,r.length-1,0],u=[];for(;c.length;){let f=c.pop()||0,h=c.pop()||0,p=c.pop()||0;if(h-p<=s){for(let y=p;y<=h;y++){let C=a[2*y],E=a[2*y+1];C>=t&&C<=i&&E>=n&&E<=o&&u.push(r[y])}continue}let A=p+h>>1,m=a[2*A],_=a[2*A+1];m>=t&&m<=i&&_>=n&&_<=o&&u.push(r[A]),(f===0?t<=m:n<=_)&&(c.push(p),c.push(A-1),c.push(1-f)),(f===0?i>=m:o>=_)&&(c.push(A+1),c.push(h),c.push(1-f))}return u}within(t,n,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");let{ids:o,coords:r,nodeSize:a}=this,s=[0,o.length-1,0],c=[],u=i*i;for(;s.length;){let f=s.pop()||0,h=s.pop()||0,p=s.pop()||0;if(h-p<=a){for(let y=p;y<=h;y++)Yte(r[2*y],r[2*y+1],t,n)<=u&&c.push(o[y]);continue}let A=p+h>>1,m=r[2*A],_=r[2*A+1];Yte(m,_,t,n)<=u&&c.push(o[A]),(f===0?t-i<=m:n-i<=_)&&(s.push(p),s.push(A-1),s.push(1-f)),(f===0?t+i>=m:n+i>=_)&&(s.push(A+1),s.push(h),s.push(1-f))}return c}};function J5(e,t,n,i,o,r){if(o-i<=n)return;let a=i+o>>1;qte(e,t,a,i,o,r),J5(e,t,n,i,a-1,1-r),J5(e,t,n,a+1,o,1-r)}function qte(e,t,n,i,o,r){for(;o>i;){if(o-i>600){let u=o-i+1,f=n-i+1,h=Math.log(u),p=.5*Math.exp(2*h/3),A=.5*Math.sqrt(h*p*(u-p)/u)*(f-u/2<0?-1:1),m=Math.max(i,Math.floor(n-f*p/u+A)),_=Math.min(o,Math.floor(n+(u-f)*p/u+A));qte(e,t,n,m,_,r)}let a=t[2*n+r],s=i,c=o;for(dw(e,t,i,n),t[2*o+r]>a&&dw(e,t,i,o);s<c;){for(dw(e,t,s,c),s++,c--;t[2*s+r]<a;)s++;for(;t[2*c+r]>a;)c--}t[2*i+r]===a?dw(e,t,i,c):(c++,dw(e,t,c,o)),c<=n&&(i=c+1),n<=c&&(o=c-1)}}function dw(e,t,n,i){X5(e,n,i),X5(t,2*n,2*i),X5(t,2*n+1,2*i+1)}function X5(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}function Yte(e,t,n,i){let o=e-n,r=t-i;return o*o+r*r}var gI={},Cve={KDBush:wC,addCache:function(e,t){return gI[e]=t,t},removeCache:function(e){delete gI[e]},getCache:function(e){return gI[e]},getCacheOrAdd:function(e){return gI[e]||(gI[e]={}),gI[e]}},Lg=Cve;function Eve(e){return e!=null}var l=Eve;function BC(e){this.name="DeveloperError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}l(Object.create)&&(BC.prototype=Object.create(Error.prototype),BC.prototype.constructor=BC)
${this.stack.toString()}`),e};BC.throwInstantiationError=function(){throw new BC("This function defines an interface and should not be called directly.")};var de=BC;var $a={};$a.typeOf={};function Ive(e){return`${e} is required, actual value was undefined`}function _I(e,t,n){return`Expected ${n} to be typeof ${t}, actual typeof was ${e}`}$a.defined=function(e,t){if(!l(t))throw new de(Ive(e))};$a.typeOf.func=function(e,t){if(typeof t!="function")throw new de(_I(typeof t,"function",e))};$a.typeOf.string=function(e,t){if(typeof t!="string")throw new de(_I(typeof t,"string",e))};$a.typeOf.number=function(e,t){if(typeof t!="number")throw new de(_I(typeof t,"number",e))};$a.typeOf.number.lessThan=function(e,t,n){if($a.typeOf.number(e,t),t>=n)throw new de(`Expected ${e} to be less than ${n}, actual value was ${t}`)};$a.typeOf.number.lessThanOrEquals=function(e,t,n){if($a.typeOf.number(e,t),t>n)throw new de(`Expected ${e} to be less than or equal to ${n}, actual value was ${t}`)};$a.typeOf.number.greaterThan=function(e,t,n){if($a.typeOf.number(e,t),t<=n)throw new de(`Expected ${e} to be greater than ${n}, actual value was ${t}`)};$a.typeOf.number.greaterThanOrEquals=function(e,t,n){if($a.typeOf.number(e,t),t<n)throw new de(`Expected ${e} to be greater than or equal to ${n}, actual value was ${t}`)};$a.typeOf.object=function(e,t){if(typeof t!="object")throw new de(_I(typeof t,"object",e))};$a.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new de(_I(typeof t,"boolean",e))};$a.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new de(_I(typeof t,"bigint",e))};$a.typeOf.number.equals=function(e,t,n,i){if($a.typeOf.number(e,n),$a.typeOf.number(t,i),n!==i)throw new de(`${e} must be equal to ${t}, the actual values are ${n} and ${i}`)};var Wo=$a;var Z5=Na(aM(),1);var pt={};pt.EPSILON1=.1;pt.EPSILON2=.01;pt.EPSILON3=.001;pt.EPSILON4=1e-4;pt.EPSILON5=1e-5;pt.EPSILON6=1e-6;pt.EPSILON7=1e-7;pt.EPSILON8=1e-8;pt.EPSILON9=1e-9;pt.EPSILON10=1e-10;pt.EPSILON11=1e-11;pt.EPSILON12=1e-12;pt.EPSILON13=1e-13;pt.EPSILON14=1e-14;pt.EPSILON15=1e-15;pt.EPSILON16=1e-16;pt.EPSILON17=1e-17;pt.EPSILON18=1e-18;pt.EPSILON19=1e-19;pt.EPSILON20=1e-20;pt.EPSILON21=1e-21;pt.GRAVITATIONALPARAMETER=3986004418e5;pt.SOLAR_RADIUS=6955e5;pt.LUNAR_RADIUS=1737400;pt.SIXTY_FOUR_KILOBYTES=64*1024;pt.FOUR_GIGABYTES=4*1024*1024*1024;pt.sign=Math.sign??function(t){return t=+t,t===0||t!==t?t:t>0?1:-1};pt.signNotZero=function(e){return e<0?-1:1};pt.toSNorm=function(e,t){return t=t??255,Math.round((pt.clamp(e,-1,1)*.5+.5)*t)};pt.fromSNorm=function(e,t){return t=t??255,pt.clamp(e,0,t)/t*2-1};pt.normalize=function(e,t,n){return n=Math.max(n-t,0),n===0?0:pt.clamp((e-t)/n,0,1)};pt.sinh=Math.sinh??function(t){return(Math.exp(t)-Math.exp(-t))/2};pt.cosh=Math.cosh??function(t){return(Math.exp(t)+Math.exp(-t))/2};pt.lerp=function(e,t,n){return(1-n)*e+n*t};pt.PI=Math.PI;pt.ONE_OVER_PI=1/Math.PI;pt.PI_OVER_TWO=Math.PI/2;pt.PI_OVER_THREE=Math.PI/3;pt.PI_OVER_FOUR=Math.PI/4;pt.PI_OVER_SIX=Math.PI/6;pt.THREE_PI_OVER_TWO=3*Math.PI/2;pt.TWO_PI=2*Math.PI;pt.ONE_OVER_TWO_PI=1/(2*Math.PI);pt.RADIANS_PER_DEGREE=Math.PI/180;pt.DEGREES_PER_RADIAN=180/Math.PI;pt.RADIANS_PER_ARCSECOND=pt.RADIANS_PER_DEGREE/3600;pt.toRadians=function(e){return e*pt.RADIANS_PER_DEGREE};pt.toDegrees=function(e){return e*pt.DEGREES_PER_RADIAN};pt.convertLongitudeRange=function(e){let t=pt.TWO_PI,n=e-Math.floor(e/t)*t;return n<-Math.PI?n+t:n>=Math.PI?n-t:n};pt.clampToLatitudeRange=function(e){return pt.clamp(e,-1*pt.PI_OVER_TWO,pt.PI_OVER_TWO)};pt.negativePiToPi=function(e){return e>=-pt.PI&&e<=pt.PI?e:pt.zeroToTwoPi(e+pt.PI)-pt.PI};pt.zeroToTwoPi=function(e){if(e>=0&&e<=pt.TWO_PI)return e;let t=pt.mod(e,pt.TWO_PI);return Math.abs(t)<pt.EPSILON14&&Math.abs(e)>pt.EPSILON14?pt.TWO_PI:t};pt.mod=function(e,t){return pt.sign(e)===pt.sign(t)&&Math.abs(e)<Math.abs(t)?e:(e%t+t)%t};pt.equalsEpsilon=function(e,t,n,i){n=n??0,i=i??n;let o=Math.abs(e-t);return o<=i||o<=n*Math.max(Math.abs(e),Math.abs(t))};pt.lessThan=function(e,t,n){return e-t<-n};pt.lessThanOrEquals=function(e,t,n){return e-t<n};pt.greaterThan=function(e
(${this[1]}, ${this[4]}, ${this[7]})(${this[2]}, ${this[5]}, ${this[8]})`};var J=ut;function hw(e){this.name="RuntimeError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}l(Object.create)&&(hw.prototype=Object.create(Error.prototype),hw.prototype.constructor=hw);hw.prototype.toString=function(){let e=`${this.name}: ${this.message}`;return l(this.stack)&&(e+=`${this.stack.toString()}`),e};var ue=hw;function ct(e,t,n,i,o,r,a,s,c,u,f,h,p,A,m,_){this[0]=e??0,this[1]=o??0,this[2]=c??0,this[3]=p??0,this[4]=t??0,this[5]=r??0,this[6]=u??0,this[7]=A??0,this[8]=n??0,this[9]=a??0,this[10]=f??0,this[11]=m??0,this[12]=i??0,this[13]=s??0,this[14]=h??0,this[15]=_??0}ct.packedLength=16;ct.pack=function(e,t,n){return n=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};ct.unpack=function(e,t,n){return t=t??0,l(n)||(n=new ct),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};ct.packArray=function(e,t){let n=e.length,i=n*16;l(t)?!Array.isArray(t)&&t.length!==i||t.length!==i&&(t.length=i):t=new Array(i);for(let o=0;o<n;++o)ct.pack(e[o],t,o*16);return t};ct.unpackArray=function(e,t){let n=e.length;l(t)?t.length=n/16:t=new Array(n/16);for(let i=0;i<n;i+=16){let o=i/16;t[o]=ct.unpack(e,i,t[o])}return t};ct.clone=function(e,t){if(l(e))return l(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 ct(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])};ct.fromArray=ct.unpack;ct.fromColumnMajorArray=function(e,t){return ct.clone(e,t)};ct.fromRowMajorArray=function(e,t){return l(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 ct(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])};ct.fromRotationTranslation=function(e,t,n){return t=t??d.ZERO,l(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 ct(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)};ct.fromTranslationQuaternionRotationScale=function(e,t,n,i){l(i)||(i=new ct);let o=n.x,r=n.y,a=n.z,s=t.x*t.x,c=t.x*t.y,u=t.x*t.z,f=t.x*t.w,h=t.y*t.y,p=t.y*t.z,A=t.y*t.w,m=t.z*t.z,_=t.z*t.w,y=t.w*t.w,C=s-h-m+y,E=2*(c-_),I=2*(u+A),x=2*(c+_),S=-s+h-m+y,w=2*(p-f),v=2*(u-A),R=2*(p+f),N=-s-h+m+y;return i[0]=C*o,i[1]=x*o,i[2]=v*o,i[3]=0,i[4]=E*r,i[5]=S*r,i[6]=R*r,i[7]=0,i[8]=I*a,i[9]=w*a,i[10]=N*a,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,i};ct.fromTranslationRotationScale=function(e,t){return ct.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,t)};ct.fromTranslation=function(e,t){return ct.fromRotationTranslation(J.IDENTITY,e,t)};ct.fromScale=function(e,t){return l(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 ct(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)};ct.fromUniformScale=function(e,t){return l(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 ct(e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1)};ct.fromRotation=function(e,t){return l(t)||(t=new ct),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 CI=new d,EI=new d,mw=new d;ct.fromCamera=function(e,t){let n=e.position,i=e.direction,o=e.up;d.normalize(i,CI),d.normalize(d.cross(CI,o,EI),EI),d.normalize(d.cross(EI,CI,mw),mw);let r=EI.x,a=EI.y,s=EI.z,c=CI.x,u=CI.y,f=CI.z,h=mw.x,p=mw.y,A=mw.z,m=n.x,_=n.y,y=n.z,C=r*-m+a*-_+s*-y,E=h*-m+p*-_+A*-y,I=c*m+u*_+f*y;return l(t)?(t[0]=r,t[1]=h,t[2]=-c,t[3]=0,t[4]=a,t[5]=p,t[6]=-u,t[7]=0,t[8]=s,t[9]=A,t[10]=-f,t[11]=0,t[12]=C,t[13]=E,t[14]=I,t[15]=1,t):new ct(r,a,s,C,h,p,A,E,-c,-u,-f,I,0,0,0,1)};ct.computePerspectiveFieldOfView=function(e,t,n,i,o){let a=1/Math.tan(e*.5),s=a/t,c=(i+n)/(n-i),u=2*i*n/(n-i);return o[0]=s,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=a,o[6]
(${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 P=ct;var Hve={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:339
`);for(let i=0;i<n.length;++i){let o=n[i],r=o.indexOf(": ");if(r>0){let a=o.substring(0,r),s=o.substring(r+2);t[a]=s}}return t}var PM=nRe;function Pne(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=PM(this.responseHeaders))}Pne.prototype.toString=function(){let e="Request has failed.";return l(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};var nA=Pne;var MM=Na(Fu(),1);function gw(){this._listeners=new Map,this._toRemove=new Map,this._toAdd=new Map,this._invokingListeners=!1,this._listenerCount=0}Object.defineProperties(gw.prototype,{numberOfListeners:{get:function(){return this._listenerCount}}});gw.prototype.addEventListener=function(e,t){let n=this,i=n._invokingListeners?n._toAdd:n._listeners;return IW(this,i,e,t)&&n._listenerCount++,function(){n.removeEventListener(e,t)}};function IW(e,t,n,i){t.has(n)||t.set(n,new Set);let o=t.get(n);return o.has(i)?!1:(o.add(i),!0)}gw.prototype.removeEventListener=function(e,t){let n=EW(this,this._listeners,e,t),i=EW(this,this._toAdd,e,t),o=n||i;return o&&this._listenerCount--,o};function EW(e,t,n,i){let o=t.get(n);if(!o||!o.has(i))return!1;if(e._invokingListeners){if(!IW(e,e._toRemove,n,i))return!1}else o.delete(i),o.size===0&&t.delete(n);return!0}gw.prototype.raiseEvent=function(){this._invokingListeners=!0;for(let[e,t]of this._listeners.entries())if(l(e))for(let n of t)e.apply(n,arguments);this._invokingListeners=!1;for(let[e,t]of this._toAdd.entries())for(let n of t)IW(this,this._listeners,e,n);this._toAdd.clear();for(let[e,t]of this._toRemove.entries())for(let n of t)EW(this,this._listeners,e,n);this._toRemove.clear()};var _e=gw;function PC(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(PC.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 bW(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}PC.prototype.reserve=function(e){e=e??this._length,this._array.length=e};PC.prototype.heapify=function(e){e=e??0;let t=this._length,n=this._comparator,i=this._array,o=-1,r=!0;for(;r;){let a=2*(e+1),s=a-1;s<t&&n(i[s],i[e])<0?o=s:o=e,a<t&&n(i[a],i[o])<0&&(o=a),o!==e?(bW(i,o,e),e=o):r=!1}};PC.prototype.resort=function(){let e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};PC.prototype.insert=function(e){let t=this._array,n=this._comparator,i=this._maximumLength,o=this._length++;for(o<t.length?t[o]=e:t.push(e);o!==0;){let a=Math.floor((o-1)/2);if(n(t[o],t[a])<0)bW(t,o,a),o=a;else break}let r;return l(i)&&this._length>i&&(r=t[i],this._length=i),r};PC.prototype.pop=function(e){if(e=e??0,this._length===0)return;let t=this._array,n=t[e];return bW(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};var RM=PC;function iRe(e,t){return e.priority-t.priority}var po={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0},vI=20,vc=new RM({comparator:iRe});vc.maximumLength=vI;vc.reserve(vI);var gm=[],iA={},oRe=typeof document<"u"?new MM.default(document.location.href):new MM.default,NM=new _e;function Ar(){}Ar.maximumRequests=50;Ar.maximumRequestsPerServer=18;Ar.requestsByServer={};Ar.throttleRequests=!0;Ar.debugShowStatistics=!1;Ar.requestCompletedEvent=NM;Object.defineProperties(Ar,{statistics:{get:function(){return po}},priorityHeapLength:{get:function(){return vI},set:function(e){if(e<vI)for(;vc.length>e;){let t=vc.pop();RC(t)}vI=e,vc.maximumLength=e,vc.reserve(e)}}});function Rne(e){l(e.priorityFunction)&&(e.priority=e.priorityFunction())}Ar.serverHasOpenSlots=function(e,t){t=t??1;let n=Ar.requestsByServer[e]??Ar.maximumRequestsPerServer;return iA[e]+t<=n};Ar.heapHasOpenSlots=f
in vec2 textureCoordinates;
out vec2 v_textureCoordinates;
void main() { gl_Position = position; v_textureCoordinates = textureCoordinates;}`;var Or={CULL:1,OCCLUDE:2,EXECUTE_IN_CLOSEST_FRUSTUM:4,DEBUG_SHOW_BOUNDING_VOLUME:8,CAST_SHADOWS:16,RECEIVE_SHADOWS:32,PICK_ONLY:64,DEPTH_FOR_TRANSLUCENT_CLASSIFICATION:128};function xw(e){e=e??V.EMPTY_OBJECT,this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._modelMatrix=e.modelMatrix,this._primitiveType=e.primitiveType??Pe.TRIANGLES,this._vertexArray=e.vertexArray,this._count=e.count,this._offset=e.offset??0,this._instanceCount=e.instanceCount??0,this._shaderProgram=e.shaderProgram,this._uniformMap=e.uniformMap,this._renderState=e.renderState,this._framebuffer=e.framebuffer,this._pass=e.pass,this._owner=e.owner,this._debugOverlappingFrustums=0,this._pickId=e.pickId,this._pickMetadataAllowed=e.pickMetadataAllowed===!0,this._pickedMetadataInfo=void 0,this._flags=0,this.cull=e.cull??!0,this.occlude=e.occlude??!0,this.executeInClosestFrustum=e.executeInClosestFrustum??!1,this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this.castShadows=e.castShadows??!1,this.receiveShadows=e.receiveShadows??!1,this.pickOnly=e.pickOnly??!1,this.depthForTranslucentClassification=e.depthForTranslucentClassification??!1,this.dirty=!0,this.lastDirtyTime=0,this.derivedCommands={}}function Mc(e,t){return(e._flags&t)===t}function Hg(e,t,n){n?e._flags|=t:e._flags&=~t}Object.defineProperties(xw.prototype,{boundingVolume:{get:function(){return this._boundingVolume},set:function(e){this._boundingVolume!==e&&(this._boundingVolume=e,this.dirty=!0)}},orientedBoundingBox:{get:function(){return this._orientedBoundingBox},set:function(e){this._orientedBoundingBox!==e&&(this._orientedBoundingBox=e,this.dirty=!0)}},cull:{get:function(){return Mc(this,Or.CULL)},set:function(e){Mc(this,Or.CULL)!==e&&(Hg(this,Or.CULL,e),this.dirty=!0)}},occlude:{get:function(){return Mc(this,Or.OCCLUDE)},set:function(e){Mc(this,Or.OCCLUDE)!==e&&(Hg(this,Or.OCCLUDE,e),this.dirty=!0)}},modelMatrix:{get:function(){return this._modelMatrix},set:function(e){this._modelMatrix!==e&&(this._modelMatrix=e,this.dirty=!0)}},primitiveType:{get:function(){return this._primitiveType},set:function(e){this._primitiveType!==e&&(this._primitiveType=e,this.dirty=!0)}},vertexArray:{get:function(){return this._vertexArray},set:function(e){this._vertexArray!==e&&(this._vertexArray=e,this.dirty=!0)}},count:{get:function(){return this._count},set:function(e){this._count!==e&&(this._count=e,this.dirty=!0)}},offset:{get:function(){return this._offset},set:function(e){this._offset!==e&&(this._offset=e,this.dirty=!0)}},instanceCount:{get:function(){return this._instanceCount},set:function(e){this._instanceCount!==e&&(this._instanceCount=e,this.dirty=!0)}},shaderProgram:{get:function(){return this._shaderProgram},set:function(e){this._shaderProgram!==e&&(this._shaderProgram=e,this.dirty=!0)}},castShadows:{get:function(){return Mc(this,Or.CAST_SHADOWS)},set:function(e){Mc(this,Or.CAST_SHADOWS)!==e&&(Hg(this,Or.CAST_SHADOWS,e),this.dirty=!0)}},receiveShadows:{get:function(){return Mc(this,Or.RECEIVE_SHADOWS)},set:function(e){Mc(this,Or.RECEIVE_SHADOWS)!==e&&(Hg(this,Or.RECEIVE_SHADOWS,e),this.dirty=!0)}},uniformMap:{get:function(){return this._uniformMap},set:function(e){this._uniformMap!==e&&(this._uniformMap=e,this.dirty=!0)}},renderState:{get:function(){return this._renderState},set:function(e){this._renderState!==e&&(this._renderState=e,this.dirty=!0)}},framebuffer:{get:function(){return this._framebuffer},set:function(e){this._framebuffer!==e&&(this._framebuffer=e,this.dirty=!0)}},pass:{get:function(){return this._pass},set:function(e){this._pass!==e&&(this._pass=e,this.dirty=!0)}},executeInClosestFrustum:{get:function(){return Mc(this,Or.EXECUTE_IN_CLOSEST_FRUSTUM)},set:function(e){Mc(this,Or.EXECUTE_IN_CLOSEST_FRUSTUM)!==e&&(Hg(this,Or.EXECUTE_IN_CLOSEST_FRUSTUM,e),this.dirty=!0)}},owner:{get:function(){return this._owner},set:function(e){this._owner!==e&&(this._owner=e,this.dirty=!0)}},debugShowBoundingVolume:{get:function(){return Mc(this,Or.DEBUG_SHOW_BOUNDING_VOLUME)},set:function(e){Mc(this,Or.DEBUG_SHOW_BOUNDING_VOLUME)!==e&&(Hg(this,Or.DEBUG_SHO
(${this[1]}, ${this[3]})`};var Ki=rn;function gMe(e,t,n,i){switch(t.type){case e.FLOAT:return new Eie(e,t,n,i);case e.FLOAT_VEC2:return new Iie(e,t,n,i);case e.FLOAT_VEC3:return new bie(e,t,n,i);case e.FLOAT_VEC4:return new xie(e,t,n,i);case e.SAMPLER_2D:case e.SAMPLER_3D:case e.SAMPLER_CUBE:case e.SAMPLER_2D_ARRAY:return new KM(e,t,n,i);case e.UNSIGNED_INT_SAMPLER_2D:return new KM(e,t,n,i);case e.INT:case e.BOOL:return new Tie(e,t,n,i);case e.INT_VEC2:case e.BOOL_VEC2:return new Sie(e,t,n,i);case e.INT_VEC3:case e.BOOL_VEC3:return new wie(e,t,n,i);case e.INT_VEC4:case e.BOOL_VEC4:return new Bie(e,t,n,i);case e.FLOAT_MAT2:return new Die(e,t,n,i);case e.FLOAT_MAT3:return new vie(e,t,n,i);case e.FLOAT_MAT4:return new Pie(e,t,n,i);default:throw new ue(`Unrecognized uniform type: ${t.type} for uniform "${n}".`)}}function Eie(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}Eie.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1f(this._location,this.value))};function Iie(e,t,n,i){this.name=n,this.value=void 0,this._value=new Q,this._gl=e,this._location=i}Iie.prototype.set=function(){let e=this.value;Q.equals(e,this._value)||(Q.clone(e,this._value),this._gl.uniform2f(this._location,e.x,e.y))};function bie(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}bie.prototype.set=function(){let e=this.value;e&&(l(e.red)?U.equals(e,this._value)||(this._value=U.clone(e,this._value),this._gl.uniform3f(this._location,e.red,e.green,e.blue)):l(e.x)&&(d.equals(e,this._value)||(this._value=d.clone(e,this._value),this._gl.uniform3f(this._location,e.x,e.y,e.z))))};function xie(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}xie.prototype.set=function(){let e=this.value;l(e.red)?U.equals(e,this._value)||(this._value=U.clone(e,this._value),this._gl.uniform4f(this._location,e.red,e.green,e.blue,e.alpha)):l(e.x)&&(ie.equals(e,this._value)||(this._value=ie.clone(e,this._value),this._gl.uniform4f(this._location,e.x,e.y,e.z,e.w)))};function KM(e,t,n,i){this.name=n,this.value=void 0,this._gl=e,this._location=i,this.textureUnitIndex=void 0}KM.prototype.set=function(){let e=this._gl;e.activeTexture(e.TEXTURE0+this.textureUnitIndex);let t=this.value;t&&e.bindTexture(t._target,t._texture)};KM.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function Tie(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}Tie.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1i(this._location,this.value))};function Sie(e,t,n,i){this.name=n,this.value=void 0,this._value=new Q,this._gl=e,this._location=i}Sie.prototype.set=function(){let e=this.value;Q.equals(e,this._value)||(Q.clone(e,this._value),this._gl.uniform2i(this._location,e.x,e.y))};function wie(e,t,n,i){this.name=n,this.value=void 0,this._value=new d,this._gl=e,this._location=i}wie.prototype.set=function(){let e=this.value;d.equals(e,this._value)||(d.clone(e,this._value),this._gl.uniform3i(this._location,e.x,e.y,e.z))};function Bie(e,t,n,i){this.name=n,this.value=void 0,this._value=new ie,this._gl=e,this._location=i}Bie.prototype.set=function(){let e=this.value;ie.equals(e,this._value)||(ie.clone(e,this._value),this._gl.uniform4i(this._location,e.x,e.y,e.z,e.w))};var _Me=new Float32Array(4);function Die(e,t,n,i){this.name=n,this.value=void 0,this._value=new Ki,this._gl=e,this._location=i}Die.prototype.set=function(){if(!Ki.equalsArray(this.value,this._value,0)){Ki.clone(this.value,this._value);let e=Ki.toArray(this.value,_Me);this._gl.uniformMatrix2fv(this._location,!1,e)}};var yMe=new Float32Array(9);function vie(e,t,n,i){this.name=n,this.value=void 0,this._value=new J,this._gl=e,this._location=i}vie.prototype.set=function(){if(!J.equalsArray(this.value,this._value,0)){J.clone(this.value,this._value);let e=J.toArray(this.value,yMe);this._gl.uniformMatrix3fv(this._location,!1,e)}};var CMe=new Float32Array(16);function Pie(e,t,n,i){this.name=n,th
${n}`),u=`Vertex shader failed to compile. Compile log: ${c}`):(c=e.getShaderInfoLog(r),console.error(`${Em}Fragment shader compile log: ${c}`),console.error(`${Em} Fragment shader source:${i}`),u=`Fragment shader failed to compile. Compile log: ${c}`),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(a),new ue(u);function h(p,A){if(!l(f))return;let m=f.getTranslatedShaderSource(p);if(m===""){console.error(`${Em}${A} shader translation failed.`);return}console.error(`${Em}Translated ${A} shaderSource:${m}`)}}function TMe(e,t,n){let i={};for(let o=0;o<n;++o){let r=e.getActiveAttrib(t,o),a=e.getAttribLocation(t,r.name);i[r.name]={name:r.name,type:r.type,index:a}}return i}function SMe(e,t){let n={},i=[],o=[],r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<r;++a){let s=e.getActiveUniform(t,a),c="[0]",u=s.name.indexOf(c,s.name.length-c.length)!==-1?s.name.slice(0,s.name.length-3):s.name;if(u.indexOf("gl_")!==0)if(s.name.indexOf("[")<0){let f=e.getUniformLocation(t,u);if(f!==null){let h=XM(e,s,u,f);n[u]=h,i.push(h),h._setSampler&&o.push(h)}}else{let f,h,p,A,m=u.indexOf("[");if(m>=0){if(f=n[u.slice(0,m)],!l(f))continue;h=f._locations,h.length<=1&&(p=f.value,A=e.getUniformLocation(t,u),A!==null&&(h.push(A),p.push(e.getUniform(t,A))))}else{h=[];for(let _=0;_<s.size;++_)A=e.getUniformLocation(t,`${u}[${_}]`),A!==null&&h.push(A);f=JM(e,s,u,h),n[u]=f,i.push(f),f._setSampler&&o.push(f)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:o}}function wMe(e,t){let n=[],i=[];for(let o in t)if(t.hasOwnProperty(o)){let r=t[o],a=o,s=e._duplicateUniformNames[a];l(s)&&(r.name=s,a=s);let c=Og[a];l(c)?n.push({uniform:r,automaticUniform:c}):i.push(r)}return{automaticUniforms:n,manualUniforms:i}}function BMe(e,t,n){e.useProgram(t);let i=0,o=n.length;for(let r=0;r<o;++r)i=n[r]._setSampler(i);return e.useProgram(null),i}function ZM(e){l(e._program)||Hie(e)}function Hie(e){let t=e._program,n=e._gl,i=xMe(n,e,e._debugShaders),o=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),r=SMe(n,i),a=wMe(e,r.uniformsByName);e._program=i,e._numberOfVertexAttributes=o,e._vertexAttributes=TMe(n,i,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=a.automaticUniforms,e._manualUniforms=a.manualUniforms,e.maximumTextureUnitIndex=BMe(n,i,r.samplerUniforms),t&&e._gl.deleteProgram(t),typeof spector<"u"&&(e._program.__SPECTOR_rebuildProgram=function(s,c,u,f){let h=e._vertexShaderText,p=e._fragmentShaderText,A=/ ! = /g;e._vertexShaderText=s.replace(A," != "),e._fragmentShaderText=c.replace(A," != ");try{Hie(e),u(e._program)}catch(m){e._vertexShaderText=h,e._fragmentShaderText=p;let y=/(?:Compile|Link) error: ([^]*)/.exec(m.message);f(y?y[1]:m.message)}})}aA.prototype._bind=function(){ZM(this),this._gl.useProgram(this._program)};aA.prototype._setUniforms=function(e,t,n){let i,o;if(l(e)){let s=this._manualUniforms;for(i=s.length,o=0;o<i;++o){let c=s[o];c.value=e[c.name]()}}let r=this._automaticUniforms;for(i=r.length,o=0;o<i;++o){let s=r[o];s.uniform.value=s.automaticUniform.getValue(t)}let a=this._uniforms;for(i=a.length,o=0;o<i;++o)a[o].set();if(n){let s=this._gl,c=this._program;s.validateProgram(c)}};aA.prototype.isDestroyed=function(){return!1};aA.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};aA.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),fe(this)};var $t=aA;function $M(e){this._context=e}var Tw,DMe=new it({primitiveType:Pe.TRIANGLES}),vMe=new ui({color:new U(0,0,0,0)});function PMe(e,t){return new pa({context:e,colorTextures:[t],destroyAttachments:!1})}function RMe(e,t){return $t.fromCache({context:e,vertexShaderSource:OI,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function MMe(e,t){return(!l(Tw)||Tw.viewport.width!==e||Tw.viewport.height!==t)&&(Tw=Ve.fromCache({viewport:new et(0,0,e,t)})),Tw}$M.prototype.execute=function(e){l(e.preExecute)&&e.preExecute(e);let t=e.outputTexture,n=t.width,i=t.height,o=this._context,r=l(e.vertexArray)?e.vertexArray:o.getViewportQuadVertexArray(),a=l(e.shaderProgram)?e.shaderProgram:RMe(o,e.fragmentShaderSource),s=PMe(o,t),c=MMe(n,i),u=e.uniformMap,f=vMe;f.framebuffer=s,f.renderState=c,f.execute(o);let h=DMe;h.vertexArray=r,h.renderState=c,h.shaderProgram=a,h.uniformMap=u,h.framebuffer=s,h.execute(o),s.destroy(),e.persists||(a.destroy(),l(e.vertexArray)&&r.destroy()),l(e.postExecute)&&e.postExecute(t)};$M.prototype.isDestroyed=function(){return!1};$M.prototype.destroy=function(){return fe(this)};var eN=$M;var Pn={BYTE:ee.BYTE,UNSIGNED_BYTE:ee.UNSIGNED_BYTE,SHORT:ee.SHORT,UNSIGNED_SHORT:ee.UNSI
importScripts("${HW(CESIUM_WORKERS)}"); CesiumWorkers["${i}"](); `;return r=HW(s),new Worker(r,o)}if(r=e,n||(r=Zt(`${ks._workerModulePrefix+i}.js`)),!hn.supportsEsmWebWorkers())throw new ue("This browser is not supported. Please update your browser to continue.");return o.type="module",new Worker(r,o)}async function WMe(e,t){let n={modulePath:void 0,wasmBinaryFile:void 0,wasmBinary:void 0};if(!hn.supportsWebAssembly()){if(!l(t.fallbackModulePath))throw new ue(`This browser does not support Web Assembly, and no backup module was provided for ${e._workerPath}`);return n.modulePath=Zt(t.fallbackModulePath),n}n.wasmBinaryFile=Zt(t.wasmBinaryFile);let i=await De.fetchArrayBuffer({url:n.wasmBinaryFile});return n.wasmBinary=i,n}function ks(e,t){this._workerPath=e,this._maximumActiveTasks=t??Number.POSITIVE_INFINITY,this._activeTasks=0,this._nextID=0,this._webAssemblyPromise=void 0}var jMe=(e,t,n,i)=>{let o=({data:r})=>{if(r.id===t){if(l(r.error)){let a=r.error;a.name==="RuntimeError"?(a=new ue(r.error.message),a.stack=r.error.stack):a.name==="DeveloperError"?(a=new de(r.error.message),a.stack=r.error.stack):a.name==="Error"&&(a=new Error(r.error.message),a.stack=r.error.stack),WW.raiseEvent(a),i(a)}else WW.raiseEvent(),n(r.result);e.removeEventListener("message",o)}};return o},YMe=[];async function qMe(e,t,n){let i=await Promise.resolve(Yie());l(n)?i||(n.length=0):n=YMe;let o=e._nextID++,r=new Promise((a,s)=>{e._worker.addEventListener("message",jMe(e._worker,o,a,s))});return e._worker.postMessage({id:o,baseUrl:Zt.getCesiumBaseUrl().url,parameters:t,canTransferArrayBuffer:i},n),r}async function KMe(e,t,n){++e._activeTasks;try{let i=await qMe(e,t,n);return--e._activeTasks,i}catch(i){throw--e._activeTasks,i}}ks.prototype.scheduleTask=function(e,t){if(l(this._worker)||(this._worker=jW(this._workerPath)),!(this._activeTasks>=this._maximumActiveTasks))return KMe(this,e,t)};ks.prototype.initWebAssemblyModule=async function(e){if(l(this._webAssemblyPromise))return this._webAssemblyPromise;let t=async()=>{let n=this._worker=jW(this._workerPath),i=await WMe(this,e),o=await Promise.resolve(Yie()),r,a=i.wasmBinary;l(a)&&o&&(r=[a]);let s=new Promise((c,u)=>{n.onmessage=function({data:f}){l(f)?c(f.result):u(new ue("Could not configure wasm module"))}});return n.postMessage({canTransferArrayBuffer:o,parameters:{webAssemblyConfig:i}},r),s};return this._webAssemblyPromise=t(),this._webAssemblyPromise};ks.prototype.isDestroyed=function(){return!1};ks.prototype.destroy=function(){return l(this._worker)&&this._worker.terminate(),fe(this)};ks.taskCompletedEvent=WW;ks._defaultWorkerModulePrefix="Workers/";ks._workerModulePrefix=ks._defaultWorkerModulePrefix;ks._canTransferArrayBuffer=void 0;var Zn=ks;function sA(){}sA._transcodeTaskProcessor=new Zn("transcodeKTX2",Number.POSITIVE_INFINITY);sA._readyPromise=void 0;function XMe(){let e=sA._transcodeTaskProcessor.initWebAssemblyModule({wasmBinaryFile:"ThirdParty/basis_transcoder.wasm"}).then(function(t){if(t)return sA._transcodeTaskProcessor;throw new ue("KTX2 transcoder could not be initialized.")});sA._readyPromise=e}sA.transcode=function(e,t){return l(sA._readyPromise)||XMe(),sA._readyPromise.then(function(n){let i=e;e instanceof ArrayBuffer&&(i=new Uint8Array(e));let o={supportedTargetFormats:t,ktx2Buffer:i};return n.scheduleTask(o,[i.buffer])}).then(function(n){let i=n.length,o=Object.keys(n[0]);for(let r=0;r<i;r++){let a=n[r];for(let s=0;s<o.length;s++){let c=a[o[s]];a[o[s]]=new tN(c.internalFormat,c.datatype,c.width,c.height,c.levelBuffer)}}if(o.length===1){for(let r=0;r<i;++r)n[r]=n[r][o[0]];i===1&&(n=n[0])}return n}).catch(function(n){throw n})};var nN=sA;var qie;Kie.setKTX2SupportedFormats=function(e,t,n,i,o,r){qie={s3tc:e,pvrtc:t,astc:n,etc:i,etc1:o,bc7:r}};function Kie(e){let t;return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?t=Promise.resolve(e):t=De.createIfNeeded(e).fetchArrayBuffer(),t.then(function(n){return nN.transcode(n,qie)})}var ku=Kie;function JMe(e,t){this.start=e??0,this.stop=t??0}var ea=JMe;function Cn(e,t){this.center=d.clone(e??d.ZERO),this.radius=t??0}var KW=new d,XW=new d,JW=new d,ZW=new d,$W=new d,ej=new d,tj=new d,Us=new d
* 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 EN=`/** * 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 IN=`/** * 0.1 * * @name czm_epsilon1 * @glslConstant */const float czm_epsilon1 = 0.1;`;var bN=`/** * 0.01 * * @name czm_epsilon2 * @glslConstant */const float czm_epsilon2 = 0.01;`;var xN=`/** * 0.001 * * @name czm_epsilon3 * @glslConstant */const float czm_epsilon3 = 0.001;`;var TN=`/** * 0.0001 * * @name czm_epsilon4 * @glslConstant */const float czm_epsilon4 = 0.0001;`;var SN=`/** * 0.00001 * * @name czm_epsilon5 * @glslConstant */const float czm_epsilon5 = 0.00001;`;var wN=`/** * 0.000001 * * @name czm_epsilon6 * @glslConstant */const float czm_epsilon6 = 0.000001;`;var BN=`/** * 0.0000001 * * @name czm_epsilon7 * @glslConstant */const float czm_epsilon7 = 0.0000001;`;var DN=`/** * 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 vN=`/** * 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 PN=`/** * 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 RN=`/** * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE} * * @name czm_passCesium3DTile * @glslConstant * * @see czm_pass */const float czm_passCesium3DTile = 5.0;`;var MN=`/** * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION} * * @name czm_passCesium3DTileClassification * @glslConstant * * @see czm_pass */const float czm_passCesium3DTileClassification = 6.0;`;var NN=`/** * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW} * * @name czm_passCesium3DTileClassificationIgnoreShow * @glslConstant * * @see czm_pass */const float czm_passCesium3DTileClassificationIgnoreShow = 7.0;`;var LN=`/** * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_EDGES} * * @name czm_passCesium3DTileEdges * @glslConstant * * @see czm_pass */const float czm_passCesium3DTileEdges = 4.0;
`;var ON=`/** * The automatic GLSL constant for {@link Pass#CLASSIFICATION} * * @name czm_passClassification * @glslConstant * * @see czm_pass */const float czm_passClassification = 7.0;`;var FN=`/** * The automatic GLSL constant for {@link Pass#COMPUTE} * * @name czm_passCompute * @glslConstant * * @see czm_pass */const float czm_passCompute = 1.0;`;var QN=`/** * The automatic GLSL constant for {@link Pass#ENVIRONMENT} * * @name czm_passEnvironment * @glslConstant * * @see czm_pass */const float czm_passEnvironment = 0.0;`;var kN=`/** * The automatic GLSL constant for {@link Pass#GAUSSIAN_SPLATS} * * @name czm_passGaussianSplats * @glslConstant * * @see czm_pass */const float czm_passGaussianSplats = 11.0;`;var UN=`/** * The automatic GLSL constant for {@link Pass#GLOBE} * * @name czm_passGlobe * @glslConstant * * @see czm_pass */const float czm_passGlobe = 2.0;`;var zN=`/** * The automatic GLSL constant for {@link Pass#OPAQUE} * * @name czm_passOpaque * @glslConstant * * @see czm_pass */const float czm_passOpaque = 8.0;`;var GN=`/** * The automatic GLSL constant for {@link Pass#OVERLAY} * * @name czm_passOverlay * @glslConstant * * @see czm_pass */const float czm_passOverlay = 12.0;`;var VN=`/** * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION} * * @name czm_passTerrainClassification * @glslConstant * * @see czm_pass */const float czm_passTerrainClassification = 3.0;`;var HN=`/** * The automatic GLSL constant for {@link Pass#TRANSLUCENT} * * @name czm_passTranslucent * @glslConstant * * @see czm_pass */const float czm_passTranslucent = 9.0;`;var WN=`/** * The automatic GLSL constant for {@link Pass#VOXELS} * * @name czm_passVoxels * @glslConstant * * @see czm_pass */const float czm_passVoxels = 10.0;`;var jN=`/** * 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 YN=`/** * 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 qN=`/** * 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 KN=`/** * 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 XN=`/** * 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 JN=`/** * 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 ZN=`/** * 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 $N=`/** * 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 eL=`/** * 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 tL=`/** * 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 nL=`/** * 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 iL=`/** * 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 oL=`/** * 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 rL=`/** * 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 aL=`/** * @name czm_depthRangeStruct * @glslStruct */struct czm_depthRangeStruct{ float near; float far;};`;var sL=`/** * 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 cL=`/** * 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 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.* @property {float} waterMask The value of the water mask. 0 is land, 1 is water. 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; float waterMask;};`;var lL=`/** * 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 {vec4} baseColor The base color of the material. * @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 { vec4 baseColor; vec3 diffuse; float alpha; vec3 specular; float roughness; vec3 normalEC; float occlusion; vec3 emissive;#ifdef USE_SPECULAR float specularWeight;#endif#ifdef USE_ANISOTROPY vec3 anisotropicT; vec3 anisotropicB; float anisotropyStrength;#endif#ifdef USE_CLEARCOAT float clearcoatFactor; float clearcoatRoughness; vec3 clearcoatNormal; // Add clearcoatF0 when KHR_materials_ior is implemented
#endif};`;var uL=`/** * 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 fL=`/** * DOC_TBA * * @name czm_ray * @glslStruct */struct czm_ray{ vec3 origin; vec3 direction;};`;var dL=`/** * 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 hL=`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 mL=`// 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 pL=`/** * @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 AL=`/** * 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 gL=`/** * Apply a HSB color shift to an RGB color. * * @param {vec3} rgb The color in RGB space. * @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment * @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects. * * @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range. */vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) { // Convert rgb color to hsb
vec3 hsb = czm_RGBToHSB(rgb);
// Perform hsb shift
// Hue cycles around so no clamp is needed.
hsb.x += hsbShift.x; // hue
hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation
// brightness
//
// Some shaders such as atmosphere-related effects need to leave black
// pixels unchanged
if (ignoreBlackPixels) { hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0; } else { hsb.z = hsb.z + hsbShift.z; } hsb.z = clamp(hsb.z, 0.0, 1.0);
// Convert shifted hsb back to rgb
return czm_HSBToRGB(hsb);}`;var _L=`/** * 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 yL=`/** * Compute a rational approximation to tanh(x) * * @param {float} x A real number input * @returns {float} An approximation for tanh(x)*/float czm_approximateTanh(float x) { float x2 = x * x; return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));}`;var CL=`/** * 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 EL=`/** * 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 IL=`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 bL=`uniform vec4 shadowMap_cascadeDistances;
float czm_cascadeDistance(vec4 weights){ return dot(shadowMap_cascadeDistances, weights);}`;var xL=`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 TL=`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 SL=`float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) { float signedDistance = texture(clippingDistance, uv).r; return (signedDistance - 0.5) * 2.0;}
void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) { // Position is completely outside of polygons bounds
vec2 rectUv = clippingPosition; if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) { #ifdef CLIPPING_INVERSE discard; #endif return; }
vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0)); vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005)); float dimension = float(extentsLength); if (extentsLength > 2) { dimension = ceil(log2(float(extentsLength))); }
vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension; vec2 uv = textureOffset + rectUv / dimension;
float signedDistance = getSignedDistance(uv, clippingDistance);
#ifdef CLIPPING_INVERSE if (signedDistance > 0.0) { discard; } #else if (signedDistance < 0.0) { discard; } #endif}`;var wL=`/** * DOC_TBA * * @name czm_columbusViewMorph * @glslFunction */vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time){ // Just linear for now.
// We're manually doing the equivalent of a \`mix\` here because, some GPUs
// (NVidia GeForce 3070 Ti and Intel Arc A750, to name two), \`mix\` seems to
// use an alternate formulation that introduces jitter even when \`time\` is
// 0.0 or 1.0. That is, the value of \`p\` won't be exactly \`position2D.xyz\`
// when \`time\` is 0.0 and it won't be exactly \`position3D.xyz\` when \`time\` is
// 1.0. The "textbook" formulation here, while probably a bit slower,
// does not have this problem.
vec3 p = position2D.xyz * (1.0 - time) + position3D.xyz * time; return vec4(p, 1.0);}`;var BL=`/** * Compute the atmosphere color, applying Rayleigh and Mie scattering. This * builtin uses automatic uniforms so the atmophere settings are synced with the * state of the Scene, even in other contexts like Model. * * @name czm_computeAtmosphereColor * @glslFunction * * @param {vec3} positionWC Position of the fragment in world coords (low precision) * @param {vec3} lightDirection Light direction from the sun or other light source. * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function * @param {vec3} mieColor The Mie scattering color computed by a scattering function * @param {float} opacity The opacity computed by a scattering function. */vec4 czm_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 = czm_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) * czm_atmosphereLightIntensity;
return vec4(color, opacity);}
/** * Compute the atmosphere color, applying Rayleigh and Mie scattering. This * builtin uses automatic uniforms so the atmophere settings are synced with the * state of the Scene, even in other contexts like Model. * * @name czm_computeAtmosphereColor * @glslFunction * * @param {czm_ray} primaryRay Ray from the origin to sky fragment to in world coords (low precision) * @param {vec3} lightDirection Light direction from the sun or other light source. * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function * @param {vec3} mieColor The Mie scattering color computed by a scattering function * @param {float} opacity The opacity computed by a scattering function. */vec4 czm_computeAtmosphereColor( czm_ray primaryRay, vec3 lightDirection, vec3 rayleighColor, vec3 mieColor, float opacity) { vec3 direction = normalize(primaryRay.direction);
float cosAngle = dot(direction, lightDirection); float cosAngleSq = cosAngle * cosAngle;
float G = czm_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) * czm_atmosphereLightIntensity;
return vec4(color, opacity);}
`;var DL=`/** * Compute atmosphere scattering for the ground atmosphere and fog. This method * uses automatic uniforms so it is always synced with the scene settings. * * @name czm_computeGroundAtmosphereScattering * @glslfunction * * @param {vec3} positionWC The position of the fragment in world coordinates. * @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. */void czm_computeGroundAtmosphereScattering(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);
czm_computeScattering( primaryRay, length(cameraToPositionWC), lightDirection, atmosphereInnerRadius, rayleighColor, mieColor, opacity );}`;var vL=`/** * 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 PL=`/** * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as * the transmittance value for the ray. This function uses automatic uniforms * so the atmosphere settings are always synced with the current scene. * * @name czm_computeScattering * @glslfunction * * @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. */void czm_computeScattering( czm_ray primaryRay, float primaryRayLength, vec3 lightDirection, float atmosphereInnerRadius, out vec3 rayleighColor, out vec3 mieColor, out float opacity) { const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
const int LIGHT_STEPS_MAX = 4; // Maximum number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
// 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; }
// To deal with smaller values of PRIMARY_STEPS (e.g. 4)
// we implement a split strategy: sky or horizon.
// For performance reasons, instead of a if/else branch
// a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength); // Value close to 0.0: close to the horizon
// Value close to 1.0: above in the sky
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
float start_0 = primaryRayAtmosphereIntersect.start; 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));
// For the number of ray steps, distinguish inside or outside atmosphere (outer space)
// (1) from outer space we have to use more ray steps to get a realistic rendering
// (2) within atmosphere we need fewer steps for faster rendering
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a)); int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
float rayPositionLength = primaryRayAtmosphereIntersect.start; // (1) Outside the atmosphere: constant rayStepLength
// (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength; float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0)); float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
vec3 rayleighAccumulation = vec3(0.0); vec3 mieAccumulation = vec3(0.0); vec2 opticalDepth = vec2(0.0); vec2 heightScale = vec2(czm_atmosphereRayleighScaleHeight, czm_atmosphereMieScaleHeight);
// Sample positions on the primary ray.
for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
// The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if (i >= PRIMARY_STEPS) { break; }
// 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_MAX; ++j) {
// The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if (j >= LIGHT_STEPS) { break; }
// 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(-((czm_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (czm_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));
// Accumulate the scattering.
rayleighAccumulation += sampleDensity.x * attenuation; mieAccumulation += sampleDensity.y * attenuation;
// Increment distance on primary ray.
rayPositionLength += (rayStepLength += rayStepLengthIncrease); }
// Compute the scattering amount.
rayleighColor = czm_atmosphereRayleighCoefficient * rayleighAccumulation; mieColor = czm_atmosphereMieCoefficient * mieAccumulation;
// Compute the transmittance i.e. how much light is passing through the atmosphere.
opacity = length(exp(-((czm_atmosphereMieCoefficient * opticalDepth.y) + (czm_atmosphereRayleighCoefficient * opticalDepth.x))));}`;var RL=`/** * Applies a 2D texture transformation matrix to texture coordinates. * This function applies translation, rotation, and scaling transformations * as specified by the KHR_texture_transform glTF extension. * * @name czm_computeTextureTransform * @glslFunction * * @param {vec2} texCoord The texture coordinates to transform. * @param {mat3} textureTransform The 3x3 transformation matrix. * * @returns {vec2} The transformed texture coordinates. * * @example * // GLSL declaration
* vec2 czm_computeTextureTransform(vec2 texCoord, mat3 textureTransform); * * // Apply texture transform to UV coordinates
* vec2 transformedUV = czm_computeTextureTransform(uv, u_textureTransform); */vec2 czm_computeTextureTransform(vec2 texCoord, mat3 textureTransform){ return vec2(textureTransform * vec3(texCoord, 1.0));}`;var ML=`/** * @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 NL=`/** * Decodes RGB values packed into a single float at 8-bit precision. Encoded * representation is equivalent to 0xFFFFFF in JavaScript. * * @name czm_decodeRGB8 * @glslFunction * * @param {float} encoded Float-encoded RGB values. * @returns {vec4} Decoded RGB values. */vec4 czm_decodeRGB8(float encoded) { const float SHIFT_RIGHT16 = 1.0 / 65536.0; const float SHIFT_RIGHT8 = 1.0 / 256.0; const float SHIFT_LEFT16 = 65536.0; const float SHIFT_LEFT8 = 256.0;
vec4 color = vec4(255.0); color.r = floor(encoded * SHIFT_RIGHT16); color.g = floor((encoded - color.r * SHIFT_LEFT16) * SHIFT_RIGHT8); color.b = floor(encoded - color.r * SHIFT_LEFT16 - color.g * SHIFT_LEFT8); return color / 255.0;}`;var LL=`/** * 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 OL=`// 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 FL=`/** * 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 coordinates
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 QL=`/** * 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 kL=`/** * Approximate uv coordinates based on the ellipsoid normal. * * @name czm_ellipsoidTextureCoordinates * @glslFunction */vec2 czm_ellipsoidTextureCoordinates(vec3 normal){ return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);}`;var UL=`/** * 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 zL=`/** * 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 GL=`/** * 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 VL=`/** * 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 HL=`/** * 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 WL=`/** * 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 jL=`/** * 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 YL=`/** * 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 qL=`/** * Select which direction vector to use for dynamic atmosphere lighting based on an enum value * * @name czm_getDynamicAtmosphereLightDirection * @glslfunction * @see DynamicAtmosphereLightingType.js * * @param {vec3} positionWC the position of the vertex/fragment in world coordinates. This is normalized and returned when dynamic lighting is turned off. * @param {float} lightEnum The enum value for selecting between light sources. * @return {vec3} The normalized light direction vector. Depending on the enum value, it is either positionWC, czm_lightDirectionWC or czm_sunDirectionWC */vec3 czm_getDynamicAtmosphereLightDirection(vec3 positionWC, float lightEnum) { const float NONE = 0.0; const float SCENE_LIGHT = 1.0; const float SUNLIGHT = 2.0;
vec3 lightDirection = positionWC * float(lightEnum == NONE) + czm_lightDirectionWC * float(lightEnum == SCENE_LIGHT) + czm_sunDirectionWC * float(lightEnum == SUNLIGHT); return normalize(lightDirection);}`;var KL=`/** * 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 XL=`/** * 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 JL=`/** * @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 ZL=`/** * 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 $L=`/** * 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 eO=`/** * 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 tO=`/** * 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 nO=`/** * 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 iO=`/** * 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 oO=`/** * 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 rO=`/** * 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 aO=`/** * 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 sO=`/** * 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 cO=`/** * Find the maximum component of a vector. * * @name czm_maximumComponent * @glslFunction * * @param {vec2|vec3|vec4} v The input vector. * @returns {float} The value of the largest component. */float czm_maximumComponent(vec2 v){ return max(v.x, v.y);}float czm_maximumComponent(vec3 v){ return max(max(v.x, v.y), v.z);}float czm_maximumComponent(vec4 v){ return max(max(max(v.x, v.y), v.z), v.w);}`;var lO=`/** * 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 uO=`/** * 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 positionEC = czm_modelView * position; vec4 q = czm_projection * positionEC; q.xyz /= q.w; // normalized device coordinates
q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
return q;}`;var fO=`/** * 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 dO=`/** * 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 hO=` /** * 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 mO=`/** * Packs a depth value into a vec4 that can be represented by unsigned bytes. * * @name czm_packDepth * @glslFunction * * @param {float} depth The floating-point depth. * @returns {vec4} 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 pO=`vec3 lambertianDiffuse(vec3 diffuseColor){ return diffuseColor / czm_pi;}
vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH){ float versine = 1.0 - VdotH; // pow(versine, 5.0) is slow. See https://stackoverflow.com/a/68793086/10082269
float versineSquared = versine * versine; return f0 + (f90 - f0) * versineSquared * versineSquared * versine;}
#ifdef USE_ANISOTROPY/** * @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent) * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent) * @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates * @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates */float smithVisibilityGGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection){ vec3 roughnessScale = vec3(tangentialRoughness, bitangentRoughness, 1.0); float GGXV = lightDirection.z * length(roughnessScale * viewDirection); float GGXL = viewDirection.z * length(roughnessScale * lightDirection); float v = 0.5 / (GGXV + GGXL); return clamp(v, 0.0, 1.0);}
/** * @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent) * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent) * @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates */float GGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 halfwayDirection){ float roughnessSquared = bitangentRoughness * tangentialRoughness; vec3 f = halfwayDirection * vec3(bitangentRoughness, tangentialRoughness, roughnessSquared); float w2 = roughnessSquared / dot(f, f); return roughnessSquared * w2 * w2 / czm_pi;}#endif
/** * Estimate the geometric self-shadowing of the microfacets in a surface, * using the Smith Joint GGX visibility function. * Note: Vis = G / (4 * NdotL * NdotV) * see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3 * see Real-Time Rendering. Page 331 to 336. * see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
* * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness. * @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source. * @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera. */float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV){ float alphaRoughnessSq = alphaRoughness * alphaRoughness;
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq); float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float GGX = GGXV + GGXL; if (GGX > 0.0) { return 0.5 / GGX; } return 0.0;}
/** * Estimate the fraction of the microfacets in a surface that are aligned with * the halfway vector, which is aligned halfway between the directions from * the fragment to the camera and from the fragment to the light source. * * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness. * @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector. * @return {float} The fraction of microfacets aligned to the halfway vector. */float GGX(float alphaRoughness, float NdotH){ float alphaRoughnessSquared = alphaRoughness * alphaRoughness; float f = (NdotH * alphaRoughnessSquared - NdotH) * NdotH + 1.0; return alphaRoughnessSquared / (czm_pi * f * f);}
/** * Compute the strength of the specular reflection due to direct lighting. * * @param {vec3} normal The surface normal. * @param {vec3} lightDirection The unit vector pointing from the fragment to the light source. * @param {vec3} viewDirection The unit vector pointing from the fragment to the camera. * @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera. * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness. * @return {float} The strength of the specular reflection. */float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float alphaRoughness){ float NdotL = clamp(dot(normal, lightDirection), 0.0, 1.0); float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0); float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV); float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0); float D = GGX(alphaRoughness, NdotH); return G * D;}
/** * 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 {@MaterialStageFS} * </p> * * @name czm_pbrLighting * @glslFunction * * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position * @param {vec3} normalEC The surface normal in eye coordinates * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates. * @param {czm_modelMaterial} The material properties. * @return {vec3} The computed HDR color */vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC, czm_modelMaterial material){ vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC); float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0); float NdotL = clamp(dot(normalEC, lightDirectionEC), 0.001, 1.0);
vec3 f0 = material.specular; float reflectance = czm_maximumComponent(f0); // Typical dielectrics will have reflectance 0.04, so f90 will be 1.0.
// In this case, at grazing angle, all incident energy is reflected.
vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0)); vec3 F = fresnelSchlick2(f0, f90, VdotH);
#if defined(USE_SPECULAR) F *= material.specularWeight; #endif
float alphaRoughness = material.roughness * material.roughness; #ifdef USE_ANISOTROPY mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC); vec3 lightDirection = lightDirectionEC * tbn; vec3 viewDirection = viewDirectionEC * tbn; vec3 halfwayDirection = halfwayDirectionEC * tbn; float anisotropyStrength = material.anisotropyStrength; float tangentialRoughness = mix(alphaRoughness, 1.0, anisotropyStrength * anisotropyStrength); float bitangentRoughness = clamp(alphaRoughness, 0.001, 1.0); float G = smithVisibilityGGX_anisotropic(bitangentRoughness, tangentialRoughness, lightDirection, viewDirection); float D = GGX_anisotropic(bitangentRoughness, tangentialRoughness, halfwayDirection); vec3 specularContribution = F * G * D; #else float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alphaRoughness); vec3 specularContribution = F * specularStrength; #endif
vec3 diffuseColor = material.diffuse; // F here represents the specular contribution
vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);
// Lo = (diffuse + specular) * Li * NdotL
return (diffuseContribution + specularContribution) * NdotL;}`;var AO=`// KhronosGroup https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral
// Input color is non-negative and resides in the Linear Rec. 709 color space.
// Output color is also Linear Rec. 709, but in the [0, 1] range.
vec3 czm_pbrNeutralTonemapping(vec3 color) { const float startCompression = 0.8 - 0.04; const float desaturation = 0.15;
float x = min(color.r, min(color.g, color.b)); float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04); color -= offset;
float peak = max(color.r, max(color.g, color.b)); if (peak < startCompression) return color;
const float d = 1.0 - startCompression; float newPeak = 1.0 - d * d / (peak + d - startCompression); color *= newPeak / peak;
float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0); return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g);}`;var gO=`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 _O=`/** * 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 yO=`/** * 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 CO=`/** * 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 EO=`/** * 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 IO=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords){ return czm_reverseLogDepth(texture(depthTexture, texCoords).r);}`;var bO=`/** * 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 xO=`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 = exp2(log2Depth) - 1.0; return far * (1.0 - near / (depthFromNear + near)) / (far - near);#endif return logZ;}`;var TO=`/** * 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 SO=`/** * 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 wO=`/** * 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 BO=`/** * 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 DO=`/** * 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 vO=`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 PO=`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_SHADOWfloat 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);}#elsefloat 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 RO=`/** * 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 MO=`/** * 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;
vec3 L = 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); return max(L, vec3(0.0));}`;var NO=`/** * 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 LO=`/** * 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 OO=`/** * 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 coordinate at which to sample the texture. */vec4 czm_textureCube(samplerCube sampler, vec3 p) {#if __VERSION__ == 300 return texture(sampler, p);#else return textureCube(sampler, p);#endif}
/** * A wrapper around the textureLod (WebGL2) / textureCube (WebGL1) * function to allow for WebGL 1 support in fragment shaders. * * @name czm_textureCubeLod * @glslFunction * * @param {samplerCube} sampler The sampler. * @param {vec3} p The coordinate at which to sample the texture. * @param {float} lod The mipmap level from which to sample. */vec4 czm_textureCube(samplerCube sampler, vec3 p, float lod) {#if __VERSION__ == 300 return textureLod(sampler, p, lod);#elif defined(GL_EXT_shader_texture_lod) return textureCubeLodEXT(sampler, p, lod);#endif}`;var FO=`/** * 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 QO=`/** * 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; // This check handles the case when NaN values have gotten into \`highDifference\`.
// Such a thing could happen on devices running iOS.
if (length(highDifference) == 0.0) { highDifference = vec3(0); } vec3 lowDifference = low - czm_encodedCameraPositionMCLow;
return vec4(highDifference + lowDifference, 1.0);}`;var kO=`/** * @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 UO=`/** * 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 zO=`vec2 getLookupUv(vec2 dimensions, int i) { int pixY = i / int(dimensions.x); int pixX = i - (pixY * int(dimensions.x)); float pixelWidth = 1.0 / dimensions.x; float pixelHeight = 1.0 / dimensions.y; float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
float v = (float(pixY) + 0.5) * pixelHeight; return vec2(u, v);}
vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) { vec2 textureDimensions = vec2(textureSize(extentsTexture, 0)); return texture(extentsTexture, getLookupUv(textureDimensions, index));}`;var GO=`/** * 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 VO=`/** * 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 HO=`/** * Useful for reinterpreting texture data as higher-precision values. * Only works correctly in WebGL 2, which supports the uint type and bitwise operations. * * @param {float|vec2|vec3|vec4} 1-4 values from a texture lookup (RGBA channels), normalized to [0.0, 1.0]. * @return {uint} Raw bits as an unsigned integer.*/uint czm_unpackTexture(float packedValue) { float rounded = czm_round(packedValue * 255.0); return uint(rounded);}
uint czm_unpackTexture(vec2 packedValue) { vec2 rounded = czm_round(packedValue * 255.0); uint byte0 = uint(rounded.x); uint byte1 = uint(rounded.y); return byte0 | (byte1 << 8);}
uint czm_unpackTexture(vec3 packedValue) { vec3 rounded = czm_round(packedValue * 255.0); uint byte0 = uint(rounded.x); uint byte1 = uint(rounded.y); uint byte2 = uint(rounded.z); return byte0 | (byte1 << 8) | (byte2 << 16);}
uint czm_unpackTexture(vec4 packedValue) { vec4 rounded = czm_round(packedValue * 255.0); uint byte0 = uint(rounded.x); uint byte1 = uint(rounded.y); uint byte2 = uint(rounded.z); uint byte3 = uint(rounded.w); return byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);}`;var WO=`/** * 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 jO=`/** * 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 YO=`#ifdef LOG_DEPTH// 1.0 at the near plane, increasing linearly from there.
out float v_depthFromNearPlusOne;#ifdef SHADOW_MAPout 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 qO=`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 = exp2(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
#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 KO=`// 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 XO=`#ifdef LOG_DEPTHin float v_depthFromNearPlusOne;
#ifdef POLYGON_OFFSETuniform vec2 u_polygonOffset;#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 JO=`/** * 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 ZO=`/** * 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 HI={czm_degreesPerRadian:CN,czm_depthRange:EN,czm_epsilon1:IN,czm_epsilon2:bN,czm_epsilon3:xN,czm_epsilon4:TN,czm_epsilon5:SN,czm_epsilon6:wN,czm_epsilon7:BN,czm_infinity:DN,czm_oneOverPi:vN,czm_oneOverTwoPi:PN,czm_passCesium3DTile:RN,czm_passCesium3DTileClassification:MN,czm_passCesium3DTileClassificationIgnoreShow:NN,czm_passCesium3DTileEdges:LN,czm_passClassification:ON,czm_passCompute:FN,czm_passEnvironment:QN,czm_passGaussianSplats:kN,czm_passGlobe:UN,czm_passOpaque:zN,czm_passOverlay:GN,czm_passTerrainClassification:VN,czm_passTranslucent:HN,czm_passVoxels:WN,czm_pi:jN,czm_piOverFour:YN,czm_piOverSix:qN,czm_piOverThree:KN,czm_piOverTwo:XN,czm_radiansPerDegree:JN,czm_sceneMode2D:ZN,czm_sceneMode3D:$N,czm_sceneModeColumbusView:eL,czm_sceneModeMorphing:tL,czm_solarRadius:nL,czm_threePiOver2:iL,czm_twoPi:oL,czm_webMercatorMaxLatitude:rL,czm_depthRangeStruct:aL,czm_material:sL,czm_materialInput:cL,czm_modelMaterial:lL,czm_modelVertexOutput:uL,czm_ray:fL,czm_raySegment:dL,czm_shadowParameters:hL,czm_acesTonemapping:mL,czm_alphaWeight:pL,czm_antialias:AL,czm_applyHSBShift:gL,czm_approximateSphericalCoordinates:_L,czm_approximateTanh:yL,czm_backFacing:CL,czm_branchFreeTernary:EL,czm_cascadeColor:IL,czm_cascadeDistance:bL,czm_cascadeMatrix:xL,czm_cascadeWeights:TL,czm_clipPolygons:SL,czm_columbusViewMorph:wL,czm_computeAtmosphereColor:BL,czm_computeGroundAtmosphereScattering:DL,czm_computePosition:vL,czm_computeScattering:PL,czm_computeTextureTransform:RL,czm_cosineAndSine:ML,czm_decodeRGB8:NL,czm_decompressTextureCoordinates:LL,czm_depthClamp:OL,czm_eastNorthUpToEyeCoordinates:FL,czm_ellipsoidContainsPoint:QL,czm_ellipsoidTextureCoordinates:kL,czm_equalsEpsilon:UL,czm_eyeOffset:zL,czm_eyeToWindowCoordinates:GL,czm_fastApproximateAtan:VL,czm_fog:HL,czm_gammaCorrect:WL,czm_geodeticSurfaceNormal:jL,czm_getDefaultMaterial:YL,czm_getDynamicAtmosphereLightDirection:qL,czm_getLambertDiffuse:KL,czm_getSpecular:XL,czm_getWaterNoise:JL,czm_HSBToRGB:ZL,czm_HSLToRGB:$L,czm_hue:eO,czm_inverseGamma:tO,czm_isEmpty:nO,czm_isFull:iO,czm_latitudeToWebMercatorFraction:oO,czm_linearToSrgb:rO,czm_lineDistance:aO,czm_luminance:sO,czm_maximumComponent:cO,czm_metersPerPixel:lO,czm_modelToWindowCoordinates:uO,czm_multiplyWithColorBalance:fO,czm_nearFarScalar:dO,czm_octDecode:hO,czm_packDepth:mO,czm_pbrLighting:pO,czm_pbrNeutralTonemapping:AO,czm_phong:gO,czm_planeDistance:_O,czm_pointAlongRay:yO,czm_rayEllipsoidIntersectionInterval:CO,czm_raySphereIntersectionInterval:EO,czm_readDepth:IO,czm_readNonPerspective:bO,czm_reverseLogDepth:xO,czm_RGBToHSB:TO,czm_RGBToHSL:SO,czm_RGBToXYZ:wO,czm_round:BO,czm_saturation:DO,czm_shadowDepthCompare:vO,czm_shadowVisibility:PO,czm_signNotZero:RO,czm_sphericalHarmonics:MO,czm_srgbToLinear:NO,czm_tangentToEyeSpaceMatrix:LO,czm_textureCube:OO,czm_transformPlane:FO,czm_translateRelativeToEye:QO,czm_translucentPhong:kO,czm_transpose:UO,czm_unpackClippingExtents:zO,czm_unpackDepth:GO,czm_unpackFloat:VO,czm_unpackTexture:HO,czm_unpackUint:WO,czm_valueTransform:jO,czm_vertexLogDepth:YO,czm_windowToEyeCoordinates:qO,czm_writeDepthClamp:KO,czm_writeLogDepth:XO,czm_writeNonPerspective:JO,czm_XYZToRGB:ZO};function MLe(e,t){let n=e;return n=n.replaceAll("version 300 es",""),n=n.replaceAll(/(texture\()/g,"texture2D("),t?(n=n.replaceAll(/\n\s*(in)\s+(vec\d|mat\d|float)/g,`varying $2`),/out_FragData_(\d+)/.test(n)&&(n=`#extension GL_EXT_draw_buffers : enable${n}`,n=n.replaceAll(/layout\s+\(location\s*=\s*\d+\)\s*out\s+vec4\s+out_FragData_\d+;/g,""),n=n.replaceAll(/out_FragData_(\d+)/g,"gl_FragData[$1]")),n=n.replaceAll(/layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,""),n=n.replaceAll(/out_FragColor/g,"gl_FragColor"),n=n.replaceAll(/out_FragColor\[(\d+)\]/g,"gl_FragColor[$1]"),/gl_FragDepth/.test(n)&&(n=`#extension GL_EXT_frag_depth : enable${n}`,n=n.replaceAll(/gl_FragDepth/g,"gl_FragDepthEXT")),n=`#ifdef GL_EXT_shader_texture_lod#extension GL_EXT_shader_texture_lod : enable#endif${n}`,n=`#ifdef GL_OES_standard_derivatives#extension GL_OES_standard_derivatives : enable#endif${n}`):(n=n.replaceAll(/(in)\s+(vec\d|mat\d|float)/g,"attribute $2"),n=n.replaceAll(/(out)\s+(vec\d|mat\d|float)\s+([\w]+);/g,"varying $2 $3;")),n=`#version 100${n}`,n}var $O=MLe;function koe(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(t){let n=t.match(/\n/gm).length,i="";for(let o=0;o<n;++o)i+=``;return i})}function Uoe(e,t,n){let i;for(let o=0;o<n.length;++o)n[o].name===e&&(i=n[o]);return l(i)||(t=koe(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function zoe(e,t){if(e.evaluated)return;e.evaluated=!0;let n=e.glslSource.match(/\bczm_[a-zA-Z0-9_]*/g);l(n)&&n!==null&&(n=n.filter(function(i,o){return n.indexOf(i)===o}),n.forEach(function(i){if(i!==e.name&&Cs._czmBuiltinsAndUniforms.hasOwnProperty(i)){let o=Uoe(i,Cs._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(o),o.requiredBy.push(e),zoe(o,t)}}))}function NLe(e){let t=[],n=[];for(;e.length>0;){let o=e.pop();n.push(o),o.requiredBy.length===0&&t.push(o)}for(;t.length>0;){let o=t.shift();e.push(o);for(let r=0;r<o.dependsOn.length;++r){let a=o.dependsOn[r],s=a.requiredBy.indexOf(o);a.requiredBy.splice(s,1),a.requiredBy.length===0&&t.push(a)}}let i=[];for(let o=0;o<n.length;++o)n[o].requiredBy.length!==0&&i.push(n[o])}function LLe(e){let t=[],n=Uoe("main",e,t);zoe(n,t),NLe(t);let i="";for(let o=t.length-1;o>=0;--o)i=`${i+t[o].glslSource}`;return i.replace(n.glslSource,"")}function Goe(e,t,n){let i="",o=e.sources;if(l(o))for(let A=0;A<o.length;++A)i+=`#line 0${o[A]}`;i=koe(i);let r;i=i.replace(/#version\s+(.*?)\n/gm,function(A,m){return r=m,``});let a=[];i=i.replace(/#extension.*\n/gm,function(A){return a.push(A),``}),i=i.replace(/precision\s(lowp|mediump|highp)\s(float|int);/,"");let s=e.pickColorQualifier;l(s)&&(i=Cs.createPickFragmentShaderSource(i,s));let c="",u=a.length;for(let A=0;A<u;A++)c+=a[A];t&&(c+=`#ifdef GL_FRAGMENT_PRECISION_HIGH precision highp float; precision highp int;#else precision mediump float; precision mediump int; #define highp mediump#endif`),n.webgl2&&(c+=`precision highp sampler3D;
`);let f=e.defines;if(l(f))for(let A=0,m=f.length;A<m;++A){let _=f[A];_.length!==0&&(c+=`#define ${_}`)}n.textureFloatLinear&&(c+=`#define OES_texture_float_linear
`),n.floatingPointTexture&&(c+=`#define OES_texture_float
`);let h="";e.includeBuiltIns&&(h=LLe(i)),c+=`#line 0`;let p=h+i;return n.webgl2&&t&&!/layout\s*\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g.test(p)&&!/czm_out_FragColor/g.test(p)&&/out_FragColor/g.test(p)&&(c+=`layout(location = 0) out vec4 out_FragColor;
`),c+=h,c+=i,n.webgl2?c=`#version 300 es${c}`:c=$O(c,t),c}function Cs(e){e=e??V.EMPTY_OBJECT;let t=e.pickColorQualifier;this.defines=l(e.defines)?e.defines.slice(0):[],this.sources=l(e.sources)?e.sources.slice(0):[],this.pickColorQualifier=t,this.includeBuiltIns=e.includeBuiltIns??!0}Cs.prototype.clone=function(){return new Cs({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};Cs.replaceMain=function(e,t){return t=`void ${t}()`,e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g,t)};Cs.prototype.getCacheKey=function(){let t=this.defines.slice().sort().join(","),n=this.pickColorQualifier,i=this.includeBuiltIns,o=this.sources.join(``);return`${t}:${n}:${i}:${o}`};Cs.prototype.createCombinedVertexShader=function(e){return Goe(this,!1,e)};Cs.prototype.createCombinedFragmentShader=function(e){return Goe(this,!0,e)};Cs._czmBuiltinsAndUniforms={};for(let e in HI)HI.hasOwnProperty(e)&&(Cs._czmBuiltinsAndUniforms[e]=HI[e]);for(let e in Og)if(Og.hasOwnProperty(e)){let t=Og[e];typeof t.getDeclaration=="function"&&(Cs._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}Cs.createPickVertexShaderSource=function(e){return`${Cs.replaceMain(e,"czm_old_main")}in vec4 pickColor; out vec4 czm_pickColor; void main() { czm_old_main(); czm_pickColor = pickColor; }`};Cs.createPickFragmentShaderSource=function(e,t){let n=Cs.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 OLe(e,t){let n=e.defines,i=n.length;for(let o=0;o<i;++o)if(n[o]===t)return!0;return!1}function Voe(e,t){let n=e.sources,i=n.length;for(let o=0;o<i;++o)if(n[o].indexOf(t)!==-1)return!0;return!1}function Hoe(e,t){let n=t.length;for(let i=0;i<n;++i){let o=t[i];if(Voe(e,o))return o}}var FLe=["v_normalEC","v_normal"];Cs.findNormalVarying=function(e){return Voe(e,"#ifdef HAS_NORMALS")?OLe(e,"HAS_NORMALS")?"v_normalEC":void 0:Hoe(e,FLe)};var QLe=["v_positionEC"];Cs.findPositionVarying=function(e){return Hoe(e,QLe)};var We=Cs;function rh(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(rh.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});rh.prototype.replaceShaderProgram=function(e){return l(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function kLe(e){let t=Object.keys(e).sort();return JSON.stringify(e,t)}rh.prototype.getShaderProgram=function(e){let t=e.vertexShaderSource,n=e.fragmentShaderSource,i=e.attributeLocations;typeof t=="string"&&(t=new We({sources:[t]})),typeof n=="string"&&(n=new We({sources:[n]}));let o=t.getCacheKey(),r=n.getCacheKey(),a=l(i)?kLe(i):"",s=`${o}:${r}:${a}`,c;if(l(this._shaders[s]))c=this._shaders[s],delete this._shadersToRelease[s];else{let u=this._context,f=t.createCombinedVertexShader(u),h=n.createCombinedFragmentShader(u),p=new $t({gl:u._gl,logShaderCompilation:u.logShaderCompilation,debugShaders:u.debugShaders,vertexShaderSource:t,vertexShaderText:f,fragmentShaderSource:n,fragmentShaderText:h,attributeLocations:i});c={cache:this,shaderProgram:p,keyword:s,derivedKeywords:[],count:0},p._cachedShader=c,this._shaders[s]=c,++this._numberOfShaders}return++c.count,c.shaderProgram};rh.prototype.replaceDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=this._shaders[o];if(l(r)){vj(this,r);let a=i.derivedKeywords.indexOf(t);a>-1&&i.derivedKeywords.splice(a,1)}return this.createDerivedShaderProgram(e,t,n)};rh.prototype.getDerivedShaderProgram=function(e,t){let n=e._cachedShader,i=t+n.keyword,o=this._shaders[i];if(l(o))return o.shaderProgram};rh.prototype.createDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=n.vertexShaderSource,a=n.fragmentShaderSource,s=n.attributeLocations;typeof r=="string"&&(r=new We({sources:[r]})),typeof a=="string"&&(a=new We({sources:[a]}));let c=this._context,u=r.createCombinedVertexShader(c),f=a.createCombinedFragmentShader(c),h=new $t({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:r,vertexShaderText:u,fragmentShaderSource:a,fragmentShaderText:f,attributeLocations:s}),p={cache:this,shaderProgram:h,keyword:o,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),h._cachedShader=p,this._shaders[o]=p,h};function vj(e,t){let n=t.derivedKeywords,i=n.length;for(let o=0;o<i;++o){let r=n[o]+t.keyword,a=e._shaders[r];vj(e,a)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}rh.prototype.destroyReleasedShaderPrograms=function(){let e=this._shadersToRelease;for(let t in e)if(e.hasOwnProperty(t)){let n=e[t];vj(this,n),--this._numberOfShaders}this._shadersToRelease={}};rh.prototype.releaseShaderProgram=function(e){if(l(e)){let t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};rh.prototype.isDestroyed=function(){return!1};rh.prototype.destroy=function(){let e=this._shaders;for(let t in e)e.hasOwnProperty(t)&&e[t].shaderProgram.finalDestroy();return fe(this)};var e1=rh;function ah(e){e=e??V.EMPTY_OBJECT;let{context:t,source:n,pixelFormat:i=Ke.RGBA,pixelDatatype:o=He.UNSIGNED_BYTE,flipY:r=!0,skipColorSpaceConversion:a=!1,sampler:s=new jt}=e,{width:c,height:u}=e;l(n)&&(l(c)||(c=n.videoWidth??n.naturalWidth??n.width),l(u)||(u=n.videoHeight??n.naturalHeight??n.height));let f=e.preMultiplyAlpha||i===Ke.RGB||i===Ke.LUMINANCE,h=Ke.toInternalFormat(i,o,t),p=Ke.isCompressedFormat(h),A=t._gl,m=p?Ke.compressedTextureSizeInBytes(i,c,u):Ke.textureSizeInBytes(i,o,c,u);this._id=e.id??Jn(),this._context=t,this._textureFilterAnisotropic=t._t
`),r=new We({defines:this._vertexShaderParts.defineLines,sources:[o]}),a=this._fragmentShaderParts.uniformLines.concat(this._fragmentShaderParts.varyingLines,n.fragmentLines,i.fragmentLines,this._fragmentShaderParts.shaderLines).join(``),s=new We({defines:this._fragmentShaderParts.defineLines,sources:[a]});return $t.fromCache({context:e,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:this._attributeLocations})};ul.prototype.clone=function(){return Ye(this,!0)};function O1e(e){let t=[],n=[],i,o=e._vertexShaderParts.structIds,r,a,s;for(i=0;i<o.length;i++)r=o[i],a=e._structs[r],s=a.generateGlslLines(),oi(t,s);for(o=e._fragmentShaderParts.structIds,i=0;i<o.length;i++)r=o[i],a=e._structs[r],s=a.generateGlslLines(),oi(n,s);return{vertexLines:t,fragmentLines:n}}function F1e(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function Q1e(e){let t=[],n=[],i,o=e._vertexShaderParts.functionIds,r,a,s;for(i=0;i<o.length;i++)r=o[i],a=e._functions[r],s=a.generateGlslLines(),oi(t,s);for(o=e._fragmentShaderParts.functionIds,i=0;i<o.length;i++)r=o[i],a=e._functions[r],s=a.generateGlslLines(),oi(n,s);return{vertexLines:t,fragmentLines:n}}var Xg=ul;function f1(e){this._autoDestroy=e?.autoDestroy??!0,this._canvas=document.createElement("canvas"),this._context=new YI(this._canvas,Ye(e?.contextOptions)),this._canvases=[]}f1.prototype.createSceneContext=function(e){let t=e.getContext("2d",{alpha:!0}),n=this;n._canvases.push(e);let i=!1,o=function(){i=!0;let c=n._canvases.indexOf(e);c!==-1&&(n._canvases.splice(c,1),n._autoDestroy&&n._canvases.length===0&&n.destroy())},r=function(){let c=n._context.canvas,u=this.drawingBufferWidth;c.width<u&&(c.width=u);let f=this.drawingBufferHeight;c.height<f&&(c.height=f)},a=function(){let c=this.drawingBufferWidth,u=this.drawingBufferHeight,f=n._context.canvas.height-u;t.drawImage(n._context.canvas,0,f,c,u,0,0,c,u),n._context.endFrame()};return new Proxy(this._context,{get(c,u,f){if(u==="isDestroyed")return function(){return i};switch(u){case"_canvas":return e;case"destroy":return o;case"drawingBufferWidth":return e.width;case"drawingBufferHeight":return e.height;case"beginFrame":return r;case"endFrame":return a;default:return Reflect.get(c,u,f)}}})};f1.prototype.destroy=function(){this._context.destroy(),fe(this)};f1.prototype.isDestroyed=function(){return!1};var d1=f1;function HC(e){e=e??V.EMPTY_OBJECT;let t=e.context;if(!t._webgl2)throw new de("A WebGL 2 context is required to use Sync operations.");let n=t._gl,i=n.fenceSync(ee.SYNC_GPU_COMMANDS_COMPLETE,0);this._gl=n,this._sync=i}HC.create=function(e){return new HC(e)};HC.prototype.getStatus=function(){return this._gl.getSyncParameter(this._sync,ee.SYNC_STATUS)};HC.prototype.isDestroyed=function(){return!1};HC.prototype.destroy=function(){return this._gl.deleteSync(this._sync),fe(this)};HC.prototype.waitForSignal=async function(e,t){let n=this;t=t??10;function i(o,r,a){return()=>{n.getStatus()===ee.SIGNALED?o():a<=0?r(new ue("Wait for signal timeout")):e(i(o,r,a-1))}}return new Promise((o,r)=>{e(i(o,r,t))})};var h1=HC;function Jg(e){e=e??V.EMPTY_OBJECT;let{context:t,source:n,pixelFormat:i=Ke.RGBA,pixelDatatype:o=He.UNSIGNED_BYTE,flipY:r=!0,skipColorSpaceConversion:a=!1,sampler:s=new jt}=e;if(!t.webgl2&&!l(t.options.getWebGLStub))throw new de("WebGL1 does not support texture3D. Please use a WebGL2 context.");let{width:c,height:u,depth:f}=e;l(n)&&(l(c)||(c=n.width),l(u)||(u=n.height),l(f)||(f=n.depth));let h=e.preMultiplyAlpha||i===Ke.RGB||i===Ke.LUMINANCE,p=Ke.toInternalFormat(i,o,t),A=Ke.isCompressedFormat(p),m=t._gl,_=Ke.texture3DSizeInBytes(i,o,c,u,f);if(this._id=e.id??Jn(),this._context=t,this._textureFilterAnisotropic=t._textureFilterAnisotropic,this._textureTarget=m.TEXTURE_3D,this._texture=m.createTexture(),this._internalFormat=p,this._pixelFormat=i,this._pixelDatatype=o,this._width=c,this._height=u,this._depth=f,this._dimensions=new d(c,u,f),this._hasMipmap=!1,this._sizeInBytes=_,this._preMultiplyAlpha=h,this._flipY=r,this._initialized=!1,this._sampler=void 0,this._sampler=s,Bre(this,s),m.activeTexture(m.TEXTURE0),m.bindTexture(this._textureTarget,this._texture),l(n)){if(a?m.pixelStorei(m.UNPACK_COLORSPACE_CONVERSION_WEBGL,m.NONE):m.pixelStorei(m.UNPACK_COLORSPACE_CONVERSION_WEBGL,m.BROWSER_DEFAULT_WEBGL),!l(n.arrayBufferVi
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 _1=`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 y1=`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 C1=`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 E1=`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 I1=`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 EFe={ADD:ee.FUNC_ADD,SUBTRACT:ee.FUNC_SUBTRACT,REVERSE_SUBTRACT:ee.FUNC_REVERSE_SUBTRACT,MIN:ee.MIN,MAX:ee.MAX},Lc=Object.freeze(EFe);var IFe={ZERO:ee.ZERO,ONE:ee.ONE,SOURCE_COLOR:ee.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:ee.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:ee.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:ee.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:ee.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:ee.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:ee.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:ee.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:ee.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:ee.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:ee.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:ee.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:ee.SRC_ALPHA_SATURATE},Zo=Object.freeze(IFe);var bFe={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:Lc.ADD,equationAlpha:Lc.ADD,functionSourceRgb:Zo.SOURCE_ALPHA,functionSourceAlpha:Zo.ONE,functionDestinationRgb:Zo.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Zo.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:Lc.ADD,equationAlpha:Lc.ADD,functionSourceRgb:Zo.ONE,functionSourceAlpha:Zo.ONE,functionDestinationRgb:Zo.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Zo.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:Lc.ADD,equationAlpha:Lc.ADD,functionSourceRgb:Zo.SOURCE_ALPHA,functionSourceAlpha:Zo.ONE,functionDestinationRgb:Zo.ONE,functionDestinationAlpha:Zo.ONE})},sn=Object.freeze(bFe);var xFe={FRONT:ee.FRONT,BACK:ee.BACK,FRONT_AND_BACK:ee.FRONT_AND_BACK},Li=Object.freeze(xFe);function $I(e){e=e??V.EMPTY_OBJECT,this.material=e.material,this.translucent=e.translucent??!0,this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=e.closed??!1}Object.defineProperties($I.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}}});$I.prototype.getFragmentShaderSource=function(){let e=[];return this.flat&&e.push("#define FLAT"),this.faceForward&&e.push("#define FACE_FORWARD"),l(this.material)&&e.push(this.material.shaderSource),e.push(this.fragmentShaderSource),e.join(``)};$I.prototype.isTranslucent=function(){return l(this.material)&&this.material.isTranslucent()||!l(this.material)&&this.translucent};$I.prototype.getRenderState=function(){let e=this.isTranslucent(),t=Ye(this.renderState,!1);return e?(t.depthMask=!1,t.blending=sn.ALPHA_BLEND):t.depthMask=!0,t};$I.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=sn.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:Li.BACK}),l(n)&&(i=Pt(n,i,!0)),i};var xo=$I;var b1=`uniform sampler2D image;
czm_material czm_getMaterial(czm_materialInput materialInput){ czm_material material = czm_getDefaultMaterial(materialInput); vec4 rampColor = texture(image, vec2(materialInput.aspect / (2.0 * czm_pi), 0.5)); rampColor = czm_gammaCorrect(rampColor); material.diffuse = rampColor.rgb; material.alpha = rampColor.a; return material;}`;var x1=`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 T1=`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 S1=`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 w1=`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 B1=`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 D1=`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 v1=`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 P1=`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 R1=`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 M1=`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 N1=`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 L1=`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 O1=`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 F1=`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 Q1=`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 k1=`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 U1=`uniform vec4 waterColor;uniform vec4 landColor;
czm_material czm_getMaterial(czm_materialInput materialInput){ czm_material material = czm_getDefaultMaterial(materialInput);
vec4 outColor = mix(landColor, waterColor, materialInput.waterMask); outColor = czm_gammaCorrect(outColor);
material.diffuse = outColor.rgb; material.alpha = outColor.a;
return material;}`;var z1=`// 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 $e(e){this.type=void 0,this.autoDestroyOldTexture=e.autoDestroyOldTexture??!0,this.shaderSource=void 0,this.materials=void 0,this.uniforms=void 0,this._uniforms=void 0,this.translucent=void 0,this._minificationFilter=e.minificationFilter??Wt.LINEAR,this._magnificationFilter=e.magnificationFilter??si.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,this._initializationPromises=[],this._initializationError=void 0,TFe(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1},minificationFilter:{get:function(){return this._minificationFilter},set:function(t){this._minificationFilter=t}},magnificationFilter:{get:function(){return this._magnificationFilter},set:function(t){this._magnificationFilter=t}}}),l($e._uniformList[this.type])||($e._uniformList[this.type]=Object.keys(this._uniforms))}$e._uniformList={};$e.fromType=function(e,t){let n=new $e({fabric:{type:e}});if(l(t))for(let i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};$e.fromTypeAsync=async function(e,t){let n=[],i=new $e({fabric:{type:e,uniforms:t}});if(kre(i,n),await Promise.all(n),n.length=0,l(i._initializationError))throw i._initializationError;return i};function kre(e,t){t.push(...e._initializationPromises);let n=e.materials;for(let i in n)if(n.hasOwnProperty(i)){let o=n[i];kre(o,t)}}$e.prototype.isTranslucent=function(){if(l(this.translucent))return typeof this.translucent=="function"?this.translucent():this.translucent;let e=!0,t=this._translucentFunctions,n=t.length;for(let i=0;i<n;++i){let o=t[i];if(typeof o=="function"?e=e&&o():e=e&&o,!e)break}return e};$e.prototype.update=function(e){this._defaultTexture=e.defaultTexture;let t,n,i=this._loadedImages,o=i.length;for(t=0;t<o;++t){let c=i[t];n=c.id;let u=c.image,f;Array.isArray(u)&&(f=u.slice(1,u.length).map(function(_){return _.bufferView}),u=u[0]);let h=new jt({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter}),p;l(u.internalFormat)?p=new vt({context:e,pixelFormat:u.internalFormat,width:u.width,height:u.height,source:{arrayBufferView:u.bufferView,mipLevels:f},sampler:h}):p=new vt({context:e,source:u,sampler:h});let A=this._textures[n];l(A)&&A!==this._defaultTexture&&A.destroy(),this._textures[n]=p;let m=`${n}Dimensions`;if(this.uniforms.hasOwnProperty(m)){let _=this.uniforms[m];_.x=p._width,_.y=p._height}}i.length=0;let r=this._loadedCubeMaps;for(o=r.length,t=0;t<o;++t){let c=r[t];n=c.id;let u=c.images,f=new ta({context:e,source:{positiveX:u[0],negativeX:u[1],positiveY:u[2],negativeY:u[3],positiveZ:u[4],negativeZ:u[5]},sampler:new jt({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[n]=f}r.length=0;let a=this._updateFunctions;for(o=a.length,t=0;t<o;++t)a[t](this,e);let s=this.materials;for(let c in s)s.hasOwnProperty(c)&&s[c].update(e)};$e.prototype.isDestroyed=function(){return!1};$e.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 fe(this)};function TFe(e,t){e=e??V.EMPTY_OBJECT,t._strict=e.strict??!1,t._count=e.count??0,t._template=Ye(e.fabric??V.EMPTY_OBJECT),t.fabric=Ye(e.fabric??V.EMPTY_OBJECT),t._template.uniforms=Ye(t._template.uniforms??V.EMPTY_OBJECT),t._template.materials=Ye(t._template.materials??V.EMPTY_OBJECT),t.type=l(t._template.type)?t._template.type:Jn(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];let n,i=$e._materialCache.getMaterial(t.type);if(l(i)){let r=Ye(i.fabric,!0);t._template=Pt(t._template,r,!0),n=i.translucent}DFe(t),PFe(t),LFe(t),FFe(t),l(i)||$e._materialCache.addMaterial(t.type,t);let o=t._translucentFunctions.length===0?!0:void 0;if(n=n??o,n=e.translucent??n,l(n))if(typeof n=="function"){let r=function(){return n(t)};t._translucentFunctions.push(r)}else t._translucentFunctions
`;else{if(e.shaderSource+=`czm_material czm_getMaterial(czm_materialInput materialInput){`,e.shaderSource+=`czm_material material = czm_getDefaultMaterial(materialInput);`,l(t)){let i=Object.keys(e._template.materials).length>0;for(let o in t)if(t.hasOwnProperty(o))if(o==="diffuse"||o==="emission"){let a=i&&vFe(t[o],e)?t[o]:`czm_gammaCorrect(${t[o]})`;e.shaderSource+=`material.${o} = ${a}; `}else o==="alpha"?e.shaderSource+=`material.alpha = ${t.alpha}; `:e.shaderSource+=`material.${o} = ${t[o]};`}e.shaderSource+=`return material;}`}}var Qre={mat2:Ki,mat3:J,mat4:P},RFe=/\.ktx2$/i;function MFe(e){let t;return function(n,i){let o=n.uniforms,r=o[e],a=t!==r,s=!l(r)||r===$e.DefaultImageId;t=r;let c=n._textures[e],u,f;if(r instanceof HTMLVideoElement){if(r.readyState>=2){if(a&&l(c)&&(c!==i.defaultTexture&&c.destroy(),c=void 0),!l(c)||c===i.defaultTexture){let h=new jt({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new vt({context:i,source:r,sampler:h}),n._textures[e]=c;return}c.copyFrom({source:r})}else l(c)||(n._textures[e]=i.defaultTexture);return}if(r instanceof vt&&r!==c){n._texturePaths[e]=void 0;let h=n._textures[e];l(h)&&h!==n._defaultTexture&&!h.isDestroyed()&&n.autoDestroyOldTexture&&h.destroy(),n._textures[e]=r,u=`${e}Dimensions`,o.hasOwnProperty(u)&&(f=o[u],f.x=r._width,f.y=r._height);return}if(a&&l(c)&&s&&(c!==n._defaultTexture&&c.destroy(),c=void 0,n._texturePaths[e]=void 0),l(c)||(c=n._textures[e]=n._defaultTexture,u=`${e}Dimensions`,o.hasOwnProperty(u)&&(f=o[u],f.x=c._width,f.y=c._height)),!s){if((r instanceof HTMLCanvasElement||r instanceof HTMLImageElement||r instanceof ImageBitmap||r instanceof OffscreenCanvas)&&r!==n._texturePaths[e]){n._loadedImages.push({id:e,image:r}),n._texturePaths[e]=r;return}Ure(n,e)}}}function Ure(e,t){let i=e.uniforms[t];if(i===$e.DefaultImageId)return Promise.resolve();let o=De.createIfNeeded(i);if(!(o instanceof De))return Promise.resolve();let r=De.createIfNeeded(e._texturePaths[t]);if(!(!l(r)||r.url!==o.url))return Promise.resolve();let s;return RFe.test(o.url)?s=ku(o.url):s=o.fetchImage(),Promise.resolve(s).then(function(c){e._loadedImages.push({id:t,image:c})}).catch(function(c){e._initializationError=c;let u=e._textures[t];l(u)&&u!==e._defaultTexture&&u.destroy(),e._textures[t]=e._defaultTexture}),e._texturePaths[t]=i,s}function NFe(e){return function(t,n){let i=t.uniforms[e];if(i instanceof ta){let o=t._textures[e];o!==t._defaultTexture&&o.destroy(),t._texturePaths[e]=void 0,t._textures[e]=i;return}l(t._textures[e])||(t._textures[e]=n.defaultCubeMap),zre(t,e)}}function zre(e,t){let i=e.uniforms[t];if(i===$e.DefaultCubeMapId)return Promise.resolve();let o=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(o===e._texturePaths[t])return Promise.resolve();let r=[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()],a=Promise.all(r);return a.then(function(s){e._loadedCubeMaps.push({id:t,images:s})}).catch(function(s){e._initializationError=s}),e._texturePaths[t]=o,a}function LFe(e){let t=e._template.uniforms;for(let n in t)t.hasOwnProperty(n)&&Gre(e,n)}function Gre(e,t){let n=e._strict,i=e._template.uniforms,o=i[t],r=OFe(o),a;if(r==="channels")a=zw(e,t,o,!1);else{if(r==="sampler2D"){let u=`${t}Dimensions`;QFe(e,u)>0&&(i[u]={type:"ivec3",x:1,y:1},Gre(e,u))}if(!new RegExp(`uniform\\s+${r}\\s+${t}\\s*;`).test(e.shaderSource)){let u=`uniform ${r} ${t};`;e.shaderSource=u+e.shaderSource}let c=`${t}_${e._count++}`;if(a=zw(e,t,c),e.uniforms[t]=o,r==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(MFe(t)),e._initializationPromises.push(Ure(e,t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(NFe(t)),e._initializationPromises.push(zre(e,t));else if(r.indexOf("mat")!==-1){let u=new Qre[r];e._uniforms[c]=function(){return Qre[r].fromColumnMajorArray(e.uniforms[t],u)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function OFe(e){let t=e.type;if(!l(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||e instanceof ImageBitmap||e instanceof OffscreenCanvas||e instanceof vt)/^([rgba]){1,4}$/i.test(e)?t="channels":e===$e.DefaultCubeMapId?t="samplerCube":t="sampler2D";else if(n==="object")if(Array.isArray(e))(e.length===4||e.length===
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 V1=`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 eb=`in vec4 v_color;
void main(){ out_FragColor = czm_gammaCorrect(v_color);}`;var H1=`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 lA(e){e=e??V.EMPTY_OBJECT;let t=e.translucent??!0,n=e.closed??!1,i=e.flat??!1,o=i?H1:V1,r=i?eb:G1,a=i?lA.FLAT_VERTEX_FORMAT:lA.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??o,this._fragmentShaderSource=e.fragmentShaderSource??r,this._renderState=xo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=a,this._flat=i,this._faceForward=e.faceForward??!n}Object.defineProperties(lA.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}}});lA.VERTEX_FORMAT=ke.POSITION_AND_NORMAL;lA.FLAT_VERTEX_FORMAT=ke.POSITION_ONLY;lA.prototype.getFragmentShaderSource=xo.prototype.getFragmentShaderSource;lA.prototype.isTranslucent=xo.prototype.isTranslucent;lA.prototype.getRenderState=xo.prototype.getRenderState;var gn=lA;function tb(e){this._definitionChanged=new _e,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(tb.prototype,{isConstant:{get:function(){return q.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:Ae("color")});tb.prototype.getType=function(e){return"Color"};var kFe=new X;tb.prototype.getValue=function(e,t){return l(e)||(e=X.now(kFe)),l(t)||(t={}),t.color=q.getValueOrClonedDefault(this._color,e,U.WHITE,t.color),t};tb.prototype.equals=function(e){return this===e||e instanceof tb&&q.equals(this._color,e._color)};var Kt=tb;function t_(e){e=e??V.EMPTY_OBJECT,this._ellipsoid=e.ellipsoid??te.default,this._rectangle=e.rectangle??ce.MAX_VALUE,this._projection=new qi(this._ellipsoid),this._numberOfLevelZeroTilesX=e.numberOfLevelZeroTilesX??2,this._numberOfLevelZeroTilesY=e.numberOfLevelZeroTilesY??1}Object.defineProperties(t_.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});t_.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};t_.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};t_.prototype.rectangleToNativeRectangle=function(e,t){let n=D.toDegrees(e.west),i=D.toDegrees(e.south),o=D.toDegrees(e.east),r=D.toDegrees(e.north);return l(t)?(t.west=n,t.south=i,t.east=o,t.north=r,t):new ce(n,i,o,r)};t_.prototype.tileXYToNativeRectangle=function(e,t,n,i){let o=this.tileXYToRectangle(e,t,n,i);return o.west=D.toDegrees(o.west),o.south=D.toDegrees(o.south),o.east=D.toDegrees(o.east),o.north=D.toDegrees(o.north),o};t_.prototype.tileXYToRectangle=function(e,t,n,i){let o=this._rectangle,r=this.getNumberOfXTilesAtLevel(n),a=this.getNumberOfYTilesAtLevel(n),s=o.width/r,c=e*s+o.west,u=(e+1)*s+o.west,f=o.height/a,h=o.north-t*f,p=o.north-(t+1)*f;return l(i)||(i=new ce(c,p,u,h)),i.west=c,i.south=p,i.east=u,i.north=h,i};t_.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!ce.contains(i,e))return;let o=this.getNumberOfXTilesAtLevel(t),r=this.getNumberOfYTilesAtLevel(t),a=i.width/o,s=i.height/r,c=e.longitude;i.east<i.west&&(c+=D.TWO_PI);let u=(c-i.west)/a|0;u>=o&&(u=o-1);let f=(i.north-e.latitude)/s|0;return f>=r&&(f=r-1),l(n)?(n.x=u,n.y=f,n):new Q(u,f)};var Ji=t_;var Vre=new d,Hre=new d,Wre=new me,Vj=new d,UFe=new d,jre=new le,zFe=new Ji,Gw=[new me,new me,new me,new me],Vw=new Q,ga={};ga.initialize=function(){let e=ga._initPromise;return l(e)||(e=De.fetchJson(Zt("Assets/approximateTerrainHeights.json")).then(function(t){ga._terrainHeights=t}),ga._initPromise=e),e};ga.getMinimumMaximumHeights=function(e,t){t=t??te.default;let n=Yre(e),i=ga._defaultMinTerrainHeight,o=ga._defaultMaxTerrainHeight;if(l(n)){let r=`${n.level}-${n.x}-${n.y}`,a=ga._terrainHeights[r];l(a)&&(i=a[0],o=a[1]),t.cartographicToCartesian(ce.northeast(e,Wre),Vre),t
in vec3 position3DLow;in float batchId;
#ifdef EXTRUDED_GEOMETRYin vec3 extrudeDirection;
uniform float u_globeMinimumAltitude;#endif // EXTRUDED_GEOMETRY
#ifdef PER_INSTANCE_COLORout vec4 v_color;#endif // PER_INSTANCE_COLOR
#ifdef TEXTURE_COORDINATES#ifdef SPHERICALout 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 qC=`#ifdef VECTOR_TILEuniform 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 oae={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};oae.NUMBER_OF_CLASSIFICATION_TYPES=3;var ei=Object.freeze(oae);var RQe={NEVER:ee.NEVER,LESS:ee.LESS,EQUAL:ee.EQUAL,LESS_OR_EQUAL:ee.LEQUAL,GREATER:ee.GREATER,NOT_EQUAL:ee.NOTEQUAL,GREATER_OR_EQUAL:ee.GEQUAL,ALWAYS:ee.ALWAYS},hc=Object.freeze(RQe);function MQe(e,t){let n=[],i=e.length,o=0;for(;o<i;){let r=Math.ceil((i-o)/t--);n.push(e.slice(o,o+r)),o+=r}return n}var K1=MQe;function uA(e,t,n){if(this._attributes=t,this._numberOfInstances=n,t.length===0)return;let i=NQe(t),o=e.floatingPointTexture,r=i===He.FLOAT&&!o,a=LQe(t,r),s=OQe(a,t,r),c=Math.floor(Nt.maximumTextureSize/s),u=Math.min(n,c),f=s*u,h=Math.ceil(n/u),p=1/f,A=p*.5,m=1/h,_=m*.5;this._textureDimensions=new Q(f,h),this._textureStep=new ie(p,A,m,_),this._pixelDatatype=r?He.UNSIGNED_BYTE:i,this._packFloats=r,this._offsets=a,this._stride=s,this._texture=void 0;let y=4*f*h;this._batchValues=i===He.FLOAT&&!r?new Float32Array(y):new Uint8Array(y),this._batchValuesDirty=!1}Object.defineProperties(uA.prototype,{attributes:{get:function(){return this._attributes}},numberOfInstances:{get:function(){return this._numberOfInstances}}});function NQe(e){let t=!1,n=e.length;for(let i=0;i<n;++i)if(e[i].componentDatatype!==j.UNSIGNED_BYTE){t=!0;break}return t?He.FLOAT:He.UNSIGNED_BYTE}function aae(e,t){let n=e[t].componentsPerAttribute;return n===2?Q:n===3?d:n===4?ie:Number}function LQe(e,t){let n=new Array(e.length),i=0,o=e.length;for(let r=0;r<o;++r){let s=e[r].componentDatatype;n[r]=i,s!==j.UNSIGNED_BYTE&&t?i+=4:++i}return n}function OQe(e,t,n){let i=e.length,o=e[i-1];return t[i-1].componentDatatype!==j.UNSIGNED_BYTE&&n?o+4:o+1}var Hw=new ie;function FQe(e,t,n){let i=ie.unpack(e,t,Hw),o=ie.unpackFloat(i);i=ie.unpack(e,t+4,Hw);let r=ie.unpackFloat(i);i=ie.unpack(e,t+8,Hw);let a=ie.unpackFloat(i);i=ie.unpack(e,t+12,Hw);let s=ie.unpackFloat(i);return ie.fromElements(o,r,a,s,n)}function QQe(e,t,n){let i=ie.packFloat(e.x,Hw);ie.pack(i,t,n),i=ie.packFloat(e.y,i),ie.pack(i,t,n+4),i=ie.packFloat(e.z,i),ie.pack(i,t,n+8),i=ie.packFloat(e.w,i),ie.pack(i,t,n+12)}var rae=new ie;uA.prototype.getBatchedAttribute=function(e,t,n){let i=this._attributes,o=this._offsets[t],a=4*this._stride*e+4*o,s;this._packFloats&&i[t].componentDatatype!==He.UNSIGNED_BYTE?s=FQe(this._batchValues,a,rae):s=ie.unpack(this._batchValues,a,rae);let c=aae(i,t);return l(c.fromCartesian4)?c.fromCartesian4(s,n):l(c.clone)?c.clone(s,n):s.x};var kQe=[void 0,void 0,new Q,new d,new ie],UQe=new ie;uA.prototype.setBatchedAttribute=function(e,t,n){let i=this._attributes,o=kQe[i[t].componentsPerAttribute],r=this.getBatchedAttribute(e,t,o),a=aae(this._attributes,t);if(l(a.equals)?a.equals(r,n):r===n)return;let c=UQe;c.x=l(n.x)?n.x:n,c.y=l(n.y)?n.y:0,c.z=l(n.z)?n.z:0,c.w=l(n.w)?n.w:0;let u=this._offsets[t],h=4*this._stride*e+4*u;this._packFloats&&i[t].componentDatatype!==He.UNSIGNED_BYTE?QQe(c,this._batchValues,h):ie.pack(c,this._batchValues,h),this._batchValuesDirty=!0};function zQe(e,t){let n=e._textureDimensions;e._texture=new vt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:e._pixelDatatype,width:n.x,height:n.y,sampler:jt.NEAREST,flipY:!1})}function GQe(e){let t=e._textureDimensions;e._texture.copyFrom({source:{width:t.x,height:t.y,arrayBufferView:e._batchValues}})}uA.prototype.update=function(e){l(this._texture)&&!this._batchValuesDirty||this._attributes.length===0||(this._batchValuesDirty=!1,l(this._texture)||zQe(this,e.context),GQe(this))};uA.prototype.getUniformMapCallback=function(){let e=this;return function(t){return e._attributes.length===0?t:Pt(t,{batchTexture:function(){return e._texture},batchTextureDimensions:function(){return e._textureDimensions},batchTextureStep:function(){return e._textureStep}})}};function VQe(e){let t=e._stride;return e._textureDimensions.y===1?`uniform vec4 batchTextureStep; vec2 computeSt(float batchId) { float stepX = batchTextureStep.x; float centerX = batchTextureStep.y; float numberOfAttributes = float(${t}); return vec2(centerX + (batchId * numberOfAttributes * stepX), 0.5); } `:`uniform vec4 batchTextureStep; uniform vec2 batchTextureDimensions; vec2 computeSt(float batchId) { float stepX = batchTextureStep.x; float centerX = batchTextureStep.y; float stepY = batchTextureStep.z; float centerY = batchTextureStep.w; float numberOfAttributes = float(${t}); float xId = mod(batchId * numberOfAttributes, batchTextureDimensions.x); float yId = floor(batchId * numberOfAttributes / batchTextureDimensions.x); return vec2(centerX + (xId * stepX), centerY + (yId * stepY)); } `}function HQe(e){return e===1?"float":`vec${e}`}function WQe(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function jQe(e,t){let i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,a=HQe(o),s=WQe(o),c=e._offsets[t],u=`${a} ${r}(float batchId) { vec2 st = computeSt(batchId); st.x += batchTextureStep.x * float(${c}); `;return e._packFloats&&i.componentDatatype!==He.UNSIGNED_BYTE?u+=`vec4 textureValue; textureValue.x = czm_unpackFloat(texture(batchTexture, st)); textureValue.y = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x, 0.0))); textureValue.z = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 2.0, 0.0))); textureValue.w = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 3.0, 0.0))); `:u+=` vec4 textureValue = texture(batchTexture, st); `,u+=` ${a} value = textureValue${s}; `,e._pixelDatatype===He.UNSIGNED_BYTE&&i.componentDatatype===j.UNSIGNED_BYTE&&!i.normalize?u+=`value *= 255.0; `:e._pixelDatatype===He.FLOAT&&i.componentDatatype===j.UNSIGNED_BYTE&&i.normalize&&(u+=`value /= 255.0; `),u+=` return value; } `,u}uA.prototype.getVertexShaderCallback=function(){let e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture; `;t+=`${VQe(this)}`;let n=e.length;for(let i=0;i<n;++i)t+=jQe(this,i);return function(i){let o=i.indexOf("void main"),r=i.substring(0,o),a=i.substring(o);return`${r}${t}${a}`}};uA.prototype.isDestroyed=function(){return!1};uA.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),fe(this)};var nb=uA;function Xl(e){this._ellipsoid=e??te.WGS84,this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(Xl.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});Xl.mercatorAngleToGeodeticLatitude=function(e){return D.PI_OVER_TWO-2*Math.atan(Math.exp(-e))};Xl.geodeticLatitudeToMercatorAngle=function(e){e>Xl.MaximumLatitude?e=Xl.MaximumLatitude:e<-Xl.MaximumLatitude&&(e=-Xl.MaximumLatitude);let t=Math.sin(e);return .5*Math.log((1+t)/(1-t))};Xl.MaximumLatitude=Xl.mercatorAngleToGeodeticLatitude(Math.PI);Xl.prototype.project=function(e,t){let n=this._semimajorAxis,i=e.longitude*n,o=Xl.geodeticLatitudeToMercatorAngle(e.latitude)*n,r=e.height;return l(t)?(t.x=i,t.y=o,t.z=r,t):new d(i,o,r)};Xl.prototype.unproject=function(e,t){let n=this._oneOverSemimajorAxis,i=e.x*n,o=Xl.mercatorAngleToGeodeticLatitude(e.y*n),r=e.z;return l(t)?(t.longitude=i,t.latitude=o,t.height=r,t):new me(i,o,r)};var mi=Xl;function YQe(e,t,n){let i=!n,o=e.length,r;if(!i&&o>1){let a=e[0].modelMatrix;for(r=1;r<o;++r)if(!P.equals(a,e[r].modelMatrix)){i=!0;break}}if(i)for(r=0;r<o;++r)l(e[r].geometry)&&jn.transformToWorldCoordinates(e[r]);else P.multiplyTransformation(t,e[0].modelMatrix,t)}function Wj(e,t){let n=e.attributes,i=n.position,o=i.values.length/i.componentsPerAttribute;n.batchId=new Me({componentDatatype:j.FLOAT,componentsPerAttribute:1,values:new Float32Array(o)});let r=n.batchId.values;for(let a=0;a<o;++a)r[a]=t}function qQe(e){let t=e.length;for(let n=0;n<t;++n){let i=e[n];l(i.geometry)?Wj(i.geometry,n):l(i.westHemisphereGeometry)&&l(i.eastHemisphereGeometry)&&(Wj(i.westHemisphereGeometry,n),Wj(i.eastHemisphereGeometry,n))}}function KQe(e){let t=e.instances,n=e.projection,i=e.elementIndexUintSupported,o=e.scene3DOnly,r=e.vertexCacheOptimize,a=e.compressVertices,s=e.modelMatrix,c,u,f,h=t.length;for(c=0;c<h;++c)if(l(t[c].geometry)){f=t[c].geometry.primitiveType;break}if(YQe(t,s,o),!o)for(c=0;c<h;++c)l(t[c].geometry)&&jn.splitLongitude(t[c]);if(qQe(t),r)for(c=0;c<h;++c){let A=t[c];l(A.geometry)?(jn.reorderForPostVertexCache(A.geometry),jn.reorderForPreVertexCache(A.geometry)):l(A.westHemisphereGeometry)&&l(A.eastHemisphereGeometry)&&(jn.reorderForPostVertexCache(A.westHemisphereGeometry),jn.reorderForPreVertexCache(A.westHemisphereGeometry),jn.reorderForPostVertexCache(A.eastHemisphereGeometry),jn.reorderForPreVertexCache(A.eastHemisphereGeometry))}let p=jn.combineInstances(t);for(h=p.length,c=0;c<h;++c){u=p[c];let A=u.attributes;if(o)for(let m in A)A.hasOwnProperty(m)&&A[m].componentDatatype===j.DOUBLE&&jn.encodeAttribute(u,m,`${m}3DHigh`,`${m}3DLow`);else for(let m in A)if(A.hasOwnProperty(m)&&A[m].componentDatatype===j.DOUBLE){let _=`${m}3D`,y=`${m}2D`;jn.projectTo2D(u,m,_,y,n),l(u.boundingSphere)&&m==="position"&&(u.boundingSphereCV=le.fromVertices(u.attributes.position2D.values)),jn.encodeAttribute(u,_,`${_}High`,`${_}Low`),jn.encodeAttribute(u,y,`${y}High`,`${y}Low`)}a&&jn.compressVertices(u)}if(!i){let A=[];for(h=p.length,c=0;c<h;++c)u=p[c],A=A.concat(jn.fitToUnsignedShortIndices(u));p=A}return p}function jj(e,t,n,i){let o,r,a,s=i.length-1;if(s>=0){let u=i[s];o=u.offset+u.count,a=u.index,r=n[a].indices.length}else o=0,a=0,r=n[a].indices.length;let c=e.length;for(let u=0;u<c;++u){let h=e[u][t];if(!l(h))continue;let p=h.indices.length;o+p>r&&(o=0,r=n[++a].indices.length),i.push({index:a,offset:o,count:p}),o+=p}}function XQe(e,t){let n=[];return jj(e,"geometry",t,n),jj(e,"westHemisphereGeometry",t,n),jj(e,"eastHemisphereGeometry",t,n),n}var fA={};fA.combineGeometry=function(e){let t,n,i=e.instances,o=i.length,r,a,s=!1;o>0&&(t=KQe(e),t.length>0&&(n=jn.createAttributeLocations(t[0]),e.createPickOffsets&&(r=XQe(i,t))),l(i[0].attributes)&&l(i[0].attributes.offset)&&(a=new Array(o),s=!0));let c=new Array(o),u=new Array(o);for(let f=0;f<o;++f){let h=i[f],p=h.geometry;l(p)&&(c[f]=p.boundingSphere,u[f]=p.boundingSphereCV
`),l(e.rtcCenter)?(t=t.replace(/in\s+vec(?:3|4)\s+position3DHigh;/g,""),t=t.replace(/in\s+vec(?:3|4)\s+position3DLow;/g,""),o+=`uniform mat4 u_modifiedModelView;`,r+=`in vec4 position;`,a+=`${c}{ return u_modifiedModelView * position;}
`,t=t.replace(/czm_modelViewRelativeToEye\s+\*\s+/g,""),t=t.replace(/czm_modelViewProjectionRelativeToEye/g,"czm_projection")):n?a+=`${c}{ return czm_translateRelativeToEye(${s}3DHigh, ${s}3DLow);}
`:(r+=`in vec3 ${s}2DHigh;in vec3 ${s}2DLow;`,a+=`${c}{ vec4 p; if (czm_morphTime == 1.0) { p = czm_translateRelativeToEye(${s}3DHigh, ${s}3DLow); } else if (czm_morphTime == 0.0) { p = czm_translateRelativeToEye(${s}2DHigh.zxy, ${s}2DLow.zxy); } else { p = czm_columbusViewMorph( czm_translateRelativeToEye(${s}2DHigh.zxy, ${s}2DLow.zxy), czm_translateRelativeToEye(${s}3DHigh, ${s}3DLow), czm_morphTime); } return p;}
`)}return[o,r,t,a].join(``)};kr._appendShowToShader=function(e,t){return l(e._batchTableAttributeIndices.show)?`${We.replaceMain(t,"czm_non_show_main")}void main() { czm_non_show_main(); gl_Position *= czm_batchTable_show(batchId); }`:t};kr._updateColorAttribute=function(e,t,n){if(!l(e._batchTableAttributeIndices.color)&&!l(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 lae(e){return`${We.replaceMain(e,"czm_non_pick_main")}out vec4 v_pickColor; void main() { czm_non_pick_main(); v_pickColor = czm_batchTable_pickColor(batchId); }`}function uae(e){return`in vec4 v_pickColor;${e}`}kr._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};kr._appendOffsetToShader=function(e,t){if(!l(e._batchTableAttributeIndices.offset))return t;let n=`in float batchId;`;n+="in float applyOffset;";let i=t.replace(/in\s+float\s+batchId;/g,n),o=`vec4 $1 = czm_computePosition();`;return o+=` if (czm_sceneMode == czm_sceneMode3D)`,o+=` {`,o+=" $1 = $1 + vec4(czm_batchTable_offset(batchId) * applyOffset, 0.0);",o+=` }`,o+=` else`,o+=` {`,o+=" $1 = $1 + vec4(czm_batchTable_offset2D(batchId) * applyOffset, 0.0);",o+=` }`,i=i.replace(/vec4\s+([A-Za-z0-9_]+)\s+=\s+czm_computePosition\(\);/g,o),i};kr._appendDistanceDisplayConditionToShader=function(e,t,n){if(!l(e._batchTableAttributeIndices.distanceDisplayCondition))return t;let i=We.replaceMain(t,"czm_non_distanceDisplayCondition_main"),o=`void main() { czm_non_distanceDisplayCondition_main(); vec2 distanceDisplayCondition = czm_batchTable_distanceDisplayCondition(batchId); vec3 boundingSphereCenter3DHigh = czm_batchTable_boundingSphereCenter3DHigh(batchId); vec3 boundingSphereCenter3DLow = czm_batchTable_boundingSphereCenter3DLow(batchId); float boundingSphereRadius = czm_batchTable_boundingSphereRadius(batchId);`;return n?o+=` vec4 centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);`:o+=` vec3 boundingSphereCenter2DHigh = czm_batchTable_boundingSphereCenter2DHigh(batchId); vec3 boundingSphereCenter2DLow = czm_batchTable_boundingSphereCenter2DLow(batchId); vec4 centerRTE; if (czm_morphTime == 1.0) { centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow); } else if (czm_morphTime == 0.0) { centerRTE = czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy); } else { centerRTE = czm_columbusViewMorph( czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy), czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow), czm_morphTime); }`,o+=` float radiusSq = boundingSphereRadius * boundingSphereRadius; float distanceSq; if (czm_sceneMode == czm_sceneMode2D) { distanceSq = czm_eyeHeight2D.y - radiusSq; } else { distanceSq = dot(centerRTE.xyz, centerRTE.xyz) - radiusSq; } distanceSq = max(distanceSq, 0.0); float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x; float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y; float show = (distanceSq >= nearSq && distanceSq <= farSq) ? 1.0 : 0.0; gl_Position *= show; }`,`${i}${o}`};function fae(e,t){if(!e.compressVertices)return t;let n=t.search(/in\s+vec3\s+normal;/g)!==-1,i=t.search(/in\s+vec2\s+st;/g)!==-1;if(!n&&!i)return t;let o=t.search(/in\s+vec3\s+tangent;/g)!==-1,r=t.search(/in\s+vec3\s+bitangent;/g)!==-1,a=i&&n?2:1;a+=o||r?1:0;let s=a>1?`vec${a}`:"float",c="compressedAttributes",u=`in ${s} ${c};`,f="",h="";if(i){f+=`vec2 st;`;let m=a>1?`${c}.x`:c;h+=` st = czm_decompressTextureCoordinates(${m});`}n&&o&&r?(f+=`vec3 normal;vec3 tangent;vec3 bitangent;`,h+=` czm_octDecode(${c}.${i?"yz":"xy"}, normal, tangent, bitangent);`):(n&&(f+=`vec3 normal;`,h+=` normal = czm_octDecode(${c}${a>1?`.${i?"y":"x"}`:""});`),o&&(f+=`vec3 tangent;`,h+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"});`),r&&(f+=`vec3 bitangent;`,h+=` 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=We.replaceMain(p,"czm_non_compressed_main");let A=`void main() { ${h} czm_non_compressed_main(); }`;return[u,f,p,A].join(``)}function f2e(e){let t=We.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() { czm_non_depth_clamp_main(); gl_Position = czm_depthClamp(gl_Position);}`,t}function d2e(e){let t=We.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 dae(e,t){let n=e.vertexAttributes}function h2e(e,t){return function(){return e[t]}}var Yj=Math.max(hn.hardwareConcurrency-1,1),X1,m2e=new Zn("combineGeometry");function p2e(e,t){let n,i,o,r,a=e._instanceIds;if(e._state===na.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let s=e._numberOfInstances=n.length,c=[],u=[];for(o=0;o<s;++o)i=n[o].geometry,a.push(n[o].id),u.push({moduleName:i._workerName,modulePath:i._workerPath,geometry:i});if(!l(X1))for(X1=new Array(Yj),o=0;o<Yj;o++)X1[o]=new Zn("createGeometry");let f;for(u=K1(u,Yj),o=0;o<u.length;o++){let h=0,p=u[o],A=p.length;for(r=0;r<A;++r)f=p[r],i=f.geometry,l(i.constructor.pack)&&(f.offset=h,h+=i.constructor.packedLength??i.packedLength);let m;if(h>0){let _=new Float64Array(h);for(m=[_.buffer],r=0;r<A;++r)f=p[r],i=f.geometry,l(i.constructor.pack)&&(i.constructor.pack(i,_,f.offset),f.geometry=_)}c.push(X1[o].scheduleTask({subTasks:u[o]},m))}e._state=na.CREATING,Promise.all(c).then(function(h){e._createGeometryResults=h,e._state=na.CREATED}).catch(function(h){jw(e,t,na.FAILED,h)})}else if(e._state===na.CREATED){let s=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let c=t.scene3DOnly,u=t.mapProjection,f=m2e.scheduleTask(ib.packCombineGeometryParameters({createGeometryResults:e._createGeometryResults,instances:n,ellipsoid:u.ellipsoid,projection:u,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:c,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets},s),s);e._createGeometryResults=void 0,e._state=na.COMBINING,Promise.resolve(f).then(function(h){let p=ib.unpackCombineGeometryResults(h);e._geometries=p.geometries,e._attributeLocations=p.attributeLocations,e.modelMatrix=P.clone(p.modelMatrix,e.modelMatrix),e._pickOffsets=p.pickOffsets,e._offsetInstanceExtend=p.offsetInstanceExtend,e._instanceBoundingSpheres=p.boundingSpheres,e._instanceBoundingSpheresCV=p.boundingSpheresCV,l(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=na.COMBINED):jw(e,t,na.FAILED,void 0)}).catch(function(h){jw(e,t,na.FAILED,h)})}}function A2e(e,t){let n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,o=new Array(i),r=e._instanceIds,a,s,c=0;for(s=0;s<i;s++){a=n[s];let p=a.geometry,A;l(p.attributes)&&l(p.primitiveType)?A=c2e(p):A=p.constructor.createGeometry(p),o[c++]=l2e(a,A),r.push(a.id)}o.length=c;let u=t.scene3DOnly,f=t.mapProjection,h=ib.combineGeometry({instances:o,ellipsoid:f.ellipsoid,projection:f,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:u,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets});e._geometries=h.geometries,e._attributeLocations=h.attributeLocations,e.modelMatrix=P.clone(h.modelMatrix,e.modelMatrix),e._pickOffsets=h.pickOffsets,e._offsetInstanceExtend=h.offsetInstanceExtend,e._instanceBoundingSpheres=h.boundingSpheres,e._instanceBoundingSpheresCV=h.boundingSpheresCV,l(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=na.COMBINED):jw(e,t,na.FAILED,void 0)}function g2e(e,t){let n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!l(n)){e._recomputeBoundingSpheres=!1;return}let i,o=e._offsetInstanceExtend,r=e._instanceBoundingSpheres,a=r.length,s=e._tempBoundingSpheres;if(!l(s)){for(s=new Array(a),i=0;i<a;i++)s[i]=new le;e._tempBoundingSpheres=s}for(i=0;i<a;++i){let _=s[i],y=e._batchTable.getBatchedAttribute(i,n,new d);_=r[i].clone(_),Iae(_,y,o[i])}let c=[],u=[],f=[];for(i=0;i<a;++i){let _=s[i];_.center.x-_.radius>0||le.intersectPlane(_,cn.ORIGIN_ZX_PLANE)!==Xt.INTERSECTING?c.push(_):(u.push(_),f.push(_))}let h=c[0],p=f[0],A=u[0];for(i=1;i<c.length;i++)h=le.union(h,c[i]);for(i=1;i<f.length;i++)p=le.union(p,f[i]);for(i=1;i<u.length;i++)A=le.union(A,u[i]);let m=[];for(l(h)&&m.push(h),l(p)&&m.push(p),l(A)&&m.push(A),i=0;i<m.length;i++){let _=m[i].clone(
#ifdef SPHERICALin 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_COLORin vec4 v_color;#endif
#ifdef NORMAL_ECvec3 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 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 PICK out_FragColor.a = 1.0; // Explicitly set the alpha, otherwise this may be discarded by ShaderSource.createPickFragmentShaderSource
#ifdef CULL_FRAGMENTS czm_writeDepthClamp();#endif // CULL_FRAGMENTS
#else // PICK
#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 jf(e,t,n){this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};let i=new Kj;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;let o=new Kj;if(o.requiresTextureCoordinates=e,n instanceof gn)i.requiresNormalEC=!n.flat;else{let r=`${n.material.shaderSource}${n.fragmentShaderSource}`;i.normalEC=r.indexOf("materialInput.normalEC")!==-1||r.indexOf("czm_getDefaultMaterial")!==-1,i.positionToEyeEC=r.indexOf("materialInput.positionToEyeEC")!==-1,i.tangentToEyeMatrix=r.indexOf("materialInput.tangentToEyeMatrix")!==-1,i.st=r.indexOf("materialInput.st")!==-1}this._colorShaderDependencies=i,this._pickShaderDependencies=o,this._appearance=n,this._extentsCulling=e,this._planarExtents=t}jf.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 gn&&i.push("PER_INSTANCE_COLOR"),n.normalEC&&i.push("USES_NORMAL_EC"),n.positionToEyeEC&&i.push("USES_POSITION_TO_EYE_EC"),n.tangentToEyeMatrix&&i.push("USES_TANGENT_TO_EYE"),n.st&&i.push("USES_ST"),t.flat&&i.push("FLAT");let o="";return t instanceof gn||(o=t.material.shaderSource),new We({defines:i,sources:[o,Yw]})};jf.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 We({defines:n,sources:[Yw],pickColorQualifier:"in"})};jf.prototype.createVertexShader=function(e,t,n,i){return vae(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};jf.prototype.createPickVertexShader=function(e,t,n,i){return vae(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};var bae=new d,xae=new me,Tae={high:0,low:0};function vae(e,t,n,i,o,r,a,s){let c=i.slice();if(s.eastMostYhighDefine===""){let u=xae;u.longitude=D.PI,u.latitude=0,u.height=0;let f=a.project(u,bae),h=xn.encode(f.x,Tae);s.eastMostYhighDefine=`EAST_MOST_X_HIGH ${h.high.toFixed(`${h.high}`.length+1)}`,s.eastMostYlowDefine=`EAST_MOST_X_LOW ${h.low.toFixed(`${h.low}`.length+1)}`;let p=xae;p.longitude=-D.PI,p.latitude=0,p.height=0;let A=a.project(p,bae);h=xn.encode(A.x,Tae),s.westMostYhighDefine=`WEST_MOST_X_HIGH ${h.high.toFixed(`${h.high}`.length+1)}`,s.westMostYlowDefine=`WEST_MOST_X_LOW ${h.low.toFixed(`${h.low}`.length+1)}`}return n&&(c.push(s.eastMostYhighDefine),c.push(s.eastMostYlowDefine),c.push(s.westMostYhighDefine),c.push(s.westMostYlowDefine)),l(r)&&r instanceof gn&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new We({defines:c,sources:[o]})}function Kj(){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(Kj.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:
`,r=` extrudeDirection = czm_octDecode(${n}, 65535.0);`,a=t;a=a.replace(/in\s+vec3\s+extrudeDirection;/g,""),a=We.replaceMain(a,"czm_non_compressed_main");let s=`void main() { ${r} czm_non_compressed_main(); }`;return[i,o,a,s].join(``)}}function J2e(e,t){let n=t.context,i=e._primitive,o=q1;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=Ln._appendDistanceDisplayConditionToShader(i,o),o=Ln._modifyShaderPosition(e,o,t.scene3DOnly),o=Ln._updateColorAttribute(i,o);let r=e._hasPlanarExtentsAttributes,a=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=X2e(i,o));let s=e._extruded?"EXTRUDED_GEOMETRY":"",c=new We({defines:[s],sources:[o]}),u=new We({sources:[qC]}),f=e._primitive._attributeLocations,h=new Yf(a,r,e.appearance);if(e._spStencil=$t.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f}),e._primitive.allowPicking){let m=We.createPickVertexShaderSource(o);m=Ln._appendShowToShader(i,m),m=Ln._updatePickColorAttribute(m);let _=h.createPickFragmentShader(!1),y=h.createPickVertexShader([s],m,!1,t.mapProjection);if(e._spPick=$t.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:y,fragmentShaderSource:_,attributeLocations:f}),a){let C=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!l(C)){let E=h.createPickFragmentShader(!0),I=h.createPickVertexShader([s],m,!0,t.mapProjection);C=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:I,fragmentShaderSource:E,attributeLocations:f})}e._spPick2D=C}}else e._spPick=$t.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});o=Ln._appendShowToShader(i,o),c=new We({defines:[s],sources:[o]}),e._sp=$t.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});let p=h.createFragmentShader(!1),A=h.createVertexShader([s],o,!1,t.mapProjection);if(e._spColor=$t.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:A,fragmentShaderSource:p,attributeLocations:f}),a){let m=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!l(m)){let _=h.createFragmentShader(!0),y=h.createVertexShader([s],o,!0,t.mapProjection);m=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:y,fragmentShaderSource:_,attributeLocations:f})}e._spColor2D=m}}function Z2e(e,t){let n=e._primitive,i=n._va.length*2;t.length=i;let o,r,a,s=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap),u=e._needs2DShader;for(o=0;o<i;o+=2){let A=n._va[s++];r=t[o],l(r)||(r=t[o]=new it({owner:e,primitiveType:n._primitiveType})),r.vertexArray=A,r.renderState=e._rsStencilDepthPass,r.shaderProgram=e._sp,r.uniformMap=c,r.pass=Be.TERRAIN_CLASSIFICATION,a=it.shallowClone(r,r.derivedCommands.tileset),a.renderState=e._rsStencilDepthPass3DTiles,a.pass=Be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=a,r=t[o+1],l(r)||(r=t[o+1]=new it({owner:e,primitiveType:n._primitiveType})),r.vertexArray=A,r.renderState=e._rsColorPass,r.shaderProgram=e._spColor,r.pass=Be.TERRAIN_CLASSIFICATION;let _=e.appearance.material;if(l(_)&&(c=Pt(c,_._uniforms)),r.uniformMap=c,a=it.shallowClone(r,r.derivedCommands.tileset),a.pass=Be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=a,u){let y=it.shallowClone(r,r.derivedCommands.appearance2D);y.shaderProgram=e._spColor2D,r.derivedCommands.appearance2D=y,y=it.shallowClone(a,a.derivedCommands.appearance2D),y.shaderProgram=e._spColor2D,a.derivedCommands.appearance2D=y}}let f=e._commandsIgnoreShow,h=e._spStencil,p=0;i=f.length=i/2;for(let A=0;A<i;++A){let m=f[A]=it.shallowClone(t[p],f[A]);m.shaderProgram=h,m.pass=Be.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,p+=2}}function $2e(e,t){let n=e._usePickOffsets,i=e._primitive,o=i._va.length*2,r,a=0,s;n&&(r=i._pickOffsets,o=r.length*2),t.length=o;let c,u,f,h=0,p=i._batchTable.getUniformMapCallback()(e._uniformMap),A=e._needs2DShader;for(c=0;c<o;c+=2){let m=i._va[h++];if(n&&(s=r[a++],m=i._va[s.index]),u=t[c],l(u)||(u=t[c]=new it({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),u.vertexArray=m,u.renderState=e._rsStencilDepthPass,u.shaderProgram=e._sp,u.uniformMap=p,u.pass=Be.TERRAIN_CLASSIFICATION,n&&(u.offset=s.offset,u.count=s.count),f=it.shallowClone(u,u.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_COLORin 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 rF=`in vec3 v_forwardDirectionEC;in vec3 v_texcoordNormalizationAndHalfWidth;in float v_batchId;
#ifdef PER_INSTANCE_COLORin vec4 v_color;#elsein 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 aF=`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_VARYINGout float v_width;#endif#ifdef ANGLE_VARYINGout float v_polylineAngle;#endif
#ifdef PER_INSTANCE_COLORout vec4 v_color;#elseout 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 sF=`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_2Din vec4 startHiAndForwardOffsetX;in vec4 startLoAndForwardOffsetY;in vec4 startNormalAndForwardOffsetZ;in vec4 endNormalAndTextureCoordinateNormalizationX;in vec4 rightNormalAndTextureCoordinateNormalizationY;#elsein 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_VARYINGout float v_width;#endif#ifdef ANGLE_VARYINGout float v_polylineAngle;#endif
#ifdef PER_INSTANCE_COLORout 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 cF=`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 $l=`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 f3e=`#define CLIP_POLYLINE ${$l}${cF}`,d3e=eb;function JC(e){e=e??V.EMPTY_OBJECT;let t=e.translucent??!0,n=!1,i=JC.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??f3e,this._fragmentShaderSource=e.fragmentShaderSource??d3e,this._renderState=xo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(JC.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}}});JC.VERTEX_FORMAT=ke.POSITION_ONLY;JC.prototype.getFragmentShaderSource=xo.prototype.getFragmentShaderSource;JC.prototype.isTranslucent=xo.prototype.isTranslucent;JC.prototype.getRenderState=xo.prototype.getRenderState;var Qa=JC;var lF=`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 cb=`#ifdef VECTOR_TILEuniform 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 h3e=`#define CLIP_POLYLINE ${$l}${lF}`,m3e=cb;function ZC(e){e=e??V.EMPTY_OBJECT;let t=e.translucent??!0,n=!1,i=ZC.VERTEX_FORMAT;this.material=l(e.material)?e.material:Xi.fromType(Xi.ColorType),this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??h3e,this._fragmentShaderSource=e.fragmentShaderSource??m3e,this._renderState=xo.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(ZC.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}}});ZC.VERTEX_FORMAT=ke.POSITION_AND_ST;ZC.prototype.getFragmentShaderSource=xo.prototype.getFragmentShaderSource;ZC.prototype.isTranslucent=xo.prototype.isTranslucent;ZC.prototype.getRenderState=xo.prototype.getRenderState;var mc=ZC;function mA(e){e=e??V.EMPTY_OBJECT,this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;l(t)||(t=new mc),this.appearance=t,this.show=e.show??!0,this.classificationType=e.classificationType??ei.BOTH,this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this._debugShowShadowVolume=e.debugShowShadowVolume??!1,this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:!1,interleave:e.interleave??!1,releaseGeometryInstances:e.releaseGeometryInstances??!0,allowPicking:e.allowPicking??!0,asynchronous:e.asynchronous??!0,compressVertices:!1,_createShaderProgramFunction:void 0,_createCommandsFunction:void 0,_updateAndQueueCommandsFunction:void 0},this._zIndex=void 0,this._ready=!1,this._primitive=void 0,this._sp=void 0,this._sp2D=void 0,this._spMorph=void 0,this._renderState=_se(!1),this._renderState3DTiles=_se(!0),this._renderStateMorph=Ve.fromCache({cull:{enabled:!0,face:Li.FRONT},depthTest:{enabled:!0},blending:sn.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(mA.prototype,{interleave:{get:function(){return this._primitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._primitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._primitiveOptions.allowPicking}},asynchronous:{get:function(){return this._primitiveOptions.asynchronous}},ready:{get:function(){return this._ready}},debugShowShadowVolume:{get:function(){return this._debugShowShadowVolume}}});mA.initializeTerrainHeights=function(){return vi.initialize()};function p3e(e,t,n){let i=t.context,o=e._primitive,r=o._attributeLocations,a=o._batchTable.getVertexShaderCallback()(sF);a=Ln._appendShowToShader(o,a),a=Ln._appendDistanceDisplayConditionToShader(o,a),a=Ln._modifyShaderPosition(e,a,t.scene3DOnly);let s=o._batchTable.getVertexShaderCallback()(aF);s=Ln._appendShowToShader(o,s),s=Ln._appendDistanceDisplayConditionToShader(o,s),s=Ln._modifyShaderPosition(e,s,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(oF),u=[`GLOBE_MINIMUM_ALTITUDE ${t.mapProjection.ellipsoid.minimumRadius.toFixed(1)}`],f="",h="";l(n.material)?(h=l(n.material)?n.material.shaderSource:"",h.search(/in\s+float\s+v_polylineAngle;/g)!==-1&&u.push("ANGLE_VARYING"),h.search(/in\s+float\s+v_width;/g)!==-1&&u.push("WIDTH_VARYING")):f="PER_INSTANCE_COLOR",u.push(f);let p=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",f]:[f],A=new We({defines:u,sources:[a]}),m=new We({defines:p,sources:[h,c]});e._sp=$t.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:A,fragmentShaderSource:m,attributeLocations:r});let _=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!l(_)){let C=new We({defines:u.concat(["COLUMBUS_VIEW_2D"]),sources:[a]});_=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:C,fragmentShaderSource:m,attributeLocations:r})}e._sp2D=_;let y=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!l(y)){let C=new We({defines:u.concat([`MAX_TERRAIN_HEIGHT ${vi._defaultMaxTerrainHeight.toFixed(1)}`]),sources:[s]});c=o._batchTable.getVertexShaderCallback()(rF);let E=new We({defines:p,sources:[h,c]});y=i.shaderCache.createDerivedShaderProgram(e._sp,"MorphColor",{context:i,shaderProgram:e._spMorph,vertexShaderSource:C,fragmentShaderSource:E,attributeLocations:r})}e._spMorph=y}function _se(e){return Ve.fromCache({cull:{enabled:!0},blending:sn.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1,stencilTest:{enabled:e,frontFunction:ti.EQUAL,frontOperation:{fail:wt.KEEP,zFail:wt.KEEP,zPass:wt.KEEP},backFunction:ti.EQUAL,backOperation:{fa
`+ha),Ne&&hF([b,T,B],il=>{ha=AB(ha,il," ")}),x&&je?x.createHTML(ha):ha},t.setConfig=function(){let on=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ui(on),nt=!0},t.clearConfig=function(){Vo=null,nt=!1},t.isValidAttribute=function(on,we,lt){Vo||Ui({});let an=Nn(on),fo=Nn(we);return dm(an,fo,lt)},t.addHook=function(on,we){typeof we=="function"&&pB(g[on],we)},t.removeHook=function(on,we){if(we!==void 0){let lt=aUe(g[on],we);return lt===-1?void 0:sUe(g[on],lt,1)[0]}return Pse(g[on])},t.removeHooks=function(on){g[on]=[]},t.removeAllHooks=function(){g=Fse()},t}var Gse=zse();var xUe=0,I6={};function Lm(e,t){let n,i=e;l(I6[i])?n=I6[i]:(n=xUe++,I6[i]=n),t=t??!1,this._id=n,this._html=e,this._showOnScreen=t,this._element=void 0}Object.defineProperties(Lm.prototype,{html:{get:function(){return this._html}},id:{get:function(){return this._id}},showOnScreen:{get:function(){return this._showOnScreen},set:function(e){this._showOnScreen=e}},element:{get:function(){if(!l(this._element)){let e=Gse.sanitize(this._html),t=document.createElement("div");t.className="cesium-credit-wrapper",t._creditId=this._id,t.style.display="inline",t.innerHTML=e;let n=t.querySelectorAll("a");for(let i=0;i<n.length;i++)n[i].setAttribute("target","_blank");this._element=t}return this._element}}});Lm.equals=function(e,t){return e===t||l(e)&&l(t)&&e._id===t._id&&e._showOnScreen===t._showOnScreen};Lm.prototype.equals=function(e){return Lm.equals(this,e)};Lm.prototype.isIon=function(){return this.html.indexOf("ion-credit.png")!==-1};Lm.getIonCredit=function(e){let t=l(e.collapsible)&&!e.collapsible;return new Lm(e.html,t)};Lm.clone=function(e){if(l(e))return new Lm(e.html,e.showOnScreen)};var Et=Lm;function TUe(e,t){bt(e,t)}var Gs=TUe;function iE(e){this._url=e,this._cubeMapBuffers=void 0,this._texture=void 0,this._maximumMipmapLevel=void 0,this._loading=!1,this._ready=!1,this._errorEvent=new _e}Object.defineProperties(iE.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}}});iE.isSupported=function(e){return(e.colorBufferHalfFloat&&e.halfFloatingPointTexture||e.floatingPointTexture&&e.colorBufferFloat)&&e.supportsTextureLod};function b6(e){e._cubeMapBuffers=void 0}iE.prototype.update=function(e){let{context:t}=e;if(!iE.isSupported(t))return;if(l(this._texture)){b6(this);return}if(!l(this._texture)&&!this._loading){let f=t.textureCache.getTexture(this._url);l(f)&&(b6(this),this._texture=f,this._maximumMipmapLevel=this._texture.maximumMipmapLevel,this._ready=!0)}let n=this._cubeMapBuffers;if(!l(n)&&!this._loading){let f=this;ku(this._url).then(function(h){f._cubeMapBuffers=h,f._loading=!1}).catch(function(h){f.isDestroyed()||f._errorEvent.raiseEvent(h)}),this._loading=!0}if(!l(this._cubeMapBuffers))return;let{pixelDatatype:i}=n[0].positiveX;l(i)||(i=t.halfFloatingPointTexture?He.HALF_FLOAT:He.FLOAT);let o=Ke.RGBA,r=n.length;this._maximumMipmapLevel=r-1;let a=n[0].positiveX.width,s=Math.log2(a)+1;if(r!==s){let f={};Object.values(ta.FaceName).forEach(h=>{f[h]=void 0});for(let h=r;h<s;h++)n.push(f)}let c=new jt({minificationFilter:Wt.LINEAR_MIPMAP_LINEAR}),u=new ta({context:t,source:n[0],flipY:!1,pixelDatatype:i,pixelFormat:o,sampler:c});u.loadMipmaps(n.slice(1)),this._texture=u,this._texture.maximumMipmapLevel=this._maximumMipmapLevel,t.textureCache.addTexture(this._url,this._texture),this._ready=!0};iE.prototype.isDestroyed=function(){return!1};iE.prototype.destroy=function(){return b6(this),this._texture=this._texture&&this._texture.destroy(),fe(this)};var Om=iE;function CB(e){e=e??V.EMPTY_OBJECT;let t=l(e.imageBasedLightingFactor)?Q.clone(e.imageBasedLightingFactor):new Q(1,1);this._imageBasedLightingFactor=t;let n=e.sphericalHarmonicCoefficients;this._sphericalHarmonicCoefficients=n,this._specularEnvironmentMaps=e.specularEnvironmentMaps,this._specularEnvironmentCubeMap=void 0,this._specularEnvironmentCubeMapDirty=!0,this._specularEnvironmentMap
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)); } `}Fo.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;let i=this;return function(o){let r=Zse(o,n,!1),a;return Nt.maximumVertexTextureImageUnits>0?(a="",e&&(a+=`uniform bool tile_translucentCommand; `),a+=`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&&(a+=` 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; } } `),a+=` tile_featureColor = featureProperties; tile_featureSt = st; }`):a=`out vec2 tile_featureSt; void main() { tile_color(vec4(1.0)); tile_featureSt = computeSt(${t}); }`,`${r}${$Ue(i)}${a}`}};function Xse(e,t){return e=We.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 eze(e,t){let n=`texture(${t}`,i=0,o=e.indexOf(n,i),r;for(;o>-1;){let a=0;for(let u=o;u<e.length;++u){let f=e.charAt(u);if(f==="(")++a;else if(f===")"&&(--a,a===0)){r=u+1;break}}let c=`tile_diffuse_final(${e.slice(o,r)}, tile_diffuse)`;e=e.slice(0,o)+c+e.slice(r),i=o+c.length,o=e.indexOf(n,i)}return e}function Zse(e,t,n){if(!l(t))return Xse(e,n);let i=new RegExp(`(uniform|attribute|in)\\s+(vec[34]|sampler2D)\\s+${t};`),o=e.match(i);if(!l(o))return Xse(e,n);let r=o[0],a=o[2];e=We.replaceMain(e,"tile_main"),e=e.replace(r,"");let s=`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); `,u;if(a==="vec3"||a==="vec4"){let f=a==="vec3"?`vec4(${t}, 1.0)`:t,h=a==="vec3"?"tile_diffuse.xyz":"tile_diffuse";i=new RegExp(t,"g"),e=e.replace(i,h),u=` vec4 source = ${f}; tile_diffuse = tile_diffuse_final(source, tile_featureColor); tile_main(); `}else a==="sampler2D"&&(e=eze(e,t),u=` tile_diffuse = tile_featureColor; tile_main(); `);return e=`uniform float tile_colorBlend; vec4 tile_diffuse = vec4(1.0); ${s}${r}${e}void tile_color(vec4 tile_featureColor) { ${u}`,n&&(e+=c),e+=`} `,e}Fo.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=Zse(i,t,!0),Nt.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}};function tze(e){let t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n===Yu.HIGHLIGHT)return 0;if(n===Yu.REPLACE)return 1;if(n===Yu.MIX)return D.clamp(i,D.EPSILON4,1)}Fo.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;let e=this;return function(t){return Pt(t,{tile_batchTexture:function(){return e._batchTexture.batchTexture??e._batchTexture.defaultTexture},tile_textureDimensions:function(){return e._batchTexture.textureDimensions},tile_textureStep:function(){return e._batchTexture.textureStep},tile_colorBlend:function(){return tze(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};Fo.prototype.getPickId=function(){return"texture(tile_pickTexture, tile_featureSt)"};var f_={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};Fo.prototype.addDerivedCommands=function(e,t){let n=e.commandList,i=n.length,o=this._content._tile,r=o._finalResolution,a=o.tileset,s=a.isSkippingLevelOfDetail&&a.hasMixedContent&&e.context.stencilBuffer,c=nze(this);for(let u=t;u<i;++u){let f=n[u];if(f.pass===Be.COMPUTE)continue;let h=f.derivedCommands.tileset;(!l(h)||f.dirty)&&(h={},f.derivedCommands.tileset=h,h.originalCommand=ize(f),f.dirty=!1);let p=h.originalCommand;c!==f_.ALL_OPAQUE&&f.pass!==Be.TRANSLUCENT&&(l(h.translucent)||(h.translucent=oze(p))),c!==f_.ALL_TRANSLUCENT&&f.pass!==Be.TRANSLUCENT&&(l(h.opaque)||(h.opaque=rze(p)),s&&(r||(l(h.zback)||(h.zback=sze(e.context,p)),a._backfaceCommands.push(h.zback)),(!l(h.stencil)||o._selectionDepth!==lze(h.stencil))&&(f.renderState.depthMask?h.stencil=cze(p,o._selectionDepth):h.stencil=h.opaque)));let A=s?h.stencil:h.opaque,m=h.translucent;f.pass!==Be.TRANSLUCENT?(c===f_.ALL_OPAQUE&&(n[u]=A),c===f_.ALL_TRANSLUCENT&&(n[u]=m),c===f_.OPAQUE_AND_TRANSLUCENT&&(n[u]=A,n.push(m))):n[u]=p}};function nze(e){let t=e._batchTexture.translucentFeaturesLength;return t===0?f_.ALL_OPAQUE:t===e.featuresLength?f_.ALL_TRANSLUCENT:f_.OPAQUE_AND_TRANSLUCENT}function ize(e){let t=it.shallowClone(e),n=t.pass===Be.TRANSLUCENT;return t.uniformMap=l(t.uniformMap)?t.uniformMap:{},t.uniformMap.tile_translucentCommand=function(){return n},t}function oze(e){let t=it.shallowClone(e);return t.pass=Be.TRANSLUCENT,t.renderState=uze(e.renderState),t}function rze(e){let t=it.shallowClone(e);return t.renderState=fze(e.renderState),t}function aze(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"zBackfaceLogDepth");if(!l(n)){let i=t.fragmentShaderSource.clone();i.defines=l(i.defines)?i.defines.slice(0):[],i.defines.push("POLYGON_OFFSET"),n=e.shaderCache.createDerivedShaderProgram(t,"zBackfaceLogDepth",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}return n}function sze(e,t){let n=it.shallowClone(t),i=Ye(n.renderState,!0);i.cull.enabled=!0,i.cull.face=Li.FRONT,i.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i.polygonOffset={enabled:!0,factor:5,units:5},i.stencilTest=Yt.setCesium3DTileBit(),i.stencilMask=Yt.CESIUM_3D_TILE_MASK,n.renderState=Ve.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=Ye(t.uniformMap);let o=new Q(5,5);return n.uniformMap.u_polygonOffset=function(){return o},n.shaderProgram=aze(e,t.shaderProgram),n}function cze(e,t){let n=it.shallowClone(e),i=Ye(n.renderState,!0);return i.stencilTest.enabled=!0,i.stencilTest.mask=Yt.SKIP_LOD_MASK,i.stencilTest.reference=Yt.CESIUM_3D_TILE_MASK|t<<Yt.SKIP_LOD_BIT_SHIFT,i.stencilTest.frontFunction=ti.GREATER_OR_EQUAL,i.stencilTest.frontOperation.zPass=wt.REPLACE,i.stencilTest.backFunction=ti.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=wt.REPLACE,i.stencilMask=Yt.CESIUM_3D_TILE_MASK|Yt.SKIP_LOD_MASK,n.renderState=Ve.fromCache(i),n}function lze(e){return(e.renderState.stencilTest.reference&Yt.SKIP_LOD_MASK)>>>Yt.SKIP_LOD_BIT_SHIFT}function uze(e){let t=Ye(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=sn.ALPHA_BLEND,t.stencilTest=Yt.setCesium3DTileBit(),t.stencilMask=Yt.CESIUM_3D_TILE_MASK,Ve.fromCache(t)}function fze(e){let t=Ye(e,!0);return t.stencilTest=Yt.setCesium3DTileBit(),t.stencilMask=Yt.CES
in float a_batchId;
uniform mat4 u_modifiedModelViewProjection;
void main(){ gl_Position = czm_depthClamp(u_modifiedModelViewProjection * vec4(position, 1.0));}`;var B6=class e{constructor(t,n){this._content=t,this._batchId=n,this._color=void 0}get show(){return this._content.batchTable.getShow(this._batchId)}set show(t){this._content.batchTable.setShow(this._batchId,t)}get color(){return l(this._color)||(this._color=new U),this._content.batchTable.getColor(this._batchId,this._color)}set color(t){this._content.batchTable.setColor(this._batchId,t)}get polylinePositions(){if(l(this._content.getPolylinePositions))return this._content.getPolylinePositions(this._batchId)}get content(){return this._content}get tileset(){return this._content.tileset}get primitive(){return this._content.tileset}get featureId(){return this._batchId}get pickId(){return this._content.batchTable.getPickColor(this._batchId)}hasProperty(t){return this._content.batchTable.hasProperty(this._batchId,t)}getPropertyIds(t){return this._content.batchTable.getPropertyIds(this._batchId,t)}getProperty(t){return this._content.batchTable.getProperty(this._batchId,t)}static getPropertyInherited(t,n,i){let o=t.batchTable;if(l(o)){if(o.hasPropertyBySemantic(n,i))return o.getPropertyBySemantic(n,i);if(o.hasProperty(n,i))return o.getProperty(n,i)}let r=t.metadata;if(l(r)){if(r.hasPropertyBySemantic(i))return r.getPropertyBySemantic(i);if(r.hasProperty(i))return r.getProperty(i)}let a=t.tile,s=a.metadata;if(l(s)){if(s.hasPropertyBySemantic(i))return s.getPropertyBySemantic(i);if(s.hasProperty(i))return s.getProperty(i)}let c;if(l(a.implicitSubtree)&&(c=a.implicitSubtree.metadata),l(c)){if(c.hasPropertyBySemantic(i))return c.getPropertyBySemantic(i);if(c.hasProperty(i))return c.getProperty(i)}let u=l(t.group)?t.group.metadata:void 0;if(l(u)){if(u.hasPropertyBySemantic(i))return u.getPropertyBySemantic(i);if(u.hasProperty(i))return u.getProperty(i)}let f=t.tileset.metadata;if(l(f)){if(f.hasPropertyBySemantic(i))return f.getPropertyBySemantic(i);if(f.hasProperty(i))return f.getProperty(i)}}getPropertyInherited(t){return e.getPropertyInherited(this._content,this._batchId,t)}setProperty(t,n){this._content.batchTable.setProperty(this._batchId,t,n),this._content.featurePropertiesDirty=!0}isExactClass(t){return this._content.batchTable.isExactClass(this._batchId,t)}isClass(t){return this._content.batchTable.isClass(this._batchId,t)}getExactClassName(){return this._content.batchTable.getExactClassName(this._batchId)}},Vs=B6;var D6=class{add(t,n,i){if(typeof arguments[0]!="string")for(let o in arguments[0])this.add(o,arguments[0][o],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(o){this[o]=this[o]||[],n&&this[o][i?"unshift":"push"](n)},this)}run(t,n){this[t]=this[t]||[],this[t].forEach(function(i){i.call(n&&n.context?n.context:n,n)})}},v6=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)})}},ru=class e{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,n,i){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=n,i?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,n){return e.literals[t]=n,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code
`;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=r}else t+=r}return o||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let t=this.code,n=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(t){let n=[],i=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===t){i=!0,this.index++,t===e.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(r===e.COMMA_CODE){if(this.index++,o++,o!==n.length){if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let a=n.length;a<o;a++)n.push(null)}}else if(n.length!==o&&o!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===e.COMPOUND)&&this.throwError("Expected comma"),n.push(a)}}return i||this.throwError("Expected "+String.fromCharCode(t)),n}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:e.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}},hze=new D6;Object.assign(ru,{hooks:hze,plugins:new v6(ru),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"});ru.max_unop_len=ru.getMaxKeyLen(ru.unary_ops);ru.max_binop_len=ru.getMaxKeyLen(ru.binary_ops);var d_=e=>new ru(e).parse(),mze=Object.getOwnPropertyNames(ru);mze.forEach(e=>{d_[e]===void 0&&e!=="prototype"&&(d_[e]=ru[e])});d_.Jsep=ru;var pze="ConditionalExpression",Aze={name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;let i=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:pze,test:i,consequent:o,alternate:r},i.operator&&e.binary_ops[i.operator]<=.9){let a=i;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;n.node.test=a.right,a.right=n.node,n.node=i}}else this.throwError("Expected :")}})}};d_.plugins.register(Aze);var gze={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},Bt=Object.freeze(gze);function lh(e,t){this._expression=e,e=vze(e,t),e=Rze(Pze(e)),d_.addBinaryOp("=~",0),d_.addBinaryOp("!~",0);let n;try{n=d_(e)}catch(i){throw new ue(i)}this._runtimeAst=Qi(this,n)}Object.defineProperties(lh.prototype,{expression:{get:function(){return this._expression}}});var Un={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new Q],cartesian3Array:[new d],cartesian4Array:[new ie],reset:function(){this.arrayIndex=0,this.cartesian2Index=0,this.cartesian3Index=0,this.cartesian4Index=0},getArr
{ return ${o};}`,o};lh.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};lh.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};var _ze=["!","-","+"],$se=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],TB=/\${(.*?)}/g,yze=/\\/g,Cze="@#%",Eze=/@#%/g,EF=new U,IF={abs:bs(Math.abs),sqrt:bs(Math.sqrt),cos:bs(Math.cos),sin:bs(Math.sin),tan:bs(Math.tan),acos:bs(Math.acos),asin:bs(Math.asin),atan:bs(Math.atan),radians:bs(D.toRadians),degrees:bs(D.toDegrees),sign:bs(D.sign),floor:bs(Math.floor),ceil:bs(Math.ceil),round:bs(Math.round),exp:bs(Math.exp),exp2:bs(bze),log:bs(Math.log),log2:bs(xze),fract:bs(Ize),length:Tze,normalize:Sze},bF={atan2:yF(Math.atan2,!1),pow:yF(Math.pow,!1),min:yF(Math.min,!0),max:yF(Math.max,!0),distance:wze,dot:Bze,cross:Dze},M6={clamp:ece(D.clamp,!0),mix:ece(D.lerp,!0)};function Ize(e){return e-Math.floor(e)}function bze(e){return Math.pow(2,e)}function xze(e){return D.log2(e)}function bs(e){return function(t,n){if(typeof n=="number")return e(n);if(n instanceof Q)return Q.fromElements(e(n.x),e(n.y),Un.getCartesian2());if(n instanceof d)return d.fromElements(e(n.x),e(n.y),e(n.z),Un.getCartesian3());if(n instanceof ie)return ie.fromElements(e(n.x),e(n.y),e(n.z),e(n.w),Un.getCartesian4());throw new ue(`Function "${t}" requires a vector or number argument. Argument is ${n}.`)}}function yF(e,t){return function(n,i,o){if(t&&typeof o=="number"){if(typeof i=="number")return e(i,o);if(i instanceof Q)return Q.fromElements(e(i.x,o),e(i.y,o),Un.getCartesian2());if(i instanceof d)return d.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),Un.getCartesian3());if(i instanceof ie)return ie.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),e(i.w,o),Un.getCartesian4())}if(typeof i=="number"&&typeof o=="number")return e(i,o);if(i instanceof Q&&o instanceof Q)return Q.fromElements(e(i.x,o.x),e(i.y,o.y),Un.getCartesian2());if(i instanceof d&&o instanceof d)return d.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),Un.getCartesian3());if(i instanceof ie&&o instanceof ie)return ie.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),e(i.w,o.w),Un.getCartesian4());throw new ue(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i} and ${o}.`)}}function ece(e,t){return function(n,i,o,r){if(t&&typeof r=="number"){if(typeof i=="number"&&typeof o=="number")return e(i,o,r);if(i instanceof Q&&o instanceof Q)return Q.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),Un.getCartesian2());if(i instanceof d&&o instanceof d)return d.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),Un.getCartesian3());if(i instanceof ie&&o instanceof ie)return ie.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),e(i.w,o.w,r),Un.getCartesian4())}if(typeof i=="number"&&typeof o=="number"&&typeof r=="number")return e(i,o,r);if(i instanceof Q&&o instanceof Q&&r instanceof Q)return Q.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),Un.getCartesian2());if(i instanceof d&&o instanceof d&&r instanceof d)return d.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),Un.getCartesian3());if(i instanceof ie&&o instanceof ie&&r instanceof ie)return ie.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),e(i.w,o.w,r.w),Un.getCartesian4());throw new ue(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i}, ${o}, and ${r}.`)}}function Tze(e,t){if(typeof t=="number")return Math.abs(t);if(t instanceof Q)return Q.magnitude(t);if(t instanceof d)return d.magnitude(t);if(t instanceof ie)return ie.magnitude(t);throw new ue(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function Sze(e,t){if(typeof t=="number")return 1;if(t instanceof Q)return Q.normalize(t,Un.getCartesian2());if(t instanceof d)return d.normalize(t,Un.getCartesian3());if(t instanceof ie)return ie.normalize(t,Un.getCartesian4());throw new ue(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function wze(e,t,n){if(typeof t=="number"&&typeof n=="number")return Math.abs(t-n);if(t instanceof Q
{ czm_non_pick_main(); out_FragColor = ${o}; } `,e._spPick=$t.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:i});return}let s=n.getVertexShaderCallback(!1,"a_batchId",void 0)(xB),c=n.getFragmentShaderCallback(!1,void 0,!0)(qC);o=n.getPickId();let u=new We({sources:[s]}),f=new We({defines:["VECTOR_TILE"],sources:[c]});e._sp=$t.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),u=new We({sources:[xB]}),f=new We({defines:["VECTOR_TILE"],sources:[qC]}),e._spStencil=$t.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),c=We.replaceMain(c,"czm_non_pick_main"),c=`${c}void main() { czm_non_pick_main(); out_FragColor = ${o}; } `;let h=new We({sources:[s]}),p=new We({defines:["VECTOR_TILE"],sources:[c]});e._spPick=$t.fromCache({context:t,vertexShaderSource:h,fragmentShaderSource:p,attributeLocations:i})}function rce(e){let t=e?ti.EQUAL:ti.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:t,frontOperation:{fail:wt.KEEP,zFail:wt.DECREMENT_WRAP,zPass:wt.KEEP},backFunction:t,backOperation:{fail:wt.KEEP,zFail:wt.INCREMENT_WRAP,zPass:wt.KEEP},reference:Yt.CESIUM_3D_TILE_MASK,mask:Yt.CESIUM_3D_TILE_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:hc.LESS_OR_EQUAL},depthMask:!1}}var Jze={stencilTest:{enabled:!0,frontFunction:ti.NOT_EQUAL,frontOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},backFunction:ti.NOT_EQUAL,backOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},reference:0,mask:Yt.CLASSIFICATION_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:sn.PRE_MULTIPLIED_ALPHA_BLEND},Zze={stencilTest:{enabled:!0,frontFunction:ti.NOT_EQUAL,frontOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},backFunction:ti.NOT_EQUAL,backOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},reference:0,mask:Yt.CLASSIFICATION_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function $ze(e){l(e._rsStencilDepthPass)||(e._rsStencilDepthPass=Ve.fromCache(rce(!1)),e._rsStencilDepthPass3DTiles=Ve.fromCache(rce(!0)),e._rsColorPass=Ve.fromCache(Jze),e._rsPickPass=Ve.fromCache(Zze))}var rE=new P,ace=new d;function eGe(e,t){if(l(e._uniformMap))return;let n={u_modifiedModelViewProjection:function(){let i=t.uniformState.view,o=t.uniformState.projection;return P.clone(i,rE),P.multiplyByPoint(rE,e._center,ace),P.setTranslation(rE,ace,rE),P.multiply(o,rE,rE),rE},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function N6(e,t,n,i,o,r,a){let s=e.constructor.BYTES_PER_ELEMENT,c=r.length;for(let u=0;u<c;++u){let f=r[u],h=a[f],p=i[h],A=o[h],m=new e.constructor(e.buffer,s*p,A);t.set(m,n),i[h]=n,n+=A}return n}function tGe(e,t){let n=e._indices,i=e._indexOffsets,o=e._indexCounts,r=e._batchIdLookUp,a=new n.constructor(n.length),s=t.pop(),c=[s],u=N6(n,a,0,i,o,s.batchIds,r);for(s.offset=0,s.count=u;t.length>0;){let f=t.pop();if(U.equals(f.color,s.color))u=N6(n,a,u,i,o,f.batchIds,r),s.batchIds=s.batchIds.concat(f.batchIds),s.count=u-s.offset;else{let h=u;u=N6(n,a,u,i,o,f.batchIds,r),f.offset=h,f.count=u-h,c.push(f),s=f}}e._va.indexBuffer.copyFromArrayView(a),e._indices=a,e._batchedIndices=c}function L6(e,t,n,i,o,r,a){let s=e.bytesPerIndex,c=r.length;for(let u=0;u<c;++u){let f=r[u],h=a[f],p=i[h],A=o[h];t.copyFromBuffer(e,p*s,n*s,A*s),i[h]=n,n+=A}return n}function nGe(e,t){let n=e._indexOffsets,i=e._indexCounts,o=e._batchIdLookUp,r=t.pop(),a=[r],s=e._va.indexBuffer,c=e._vaSwap.indexBuffer,u=L6(s,c,0,n,i,r.batchIds,o);for(r.offset=0,r.count=u;t.length>0;){let h=t.pop();if(U.equals(h.color,r.color))u=L6(s,c,u,n,i,h.batchIds,o),r.batchIds=r.batchIds.concat(h.batchIds),r.count=u-r.offset;else{let p=u;u=L6(s,c,u,n,i,h.batchIds,o),h.offset=p,h.count=u-p,a.push(h),r=h}}let f=e._va;e._va=e._vaSwap,e._vaSwap=f,e._batchedIndices=a}function iGe(e,t){return t.color.toRgba()-e.color.toRgba()}function oGe(e,t){if(!e._batchDirty)return!1;let n=e._batchedIndices,i=n.length,o=!1,r={};for(let a=0;a<i;++a){let c=n[a].color.toRgba();if(l(r[c])){o=!0;break}else r[c]=!0}if(!o)return e._batchDirty=!1,!1;if(o&&!e.forceRebatch&&e._framesSinceLastRebatch<120){++e._framesSinceLastRebatch;return}return n.sort(iGe),t.webgl2?nGe(e,n):tGe(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function rGe(e,t){let n=oGe(e,t),i=e._commands,o=e._batchedIndices,r=o.length,a=r*2;if(l(i)&&!n&&i.length===a)return;i.length=a;let s=e._va,c=e._sp,u=e._modelMatrix??P.IDENTITY,f=e._uniformMap,h=e._boundingVolume;for(let p=0;p<r;++p){let A=o[p].offset,m=o[p].count,_=i[p*2];l(_)||(_=i[p*2]=new it({owner:e})),_.vertexArray=s,_.modelMatrix=u,_.offset=A,_.count=m,_.renderState=e._rsStencilDepthPass,_.sh
${n.message}`);let i=new ue(t);return l(n)&&(i.stack=`Original stack:${n.stack}Handler stack:${i.stack}`),i}isDestroyed(){return!1}destroy(){return this.unload(),fe(this)}},$i=G6;var fVe={UNLOADED:0,LOADING:1,LOADED:2,PROCESSING:3,READY:4,FAILED:5},gt=Object.freeze(fVe);var RF=class extends $i{constructor(t){super(),t=t??V.EMPTY_OBJECT;let n=t.typedArray,i=t.resource,o=t.cacheKey;this._typedArray=n,this._resource=i,this._cacheKey=o,this._state=gt.UNLOADED,this._promise=void 0}get cacheKey(){return this._cacheKey}get typedArray(){return this._typedArray}async load(){return l(this._promise)?this._promise:l(this._typedArray)?(this._promise=Promise.resolve(this),this._promise):(this._promise=dVe(this),this._promise)}static _fetchArrayBuffer(t){return t.fetchArrayBuffer()}unload(){this._typedArray=void 0}};async function dVe(e){let t=e._resource;e._state=gt.LOADING;try{let n=await RF._fetchArrayBuffer(t);return e.isDestroyed()?void 0:(e._typedArray=new Uint8Array(n),e._state=gt.READY,e)}catch(n){if(e.isDestroyed())return;e._state=gt.FAILED;let i=`Failed to load external buffer: ${t.url}`;throw e.getError(i,n)}}var Db=RF;var Mln=(function(){var e="b9H79Tebbbe9ok9Geueu9Geub9Gbb9Gruuuuuuueu9Gvuuuuueu9Gduueu9Gluuuueu9Gvuuuuub9Gouuuuuub9Gluuuub9GiuuueuiE8AdilveoveovrrwrrrDDoDrbqqbelve9Weiiviebeoweuecj:Gdkr:PlCo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9mW4W2be8A9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWVbd8F9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949c919M9MWV9c9V919U9KbiE9TW79O9V9Wt9FW9U9J9V9KW9wWVtW949wWV79P9V9UblY9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWVbv8E9TW79O9V9Wt9FW9U9J9V9KW69U9KW949c919M9MWV9c9V919U9Kbo8A9TW79O9V9Wt9FW9U9J9V9KW69U9KW949wWV79P9V9UbrE9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JWbwa9TW79O9V9Wt9FW9U9J9V9KW69U9KW949tWG91W9U9JW9c9V919U9KbDL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9p9JtbqK9TW79O9V9Wt9FW9U9J9V9KWS9P2tWV9r919HtbkL9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVT949WbxY9TW79O9V9Wt9FW9U9J9V9KWS9P2tWVJ9V29VVbmE9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OWbza9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94J9H9J9OW9ttV9P9WbHa9TW79O9V9Wt9F9V9Wt9P9T9P96W9wWVtW94SWt9J9O9sW9T9H9WbOK9TW79O9V9Wt9F79W9Ht9P9H29t9VVt9sW9T9H9WbAl79IV9RbXDwebcekdKYq:8f8Adbk;wadhud9:8Jjjjjbc;qw9Rgr8KjjjjbcbhwdnaeTmbabcbyd;i:I:cjbaoaocb9iEgDc:GeV86bbarc;adfcbcjdz:xjjjb8AdnaiTmbarc;adfadalz:wjjjb8Akarc;abfalfcbcbcjdal9RalcFe0Ez:xjjjb8Aarc;abfarc;adfalz:wjjjb8Aar9cb83iUar9cb83i8War9cb83iyar9cb83iaar9cb83iKar9cb83izar9cb83iwar9cb83ibcj;abal9Uc;WFbGcjdalca0Ehqdnaicd6mbavcd9imbaDTmbadcefhkaqci2gxal2hmarc;alfclfhParc;qlfceVhsarc;qofclVhzcbhHincdhOcbhAdnavci6mbar9cb83i;Ooar9cb83i;Goar9cb83i;yoar9cb83i;qoadaHfgoybbhCcbhXincbhwcbhQdninaoalfhLaoybbgKaC7aQVhQawcP0meaLhoaKhCawcefgwaXfai6mbkkcbhCarc;qofhwincwhYcwh8AdnaQaC93gocFeGgEcs0mbclh8AaEci0mbcdcbaEEh8Akdnaocw4cFeGgEcs0mbclhYaEci0mbcdcbaEEhYkaYa8AfhEawydbh3cwhYcwh8Adnaocz4cFeGg5cs0mbclh8Aa5ci0mbcdcba5Eh8AkaEa3fhEdnaocFFFFb0mbclhYaocFFF8F0mbcbcdaocjjjw6EhYkawaEa8AfaYfBdbawclfhwaCcefgCcw9hmbkaLhoaKhCaXczfgXai6mbkcbhocehwazhQinawaoaQydbarc;qofaocdtfydb6EhoaQclfhQawcefgwcw9hmbkaoclthAcihOkcbhEarc;qlfcbcjdz:xjjjb8AarcbBd;ilar9cb83i;aladh8Eaqh8Fakh3inarc;qlfadaEaEcb9h9Ral2falz:wjjjb8Aaia8Faia8F6EhadnaqaiaE9RaEaqfai6EgKcsfc9WGgoaK9nmbarc;qofaKfcbaoaK9Rz:xjjjb8AkadaEal2fhhcbhginagaAVcl4hXarc;alfagcdtfh8JaHh8Kcbh8Lina8LaHfhwdndndndndndndnagPlbedibkaKTmvahawfhoarc;qlfawfRbbhQarc;qofhwaahCinawaoRbbgYaQ9RgQcetaQcKtc8F91786bbawcefhwaoalfhoaYhQaEaCcufgC9hmbxvkkaKTmla8Kc9:Ghoa8LcitcwGh8Aarc;qlfawceVfRbbcwtarc;qlfawc9:GfRbbVhQarc;qofhwaahCinawa3aofRbbcwta8EaofRbbVgYaQ9RgQcetaQcztc8F917cFFiGa8A486bbaoalfhoawcefhwaYhQaEaCcufgC9hmbxlkkasa8Kc98GgQfhoa3aQfhYarc;qlfawc98GgQfRbbhCcwhwinaoRbbawtaCVhCaocefhoawcwfgwca9hmbxdkkaKTmdxekaKTmea8Lcith5ahaQfh8AcbhLina8ARbbhQcwhoaYhwinawRbbaotaQVhQawcefhwaocwfgoca9hmbkarc;qofaLfaQaC7aX93a5486bbaYalfhYa8Aalfh8AaQhCaLcefgLaK9hmbkka8Jydbh8AcbhLarc;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhocehwaPhQinawaoaQydbarc;alfaocdtfydb6EhoaQclfhQaOawcefgw9hmbkara
${n.message}`);let o=new ue(i);return l(n)&&(o.stack=`Original stack:${n.stack}Handler stack:${o.stack}`),o};zc.getNodeTransform=function(e){return l(e.matrix)?e.matrix:P.fromTranslationQuaternionRotationScale(l(e.translation)?e.translation:d.ZERO,l(e.rotation)?e.rotation:Qe.IDENTITY,l(e.scale)?e.scale:d.ONE)};zc.getAttributeBySemantic=function(e,t,n){let i=e.attributes,o=i.length;for(let r=0;r<o;++r){let a=i[r],s=l(n)?a.setIndex===n:!0;if(a.semantic===t&&s)return a}};zc.getAttributeByName=function(e,t){let n=e.attributes,i=n.length;for(let o=0;o<i;++o){let r=n[o];if(r.name===t)return r}};zc.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}};zc.hasQuantizedAttributes=function(e){if(!l(e))return!1;for(let t=0;t<e.length;t++){let n=e[t];if(l(n.quantization))return!0}return!1};zc.getAttributeInfo=function(e){let t=e.semantic,n=e.setIndex,i,o=!1;l(t)?(i=at.getVariableName(t,n),o=!0):(i=e.name,i=i.replace(/^_/,""),i=i.toLowerCase());let r=/^color_\d+$/.test(i),a=e.type,s=zt.getGlslType(a);r&&(s="vec4");let c=l(e.quantization),u;return c&&(u=r?"vec4":zt.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:o,glslType:s,quantizedGlslType:u}};var z8e=new d,G8e=new d;zc.getPositionMinMax=function(e,t,n){let i=zc.getAttributeBySemantic(e,"POSITION"),o=i.max,r=i.min;return l(n)&&l(t)&&(r=d.add(r,t,G8e),o=d.add(o,n,z8e)),{min:r,max:o}};zc.getAxisCorrectionMatrix=function(e,t,n){return n=P.clone(P.IDENTITY,n),e===so.Y?n=P.clone(so.Y_UP_TO_Z_UP,n):e===so.X&&(n=P.clone(so.X_UP_TO_Z_UP,n)),t===so.Z&&(n=P.multiplyTransformation(n,so.Z_UP_TO_X_UP,n)),n};var V8e=new J;zc.getCullFace=function(e,t){if(!Pe.isTriangles(t))return Li.BACK;let n=P.getMatrix3(e,V8e);return J.determinant(n)<0?Li.FRONT:Li.BACK};zc.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^\d/.test(t)&&(t=`_${t}`),t};zc.supportedExtensions={AGI_articulations:!0,CESIUM_primitive_outline:!0,CESIUM_RTC:!0,EXT_feature_metadata:!0,EXT_implicit_cylinder_region:!0,EXT_implicit_ellipsoid_region:!0,EXT_instance_features:!0,EXT_mesh_features:!0,EXT_mesh_gpu_instancing:!0,EXT_meshopt_compression:!0,EXT_primitive_voxels:!0,EXT_structural_metadata:!0,EXT_texture_webp:!0,KHR_blend:!0,KHR_draco_mesh_compression:!0,KHR_implicit_shapes:!0,KHR_materials_common:!0,KHR_materials_pbrSpecularGlossiness:!0,KHR_materials_specular:!0,KHR_materials_anisotropy:!0,KHR_materials_clearcoat:!0,KHR_materials_unlit:!0,KHR_mesh_quantization:!0,KHR_techniques_webgl:!0,KHR_texture_basisu:!0,KHR_texture_transform:!0,KHR_gaussian_splatting:!0,KHR_gaussian_splatting_compression_spz_2:!0,WEB3D_quantized_attributes:!0};zc.checkSupportedExtensions=function(e){let t=e.length;for(let n=0;n<t;n++){let i=e[n];if(!zc.supportedExtensions[i])throw new ue(`Unsupported glTF Extension: ${i}`)}};var Tt=zc;var eY=class extends $i{constructor(t){super(),t=t??V.EMPTY_OBJECT;let n=t.resourceCache,i=t.gltfResource,o=t.baseResource,r=t.typedArray,a=t.gltfJson,s=t.cacheKey;this._resourceCache=n,this._gltfResource=i,this._baseResource=o,this._typedArray=r,this._gltfJson=a,this._cacheKey=s,this._gltf=void 0,this._bufferLoaders=[],this._state=gt.UNLOADED,this._promise=void 0}get cacheKey(){return this._cacheKey}get gltf(){return this._gltf}async load(){return l(this._promise)?this._promise:(this._state=gt.LOADING,l(this._gltfJson)?(this._promise=Gce(this,this._gltfJson),this._promise):l(this._typedArray)?(this._promise=Vce(this,this._typedArray),this._promise):(this._promise=H8e(this),this._promise))}unload(){let t=this._bufferLoaders,n=t.length;for(let i=0;i<n;++i)t[i]=!t[i].isDestroyed()&&this._resourceCache.unload(t[i]);this._bufferLoaders.length=0,this._gltf=void 0}_fetchGltf(){return this._gltfResource.fetchArrayBuffer()}};async function H8e(e){let t;try{let n=await e._fetchGltf();if(e.isDestroyed())return;t=new Uint8Array(n)}catch(n){if(e.isDestroyed())return;tY(e,n)}return Vce(e,t)}function tY(e,t){e.unload(),e._state=gt.FAILED;let n=`Failed to load glTF: ${e._gltfResource.url}`;throw e.getError(n,t)}async function W8e(e,t){if(l(t.asset)&&t.asset.version==="2.
`,Sn&&(dn+=`var destructors = [];`);var ma=Sn?"destructors":"null",Lu="humanName throwBindingError invoker fn runDestructors fromRetWire toClassParamWire".split(" ");for(Dt&&(dn+=`var thisWired = toClassParamWire(${ma}, this);`),ht=0;ht<qe;++ht){var ol=`toArg${ht}Wire`;dn+=`var arg${ht}Wired = ${ol}(${ma}, arg${ht});`,Lu.push(ol)}if(dn+=(Ie||xt?"var rv = ":"")+`invoker(${Wn});`,Sn)dn+=`runDestructors(destructors);`;else for(ht=Dt?1:2;ht<ne.length;++ht)xt=ht===1?"thisWired":"arg"+(ht-2)+"Wired",ne[ht].V!==null&&(dn+=`${xt}_dtor(${xt});`,Lu.push(`${xt}_dtor`));return Ie&&(dn+=`var ret = fromRetWire(rv);return ret;`),ne=new Function(Lu,dn+`}`)(...Te),mt(ae,ne)}for(var ps=ae=>{ae=ae.trim();let ne=ae.indexOf("(");return ne===-1?ae:ae.slice(0,ne)},da=[],wr=[0,1,,1,null,1,!0,1,!1,1],As=ae=>{9<ae&&--wr[ae+1]===0&&(wr[ae]=void 0,da.push(ae))},Ru=ae=>{if(!ae)throw new Fe(`Cannot use deleted val. handle = ${ae}`);return wr[ae]},Mu=ae=>{switch(ae){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let ne=da.pop()||wr.length;return wr[ne]=ae,wr[ne+1]=1,ne}},Nu={name:"emscripten::val",N:ae=>{var ne=Ru(ae);return As(ae),ne},T:(ae,ne)=>Mu(ne),X:ye,V:null},Kd=(ae,ne,Ie)=>{switch(ne){case 1:return Ie?function(Te){return this.N(x[Te])}:function(Te){return this.N(S[Te])};case 2:return Ie?function(Te){return this.N(w[Te>>1])}:function(Te){return this.N(v[Te>>1])};case 4:return Ie?function(Te){return this.N(R[Te>>2])}:function(Te){return this.N(N[Te>>2])};default:throw new TypeError(`invalid integer width (${ne}): ${ae}`)}},Fs=(ae,ne)=>{var Ie=ve[ae];if(Ie===void 0)throw ae=`${ne} has unknown type ${Vo(ae)}`,new Fe(ae);return Ie},Pg=(ae,ne)=>{switch(ne){case 4:return function(Ie){return this.N(L[Ie>>2])};case 8:return function(Ie){return this.N(g[Ie>>3])};default:throw new TypeError(`invalid float width (${ne}): ${ae}`)}},dm=Object.assign({optional:!0},Nu),pr=(ae,ne,Ie)=>{var Te=S;if(!(0<Ie))return 0;var qe=ne;Ie=ne+Ie-1;for(var xt=0;xt<ae.length;++xt){var ht=ae.codePointAt(xt);if(127>=ht){if(ne>=Ie)break;Te[ne++]=ht}else if(2047>=ht){if(ne+1>=Ie)break;Te[ne++]=192|ht>>6,Te[ne++]=128|ht&63}else if(65535>=ht){if(ne+2>=Ie)break;Te[ne++]=224|ht>>12,Te[ne++]=128|ht>>6&63,Te[ne++]=128|ht&63}else{if(ne+3>=Ie)break;Te[ne++]=240|ht>>18,Te[ne++]=128|ht>>12&63,Te[ne++]=128|ht>>6&63,Te[ne++]=128|ht&63,xt++}}return Te[ne]=0,ne-qe},Ja=ae=>{for(var ne=0,Ie=0;Ie<ae.length;++Ie){var Te=ae.charCodeAt(Ie);127>=Te?ne++:2047>=Te?ne+=2:55296<=Te&&57343>=Te?(ne+=4,++Ie):ne+=3}return ne},Za=new TextDecoder,on=(ae,ne,Ie,Te)=>{if(Ie=ne+Ie,Te)return Ie;for(;ae[ne]&&!(ne>=Ie);)++ne;return ne},we=new TextDecoder("utf-16le"),lt=(ae,ne,Ie)=>(ae>>=1,we.decode(v.subarray(ae,on(v,ae,ne/2,Ie)))),an=(ae,ne,Ie)=>{if(Ie??(Ie=2147483647),2>Ie)return 0;Ie-=2;var Te=ne;Ie=Ie<2*ae.length?Ie/2:ae.length;for(var qe=0;qe<Ie;++qe)w[ne>>1]=ae.charCodeAt(qe),ne+=2;return w[ne>>1]=0,ne-Te},fo=ae=>2*ae.length,Ma=(ae,ne,Ie)=>{var Te="";ae>>=2;for(var qe=0;!(qe>=ne/4);qe++){var xt=N[ae+qe];if(!xt&&!Ie)break;Te+=String.fromCodePoint(xt)}return Te},ao=(ae,ne,Ie)=>{if(Ie??(Ie=2147483647),4>Ie)return 0;var Te=ne;Ie=Te+Ie-4;for(var qe=0;qe<ae.length;++qe){var xt=ae.codePointAt(qe);if(65535<xt&&qe++,R[ne>>2]=xt,ne+=4,ne+4>Ie)break}return R[ne>>2]=0,ne-Te},ha=ae=>{for(var ne=0,Ie=0;Ie<ae.length;++Ie)65535<ae.codePointAt(Ie)&&Ie++,ne+=4;return ne},il=[],Rg=ae=>{var ne=il.length;return il.push(ae),ne},cw=(ae,ne)=>{for(var Ie=Array(ae),Te=0;Te<ae;++Te)Ie[Te]=Fs(N[ne+4*Te>>2],`parameter ${Te}`);return Ie},gs=(ae,ne,Ie)=>{var Te=[];return ae=ae(Te,Ie),Te.length&&(N[ne>>2]=Mu(Te)),ae},iM={},oM=ae=>{var ne=iM[ae];return ne===void 0?nt(ae):ne},V5={},Vte=()=>{if(!H5){var ae={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.language||"C").replace("-","_")+".UTF-8",_:c||"./this.program"},ne;for(ne in V5)V5[ne]===void 0?delete ae[ne]:ae[ne]=V5[ne];var Ie=[];for(ne in ae)Ie.push(`${ne}=${ae[ne]}`);H5=Ie}return H5},H5,fve=[null,[],[]],Jp=new Uint8Array(123),Mg=25;0<=Mg;--Mg)Jp[48+Mg]=52+Mg,Jp[65+Mg]=Mg,Jp[97+Mg]=26+Mg;Jp[43]=62,Jp[47]=63,(()=>{let ae=qt.prototype;Object.assign(ae,{isAliasOf:function(Ie){if(!(this instanceof qt&&Ie instanceof qt))return!1;var Te=this.L.P.M,qe=this.L.O;Ie.L=Ie.L;var xt=Ie.L.P.M;for(Ie=Ie.L.O;Te.U;)qe=Te.ea(qe),Te=Te.U;for(;xt.U;)Ie=xt.ea(Ie),xt=xt.U;return Te===xt&&qe===Ie},clone:function(){if(this.L.O||ft(this),this.L.da)return this.L.count.value+=1,this;var Ie=Se,Te=Object,qe=Te.create,xt=Object.getPrototypeOf(this),ht=this.L;return Ie=Ie(qe.call(Te,xt,{L:{value:{count:ht.count,ba:ht.ba,da:ht.da,O:ht.O,P:ht.P,S:ht.S,W:ht.W}}})),Ie.L.count.value+=1,Ie.L.ba=!1,Ie},delete(){if(this.L.O||ft(this),this.L.ba&&!this.L.da)t
${Dt} }`,Ie=new Function(Object.keys(ht),Dt)(...Object.values(ht)),Dt=`methodCaller<(${qe.map(Sn=>Sn.name)}) => ${Te.name}>`,Rg(mt(Dt,Ie))},E:As,o:(ae,ne,Ie,Te,qe)=>il[ae](ne,Ie,Te,qe),D:ae=>{var ne=Ru(ae);re(ne),As(ae)},s:(ae,ne,Ie,Te)=>{var qe=new Date().getFullYear(),xt=new Date(qe,0,1).getTimezoneOffset();qe=new Date(qe,6,1).getTimezoneOffset(),N[ae>>2]=60*Math.max(xt,qe),R[ne>>2]=+(xt!=qe),ne=ht=>{var Dt=Math.abs(ht);return`UTC${0<=ht?"-":"+"}${String(Math.floor(Dt/60)).padStart(2,"0")}${String(Dt%60).padStart(2,"0")}`},ae=ne(xt),ne=ne(qe),qe<xt?(pr(ae,Ie,17),pr(ne,Te,17)):(pr(ae,Te,17),pr(ne,Ie,17))},y:ae=>{var ne=S.length;if(ae>>>=0,2147483648<ae)return!1;for(var Ie=1;4>=Ie;Ie*=2){var Te=ne*(1+.2/Ie);Te=Math.min(Te,ae+100663296);e:{Te=(Math.min(2147483648,65536*Math.ceil(Math.max(ae,Te)/65536))-I.buffer.byteLength+65535)/65536|0;try{I.grow(Te),M();var qe=1;break e}catch{}qe=void 0}if(qe)return!0}return!1},t:(ae,ne)=>{var Ie=0,Te=0,qe;for(qe of Vte()){var xt=ne+Ie;N[ae+Te>>2]=xt,Ie+=pr(qe,xt,1/0)+1,Te+=4}return 0},u:(ae,ne)=>{var Ie=Vte();N[ae>>2]=Ie.length,ae=0;for(var Te of Ie)ae+=Ja(Te)+1;return N[ne>>2]=ae,0},v:()=>52,w:function(){return 70},k:(ae,ne,Ie,Te)=>{for(var qe=0,xt=0;xt<Ie;xt++){var ht=N[ne>>2],Dt=N[ne+4>>2];ne+=8;for(var Sn=0;Sn<Dt;Sn++){var Wn=ae,dn=S[ht+Sn],ma=fve[Wn];dn===0||dn===10?(Wn=Wn===1?p:A,dn=on(ma,0),dn=Za.decode(ma.buffer?ma.subarray(0,dn):new Uint8Array(ma.slice(0,dn))),Wn(dn),ma.length=0):ma.push(dn)}qe+=Dt}return N[Te>>2]=qe,0}},AI=await(async function(){var ae;function ne(Te){var qe;return AI=Te.exports,I=AI.F,M(),yn=AI.H,Te=AI,Hte=Te.I,i._malloc=W5=Te.J,i._free=Ng=Te.K,O--,(qe=i.monitorRunDependencies)==null||qe.call(i,O),O==0&&G&&(Te=G,G=null,Te()),AI}O++,(ae=i.monitorRunDependencies)==null||ae.call(i,O);var Ie={a:dve};return i.instantiateWasm?new Promise(Te=>{i.instantiateWasm(Ie,(qe,xt)=>{Te(ne(qe))})}):(z??(z=pe("AGFzbQEAAAAB2QM5YAF/AX9gAn9/AGABfwBgA39/fwF/YAJ/fwF/YAN/f38AYAZ/f39/f38Bf2AFf39/f38Bf2AEf39/fwBgBH9/f38Bf2AGf39/f39/AGAFf39/f38AYAAAYAh/f39/f39/fwF/YAd/f39/f39/AX9gAAF/YAV/fn5+fgBgCn9/f39/f39/f38AYAd/f39/f39/AGAFf39/f34Bf2AIf39/f39/f38AYAR/fn5/AGADf35/AX5gBX9/fn9/AGACf34AYAp/f39/f39/f39/AX9gDH9/f39/f39/f39/fwF/YAN/f38BfmAGf39/f35/AX9gD39/f39/f39/f39/f39/fwBgC39/f39/f39/f39/AX9gBH9/f38BfmAGf3x/f39/AX9gB39/f39/fn4Bf2AGf39/f35+AX9gBX9/f398AX9gDX9/f39/f39/f39/f38AYAV/f39+fgBgBX9/f39/AXxgBH9+f38Bf2ACf3wAYAR+fn5+AX9gAn5/AX9gBH9/f34BfmACfn4BfGABfwF8YAN/f38BfGADf39/AX1gA39/fgBgAn5+AX1gAn9/AX5gBH9+fn4AYAN+fn4Bf2ACfH8BfGAEf39/fQF/YAR/f399AGADf399AAK7AR8BYQFhAAUBYQFiABEBYQFjAAsBYQFkAAUBYQFlABEBYQFmAAUBYQFnAAoBYQFoAAEBYQFpAAoBYQFqACQBYQFrAAkBYQFsABQBYQFtAAUBYQFuACUBYQFvACYBYQFwAAMBYQFxAAIBYQFyAAgBYQFzAAgBYQF0AAQBYQF1AAQBYQF2AAABYQF3ACcBYQF4AAwBYQF5AAABYQF6AAIBYQFBAAEBYQFCAAgBYQFDAAEBYQFEAAIBYQFFAAIDjQWLBQAAAQQAAAIAAQABAQQEAg8QAgAEBQACAwAAAAIDAQwAABAEBQgVCwAAAAAQBAAFAAEBAwQAAAQBAQEAAAwBAQADAwACBBgFBQcHAwAAKA0NCAEDAQABAAQAAAgEAQEAAAwGBAQBAQYDKQUAFQMMAAQBAAEBBQQEBwMZABkAAQABAAQBBAABACoBAAEHAQAFBAUBAAgDBAIECwEUAgIBAAACCQABBAAACQEJAwcIBA4EDgQJCQQAAQABAAACAQQAAgADAgAGAQoFCAQFAQwAAAMBBAAABAsEAgACAxoLAAMaCwgCGwArAQAJEAAEAgIDAgAABBgBACwEAQUtAQIMAAgCBBwGHAYACQkBBAwIAwECFAUFBQAEBAIABQACBQ8FAwUFAAIAAAcNDQcNDQUABw0EAAQCAgIBAAIBAQIAAwMdEQMBHREAAAADCwEeAQAABQEeAQEBCgsKCgsKCg8AAxICEgcJBxIJBwkHCRIDBgMILgwvHwkGCR8JAQUbCQAABwQCAAQEAzAxMggQEBUzNAEAAAAAAAMEAAEFAQUBAAACAQgCBAAAAgICBAAMAgQDCAAOBzUAAQMAAAkDCAU2Azc4CgoKCwsLAwgICAMCDwIAAgACAAIAAgUAAgACAAIAAgACBAACAAIAAgACAAUBAQEBAQEAAAIEAgAHAAcNDQIHBwMJAwQDBAIHAwkDBAMEAgkJCQMCAg8DCgoGIQUGIQUODgEADg4DDg4NBQYGBgYGBQ0GBgYGBgciIxMHEwcHAAciBCMTBxMJBwcGBgYGBgYGBgYGBgYGBgAGBgYIAQYDCAcDCAcDAwICAAIACAIXBAQAAAACAgAAAgACAAMAAAMIFwMCABYBIBYDDAQHAXABgAOAAwUHAQGCAoCAAgYIAX8BQfD+BQsHGwYBRgIAAUcAqQUBSAEAAUkA1gMBSgA0AUsALQm/BQEAQQEL/wKQA/sE9wTmBOEE3gT/AvsC/ATPBGvJBMUEwgT/AvsCwQS+BNcDuwS2BLUErgTPAssClQSLBIEE9gPsAzDPAssCpQLfA94DoALdA9wDpQLbA9oDoALZA9gDnALVA9QDRqgFpwWmBaUFlAKiBZMCoQWgBZ8FRkaeBZ0FnAXIA5sFyAOQAsYDmgWZBY8CwQOYBZcF2AGOApYFlAWVBZMF/AGMBY0FiwWQBY8FjgWxAYwCigWJBYgFhwWJAoYFhQWEBS3hAdICiQSHBIUEgwSABP4D/AP6A/gD9QPzA/ED7wPtA9YCtASzBNACpgSlBKQEowSiBNECoQSgBJ8E2wKdBJwEmwSaBJk
uniform int u_polygonsLength;uniform int u_extentsLength;uniform highp sampler2D u_polygonTexture;uniform highp sampler2D u_extentsTexture;
int getPolygonIndex(float dimension, vec2 coord) { vec2 uv = coord.xy * dimension; return int(floor(uv.y) * dimension + floor(uv.x));}
vec2 getLookupUv(ivec2 dimensions, int i) { int pixY = i / dimensions.x; int pixX = i - (pixY * dimensions.x); float pixelWidth = 1.0 / float(dimensions.x); float pixelHeight = 1.0 / float(dimensions.y); float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
float v = (float(pixY) + 0.5) * pixelHeight; return vec2(u, v);}
vec4 getExtents(int i) { return texture(u_extentsTexture, getLookupUv(textureSize(u_extentsTexture, 0), i));}
ivec2 getPositionsLengthAndExtentsIndex(int i) { vec2 uv = getLookupUv(textureSize(u_polygonTexture, 0), i); vec4 value = texture(u_polygonTexture, uv); return ivec2(int(value.x), int(value.y));}
vec2 getPolygonPosition(int i) { vec2 uv = getLookupUv(textureSize(u_polygonTexture, 0), i); return texture(u_polygonTexture, uv).xy;}
vec2 getCoordinates(vec2 textureCoordinates, vec4 extents) { float latitude = mix(extents.x, extents.x + 1.0 / extents.z, textureCoordinates.y); float longitude = mix(extents.y, extents.y + 1.0 / extents.w, textureCoordinates.x); return vec2(latitude, longitude);}
void main() { int lastPolygonIndex = 0; out_FragColor = vec4(1.0);
// Get the relevant region of the texture
float dimension = float(u_extentsLength); if (u_extentsLength > 2) { dimension = ceil(log2(float(u_extentsLength))); } int regionIndex = getPolygonIndex(dimension, v_textureCoordinates);
if (regionIndex >= u_extentsLength) { return; // done (no polygons in this region)
}
for (int polygonIndex = 0; polygonIndex < u_polygonsLength; polygonIndex++) { ivec2 positionsLengthAndExtents = getPositionsLengthAndExtentsIndex(lastPolygonIndex); int positionsLength = positionsLengthAndExtents.x; int polygonExtentsIndex = positionsLengthAndExtents.y; lastPolygonIndex += 1;
// Read the individual polygon extent (2 pixels: south/west, latRange/lonRange)
vec2 extentsSouthWest = getPolygonPosition(lastPolygonIndex); vec2 extentsRange = getPolygonPosition(lastPolygonIndex + 1); vec4 polygonExtent = vec4(extentsSouthWest, extentsRange); lastPolygonIndex += 2;
if (polygonExtentsIndex < regionIndex) { lastPolygonIndex += positionsLength; continue; // skip to next (TODO: could optimize further if we knew how many polygons to skip)
} else if (polygonExtentsIndex > regionIndex) { break; // done (we know polygons are sorted by regionIndex)
}
// Only compute signed distance for the relevant part of the atlas
float clipAmount = czm_infinity; vec4 extents = getExtents(polygonExtentsIndex); vec2 textureOffset = vec2(mod(float(polygonExtentsIndex), dimension), floor(float(polygonExtentsIndex) / dimension)) / dimension; vec2 p = getCoordinates((v_textureCoordinates - textureOffset) * dimension, extents); // current pixel position
// Only consider polygons whos boundingbox includes current pixel (with a slight padding)
float padding = 0.05; // 5% of polygon extents
float polygonNorth = polygonExtent.x + polygonExtent.z; float polygonEast = polygonExtent.y + polygonExtent.w; float latPadding = padding * polygonExtent.z; // padding as fraction of latitude range
float lonPadding = padding * polygonExtent.w; // padding as fraction of longitude range
if (p.x < polygonExtent.x - latPadding || p.x > polygonNorth + latPadding || p.y < polygonExtent.y - lonPadding || p.y > polygonEast + lonPadding) { lastPolygonIndex += positionsLength; continue; // skip to next
}
float s = 1.0;
// Check each edge for absolute distance.
// Cache the previous vertex to halve the texture reads per iteration.
vec2 prev = getPolygonPosition(lastPolygonIndex + positionsLength - 1); for (int i = 0; i < positionsLength; i++) { vec2 a = getPolygonPosition(lastPolygonIndex + i); vec2 b = prev; prev = a;
vec2 ab = b - a; vec2 pa = p - a; float t = dot(pa, ab) / dot(ab, ab); t = clamp(t, 0.0, 1.0);
vec2 pq = pa - t * ab; float d = length(pq);
// Inside / outside computation to determine sign
bvec3 cond = bvec3(p.y >= a.y, p.y < b.y, ab.x * pa.y > ab.y * pa.x); if (all(cond) || all(not(cond))) s = -s; if (abs(d) < abs(clipAmount)) { clipAmount = d; } }
// Normalize the range to [0,1]
vec4 result = (s * vec4(clipAmount * length(extents.zw))) / 2.0 + 0.5; // In the case where we've iterated through multiple polygons, take the minimum
out_FragColor = min(out_FragColor, result);
lastPolygonIndex += positionsLength; }}`;function Ea(e){e=e??V.EMPTY_OBJECT,this._polygons=[],this._totalPositions=0,this.debugShowDistanceTexture=e.debugShowDistanceTexture??!1,this.enabled=e.enabled??!0,this.inverse=e.inverse??!1,this.quality=e.quality??1,this.polygonAdded=new _e,this.polygonRemoved=new _e,this._owner=void 0,this._float32View=void 0,this._extentsFloat32View=void 0,this._extentsCount=0,this._polygonsTexture=void 0,this._extentsTexture=void 0,this._signedDistanceTexture=void 0,this._signedDistanceComputeCommand=void 0;let t=e.polygons;if(l(t)){let n=t.length;for(let i=0;i<n;++i)this._polygons.push(t[i])}}Object.defineProperties(Ea.prototype,{length:{get:function(){return this._polygons.length}},totalPositions:{get:function(){return this._totalPositions}},extentsTexture:{get:function(){return this._extentsTexture}},extentsCount:{get:function(){return this._extentsCount}},pixelsNeededForExtents:{get:function(){return this.length}},pixelsNeededForPolygonPositions:{get:function(){return this.totalPositions+3*this.length}},clippingTexture:{get:function(){return this._signedDistanceTexture}},owner:{get:function(){return this._owner}},clippingPolygonsState:{get:function(){return this.inverse?-this.extentsCount:this.extentsCount}}});Ea.prototype.add=function(e){let t=this._polygons.length;return this._polygons.push(e),this.polygonAdded.raiseEvent(e,t),e};Ea.prototype.get=function(e){return this._polygons[e]};Ea.prototype.contains=function(e){return this._polygons.some(t=>jB.equals(t,e))};Ea.prototype.remove=function(e){let t=this._polygons,n=t.findIndex(i=>jB.equals(i,e));return n===-1?!1:(t.splice(n,1),this.polygonRemoved.raiseEvent(e,n),!0)};function x9e(e,t,n){let i=Math.max(e.height*t,0),o=Math.max(e.width*t,0),r=ce.clone(e,n);return r.south-=i,r.west-=o,r.north+=i,r.east+=o,r.south=Math.max(r.south,-Math.PI),r.west=Math.max(r.west,-Math.PI),r.north=Math.min(r.north,Math.PI),r.east=Math.min(r.east,Math.PI),r}function T9e(e,t){let i=[],o=e.length;for(let s=0;s<o;++s){let c=x9e(t[s],2.5),u=-1;for(let f=0;f<i.length;++f)if(l(ce.simpleIntersection(i[f].extent,c))){u=f;break}if(u===-1)i.push({extent:c,polygonIndices:[s]});else{let f=i[u];f.polygonIndices.push(s),ce.union(f.extent,c,f.extent);for(let h=0;h<i.length;++h)h!==u&&l(ce.simpleIntersection(i[h].extent,f.extent))&&(f.polygonIndices.push(...i[h].polygonIndices),ce.union(f.extent,i[h].extent,f.extent),i.splice(h,1),h<u&&u--,h=-1)}}let r=i.map(s=>s.extent),a=new Map;return i.forEach((s,c)=>s.polygonIndices.forEach(u=>a.set(u,c))),{extentsList:r,extentsIndexByPolygon:a}}Ea.prototype.removeAll=function(){let e=this._polygons,t=e.length;for(let n=0;n<t;++n){let i=e[n];this.polygonRemoved.raiseEvent(i,n)}this._polygons=[]};function S9e(e){let t=e._float32View,n=e._extentsFloat32View,i=e._polygons,o=i.map(f=>f.computeSphericalExtents()),{extentsList:r,extentsIndexByPolygon:a}=T9e(i,o),s=Array.from(i.keys()).sort((f,h)=>a.get(f)-a.get(h)),c=0;for(let f of s){let h=i[f],p=h.length;t[c++]=p,t[c++]=a.get(f);let A=o[f];t[c++]=A.south,t[c++]=A.west,t[c++]=A.north-A.south,t[c++]=A.east-A.west;for(let m=0;m<p;++m){let _=h.positions[m],y=Math.hypot(_.x,_.y),C=D.fastApproximateAtan2(y,_.z),E=D.fastApproximateAtan2(_.x,_.y);t[c++]=C,t[c++]=E}}let u=0;for(let f of r){let h=1/(f.east-f.west),p=1/(f.north-f.south);n[u++]=f.south,n[u++]=f.west,n[u++]=p,n[u++]=h}e._extentsCount=r.length}var WY=new Q;Ea.prototype.update=function(e){let t=e.context;if(!Ea.isSupported(e))throw new ue("ClippingPolygonCollections are only supported for WebGL 2.");this.debugShowDistanceTexture&&l(this._signedDistanceTexture)&&(l(this.debugCommand)||(this.debugCommand=w9e(this._signedDistanceTexture,e.context)),e.commandList.push(this.debugCommand));let n=this._polygons.reduce((a,s)=>a+s.length,0);if(n===this.totalPositions||(this._totalPositions=n,this.length===0))return;l(this._signedDistanceComputeCommand)&&(this._signedDistanceComputeCommand.canceled=!0,this._signedDistanceComputeCommand=void 0);let i=this._polygonsTexture,o=this._extentsTexture,r=this._signedDistanceTexture;if(l(i)){let a=i.width*i.height;(a<this.pixelsNeededForPolyg
in vec2 v_textureCoordinates; float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) { float signedDistance = texture(clippingDistance, uv).r; return (signedDistance - 0.5) * 2.0; } void main() { float dist = texture(billboard_texture, v_textureCoordinates).r; if (dist > 0.5) { out_FragColor = vec4(dist, 0.0, 0.0, 1.0); } else { out_FragColor = vec4(0.0, dist, 0.0, 1.0); } } `,{uniformMap:{billboard_texture:function(){return e}}});return i.pass=Be.OVERLAY,i}Ea.prototype.queueCommands=function(e){l(this._signedDistanceComputeCommand)&&e.commandList.push(this._signedDistanceComputeCommand)};function B9e(e){let t=e._polygonsTexture,n=e._extentsTexture;return new Vl({fragmentShaderSource:mQ,outputTexture:e._signedDistanceTexture,uniformMap:{u_polygonsLength:function(){return e.length},u_extentsLength:function(){return e.extentsCount},u_extentsTexture:function(){return n},u_polygonTexture:function(){return t}},persists:!1,owner:e,postExecute:()=>{e._signedDistanceComputeCommand=void 0}})}var Ule=new ce,D9e=new ce,v9e=new ce;Ea.prototype.computeIntersectionWithBoundingVolume=function(e,t){let n=this._polygons,i=n.length,o=Xt.OUTSIDE;this.inverse&&(o=Xt.INSIDE);let r=e.rectangle;if(!l(r)&&l(e.boundingVolume?.computeCorners)){let a=e.boundingVolume.computeCorners();r=ce.fromCartesianArray(a,t,Ule)}l(r)||(r=ce.fromBoundingSphere(e.boundingSphere,t,Ule));for(let a=0;a<i;++a){let c=n[a].computeRectangle(v9e),u=ce.simpleIntersection(r,c,D9e);if(l(u))return Xt.INTERSECTING}return o};Ea.setOwner=function(e,t,n){e!==t[n]&&(t[n]=t[n]&&t[n].destroy(),l(e)&&(e._owner=t,t[n]=e))};Ea.isSupported=function(e){return e?.context.webgl2};Ea.getTextureResolution=function(e,t,n){if(l(e))return n.x=e.width,n.y=e.height,n;let i=Nt.maximumTextureSize;return n.x=Math.min(t,i),n.y=Math.ceil(t/n.x),n.y*=2,n};Ea.getClippingDistanceTextureResolution=function(e,t){let n=e.signedDistanceTexture;if(l(n))return t.x=n.width,t.y=n.height,t;let i=e.quality,o=Math.max(128,Math.ceil(4096*i));return t.x=Math.min(Nt.maximumTextureSize,o),t.y=Math.min(Nt.maximumTextureSize,o),t};Ea.getClippingExtentsTextureResolution=function(e,t){let n=e.extentsTexture;return l(n)?(t.x=n.width,t.y=n.height,t):Ea.getTextureResolution(n,e.pixelsNeededForExtents,t)};Ea.prototype.isDestroyed=function(){return!1};Ea.prototype.destroy=function(){return l(this._signedDistanceComputeCommand)&&(this._signedDistanceComputeCommand.canceled=!0),this._polygonsTexture=this._polygonsTexture&&this._polygonsTexture.destroy(),this._extentsTexture=this._extentsTexture&&this._extentsTexture.destroy(),this._signedDistanceTexture=this._signedDistanceTexture&&this._signedDistanceTexture.destroy(),fe(this)};var jm=Ea;var YB={NONE:0,SCENE_LIGHT:1,SUNLIGHT:2};YB.fromGlobeFlags=function(e){return e.enableLighting&&e.dynamicAtmosphereLighting?e.dynamicAtmosphereLightingFromSun?YB.SUNLIGHT:YB.SCENE_LIGHT:YB.NONE};var P_=Object.freeze(YB);function zle(){this.lightIntensity=10,this.rayleighCoefficient=new d(55e-7,13e-6,284e-7),this.mieCoefficient=new d(21e-6,21e-6,21e-6),this.rayleighScaleHeight=1e4,this.mieScaleHeight=3200,this.mieAnisotropy=.9,this.hueShift=0,this.saturationShift=0,this.brightnessShift=0,this.dynamicLighting=P_.NONE}zle.requiresColorCorrect=function(e){return!(D.equalsEpsilon(e.hueShift,0,D.EPSILON7)&&D.equalsEpsilon(e.saturationShift,0,D.EPSILON7)&&D.equalsEpsilon(e.brightnessShift,0,D.EPSILON7))};var Wb=zle;var Ym=`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_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
const int LIGHT_STEPS_MAX = 4; // Maximum 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; }
// To deal with smaller values of PRIMARY_STEPS (e.g. 4)
// we implement a split strategy: sky or horizon.
// For performance reasons, instead of a if/else branch
// a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength); // Value close to 0.0: close to the horizon
// Value close to 1.0: above in the sky
float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
float start_0 = primaryRayAtmosphereIntersect.start; 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));
// For the number of ray steps, distinguish inside or outside atmosphere (outer space)
// (1) from outer space we have to use more ray steps to get a realistic rendering
// (2) within atmosphere we need fewer steps for faster rendering
float x_o_a = start_0 - ATMOSPHERE_THICKNESS; // ATMOSPHERE_THICKNESS used as an ad-hoc constant, no precise meaning here, only the order of magnitude matters
float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a)); int PRIMARY_STEPS = PRIMARY_STEPS_MAX - int(w_inside_atmosphere * 12.0); // Number of times the ray from the camera to the world position (primary ray) is sampled.
int LIGHT_STEPS = LIGHT_STEPS_MAX - int(w_inside_atmosphere * 2.0); // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
float rayPositionLength = primaryRayAtmosphereIntersect.start; // (1) Outside the atmosphere: constant rayStepLength
// (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength; float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0)); float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
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_MAX; ++i) {
// The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if (i >= PRIMARY_STEPS) { break; }
// 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_MAX; ++j) {
// The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if (j >= LIGHT_STEPS) { break; }
// 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 += rayStepLengthIncrease); }
// 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 pQ=`uniform samplerCube u_radianceMap;
in vec2 v_textureCoordinates;
const float twoSqrtPi = 2.0 * sqrt(czm_pi);
// Coutesy of https://www.ppsloan.org/publications/StupidSH36.pdf
float computeShBasis(int index, vec3 s) { if (index == 0) { // l = 0, m = 0
return 1.0 / twoSqrtPi; } if (index == 1) { // l = 1, m = -1
return -sqrt(3.0) * s.y / twoSqrtPi; }
if (index == 2) { // l = 1, m = 0
return sqrt(3.0) * s.z / twoSqrtPi; }
if (index == 3) { // l = 1, m = 1
return -sqrt(3.0) * s.x / twoSqrtPi; }
if (index == 4) { // l = 2, m = -2
return sqrt(15.0) * s.y * s.x / twoSqrtPi; }
if (index == 5) { // l = 2, m = -1
return -sqrt(15.0) * s.y * s.z / twoSqrtPi; }
if (index == 6) { // l = 2, m = 0
return sqrt(5.0) * (3.0 * s.z * s.z - 1.0) / 2.0 / twoSqrtPi; }
if (index == 7) { // l = 2, m = 1
return -sqrt(15.0) * s.x * s.z / twoSqrtPi; }
if (index == 8) { // l = 2, m = 2
return sqrt(15.0) * (s.x * s.x - s.y * s.y) / 2.0 / twoSqrtPi; }
return 0.0;}
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));}
// Sample count is relatively low for the sake of performance, but should still be enough to capture directionality needed for third-order harmonics
const int samples = 256; const float solidAngle = 1.0 / float(samples);
void main() { // Get the current coefficient based on the uv
vec2 uv = v_textureCoordinates.xy * 3.0; int coefficientIndex = int(floor(uv.y) * 3.0 + floor(uv.x));
for (int i = 0; i < samples; ++i) { vec2 xi = hammersley2D(i, samples); float phi = czm_twoPi * xi.x; float cosTheta = 1.0 - 2.0 * sqrt(1.0 - xi.y * xi.y); float sinTheta = sqrt(1.0 - cosTheta * cosTheta); vec3 direction = normalize(vec3(sinTheta * cos(phi), cosTheta, sinTheta * sin(phi)));
// Generate the spherical harmonics basis from the direction
float Ylm = computeShBasis(coefficientIndex, direction);
vec3 lookupDirection = -direction.xyz; lookupDirection.z = -lookupDirection.z;
vec4 color = czm_textureCube(u_radianceMap, lookupDirection, 0.0);
// Use the relevant function for this coefficient
out_FragColor += Ylm * color * solidAngle * sinTheta; } }`;var AQ=`precision highp float;
in vec2 v_textureCoordinates;
uniform vec3 u_faceDirection; // Current cubemap face
uniform vec3 u_positionWC;uniform mat4 u_enuToFixedFrame;uniform vec4 u_brightnessSaturationGammaIntensity;uniform vec4 u_groundColor; // alpha component represent albedo
vec4 getCubeMapDirection(vec2 uv, vec3 faceDir) { vec2 scaledUV = uv * 2.0 - 1.0;
if (faceDir.x != 0.0) { return vec4(faceDir.x, scaledUV.x * faceDir.x, -scaledUV.y, 0.0); } else if (faceDir.y != 0.0) { return vec4(scaledUV.x, -scaledUV.y * faceDir.y, faceDir.y, 0.0); } else { return vec4(scaledUV.x * faceDir.z, -faceDir.z, -scaledUV.y, 0.0); }}
void main() { float height = length(u_positionWC); float atmosphereInnerRadius = u_radiiAndDynamicAtmosphereColor.y; float ellipsoidHeight = max(height - atmosphereInnerRadius, 0.0);
// Scale the position to ensure the sky color is present, even when underground.
vec3 positionWC = u_positionWC / height * (ellipsoidHeight + atmosphereInnerRadius);
float atmosphereOuterRadius = u_radiiAndDynamicAtmosphereColor.x; float atmosphereHeight = atmosphereOuterRadius - atmosphereInnerRadius;
vec3 direction = (u_enuToFixedFrame * getCubeMapDirection(v_textureCoordinates, u_faceDirection)).xyz; vec3 normalizedDirection = normalize(direction);
czm_ray ray = czm_ray(positionWC, normalizedDirection); czm_raySegment intersection = czm_raySphereIntersectionInterval(ray, vec3(0.0), atmosphereInnerRadius); if (!czm_isEmpty(intersection)) { intersection = czm_rayEllipsoidIntersectionInterval(ray, vec3(0.0), czm_ellipsoidInverseRadii); }
bool onEllipsoid = intersection.start >= 0.0; float rayLength = czm_branchFreeTernary(onEllipsoid, intersection.start, atmosphereOuterRadius);
// Compute sky color for each position on a sphere at radius centered around the provided position's origin
vec3 skyPositionWC = positionWC + normalizedDirection * rayLength;
float lightEnum = u_radiiAndDynamicAtmosphereColor.z; vec3 lightDirectionWC = normalize(czm_getDynamicAtmosphereLightDirection(skyPositionWC, lightEnum)); vec3 mieColor; vec3 rayleighColor; float opacity; czm_computeScattering( ray, rayLength, lightDirectionWC, atmosphereInnerRadius, rayleighColor, mieColor, opacity );
vec4 atmopshereColor = czm_computeAtmosphereColor(ray, lightDirectionWC, rayleighColor, mieColor, opacity);
#ifdef ATMOSPHERE_COLOR_CORRECT const bool ignoreBlackPixels = true; atmopshereColor.rgb = czm_applyHSBShift(atmopshereColor.rgb, czm_atmosphereHsbShift, ignoreBlackPixels);#endif
vec3 lookupDirection = -normalizedDirection; // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
lookupDirection.x = -lookupDirection.x; lookupDirection = -normalize(czm_temeToPseudoFixed * lookupDirection); lookupDirection.x = -lookupDirection.x;
// Values outside the atmopshere are rendered as black, when they should be treated as transparent
float skyAlpha = clamp((1.0 - ellipsoidHeight / atmosphereHeight) * atmopshereColor.a, 0.0, 1.0); skyAlpha = czm_branchFreeTernary(length(atmopshereColor.rgb) <= czm_epsilon7, 0.0, skyAlpha); // Treat black as transparent
// Blend starmap with atmopshere scattering
float intensity = u_brightnessSaturationGammaIntensity.w; vec4 sceneSkyBoxColor = czm_textureCube(czm_environmentMap, lookupDirection); vec3 skyBackgroundColor = mix(czm_backgroundColor.rgb, sceneSkyBoxColor.rgb, sceneSkyBoxColor.a); vec4 combinedSkyColor = vec4(mix(skyBackgroundColor, atmopshereColor.rgb * intensity, skyAlpha), 1.0);
// Compute ground color based on amount of reflected light, then blend it with ground atmosphere based on height
vec3 up = normalize(positionWC); float occlusion = max(dot(lightDirectionWC, up), 0.05); vec4 groundColor = vec4(u_groundColor.rgb * u_groundColor.a * (vec3(intensity * occlusion) + atmopshereColor.rgb), 1.0); vec4 blendedGroundColor = mix(groundColor, atmopshereColor, clamp(ellipsoidHeight / atmosphereHeight, 0.0, 1.0));
vec4 color = czm_branchFreeTernary(onEllipsoid, blendedGroundColor, combinedSkyColor);
float brightness = u_brightnessSaturationGammaIntensity.x; float saturation = u_brightnessSaturationGammaIntensity.y; float gamma = u_brightnessSaturationGammaIntensity.z;
#ifdef ENVIRONMENT_COLOR_CORRECT color.rgb = mix(vec3(0.0), color.rgb, brightness); color.rgb = czm_saturation(color.rgb, saturation);#endif color.rgb = pow(color.rgb, vec3(gamma)); // Normally this would be in the ifdef above, but there is a precision issue with the atmopshere scattering transmittance (alpha). Having this line is a workaround for that issue, even when gamma is 1.0.
color.rgb = czm_gammaCorrect(color.rgb);
out_FragColor = color;}`;var gQ=`precision highp float;
in vec3 v_textureCoordinates;
uniform float u_roughness;uniform samplerCube u_radianceTexture;uniform vec3 u_faceDirection;
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 alphaRoughness, vec3 N){ float alphaRoughnessSquared = alphaRoughness * alphaRoughness; float phi = czm_twoPi * xi.x; float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 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;}
// Sample count is relatively low for the sake of performance, but should still be enough to prevent artifacting in lower roughnesses
const int samples = 128;
void main() { vec3 normal = u_faceDirection; vec3 V = normalize(v_textureCoordinates); float roughness = u_roughness;
vec4 color = vec4(0.0); float weight = 0.0; for (int i = 0; i < samples; ++i) { vec2 xi = hammersley2D(i, samples); vec3 H = importanceSampleGGX(xi, roughness, V); vec3 L = 2.0 * dot(V, H) * H - V; // reflected vector
float NdotL = max(dot(V, L), 0.0); if (NdotL > 0.0) { color += vec4(czm_textureCube(u_radianceTexture, L).rgb, 1.0) * NdotL; weight += NdotL; } } out_FragColor = color / weight;}`;var _Q=`in vec3 position;out vec3 v_textureCoordinates;
uniform vec3 u_faceDirection;
vec3 getCubeMapDirection(vec2 uv, vec3 faceDir) { vec2 scaledUV = uv;
if (faceDir.x != 0.0) { return vec3(faceDir.x, scaledUV.y, scaledUV.x * faceDir.x); } else if (faceDir.y != 0.0) { return vec3(scaledUV.x, -faceDir.y, -scaledUV.y * faceDir.y); } else { return vec3(scaledUV.x * faceDir.z, scaledUV.y, -faceDir.z); }}
void main() { v_textureCoordinates = getCubeMapDirection(position.xy, u_faceDirection); v_textureCoordinates.y = -v_textureCoordinates.y; v_textureCoordinates.z = -v_textureCoordinates.z; gl_Position = vec4(position, 1.0);}`;function pi(e){this._position=void 0,this._radianceMapDirty=!1,this._radianceCommandsDirty=!1,this._convolutionsCommandsDirty=!1,this._irradianceCommandDirty=!1,this._irradianceTextureDirty=!1,this._sphericalHarmonicCoefficientsDirty=!1,this._shouldRegenerateShaders=!1,this._shouldReset=!1,e=e??V.EMPTY_OBJECT;let t=Math.max(Math.floor(Math.min(e.mipmapLevels??7,Math.log2(Nt.maximumCubeMapSize))),0);this._mipmapLevels=t;let n=Math.max(t-1,0)*6;this._radianceMapComputeCommands=new Array(6),this._convolutionComputeCommands=new Array(n),this._irradianceComputeCommand=void 0,this._radianceMapFS=void 0,this._irradianceMapFS=void 0,this._convolveSP=void 0,this._va=void 0,this._radianceMapTextures=new Array(6),this._specularMapTextures=new Array(n),this._radianceCubeMap=void 0,this._irradianceMapTexture=void 0,this._sphericalHarmonicCoefficients=pi.DEFAULT_SPHERICAL_HARMONIC_COEFFICIENTS.slice(),this._lastTime=new X;let i=Math.max(Math.pow(2,t-1),1);this._textureDimensions=new Q(i,i),this._radiiAndDynamicAtmosphereColor=new d,this._sceneEnvironmentMap=void 0,this._backgroundColor=void 0,this._owner=void 0,this.enabled=e.enabled??!0,this.shouldUpdate=!0,this.maximumSecondsDifference=e.maximumSecondsDifference??3600,this.maximumPositionEpsilon=e.maximumPositionEpsilon??1e3,this.atmosphereScatteringIntensity=e.atmosphereScatteringIntensity??2,this.gamma=e.gamma??1,this.brightness=e.brightness??1,this.saturation=e.saturation??1,this.groundColor=e.groundColor??pi.AVERAGE_EARTH_GROUND_COLOR,this.groundAlbedo=e.groundAlbedo??.31}Object.defineProperties(pi.prototype,{owner:{get:function(){return this._owner}},shouldRegenerateShaders:{get:function(){return this._shouldRegenerateShaders}},position:{get:function(){return this._position},set:function(e){d.equalsEpsilon(e,this._position,0,this.maximumPositionEpsilon)||(this._position=d.clone(e,this._position),this._shouldReset=!0)}},radianceCubeMap:{get:function(){return this._radianceCubeMap}},maximumMipmapLevel:{get:function(){return this._mipmapLevels}},sphericalHarmonicCoefficients:{get:function(){return this._sphericalHarmonicCoefficients}}});pi._maximumComputeCommandCount=8;pi._activeComputeCommandCount=0;pi._nextFrameCommandQueue=[];pi._queueCommand=(e,t)=>{if(pi._activeComputeCommandCount>=pi._maximumComputeCommandCount){pi._nextFrameCommandQueue.push(e);return}t.commandList.push(e),pi._activeComputeCommandCount++};pi._updateCommandQueue=e=>{if(pi._maximumComputeCommandCount=Math.log2(Nt.maximumCubeMapSize),pi._nextFrameCommandQueue.length>0&&pi._activeComputeCommandCount<pi._maximumComputeCommandCount){let t=pi._nextFrameCommandQueue.shift();for(;l(t)&&pi._activeComputeCommandCount<pi._maximumComputeCommandCount;){if(t.owner.isDestroyed()||t.canceled){t=pi._nextFrameCommandQueue.shift();continue}e.commandList.push(t),pi._activeComputeCommandCount++,t=pi._nextFrameCommandQueue.shift()}l(t)&&pi._nextFrameCommandQueue.push(t)}};pi.setOwner=function(e,t,n){e!==t[n]&&(t[n]=t[n]&&t[n].destroy(),l(e)&&(e._owner=t,t[n]=e))};pi.prototype.reset=function(){let e=this._radianceMapComputeCommands.length;for(let t=0;t<e;++t)l(this._radianceMapComputeCommands[t])&&(this._radianceMapComputeCommands[t].canceled=!0),this._radianceMapComputeCommands[t]=void 0;e=this._convolutionComputeCommands.length;for(let t=0;t<e;++t)l(this._convolutionComputeCommands[t])&&(this._convolutionComputeCommands[t].canceled=!0),this._convolutionComputeCommands[t]=void 0;l(this._irradianceComputeCommand)&&(this._irradianceComputeCommand.canceled=!0,this._irradianceComputeCommand=void 0),this._radianceMapDirty=!0,this._radianceCommandsDirty=!0,this._convolutionsCommandsDirty=!1,this._irradianceCommandDirty=!1};var P9e=new d,R9e=new d;function M9e(e,t){let n=e._position,i=t.atmosphere,o=t.mapProjection.ellipsoid,r=o.scaleToGeodeticSurface(n,R9e),a=1.025,s=P9e,c=l(r)?d.magnitude(r):o.maximumRadius;return s.x=c*a,s.y=c,s.z=i.dynamicLighting,!d.equalsEpsilon(e._radiiAndDynamicAtmosphereColor,s)||t.environmentMap!==e._sceneEnvironmentMap||t.backgroundColor!==e._backgroundColor?(d.clone(s,e._radiiAndDynamicAtmosphereColor),e.
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 Zb(){this._framebuffer=new bi({colorAttachmentsLength:2,depth:!0,supportsDepthTexture:!0}),this._drawCommand=void 0,this._clearCommand=void 0,this._strength=1,this._radius=1}Object.defineProperties(Zb.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 gje(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}var nq=new Q;function _je(e,t){let n=new We({defines:["LOG_DEPTH_WRITE"],sources:[QQ]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return nq.x=e._radius,nq.y=e._strength,nq}},o=Ve.fromCache({blending:sn.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:Yt.setCesium3DTileBit(),stencilMask:Yt.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:o,pass:Be.CESIUM_3D_TILE,owner:e}),e._clearCommand=new ui({framebuffer:e.framebuffer,color:new U(0,0,0,0),depth:1,renderState:Ve.fromCache(),pass:Be.CESIUM_3D_TILE,owner:e})}function yje(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),_je(e,t)}function Cue(e){return e.drawBuffers&&e.fragmentDepth}Zb.isSupported=Cue;function Cje(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"EC");if(!l(n)){let i=t._attributeLocations,o=t.fragmentShaderSource.clone();o.sources.splice(0,0,`layout (location = 0) out vec4 out_FragData_0;layout (location = 1) out vec4 out_FragData_1;`),o.sources=o.sources.map(function(r){return r=We.replaceMain(r,"czm_point_cloud_post_process_main"),r=r.replaceAll(/out_FragColor/g,"out_FragData_0"),r}),o.sources.push(`void main() { czm_point_cloud_post_process_main(); #ifdef LOG_DEPTH czm_writeLogDepth(); out_FragData_1 = czm_packDepth(gl_FragDepth); #else out_FragData_1 = czm_packDepth(gl_FragCoord.z);#endif}`),n=e.shaderCache.createDerivedShaderProgram(t,"EC",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}Zb.prototype.update=function(e,t,n,i){if(!Cue(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,yje(this,e.context);let o,r=e.commandList,a=r.length;for(o=t;o<a;++o){let u=r[o];if(u.primitiveType!==Pe.POINTS||u.pass===Be.TRANSLUCENT)continue;let f,h,p=u.derivedCommands.pointCloudProcessor;l(p)&&(f=p.command,h=p.originalShaderProgram),(!l(f)||u.dirty||h!==u.shaderProgram||f.framebuffer!==this.framebuffer)&&(f=it.shallowClone(u,f),f.framebuffer=this.framebuffer,f.shaderProgram=Cje(e.context,u.shaderProgram),f.castShadows=!1,f.receiveShadows=!1,l(p)||(p={command:f,originalShaderProgram:u.shaderProgram},u.derivedCommands.pointCloudProcessor=p),p.originalShaderProgram=u.shaderProgram),r[o]=f}let s=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,r.push(c),r.push(s)};Zb.prototype.isDestroyed=function(){return!1};Zb.prototype.destroy=function(){return gje(this),fe(this)};var O_=Zb;function Eue(e){let t=e??{};this.attenuation=t.attenuation??!1,this.geometricErrorScale=t.geometricErrorScale??1,this.maximumAttenuation=t.maximumAttenuation,this.baseResolution=t.baseResolution,this.eyeDomeLighting=t.eyeDomeLighting??!0,this.eyeDomeLightingStrength=t.eyeDomeLightingStrength??1,this.eyeDomeLightingRadius=t.eyeDomeLightingRadius??1,this.backFaceCulling=t.backFaceCulling??!1,this.normalShading=t.normalShading??!0}Eue.isSupported=function(e){return O_.isSupported(e.context)};var TA=Eue;var Ac={},Eje=new ie(0,0,0,1),Vc=new ie,Ije=new et,iq=new Q,oq=new Q;Ac.worldToWindowCoordinates=function(e,t,n){return Ac.worldWithEyeOffsetToWindowCoordinates(e,t,d.ZERO,n)};var Iue=new ie,bue=new d;function ZB(e,t,n,i){let o=n.viewMatrix,r=P.multiplyByVector(o,ie.fromElements(e.x,e.y,e.z,1,Iue),Iue),a=d.multiplyComponents(t,d.normalize(r,bue),bue);return r.x+=t.x+a.x,r.y+=t.y+a.y,r.z+=a.z,P.multiplyByVector(n.frustum.projectionMatrix,r,i)}var bje=new me(Math.PI,D.PI_OVER_TWO),xje=new d,Tje=new d;Ac.worldWithEyeOffsetToWindowCoordinates=function(e,t,n,i){let o=e.frameState,r=Ac.computeActualEllipsoidPosition(o,t,Eje);if(!l(r))return;let a=e.canvas,s=Ije;s.x=0,s.y=0,s.width=a.clientWidth,s.height=a.clientHeight;let c=e.camera,u=!1;if(o.mode===oe.SCENE2D){let f=e.mapProjection,h=bje,p=f.project(h,xje),A=d.clone(c.position,Tje),m=c.frustum.clone(),_=P.computeViewportTransformation(s,0,1,new P),y=c.frustum.projectionMatrix,C=c.positionWC.y,E=d.fromElements(D.sign(C)*p.x-C,0,-c.positionWC.x),I=At.pointToGLWindowCoordinates(y,_,E);if(C===0||I.x<=0||I.x>=a.clientWidth)u=!0;else{if(I.x>a.clientWidth*.5){s.width=I.x,c.frustum.right=p.x-C,Vc=ZB(r,n,c,Vc),Ac.clipToGLWindowCoordinates(s,Vc,iq),s.x+=I.x,c.position.x=-c.position.x;let x=c.frustum.right;c.frustum.right=-c.frustum.left,c.frustum.left=-x,Vc=ZB(r,n,c,Vc),Ac.clipToGLWindowCoordinates(s,Vc,oq)}else{s.x+=I.x,s.width-=I.x,c.frustum.left=-p.x-C,Vc=ZB(r,n,c,Vc),Ac.clipToGLWindowCoordinates(s,Vc,iq),s.x=s.x-s.width,c.position.x=-c.position.x;let x=c.frustum.left;c.frustum.left=-c.frustum.right,c.frustum.right=-x,Vc=ZB(r,n,c,Vc),Ac.clipToGLWindowCoordinates(s,Vc,oq)}d.clone(A,c.position),c.frustum=m.clone(),i=Q.clone(iq,i),(i.x<0||i.x>a.clientWidth)&&(i.x=oq.x)}}if(o.mode!==oe.SCENE2D||u){if(Vc=ZB(r,n,c,Vc),Vc.z<0&&!(c.frustum instanceof An)&&!(c.frustum instanceof Aa))return;i=Ac.clipToGLWindowCoordinates(s,Vc,i)}return i.y=a.clientHeight-i.y,i};Ac.worldToDrawingBufferCoordinates=function(e,t,n){if(n=Ac.worldToWindowCoordinates(e,t,n),!!l(n))return Ac.transformWindowToDrawingBuffer(e,n,n)};var SA=new d,Sje=new me;Ac.computeActualEllipsoidPosition=function(e,t,n){let i=e.mode;if(i===oe.SCENE3D)return d.clone(t,n);let o=e.mapProjection,r=o.ellipsoid.cartesianToCartographic(t,Sje);if(!l(r))return;if(o.project(r,SA),i===oe.COLUMBUS_VIEW)return d.fromElements(SA.z,SA.x,SA.y,n);if(i===oe.SCENE2D)return d.fromElements(0,SA.x,SA.y,n);let a=e.morphTime;return d.fromElements(D.lerp(SA.z,t.x,a),D.lerp(SA.x,t
// https://github.com/0xfaded/ellipse_demo/issues/1
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
//
// This version uses only a single iteration for best performance. For fog
// rendering, the difference is negligible.
vec2 nearestPointOnEllipseFast(vec2 pos, vec2 radii) { vec2 p = abs(pos); vec2 inverseRadii = 1.0 / radii; vec2 evoluteScale = (radii.x * radii.x - radii.y * radii.y) * vec2(1.0, -1.0) * inverseRadii;
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
// but store the cos and sin of t in a vec2 for efficiency.
// Initial guess: t = cos(pi/4)
vec2 tTrigs = vec2(0.70710678118); vec2 v = radii * tTrigs;
// Find the evolute of the ellipse (center of curvature) at v.
vec2 evolute = evoluteScale * tTrigs * tTrigs * tTrigs; // Find the (approximate) intersection of p - evolute with the ellipsoid.
vec2 q = normalize(p - evolute) * length(v - evolute); // Update the estimate of t.
tTrigs = (q + evolute) * inverseRadii; tTrigs = normalize(clamp(tTrigs, 0.0, 1.0)); v = radii * tTrigs;
return v * sign(pos);}
vec3 computeEllipsoidPositionWC(vec3 positionMC) { // Get the world-space position and project onto a meridian plane of
// the ellipsoid
vec3 positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
vec2 positionEllipse = vec2(length(positionWC.xy), positionWC.z); vec2 nearestPoint = nearestPointOnEllipseFast(positionEllipse, czm_ellipsoidRadii.xz);
// Reconstruct a 3D point in world space
return vec3(nearestPoint.x * normalize(positionWC.xy), nearestPoint.y);}
void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection, float distanceToCamera) {
vec3 fogColor = groundAtmosphereColor.rgb;
// If there is dynamic lighting, apply that to the fog.
const float NONE = 0.0; if (czm_atmosphereDynamicLighting != NONE) { float darken = clamp(dot(normalize(czm_viewerPositionWC), lightDirection), czm_fogMinimumBrightness, 1.0); fogColor *= darken; }
// Tonemap if HDR rendering is disabled
#ifndef HDR fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb); fogColor.rgb = czm_inverseGamma(fogColor.rgb); #endif
vec3 withFog = czm_fog(distanceToCamera, color.rgb, fogColor, czm_fogVisualDensityScalar); color = vec4(withFog, color.a);}
void atmosphereStage(inout vec4 color, in ProcessedAttributes attributes) { vec3 rayleighColor; vec3 mieColor; float opacity;
vec3 positionWC; vec3 lightDirection;
// When the camera is in space, compute the position per-fragment for
// more accurate ground atmosphere. All other cases will use
//
// The if condition will be added in https://github.com/CesiumGS/cesium/issues/11717
if (false) { positionWC = computeEllipsoidPositionWC(attributes.positionMC); lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);
// The fog color is derived from the ground atmosphere color
czm_computeGroundAtmosphereScattering( positionWC, lightDirection, rayleighColor, mieColor, opacity ); } else { positionWC = attributes.positionWC; lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting); rayleighColor = v_atmosphereRayleighColor; mieColor = v_atmosphereMieColor; opacity = v_atmosphereOpacity; }
//color correct rayleigh and mie colors
const bool ignoreBlackPixels = true; rayleighColor = czm_applyHSBShift(rayleighColor, czm_atmosphereHsbShift, ignoreBlackPixels); mieColor = czm_applyHSBShift(mieColor, czm_atmosphereHsbShift, ignoreBlackPixels);
vec4 groundAtmosphereColor = czm_computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
if (u_isInFog) { float distanceToCamera = length(attributes.positionEC); applyFog(color, groundAtmosphereColor, lightDirection, distanceToCamera); } else { // Ground atmosphere
}}`;var r2=`void atmosphereStage(ProcessedAttributes attributes) { vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_positionWC, czm_atmosphereDynamicLighting);
czm_computeGroundAtmosphereScattering( // This assumes the geometry stage came before this.
v_positionWC, lightDirection, v_atmosphereRayleighColor, v_atmosphereMieColor, v_atmosphereOpacity );}`;var Gue={name:"AtmospherePipelineStage"};Gue.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_ATMOSPHERE",void 0,he.BOTH),i.addDefine("COMPUTE_POSITION_WC_ATMOSPHERE",void 0,he.BOTH),i.addVarying("vec3","v_atmosphereRayleighColor"),i.addVarying("vec3","v_atmosphereMieColor"),i.addVarying("float","v_atmosphereOpacity"),i.addVertexLines([r2]),i.addFragmentLines([o2]),i.addUniform("bool","u_isInFog",he.FRAGMENT),e.uniformMap.u_isInFog=function(){let o=d.distance(n.camera.positionWC,t.boundingSphere.center);return D.fog(o,n.fog.density)>D.EPSILON3}};var a2=Gue;var s2=`#ifdef DIFFUSE_IBLvec3 sampleDiffuseEnvironment(vec3 cubeDir){ #ifdef CUSTOM_SPHERICAL_HARMONICS return czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients); #else return czm_sphericalHarmonics(cubeDir, czm_sphericalHarmonicCoefficients); #endif}#endif
#ifdef SPECULAR_IBLvec3 sampleSpecularEnvironment(vec3 cubeDir, float roughness){ #ifdef CUSTOM_SPECULAR_IBL float lod = roughness * model_specularEnvironmentMapsMaximumLOD; return czm_textureCube(model_specularEnvironmentMaps, cubeDir, lod).rgb; #else float lod = roughness * czm_specularEnvironmentMapsMaximumLOD; return czm_textureCube(czm_specularEnvironmentMaps, cubeDir, lod).rgb; #endif}vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, vec3 f0, float roughness){ // see https://bruop.github.io/ibl/ at Single Scattering Results
// Roughness dependent fresnel, from Fdez-Aguera
vec3 f90 = max(vec3(1.0 - roughness), f0); vec3 F = fresnelSchlick2(f0, f90, NdotV);
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg; vec3 specularSample = sampleSpecularEnvironment(cubeDir, roughness);
return specularSample * (F * brdfLut.x + brdfLut.y);}#endif
#if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)/** * Compute the light contributions from environment maps and spherical harmonic coefficients. * See Fdez-Aguera, https://www.jcgt.org/published/0008/01/03/paper.pdf, for explanation
* of the single- and multi-scattering terms. * * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position. * @param {vec3} normalEC The surface normal in eye coordinates. * @param {czm_modelMaterial} The material properties. * @return {vec3} The computed HDR color. */vec3 textureIBL(vec3 viewDirectionEC, vec3 normalEC, czm_modelMaterial material) { vec3 f0 = material.specular; float roughness = material.roughness; float specularWeight = 1.0; #ifdef USE_SPECULAR specularWeight = material.specularWeight; #endif float NdotV = clamp(dot(normalEC, viewDirectionEC), 0.0, 1.0);
// see https://bruop.github.io/ibl/ at Single Scattering Results
// Roughness dependent fresnel, from Fdez-Aguera
vec3 f90 = max(vec3(1.0 - roughness), f0); vec3 singleScatterFresnel = fresnelSchlick2(f0, f90, NdotV);
vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg; vec3 FssEss = specularWeight * (singleScatterFresnel * brdfLut.x + brdfLut.y);
#ifdef DIFFUSE_IBL vec3 normalMC = normalize(model_iblReferenceFrameMatrix * normalEC); vec3 irradiance = sampleDiffuseEnvironment(normalMC);
vec3 averageFresnel = f0 + (1.0 - f0) / 21.0; float Ems = specularWeight * (1.0 - brdfLut.x - brdfLut.y); vec3 FmsEms = FssEss * averageFresnel * Ems / (1.0 - averageFresnel * Ems); vec3 dielectricScattering = (1.0 - FssEss - FmsEms) * material.diffuse; vec3 diffuseContribution = irradiance * (FmsEms + dielectricScattering) * model_iblFactor.x; #else vec3 diffuseContribution = vec3(0.0); #endif
#ifdef USE_ANISOTROPY // Bend normal to account for anisotropic distortion of specular reflection
vec3 anisotropyDirection = material.anisotropicB; vec3 anisotropicTangent = cross(anisotropyDirection, viewDirectionEC); vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection); float bendFactor = 1.0 - material.anisotropyStrength * (1.0 - roughness); float bendFactorPow4 = bendFactor * bendFactor * bendFactor * bendFactor; vec3 bentNormal = normalize(mix(anisotropicNormal, normalEC, bendFactorPow4)); vec3 reflectEC = reflect(-viewDirectionEC, bentNormal); #else vec3 reflectEC = reflect(-viewDirectionEC, normalEC); #endif
#ifdef SPECULAR_IBL vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflectEC); vec3 radiance = sampleSpecularEnvironment(reflectMC, roughness); vec3 specularContribution = radiance * FssEss * model_iblFactor.y; #else vec3 specularContribution = vec3(0.0); #endif
return diffuseContribution + specularContribution;}#endif`;var Vue={name:"ImageBasedLightingPipelineStage"},y6e=new Q;Vue.process=function(e,t,n){let i=t.imageBasedLighting,o=t.environmentMapManager,r=e.shaderBuilder,a;l(i.specularEnvironmentMaps)||(a=o.radianceCubeMap);let s=i.sphericalHarmonicCoefficients??o.sphericalHarmonicCoefficients;r.addDefine("USE_IBL_LIGHTING",void 0,he.FRAGMENT),r.addUniform("vec2","model_iblFactor",he.FRAGMENT),Om.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&r.addUniform("mat3","model_iblReferenceFrameMatrix",he.FRAGMENT),l(a)&&r.addDefine("COMPUTE_POSITION_WC_ATMOSPHERE",void 0,he.BOTH),l(s)&&l(s[0])?(r.addDefine("DIFFUSE_IBL",void 0,he.FRAGMENT),r.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,he.FRAGMENT),r.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",he.FRAGMENT)):i.useDefaultSphericalHarmonics&&r.addDefine("DIFFUSE_IBL",void 0,he.FRAGMENT),l(i.specularEnvironmentCubeMap)&&i.specularEnvironmentCubeMap.ready||l(a)?(r.addDefine("SPECULAR_IBL",void 0,he.FRAGMENT),r.addDefine("CUSTOM_SPECULAR_IBL",void 0,he.FRAGMENT),r.addUniform("samplerCube","model_specularEnvironmentMaps",he.FRAGMENT),r.addUniform("float","model_specularEnvironmentMapsMaximumLOD",he.FRAGMENT)):t.useDefaultSpecularMaps&&r.addDefine("SPECULAR_IBL",void 0,he.FRAGMENT)),r.addFragmentLines(s2);let c={model_iblFactor:function(){return Q.multiplyByScalar(i.imageBasedLightingFactor,o?.intensity||1,y6e)},model_iblReferenceFrameMatrix:function(){return t._iblReferenceFrameMatrix},model_sphericalHarmonicCoefficients:function(){return s},model_specularEnvironmentMaps:function(){return i.specularEnvironmentCubeMap.texture},model_specularEnvironmentMapsMaximumLOD:function(){return i.specularEnvironmentCubeMap.maximumMipmapLevel}};l(a)&&(c.model_specularEnvironmentMaps=function(){return a},c.model_specularEnvironmentMapsMaximumLOD=function(){return o.maximumMipmapLevel}),e.uniformMap=Pt(c,e.uniformMap)};var c2=Vue;var C6e=D.EPSILON16;function pq(e){e=e??V.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(pq.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=D.clamp(e,this.minimumValue,this.maximumValue),D.equalsEpsilon(this._currentValue,e,C6e)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});var E6e=new d,mq=new J;pq.prototype.applyStageToMatrix=function(e){let t=this.type,n=this.currentValue,i=E6e,o;switch(t){case xl.XROTATE:o=J.fromRotationX(D.toRadians(n),mq),e=P.multiplyByMatrix3(e,o,e);break;case xl.YROTATE:o=J.fromRotationY(D.toRadians(n),mq),e=P.multiplyByMatrix3(e,o,e);break;case xl.ZROTATE:o=J.fromRotationZ(D.toRadians(n),mq),e=P.multiplyByMatrix3(e,o,e);break;case xl.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=P.multiplyByTranslation(e,i,e);break;case xl.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=P.multiplyByTranslation(e,i,e);break;case xl.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=P.multiplyByTranslation(e,i,e);break;case xl.XSCALE:i.x=n,i.y=1,i.z=1,e=P.multiplyByScale(e,i,e);break;case xl.YSCALE:i.x=1,i.y=n,i.z=1,e=P.multiplyByScale(e,i,e);break;case xl.ZSCALE:i.x=1,i.y=1,i.z=n,e=P.multiplyByScale(e,i,e);break;case xl.UNIFORMSCALE:e=P.multiplyByUniformScale(e,n,e);break;default:break}return e};var l2=pq;function u2(e){e=e??V.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,I6e(this)}Object.defineProperties(u2.prototype,{articulation:{get:function(){return this._articulation}},sceneGraph:{get:function(){return this._sceneGraph}},name:{get:function(){return thi
{ 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 sx={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};sx.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,he.FRAGMENT),i.addFragmentLines(d2);let o={},r=t.color;r.alpha===0&&!t.hasSilhouette(n)&&(e.renderStateOptions.colorMask={red:!1,green:!1,blue:!1,alpha:!1}),r.alpha<1&&(e.alphaOptions.pass=Be.TRANSLUCENT),i.addUniform("vec4",sx.COLOR_UNIFORM_NAME,he.FRAGMENT),o[sx.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",sx.COLOR_BLEND_UNIFORM_NAME,he.FRAGMENT),o[sx.COLOR_BLEND_UNIFORM_NAME]=function(){return bl.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=Pt(o,e.uniformMap)};var xE=sx;var h2=`#ifdef USE_CLIPPING_PLANES_FLOAT_TEXTUREvec4 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 Hue={name:"ModelClippingPlanesPipelineStage"},T6e=new Q;Hue.process=function(e,t,n){let i=t.clippingPlanes,o=n.context,r=e.shaderBuilder;r.addDefine("HAS_CLIPPING_PLANES",void 0,he.FRAGMENT),r.addDefine("CLIPPING_PLANES_LENGTH",i.length,he.FRAGMENT),i.unionClippingRegions&&r.addDefine("UNION_CLIPPING_REGIONS",void 0,he.FRAGMENT),Ca.useFloatTexture(o)&&r.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,he.FRAGMENT);let a=Ca.getTextureResolution(i,o,T6e);r.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",a.x,he.FRAGMENT),r.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",a.y,he.FRAGMENT),r.addUniform("sampler2D","model_clippingPlanes",he.FRAGMENT),r.addUniform("vec4","model_clippingPlanesEdgeStyle",he.FRAGMENT),r.addUniform("mat4","model_clippingPlanesMatrix",he.FRAGMENT),r.addFragmentLines(h2);let s={model_clippingPlanes:function(){return i.texture},model_clippingPlanesEdgeStyle:function(){let c=U.clone(i.edgeColor);return c.alpha=i.edgeWidth,c},model_clippingPlanesMatrix:function(){return t._clippingPlanesMatrix}};e.uniformMap=Pt(s,e.uniformMap)};var m2=Hue;var p2=`void modelClippingPolygonsStage(ProcessedAttributes attributes){ vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC); sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
vec2 minDistance = vec2(czm_infinity); v_regionIndex = -1; v_clippingPosition = vec2(czm_infinity);
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) { vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex); vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0)); vec2 distance = abs(rectUv - clamped) * extents.wz; if (minDistance.x > distance.x || minDistance.y > distance.y) { minDistance = distance; v_clippingPosition = rectUv; }
float threshold = 0.01; if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) { v_regionIndex = regionIndex; } }}`;var A2=`void modelClippingPolygonsStage(){ vec2 clippingPosition = v_clippingPosition; int regionIndex = v_regionIndex; czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);}`;var Wue={name:"ModelClippingPolygonsPipelineStage"};Wue.process=function(e,t,n){let i=t.clippingPolygons,o=e.shaderBuilder;o.addDefine("ENABLE_CLIPPING_POLYGONS",void 0,he.BOTH),i.inverse&&o.addDefine("CLIPPING_INVERSE",void 0,he.FRAGMENT),o.addDefine("CLIPPING_POLYGON_REGIONS_LENGTH",i.extentsCount,he.BOTH),o.addUniform("sampler2D","model_clippingDistance",he.FRAGMENT),o.addUniform("sampler2D","model_clippingExtents",he.VERTEX),o.addVarying("vec2","v_clippingPosition"),o.addVarying("int","v_regionIndex","flat"),o.addVertexLines(p2),o.addFragmentLines(A2);let r={model_clippingDistance:function(){return i.clippingTexture??n.context.defaultTexture},model_clippingExtents:function(){return i.extentsTexture??n.context.defaultTexture}};e.uniformMap=Pt(r,e.uniformMap)};var g2=Wue;function jue(e,t){this._model=e,this._runtimeNode=t}Object.defineProperties(jue.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){l(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 _2=jue;var y2=`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_INSTANCINGmat4 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 C2=`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 E2=`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 I2=new P,S6e=new P,w6e=new P,que={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:$ue,_transformsToTypedArray:gq};que.process=function(e,t,n){let i=t.instances,o=i.attributes[0].count,r=e.shaderBuilder;r.addDefine("HAS_INSTANCING"),r.addVertexLines(y2);let a=e.model,s=a.sceneGraph,c=e.runtimeNode,u=n.mode!==oe.SCENE3D&&!n.scene3DOnly&&a._projectTo2D,f=a._enablePick&&!n.context.webgl2,h=[];G6e(e,n,i,h,u,f),W6e(e,n,i,h);let p={};if(i.transformInWorldSpace?(r.addDefine("USE_LEGACY_INSTANCING",void 0,he.VERTEX),r.addUniform("mat4","u_instance_modifiedModelView",he.VERTEX),r.addUniform("mat4","u_instance_nodeTransform",he.VERTEX),p.u_instance_modifiedModelView=function(){let A=P.multiplyTransformation(a.modelMatrix,s.components.transform,I2);return u?P.multiplyTransformation(n.context.uniformState.view3D,A,I2):(n.mode!==oe.SCENE3D&&(A=At.basisTo2D(n.mapProjection,A,I2)),P.multiplyTransformation(n.context.uniformState.view,A,I2))},p.u_instance_nodeTransform=function(){return P.multiplyTransformation(s.axisCorrectionMatrix,c.computedTransform,S6e)},r.addVertexLines(E2)):r.addVertexLines(C2),u){r.addDefine("USE_2D_INSTANCING",void 0,he.VERTEX),r.addUniform("mat4","u_modelView2D",he.VERTEX);let A=n.context,m=P.fromTranslation(c.instancingReferencePoint2D,new P);p.u_modelView2D=function(){return P.multiplyTransformation(A.uniformState.view,m,w6e)}}e.uniformMap=Pt(p,e.uniformMap),e.instanceCount=o,oi(e.attributes,h)};var iD=new P,B6e=new d;function D6e(e,t,n,i,o){let r=P.multiplyTransformation(t,e,iD);return r=P.multiplyTransformation(r,n,iD),o=At.basisTo2D(i.mapProjection,r,o),o}function v6e(e,t,n,i,o){let r=P.fromTranslation(e,iD),a=P.multiplyTransformation(t,r,iD);a=P.multiplyTransformation(a,n,iD);let s=P.getTranslation(a,B6e);return o=co.computeActualEllipsoidPosition(i,s,o),o}function Kue(e,t,n){let i=e.model,o=i.sceneGraph;e.runtimeNode.node.instances.transformInWorldSpace?(t=P.multiplyTransformation(i.modelMatrix,o.components.transform,t),n=P.multiplyTransformation(o.axisCorrectionMatrix,e.runtimeNode.computedTransform,n)):(t=P.clone(o.computedModelMatrix,t),t=P.multiplyTransformation(t,e.runtimeNode.computedTransform,t),n=P.clone(P.IDENTITY,n))}var Xue=new P,Jue=new P,P6e=new P,R6e=new d;function M6e(e,t,n,i){let o=Xue,r=Jue;Kue(t,o,r);let s=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){let f=e[u],h=D6e(f,o,r,n,P6e),p=P.getTranslation(h,R6e),A=d.subtract(p,s,p);i[u]=P.setTranslation(h,A,i[u])}return i}function N6e(e,t,n,i){let o=Xue,r=Jue;Kue(t,o,r);let s=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){let f=e[u],h=v6e(f,o,r,n,f);i[u]=d.subtract(h,s,i[u])}return i}var L6e=new d,O6e=new d;function Zue(e,t){let n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,o=P.multiplyByPoint(i,n.instancingTranslationMin,L6e),r=co.computeActualEllipsoidPosition(t,o,o),a=P.multiplyByPoint(i,n.instancingTranslationMax,O6e),s=co.computeActualEllipsoidPosition(t,a,a);n.instancingReferencePoint2D=d.lerp(r,s,.5,new d)}function gq(e){let n=e.length,i=new Float32Array(n*12);for(let o=0;o<n;o++){let r=e[o],a=12*o;i[a+0]=r[0],i[a+1]=r[4],i[a+2]=r[8],i[a+3]=r[12],i[a+4]=r[1],i[a+5]=r[5],i[a+6]=r[9],i[a+7]=r[13],i[a+8]=r[2],i[a+9]=r[6],i[a+10]=r[10],i[a+11]=r[14]}return i}function F6e(e){let n=e.length,i=new Float32Array(n*3);for(let o=0;o<n;o++){let r=e[o],a=3*o;i[a+0]=r[0],i[a+1]=r[4],i[a+2]=r[8]}return i}var Q6e=new d,k6e=new Qe,U6e=new d;function $ue(e,t,n){let i=new Array(t),o=Tt.getAttributeBySemantic(e,Ua.TRANSLATION),r=Tt.getAttributeBySemantic(e,Ua.ROTATION),a=Tt.getAttributeBySemantic(e,Ua.SCALE),s=new d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=new d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),u=l(o),f=l(r),h=l(a),p=u?o.typedArray:new Float32Array(t*3),A=f?r.typedArray:new Float32Array(t*4);f&&r.normalized&&(A=tn.dequantize(A,r.componentDatatype,r.type,t));let m;h?m=a.typedArray:(m=new Float32Array(t*3),m.fill(1));for(let y=0;y<t;y++){let C=new d(p[y*3],p[y*3+1],p[y*3+2],Q6e);d.maximumByComponent(s,C,s),d.minimumByComponent(c,C,c);let
{ 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 P2=`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 sfe={name:"CPUStylingPipelineStage"};sfe.process=function(e,t,n){let i=e.model,o=e.shaderBuilder;o.addVertexLines(v2),o.addFragmentLines(P2),o.addDefine("USE_CPU_STYLING",void 0,he.BOTH),l(i.color)||(o.addUniform("float",xE.COLOR_BLEND_UNIFORM_NAME,he.FRAGMENT),e.uniformMap[xE.COLOR_BLEND_UNIFORM_NAME]=function(){return bl.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),o.addUniform("bool","model_commandTranslucent",he.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===Be.TRANSLUCENT}};var R2=sfe;var cfe={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};cfe.getDefineName=function(e){return`CUSTOM_SHADER_${e}`};var U_=Object.freeze(cfe);var M2=`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 N2=`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 L2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) { initializeFeatureIds(featureIds, attributes); initializeFeatureIdAliases(featureIds);}`;var O2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) { initializeFeatureIds(featureIds, attributes); initializeFeatureIdAliases(featureIds); setFeatureIdVaryings();}`;var eo={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()"};eo.process=function(e,t,n){let i=e.shaderBuilder;K6e(i);let o=e.runtimeNode.node.instances;l(o)&&X6e(e,o,n),J6e(e,t,n),i.addVertexLines(O2),i.addFragmentLines(L2)};function K6e(e){e.addStruct(eo.STRUCT_ID_FEATURE_IDS_VS,eo.STRUCT_NAME_FEATURE_IDS,he.VERTEX),e.addStruct(eo.STRUCT_ID_FEATURE_IDS_FS,eo.STRUCT_NAME_FEATURE_IDS,he.FRAGMENT),e.addFunction(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,eo.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,he.VERTEX),e.addFunction(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,eo.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,he.FRAGMENT),e.addFunction(eo.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,eo.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,he.VERTEX),e.addFunction(eo.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,eo.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,he.FRAGMENT),e.addFunction(eo.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,eo.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,he.VERTEX)}function X6e(e,t,n){let i=t.featureIds,o=t.attributes[0].count;for(let r=0;r<i.length;r++){let a=i[r],s=a.positionalLabel;a instanceof bn.FeatureIdAttribute?Z6e(e,a,s):lfe(e,a,s,o,1,n);let c=a.label;l(c)&&ufe(e,s,c,he.BOTH)}}function J6e(e,t,n){let i=t.featureIds,r=Tt.getAttributeBySemantic(t,at.POSITION).count;for(let a=0;a<i.length;a++){let s=i[a],c=s.positionalLabel,u=he.BOTH;s instanceof bn.FeatureIdAttribute?$6e(e,s,c):s instanceof bn.FeatureIdImplicitRange?lfe(e,s,c,r,void 0,n):(eYe(e,s,c,a,n),u=he.FRAGMENT);let f=s.label;l(f)&&ufe(e,c,f,u)}}function Z6e(e,t,n){let i=e.shaderBuilder;i.addStructField(eo.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(eo.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),a=`a_${r}${o}`,s=`v_${r}${o}`,c=`featureIds.${n} = int(czm_round(${a}));`,u=`featureIds.${n} = int(czm_round(${s}));`;i.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[u]),i.addVarying("float",s),i.addFunctionLines(eo.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${s} = ${a};`])}function $6e(e,t,n){let i=e.shaderBuilder;i.addStructField(eo.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(eo.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),a=[`featureIds.${n} = int(czm_round(attributes.${r}${o}));`];i.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,a),i.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,a)}function lfe(e,t,n,i,o,r){tYe(e,t,i,o,r);let a=e.shaderBuilder,s=`a_implicit_${n}`;a.addAttribute("float",s);let c=`v_implicit_${n}`;a.addVarying("float",c),a.addStructField(eo.STRUCT_ID_FEATURE_IDS_VS,"int",n),a.addStructField(eo.STRUCT_ID_FEATURE_IDS_FS,"int",n),a.addFunctionLines(eo.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${c} = ${s};`]),a.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[`featureIds.${n} = int(czm_round(${s}));`]),a.addFunctionLines(eo.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[`featureIds.${n} = int(czm_round(${c}));`])}function eYe(e,t,n,i,o){let r=`u_featureIdTexture_${i}`,a=e.uniformMap,s=t.textureReader;a[r]=function(){return s.texture??o.context.defaultTexture};let c=s.channels,u=e.shaderBuilder;u.addStructField(eo.STRUCT_ID_FEATURE_IDS_FS,"int",n),u.addUniform("sampler2D",r,he.FRAGMENT);let h=`v_texCoord_${s.texCoord}`,p=h,A=s.transform;if(l(A)&&
FeatureIds featureIds, out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes ){ initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);}`;var Q2=`void metadataStage( FeatureIds featureIds, out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes ){ initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes); setMetadataVaryings();}`;var Ci={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(FeatureIds featureIds, 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"}]};Ci.process=function(e,t,n){let{shaderBuilder:i,model:o}=e,{structuralMetadata:r={},content:a}=o,s=a?.tileset.metadataExtension?.statistics,c=n.context.webgl2,u=EYe(o,t),f=iYe(r.propertyAttributes,t,s),h=rYe(r.propertyTextures,s),p=cYe(r.propertyTables,t,e,s,u),A=f.concat(h).concat(p);fYe(i,A),mYe(i),i.addVertexLines(Q2),i.addFragmentLines(F2);for(let m=0;m<f.length;m++){let _=f[m];pYe(e,_)}for(let m=0;m<h.length;m++){let _=h[m];gYe(e,_,c)}for(let m=0;m<p.length;m++){let _=p[m];yYe(e,_,c)}};function iYe(e,t,n){return l(e)?e.flatMap(i=>oYe(i,t,n)):[]}function oYe(e,t,n){let{getAttributeByName:i,getAttributeInfo:o,sanitizeGlslIdentifier:r}=Tt,a=e.class.id,s=n?.classes[a],c=Object.entries(e.properties),u=new Array(c.length);for(let f=0;f<c.length;f++){let[h,p]=c[f],A=i(t,p.attribute),{glslType:m,variableName:_}=o(A);u[f]={metadataVariable:r(h),property:p,classProperty:p.classProperty,type:p.classProperty.type,glslType:m,variableName:_,propertyStatistics:s?.properties[h],shaderDestination:he.BOTH}}return u}function rYe(e,t){return l(e)?e.flatMap(n=>aYe(n,t)):[]}function aYe(e,t){let{sanitizeGlslIdentifier:n}=Tt,i=e.class.id,o=t?.classes[i],r=Object.entries(e.properties).filter(([s,c])=>{let u=c.textureReader.channels.length;return c.classProperty.isGpuCompatible(u)}),a=new Array(r.length);for(let s=0;s<r.length;s++){let[c,u]=r[s];a[s]={metadataVariable:n(c),property:u,classProperty:u.classProperty,type:u.classProperty.type,glslType:u.classProperty.getGlslType(),propertyStatistics:o?.properties[c],shaderDestination:he.FRAGMENT}}return a}var sYe=4;function cYe(e,t,n,i,o){if(!l(e))return[];let r=uYe(n,t);return e.filter(a=>l(a.class)&&r.has(String(a.id))).flatMap(a=>lYe(a,r,i,o))}function lYe(e,t,n,i){let{sanitizeGlslIdentifier:o}=Tt,r=e.class,a=n?.classes[r.id],s=t.get(String(e.id))??{},c=s.shaderDestination??he.BOTH,u=e.properties,f=r.properties,h=[],p=0;for(let[A,m]of Object.entries(f)){if(!m.isGpuCompatible(sYe))continue;let _=u[A],y=he.intersection(xYe(A,i),c);if(y===he.NONE){p++;continue}h.push({metadataVariable:o(A),property:_,classProperty:m,type:m.type,glslType:m.getGlslType(),propertyStatistics:a?.properties[A],shaderDestination:y,propertyTable:e,featureIdVariableName:s.variableName,propertyInfoIndex:p}),p++}return h}function uYe(e,t){let n=new Map;function i(s,c){let u=s?.propertyTableId;if(!l(u))return;let f=String(u),h={variableName:s.positionalLabel,shaderDestination:c},p=n.get(f);l(p)&&console.warn(`Multiple feature ID sets reference the same property table ${u} in primitive. Only one will be used.`),n.set(f,h)}let o=t?.featureIds??[];for(let s=0;s<o.length;s++){let c=o[s],u=l(c?.texture
if (u_isEdgePass) { return; }
vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;
vec4 edgeColor = texture(czm_edgeColorTexture, screenCoord); vec4 edgeId = texture(czm_edgeIdTexture, screenCoord);
// Packed window-space depth from edge pass (0..1)
float edgeDepthWin = czm_unpackDepth(texture(czm_edgeDepthTexture, screenCoord));
// Near / far for current frustum
float n = czm_currentFrustum.x; float f = czm_currentFrustum.y;
// geometry depth in eye coordinate
vec4 geomEC = czm_windowToEyeCoordinates(gl_FragCoord); float geomDepthLinear = -geomEC.z;
// Convert edge depth to linear depth
float z_ndc_edge = edgeDepthWin * 2.0 - 1.0; float edgeDepthLinear = (2.0 * n * f) / (f + n - z_ndc_edge * (f - n));
float d = abs(edgeDepthLinear - geomDepthLinear);
// Adaptive epsilon using linear depth fwidth for robustness
float pixelStepLinear = fwidth(geomDepthLinear); float rel = geomDepthLinear * 0.0005; float eps = max(n * 1e-4, max(pixelStepLinear * 1.5, rel));
// If Edge isn't behind any geometry and the pixel has edge data
if (d < eps && edgeId.r > 0.0) {#ifdef HAS_EDGE_FEATURE_ID float edgeFeatureId = edgeId.g; float currentFeatureId = float(featureIds.featureId_0);#endif float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord)); // Background / sky / globe: always show edge
bool isBackground = geomDepthLinear > globeDepth; bool drawEdge = isBackground;
#ifdef HAS_EDGE_FEATURE_ID bool hasEdgeFeature = edgeFeatureId > 0.0; bool hasCurrentFeature = currentFeatureId > 0.0; bool featuresMatch = edgeFeatureId == currentFeatureId;
drawEdge = drawEdge || !hasEdgeFeature || !hasCurrentFeature || featuresMatch;#else drawEdge = true;#endif
if (drawEdge) { color = edgeColor; } }}`;var gfe={name:"EdgeDetectionPipelineStage"};gfe.process=function(e){e.shaderBuilder.addFragmentLines([z2])};var G2=gfe;var V2=`// CESIUM_REDIRECTED_COLOR_OUTPUT flag is used to avoid color attachment conflicts
// when shaders are processed by different rendering pipelines (e.g., OIT).
// Only declare MRT outputs when not in a derived shader context.
#if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)layout(location = 1) out vec4 out_id; // edge id / metadata
layout(location = 2) out vec4 out_edgeDepth; // packed depth
#endif
void edgeVisibilityStage(inout vec4 color, inout FeatureIds featureIds){#ifdef HAS_EDGE_VISIBILITY
if (!u_isEdgePass) { return; } float edgeTypeInt = v_edgeType * 255.0;
if (edgeTypeInt < 0.5) { discard; }
if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) { // silhouette candidate
// Silhouette check done in vertex shader
// v_shouldDiscard will be > 0.5 if this edge should be discarded
if (v_shouldDiscard > 0.5) { discard; } }
vec4 finalColor = color;#ifdef HAS_EDGE_COLOR_ATTRIBUTE if (v_edgeColor.a >= 0.0) { finalColor = v_edgeColor; }#endif
#ifdef HAS_LINE_PATTERN // Pattern is 16-bit, each bit represents visibility at that position
const float maskLength = 16.0; // Get the relative position within the dash from 0 to 1
float dashPosition = fract(v_lineCoord / maskLength); // Figure out the mask index
float maskIndex = floor(dashPosition * maskLength); // Test the bit mask
float maskTest = floor(u_linePattern / pow(2.0, maskIndex)); // If bit is 0 (gap), discard the fragment (use < 1.0 for better numerical stability)
if (mod(maskTest, 2.0) < 1.0) { discard; }#endif color = finalColor; #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT) // Write edge metadata
out_id = vec4(0.0); out_id.r = edgeTypeInt; // Edge type (0-3)
#ifdef HAS_EDGE_FEATURE_ID out_id.g = float(featureIds.featureId_0); // Feature ID if available
#else out_id.g = 0.0;#endif // Pack depth into separate MRT attachment
out_edgeDepth = czm_packDepth(gl_FragCoord.z); #endif#endif}`;var H2=`#ifdef HAS_EDGE_VISIBILITYvoid edgeVisibilityStageVS() { if (!u_isEdgePass) { return; }
v_edgeType = a_edgeType; v_silhouetteNormalView = czm_normal * a_silhouetteNormal; v_faceNormalAView = czm_normal * a_faceNormalA; v_faceNormalBView = czm_normal * a_faceNormalB; v_edgeOffset = a_edgeOffset;
// Silhouette detection: check both endpoints of the edge
v_shouldDiscard = 0.0; float edgeTypeInt = a_edgeType * 255.0; if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) { vec3 normalA = normalize(v_faceNormalAView); vec3 normalB = normalize(v_faceNormalBView); const float perpTol = 2.5e-4;
// Check at current vertex (first endpoint)
vec4 currentPosEC = czm_modelView * vec4(v_positionMC, 1.0); vec3 toEye1 = normalize(-currentPosEC.xyz); float dotA1 = dot(normalA, toEye1); float dotB1 = dot(normalB, toEye1);
// Check at other vertex (second endpoint)
vec4 otherPosEC = czm_modelView * vec4(a_edgeOtherPos, 1.0); vec3 toEye2 = normalize(-otherPosEC.xyz); float dotA2 = dot(normalA, toEye2); float dotB2 = dot(normalB, toEye2);
// Discard if EITHER endpoint is non-silhouette
if (dotA1 * dotB1 > perpTol || dotA2 * dotB2 > perpTol) { v_shouldDiscard = 1.0; } }
#ifdef HAS_EDGE_FEATURE_ID v_featureId_0 = a_edgeFeatureId;#endif
#ifdef HAS_EDGE_COLOR_ATTRIBUTE v_edgeColor = a_edgeColor;#endif
#ifdef HAS_LINE_PATTERN #ifdef HAS_EDGE_CUMULATIVE_DISTANCE v_lineCoord = a_edgeCumulativeDistance * u_pixelsPerWorld; #else vec4 currentClip = czm_modelViewProjection * vec4(v_positionMC, 1.0); vec2 currentScreen = ((currentClip.xy / currentClip.w) * 0.5 + 0.5) * czm_viewport.zw;
vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0); vec2 otherScreen = ((otherClip.xy / otherClip.w) * 0.5 + 0.5) * czm_viewport.zw; vec2 windowDir = otherScreen - currentScreen;
const float textureCoordinateBase = 8192.0; if (abs(windowDir.x) > abs(windowDir.y)) { v_lineCoord = textureCoordinateBase + currentScreen.x; } else { v_lineCoord = textureCoordinateBase + currentScreen.y; } #endif#endif
// Expand vertex to form quad
vec4 posClip = gl_Position;
if (length(a_edgeOtherPos) > 0.0 && abs(a_edgeOffset) > 0.0) { vec4 currentClip = posClip; vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0);
vec2 currentNDC = currentClip.xy / currentClip.w; vec2 otherNDC = otherClip.xy / otherClip.w;
vec2 edgeDirNDC = otherNDC - currentNDC;
// Ensure consistent edge direction
if (edgeDirNDC.x < 0.0 || (abs(edgeDirNDC.x) < 0.001 && edgeDirNDC.y < 0.0)) { edgeDirNDC = -edgeDirNDC; }
edgeDirNDC = normalize(edgeDirNDC); vec2 perpNDC = vec2(-edgeDirNDC.y, edgeDirNDC.x);
// Convert line width from pixels to clip space
float lineWidthPixels = u_lineWidth; vec2 viewportSize = czm_viewport.zw; vec2 clipPerPixel = (2.0 / viewportSize) * currentClip.w; vec2 offsetClip = perpNDC * lineWidthPixels * clipPerPixel * 0.5 * a_edgeOffset;
posClip.xy += offsetClip; }
gl_Position = posClip;}#endif`;var xq=class e{static readAttributeAsTypedArray(t){let n=e.readAttributeAsRawCompactTypedArray(t),i=t.normalized,o=t.quantization;if(!l(o)&&!i)return n;let r=t.type,a=t.count,s=n;return i&&(s=tn.dequantize(n,t.componentDatatype,r,a)),l(o)?e.dequantize(s,a,r,o):s}static readAttributeAsRawCompactTypedArray(t){let n=t.type,i=t.count,o=zt.getNumberOfComponents(n),r=i*o,a=t.componentDatatype,s=t.quantization;l(s)&&(a=s.componentDatatype);let c=t.buffer,u=t.byteOffset,f=t.byteStride,h=j.getSizeInBytes(a),p=o*h;if(!l(f)||f===p){let I=j.createTypedArray(a,r);return c.getBufferData(I,u),I}let A=new Uint8Array(c.sizeInBytes);c.getBufferData(A);let m=j.createTypedArray(a,r),_=f??p,y=new DataView(A.buffer,A.byteOffset,A.byteLength),C=new Array(o),E=e.createComponentsReader(a);for(let I=0;I<i;++I){let x=u+I*_;E(y,x,o,C);for(let S=0;S<o;++S)m[I*o+S]=C[S]}return m}static dequantize(t,n,i,o){if(o.octEncoded){let s=e.octDecode(t,n,o.normalizationRange,void 0);return o.octEncodedZXY&&e.convertZxyToXyz(s,s),s}let r=o.quantizedVolumeStepSize,a=o.quantizedVolumeOffset;if(i===zt.SCALAR)return e.dequantize1D(t,n,r,a,void 0);if(i===zt.VEC2)return e.dequantize2D(t,n,r,a,void 0);if(i===zt.VEC3)return e.dequantize3D(t,n,r,a,void 0);if(i===zt.VEC4)return e.dequantize4D(t,n,r,a,void 0);throw new de(`Element type for dequantization must be SCALAR, VEC2, VEC3, or VEC4, but is ${i}`)}static octDecode(t,n,i,o){l(o)||(o=new Float32Array(t.length));let r=new d;for(let a=0;a<n;a++)d.unpack(t,a*3,r),tn.octDecodeInRange(r,i,r),d.pack(o,r,a*3);return o}static convertZxyToXyz(t,n,i){l(i)||(i=new Float32Array(t.length));let o=0;for(let r=0;r<n;r++,o+=3){let a=t[o+0],s=t[o+1],c=t[o+2];i[o+0]=s,i[o+1]=c,i[o+2]=a}return i}static dequantize1D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));for(let a=0;a<n;a++){let c=t[a]*i+o;r[a]=c}return r}static dequantize2D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let a=new Q;for(let s=0;s<n;s++)Q.unpack(t,s*2,a),Q.multiplyComponents(a,i,a),Q.add(a,o,a),Q.pack(a,r,s*2);return r}static dequantize3D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let a=new d;for(let s=0;s<n;s++)d.unpack(t,s*3,a),d.multiplyComponents(a,i,a),d.add(a,o,a),d.pack(a,r,s*3);return r}static dequantize4D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let a=new ie;for(let s=0;s<n;s++)ie.unpack(t,s*4,a),ie.multiplyComponents(a,i,a),ie.add(a,o,a),ie.pack(a,r,s*4);return r}static createComponentsReader(t){let n=e.createComponentReader(t),i=j.getSizeInBytes(t);return function(o,r,a,s){let c=r;for(let u=0;u<a;++u)s[u]=n(o,c),c+=i}}static createComponentReader(t){switch(t){case j.BYTE:return function(n,i){return n.getInt8(i)};case j.UNSIGNED_BYTE:return function(n,i){return n.getUint8(i)};case j.SHORT:return function(n,i){return n.getInt16(i,!0)};case j.UNSIGNED_SHORT:return function(n,i){return n.getUint16(i,!0)};case j.INT:return function(n,i){return n.getInt32(i,!0)};case j.UNSIGNED_INT:return function(n,i){return n.getUint32(i,!0)};case j.FLOAT:return function(n,i){return n.getFloat32(i,!0)};case j.DOUBLE:return function(n,i){return n.getFloat64(i,!0)}}throw new de(`The componentType must be a valid ComponentDatatype, but is ${t}`)}static transform3D(t,n,i){l(i)||(i=new Float32Array(t.length));let o=new d,r=t.length/3;for(let a=0;a<r;a++)d.unpack(t,a*3,o),P.multiplyByPoint(n,o,o),d.pack(o,i,a*3);return i}static readIndicesAsTypedArray(t){let n=t.typedArray;if(l(n))return n;let i=t.buffer,o=t.count,r=t.indexDatatype,a=e.createIndexTypedArray(r,o);return i.getBufferData(a),a}static readIndicesAsTriangleIndicesTypedArray(t,n){let i=e.readIndicesAsTypedArray(t);if(n===Pe.TRIANGLES)return i;if(n===Pe.TRIANGLE_STRIP)return e.convertTriangleStripToTriangleIndices(i);if(n===Pe.TRIANGLE_FAN)return e.convertTriangleFanToTriangleIndices(i);throw new de(`The primitiveType must be TRIANGLES (${Pe.TRIANGLES}, TRIANGLE_STRIP (${Pe.TRIANGLE_STRIP}, or TRIANGLE_FAN (${Pe.TRIANGLE_FAN}, but is ${n}`)}static convertTriangleStripToTriangleIndices(t){let n=t.constructor((t.length-2)*3);for(let i=0;i<t.length-2;i++)i%2===1?(n[i*3+0]=t[i+0],n[i*3+1]=t[i+2],n[i*3+2]=t[i+
{ attributes.positionMC = v_positionMC; attributes.positionEC = v_positionEC;
#if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) 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 Y2=`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) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS) // 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 rD=`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 aD={name:"SelectedFeatureIdPipelineStage",STRUCT_ID_SELECTED_FEATURE:"SelectedFeature",STRUCT_NAME_SELECTED_FEATURE:"SelectedFeature"};aD.process=function(e,t,n){let i=e.shaderBuilder;e.hasPropertyTable=!0;let o=e.model,r=e.runtimeNode.node,a=qYe(o,r,t),s=a.shaderDestination;i.addDefine("HAS_SELECTED_FEATURE_ID",void 0,s),i.addDefine("SELECTED_FEATURE_ID",a.variableName,s),i.addDefine(a.featureIdDefine,void 0,s),KYe(i);let c=a.featureIds.nullFeatureId,u=e.uniformMap;l(c)&&(i.addDefine("HAS_NULL_FEATURE_ID",void 0,s),i.addUniform("int","model_nullFeatureId",s),u.model_nullFeatureId=function(){return c}),a.shaderDestination===he.BOTH&&i.addVertexLines(rD),i.addFragmentLines(rD)};function yfe(e){return e instanceof bn.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function Cfe(e){return e instanceof bn.FeatureIdTexture?he.FRAGMENT:he.BOTH}function qYe(e,t,n){let i,o;return l(t.instances)&&(o=Tt.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),l(o))?(i=o.label??o.positionalLabel,{featureIds:o,variableName:i,shaderDestination:Cfe(o),featureIdDefine:yfe(o)}):(o=Tt.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=o.label??o.positionalLabel,{featureIds:o,variableName:i,shaderDestination:Cfe(o),featureIdDefine:yfe(o)})}function KYe(e){e.addStructField(aD.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(aD.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(aD.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}var wE=aD;var Ts={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)"};Ts.process=function(e,t,n){let{shaderBuilder:i,model:o}=e;i.addStruct(Ts.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",he.VERTEX),i.addStruct(Ts.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",he.FRAGMENT),i.addStruct(wE.STRUCT_ID_SELECTED_FEATURE,wE.STRUCT_NAME_SELECTED_FEATURE,he.BOTH),i.addFunction(Ts.FUNCTION_ID_INITIALIZE_ATTRIBUTES,Ts.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,he.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(Ts.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(Ts.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(Ts.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,Ts.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,he.VERTEX),i.addFunction(Ts.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,Ts.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,he.FRAGMENT),o.type===Vr.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,he.FRAGMENT);let r=n.mode!==oe.SCENE3D&&!n.scene3DOnly&&o._projectTo2D,a=l(e.runtimeNode.node.instances),s=r&&!a,c=t.attributes.length;for(let u=0;u<c;u++){let f=t.attributes[u],h=zt.getAttributeLocationCount(f.type),p=f.semantic===at.POSITION,A;h>1?(A=e.attributeIndex,e.attributeIndex+=h):p&&!s?A=0:A=e.attributeIndex++;let m=!p&&t.primitiveType===Pe.POINTS&&n.context.webgl2?"flat":void 0;XYe(e,f,A,h,r,a,m)}rqe(i,t.attributes),t.primitiveType===Pe.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines(Y2),i.addFragmentLines(j2)};function XYe(e,t,n,i,o,r,a){let s=e.shaderBuilder,c=Tt.getAttributeInfo(t),u=o&&!r;i>1?$Ye(e,t,n,i):ZYe(e,t,n,u),tqe(s,c,u),eqe(s,c,a),l(t.semantic)&&JYe(s,t),nqe(s,c,o),iqe(s,c,u),oqe(s,c)}function JYe(e,t){let{semantic:n,setIndex:i}=t;switch(n){case at.NORMAL:e.addDefine("HAS_NORMALS");break;case at.TANGENT:e.addDefine("HAS_TANGENTS");break;case at.FEATURE_ID:e.addDefine(`HAS${n}_${i}`);break;case at.TEXCOORD:case at.COLOR:e.addDefine(`HAS_${n}_${i}`)}}function ZYe(e,t,n,i){let{quantization:o,semantic:r,setIndex:a}=t,{type:s,compone
${o}`),t}var vA=fqe;function X2(e,t,n,i,o,r,a){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=o,this.timesRetried=r??0,this.retry=!1,this.error=a}X2.reportError=function(e,t,n,i,o,r,a,s){let c=e;return l(e)?(c.provider=t,c.message=i,c.x=o,c.y=r,c.level=a,c.retry=!1,c.error=s,++c.timesRetried):c=new X2(t,i,o,r,a,0,s),l(n)&&n.numberOfListeners>0?n.raiseEvent(c):l(t)&&console.log(`An error occurred in "${t.constructor.name}": ${vA(i)}`),c};X2.reportSuccess=function(e){l(e)&&(e.timesRetried=-1)};var tr=X2;var dqe={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"},sD=Object.freeze(dqe);function cD(e){}cD.prototype.isReady=function(){return!0};cD.prototype.shouldDiscardImage=function(e){return cD.EMPTY_IMAGE===e};var J2;Object.defineProperties(cD,{EMPTY_IMAGE:{get:function(){return l(J2)||(J2=new Image,J2.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),J2}}});var lD=cD;function xfe(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}xfe.prototype.build=function(e){e._tileWidth=this.tileWidth,e._tileHeight=this.tileHeight,e._maximumLevel=this.maximumLevel,e._imageUrlSubdomains=this.imageUrlSubdomains,e._imageUrlTemplate=this.imageUrlTemplate;let t=e._attributionList=this.attributionList;t||(t=[]),e._attributionList=t;for(let n=0,i=t.length;n<i;++n){let o=t[n];if(o.credit instanceof Et)break;o.credit=new Et(o.attribution);let r=o.coverageAreas;for(let a=0,s=o.coverageAreas.length;a<s;++a){let c=r[a],u=c.bbox;c.bbox=new ce(D.toRadians(u[1]),D.toRadians(u[0]),D.toRadians(u[3]),D.toRadians(u[2]))}}};function hqe(e,t){if(e.resourceSets.length!==1)throw new ue("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;let i=n.imageryProviders;l(n.imageryProviders)&&(i=n.imageryProviders.filter(o=>o.coverageAreas?.some(r=>l(r.bbox)))),t.attributionList=i}function mqe(e,t,n){let i=`An error occurred while accessing ${e.url}`;throw l(t)&&l(t.message)&&(i+=`: ${t.message}`),tr.reportError(void 0,n,l(n)?n._errorEvent:void 0,i,void 0,void 0,void 0,t),new ue(i)}async function pqe(e,t,n){let i=e.url,o=rs._metadataCache[i];l(o)||(o=e.fetchJson(),rs._metadataCache[i]=o);try{let r=await o;return hqe(r,t)}catch(r){mqe(e,r,n)}}function rs(e){e=e??V.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=e.mapStyle??sD.AERIAL,this._mapLayer=e.mapLayer,this._culture=e.culture??"",this._key=e.key,this._tileDiscardPolicy=e.tileDiscardPolicy,l(this._tileDiscardPolicy)||(this._tileDiscardPolicy=new lD),this._proxy=e.proxy,this._credit=new Et(`<a href="https://www.microsoft.com/en-us/maps/bing-maps/product"><img src="${rs.logoUrl}" title="Bing Imagery"/></a>`),this._tilingScheme=new za({numberOfLevelZeroTilesX:2,numberOfLevelZeroTilesY:2,ellipsoid:e.ellipsoid}),this._tileWidth=void 0,this._tileHeight=void 0,this._maximumLevel=void 0,this._imageUrlTemplate=void 0,this._imageUrlSubdomains=void 0,this._attributionList=void 0,this._errorEvent=new _e}Object.defineProperties(rs.prototype,{url:{get:function(){return this._resource.url}},proxy:{get:function(){return this._resource.proxy}},key:{get:function(){return this._key}},mapStyle:{get:function(){return this._mapStyle}},mapLayer:{get:function(){return this._mapLayer}},culture:{get:function(){return this._culture}},tileWidth:{g
in vec2 v_textureCoordinates;
void main(){ out_FragColor = texture(u_texture, v_textureCoordinates);}`;var mk=`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));}`;var UKe={UNLOADED:0,TRANSITIONING:1,RECEIVED:2,TEXTURE_LOADED:3,READY:4,FAILED:5,INVALID:6,PLACEHOLDER:7},Hn=Object.freeze(UKe);function _x(e,t,n,i,o){if(this.imageryLayer=e,this.x=t,this.y=n,this.level=i,this.request=void 0,i!==0){let r=t/2|0,a=n/2|0,s=i-1;this.parent=e.getImageryFromCache(r,a,s)}this.state=Hn.UNLOADED,this.imageUrl=void 0,this.image=void 0,this.texture=void 0,this.textureWebMercator=void 0,this.credits=void 0,this.referenceCount=0,!l(o)&&e.ready&&(o=e.imageryProvider.tilingScheme.tileXYToRectangle(t,n,i)),this.rectangle=o}_x.createPlaceholder=function(e){let t=new _x(e,0,0,0);return t.addReference(),t.state=Hn.PLACEHOLDER,t};_x.prototype.addReference=function(){++this.referenceCount};_x.prototype.releaseReference=function(){return--this.referenceCount,this.referenceCount===0?(this.imageryLayer.removeImageryFromCache(this),l(this.parent)&&this.parent.releaseReference(),l(this.image)&&l(this.image.destroy)&&this.image.destroy(),l(this.texture)&&this.texture.destroy(),l(this.textureWebMercator)&&this.texture!==this.textureWebMercator&&this.textureWebMercator.destroy(),fe(this),0):this.referenceCount};_x.prototype.processStateMachine=function(e,t,n){this.state===Hn.UNLOADED&&!n&&(this.state=Hn.TRANSITIONING,this.imageryLayer._requestImagery(this)),this.state===Hn.RECEIVED&&(this.state=Hn.TRANSITIONING,this.imageryLayer._createTexture(e.context,this));let i=this.state===Hn.READY&&t&&!this.texture;(this.state===Hn.TEXTURE_LOADED||i)&&(this.state=Hn.TRANSITIONING,this.imageryLayer._reprojectTexture(e,this,t))};var mD=_x;function Lq(e,t,n){this.readyImagery=void 0,this.loadingImagery=e,this.textureCoordinateRectangle=t,this.textureTranslationAndScale=void 0,this.useWebMercatorT=n}Lq.prototype.freeResources=function(){l(this.readyImagery)&&this.readyImagery.releaseReference(),l(this.loadingImagery)&&this.loadingImagery.releaseReference()};Lq.prototype.processStateMachine=function(e,t,n){let i=this.loadingImagery,o=i.imageryLayer;if(i.processStateMachine(t,!this.useWebMercatorT,n),i.state===Hn.READY)return l(this.readyImagery)&&this.readyImagery.releaseReference(),this.readyImagery=this.loadingImagery,this.loadingImagery=void 0,this.textureTranslationAndScale=o._calculateTextureTranslationAndScale(e,this),!0;let r=i.parent,a;for(;l(r)&&(r.state!==Hn.READY||!this.useWebMercatorT&&!l(r.texture));)r.state!==Hn.FAILED&&r.state!==Hn.INVALID&&(a=a||r),r=r.parent;return this.readyImagery!==r&&(l(this.readyImagery)&&this.readyImagery.releaseReference(),this.readyImagery=r,l(r)&&(r.addReference(),this.textureTranslationAndScale=o._calculateTextureTranslationAndScale(e,this))),i.state===Hn.FAILED||i.state===Hn.INVALID?l(a)?(a.processStateMachine(t,!this.useWebMercatorT,n),!1):!0:!1};var pD=Lq;function Ri(e,t){this._imageryProvider=e,this._readyEvent=new _e,this._errorEvent=new _e,t=t??V.EMPTY_OBJECT,e=e??V.EMPTY_OBJECT,this.alpha=t.alpha??e._defaultAlpha??1,this.nightAlpha=t.nightAlpha??e._defaultNightAlpha??1,this.dayAlpha=t.dayAlpha??e._defaultDayAlpha??1,this.brightness=t.brightness??e._defaultBrightness??Ri.DEFAULT_BRIGHTNESS,this.contrast=t.contrast??e._defaultContrast??Ri.DEFAULT_CONTRAST,this.hue=t.hue??e._defaultHue??Ri.DEFAULT_HUE,this.saturation=t.saturation??e._defaultSaturation??Ri.DEFAULT_SATURATION,this.gamma=t.gamma??e._defaultGamma??Ri.DEFAULT_GAMMA,this.splitDirection=t.splitDirection??Ri.DEFAULT_SPLIT,this.minificationFilter=t.minificationFilter??e._defaultMinificationFilter??Ri.DEFAULT_MINIFICATION_FILTER,this.magnificationFilter=t.magnificationFilter??e._defaultMagnificationFilter??Ri.DEFAULT_MAGNIFICATION_FILTER,this.show=t.show??!0,this._minimumTerrainLevel=t.minimumTerrainLevel,this._maximumTerrainLevel=t.maximumTerrainLevel,this._rectangle=t.rectangle??ce.MAX_VALUE,this._maximumAnisotropy=t.maximumAnisotropy,this._imageryCache={},this._skeletonPlaceholder=new pD(mD.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.colorToAlpha
vec3 computeIBL(vec3 position, vec3 normal, vec3 lightDirection, vec3 lightColorHdr, czm_modelMaterial material){ #if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL) // Environment maps were provided, use them for IBL
vec3 viewDirection = -normalize(position); vec3 iblColor = textureIBL(viewDirection, normal, material); return iblColor; #endif return vec3(0.0);}#endif
#ifdef USE_CLEARCOATvec3 addClearcoatReflection(vec3 baseLayerColor, vec3 position, vec3 lightDirection, vec3 lightColorHdr, czm_modelMaterial material){ vec3 viewDirection = -normalize(position); vec3 halfwayDirection = normalize(viewDirection + lightDirection); vec3 normal = material.clearcoatNormal; float NdotL = clamp(dot(normal, lightDirection), 0.001, 1.0);
// clearcoatF0 = vec3(pow((ior - 1.0) / (ior + 1.0), 2.0)), but without KHR_materials_ior, ior is a constant 1.5.
vec3 f0 = vec3(0.04); vec3 f90 = vec3(1.0); // Note: clearcoat Fresnel computed with dot(n, v) instead of dot(v, h).
// This is to make it energy conserving with a simple layering function.
float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0); vec3 F = fresnelSchlick2(f0, f90, NdotV);
// compute specular reflection from direct lighting
float roughness = material.clearcoatRoughness; float alphaRoughness = roughness * roughness; float directStrength = computeDirectSpecularStrength(normal, lightDirection, viewDirection, halfwayDirection, alphaRoughness); vec3 directReflection = F * directStrength * NdotL; vec3 color = lightColorHdr * directReflection;
#ifdef SPECULAR_IBL // Find the direction in which to sample the environment map
vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflect(-viewDirection, normal)); vec3 iblColor = computeSpecularIBL(reflectMC, NdotV, f0, roughness); color += iblColor * material.occlusion; #endif
float clearcoatFactor = material.clearcoatFactor; vec3 clearcoatColor = color * clearcoatFactor;
// Dim base layer based on transmission loss through clearcoat
return baseLayerColor * (1.0 - clearcoatFactor * F) + clearcoatColor;}#endif
#if defined(LIGHTING_PBR) && defined(HAS_NORMALS)vec3 computePbrLighting(in czm_modelMaterial material, in vec3 position){ #ifdef USE_CUSTOM_LIGHT_COLOR vec3 lightColorHdr = model_lightColorHdr; #else vec3 lightColorHdr = czm_lightColorHdr; #endif
vec3 viewDirection = -normalize(position); vec3 normal = material.normalEC; vec3 lightDirection = normalize(czm_lightDirectionEC);
vec3 directLighting = czm_pbrLighting(viewDirection, normal, lightDirection, material); vec3 directColor = lightColorHdr * directLighting;
// Accumulate colors from base layer
vec3 color = directColor + material.emissive; #ifdef USE_IBL_LIGHTING color += computeIBL(position, normal, lightDirection, lightColorHdr, material); #endif
#ifdef USE_CLEARCOAT color = addClearcoatReflection(color, position, lightDirection, lightColorHdr, material); #endif
return color;}#endif
/** * Compute the material color under the current lighting conditions. * All other material properties are passed through so further stages * have access to them. * * @param {czm_modelMaterial} material The material properties from {@MaterialStageFS} * @param {ProcessedAttributes} attributes */void lightingStage(inout czm_modelMaterial material, ProcessedAttributes attributes){ #ifdef LIGHTING_PBR #ifdef HAS_NORMALS vec3 color = computePbrLighting(material, attributes.positionEC); #else vec3 color = material.diffuse * material.occlusion + material.emissive; #endif // 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_pbrNeutralTonemapping(color); #endif #else // unlit
vec3 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 eXe={UNLIT:0,PBR:1},RA=Object.freeze(eXe);var $fe={name:"LightingPipelineStage"};$fe.process=function(e,t){let{model:n,lightingOptions:i,shaderBuilder:o}=e;if(l(n.lightColor)){o.addDefine("USE_CUSTOM_LIGHT_COLOR",void 0,he.FRAGMENT),o.addUniform("vec3","model_lightColorHdr",he.FRAGMENT);let a=e.uniformMap;a.model_lightColorHdr=function(){return n.lightColor}}let{lightingModel:r}=i;r===RA.PBR?o.addDefine("LIGHTING_PBR",void 0,he.FRAGMENT):o.addDefine("LIGHTING_UNLIT",void 0,he.FRAGMENT),o.addFragmentLines(Ck)};var Ek=$fe;var Ik=`// 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;}
#ifdef HAS_NORMAL_TEXTUREvec2 getNormalTexCoords(){ vec2 texCoord = TEXCOORD_NORMAL; #ifdef HAS_NORMAL_TEXTURE_TRANSFORM texCoord = czm_computeTextureTransform(texCoord, u_normalTextureTransform); #endif return texCoord;}#endif
#if defined(HAS_NORMAL_TEXTURE) || defined(HAS_CLEARCOAT_NORMAL_TEXTURE)vec3 computeTangent(in vec3 position, in vec2 normalTexCoords){ vec2 tex_dx = dFdx(normalTexCoords); vec2 tex_dy = dFdy(normalTexCoords); float determinant = tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y; vec3 tangent = tex_dy.t * dFdx(position) - tex_dx.t * dFdy(position); return tangent / determinant;}#endif
#ifdef USE_ANISOTROPYstruct NormalInfo { vec3 tangent; vec3 bitangent; vec3 normal; vec3 geometryNormal;};
NormalInfo getNormalInfo(ProcessedAttributes attributes){ vec3 geometryNormal = attributes.normalEC; #ifdef HAS_NORMAL_TEXTURE vec2 normalTexCoords = getNormalTexCoords(); #endif
#ifdef HAS_BITANGENTS vec3 tangent = attributes.tangentEC; vec3 bitangent = attributes.bitangentEC; #else // Assume HAS_NORMAL_TEXTURE
vec3 tangent = computeTangent(attributes.positionEC, normalTexCoords); tangent = normalize(tangent - geometryNormal * dot(geometryNormal, tangent)); vec3 bitangent = normalize(cross(geometryNormal, tangent)); #endif
#ifdef HAS_NORMAL_TEXTURE mat3 tbn = mat3(tangent, bitangent, geometryNormal); vec3 normalSample; #if defined(HAS_NORMAL_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD) #ifdef HAS_NORMAL_TEXTURE_TRANSFORM normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams, u_normalTextureTransform).rgb; #else normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams).rgb; #endif #else normalSample = texture(u_normalTexture, normalTexCoords).rgb; #endif normalSample = 2.0 * normalSample - 1.0; #ifdef HAS_NORMAL_TEXTURE_SCALE normalSample.xy *= u_normalTextureScale; #endif vec3 normal = normalize(tbn * normalSample); #else vec3 normal = geometryNormal; #endif
#ifdef HAS_DOUBLE_SIDED_MATERIAL if (czm_backFacing()) { tangent *= -1.0; bitangent *= -1.0; normal *= -1.0; geometryNormal *= -1.0; } #endif
NormalInfo normalInfo; normalInfo.tangent = tangent; normalInfo.bitangent = bitangent; normalInfo.normal = normal; normalInfo.geometryNormal = geometryNormal;
return normalInfo;}#endif
#if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal){ vec2 normalTexCoords = getNormalTexCoords();
// If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
#ifdef HAS_BITANGENTS vec3 t = attributes.tangentEC; vec3 b = attributes.bitangentEC; #else vec3 t = computeTangent(attributes.positionEC, normalTexCoords); t = normalize(t - geometryNormal * dot(geometryNormal, t)); vec3 b = normalize(cross(geometryNormal, t)); #endif
mat3 tbn = mat3(t, b, geometryNormal); vec3 normalSample; #if defined(HAS_NORMAL_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD) #ifdef HAS_NORMAL_TEXTURE_TRANSFORM normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams, u_normalTextureTransform).rgb; #else normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams).rgb; #endif #else normalSample = texture(u_normalTexture, normalTexCoords).rgb; #endif normalSample = 2.0 * normalSample - 1.0; #ifdef HAS_NORMAL_TEXTURE_SCALE normalSample.xy *= u_normalTextureScale; #endif return normalize(tbn * normalSample);}#endif
#ifdef HAS_CLEARCOAT_NORMAL_TEXTUREvec3 getClearcoatNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal){ vec2 normalTexCoords = TEXCOORD_CLEARCOAT_NORMAL; #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_TRANSFORM normalTexCoords = vec2(u_clearcoatNormalTextureTransform * vec3(normalTexCoords, 1.0)); #endif
// If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
#ifdef HAS_BITANGENTS vec3 t = attributes.tangentEC; vec3 b = attributes.bitangentEC; #else vec3 t = computeTangent(attributes.positionEC, normalTexCoords); t = normalize(t - geometryNormal * dot(geometryNormal, t)); vec3 b = normalize(cross(geometryNormal, t)); #endif
mat3 tbn = mat3(t, b, geometryNormal); vec3 normalSample = texture(u_clearcoatNormalTexture, normalTexCoords).rgb; normalSample = 2.0 * normalSample - 1.0; #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_SCALE normalSample.xy *= u_clearcoatNormalTextureScale; #endif return normalize(tbn * normalSample);}#endif
#ifdef HAS_NORMALSvec3 computeNormal(ProcessedAttributes attributes){ // Geometry normal. This is already normalized
vec3 normal = attributes.normalEC;
#if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME) normal = getNormalFromTexture(attributes, normal); #endif
#ifdef HAS_DOUBLE_SIDED_MATERIAL if (czm_backFacing()) { normal = -normal; } #endif
return normal;}#endif
#ifdef HAS_BASE_COLOR_TEXTUREvec4 getBaseColorFromTexture(){ vec2 baseColorTexCoords = TEXCOORD_BASE_COLOR; #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM baseColorTexCoords = czm_computeTextureTransform(baseColorTexCoords, u_baseColorTextureTransform); #endif
vec4 baseColorWithAlpha; #if defined(HAS_BASE_COLOR_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD) #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM baseColorWithAlpha = czm_srgbToLinear(constantLodTextureLookup(u_baseColorTexture, u_baseColorTextureConstantLodParams, u_baseColorTextureTransform)); #else baseColorWithAlpha = czm_srgbToLinear(constantLodTextureLookup(u_baseColorTexture, u_baseColorTextureConstantLodParams)); #endif #else baseColorWithAlpha = czm_srgbToLinear(texture(u_baseColorTexture, baseColorTexCoords)); #endif
#ifdef HAS_BASE_COLOR_FACTOR baseColorWithAlpha *= u_baseColorFactor; #endif
return baseColorWithAlpha;}#endif
#ifdef HAS_EMISSIVE_TEXTUREvec3 getEmissiveFromTexture(){ vec2 emissiveTexCoords = TEXCOORD_EMISSIVE; #ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM emissiveTexCoords = czm_computeTextureTransform(emissiveTexCoords, u_emissiveTextureTransform); #endif
vec3 emissive = czm_srgbToLinear(texture(u_emissiveTexture, emissiveTexCoords).rgb); #ifdef HAS_EMISSIVE_FACTOR emissive *= u_emissiveFactor; #endif
return emissive;}#endif
#if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)void setSpecularGlossiness(inout czm_modelMaterial material){ #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE vec2 specularGlossinessTexCoords = TEXCOORD_SPECULAR_GLOSSINESS; #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE_TRANSFORM specularGlossinessTexCoords = czm_computeTextureTransform(specularGlossinessTexCoords, u_specularGlossinessTextureTransform); #endif
vec4 specularGlossiness = czm_srgbToLinear(texture(u_specularGlossinessTexture, specularGlossinessTexCoords)); vec3 specular = specularGlossiness.rgb; float glossiness = specularGlossiness.a; #ifdef HAS_LEGACY_SPECULAR_FACTOR specular *= u_legacySpecularFactor; #endif
#ifdef HAS_GLOSSINESS_FACTOR glossiness *= u_glossinessFactor; #endif #else #ifdef HAS_LEGACY_SPECULAR_FACTOR vec3 specular = clamp(u_legacySpecularFactor, 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 = czm_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
material.diffuse = diffuse.rgb * (1.0 - czm_maximumComponent(specular)); // the specular glossiness extension's alpha overrides anything set
// by the base material.
material.alpha = diffuse.a;
material.specular = specular;
// glossiness is the opposite of roughness, but easier for artists to use.
material.roughness = 1.0 - glossiness;}#elif defined(LIGHTING_PBR)float setMetallicRoughness(inout czm_modelMaterial material){ #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE vec2 metallicRoughnessTexCoords = TEXCOORD_METALLIC_ROUGHNESS; #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM metallicRoughnessTexCoords = czm_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.0, 1.0); #ifdef HAS_METALLIC_FACTOR metalness = clamp(metalness * u_metallicFactor, 0.0, 1.0); #endif
#ifdef HAS_ROUGHNESS_FACTOR roughness = clamp(roughness * u_roughnessFactor, 0.0, 1.0); #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.0, 1.0); #else float roughness = 1.0; #endif #endif
// dielectrics use f0 = 0.04, metals use albedo as f0
const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04); vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.baseColor.rgb, metalness);
material.specular = f0;
// diffuse only applies to dielectrics.
material.diffuse = mix(material.baseColor.rgb, vec3(0.0), metalness);
// This is perceptual roughness. The square of this value is used for direct lighting
material.roughness = roughness;
return metalness;}#ifdef USE_SPECULARvoid setSpecular(inout czm_modelMaterial material, in float metalness){ #ifdef HAS_SPECULAR_TEXTURE vec2 specularTexCoords = TEXCOORD_SPECULAR; #ifdef HAS_SPECULAR_TEXTURE_TRANSFORM specularTexCoords = czm_computeTextureTransform(specularTexCoords, u_specularTextureTransform); #endif float specularWeight = texture(u_specularTexture, specularTexCoords).a; #ifdef HAS_SPECULAR_FACTOR specularWeight *= u_specularFactor; #endif #else #ifdef HAS_SPECULAR_FACTOR float specularWeight = u_specularFactor; #else float specularWeight = 1.0; #endif #endif
#ifdef HAS_SPECULAR_COLOR_TEXTURE vec2 specularColorTexCoords = TEXCOORD_SPECULAR_COLOR; #ifdef HAS_SPECULAR_COLOR_TEXTURE_TRANSFORM specularColorTexCoords = czm_computeTextureTransform(specularColorTexCoords, u_specularColorTextureTransform); #endif vec3 specularColorSample = texture(u_specularColorTexture, specularColorTexCoords).rgb; vec3 specularColorFactor = czm_srgbToLinear(specularColorSample); #ifdef HAS_SPECULAR_COLOR_FACTOR specularColorFactor *= u_specularColorFactor; #endif #else #ifdef HAS_SPECULAR_COLOR_FACTOR vec3 specularColorFactor = u_specularColorFactor; #else vec3 specularColorFactor = vec3(1.0); #endif #endif material.specularWeight = specularWeight; vec3 f0 = material.specular; vec3 dielectricSpecularF0 = min(f0 * specularColorFactor, vec3(1.0)); material.specular = mix(dielectricSpecularF0, material.baseColor.rgb, metalness);}#endif#ifdef USE_ANISOTROPYvoid setAnisotropy(inout czm_modelMaterial material, in NormalInfo normalInfo){ mat2 rotation = mat2(u_anisotropy.xy, -u_anisotropy.y, u_anisotropy.x); float anisotropyStrength = u_anisotropy.z;
vec2 direction = vec2(1.0, 0.0); #ifdef HAS_ANISOTROPY_TEXTURE vec2 anisotropyTexCoords = TEXCOORD_ANISOTROPY; #ifdef HAS_ANISOTROPY_TEXTURE_TRANSFORM anisotropyTexCoords = czm_computeTextureTransform(anisotropyTexCoords, u_anisotropyTextureTransform); #endif vec3 anisotropySample = texture(u_anisotropyTexture, anisotropyTexCoords).rgb; direction = anisotropySample.rg * 2.0 - vec2(1.0); anisotropyStrength *= anisotropySample.b; #endif
direction = rotation * direction; mat3 tbn = mat3(normalInfo.tangent, normalInfo.bitangent, normalInfo.normal); vec3 anisotropicT = tbn * normalize(vec3(direction, 0.0)); vec3 anisotropicB = cross(normalInfo.geometryNormal, anisotropicT);
material.anisotropicT = anisotropicT; material.anisotropicB = anisotropicB; material.anisotropyStrength = anisotropyStrength;}#endif#ifdef USE_CLEARCOATvoid setClearcoat(inout czm_modelMaterial material, in ProcessedAttributes attributes){ #ifdef HAS_CLEARCOAT_TEXTURE vec2 clearcoatTexCoords = TEXCOORD_CLEARCOAT; #ifdef HAS_CLEARCOAT_TEXTURE_TRANSFORM clearcoatTexCoords = czm_computeTextureTransform(clearcoatTexCoords, u_clearcoatTextureTransform); #endif float clearcoatFactor = texture(u_clearcoatTexture, clearcoatTexCoords).r; #ifdef HAS_CLEARCOAT_FACTOR clearcoatFactor *= u_clearcoatFactor; #endif #else #ifdef HAS_CLEARCOAT_FACTOR float clearcoatFactor = u_clearcoatFactor; #else // PERFORMANCE_IDEA: this case should turn the whole extension off
float clearcoatFactor = 0.0; #endif #endif
#ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE vec2 clearcoatRoughnessTexCoords = TEXCOORD_CLEARCOAT_ROUGHNESS; #ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE_TRANSFORM clearcoatRoughnessTexCoords = czm_computeTextureTransform(clearcoatRoughnessTexCoords, u_clearcoatRoughnessTextureTransform); #endif float clearcoatRoughness = texture(u_clearcoatRoughnessTexture, clearcoatRoughnessTexCoords).g; #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR clearcoatRoughness *= u_clearcoatRoughnessFactor; #endif #else #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR float clearcoatRoughness = u_clearcoatRoughnessFactor; #else float clearcoatRoughness = 0.0; #endif #endif
material.clearcoatFactor = clearcoatFactor; // This is perceptual roughness. The square of this value is used for direct lighting
material.clearcoatRoughness = clearcoatRoughness; #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE material.clearcoatNormal = getClearcoatNormalFromTexture(attributes, attributes.normalEC); #else material.clearcoatNormal = attributes.normalEC; #endif}#endif#endif
void materialStage(inout czm_modelMaterial material, ProcessedAttributes attributes, SelectedFeature feature){ #ifdef USE_ANISOTROPY NormalInfo normalInfo = getNormalInfo(attributes); material.normalEC = normalInfo.normal; #elif defined(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 baseColorWithAlpha = getBaseColorFromTexture(); #elif defined(HAS_BASE_COLOR_FACTOR) baseColorWithAlpha = u_baseColorFactor; #endif
#ifdef HAS_IMAGERY baseColorWithAlpha = blendBaseColorWithImagery(baseColorWithAlpha); #endif // HAS_IMAGERY
#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
#ifdef USE_CPU_STYLING baseColorWithAlpha.rgb = blend(baseColorWithAlpha.rgb, feature.color.rgb, model_colorBlend); #endif material.baseColor = baseColorWithAlpha; material.diffuse = baseColorWithAlpha.rgb; material.alpha = baseColorWithAlpha.a;
#ifdef HAS_OCCLUSION_TEXTURE vec2 occlusionTexCoords = TEXCOORD_OCCLUSION; #ifdef HAS_OCCLUSION_TEXTURE_TRANSFORM occlusionTexCoords = czm_computeTextureTransform(occlusionTexCoords, u_occlusionTextureTransform); #endif material.occlusion = texture(u_occlusionTexture, occlusionTexCoords).r; #endif
#ifdef HAS_EMISSIVE_TEXTURE material.emissive = getEmissiveFromTexture(); #elif defined(HAS_EMISSIVE_FACTOR) material.emissive = u_emissiveFactor; #endif
#if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS) setSpecularGlossiness(material); #elif defined(LIGHTING_PBR) float metalness = setMetallicRoughness(material); #ifdef USE_SPECULAR setSpecular(material, metalness); #endif #ifdef USE_ANISOTROPY setAnisotropy(material, normalInfo); #endif #ifdef USE_CLEARCOAT setClearcoat(material, attributes); #endif #endif}`;var bk=`#ifdef HAS_CONSTANT_LOD// Extract model scale to compensate for minimumPixelSize scaling
float modelScaleX = length(czm_model[0].xyz);float modelScaleY = length(czm_model[1].xyz);float modelScaleZ = length(czm_model[2].xyz);float modelScale = (modelScaleX + modelScaleY + modelScaleZ) / 3.0;
// Transform model position through ENU but as direction only (w=0) to avoid position-dependent rotation
vec3 enuDir = (u_constantLodWorldToEnu * czm_model * vec4(v_positionMC, 0.0)).xyz;v_constantLodUvCustom.xy = (enuDir.yx + u_constantLodOffset) / modelScale;v_constantLodUvCustom.z = u_constantLodDistance / modelScale;#endif`;var xk=`#ifdef HAS_CONSTANT_LOD
vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams) { bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y; bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x; bool atClampBoundary = atMaxClamp || atMinClamp; float effectiveDistance = atMaxClamp ? constantLodParams.y : (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z); float logDepth = log2(effectiveDistance); logDepth = clamp(logDepth, -10.0, 20.0); float f = fract(logDepth); float p = floor(logDepth); if (atClampBoundary) { float clampedP = ceil(logDepth); vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z; return texture(textureSampler, tc); }
vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z; vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z; return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);}
vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams, mat3 textureTransform) { bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y; bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x; bool atClampBoundary = atMaxClamp || atMinClamp; float effectiveDistance = atMaxClamp ? constantLodParams.y : (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z); float logDepth = log2(effectiveDistance); logDepth = clamp(logDepth, -10.0, 20.0); float f = fract(logDepth); float p = floor(logDepth); if (atClampBoundary) { float clampedP = ceil(logDepth); vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z; // Apply texture transform to the final texture coordinates
tc = czm_computeTextureTransform(tc, textureTransform); return texture(textureSampler, tc); }
vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z; vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z; // Apply texture transform to both LOD texture coordinates before mixing
tc1 = czm_computeTextureTransform(tc1, textureTransform); tc2 = czm_computeTextureTransform(tc2, textureTransform); return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);}
#endif`;var{Material:tXe,MetallicRoughness:Wq,SpecularGlossiness:jq,Specular:ede,Clearcoat:tde}=bn,nde={name:"MaterialPipelineStage",_processTexture:hu,_processTextureTransform:ide};nde.process=function(e,t,n){let i=t.material,{model:o,uniformMap:r,shaderBuilder:a}=e;l(r.u_constantLodDistance)||(r.u_constantLodDistance=function(){let C=o.boundingSphere,E=n.camera;if(l(C)&&l(E)){let I=d.distance(E.positionWC,C.center);return Math.max(I,.1)}return 1});let s=l(o.classificationType),c=s,{defaultTexture:u,defaultNormalTexture:f,defaultEmissiveTexture:h}=n.context;rXe(i,r,a,u,f,h,c,e),l(i.specularGlossiness)?aXe(i.specularGlossiness,r,a,u,c,e):(l(i.specular)&&Tt.supportedExtensions.KHR_materials_specular&&sXe(i.specular,r,a,u,c),l(i.anisotropy)&&Tt.supportedExtensions.KHR_materials_anisotropy&&lXe(i.anisotropy,r,a,u,c),l(i.clearcoat)&&Tt.supportedExtensions.KHR_materials_clearcoat&&uXe(i.clearcoat,r,a,u,c),fXe(i.metallicRoughness,r,a,u,c,e));let p=Tt.getAttributeBySemantic(t,at.NORMAL),A=l(o.pointCloudShading)&&!o.pointCloudShading.normalShading,m=e.lightingOptions;i.unlit||!p||s||A?m.lightingModel=RA.UNLIT:m.lightingModel=RA.PBR;let _=o.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=_;let y=e.alphaOptions;i.alphaMode===bA.BLEND?y.pass=Be.TRANSLUCENT:i.alphaMode===bA.MASK&&(y.alphaCutoff=i.alphaCutoff),l(i.pointDiameter)&&(a.addDefine("HAS_POINT_DIAMETER",void 0,he.BOTH),a.addUniform("float","u_pointDiameter",he.VERTEX),r.u_pointDiameter=function(){return i.pointDiameter*n.pixelRatio}),l(i.lineStyle)&&iXe(i.lineStyle,t,n,r,a),a.addFragmentLines(Ik),i.doubleSided&&a.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,he.BOTH)};function nXe(e,t,n,i,o,r){let a=n.constantLod;if(!l(a)||!l(r))return;let s=`HAS_${o}_CONSTANT_LOD`;if(e.addDefine(s,void 0,he.BOTH),!l(t.u_constantLodOffset)){e.addDefine("HAS_CONSTANT_LOD",void 0,he.BOTH),e.addVarying("vec3","v_constantLodUvCustom"),e.addUniform("vec2","u_constantLodOffset",he.VERTEX),e.addUniform("float","u_constantLodDistance",he.VERTEX),e.addUniform("mat4","u_constantLodWorldToEnu",he.VERTEX),e.addFragmentLines(xk);let u=bk.split(``).filter(f=>!f.trim().startsWith("//")||f.includes("#"));e.addFunctionLines("setDynamicVaryingsVS",u)}let c=`${i}ConstantLodParams`;if(e.addUniform("vec3",c,he.FRAGMENT),t[c]=function(){return new d(a.minClampDistance,a.maxClampDistance,a.repetitions)},!l(t.u_constantLodOffset)){t.u_constantLodOffset=function(){return a.offset};let u=P.clone(P.IDENTITY),f=!1;t.u_constantLodWorldToEnu=function(){if(!f){let h=r.model.boundingSphere;if(l(h)){let p=h.center,A=At.eastNorthUpToFixedFrame(p);P.inverse(A,u),f=!0}}return f?u:P.IDENTITY}}}function iXe(e,t,n,i,o){let{width:r,pattern:a}=e;l(r)&&(o.addUniform("float","u_lineWidth",he.VERTEX),i.u_lineWidth=function(){return r*n.pixelRatio}),l(a)&&(o.addDefine("HAS_LINE_PATTERN",void 0,he.BOTH),o.addUniform("float","u_linePattern",he.FRAGMENT),o.addVarying("float","v_lineCoord"),i.u_linePattern=function(){return a});let s=Tt.getAttributeBySemantic(t,at.CUMULATIVE_DISTANCE);if(l(a)&&l(s)&&(t.primitiveType===Pe.LINES||t.primitiveType===Pe.TRIANGLE_STRIP)){o.addDefine("HAS_LINE_CUMULATIVE_DISTANCE",void 0,he.VERTEX),s.normalized&&o.addDefine("LINE_CUM_DIST_NORMALIZED",void 0,he.VERTEX),o.addUniform("float","u_cumulativeDistanceMax",he.VERTEX),o.addUniform("float","u_pixelsPerWorld",he.VERTEX);let c=l(s.max)?s.max:1;i.u_cumulativeDistanceMax=function(){return c},i.u_pixelsPerWorld=function(){let f=n.camera.frustum,h=1,p;return l(f.right)&&l(f.left)?p=f.right-f.left:l(f.width)&&(p=f.width),l(p)&&p>0&&(h=n.context.drawingBufferWidth/p),h};let u=Tt.getAttributeInfo(s).variableName;o.addVertexLines(`#ifdef HAS_LINE_CUMULATIVE_DISTANCEvoid lineStyleStageVS(in ProcessedAttributes attributes){ float cumDist = attributes.${u};#ifdef LINE_CUM_DIST_NORMALIZED cumDist *= u_cumulativeDistanceMax;#endif const float textureCoordinateBase = 8192.0; v_lineCoord = textureCoordinateBase + cumDist * u_pixelsPerWorld;}#endif`)}else l(a)&&o.addVertexLines(`#ifdef HAS_LINE_PATTERNvoid lineStyleStageVS(in ProcessedAttributes attributes){ vec4 posClip = gl_Position; vec2 screenPos = ((posClip.xy / posClip.w) * 0.5 + 0.5) * czm_viewport.zw;
const float textureCoordinateBase = 8192.0; if (czm_viewport.z > czm_viewport.w) { v_lineCoord = textureCoordinateBase + screenPos.x; } else { v_lineCoord = textureCoordinateBase + screenPos.y; }}#endif`)}function ide(e,t,n,i,o){let r=`HAS_${o}_TEXTURE_TRANSFORM`;e.addDefine(r,void 0,he.FRAGMENT);let a=`${i}Transform`;e.addUniform("mat3",a,he.FRAGMENT),t[a]=function(){return n.transform}}function oXe(e,t,n,i,o){let r=`HAS_${o}_TEXTURE_SCALE`;e.addDefine(r,void 0,he.FRAGMENT);let a=`${i}Scale`;e.addUniform("float",a,he.FRAGMENT),t[a]=function(){return n.scale}}function hu(e,t,n,i,o,r,a){e.addUniform("sampler2D",i,he.FRAGMENT),t[i]=function(){return n.texture??r};let s=`HAS_${o}_TEXTURE`;e.addDefine(s,void 0,he.FRAGMENT);let u=`v_texCoord_${n.texCoord}`,f=`TEXCOORD_${o}`;e.addDefine(f,u,he.FRAGMENT);let h=n.transform;l(h)&&!J.equals(h,J.IDENTITY)&&ide(e,t,n,i,o);let{scale:p}=n;l(p)&&p!==1&&oXe(e,t,n,i,o),nXe(e,t,n,i,o,a)}function rXe(e,t,n,i,o,r,a,s){let{emissiveFactor:c,emissiveTexture:u,normalTexture:f,occlusionTexture:h}=e;l(c)&&!d.equals(c,tXe.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",he.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,he.FRAGMENT),l(u)&&!a&&hu(n,t,u,"u_emissiveTexture","EMISSIVE",r));let p;if(l(e.metallicRoughness)&&l(e.metallicRoughness.baseColorTexture)&&l(e.metallicRoughness.baseColorTexture.constantLod)?p=e.metallicRoughness.baseColorTexture.constantLod:l(e.specularGlossiness)&&l(e.specularGlossiness.diffuseTexture)&&l(e.specularGlossiness.diffuseTexture.constantLod)&&(p=e.specularGlossiness.diffuseTexture.constantLod),l(f)&&!a){let A=f;l(f.constantLod)&&l(p)&&(A=Object.create(Object.getPrototypeOf(f)),Object.assign(A,f),A.constantLod=p),hu(n,t,A,"u_normalTexture","NORMAL",o,s)}l(h)&&!a&&hu(n,t,h,"u_occlusionTexture","OCCLUSION",i)}function aXe(e,t,n,i,o,r){let{diffuseTexture:a,diffuseFactor:s,specularGlossinessTexture:c,specularFactor:u,glossinessFactor:f}=e;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,he.FRAGMENT),l(a)&&!o&&hu(n,t,a,"u_diffuseTexture","DIFFUSE",i,r),l(s)&&!ie.equals(s,jq.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",he.FRAGMENT),t.u_diffuseFactor=function(){return e.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,he.FRAGMENT)),l(c)&&!o&&hu(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i),l(u)&&!d.equals(u,jq.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_legacySpecularFactor",he.FRAGMENT),t.u_legacySpecularFactor=function(){return e.specularFactor},n.addDefine("HAS_LEGACY_SPECULAR_FACTOR",void 0,he.FRAGMENT)),l(f)&&f!==jq.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",he.FRAGMENT),t.u_glossinessFactor=function(){return e.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,he.FRAGMENT))}function sXe(e,t,n,i,o){let{specularTexture:r,specularFactor:a,specularColorTexture:s,specularColorFactor:c}=e;n.addDefine("USE_SPECULAR",void 0,he.FRAGMENT),l(r)&&!o&&hu(n,t,r,"u_specularTexture","SPECULAR",i),l(a)&&a!==ede.DEFAULT_SPECULAR_FACTOR&&(n.addUniform("float","u_specularFactor",he.FRAGMENT),t.u_specularFactor=function(){return e.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,he.FRAGMENT)),l(s)&&!o&&hu(n,t,s,"u_specularColorTexture","SPECULAR_COLOR",i),l(c)&&!d.equals(c,ede.DEFAULT_SPECULAR_COLOR_FACTOR)&&(n.addUniform("vec3","u_specularColorFactor",he.FRAGMENT),t.u_specularColorFactor=function(){return e.specularColorFactor},n.addDefine("HAS_SPECULAR_COLOR_FACTOR",void 0,he.FRAGMENT))}var cXe=new d;function lXe(e,t,n,i,o){let{anisotropyStrength:r,anisotropyRotation:a,anisotropyTexture:s}=e;n.addDefine("USE_ANISOTROPY",void 0,he.FRAGMENT),l(s)&&!o&&hu(n,t,s,"u_anisotropyTexture","ANISOTROPY",i);let c=Math.cos(a),u=Math.sin(a);n.addUniform("vec3","u_anisotropy",he.FRAGMENT),t.u_anisotropy=function(){return d.fromElements(c,u,r,cXe)}}function uXe(e,t,n,i,o){let{clearcoatFactor:r,clearcoatTexture:a,clearcoatRoughnessFactor:s,clearcoatRoughnessTexture:c,clearcoatNormalTexture:u}=e;n.addDefine("USE_CLEARCOAT",void 0,he.FRAGMENT),l(r)&&r!==tde.DEFAULT_CLEARCOAT_FACTOR&&(n.addUniform("float","u_clearcoatFactor",he.FRAGMENT),t.u_clearcoatFactor=function(){return e.clearcoatFactor},n.addDefine("HAS_CLEARCOAT_FACTOR",void 0,he.FRAGME
{ 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 gc={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)"};gc.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,he.VERTEX),gXe(n);let i=t.morphTargets.length;for(let s=0;s<i;s++){let c=t.morphTargets[s].attributes,u=c.length;for(let f=0;f<u;f++){let h=c[f],p=h.semantic;p!==at.POSITION&&p!==at.NORMAL&&p!==at.TANGENT||(hXe(e,h,e.attributeIndex,s),e.attributeIndex++)}}_Xe(n);let r=e.runtimeNode.morphWeights.length;n.addUniform("float",`u_morphWeights[${r}]`,he.VERTEX),n.addVertexLines(Sk);let a={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=Pt(a,e.uniformMap)};var dXe={attributeString:void 0,functionId:void 0};function hXe(e,t,n,i){let o=e.shaderBuilder;mXe(e,t,n);let r=pXe(t,dXe);AXe(o,r,i)}function mXe(e,t,n){let i={index:n,value:l(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:zt.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function pXe(e,t){switch(e.semantic){case at.POSITION:t.attributeString="Position",t.functionId=gc.FUNCTION_ID_GET_MORPHED_POSITION;break;case at.NORMAL:t.attributeString="Normal",t.functionId=gc.FUNCTION_ID_GET_MORPHED_NORMAL;break;case at.TANGENT:t.attributeString="Tangent",t.functionId=gc.FUNCTION_ID_GET_MORPHED_TANGENT;break;default:break}return t}function AXe(e,t,n){let i=t.attributeString,o=`a_target${i}_${n}`,r=`morphed${i} += u_morphWeights[${n}] * a_target${i}_${n};`;e.addAttribute("vec3",o),e.addFunctionLines(t.functionId,[r])}function gXe(e){e.addFunction(gc.FUNCTION_ID_GET_MORPHED_POSITION,gc.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,he.VERTEX),e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_POSITION,["vec3 morphedPosition = position;"]),e.addFunction(gc.FUNCTION_ID_GET_MORPHED_NORMAL,gc.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,he.VERTEX),e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_NORMAL,["vec3 morphedNormal = normal;"]),e.addFunction(gc.FUNCTION_ID_GET_MORPHED_TANGENT,gc.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,he.VERTEX),e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_TANGENT,["vec3 morphedTangent = tangent;"])}function _Xe(e){e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_POSITION,["return morphedPosition;"]),e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_NORMAL,["return morphedNormal;"]),e.addFunctionLines(gc.FUNCTION_ID_GET_MORPHED_TANGENT,["return morphedTangent;"])}var wk=gc;var ode={name:"PickingPipelineStage"};ode.process=function(e,t,n){let i=n.context,o=e.runtimeNode,r=e.shaderBuilder,a=e.model,s=o.node.instances;if(e.hasPropertyTable)yXe(e,t,s,i);else if(l(s))CXe(e,i);else{let c=rde(e),u=i.createPickId(c);a._pipelineResources.push(u),a._pickIds.push(u),r.addUniform("vec4","czm_pickColor",he.FRAGMENT);let f=e.uniformMap;f.czm_pickColor=function(){return u.color},e.pickId="czm_pickColor"}};function rde(e,t){let n=e.model;if(l(n.pickObject))return n.pickObject;let i={model:n,node:e.runtimeNode,primitive:e.runtimePrimitive},o;if(Vr.is3DTiles(n.type)){let r=n.content;o={content:r,primitive:r.tileset,detail:i}}else o={primitive:n,detail:i};return o.id=n.id,l(t)&&(o.instanceId=t),o}function yXe(e,t,n){let i=e.model,o,r,a=i.featureIdLabel,s=i.instanceFeatureIdLabel;l(i.featureTableId)?o=i.featureTableId:l(n)?(r=Tt.getFeatureIdsByLabel(n.featureIds,s),o=r.propertyTableId):(r=Tt.getFeatureIdsByLabel(t.featureIds,a),o=r.propertyTableId);let c=i.featureTables[o];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",he.FRAGMENT);let f=c.batchTexture;e.uniformMap.model_pickTexture=function(){return f.pickTexture??f.defaultTexture},e.pickId="((selectedFeature.id < int(model_featuresLength)) ? texture(model_pickTe
// 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_STYLEfloat 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_STYLEvec4 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_STYLEfloat 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_CULLINGfloat 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 IXe=new ie,sde={name:"PointCloudStylingPipelineStage"};sde.process=function(e,t,n){let i=e.shaderBuilder,o=e.model,r=o.style,a=o.structuralMetadata,s=l(a)?a.propertyAttributes:void 0,c=l(o.featureTableId)&&o.featureTables[o.featureTableId].featuresLength>0,u=!l(s)&&c;if(l(r)&&!u){let _=SXe(s),y=wXe(r,_);BXe(i,y);let E=DXe(y).indexOf("normalMC")>=0,I=Tt.getAttributeBySemantic(t,at.NORMAL);if(E&&!I)throw new ue("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,he.VERTEX),y.styleTranslucent&&(e.alphaOptions.pass=Be.TRANSLUCENT)}let f=o.pointCloudShading;f.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,he.VERTEX),f.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,he.VERTEX);let h,p,A;Vr.is3DTiles(o.type)&&(p=!0,h=o.content,A=h.tile.refine===Cr.ADD),i.addUniform("vec4","model_pointCloudParameters",he.VERTEX),i.addVertexLines(Dk);let m=e.uniformMap;m.model_pointCloudParameters=function(){let _=IXe,y=1;p&&(y=A?5:h.tileset.memoryAdjustedScreenSpaceError),_.x=f.maximumAttenuation??y,_.x*=n.pixelRatio;let C=bXe(e,t,f,h);_.y=C*f.geometricErrorScale;let E=n.context,I=n.camera.frustum,x;return n.mode===oe.SCENE2D||I instanceof An?x=Number.POSITIVE_INFINITY:x=E.drawingBufferHeight/n.camera.frustum.sseDenominator,_.z=x,p&&(_.w=h.tileset.timeSinceLoad),_}};var ade=new d;function bXe(e,t,n,i){if(l(i)){let f=i.tile.geometricError;if(f>0)return f}if(l(n.baseResolution))return n.baseResolution;let o=Tt.getAttributeBySemantic(t,at.POSITION),r=o.count,a=e.runtimeNode.transform,s=d.subtract(o.max,o.min,ade);s=P.multiplyByPointAsVector(a,s,ade);let c=s.x*s.y*s.z;return D.cbrt(c/r)}var xXe={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},TXe={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function SXe(e){let t=Ye(TXe);if(!l(e))return t;for(let n=0;n<e.length;n++){let o=e[n].properties;for(let r in o)o.hasOwnProperty(r)&&(t[r]=`metadata.${r}`)}return t}var Yq="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function wXe(e,t){let n=xXe,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction(`getColorFromStyle(${Yq})`,t,i),n.showStyleFunction=e.getShowShaderFunction(`getShowFromStyle(${Yq})`,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction(`getPointSizeFromStyle(${Yq})`,t,i),n.styleTranslucent=l(n.colorStyleFunction)&&i.translucent,n}function BXe(e,t){let n=t.colorStyleFunction;l(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,he.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));let i=t.showStyleFunction;l(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,he.BOTH),e.addVertexLines(i),e.addVarying("float","v_pointCloudShow"));let o=t.pointSizeStyleFunction;l(o)&&(e.addDefine("HAS_POINT_CLOUD_POINT_SIZE_STYLE",void 0,he.VERTEX),e.addVertexLines(o))}function qq(e,t){let n=/attributes\.(\w+)/g,i=n.exec(e);for(;i!==null;){let o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function DXe(e){let t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,o=[];return l(t)&&qq(t,o),l(n)&&qq(n,o),l(i)&&qq(i,o),o}var vk=sde;var Pk=`void primitiveOutlineStage() { v_outlineCoordinates = a_outlineCoordinates;}`;var Rk=`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 cde={name:"PrimitiveOutlinePipelineStage"};cde.process=function(e,t,n){let i=e.shaderBuilder,o=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,he.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");let r=t.outlineCoordinates,a={index:e.attributeIndex++,vertexBuffer:r.buffer,componentsPerAttribute:zt.getNumberOfComponents(r.type),componentDatatype:r.componentDatatype,offsetInBytes:r.byteOffset,strideInBytes:r.byteStride,normalize:r.normalized};e.attributes.push(a),i.addUniform("sampler2D","model_outlineTexture",he.FRAGMENT);let s=Kb.createTexture(n.context);o.model_outlineTexture=function(){return s};let c=e.model;i.addUniform("vec4","model_outlineColor",he.FRAGMENT),o.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",he.FRAGMENT),o.model_showOutline=function(){return c.showOutline},i.addVertexLines(Pk),i.addFragmentLines(Rk)};var Mk=cde;var lde={name:"PrimitiveStatisticsPipelineStage",_countGeometry:ude,_count2DPositions:fde,_countMorphTargetAttributes:dde,_countMaterialTextures:hde,_countFeatureIdTextures:mde,_countBinaryMetadata:pde};lde.process=function(e,t,n){let i=e.model,o=i.statistics;ude(o,t),fde(o,e.runtimePrimitive),dde(o,t),hde(o,t.material),mde(o,t.featureIds),pde(o,i)};function ude(e,t){let n=l(t.indices)?t.indices.count:Tt.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===Pe.POINTS?e.pointsLength+=n:Pe.isTriangles(i)&&(e.trianglesLength+=vXe(i,n));let o=t.attributes,r=o.length;for(let c=0;c<r;c++){let u=o[c];if(l(u.buffer)){let f=l(u.typedArray);e.addBuffer(u.buffer,f)}}let a=t.outlineCoordinates;l(a)&&l(a.buffer)&&e.addBuffer(a.buffer,!1);let s=t.indices;if(l(s)&&l(s.buffer)){let c=l(s.typedArray);e.addBuffer(s.buffer,c)}}function vXe(e,t){switch(e){case Pe.TRIANGLES:return t/3;case Pe.TRIANGLE_STRIP:case Pe.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function fde(e,t){let n=t.positionBuffer2D;l(n)&&e.addBuffer(n,!0)}function dde(e,t){let n=t.morphTargets;if(!l(n))return;let i=!1,o=n.length;for(let r=0;r<o;r++){let a=n[r].attributes,s=a.length;for(let c=0;c<s;c++){let u=a[c];l(u.buffer)&&e.addBuffer(u.buffer,i)}}}function hde(e,t){let n=PXe(t),i=n.length;for(let o=0;o<i;o++){let r=n[o];l(r)&&l(r.texture)&&e.addTexture(r.texture)}}function PXe(e){let t=e.metallicRoughness,n=[e.emissiveTexture,e.normalTexture,e.occlusionTexture,t.baseColorTexture,t.metallicRoughnessTexture],i=e.specularGlossiness;return l(i)&&(n.push(i.diffuseTexture),n.push(i.specularGlossinessTexture)),n}function mde(e,t){let n=t.length;for(let i=0;i<n;i++){let o=t[i];if(o instanceof bn.FeatureIdTexture){let r=o.textureReader;l(r.texture)&&e.addTexture(r.texture)}}}function pde(e,t){let n=t.structuralMetadata;l(n)&&(RXe(e,n),e.propertyTablesByteLength+=n.propertyTablesByteLength);let i=t.featureTables;if(!l(i))return;let o=i.length;for(let r=0;r<o;r++){let a=i[r];e.addBatchTexture(a.batchTexture)}}function RXe(e,t){let n=t.propertyTextures;if(!l(n))return;let i=n.length;for(let o=0;o<i;o++){let a=n[o].properties;for(let s in a)if(a.hasOwnProperty(s)){let u=a[s].textureReader;l(u.texture)&&e.addTexture(u.texture)}}}var Nk=lde;var MXe=new P,NXe=new P,Ade={name:"SceneMode2DPipelineStage"};Ade.process=function(e,t,n){let i=Tt.getAttributeBySemantic(t,at.POSITION),o=e.shaderBuilder,r=e.model,a=r.sceneGraph.computedModelMatrix,s=e.runtimeNode.computedTransform,c=P.multiplyTransformation(a,s,MXe),u=FXe(e,c,n),f=e.runtimePrimitive;f.boundingSphere2D=u;let h=e.runtimeNode.node.instances;if(l(h))return;if(l(i.typedArray)){let _=UXe(i,c,u,n);f.positionBuffer2D=_,r._modelResources.push(_),i.typedArray=void 0}o.addDefine("USE_2D_POSITIONS",void 0,he.VERTEX),o.addUniform("mat4","u_modelView2D",he.VERTEX);let p=P.fromTranslation(u.center,new P),A=n.context,m={u_modelView2D:function(){return P.multiplyTransformation(A.uniformState.view,p,NXe)}};e.uniformMap=Pt(m,e.uniformMap)};var LXe=new d,OXe=new d;function FXe(e,t,n){let i=P.multiplyByPoint(t,e.positionMin,LXe),o=co.computeActualEllipsoidPosition(n,i,i),r=P.multiplyByPoint(t,e.
{ 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 vE={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};vE.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,he.VERTEX),GXe(n,t);let i=e.runtimeNode,o=i.computedJointMatrices;n.addUniform("mat4",`u_jointMatrices[${o.length}]`,he.VERTEX),n.addVertexLines(Ok);let r={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=Pt(r,e.uniformMap)};function zXe(e){let t=-1,n=e.attributes,i=n.length;for(let o=0;o<i;o++){let r=n[o];(r.semantic===at.JOINTS||r.semantic===at.WEIGHTS)&&(t=Math.max(t,r.setIndex))}return t}function GXe(e,t){e.addFunction(vE.FUNCTION_ID_GET_SKINNING_MATRIX,vE.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,he.VERTEX),e.addFunctionLines(vE.FUNCTION_ID_GET_SKINNING_MATRIX,["mat4 skinnedMatrix = mat4(0);"]);let i,o,r=["x","y","z","w"],a=zXe(t);for(i=0;i<=a;i++)for(o=0;o<=3;o++){let c=r[o],u=`skinnedMatrix += a_weights_${i}.${c} * u_jointMatrices[int(a_joints_${i}.${c})];`;e.addFunctionLines(vE.FUNCTION_ID_GET_SKINNING_MATRIX,[u])}e.addFunctionLines(vE.FUNCTION_ID_GET_SKINNING_MATRIX,["return skinnedMatrix;"])}var Fk=vE;var Qk=`void verticalExaggerationStage( inout ProcessedAttributes attributes) { // Compute the distance from the camera to the local center of curvature.
vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0); vec2 vertexAzimuth = normalize(vertexPositionENU.xy); // Curvature = 1 / radius of curvature.
float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature); float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;
// Compute the approximate ellipsoid normal at the vertex position.
// Uses a circular approximation for the Earth curvature along the geodesic.
vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz; vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC; vec3 vertexNormal = normalize(centerToVertex);
// Estimate the (sine of the) angle between the camera direction and the vertex normal
float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC); float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC); float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance); bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;
// Approximate the change in height above the ellipsoid, from camera to vertex position.
float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal); float smallAngleVersine = 0.5 * sinTheta * sinTheta; float versine = isSmallAngle ? smallAngleVersine : exactVersine; float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine; float vertexHeight = czm_eyeHeight + dHeight;
// Transform the approximate vertex normal to model coordinates.
vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz; vertexNormalMC = normalize(vertexNormalMC);
// Compute the exaggeration and apply it along the approximate vertex normal.
float stretch = u_verticalExaggerationAndRelativeHeight.x; float shift = u_verticalExaggerationAndRelativeHeight.y; float exaggeration = (vertexHeight - shift) * (stretch - 1.0); attributes.positionMC += exaggeration * vertexNormalMC;}`;var _de={name:"VerticalExaggerationPipelineStage"},VXe=new Q;_de.process=function(e,t,n){let{shaderBuilder:i,uniformMap:o}=e;i.addVertexLines(Qk),i.addDefine("HAS_VERTICAL_EXAGGERATION",void 0,he.VERTEX),i.addUniform("vec2","u_verticalExaggerationAndRelativeHeight",he.VERTEX),o.u_verticalExaggerationAndRelativeHeight=function(){return Q.fromElements(n.verticalExaggeration,n.verticalExaggerationRelativeHeight,VXe)}};var kk=_de;var Kq={};function HXe(e){let t=Ue.createTypedArray(e,e*2),n=e,i=0;for(let o=0;o<n;o+=3)t[i++]=o,t[i++]=o+1,t[i++]=o+1,t[i++]=o+2,t[i++]=o+2,t[i++]=o;return t}function WXe(e,t){let n=t.length,i=Ue.createTypedArray(e,n*2),o=0;for(let r=0;r<n;r+=3){let a=t[r],s=t[r+1],c=t[r+2];i[o++]=a,i[o++]=s,i[o++]=s,i[o++]=c,i[o++]=c,i[o++]=a}return i}function jXe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),o=0;i[o++]=0,i[o++]=1;for(let r=0;r<t;r++)i[o++]=r+1,i[o++]=r+2,i[o++]=r+2,i[o++]=r;return i}function YXe(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),a=0;r[a++]=t[0],r[a++]=t[1];for(let s=0;s<i;s++){let c=t[s],u=t[s+1],f=t[s+2];r[a++]=u,r[a++]=f,r[a++]=f,r[a++]=c}return r}function qXe(e){let t=e-2,n=2+t*4,i=Ue.createTypedArray(e,n),o=0;i[o++]=0,i[o++]=1;for(let r=0;r<t;r++)i[o++]=r+1,i[o++]=r+2,i[o++]=r+2,i[o++]=0;return i}function KXe(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),a=0,s=t[0];r[a++]=s,r[a++]=t[1];for(let c=0;c<i;c++){let u=t[c+1],f=t[c+2];r[a++]=u,r[a++]=f,r[a++]=f,r[a++]=s}return r}Kq.createWireframeIndices=function(e,t,n){let i=l(n);if(e===Pe.TRIANGLES)return i?WXe(t,n):HXe(t);if(e===Pe.TRIANGLE_STRIP)return i?YXe(t,n):jXe(t);if(e===Pe.TRIANGLE_FAN)return i?KXe(t,n):qXe(t)};Kq.getWireframeIndicesCount=function(e,t){return e===Pe.TRIANGLES?t*2:e===Pe.TRIANGLE_STRIP||e===Pe.TRIANGLE_FAN?2+(t-2)*4:t};var _D=Kq;var yde={name:"WireframePipelineStage"};yde.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,he.FRAGMENT);let o=e.model,r=XXe(t,e.indices,n);o._pipelineResources.push(r),e.wireframeIndexBuffer=r,o.statistics.addBuffer(r,!1);let s=e.primitiveType,c=e.count;e.primitiveType=Pe.LINES,e.count=_D.getWireframeIndicesCount(s,c)};function XXe(e,t,n){let o=Tt.getAttributeBySemantic(e,at.POSITION).count,r=n.context.webgl2,a;if(l(t)){let f=t.buffer,h=t.count;l(f)&&r?(a=f.sizeInBytes===h?new Uint8Array(h):Ue.createTypedArray(o,h),f.getBufferData(a)):a=t.typedArray}let s=e.primitiveType,c=_D.createWireframeIndices(s,o,a),u=Ue.fromSizeInBytes(c.BYTES_PER_ELEMENT);return tt.createIndexBuffer({context:n.context,typedArray:c,usage:Re.STATIC_DRAW,indexDatatype:u})}var Uk=yde;function Cde(e){e=e??V.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=[]}Cde.prototype.configurePipeline=function(e){let t=this.pipelineStages;t.length=0;let n=this.primitive,i=this.node,o=this.model,r=o.customShader;if(l(o._marsOptions)&&l(o._marsOptions.customShaders)){let g=Lg.getCache(o._marsOptions.customShaders);for(let b in g)if(Object.prototype.hasOwnProperty.call(g,b)){r=g[b];break}}let a=o.style,s=e.context.webgl2,u=e.mode!==oe.SCENE3D&&!e.scene3DOnly&&o._projectTo2D,f=e.verticalExaggeration!==1&&o.hasVerticalExaggeration,h=l(n.morphTargets)&&n.morphTargets.length>0,p=l(i.skin),A=l(o.imageryLayers),m=l(r),y=!(m&&l(r.fragmentShaderText))||r.mode!==U_.REPLACE_MATERIAL,C=Tt.hasQuantizedAttributes(n.attributes),E=o.debugWireframe&&Pe.isTriangles(n.primitiveType)&&(o._enableDebugWireframe||s),I=o.pointCloudShading,x=l(I)&&I.attenuation,S=l(I)&&I.backFaceCulling,w=n.primitiveType===Pe.POINTS&&(l(a)||x||S),v=o._enableShowOutline&&l(n.outlineCoordinates),R=l(n.edgeVisibility),N=JXe(o,i,n),L=l(o.classificationType);u&&t.push(Lk),t.push(q2),E&&t.push(Uk),L&&t.push(D2),h&&t.push(wk),p&&t.push(Fk),w&&t.push(vk),C&&t.push(U2),A&&(v?bt("outlines-and-draping","Primitive outlines disable imagery draping"):t.push(yk)),y&&t.push(Tk),t.push(TE),t.push(p
if(model_silhouettePass) { color = czm_gammaCorrect(model_silhouetteColor); }}`;var Wk=`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 jk={name:"ModelSilhouettePipelineStage"};jk.silhouettesLength=0;jk.process=function(e,t,n){l(t._silhouetteId)||(t._silhouetteId=++jk.silhouettesLength);let i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,he.BOTH),i.addVertexLines(Wk),i.addFragmentLines(Hk),i.addUniform("vec4","model_silhouetteColor",he.FRAGMENT),i.addUniform("float","model_silhouetteSize",he.VERTEX),i.addUniform("bool","model_silhouettePass",he.BOTH);let o={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=Pt(o,e.uniformMap),e.hasSilhouette=!0};var Yk=jk;var qk=`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 Kk={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};Kk.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,he.FRAGMENT),i.addFragmentLines(qk);let o={};i.addUniform("float",Kk.SPLIT_DIRECTION_UNIFORM_NAME,he.FRAGMENT),o[Kk.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=Pt(o,e.uniformMap)};var Xk=Kk;function tJe(e,t){this.model=e.model,this.shaderBuilder=e.shaderBuilder.clone(),this.uniformMap=Ye(e.uniformMap),this.alphaOptions=Ye(e.alphaOptions),this.renderStateOptions=Ye(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,this.primitiveRenderResources=[]}var Jk=tJe;function nJe(e){e=e??V.EMPTY_OBJECT,this.lightingModel=e.lightingModel??RA.UNLIT}var Zk=nJe;function iJe(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=Ye(e.uniformMap),this.alphaOptions=Ye(e.alphaOptions),this.renderStateOptions=Ye(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=l(n.indices)?n.indices.count:Tt.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;let i=Tt.getPositionMinMax(n,this.runtimeNode.instancingTranslationMin,this.runtimeNode.instancingTranslationMax);this.positionMin=d.clone(i.min,new d),this.positionMax=d.clone(i.max,new d),this.boundingSphere=le.fromCornerPoints(this.positionMin,this.positionMax,new le),this.lightingOptions=new Zk,this.pickId=void 0}var $k=iJe;function Zq(e){e=e??V.EMPTY_OBJECT;let t=e.command,n=e.primitiveRenderResources,i=n.model;this._command=t,this._model=i,this._runtimePrimitive=n.runtimePrimitive,this._modelMatrix=t.modelMatrix,this._boundingVolume=t.boundingVolume,this._cullFace=t.renderState.cull.face;let o=i.classificationType;this._classificationType=o,this._classifiesTerrain=o!==ei.CESIUM_3D_TILE,this._classifies3DTiles=o!==ei.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[],sJe(this)}function oJe(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:wt.KEEP,zFail:wt.DECREMENT_WRAP,zPass:wt.KEEP},backFunction:e,backOperation:{fail:wt.KEEP,zFail:wt.INCREMENT_WRAP,zPass:wt.KEEP},reference:Yt.CESIUM_3D_TILE_MASK,mask:Yt.CESIUM_3D_TILE_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:hc.LESS_OR_EQUAL},depthMask:!1}}var rJe={stencilTest:{enabled:!0,frontFunction:ti.NOT_EQUAL,frontOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},backFunction:ti.NOT_EQUAL,backOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},reference:0,mask:Yt.CLASSIFICATION_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:sn.PRE_MULTIPLIED_ALPHA_BLEND},aJe={stencilTest:{enabled:!0,frontFunction:ti.NOT_EQUAL,frontOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},backFunction:ti.NOT_EQUAL,backOperation:{fail:wt.ZERO,zFail:wt.ZERO,zPass:wt.ZERO},reference:0,mask:Yt.CLASSIFICATION_MASK},stencilMask:Yt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},xde=[];function sJe(e){let t=e._command,n=xde;if(e._useDebugWireframe){t.pass=Be.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=yD(e,n,e._commandListDebugWireframe);let r=e._commandListDebugWireframe,a=r.length;for(let s=0;s<a;s++){let c=r[s];c.count*=2,c.offset*=2}return}let o=e.
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);
#ifdef HAS_IMAGERY initializeImageryAttributes(); #endif
// 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(featureIds, metadata, metadataClass, metadataStatistics, attributes);
#ifdef HAS_VERTICAL_EXAGGERATION verticalExaggerationStage(attributes); #endif
#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);
#if defined(HAS_LINE_CUMULATIVE_DISTANCE) || defined(HAS_LINE_PATTERN) lineStyleStageVS(attributes); #endif
// This must go after the geometry stage as it needs v_positionWC
#ifdef HAS_ATMOSPHERE atmosphereStage(attributes); #endif
#ifdef ENABLE_CLIPPING_POLYGONS modelClippingPolygonsStage(attributes); #endif
#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); #elif defined(HAS_POINT_DIAMETER) gl_PointSize = u_pointDiameter; #else gl_PointSize = 1.0; #endif
gl_PointSize *= show; #endif
// Important NOT to compute gl_Position = show * positionClip or we hit:
// https://github.com/CesiumGS/cesium/issues/11270
//
// We will discard points with v_pointCloudShow == 0 in the fragment shader.
gl_Position = positionClip;
#ifdef HAS_EDGE_VISIBILITY edgeVisibilityStageVS(); #endif
#ifdef HAS_POINT_CLOUD_SHOW_STYLE v_pointCloudShow = show; #endif}`;var i3=`precision highp float;
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);}
void lineStyleStage(){ #if defined(HAS_LINE_PATTERN) && !defined(HAS_EDGE_VISIBILITY) const float maskLength = 16.0; float dashPosition = fract(v_lineCoord / maskLength); float maskIndex = floor(dashPosition * maskLength); float maskTest = floor(u_linePattern / pow(2.0, maskIndex)); if (mod(maskTest, 2.0) < 1.0) { discard; } #endif}
SelectedFeature selectedFeature;
void main(){ #if defined(PRIMITIVE_TYPE_POINTS) && defined(HAS_POINT_DIAMETER) // Render points as circles
float distanceToCenter = length(gl_PointCoord - vec2(0.5)); if (distanceToCenter > 0.5) { discard; } #endif
#ifdef HAS_POINT_CLOUD_SHOW_STYLE if (v_pointCloudShow == 0.0) { discard; } #endif
#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(featureIds, metadata, metadataClass, metadataStatistics, attributes);
//========================================================================
// When not picking metadata START
#ifndef METADATA_PICKING_ENABLED
#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);
// When not picking metadata END
//========================================================================
#else //========================================================================
// When picking metadata START
vec4 metadataValues = vec4(0.0, 0.0, 0.0, 0.0); metadataPickingStage(metadata, metadataClass, metadataValues); vec4 color = metadataValues;
#endif // When picking metadata END
//========================================================================
lineStyleStage();
#ifdef HAS_CLIPPING_PLANES modelClippingPlanesStage(color); #endif
#ifdef ENABLE_CLIPPING_POLYGONS modelClippingPolygonsStage(); #endif
//========================================================================
// When not picking metadata START
#ifndef METADATA_PICKING_ENABLED
#if defined(HAS_SILHOUETTE) && defined(HAS_NORMALS) silhouetteStage(color); #endif
#ifdef HAS_ATMOSPHERE atmosphereStage(color, attributes); #endif
#ifdef HAS_EDGE_VISIBILITY edgeVisibilityStage(color, featureIds); edgeDetectionStage(color, featureIds); #endif
#endif // When not picking metadata END
//========================================================================
out_FragColor = color;}
`;function Tde(){}Tde.buildModelDrawCommand=function(e,t){let n=e.shaderBuilder,i=TJe(e,n,t),o=SJe(e,i,t),r=e.model;return l(r.classificationType)?new e3({primitiveRenderResources:e,command:o}):new t3({primitiveRenderResources:e,command:o})};function TJe(e,t,n){t.addVertexLines(n3),t.addFragmentLines(i3);let i=e.model,o=t.buildShaderProgram(n.context);return i._pipelineResources.push(o),o}function SJe(e,t,n){let i=wJe(e),o=new Vn({context:n.context,indexBuffer:i,attributes:e.attributes}),r=e.model;r._pipelineResources.push(o);let a=e.alphaOptions.pass,s=r.sceneGraph,c=n.mode===oe.SCENE3D,u,f;if(!c&&!n.scene3DOnly&&r._projectTo2D)u=P.multiplyTransformation(s._computedModelMatrix,e.runtimeNode.computedTransform,new P),f=e.runtimePrimitive.boundingSphere2D;else{let C=c?s._computedModelMatrix:s._computedModelMatrix2D;u=P.multiplyTransformation(C,e.runtimeNode.computedTransform,new P),f=le.transform(e.boundingSphere,u)}let h=Ye(Ve.fromCache(e.renderStateOptions),!0);h.cull.face=Tt.getCullFace(u,e.primitiveType),h=Ve.fromCache(h);let p=l(r.classificationType),A=p?!1:Bn.castShadows(r.shadows),m=p?!1:Bn.receiveShadows(r.shadows),_=p?void 0:e.pickId,y=new it({boundingVolume:f,modelMatrix:u,uniformMap:e.uniformMap,renderState:h,vertexArray:o,shaderProgram:t,cull:r.cull,pass:a,count:e.count,owner:r,pickId:_,pickMetadataAllowed:!0,instanceCount:e.instanceCount,primitiveType:e.primitiveType,debugShowBoundingVolume:r.debugShowBoundingVolume,castShadows:A,receiveShadows:m});return r._marsOptions?.updateDrawCommand&&r._marsOptions.updateDrawCommand(y),y}function wJe(e){let t=e.wireframeIndexBuffer;if(l(t))return t;let n=e.indices;if(l(n))return n.buffer}var o3=Tde;function Hc(e){e=e??V.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=P.clone(P.IDENTITY),this._computedModelMatrix2D=P.clone(P.IDENTITY),this._axisCorrectionMatrix=Tt.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new P),this._runtimeArticulations={},BJe(this)}Object.defineProperties(Hc.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 BJe(e){let t=e._components,n=t.scene,o=e._model.modelMatrix;Sde(e,o);let r=t.articulations,a=r.length,s=e._runtimeArticulations;for(let E=0;E<a;E++){let I=r[E],x=new f2({articulation:I,sceneGraph:e}),S=x.name;s[S]=x}let c=t.nodes,u=c.length;e._runtimeNodes=new Array(u);let h=n.nodes.length,p=P.IDENTITY;for(let E=0;E<h;E++){let I=n.nodes[E],x=wde(e,I,p);e._rootNodes.push(x)}let A=t.skins,m=e._runtimeSkins,_=A.length;for(let E=0;E<_;E++){let I=A[E];m.push(new Gk({skin:I,sceneGraph:e}))}let y=e._skinnedNodes,C=y.length;for(let E=0;E<C;E++){let I=y[E],x=e._runtimeNodes[I],w=c[I].skin.index;x._runtimeSkin=m[w],x.updateJointMatrices()}e.applyArticulations()}function Sde(e,t){let n=e._components,i=e._model;e._computedModelMatrix=P.multiplyTransformation(t,n.transform,e._computedModelMatrix),e._computedModelMatrix=P.multiplyTransformation(e._computedModelMatrix,e._axisCorrectionMatrix,e._computedModelMatrix),e._computedModelMatrix=P.multiplyByUniformScale(e._computedModelMatrix,i.computedScale,e._computedModelMatrix)}var DJe=new d;function vJe(e,t){let n=e._computedModelMatrix,i=P.getTranslation(n,DJe);if(!d.equals(i,d.ZERO))e._computedModelMatrix2D=At.basisTo2D(t.mapProjection,n,e._computedModelMatrix2D);else{let o=e.boundingSphere.center,r=At.ellipsoidTo2DModelMatrix(t.mapProjection,o,e._computedModelMatrix2D);e._computedModelMatrix2D=P.multiply(r,n,e._computedModelMatrix2D)}e._boundingSphere2D=le.transform(e._boundingSphere,e._computedModelMatrix2D,e._boundingSphere2D)}function wde(e,t,n){let i=[],o=Tt.getNodeTransform(t),r=t.children.length;for(let f=0;f<r
uniform float u_coarseDepthTestDistance;uniform float u_threePointDepthTestDistance;
#ifdef VECTOR_TILEuniform vec4 u_highlightColor;#endif
in vec2 v_textureCoordinates;in vec4 v_pickColor;in vec4 v_color;flat in vec2 v_splitDirectionAndEllipsoidDepthEC;
#ifdef SDFin vec4 v_outlineColor;in float v_outlineWidth;#endif
in vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
const float SHIFT_LEFT1 = 2.0;const float SHIFT_RIGHT1 = 1.0 / 2.0;
float getGlobeDepthAtCoords(vec2 st){ 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;}
#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
bool getDepthTestEnabled() { float temp = v_compressed.y; temp = temp * SHIFT_RIGHT1; float temp2 = (temp - floor(temp)) * SHIFT_LEFT1; return temp2 != 0.0;}
float getRelativeEyeDepth(float eyeDepth, float distanceToEllipsoid, float epsilon) { float depthDifferential = eyeDepth - distanceToEllipsoid; float depthRatio = abs(depthDifferential / distanceToEllipsoid); if (depthRatio < epsilon) { // The approximations are imprecise, so use an epsilon check for small value differences and assume a value of 0.0
return 0.0; }
return depthDifferential;}
// Extra manual depth testing is done to allow more control over how a billboard is occluded
// by the globe when near and far from the camera.
void doDepthTest(float eyeDepth, float globeDepth) {
#ifdef VS_THREE_POINT_DEPTH_CHECK // Since discarding vertices is not possible, the vertex shader sets eyeDepth to 0 to indicate the depth test failed. Apply the discard here.
if (eyeDepth > -u_threePointDepthTestDistance) { if (eyeDepth == 0.0) { discard; } return; }#endif bool useGlobeDepth = eyeDepth > -u_coarseDepthTestDistance; if (useGlobeDepth && globeDepth == 0.0) { // Pixel is not on the globe, so there is no distance to compare against. Pass.
return; }
// If the camera is close, compare against the globe depth texture that includes depth from the 3D tile pass.
if (useGlobeDepth && getRelativeEyeDepth(eyeDepth, globeDepth, czm_epsilon1) < 0.0) { discard; }}
#ifdef LOG_DEPTHvoid writeDepth(float eyeDepth, float globeDepth, float distanceToEllipsoid) { // If we've made it here, the manual depth test above determined that this fragment should be visible.
// But the automatic depth test must still run in order to write the result to the depth buffer, and its results may
// disagree with our manual depth test's results. To prefer our manual results when in front of the globe, apply an offset towards the camera.
float depthArg = v_depthFromNearPlusOne;
if (globeDepth != 0.0 && getRelativeEyeDepth(eyeDepth, distanceToEllipsoid, czm_epsilon3) > 0.0) { float globeDepthFromNearPlusOne = (-globeDepth - czm_currentFrustum.x) + 1.0; float nudge = max(globeDepthFromNearPlusOne * 5e-6, czm_epsilon7); float globeOnTop = max(1.0, globeDepthFromNearPlusOne - nudge); depthArg = min(depthArg, globeOnTop); }
czm_writeLogDepth(depthArg);}#endif
void main(){ if (v_splitDirectionAndEllipsoidDepthEC.x < 0.0 && gl_FragCoord.x > czm_splitPosition) { discard; } if (v_splitDirectionAndEllipsoidDepthEC.x > 0.0 && gl_FragCoord.x < czm_splitPosition) { discard; }
if (getDepthTestEnabled()) { vec2 fragSt = gl_FragCoord.xy / czm_viewport.zw; float eyeDepth = v_compressed.x; float globeDepth = getGlobeDepthAtCoords(fragSt); float distanceToEllipsoid = -v_splitDirectionAndEllipsoidDepthEC.y; doDepthTest(eyeDepth, globeDepth);
#ifdef LOG_DEPTH writeDepth(eyeDepth, globeDepth, distanceToEllipsoid); #endif }
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;}`;var p3=`uniform float u_threePointDepthTestDistance;in vec2 direction;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, disableDepthTestDistanceSq, dimensions
in vec2 sdf; // sdf outline color (rgb) and width (w)
in float splitDirection; // splitDirection
#ifdef VS_THREE_POINT_DEPTH_CHECKin vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates
#endif#ifdef VECTOR_TILEin float a_batchId;#endif
out vec2 v_textureCoordinates;out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
out vec4 v_pickColor;out vec4 v_color;flat out vec2 v_splitDirectionAndEllipsoidDepthEC; // x: splitDirection, y: ellipsoid depth in eye coordinates
#ifdef SDFout 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 VS_THREE_POINT_DEPTH_CHECKfloat 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;}#endifvoid 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;
origin -= vec2(1.0);
float show = floor(compressed * SHIFT_RIGHT2); compressed -= show * SHIFT_LEFT2;
vec2 textureCoordinatesBottomLeft = czm_decompressTextureCoordinates(compressedAttribute0.w); vec2 textureCoordinatesRange = czm_decompressTextureCoordinates(eyeOffset.w); vec2 textureCoordinates = textureCoordinatesBottomLeft + direction * textureCoordinatesRange;
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.x *= SHIFT_RIGHT2; // undo translateX scaling (helps preserve subpixel precision, see BillboardCollection.js attribute writer for more info)
translate.y += (temp - floor(temp)) * SHIFT_LEFT8; translate.y -= UPPER_BOUND; translate.y *= SHIFT_RIGHT2;
temp = compressedAttribute1.x * SHIFT_RIGHT8; float temp2 = floor(compressedAttribute2.w * SHIFT_RIGHT2);
vec2 imageSize = vec2(floor(temp), temp2);
#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
#ifdef VS_THREE_POINT_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 color = czm_decodeRGB8(compressedAttribute2.x); vec4 pickColor = czm_decodeRGB8(compressedAttribute2.y);
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.a /= 255.0;
color.a = floor(temp); color.a /= 255.0;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); vec4 positionEC = czm_modelViewRelativeToEye * p;
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;
float enableDepthCheck = 1.0;#ifdef DISABLE_DEPTH_DISTANCE float disableDepthTestDistanceSq = compressedAttribute3.z; if (disableDepthTestDistanceSq == 0.0 && czm_minimumDisableDepthTestDistance != 0.0) { disableDepthTestDistanceSq = czm_minimumDisableDepthTestDistance; }
if (lengthSq < disableDepthTestDistanceSq || disableDepthTestDistanceSq < 0.0) { enableDepthCheck = 0.0; }#endif
v_splitDirectionAndEllipsoidDepthEC.y = czm_infinity; vec3 ellipsoidCenter = czm_view[3].xyz; vec3 rayDirection = normalize(positionEC.xyz); czm_ray ray = czm_ray(vec3(0.0), rayDirection); vec3 ellipsoid_inverseRadii = czm_ellipsoidInverseRadii; czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii);
if (!czm_isEmpty(intersection)) { v_splitDirectionAndEllipsoidDepthEC.y = intersection.start; }
v_compressed.y = enableDepthCheck;
#ifdef VS_THREE_POINT_DEPTH_CHECKif (lengthSq < (u_threePointDepthTestDistance * u_threePointDepthTestDistance) && (enableDepthCheck == 1.0)) { float depthsilon = 10.0; vec2 depthOrigin; // Horizontal origin for labels comes from a special attribute. If that value is 0, this is a billboard - use the regular origin.
// Otherwise, transform the label origin to -1, 0, 1 (right, center, left).
depthOrigin.x = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2)); depthOrigin.x = czm_branchFreeTernary(depthOrigin.x == 0.0, origin.x, depthOrigin.x - 2.0); depthOrigin.y = origin.y;
vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), depthOrigin, vec2(0.0), 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), depthOrigin, vec2(0.0), 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), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp); float globeDepth3 = getGlobeDepth(pEC3); if (globeDepth3 != 0.0 && pEC3.z + depthsilon < globeDepth3) { // "Discard" this vertex, as three key points fail depth test.
positionEC.xyz = vec3(0.0); } } }}#endif // Write out the eyespace depth before applying the screen space offset, but after potentially "discarding" the vertex
// by setting its eyespace position to zero, via the three-point depth test above.
v_compressed.x = positionEC.z;
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 (disableDepthTestDistanceSq != 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); // disableDepthTestDistanceSq can be less than zero if it's explicitly set to -1 in JS (as a sentinel value equivalent to infinity)
if (!clipped && (disableDepthTestDistanceSq < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistanceSq))) { // Position z on the near plane.
gl_Position.z = -gl_Position.w;#ifdef LOG_DEPTH v_depthFromNearPlusOne = 1.0;#endif } }#endif
#ifdef SDF vec4 outlineColor = czm_decodeRGB8(sdf.x); float outlineWidth;
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.a /= 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; v_splitDirectionAndEllipsoidDepthEC.x = splitDirection;}`;var cZe=Object.freeze({NONE:0,LOADING:2,LOADED:3,ERROR:4,FAILED:5}),Ga=cZe;function gh(e){this._billboardCollection=e,this._id=void 0,this._loadState=Ga.NONE,this._loadError=void 0,this._index=-1,this._width=void 0,this._height=void 0,this._hasSubregion=!1,this.dirty=!1}Object.defineProperties(gh.prototype,{loadError:{get:function(){return this._loadError}},loadState:{get:function(){return this._loadState}},ready:{get:function(){return this._loadState===Ga.LOADED}},hasImage:{get:function(){return this._loadState!==Ga.NONE}},id:{get:function(){return this._id}},width:{get:function(){return this._width}},height:{get:function(){return this._height}}});gh.prototype.unload=async function(){this._loadState!==Ga.NONE&&(this._id=void 0,this._loadError=void 0,this._loadState=Ga.NONE,this._index=-1,this._width=void 0,this._height=void 0,this.dirty=!0)};gh.prototype.loadImage=async function(e,t,n,i){if(this._id===e)return;let o=this._billboardCollection,r=o.billboardTextureCache,a=r.get(e);if(l(a)&&t.loadState===Ga.LOADING||t.loadState===Ga.LOADED){gh.clone(a,this);return}l(a)||(a=new gh(o),r.set(e,a)),a._id=this._id=e,a._loadState=this._loadState=Ga.LOADING,a._loadError=this._loadError=void 0;let s,c=this._billboardCollection.textureAtlas;try{s=c.addImage(e,t,n,i),s instanceof Promise&&(s=await s)}catch(f){if(a._loadState=Ga.ERROR,a._loadError=f,this._id!==e)return;this._loadState=Ga.ERROR,this._loadError=f;return}if(!l(s)||s===-1){if(a._loadState=Ga.FAILED,a._index=-1,this._id!==e)return;this._loadState=Ga.FAILED,this._index=-1;return}a._index=s,a._loadState=Ga.LOADED;let u=c.rectangles[s];a._width=u.width,a._height=u.height,this._id===e&&(this._index=s,this._loadState=Ga.LOADED,this._width=u.width,this._height=u.height,this.dirty=!0)};gh.prototype.addImageSubRegion=function(e,t){this._id=e,this._loadError=void 0,this._hasSubregion=!0;let i=this._billboardCollection.textureAtlas.addImageSubRegion(e,t);if(typeof i=="number"){this.setImageSubRegion(i,t);return}this.loadImageSubRegion(e,t,i)};gh.prototype.loadImageSubRegion=async function(e,t,n){let i;try{this._loadState=Ga.LOADING,i=await n}catch(o){this._loadState=Ga.ERROR,this._loadError=o;return}this._id===e&&(this._loadState=Ga.LOADED,this.setImageSubRegion(i,t))};gh.prototype.setImageSubRegion=function(e,t){if(this._index!==e){if(!l(e)||e===-1){this._loadState=Ga.FAILED,this._index=-1,this._width=void 0,this._height=void 0;return}this._width=t.width,this._height=t.height,this._index=e,this.dirty=!0}};gh.prototype.computeTextureCoordinates=function(e){return this._billboardCollection.textureAtlas.computeTextureCoordinates(this._index,e)};gh.clone=function(e,t){if(t._id=e._id,t._loadState=e._loadState,t._loadError=void 0,t._index=e._index,t._width=e._width,t._height=e._height,t._hasSubregion=e._hasSubregion,e.ready){t.dirty=!0;return}return(async()=>{let i=e._id;await e._billboardCollection.textureAtlas._indexPromiseById.get(i),t._id===i&&(e._hasSubregion&&await Promise.resolve(),t._id=i,t._loadState=e._loadState,t._loadError=e._loadError,t._index=e._index,t._width=e._width,t._height=e._height,t.dirty=!0)})(),t};var q_=gh;function Bi(e,t){e=e??V.EMPTY_OBJECT;let n=e.translucencyByDistance,i=e.pixelOffsetScaleByDistance,o=e.scaleByDistance,r=e.distanceDisplayCondition;l(n)&&(n=Ht.clone(n)),l(i)&&(i=Ht.clone(i)),l(o)&&(o=Ht.clone(o)),l(r)&&(r=Gt.clone(r)),this._show=e.show??!0,this._position=d.clone(e.position??d.ZERO),this._actualPosition=d.clone(this._position),this._pixelOffset=Q.clone(e.pixelOffset??Q.ZERO),this._translate=new Q(0,0),this._eyeOffset=d.clone(e.eyeOffset??d.ZERO),this._heightReference=e.heightReference??ot.NONE,this._verticalOrigin=e.verticalOrigin??Yn.CENTER,this._horizontalOrigin=e.horizontalOrigin??Ni.CENTER,this._scale=e.scale??1,this._color=U.clone(e.color??U.WHITE),this._rotation=e.rotation??0,this._alignedAxis=d.clone(e.alignedAxis??d.ZERO),this._width=e.width,this._height=e.height,this._scaleByDistance=o,this._translucencyByDistance=n,this._pixelOffsetScaleByDistance=i,this._sizeInMeters=e.sizeInMeters??!1,this._distanceDisplayCondition=r,this._disabl
in vec2 v_textureCoordinates; void main() { out_FragColor = texture(billboard_texture, v_textureCoordinates); } `,{uniformMap:{billboard_texture:function(){return e.textureAtlas.texture}}});return i.pass=Be.OVERLAY,i}var VZe=[];ud.prototype.update=function(e){if(mK(this),!this.show)return;let t=e.context;if(!t.instancedArrays||!(Nt.maximumVertexTextureImageUnits>0))throw new de("Beginning in CesiumJS 1.140, billboards and labels require device support for WebGL 2, or WebGL 1 with ANGLE_instanced_arrays and MAX_VERTEX_TEXTURE_IMAGE_UNITS > 0. For more information or to share feedback, see: https://github.com/CesiumGS/cesium/issues/13053");let n=this._billboards,i=n.length,o=!0;for(let v=0;v<i;++v){let R=n[v];l(R.loadError)&&(console.error(`Error loading image for billboard: ${R.loadError}`),R.image=void 0),R.textureDirty&&this._updateBillboard(R,ME),R.show&&(o=o&&R.ready)}let r=this._textureAtlas;if(e.afterRender.push(()=>{if(!this.isDestroyed())return r.update(e.context)}),!l(r.texture))return;UZe(this,e),n=this._billboards,i=n.length;let a=this._billboardsToUpdate,s=this._billboardsToUpdateIndex,c=this._propertiesChanged,u=r.guid,f=this._createVertexArray||this._textureAtlasGUID!==u;this._textureAtlasGUID=u;let h,p=e.passes,A=p.pick;if(f||!A&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let v=0;v<hK;++v)c[v]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),i>0){this._vaf=MZe(t,i,this._buffersUsage,this._batchTable,this._sdf),h=this._vaf.writers;for(let v=0;v<i;++v){let R=this._billboards[v];R._dirty=!1,R.textureDirty=!1,kZe(this,e,h,R)}this._vaf.commit(Yde(t))}this._billboardsToUpdateIndex=0}else if(s>0){let v=VZe;v.length=0,(c[TD]||c[BZe]||c[wZe])&&v.push(ohe),(c[ME]||c[qde]||c[TZe]||c[SZe]||c[xZe])&&(v.push(ahe),v.push(dK)),(c[ME]||c[DZe]||c[Zde])&&(v.push(she),v.push(fK)),(c[ME]||c[Xde])&&v.push(fK),(c[ME]||c[Kde])&&v.push(dK),c[Jde]&&v.push(che),c[$de]&&v.push(lhe),(c[ehe]||c[vZe]||c[ME]||c[TD])&&v.push(uhe),(c[ME]||c[TD])&&v.push(fhe),c[the]&&v.push(dhe),c[nhe]&&v.push(hhe);let R=v.length;if(h=this._vaf.writers,s/i>.1){for(let N=0;N<s;++N){let L=a[N];L._dirty=!1,L.textureDirty=!1;for(let g=0;g<R;++g)v[g](this,e,h,L)}this._vaf.commit(Yde(t))}else{for(let N=0;N<s;++N){let L=a[N];L._dirty=!1,L.textureDirty=!1;for(let g=0;g<R;++g)v[g](this,e,h,L);this._vaf.subCommit(L._index,1)}this._vaf.endSubCommits()}this._billboardsToUpdateIndex=0}if(s>i*1.5&&(a.length=i),!l(this._vaf)||!l(this._vaf.va))return;this._boundingVolumeDirty&&(this._boundingVolumeDirty=!1,le.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let m,_=P.IDENTITY;e.mode===oe.SCENE3D?(_=this.modelMatrix,m=le.clone(this._baseVolumeWC,this._boundingVolume)):m=le.clone(this._baseVolume2D,this._boundingVolume),zZe(this,e,m);let y=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,y){this._blendOption===nr.OPAQUE||this._blendOption===nr.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=Ve.fromCache({depthTest:{enabled:!0,func:ee.LESS},depthMask:!0}):this._rsOpaque=void 0;let v=this._blendOption===nr.TRANSLUCENT;this._blendOption===nr.TRANSLUCENT||this._blendOption===nr.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=Ve.fromCache({depthTest:{enabled:!0,func:v?ee.LEQUAL:ee.LESS},depthMask:v,blending:sn.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let C,E,I,x,S;if(y||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=p3,E=m3,S=["INSTANCED"],l(this._batchTable)&&(S.push("VECTOR_TILE"),C=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(C),E=this._batchTable.getFragmentShaderCallback(
`),n="";for(let i=0;i<t.length;i++){let o=t[i],r=Che.test(o.charAt(0)),a=$Ze(o,Che),s=0,c="";for(let u=0;u<a.length;++u){let f=a[u],h=f.Type===Va.BRACKETS?t$e(f.Word):e$e(f.Word);r?f.Type===Va.RTL?(c=h+c,s=0):f.Type===Va.LTR?(c=DD(c,s,f.Word),s+=f.Word.length):(f.Type===Va.WEAK||f.Type===Va.BRACKETS)&&(f.Type===Va.WEAK&&a[u-1].Type===Va.BRACKETS?c=h+c:a[u-1].Type===Va.RTL?(c=h+c,s=0):a.length>u+1?a[u+1].Type===Va.RTL?(c=h+c,s=0):(c=DD(c,s,f.Word),s+=f.Word.length):c=DD(c,0,h)):f.Type===Va.RTL?c=DD(c,s,h):f.Type===Va.LTR?(c+=f.Word,s=c.length):(f.Type===Va.WEAK||f.Type===Va.BRACKETS)&&(u>0&&a[u-1].Type===Va.RTL?a.length>u+1?a[u+1].Type===Va.RTL?c=DD(c,s,h):(c+=f.Word,s=c.length):c+=f.Word:(c+=f.Word,s=c.length))}n+=c,i<t.length-1&&(n+=``)}return n}var FE=yh;var She=Na(Ihe(),1);function a$e(){this.dimensions=void 0,this.billboardTexture=void 0,this.billboard=void 0}var s$e=1.2,bhe="ID_WHITE_PIXEL",AK=new Q(4,4),c$e=new et(1,1,1,1);function l$e(e,t){let n=t._backgroundBillboardTexture;if(!n.hasImage){let o=document.createElement("canvas");o.width=AK.x,o.height=AK.y;let r=o.getContext("2d");r.fillStyle="#fff",r.fillRect(0,0,o.width,o.height),n.loadImage(bhe,o),n.addImageSubRegion(bhe,c$e)}let i=e.add({collection:t});return i.setImageTexture(n),i._positionFromParent=!0,i._labelTranslate=new Q,i}var MA={};function u$e(e,t,n,i,o,r){return MA.font=t,MA.fillColor=n,MA.strokeColor=i,MA.strokeWidth=o,MA.padding=Ys.PADDING,MA.fill=r===Ir.FILL||r===Ir.FILL_AND_OUTLINE,MA.stroke=r===Ir.OUTLINE||r===Ir.FILL_AND_OUTLINE,MA.backgroundColor=U.BLACK,Tx(e,MA)}function gK(e,t){let n=t.billboard;l(n)&&(n.show=!1,n._clampedPosition=void 0,l(n._removeCallbackFunc)&&(n._removeCallbackFunc(),n._removeCallbackFunc=void 0),e._spareBillboards.push(n),t.billboard=void 0)}var f$e=new She.default,d$e=/\s/;function h$e(e,t){let n=t._renderedText,i=f$e.splitGraphemes(n),o=i.length,r=t._glyphs,a=r.length;if(t._relativeSize=t._fontSize/Ys.FONT_SIZE,o<a)for(let p=o;p<a;++p)gK(e,r[p]);r.length=o;let s=t._backgroundBillboard,c=e._backgroundBillboardCollection;t._showBackground&&!l(s)&&(s=l$e(c,e),t._backgroundBillboard=s),m$e(c,t,s);let u=e._glyphBillboardCollection,f=u.billboardTextureCache,h=e._textDimensionsCache;for(let p=0;p<o;++p){let A=i[p],m=t._verticalOrigin,_=JSON.stringify([A,t._fontFamily,t._fontStyle,t._fontWeight,+m]),y=h[_],C=f.get(_);if(!l(C)||!l(y)){C=new q_(u),f.set(_,C);let S=`${t._fontStyle} ${t._fontWeight} ${Ys.FONT_SIZE}px ${t._fontFamily}`,w=u$e(A,S,U.WHITE,U.WHITE,0,Ir.FILL);if(y=w.dimensions,h[_]=y,w.width>0&&w.height>0&&!d$e.test(A)){let v=(0,The.default)(w,{cutoff:Ys.CUTOFF,radius:Ys.RADIUS}),R=w.getContext("2d"),N=w.width,L=w.height,g=R.getImageData(0,0,N,L);for(let b=0;b<N;b++)for(let T=0;T<L;T++){let B=T*N+b,M=v[B]*255,O=B*4;g.data[O+0]=M,g.data[O+1]=M,g.data[O+2]=M,g.data[O+3]=M}R.putImageData(g,0,0),C.loadImage(_,w)}}let E=r[p];if(l(E)||(E=new a$e,E.dimensions=y,E.billboardTexture=C,r[p]=E),E.billboardTexture.id!==_&&(E.billboardTexture=C,E.dimensions=y),!C.hasImage){gK(e,E);continue}let I=E.billboard,x=e._spareBillboards;l(I)||(x.length>0?I=x.pop():(I=u.add({collection:e}),I._labelDimensions=new Q,I._labelTranslate=new Q,I._positionFromParent=!0),E.billboard=I),I.setImageTexture(C),I.show=t._show,I.position=t._position,I.eyeOffset=t._eyeOffset,I.pixelOffset=t._pixelOffset,I.horizontalOrigin=Ni.LEFT,I.verticalOrigin=t._verticalOrigin,I.heightReference=t._heightReference,l(t._clampedPosition)&&(I._clampedPosition=t._clampedPosition),I.scale=t.totalScale,I.pickPrimitive=t,I.id=t._id,I.translucencyByDistance=t._translucencyByDistance,I.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,I.scaleByDistance=t._scaleByDistance,I.distanceDisplayCondition=t._distanceDisplayCondition,I.disableDepthTestDistance=t._disableDepthTestDistance,I._batchIndex=t._batchIndex,I.outlineColor=t.outlineColor,t.style===Ir.FILL_AND_OUTLINE?(I.color=t._fillColor,I.outlineWidth=t.outlineWidth):t.style===Ir.FILL?(I.color=t._fillColor,I.outlineWidth=0):t.style===Ir.OUTLINE&&(I.color=U.TRANSPARENT,I.outlineWidth=t.outlineWidth)}t._repositionAllGlyphs=!0}function m$e(e,t,n){if(!l(n))return;let i=t.show&&t._showBackground&&t._renderedText.split(``).join("").length>0;if(t.show&&!i){e.remove(n),t._backgroundBillboard=n=void 0;return}n.color=t._backgroundColor,n.show=t._show,n.position=t._position,n.eyeOffset=t._eyeOffset,n.pixelOffset=t._pixelOffset,n.horizontalOrigin=Ni.LEFT,n.verticalOrigin=t._verticalOrigin,n.heightReference=t._heightReference,l(t._clampedPosition)&&(n._clampedPosition=t._clampedPosition),n.scale=t.totalScale,n.pickPrimitive=t,n.id=t._id,n.translucencyByDistance=t._translucencyByDistance,n.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,n.scaleByDistance=t._scaleByDistance,n.distanceDisplayCondition=t._distanceDisplayCondition,n.disableDepthTestDistance=t._disableDepthTestDistance,n.clusterShow=t.clusterShow}function xhe(e,t,n){return t===Ni.CENTER?-e/2:t===Ni.RIGHT?-(e+n.x):n.x}var Rr=new Q,p$e=new Q;function A$e(e){let t=e._glyphs,n=e._renderedText,i=0,o=0,r=[],a=Number.NEGATIVE_INFINITY,s=0,c=1,u=t.length,f=e._backgroundBillboard,h=Q.clone(l(f)?e._backgroundPadding:Q.ZERO,p$e);h.x/=e._relativeSize,h.y/=e._relativeSize;for(let N=0;N<u;++N){if(n.charAt(N)===``){r.push(i),++c,i=0;continue}let g=t[N].dimensions;l(g)&&(s=Math.max(s,g.height-g.descent),a=Math.max(a,g.descent),i+=g.width-g.minx,N<u-1&&(i+=t[N+1].dimensions.minx),o=Math.max(o,i))}r.push(i);let p=s+a,A=e.totalScale,m=e._horizontalOrigin,_=e._verticalOrigin,y=0,C=r[y],E=xhe(C,m,h),I=(l(e._lineHeight)?e._lineHeight:s$e*e._fontSize)/e._relativeSize,x=I*(c-1),S=o,w=p+x;l(f)&&(S+=h.x*2,w+=h.y*2,f._labelHorizontalOrigin=m),Rr.x=E*A,Rr.y=0;let v=!0,R=0;for(let N=0;N<u;++N){if(n.charAt(N)===``){++y,R+=I,C=r[y],E=xhe(C,m,h),Rr.x=E*A,v=!0;continue}let L=t[N],g=L.dimensions;if(l(g)&&(_===Yn.TOP?(Rr.y=g.height-s-h.y,Rr.y+=Ys.PADDING):_===Yn.CENTER?Rr.y=(x+g.height-s)/2:_===Yn.BASELINE?(Rr.y=x,Rr.y-=Ys.PADDING):(Rr.y=x+a+h.y,Rr.y-=Ys.PADDING),Rr.y=(Rr.y-g.descent-R)*A,v&&(Rr.x-=Ys.PADDING*A,v=!1),l(L.billboard)&&(L.billboard._setTranslate(Rr),L.billboard._labelDimensions.x=S,L.billboard._labelDimensions.y=w,L.billboard._labelHorizontalOrigin=m,Hf(e.heightReference)&&(L.billboard._labelTranslate=Q.clone(Rr,L.billboard._labelTranslate))),N<u-1)){let b=t[N+1];Rr.x+=(g.width-g.minx+b.dimensions.minx)*A}}l(f)&&n.split(``).join("").length>0&&(m===Ni.CENTER?E=-o/2-h.x:m===Ni.RIGHT?E=-(o+h.x*2):E=0,Rr.x=E*A,_===Yn.TOP?Rr.y=p-s-a:_===Yn.CENTER?Rr.y=(p-s)/2-a:_===Yn.BASELINE?Rr.y=-h.y-a:Rr.y=0,Rr.y=Rr.y*A,f.width=S,f.height=w,f._setTranslate(Rr),f._labelTranslate=Q.clone(Rr,f._labelTranslate))}function whe(e,t){let n=t._glyphs;for(let i=0,o=n.length;i<o;++i)gK(e,n[i]);l(t._backgroundBillboard)&&(e._backgroundBillboardCollection.remove(t._backgroundBillboard),t._backgroundBillboard=void 0),t._labelCollection=void 0,l(t._removeCallbackFunc)&&t._removeCallbackFunc(),fe(t)}function op(e){e=e??V.EMPTY_OBJECT,this._scene=e.scene,this._batchTable=e.batchTable;let t=new fd({scene:this._scene,textureAtlas:new KI({initialSize:AK}),coarseDepthTestDistance:e.coarseDepthTestDistance,threePointDepthTestDistance:e.threePointDepthTestDistance});this._backgroundBillboardCollection=t,this._backgroundBillboardTexture=new q_(t),this._glyphBillboardCollection=new fd({scene:this._scene,batchTable:this._batchTable,coarseDepthTestDistance:e.coarseDepthTestDistance,threePointDepthTestDistance:e.threePointDepthTestDistance}),this._glyphBillboardCollection._sdf=!0,this._spareBillboards=[],this._textDimensionsCache={},this._labels=[],this._labelsToUpdate=[],this._totalGlyphCount=0,this._highlightColor=U.clone(U.WHITE),this.show=e.show??!0,this.modelMatrix=P.clone(e.modelMatrix??P.IDENTITY),this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this.blendOption=e.blendOption??nr.OPAQUE_AND_TRANSLUCENT}Object.defineProperties(op.prototype,{length:{get:function(){return this._labels.length}},sizeInBytes:{get:function(){return this._glyphBillboardCollection.sizeInBytes+this._backgroundBillboardCollection.sizeInBytes}},ready:{get:function(){let e=this._backgroundBillboardCollection.get(0);return l(e)&&!e.ready?!1:this._glyphBillboardCollection.ready}},coarseDepthTestDistance:{get:function(){return this._backgroundBillboardCollection.coarseDepthTestDistance},set:function(e){this._backgroundBillboardCollection.coarseDepthTestDistance=e,this._glyphBillboardCollection.coarseDepthTestDistance=e}},threePointDepthTestDistance:{get:function(){return this._backgroundBillboardCollection.threePointDepthTestDistance},set:function(e){this._backgroundBillboardCollection.threePointDepthTestDistance=e,this._glyphBillboardCollection.threePointDepthTestDistance=e}}});op.prototype.add=function(e){let t=new FE(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};op.prototype.remove=function(e){if(l(e)&&e._labelCollection===this){let t=this._labels.indexOf(e);if(t!==-1)return this._labels.splice(t,1),whe(this,e),!0}return!1};op.prototype.removeAll=function(){let e=this._labels;for(let t=0,n=e.length;t<n;++t)whe(this,e[t]);e.length=0};op.prototype.contains=function(e){return l(e)&&e._labelCollection===this};op.prototype.get=function(e){return this._labels[e]};op.prototype.update=function(e){if(!this.show)return;let t=this._glyphBillboardCollection,n=this._backgroundBillboardCollection;t.modelMatrix=this.modelMatrix,t.debugShowBoundingVolume=this.debugShowBoundingVolume,n.modelMatrix=this.modelMatrix,n.debugShowBoundingVolume=this.debugShowBoundingVolume;let i=this._labelsToUpdate.length;for(let r=0;r<i;++r){let a=this._labelsToUpdate[r];if(a.isDestroyed())continue;let s=a._glyphs.length;a._rebindAllGlyphs&&(h$e(this,a),a._rebindAllGlyphs=!1),a._repositionAllGlyphs&&(A$e(a),a._repositionAllGlyphs=!1);let c=a._glyphs.length-s;this._totalGlyphCount+=c}let o=n.length>0?nr.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)};op.prototype.isDestroyed=function(){return!1};op.prototype.destroy=function(){return this.removeAll(),this._glyphBillboardCollection=this._glyphBillboardCollection.destroy(),this._backgroundBillboardCollection=this._backgroundBillboardCollection.destroy(),fe(this)};var NA=op;var E3=`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 Bl={};Bl.numberOfPoints=function(e,t,n){let i=d.distance(e,t);return Math.ceil(i/n)};Bl.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 g$e=new me;Bl.extractHeights=function(e,t){let n=e.length,i=new Array(n);for(let o=0;o<n;o++){let r=e[o];i[o]=t.cartesianToCartographic(r,g$e).height}return i};var _$e=new P,y$e=new d,Bhe=new d,C$e=new cn(d.UNIT_X,0),Dhe=new d,E$e=new cn(d.UNIT_X,0),I$e=new d,b$e=new d,yK=[];function Phe(e,t,n){let i=yK;i.length=e;let o;if(t===n){for(o=0;o<e;o++)i[o]=t;return i}let a=(n-t)/e;for(o=0;o<e;o++){let s=t+o*a;i[o]=s}return i}var b3=new me,I3=new me,J_=new d,CK=new d,x$e=new d,_K=new i_,vD=new Oc;function T$e(e,t,n,i,o,r,a,s){let c=i.scaleToGeodeticSurface(e,CK),u=i.scaleToGeodeticSurface(t,x$e),f=Bl.numberOfPoints(e,t,n),h=i.cartesianToCartographic(c,b3),p=i.cartesianToCartographic(u,I3),A=Phe(f,o,r);_K.setEndPoints(h,p);let m=_K.surfaceDistance/f,_=s;h.height=o;let y=i.cartographicToCartesian(h,J_);d.pack(y,a,_),_+=3;for(let C=1;C<f;C++){let E=_K.interpolateUsingSurfaceDistance(C*m,I3);E.height=A[C],y=i.cartographicToCartesian(E,J_),d.pack(y,a,_),_+=3}return _}function S$e(e,t,n,i,o,r,a,s){let c=i.cartesianToCartographic(e,b3),u=i.cartesianToCartographic(t,I3),f=Bl.numberOfPointsRhumbLine(c,u,n);c.height=0,u.height=0;let h=Phe(f,o,r);vD.ellipsoid.equals(i)||(vD=new Oc(void 0,void 0,i)),vD.setEndPoints(c,u);let p=vD.surfaceDistance/f,A=s;c.height=o;let m=i.cartographicToCartesian(c,J_);d.pack(m,a,A),A+=3;for(let _=1;_<f;_++){let y=vD.interpolateUsingSurfaceDistance(_*p,I3);y.height=h[_],m=i.cartographicToCartesian(y,J_),d.pack(m,a,A),A+=3}return A}Bl.wrapLongitude=function(e,t){let n=[],i=[];if(l(e)&&e.length>0){t=t??P.IDENTITY;let o=P.inverseTransformation(t,_$e),r=P.multiplyByPoint(o,d.ZERO,y$e),a=d.normalize(P.multiplyByPointAsVector(o,d.UNIT_Y,Bhe),Bhe),s=cn.fromPointNormal(r,a,C$e),c=d.normalize(P.multiplyByPointAsVector(o,d.UNIT_X,Dhe),Dhe),u=cn.fromPointNormal(r,c,E$e),f=1;n.push(d.clone(e[0]));let h=n[0],p=e.length;for(let A=1;A<p;++A){let m=e[A];if(cn.getPointDistance(u,h)<0||cn.getPointDistance(u,m)<0){let _=di.lineSegmentPlane(h,m,s,I$e);if(l(_)){let y=d.multiplyByScalar(a,5e-9,b$e);cn.getPointDistance(s,h)<0&&d.negate(y,y),n.push(d.add(_,y,new d)),i.push(f+1),d.negate(y,y),n.push(d.add(_,y,new d)),f=1}}n.push(d.clone(e[A])),f++,h=m}i.push(f)}return{positions:n,lengths:i}};Bl.generateArc=function(e){l(e)||(e={});let t=e.positions,n=t.length,i=e.ellipsoid??te.default,o=e.height??0,r=Array.isArray(o);if(n<1)return[];if(n===1){let _=i.scaleToGeodeticSurface(t[0],CK);if(o=r?o[0]:o,o!==0){let y=i.geodeticSurfaceNormal(_,J_);d.multiplyByScalar(y,o,y),d.add(_,y,_)}return[_.x,_.y,_.z]}let a=e.minDistance;if(!l(a)){let _=e.granularity??D.RADIANS_PER_DEGREE;a=D.chordLength(_,i.maximumRadius)}let s=0,c;for(c=0;c<n-1;c++)s+=Bl.numberOfPoints(t[c],t[c+1],a);let u=(s+1)*3,f=new Array(u),h=0;for(c=0;c<n-1;c++){let _=t[c],y=t[c+1],C=r?o[c]:o,E=r?o[c+1]:o;h=T$e(_,y,a,i,C,E,f,h)}yK.length=0;let p=t[n-1],A=i.cartesianToCartographic(p,b3);A.height=r?o[n-1]:o;let m=i.cartographicToCartesian(A,J_);return d.pack(m,f,u-3),f};var vhe=new me,w$e=new me;Bl.generateRhumbArc=function(e){l(e)||(e={});let t=e.positions,n=t.length,i=e.ellipsoid??te.default,o=e.height??0,r=Array.isArray(o);if(n<1)return[];if(n===1){let C=i.scaleToGeodeticSurface(t[0],CK);if(o=r?o[0]:o,o!==0){let E=i.geodeticSurfaceNormal(C,J_);d.multiplyByScalar(E,o,E),d.add(C,E,C)}return[C.x,C.y,C.z]}let a=e.granularity??D.RADIANS_PER_DEGREE,s=0,c,u=i.cartesianToCartographic(t[0],vhe),f;for(c=0;c<n-1;c++)f=i.cartesianToCartographic(t[c+1],w$e),s+=Bl.numberOfPointsRhumbLine(u,f,a),u=me.clone(f,vhe);let h=(s+1)*3,p=new Array(h),A=0;for(c=0;c<n-1;c++){let C=t[c],E=t[c+1],I=r?o[c]:o,x=r?o[c+1]:o;A=S$e(C,E,a,i,I,x,p,A)}yK.length=0;let m=t[n-1],_=i.cartesianToCartographic(m,b3);_.height=r?o[n-1]:o;let y=i.cartographicToCartesian(_,J_);return d.pack(y,p,h-3),p};Bl.generateCartesianArc=function(e){let t=Bl.generateArc(e),n=t.len
`,this.material.shaderSource,cb]}),r=t.getVertexShaderCallback()(E3),a=new We({defines:i,sources:[$l,r]});this.shaderProgram=$t.fromCache({context:e,vertexShaderSource:a,fragmentShaderSource:o,attributeLocations:mu})};function Yhe(e){return d.dot(d.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(cn.ORIGIN_ZX_PLANE)===Xt.INTERSECTING}rp.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===oe.SCENE3D||!Yhe(e))return t=e._actualPositions.length,t*4-4;let n=0,i=e._segments.lengths;t=i.length;for(let o=0;o<t;++o)n+=i[o]*4-4;return n};var as=new d,dd=new d,hd=new d,T3=new d,V$e=new ie,H$e=new Q;rp.prototype.write=function(e,t,n,i,o,r,a,s){let c=this.mode,u=s.ellipsoid.maximumRadius*D.PI,f=this.polylines,h=f.length;for(let p=0;p<h;++p){let A=f[p],m=A.width,_=A.show&&m>0,y=A._index,C=this.getSegments(A,s),E=C.positions,I=C.lengths,x=E.length,S=A.getPickId(a).color,w=0,v=0,R;for(let G=0;G<x;++G){G===0?A._loop?R=E[x-2]:(R=T3,d.subtract(E[0],E[1],R),d.add(E[0],R,R)):R=E[G-1],d.clone(R,dd),d.clone(E[G],as),G===x-1?A._loop?R=E[1]:(R=T3,d.subtract(E[x-1],E[x-2],R),d.add(E[x-1],R,R)):R=E[G+1],d.clone(R,hd);let k=I[w];G===v+k&&(v+=k,++w);let z=G-v===0,F=G===v+I[w]-1;c===oe.SCENE2D&&(dd.z=0,as.z=0,hd.z=0),(c===oe.SCENE2D||c===oe.MORPHING)&&(z||F)&&u-Math.abs(as.x)<1&&((as.x<0&&dd.x>0||as.x>0&&dd.x<0)&&d.clone(as,dd),(as.x<0&&hd.x>0||as.x>0&&hd.x<0)&&d.clone(as,hd));let H=z?2:0,Y=F?2:4;for(let $=H;$<Y;++$){xn.writeElements(as,e,n),xn.writeElements(dd,e,n+6),xn.writeElements(hd,e,n+12);let W=$-2<0?-1:1;t[o]=G/(x-1),t[o+1]=2*($%2)-1,t[o+2]=W,t[o+3]=y,n+=18,o+=4}}let N=V$e;N.x=U.floatToByte(S.red),N.y=U.floatToByte(S.green),N.z=U.floatToByte(S.blue),N.w=U.floatToByte(S.alpha);let L=H$e;L.x=m,L.y=_?1:0;let g=c===oe.SCENE2D?A._boundingVolume2D:A._boundingVolumeWC,b=xn.fromCartesian(g.center,Ghe),T=b.high,B=ie.fromElements(b.low.x,b.low.y,b.low.z,g.radius,Vhe),M=Hhe;M.x=0,M.y=Number.MAX_VALUE;let O=A.distanceDisplayCondition;l(O)&&(M.x=O.near,M.y=O.far),r.setBatchedAttribute(y,0,L),r.setBatchedAttribute(y,1,N),r.attributes.length>2&&(r.setBatchedAttribute(y,2,T),r.setBatchedAttribute(y,3,B),r.setBatchedAttribute(y,4,M))}};var W$e=new d,j$e=new d,Y$e=new d,Qhe=new d;rp.prototype.writeForMorph=function(e,t){let n=this.modelMatrix,i=this.polylines,o=i.length;for(let r=0;r<o;++r){let a=i[r],s=a._segments.positions,c=a._segments.lengths,u=s.length,f=0,h=0;for(let p=0;p<u;++p){let A;p===0?a._loop?A=s[u-2]:(A=Qhe,d.subtract(s[0],s[1],A),d.add(s[0],A,A)):A=s[p-1],A=P.multiplyByPoint(n,A,j$e);let m=P.multiplyByPoint(n,s[p],W$e),_;p===u-1?a._loop?_=s[1]:(_=Qhe,d.subtract(s[u-1],s[u-2],_),d.add(s[u-1],_,_)):_=s[p+1],_=P.multiplyByPoint(n,_,Y$e);let y=c[f];p===h+y&&(h+=y,++f);let C=p-h===0,E=p===h+c[f]-1,I=C?2:0,x=E?2:4;for(let S=I;S<x;++S)xn.writeElements(m,e,t),xn.writeElements(A,e,t+6),xn.writeElements(_,e,t+12),t+=18}}};var q$e=new Array(1);rp.prototype.updateIndices=function(e,t,n,i){let o=n.length-1,r=new EK(0,i,this);n[o].push(r);let a=0,s=e[e.length-1],c=0;s.length>0&&(c=s[s.length-1]+1);let u=this.polylines,f=u.length;for(let h=0;h<f;++h){let p=u[h];p._locatorBuckets=[];let A;if(this.mode===oe.SCENE3D){A=q$e;let _=p._actualPositions.length;if(_>0)A[0]=_;else continue}else A=p._segments.lengths;let m=A.length;if(m>0){let _=0;for(let y=0;y<m;++y){let C=A[y]-1;for(let E=0;E<C;++E)c+4>D.SIXTY_FOUR_KILOBYTES&&(p._locatorBuckets.push({locator:r,count:_}),_=0,t.push(4),s=[],e.push(s),c=0,r.count=a,a=0,i=0,r=new EK(0,0,this),n[++o]=[r]),s.push(c,c+2,c+1),s.push(c+1,c+2,c+3),_+=6,a+=6,i+=6,c+=4}p._locatorBuckets.push({locator:r,count:_}),c+4>D.SIXTY_FOUR_KILOBYTES&&(t.push(0),s=[],e.push(s),c=0,r.count=a,i=0,a=0,r=new EK(0,0,this),n[++o]=[r])}p._clean()}return r.count=a,i};rp.prototype.getPolylineStartIndex=function(e){let t=this.polylines,n=0,i=t.length;for(let o=0;o<i;++o){let r=t[o];if(r===e)break;n+=r._actualLength}return n};var Sx={positions:void 0,lengths:void 0},khe=new Array(1),K$e=new d,X$e=new me;rp.prototype.getSegments=function(e,t){let n=e._actualPositions;if(this.mode===oe.SCENE3D)return khe[0]=n.length,
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 Ih(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=e.ellipsoid??te.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=U.clone(U.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(Ih.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function pet(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,a=2+ce.packedLength+te.packedLength+d.packedLength,s=new Float64Array(a),c=0;return s[c++]=n,s[c++]=i,ce.pack(t,s,c),c+=ce.packedLength,te.pack(o,s,c),c+=te.packedLength,d.pack(r,s,c),s}var Aet=new Zn("createVectorTilePolylines",5),wx={previousPosition:0,currentPosition:1,nextPosition:2,expandAndWidth:3,a_batchId:4};function get(e,t){if(l(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,a=e._packedBuffer;l(a)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),a=e._packedBuffer=pet(e));let s=[n.buffer,i.buffer,o.buffer,r.buffer,a.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:a.buffer,keepDecodedPositions:e._keepDecodedPositions},u=Aet.scheduleTask(c,s);if(l(u))return u.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 h=f.indexDatatype;e._indices=h===Ue.UNSIGNED_SHORT?new Uint16Array(f.indices):new Uint32Array(f.indices),_et(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function _et(e,t){if(!l(e._va)){let n=e._currentPositions,i=e._previousPositions,o=e._nextPositions,r=e._expandAndWidth,a=e._vertexBatchIds,s=e._indices,c=i.byteLength+n.byteLength+o.byteLength;c+=r.byteLength+a.byteLength+s.byteLength,e._trianglesLength=s.length/3,e._geometryByteLength=c;let u=tt.createVertexBuffer({context:t,typedArray:i,usage:Re.STATIC_DRAW}),f=tt.createVertexBuffer({context:t,typedArray:n,usage:Re.STATIC_DRAW}),h=tt.createVertexBuffer({context:t,typedArray:o,usage:Re.STATIC_DRAW}),p=tt.createVertexBuffer({context:t,typedArray:r,usage:Re.STATIC_DRAW}),A=tt.createVertexBuffer({context:t,typedArray:a,usage:Re.STATIC_DRAW}),m=tt.createIndexBuffer({context:t,typedArray:s,usage:Re.STATIC_DRAW,indexDatatype:s.BYTES_PER_ELEMENT===2?Ue.UNSIGNED_SHORT:Ue.UNSIGNED_INT}),_=[{index:wx.previousPosition,vertexBuffer:u,componentDatatype:j.FLOAT,componentsPerAttribute:3},{index:wx.currentPosition,vertexBuffer:f,componentDatatype:j.FLOAT,componentsPerAttribute:3},{index:wx.nextPosition,vertexBuffer:h,componentDatatype:j.FLOAT,componentsPerAttribute:3},{index:wx.expandAndWidth,vertexBuffer:p,componentDatatype:j.FLOAT,componentsPerAttribute:2},{index:wx.a_batchId,vertexBuffer:A,componentDatatype:j.UNSIGNED_SHORT,componentsPerAttribute:1}];e._va=new Vn({context:t,attributes:_,indexBuffer:m}),e._positions=void 0,e._widths=void 0,e._coun
void main(){ out_FragColor = u_highlightColor;}`;function Iet(e,t){if(l(e._sp))return;let n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(B3),o=n.getFragmentShaderCallback(!1,void 0,!1)(Eet),r=new We({defines:["VECTOR_TILE","CLIP_POLYLINE"],sources:[$l,i]}),a=new We({defines:["VECTOR_TILE"],sources:[o]});e._sp=$t.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:wx})}function bet(e,t){if(!l(e._command)){let n=e._batchTable.getUniformMapCallback()(e._uniformMap);e._command=new it({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)}Ih.getPolylinePositions=function(e,t){let n=e._batchIds,i=e._decodedPositions,o=e._decodedPositionOffsets;if(!l(n)||!l(i))return;let r,a,s=n.length,c=0,u=0;for(r=0;r<s;++r)n[r]===t&&(c+=o[r+1]-o[r]);if(c===0)return;let f=new Float64Array(c*3);for(r=0;r<s;++r)if(n[r]===t){let h=o[r],p=o[r+1]-h;for(a=0;a<p;++a){let A=(h+a)*3;f[u++]=i[A],f[u++]=i[A+1],f[u++]=i[A+2]}}return f};Ih.prototype.getPositions=function(e){return Ih.getPolylinePositions(this,e)};Ih.prototype.createFeatures=function(e,t){let n=this._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o];t[r]=new Vs(e,r)}};Ih.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function xet(e,t){let n=e._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],a=t[r];a.show=!0,a.color=U.WHITE}}var Tet=new U,wet=U.WHITE,Bet=!0;Ih.prototype.applyStyle=function(e,t){if(!l(e)){xet(this,t);return}let n=this._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],a=t[r];a.color=l(e.color)?e.color.evaluateColor(a,Tet):wet,a.show=l(e.show)?e.show.evaluate(a):Bet}};Ih.prototype.update=function(e){let t=e.context;if(!this._ready){if(l(this._promise)||(this._promise=get(this,t)),l(this._error)){let i=this._error;throw this._error=void 0,i}return}yet(this,t),Iet(this,t),Cet(this);let n=e.passes;(n.render||n.pick)&&bet(this,e)};Ih.prototype.isDestroyed=function(){return!1};Ih.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),fe(this)};var Bx=Ih;var D3=`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 v3=`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 FA(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=e.ellipsoid??te.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 Q(vi._defaultMinTerrainHeight,vi._defaultMaxTerrainHeight),this._boundingVolume=en.fromRectangle(e.rectangle,vi._defaultMinTerrainHeight,vi._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=U.clone(U.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._promise=void 0,this._error=void 0}Object.defineProperties(FA.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function Det(e,t,n){let i=vi.getMinimumMaximumHeights(t,n),o=i.minimumTerrainHeight,r=i.maximumTerrainHeight,a=e._minimumMaximumVectorHeights;a.x=o,a.y=r;let s=e._boundingVolume,c=e._rectangle;en.fromRectangle(c,o,r,n,s)}function vet(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,a=2+ce.packedLength+te.packedLength+d.packedLength,s=new Float64Array(a),c=0;return s[c++]=n,s[c++]=i,ce.pack(t,s,c),c+=ce.packedLength,te.pack(o,s,c),c+=te.packedLength,d.pack(r,s,c),s}var Pet=new Zn("createVectorTileClampedPolylines"),$_={startEllipsoidNormal:0,endEllipsoidNormal:1,startPositionAndHeight:2,endPositionAndHeight:3,startFaceNormalAndVertexCorner:4,endFaceNormalAndHalfWidth:5,a_batchId:6};function Ret(e,t){if(l(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,a=e._packedBuffer;l(a)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),a=e._packedBuffer=vet(e));let s=[n.buffer,i.buffer,o.buffer,r.buffer,a.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:a.buffer,keepDecodedPositions:e._keepDecodedPositions},u=Pet.scheduleTask(c,s);if(l(u))return u.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 h=f.indexDatatype;e._indices=h===Ue.UNSIGNED_SHORT?new Uint16Array(f.indices):new Uint32Array(f.indices),Met(e,t),e._ready=!0}).catch(f=>{e.isDestroyed()||(e._error=f)})}function Met(e,t){if(!l(e._va)){let n=e._startEllipsoidNormals,i=e._endEllipsoidNormals,o=e._startPositionAndHeights,r=e._endPositionAndHeights,a=e._startFaceNormalAndVertexCornerIds,s=e._endFaceNormalAndHalfWidths,c=e._vertexBatchIds,u=e._indices,f=n.byteLength+i.byteLength;f+=o.byteLength+r.byteLength,f+=a.byteLength+s.byteLength,f+=c.byteLength+u.byteLength,e._trianglesLength=u.length/3,e._geometryByteLength=f;let h=tt.createVertexBuffer({context:t,typedArray:n,usage:Re.STATIC_D
in vec3 positionLow;in vec4 pickColor;in vec3 showPixelSizeAndColor;in vec2 outlineWidthAndOutlineColor;
out vec4 v_pickColor;out vec4 v_color;out vec4 v_outlineColor;out float v_innerRadiusFrac;
void main(){ // Unpack attributes.
float show = showPixelSizeAndColor.x; float pixelSize = showPixelSizeAndColor.y; vec4 color = czm_decodeRGB8(showPixelSizeAndColor.z); float outlineWidth = outlineWidthAndOutlineColor.x; vec4 outlineColor = czm_decodeRGB8(outlineWidthAndOutlineColor.y);
///////////////////////////////////////////////////////////////////////////
float innerRadius = 0.5 * pixelSize * czm_pixelRatio; float outerRadius = (0.5 * pixelSize + outlineWidth) * czm_pixelRatio;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); vec4 positionEC = czm_modelViewRelativeToEye * p;
///////////////////////////////////////////////////////////////////////////
gl_Position = czm_projection * positionEC; czm_vertexLogDepth();
v_pickColor = pickColor / 255.0;
v_color = color; v_color.a *= show;
v_outlineColor = outlineColor; v_outlineColor.a *= show;
v_innerRadiusFrac = innerRadius / outerRadius;
gl_PointSize = 2.0 * outerRadius * show; gl_Position *= show;}`;var O3=`in vec4 v_pickColor;in vec4 v_color;in vec4 v_outlineColor;in float v_innerRadiusFrac;
void main(){ // Distance between fragment and point center, 0 to 0.5.
float distanceToCenter = length(gl_PointCoord - vec2(0.5)); float delta = fwidth(distanceToCenter);
float outerLimit = 0.5; float innerLimit = 0.5 * v_innerRadiusFrac;
float outerAlpha = 1.0 - smoothstep(max(0.0, outerLimit - delta), outerLimit, distanceToCenter); float innerAlpha = 1.0 - smoothstep(innerLimit - delta, innerLimit, distanceToCenter);
vec4 color = vec4(mix(v_outlineColor.rgb, v_color.rgb, innerAlpha), outerAlpha);
if (color.a < 0.005) // matches 0/255 and 1/255
{ discard; }
out_FragColor = czm_gammaCorrect(color); czm_writeLogDepth();}`;var FD=class{constructor(t=V.EMPTY_OBJECT){this.color=U.clone(t.color??U.WHITE),this.outlineColor=U.clone(t.outlineColor??U.WHITE),this.outlineWidth=t.outlineWidth??0}static get packedLength(){return this.Layout.__BYTE_LENGTH}static pack(t,n,i){n.setUint32(this.Layout.COLOR_U32+i,t.color.toRgba(),!0),n.setUint32(this.Layout.OUTLINE_COLOR_U32+i,t.outlineColor.toRgba(),!0),n.setUint8(this.Layout.OUTLINE_WIDTH_U8+i,t.outlineWidth)}static unpack(t,n,i){return U.fromRgba(t.getUint32(this.Layout.COLOR_U32+n,!0),i.color),U.fromRgba(t.getUint32(this.Layout.OUTLINE_COLOR_U32+n,!0),i.outlineColor),i.outlineWidth=t.getUint8(this.Layout.OUTLINE_WIDTH_U8+n),i}toJSON(){return{color:this.color.toCssHexString(),outlineColor:this.outlineColor.toCssHexString(),outlineWidth:this.outlineWidth}}};vn(FD,"Layout",{COLOR_U32:0,OUTLINE_COLOR_U32:4,OUTLINE_WIDTH_U8:8,__BYTE_LENGTH:12}),vn(FD,"DEFAULT_MATERIAL");var pu=FD;var QD=class QD extends pu{constructor(t=V.EMPTY_OBJECT){super(t),this.size=t.size??1}static pack(t,n,i){super.pack(t,n,i),n.setUint8(this.Layout.SIZE_U8+i,t.size)}static unpack(t,n,i){return super.unpack(t,n,i),i.size=t.getUint8(this.Layout.SIZE_U8+n),i}toJSON(){return{...super.toJSON(),size:this.size}}};vn(QD,"Layout",{...pu.Layout,SIZE_U8:pu.Layout.__BYTE_LENGTH,__BYTE_LENGTH:pu.Layout.__BYTE_LENGTH+4}),vn(QD,"DEFAULT_MATERIAL",Object.freeze(new QD));var PK=QD,ey=PK;var QA={positionHigh:0,positionLow:1,pickColor:2,showSizeAndColor:3,outlineWidthAndOutlineColor:4},kA=new tf,kD=new ey,UD=new U,Jhe=new d,QE=new xn;function $et(e,t,n){let i=t.context;if(n=n||{destroy:ttt},!l(n.attributeArrays)){let o=e.primitiveCountMax;n.attributeArrays={positionHigh:new Float32Array(o*3),positionLow:new Float32Array(o*3),pickColor:new Uint8Array(o*4),showSizeAndColor:new Float32Array(o*3),outlineWidthAndOutlineColor:new Float32Array(o*2)}}if(l(n.pickIds)||(n.pickIds=[]),e._dirtyCount>0){let{attributeArrays:o,pickIds:r}=n,a=o.positionHigh,s=o.positionLow,c=o.pickColor,u=o.showSizeAndColor,f=o.outlineWidthAndOutlineColor,{_dirtyOffset:h,_dirtyCount:p}=e;for(let A=h,m=h+p;A<m;A++)if(e.get(A,kA),!!kA._dirty){if(e._allowPicking&&kA._pickId===0){let _=i.createPickId({collection:e,index:A,get primitive(){return e.get(this.index,new tf)}});kA._pickId=_.key,r.push(_)}kA.getPosition(Jhe),xn.fromCartesian(Jhe,QE),kA.getMaterial(kD),U.fromRgba(kA._pickId,UD),a[A*3]=QE.high.x,a[A*3+1]=QE.high.y,a[A*3+2]=QE.high.z,s[A*3]=QE.low.x,s[A*3+1]=QE.low.y,s[A*3+2]=QE.low.z,c[A*4]=U.floatToByte(UD.red),c[A*4+1]=U.floatToByte(UD.green),c[A*4+2]=U.floatToByte(UD.blue),c[A*4+3]=U.floatToByte(UD.alpha),u[A*3]=kA.show?1:0,u[A*3+1]=kD.size,u[A*3+2]=tn.encodeRGB8(kD.color),f[A*2]=kD.outlineWidth,f[A*2+1]=tn.encodeRGB8(kD.outlineColor),kA._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){for(let o in QA)if(Object.hasOwn(QA,o)){let r=o;n.vertexArray.copyAttributeFromRange(QA[r],n.attributeArrays[r],e._dirtyOffset,e._dirtyCount)}}}else{let{attributeArrays:o}=n;n.vertexArray=new Vn({context:i,attributes:[{index:QA.positionHigh,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Re.STATIC_DRAW})},{index:QA.positionLow,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Re.STATIC_DRAW})},{index:QA.pickColor,componentDatatype:j.UNSIGNED_BYTE,componentsPerAttribute:4,vertexBuffer:tt.createVertexBuffer({typedArray:o.pickColor,context:i,usage:Re.STATIC_DRAW})},{index:QA.showSizeAndColor,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.showSizeAndColor,context:i,usage:Re.STATIC_DRAW})},{index:QA.outlineWidthAndOutlineColor,componentDatatype:j.FLOAT,componentsPerAttribute:2,vertexBuffer:tt.createVertexBuffer({typedArray:o.outlineWidthAndOutlineColor,context:i,usage:Re.STATIC_DRAW})}]})}return l(n.renderState)||(n.renderState=Ve.fromCache({blending:sn.ALPHA_BLEND,depthTest:{enabled:!0}})),l(n.shaderProgram)||(n.shaderProgram=$t.fromCache({context:i,vertexShaderSource:new We({sources
in vec3 positionLow;in vec4 pickColor;in vec2 showAndColor;
out vec4 v_pickColor;out vec4 v_color;
void main(){ float show = showAndColor.x; vec4 color = czm_decodeRGB8(showAndColor.y);
///////////////////////////////////////////////////////////////////////////
vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); vec4 positionEC = czm_modelViewRelativeToEye * p;
///////////////////////////////////////////////////////////////////////////
gl_Position = czm_projection * positionEC; czm_vertexLogDepth();
v_pickColor = pickColor / 255.0;
v_color = color; v_color.a *= show;
gl_Position *= show;}`;var k3=`in vec4 v_pickColor;in vec4 v_color;
void main(){ if (v_color.a < 0.005) // matches 0/255 and 1/255
{ discard; }
out_FragColor = czm_gammaCorrect(v_color); czm_writeLogDepth();}`;var U3=class U3 extends pu{constructor(t=V.EMPTY_OBJECT){super(t)}};vn(U3,"DEFAULT_MATERIAL",Object.freeze(new U3));var NK=U3,ny=NK;var iy={positionHigh:0,positionLow:1,pickColor:2,showAndColor:3},Sa=new qs,Zhe=new ny,zD=new U,$he=new d,kE=new xn;function ntt(e,t,n){let i=t.context;if(n=n||{destroy:rtt},!l(n.attributeArrays)||!l(n.indexArray)){let{vertexCountMax:o,triangleCountMax:r}=e;n.indexArray=Ue.createTypedArray(o,r*3),n.attributeArrays={positionHigh:new Float32Array(o*3),positionLow:new Float32Array(o*3),pickColor:new Uint8Array(o*4),showAndColor:new Float32Array(o*2)}}if(l(n.pickIds)||(n.pickIds=[]),e._dirtyCount>0){let{attributeArrays:o,pickIds:r}=n,{_dirtyOffset:a,_dirtyCount:s}=e,c=n.indexArray,u=o.positionHigh,f=o.positionLow,h=o.pickColor,p=o.showAndColor;for(let A=a,m=a+s;A<m;A++){if(e.get(A,Sa),!Sa._dirty)continue;if(e._allowPicking&&Sa._pickId===0){let S=i.createPickId({collection:e,index:A,get primitive(){return e.get(A,new qs)}});Sa._pickId=S.key,r.push(S)}let _=Sa.triangleOffset,y=Sa.vertexOffset,C=Sa.getTriangles();for(let S=0,w=Sa.triangleCount;S<w;S++)c[_*3]=y+C[S*3],c[_*3+1]=y+C[S*3+1],c[_*3+2]=y+C[S*3+2],_++;let E=Sa.show,I=Sa.getPositions();Sa.getMaterial(Zhe);let x=tn.encodeRGB8(Zhe.color);U.fromRgba(Sa._pickId,zD);for(let S=0,w=Sa.vertexCount;S<w;S++)d.fromArray(I,S*3,$he),xn.fromCartesian($he,kE),u[y*3]=kE.high.x,u[y*3+1]=kE.high.y,u[y*3+2]=kE.high.z,f[y*3]=kE.low.x,f[y*3+1]=kE.low.y,f[y*3+2]=kE.low.z,h[y*4]=U.floatToByte(zD.red),h[y*4+1]=U.floatToByte(zD.green),h[y*4+2]=U.floatToByte(zD.blue),h[y*4+3]=U.floatToByte(zD.alpha),p[y*2]=E?1:0,p[y*2+1]=x,y++;Sa._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){let{indexOffset:o,indexCount:r,vertexOffset:a,vertexCount:s}=ott(e);n.vertexArray.copyIndexFromRange(n.indexArray,o,r);for(let c in iy)if(Object.hasOwn(iy,c)){let u=c;n.vertexArray.copyAttributeFromRange(iy[u],n.attributeArrays[u],a,s)}}}else{let{attributeArrays:o}=n;n.vertexArray=new Vn({context:i,indexBuffer:tt.createIndexBuffer({context:i,typedArray:n.indexArray,usage:Re.STATIC_DRAW,indexDatatype:Ue.fromTypedArray(n.indexArray)}),attributes:[{index:iy.positionHigh,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Re.STATIC_DRAW})},{index:iy.positionLow,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Re.STATIC_DRAW})},{index:iy.pickColor,componentDatatype:j.UNSIGNED_BYTE,componentsPerAttribute:4,vertexBuffer:tt.createVertexBuffer({typedArray:o.pickColor,context:i,usage:Re.STATIC_DRAW})},{index:iy.showAndColor,componentDatatype:j.FLOAT,componentsPerAttribute:2,vertexBuffer:tt.createVertexBuffer({typedArray:o.showAndColor,context:i,usage:Re.STATIC_DRAW})}]})}return l(n.renderState)||(n.renderState=Ve.fromCache({blending:sn.DISABLED,depthTest:{enabled:!0}})),l(n.shaderProgram)||(n.shaderProgram=$t.fromCache({context:i,vertexShaderSource:new We({sources:[Q3]}),fragmentShaderSource:new We({sources:[k3]}),attributeLocations:iy})),(!l(n.command)||itt(e,n.command))&&(n.command=new it({vertexArray:n.vertexArray,renderState:n.renderState,shaderProgram:n.shaderProgram,primitiveType:Pe.TRIANGLES,pass:Be.OPAQUE,pickId:"v_pickColor",owner:e,count:e.triangleCount*3,modelMatrix:e.modelMatrix,boundingVolume:e.boundingVolumeWC,debugShowBoundingVolume:e.debugShowBoundingVolume})),t.commandList.push(n.command),e._dirtyCount=0,e._dirtyOffset=0,n}function itt(e,t){let n=P.equals(e.modelMatrix,t._modelMatrix),i=le.equals(e.boundingVolumeWC,t._boundingVolume);return e.triangleCount*3!==t._count||e.debugShowBoundingVolume!==t.debugShowBoundingVolume||!n||!i}function ott(e){let{_dirtyOffset:t,_dirtyCount:n}=e;e.get(t,Sa);let i=Sa.vertexOffset,o=Sa.triangleOffset*3;e.get(t+n-1,Sa);let r=Sa.vertexOffset+Sa.vertexCount-i,a=(Sa.triangleOffset+Sa.triangleCount)*3-o;return{indexOffset:o,indexCount:a,vertexOffset:i,vertexCount:r}}function rtt(){let e=this;if(l(e.vertexArray)&&e.vertexArray.destroy(),l(e.shaderProgram)&&e.shaderProgram.destroy(),l(e.renderState)&
in vec3 positionLow;in vec3 prevPositionHigh;in vec3 prevPositionLow;in vec3 nextPositionHigh;in vec3 nextPositionLow;in vec4 pickColor;in vec4 showColorWidthAndTexCoord;
out vec4 v_pickColor;out vec4 v_color;out vec2 v_st;out float v_width;out float v_polylineAngle;
void main(){ float show = showColorWidthAndTexCoord.x; vec4 color = czm_decodeRGB8(showColorWidthAndTexCoord.y); float width = showColorWidthAndTexCoord.z; float texCoord = showColorWidthAndTexCoord.w;
///////////////////////////////////////////////////////////////////////////
bool usePrevious = texCoord == 1.0; float expandDir = gl_VertexID % 2 == 1 ? 1.0 : -1.0; float polylineAngle;
vec4 positionEC = czm_translateRelativeToEye(positionHigh, positionLow); vec4 prevPositionEC = czm_translateRelativeToEye(prevPositionHigh, prevPositionLow); vec4 nextPositionEC = czm_translateRelativeToEye(nextPositionHigh, nextPositionLow);
vec4 positionWC = getPolylineWindowCoordinates(positionEC, prevPositionEC, nextPositionEC, expandDir, width, usePrevious, polylineAngle);
///////////////////////////////////////////////////////////////////////////
gl_Position = czm_viewportOrthographic * positionWC * show;
v_pickColor = pickColor / 255.0;
v_color = color; v_color.a *= show;
v_st.s = texCoord; v_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);
v_width = width; v_polylineAngle = polylineAngle;}`;var V3=`in vec4 v_pickColor;in vec4 v_color;
void main(){ if (v_color.a < 0.005) // matches 0/255 and 1/255
{ discard; }
out_FragColor = czm_gammaCorrect(v_color); czm_writeLogDepth();}`;var GD=class GD extends pu{constructor(t=V.EMPTY_OBJECT){super(t),this.width=t.width??1}static pack(t,n,i){super.pack(t,n,i),n.setUint8(this.Layout.WIDTH_U8+i,t.width)}static unpack(t,n,i){return super.unpack(t,n,i),i.width=t.getUint8(this.Layout.WIDTH_U8+n),i}toJSON(){return{...super.toJSON(),width:this.width}}};vn(GD,"Layout",{...pu.Layout,WIDTH_U8:pu.Layout.__BYTE_LENGTH,__BYTE_LENGTH:pu.Layout.__BYTE_LENGTH+4}),vn(GD,"DEFAULT_MATERIAL",Object.freeze(new GD));var FK=GD,ry=FK;var pd={positionHigh:0,positionLow:1,prevPositionHigh:2,prevPositionLow:3,nextPositionHigh:4,nextPositionLow:5,pickColor:6,showColorWidthAndTexCoord:7},Ks=new Au,QK=new ry,VD=new U,Px=new d,UE=new d,zE=new d,GE=new xn,VE=new xn,HE=new xn;function att(e,t,n){let i=t.context;if(n=n||{destroy:ltt},!l(n.attributeArrays)||!l(n.indexArray)){let o=e.vertexCountMax-e.primitiveCount,r=e.vertexCountMax*2;n.indexArray=Ue.createTypedArray(r,o*6),n.attributeArrays={positionHigh:new Float32Array(r*3),positionLow:new Float32Array(r*3),prevPositionHigh:new Float32Array(r*3),prevPositionLow:new Float32Array(r*3),nextPositionHigh:new Float32Array(r*3),nextPositionLow:new Float32Array(r*3),pickColor:new Uint8Array(r*4),showColorWidthAndTexCoord:new Float32Array(r*4)}}if(l(n.pickIds)||(n.pickIds=[]),e._dirtyCount>0){let{_dirtyOffset:o,_dirtyCount:r}=e,{attributeArrays:a,pickIds:s}=n,c=n.indexArray,u=a.positionHigh,f=a.positionLow,h=a.prevPositionHigh,p=a.prevPositionLow,A=a.nextPositionHigh,m=a.nextPositionLow,_=a.pickColor,y=a.showColorWidthAndTexCoord;for(let C=o,E=o+r;C<E;C++){if(e.get(C,Ks),!Ks._dirty)continue;if(e._allowPicking&&Ks._pickId===0){let R=i.createPickId({collection:e,index:C,get primitive(){return e.get(C,new Au)}});Ks._pickId=R.key,s.push(R)}let I=Ks.getPositions();Ks.getMaterial(QK);let x=tn.encodeRGB8(QK.color);U.fromRgba(Ks._pickId,VD);let S=Ks.show,w=Ks.vertexOffset*2,v=(Ks.vertexOffset-C)*6;for(let R=0,N=Ks.vertexCount;R<N;R++){let L=R===0,g=R===N-1;d.fromArray(I,R*3,Px),L?(d.fromArray(I,(R+1)*3,zE),d.subtract(Px,zE,UE),d.add(Px,UE,UE)):g?(d.fromArray(I,(R-1)*3,UE),d.subtract(Px,UE,zE),d.add(Px,zE,zE)):(d.fromArray(I,(R-1)*3,UE),d.fromArray(I,(R+1)*3,zE)),g||(c[v]=w,c[v+1]=w+1,c[v+2]=w+2,c[v+3]=w+2,c[v+4]=w+1,c[v+5]=w+3,v+=6),xn.fromCartesian(Px,GE),xn.fromCartesian(UE,VE),xn.fromCartesian(zE,HE);for(let b=0;b<2;b++)u[w*3]=GE.high.x,u[w*3+1]=GE.high.y,u[w*3+2]=GE.high.z,f[w*3]=GE.low.x,f[w*3+1]=GE.low.y,f[w*3+2]=GE.low.z,h[w*3]=VE.high.x,h[w*3+1]=VE.high.y,h[w*3+2]=VE.high.z,p[w*3]=VE.low.x,p[w*3+1]=VE.low.y,p[w*3+2]=VE.low.z,A[w*3]=HE.high.x,A[w*3+1]=HE.high.y,A[w*3+2]=HE.high.z,m[w*3]=HE.low.x,m[w*3+1]=HE.low.y,m[w*3+2]=HE.low.z,_[w*4]=U.floatToByte(VD.red),_[w*4+1]=U.floatToByte(VD.green),_[w*4+2]=U.floatToByte(VD.blue),_[w*4+3]=U.floatToByte(VD.alpha),y[w*4]=S?1:0,y[w*4+1]=x,y[w*4+2]=QK.width,y[w*4+3]=R/(N-1),w++}Ks._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){let{indexOffset:o,indexCount:r,vertexOffset:a,vertexCount:s}=ctt(e);n.vertexArray.copyIndexFromRange(n.indexArray,o,r);for(let c in pd)if(Object.hasOwn(pd,c)){let u=c;n.vertexArray.copyAttributeFromRange(pd[u],n.attributeArrays[u],a,s)}}}else{let o=n.attributeArrays;n.vertexArray=new Vn({context:i,indexBuffer:tt.createIndexBuffer({context:i,typedArray:n.indexArray,usage:Re.STATIC_DRAW,indexDatatype:Ue.fromTypedArray(n.indexArray)}),attributes:[{index:pd.positionHigh,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Re.STATIC_DRAW})},{index:pd.positionLow,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Re.STATIC_DRAW})},{index:pd.prevPositionHigh,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.prevPositionHigh,context:i,usage:Re.STATIC_DRAW})},{index:pd.prevPositionLow,componentDatatype:j.FLOAT,componentsPerAttribute:3,vertexBuffer:tt.createVertexBuffer({typedArray:o.prevPositionLow,context:i,usage:Re.STATIC_DRAW})},{index:pd.nextPositionHigh,componentDatatype:j.FLOAT,
{ return ${f}; }`}return r=`${i} ${e}{${r} return ${i}(1.0);}`,r};Rx.prototype.getVariables=function(){let e=[],t=this._runtimeConditions;if(!l(t)||t.length===0)return e;let n=t.length;for(let i=0;i<n;++i){let o=t[i];oi(e,o.condition.getVariables()),oi(e,o.expression.getVariables())}return e=e.filter(function(i,o,r){return r.indexOf(i)===o}),e};var W3=Rx;function ay(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._lineWidth=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,dtt(this,e)}function dtt(e,t){t=Ye(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,e.lineWidth=t.lineWidth;let n={};if(l(t.meta)){let i=t.defines,o=t.meta??V.EMPTY_OBJECT;for(let r in o)o.hasOwnProperty(r)&&(n[r]=new uh(o[r],i))}e._meta=n,e._ready=!0}function cr(e,t){let n=(e._style??V.EMPTY_OBJECT).defines;if(l(t)){if(typeof t=="boolean"||typeof t=="number")return new uh(String(t));if(typeof t=="string")return new uh(t,n);if(l(t.conditions))return new W3(t,n)}else return;return t}function lr(e){if(l(e)){if(l(e.expression))return e.expression;if(l(e.conditionsExpression))return Ye(e.conditionsExpression,!0)}else return;return e}Object.defineProperties(ay.prototype,{style:{get:function(){return this._style}},show:{get:function(){return this._show},set:function(e){this._show=cr(this,e),this._style.show=lr(this._show),this._showShaderFunctionReady=!1}},color:{get:function(){return this._color},set:function(e){this._color=cr(this,e),this._style.color=lr(this._color),this._colorShaderFunctionReady=!1}},pointSize:{get:function(){return this._pointSize},set:function(e){this._pointSize=cr(this,e),this._style.pointSize=lr(this._pointSize),this._pointSizeShaderFunctionReady=!1}},pointOutlineColor:{get:function(){return this._pointOutlineColor},set:function(e){this._pointOutlineColor=cr(this,e),this._style.pointOutlineColor=lr(this._pointOutlineColor)}},pointOutlineWidth:{get:function(){return this._pointOutlineWidth},set:function(e){this._pointOutlineWidth=cr(this,e),this._style.pointOutlineWidth=lr(this._pointOutlineWidth)}},labelColor:{get:function(){return this._labelColor},set:function(e){this._labelColor=cr(this,e),this._style.labelColor=lr(this._labelColor)}},labelOutlineColor:{get:function(){return this._labelOutlineColor},set:function(e){this._labelOutlineColor=cr(this,e),this._style.labelOutlineColor=lr(this._labelOutlineColor)}
// Vertex shader for Gaussian splats.
// The splats are rendered as quads in view space. Splat attributes are loaded from a texture with precomputed 3D covariance.
// Passes local quad coordinates and color to the fragment shader for Gaussian evaluation.
//
// Discards splats outside the view frustum or with negligible screen size.
//
#if defined(HAS_SPHERICAL_HARMONICS)const uint coefficientCount[3] = uint[3](3u,8u,15u);const float SH_C1 = 0.48860251;const float SH_C2[5] = float[5]( 1.092548430, -1.09254843, 0.315391565, -1.09254843, 0.546274215);
const float SH_C3[7] = float[7]( -0.59004358, 2.890611442, -0.45704579, 0.373176332, -0.45704579, 1.445305721, -0.59004358);
//Retrieve SH coefficient. Currently RG32UI format
uvec2 loadSHCoeff(uint splatID, int index) { ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0); uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u]; uint splatsPerRow = uint(shTexSize.x) / dims; uint shIndex = (splatID%splatsPerRow) * dims + uint(index); ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow); return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;}
//Unpack RG32UI half float coefficients to vec3
vec3 halfToVec3(uvec2 packed) { return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);}
vec3 loadAndExpandSHCoeff(uint splatID, int index) { uvec2 coeff = loadSHCoeff(splatID, index); return halfToVec3(coeff);}
vec3 evaluateSH(uint splatID, vec3 viewDir) { vec3 result = vec3(0.0); int coeffIndex = 0; float x = viewDir.x, y = viewDir.y, z = viewDir.z;
if (u_sphericalHarmonicsDegree >= 1.) { vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++); result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;
if (u_sphericalHarmonicsDegree >= 2.) { float xx = x * x; float yy = y * y; float zz = z * z; float xy = x * y; float yz = y * z; float xz = x * z;
vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++); result += SH_C2[0] * xy * sh4 + SH_C2[1] * yz * sh5 + SH_C2[2] * (2.0f * zz - xx - yy) * sh6 + SH_C2[3] * xz * sh7 + SH_C2[4] * (xx - yy) * sh8;
if (u_sphericalHarmonicsDegree >= 3.) { vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++); vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++); result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 + SH_C3[1] * xy * z * sh10 + SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 + SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 + SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 + SH_C3[5] * z * (xx - yy) * sh14 + SH_C3[6] * x * (xx - 3.0f * yy) * sh15; } } } return result;}#endif
// Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid
// which is used to calculate the vertex position in clip space.
vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) { vec4 t = vec4(viewPos, 1.0); vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);
vec2 J1 = focal / t.z; vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z); mat3 J = mat3( J1.x, 0.0, J2.x, 0.0, J1.y, J2.y, 0.0, 0.0, 0.0 );
mat3 R = mat3(czm_modelView);
//transform our covariance into view space
//ensures orientation is correct
mat3 Vrk_view = R * Vrk * transpose(R); mat3 cov = transpose(J) * Vrk_view * J;
float diagonal1 = cov[0][0] + .3; float offDiagonal = cov[0][1]; float diagonal2 = cov[1][1] + .3;
float mid = 0.5 * (diagonal1 + diagonal2); float radius = length(vec2((diagonal1 - diagonal2) * 0.5, offDiagonal)); float lambda1 = mid + radius; float lambda2 = max(mid - radius, 0.1);
vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));
return vec4( min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector, min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x) );}
highp vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0);
void main() { uint texIdx = uint(a_splatIndex); // u_splatRowMask and u_splatRowShift encode the row width of the splat
// attribute texture. The texture width is always maximumTextureSize, which
// varies by GPU, so these are passed as uniforms rather than constants.
// rowMask = maximumTextureSize/2 - 1
// rowShift = log2(maximumTextureSize/2)
uint rowMask = uint(u_splatRowMask); uint rowShift = uint(u_splatRowShift); ivec2 posCoord = ivec2(int((texIdx & rowMask) << 1), int(texIdx >> rowShift)); vec4 splatPosition = vec4( uintBitsToFloat(uvec4(texelFetch(u_splatAttributeTexture, posCoord, 0))) );
vec4 splatViewPos = czm_modelView * vec4(splatPosition.xyz, 1.0); vec4 clipPosition = czm_projection * splatViewPos;
float clip = 1.2 * clipPosition.w; if (clipPosition.z < -clip || clipPosition.x < -clip || clipPosition.x > clip || clipPosition.y < -clip || clipPosition.y > clip) { gl_Position = vec4(0.0, 0.0, 2.0, 1.0); return; }
ivec2 covCoord = ivec2(int(((texIdx & rowMask) << 1) | 1u), int(texIdx >> rowShift)); uvec4 covariance = uvec4(texelFetch(u_splatAttributeTexture, covCoord, 0));
gl_Position = clipPosition;
vec2 u1 = unpackHalf2x16(covariance.x) ; vec2 u2 = unpackHalf2x16(covariance.y); vec2 u3 = unpackHalf2x16(covariance.z); mat3 Vrk = mat3(u1.x, u1.y, u2.x, u1.y, u2.y, u3.x, u2.x, u3.x, u3.y);
vec4 covVectors = calcCovVectors(splatViewPos.xyz, Vrk);
if (dot(covVectors.xy, covVectors.xy) < 4.0 && dot(covVectors.zw, covVectors.zw) < 4.0) { gl_Position = discardVec; return; }
vec2 corner = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2) - 1.;
gl_Position += vec4((corner.x * covVectors.xy + corner.y * covVectors.zw) / czm_viewport.zw * gl_Position.w, 0, 0); gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
v_vertPos = corner ; v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;#if defined(HAS_SPHERICAL_HARMONICS) vec4 splatWC = czm_inverseView * splatViewPos; vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));
v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;#endif v_splitDirection = u_splitDirection;}`;var X3=`//
// Fragment shader for Gaussian splats.
// Renders a Gaussian splat within a quad, discarding fragments outside the unit circle.
// Applies an approximate Gaussian falloff based on distance from the center and outputs
// a color modulated by the alpha and Gaussian weight.
//
void main() { if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard; if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
float A = -dot(v_vertPos, v_vertPos); if (A < -4.) { discard; }
float B = exp(A * 4.) * v_splatColor.a ; out_FragColor = vec4(v_splatColor.rgb * B , B);}`;var jE=new P,hme=new P,jD=new P,Ai=new J,YD=new Qe,Ett=new d,Itt=new Qe,btt=new d,xtt=1e-12,J3=1e-5,WK=1e-7,ws={IDLE:0,WAITING:1,SORTING:2,SORTED:3,ERROR:4},wa={BUILDING:"BUILDING",TEXTURE_PENDING:"TEXTURE_PENDING",TEXTURE_READY:"TEXTURE_READY",SORTING:"SORTING",READY:"READY"},Ttt=2,Stt=30,wtt=3,Btt=.008726646259971648,Dtt=1;function vtt(e,t){let n=e._lastSteadySortFrameNumber>=0?t.frameNumber-e._lastSteadySortFrameNumber:Number.POSITIVE_INFINITY;if(e._lastSteadySortFrameNumber>=0&&n<wtt)return!1;let i=t.camera;return l(i)?!e._hasLastSteadySortCameraPosition||!e._hasLastSteadySortCameraDirection||d.distance(i.positionWC,e._lastSteadySortCameraPosition)>=Dtt?!0:d.angleBetween(i.directionWC,e._lastSteadySortCameraDirection)>=Btt:!1}function cme(e,t){e._lastSteadySortFrameNumber=t.frameNumber;let n=t.camera;l(n)&&(d.clone(n.positionWC,e._lastSteadySortCameraPosition),e._hasLastSteadySortCameraPosition=!0,d.clone(n.directionWC,e._lastSteadySortCameraDirection),e._hasLastSteadySortCameraDirection=!0)}function Ptt(e,t){let n=e._selectedTileSet;if(!l(n)||n.size!==t.length)return!0;for(let i=0;i<t.length;i++)if(!n.has(t[i]))return!0;return!1}function lme(e,t){return l(t)&&t.requestId===e._sortRequestId&&t.dataGeneration===e._splatDataGeneration}function jK(e){l(e)&&(l(e.gaussianSplatTexture)&&(e.gaussianSplatTexture.destroy(),e.gaussianSplatTexture=void 0),l(e.sphericalHarmonicsTexture)&&(e.sphericalHarmonicsTexture.destroy(),e.sphericalHarmonicsTexture=void 0))}function ume(e,t,n){if(!l(t))return;e._retiredTextures.push({texture:t,frameNumber:n})}function Rtt(e,t){let n=e._retiredTextures;if(!l(n)||n.length===0)return;let i=[];for(let o=0;o<n.length;o++){let r=n[o];t-r.frameNumber>0?r.texture.destroy():i.push(r)}e._retiredTextures=i}function Mtt(e,t){let n=e?.[t];return l(n)?n.buffer:void 0}function Ntt(e,t,n,i){let o=e._aggregateScratchBuffers[t];l(o)||(o=[],e._aggregateScratchBuffers[t]=o);let r=Mtt(e._snapshot,t);for(let s=0;s<o.length;s++){let c=o[s];if(c.length>=i&&c.buffer!==r)return c}let a=j.createTypedArray(n,i);return o.push(a),a}function Ltt(e,t){return e.length===t?e:e.subarray(0,t)}function Ott(e,t,n){if(!l(t.indexes)||t.state!==wa.READY)throw new de("Committing snapshot before it is READY.");let i=n.frameNumber,o=e._snapshot,r=l(o)?o.gaussianSplatTexture:e.gaussianSplatTexture;l(r)&&r!==t.gaussianSplatTexture&&ume(e,r,i);let a=l(o)?o.sphericalHarmonicsTexture:e.sphericalHarmonicsTexture;l(a)&&a!==t.sphericalHarmonicsTexture&&ume(e,a,i),e._snapshot=t,e._positions=t.positions,e._rotations=t.rotations,e._scales=t.scales,e._colors=t.colors,e._shData=t.shData,e._sphericalHarmonicsDegree=t.sphericalHarmonicsDegree,e._numSplats=t.numSplats,e._indexes=t.indexes,e.gaussianSplatTexture=t.gaussianSplatTexture,e.sphericalHarmonicsTexture=t.sphericalHarmonicsTexture,e._lastTextureWidth=t.lastTextureWidth,e._lastTextureHeight=t.lastTextureHeight,e._splatRowMask=t.splatRowMask,e._splatRowShift=t.splatRowShift,e._splatBudgetSSEScale=t.splatBudgetSSEScale??1,e._hasGaussianSplatTexture=l(t.gaussianSplatTexture),e._needsGaussianSplatTexture=!1,e._gaussianSplatTexturePending=!1,e._vertexArray=void 0,e._vertexArrayLen=-1,e._drawCommand=void 0,e._sorterPromise=void 0,e._activeSort=void 0,e._sorterState=ws.IDLE,e._dirty=!1}async function Ftt(e,t,n,i){try{let o=await i,r=Nt.maximumTextureSize,a=r,s=Math.ceil(n.numSplats/(r/2)),c=Math.log2(r/2),u=r/2-1;if(s>r){let A=n.numSplats;s=r;let m=a/2;if(n.numSplats=r*m,n.positions=n.positions.subarray(0,n.numSplats*3),n.rotations=n.rotations.subarray(0,n.numSplats*4),n.scales=n.scales.subarray(0,n.numSplats*3),n.colors=n.colors.subarray(0,n.numSplats*4),l(n.shData)){let _=n.shData.length/A;n.shData=n.shData.subarray(0,Math.floor(n.numSplats*_))}n.splatBudgetSSEScale=A/n.numSplats,console.warn(`[GaussianSplat][HARD CAP] ${A} splats exceed the maximum texture capacity (${r}\xD7${m} = ${n.numSplats} splats at width=${a}). Rendering only the first ${n.numSplats} splats to avoid a WebGL crash. Increasing maximumScreenSpaceError by ${n.splatBudgetSSEScale.toFixed(2)}x next frame.`)}else n.splatBudget
Please retile your tileset with the KHR_gaussian_splatting and KHR_gaussian_splatting_compression_spz_2 extensions.`)),t};Object.defineProperties(nf.prototype,{featuresLength:{get:function(){return 0}},pointsLength:{get:function(){return this.gltfPrimitive.attributes[0].count}},trianglesLength:{get:function(){return 0}},geometryByteLength:{get:function(){return 0}},texturesByteLength:{get:function(){let e=this._tileset?.gaussianSplatPrimitive;if(!l(e))return 0;let t=e.gaussianSplatTexture,n=e.selectedTileLength;return!l(t)||n===0?0:t.sizeInBytes/n}},batchTableByteLength:{get:function(){return 0}},innerContents:{get:function(){}},ready:{get:function(){return this._ready}},transformed:{get:function(){return this._transformed}},tileset:{get:function(){return this._tileset}},tile:{get:function(){return this._tile}},url:{get:function(){return this._resource.getUrlComponent(!0)}},batchTable:{get:function(){}},metadata:{get:function(){return this._metadata},set:function(e){this._metadata=e}},group:{get:function(){return this._group},set:function(e){this._group=e}},positions:{get:function(){return this._positions}},rotations:{get:function(){return this._rotations}},scales:{get:function(){return this._scales}},sphericalHarmonicsCoefficientCount:{get:function(){return this._sphericalHarmonicsCoefficientCount}},sphericalHarmonicsDegree:{get:function(){return this._sphericalHarmonicsDegree}},packedSphericalHarmonicsData:{get:function(){return this._packedSphericalHarmonicsData}}});function Utt(e){return`${e.startsWith("KHR_gaussian_splatting:")?"KHR_gaussian_splatting:":"_"}SH_DEGREE_`}function ztt(e){switch(e.filter(n=>n.name.includes("SH_DEGREE_")).length){default:case 0:return{l:0,n:0};case 3:return{l:1,n:9};case 8:return{l:2,n:24};case 15:return{l:3,n:45}}}var mme=new ArrayBuffer(4),Gtt=new Float32Array(mme),Vtt=new Uint32Array(mme);function YK(e){Gtt[0]=e;let t=Vtt[0],n=t>>31&1,i=t>>23&255,o=t&8388607,r;if(i===255)r=n<<15|31744|(o?512:0);else if(i===0)r=n<<15;else{let a=i-127+15;a>=31?r=n<<15|31744:a<=0?r=n<<15:r=n<<15|a<<10|o>>>13}return r}function Htt(e){let t=Utt(e),n="_COEF_",i=t.length,o=e.indexOf(n,i),r=parseInt(e.slice(i,o),10),a=parseInt(e.slice(o+n.length),10);return{l:r,n:a}}function Wtt(e){let t=e.sphericalHarmonicsDegree,n=e.sphericalHarmonicsCoefficientCount,i=e.pointsLength*(n*(2/3)),o=new Uint32Array(i),r=e.gltfPrimitive.attributes.filter(u=>u.name.includes("SH_DEGREE_")),a=0,s=[0,9,24];switch(t){case 1:a=9;break;case 2:a=24;break;case 3:a=45;break}r.sort((u,f)=>u.name<f.name?-1:u.name>f.name?1:0);let c=a*(2/3);for(let u=0;u<r.length;u++){let{l:f,n:h}=Htt(r[u].name);for(let p=0;p<e.pointsLength;p++){let A=s[f-1]*2/3,m=p*c+A+h*2,_=p*3;o[m]=YK(r[u].typedArray[_])|YK(r[u].typedArray[_+1])<<16,o[m+1]=YK(r[u].typedArray[_+2])}}return o}nf.fromGltf=async function(e,t,n,i){let o=n,r=De.createIfNeeded(o),a={releaseGltfJson:!1,upAxis:so.Y,forwardAxis:so.Z};l(i.asset)?(a.gltfJson=i,a.baseResource=r,a.gltfResource=r):i instanceof Uint8Array?(a.typedArray=i,a.baseResource=r,a.gltfResource=r):a.gltfResource=De.createIfNeeded(i);let s=new td(a);try{await s.load()}catch(c){throw s.destroy(),new ue(`Failed to load glTF: ${c.message}`)}return new nf(s,e,t,n)};nf.prototype.update=function(e,t){let n=this._loader;if(!this._ready){if(t.afterRender.push(()=>!0),!l(n)){this._ready=!0;return}if(this._resourcesLoaded){this.gltfPrimitive=n.components.scene.nodes[0].primitives[0],this.worldTransform=n.components.scene.nodes[0].matrix,this._ready=!0,this._positions=Tt.getAttributeBySemantic(this.gltfPrimitive,at.POSITION).typedArray.slice(),this._rotations=Tt.getAttributeBySemantic(this.gltfPrimitive,at.ROTATION).typedArray.slice(),this._scales=Tt.getAttributeBySemantic(this.gltfPrimitive,at.SCALE).typedArray.slice();let{l:i,n:o}=ztt(this.gltfPrimitive.attributes);this._sphericalHarmonicsDegree=i,this._sphericalHarmonicsCoefficientCount=o,this._packedSphericalHarmonicsData=Wtt(this);return}this._resourcesLoaded=n.process(t)}};nf.prototype.hasProperty=function(e,t){return!1};nf.prototype.getFeature=function(e){};nf.prototype.applyDebugSett
Geometric error: ${e.geometricError}`,o++),t.debugShowRenderingStatistics&&(i+=`Commands: ${e.commandsLength}`,o++,e.content.pointsLength>0&&(i+=`Points: ${e.content.pointsLength}`,o++),e.content.trianglesLength>0&&(i+=`Triangles: ${e.content.trianglesLength}`,o++),i+=`Features: ${e.content.featuresLength}`,o++),t.debugShowMemoryUsage&&(i+=`Texture Memory: ${spe(e.content.texturesByteLength)}`,i+=`Geometry Memory: ${spe(e.content.geometryByteLength)}`,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+=`Urls:`;let a=e.content.innerContentUrls;for(let s=0;s<a.length;s++)i+=`- ${a[s]}`;o+=a.length}else i+=`Url: ${e._contentHeader.uri}`,o++;let r={text:i.substring(1),position:n,font:`${19-o}px sans-serif`,showBackground:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY};return t._tileDebugLabels.add(r)}function iot(e,t){let n=e._selectedTiles,i=n.length,o=e._emptyTiles,r=o.length;if(e._tileDebugLabels.removeAll(),e.debugPickedTileLabelOnly){if(l(e.debugPickedTile)){let a=l(e.debugPickPosition)?e.debugPickPosition:_X(e.debugPickedTile),s=yX(e.debugPickedTile,e,a);s.pixelOffset=new Q(15,-15)}}else{for(let a=0;a<i;++a){let s=n[a];yX(s,e,_X(s))}for(let a=0;a<r;++a){let s=o[a];(s.hasTilesetContent||s.hasImplicitContent)&&yX(s,e,_X(s))}}e._tileDebugLabels.update(t)}function oot(e,t,n){e._styleEngine.applyStyle(e),e._styleApplied=!0;let{commandList:i,context:o}=t,r=i.length,a=e._selectedTiles,s=e.isSkippingLevelOfDetail&&e._hasMixedContent&&o.stencilBuffer&&a.length>0;e._backfaceCommands.length=0,s&&(l(e._stencilClearCommand)||(e._stencilClearCommand=new ui({stencil:0,pass:Be.CESIUM_3D_TILE,renderState:Ve.fromCache({stencilMask:Yt.SKIP_LOD_MASK})})),i.push(e._stencilClearCommand));let{statistics:c,tileVisible:u}=e,f=n.isRender,h=i.length;for(let m=0;m<a.length;++m){let _=a[m];f&&u.raiseEvent(_),Zit(e,_,t),_.update(e,t,n),c.incrementSelectionCounts(_.content),++c.selected}let p=e._emptyTiles;for(let m=0;m<p.length;++m)p[m].update(e,t,n);let A=i.length-h;if(e._backfaceCommands.trim(),s){let m=e._backfaceCommands.values,_=m.length;i.length+=_;for(let y=A-1;y>=0;--y)i[h+_+y]=i[h+y];for(let y=0;y<_;++y)i[h+y]=m[y]}A=i.length-r,c.numberOfCommands=A,f&&(e.pointCloudShading.attenuation&&e.pointCloudShading.eyeDomeLighting&&A>0&&e._pointCloudEyeDomeLighting.update(t,r,e.pointCloudShading,e.boundingSphere),e.debugShowGeometricError||e.debugShowRenderingStatistics||e.debugShowMemoryUsage||e.debugShowUrl?(l(e._tileDebugLabels)||(e._tileDebugLabels=new NA),iot(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}var upe=[];function rot(e,t){let n=t,i=upe;for(i.push(t);i.length>0;){t=i.pop();let o=t.children;for(let r=0;r<o.length;++r)i.push(o[r]);t!==n&&(aot(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function fpe(e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function aot(e,t){e._cache.unloadTile(e,t,fpe),t.destroy()}ir.prototype.trimLoadedTiles=function(){this._cache.trim()};function sot(e,t){let n=e._statistics,i=e._statisticsLast,o=n.numberOfPendingRequests,r=n.numberOfTilesProcessing,a=i.numberOfPendingRequests,s=i.numberOfTilesProcessing;lp.clone(n,i);let c=o!==a||r!==s;c&&t.afterRender.push(function(){return e.loadProgress.raiseEvent(o,r),!0}),e._tilesLoaded=n.numberOfPendingRequests===0&&n.numberOfTilesProcessing===0&&n.numberOfAttemptedRequests===0,c&&e._tilesLoaded&&(t.afterRender.push(function(){return e.allTilesLoaded.raiseEvent(),!0}),e._initialTilesLoaded||(e._initialTilesLoaded=!0,t.afterRender.push(function(){return e.initialTilesLoaded.raiseEvent(),!0})))}function cot(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 lot(e,t){t.frameNumber===e._updatedModelMatrixFrame&&l(e._previousModelMatrix)||(e._updatedModelMatrixFrame=t.frameNumber,e._modelMatrixChanged=!P.equals(e.modelMatrix,e._previousModelMatrix),e._modelMatrixChanged&&(e._previousModelMatrix=P.clone(e.modelMatrix,e._previousModelMatrix)))}function uot(e,t,n,i){if(t.mode===oe.MORPHING||!l(e._root))return!1;let o=e._statistics;o.clear(),++e._updatedVisibilityFrame,cot(e),lot(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;let r=e.getTraversal(i).selectTiles(e,t);if(i.requestTiles&&Yit(e),oot(e,t,i),lp.clone(o,n),i.isRen
in vec4 v_outlineColor;in float v_innerPercent;in float v_pixelDistance;in vec4 v_pickColor;in float v_splitDirection;
void main(){ if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard; if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
// 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 OU=`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 vec4 distanceDisplayConditionAndDisableDepthAndSplitDirection; // near, far, disableDepthTestDistance, splitDirection
out vec4 v_color;out vec4 v_outlineColor;out float v_innerPercent;out float v_pixelDistance;out vec4 v_pickColor;out float v_splitDirection;
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 = czm_decodeRGB8(compressedAttribute0.x); vec4 outlineColor = czm_decodeRGB8(compressedAttribute0.y); vec4 pickColor = czm_decodeRGB8(compressedAttribute0.z); vec4 alphaPacked = czm_decodeRGB8(compressedAttribute0.w);
color.a = alphaPacked.x; outlineColor.a = alphaPacked.y; pickColor.a = alphaPacked.z;
///////////////////////////////////////////////////////////////////////////
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 = distanceDisplayConditionAndDisableDepthAndSplitDirection.x; float farSq = distanceDisplayConditionAndDisableDepthAndSplitDirection.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 = distanceDisplayConditionAndDisableDepthAndSplitDirection.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; v_splitDirection = distanceDisplayConditionAndDisableDepthAndSplitDirection.w;}`;var Brt=Ps.SHOW_INDEX,FX=Ps.POSITION_INDEX,lAe=Ps.COLOR_INDEX,Drt=Ps.OUTLINE_COLOR_INDEX,vrt=Ps.OUTLINE_WIDTH_INDEX,Prt=Ps.PIXEL_SIZE_INDEX,uAe=Ps.SCALE_BY_DISTANCE_INDEX,fAe=Ps.TRANSLUCENCY_BY_DISTANCE_INDEX,dAe=Ps.DISTANCE_DISPLAY_CONDITION_INDEX,Rrt=Ps.DISABLE_DEPTH_DISTANCE_INDEX,Mrt=Ps.SPLIT_DIRECTION_INDEX,QX=Ps.NUMBER_OF_PROPERTIES,Yc={positionHighAndSize:0,positionLowAndOutline:1,compressedAttribute0:2,compressedAttribute1:3,scaleByDistance:4,distanceDisplayConditionAndDisableDepthAndSplitDirection:5};function bd(e){e=e??V.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(QX),this._maxPixelSize=1,this._baseVolume=new le,this._baseVolumeWC=new le,this._baseVolume2D=new le,this._boundingVolume=new le,this._boundingVolumeDirty=!1,this._colorCommands=[],this.show=e.show??!0,this.modelMatrix=P.clone(e.modelMatrix??P.IDENTITY),this._modelMatrix=P.clone(P.IDENTITY),this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this.blendOption=e.blendOption??nr.OPAQUE_AND_TRANSLUCENT,this._blendOption=void 0,this._mode=oe.SCENE3D,this._maxTotalPointSize=1,this._buffersUsage=[Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW,Re.STATIC_DRAW];let t=this;this._uniforms={u_maxTotalPointSize:function(){return t._maxTotalPointSize}}}Object.defineProperties(bd.prototype,{length:{get:function(){return kX(this),this._pointPrimitives.length}}});function hAe(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}bd.prototype.add=function(e){let t=new Ps(e,this);return t._index=this._pointPrimitives.length,this._pointPrimitives.push(t),this._createVertexArray=!0,t};bd.prototype.remove=function(e){return this.contains(e)?(this._pointPrimitives[e._index]=null,this._pointPrimitivesRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};bd.prototype.removeAll=function(){hAe(this._pointPrimitives),this._pointPrimitives=[],this._pointPrimitivesToUpdate=[],this._pointPrimitivesToUpdateIndex=0,this._pointPrimitivesRemoved=!1,this._createVertexArray=!0};function kX(e){if(e._pointPrimitivesRemoved){e._pointPrimitivesRemoved=!1;let t=[],n=e._pointPrimitives,i=n.length;for(let o=0,r=0;o<i;++o){let a=n[o];a&&(a._index=r++,t.push(a))}e._pointPrimitives=t}}bd.prototype._updatePointPrimitive=function(e,t){e._dirty||(this._pointPrimitivesToUpdate[this._pointPrimitivesToUpdateIndex++]=e),++this._propertiesChanged[t]};bd.prototype.contains=function(e){return l(e)&&e._pointPrimitiveCollection===this};bd.prototype.get=function(e){return kX(this),this._pointPrimitives[e]};bd.prototype.computeNewBuffersUsage=function(){let e=this._buffersUsage,t=!1,n=this._propertiesChanged;for(let i=0;i<QX;++i){let o=n[i]===0?Re.STATIC_DRAW:Re.STREAM_DRAW;t=t||e[i]!==o,e[i]=o}return t};function Nrt(e,t,n){return new Zg(e,[{index:Yc.positionHighAndSize,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[FX]},{index:Yc.positionLowAndShow,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[FX]},{index:Yc.compressedAttribute0,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[lAe]},{index:Yc.compressedAttribute1,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[fAe]},{index:Yc.scaleByDistance,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[uAe]},{index:Yc.distanceDisplayConditionAndDisableDepthAndSplitDirection,componentsPerAttribute:4,componentDatatype:j.FLOAT,usage:n[dAe]}],t)}var LX=new xn,FU=new U;function mAe(e,t,n,i){let o=i._index,r=i._getActualPosition();e._mode===oe.SCENE3
${t.message}`),e.previousError=tr.reportError(e.previousError,n,l(n)?n._errorEvent:void 0,i),e.previousError.retry)return YZ(e,n);throw new ue(i)}async function fgt(e,t,n){await DIe(e,t,n);let i=e.overallAvailability.length;if(i>0){let o=e.availability=new Lp(e.tilingScheme,e.overallMaxZoom);for(let r=0;r<i;++r){let a=e.overallAvailability[r];for(let s=0;s<a.length;++s){let c=a[s];o.addAvailableTileRange(r,c[0],c[1],c[2],c[3])}}}if(e.attribution.length>0){let o=new Et(e.attribution);e.tileCredits.push(o)}return!0}async function YZ(e,t){try{let n=await e.layerJsonResource.fetchJson();return fgt(e,n,t)}catch(n){return l(n)&&n.statusCode===404?(await DIe(e,{tilejson:"2.1.0",format:"heightmap-1.0",version:"1.0.0",scheme:"tms",tiles:["{z}/{x}/{y}.terrain?v={version}"]},t),!0):ugt(e,n,t)}}function $h(e){e=e??V.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=e.requestVertexNormals??!1,this._requestWaterMask=e.requestWaterMask??!1,this._requestMetadata=e.requestMetadata??!0,this._errorEvent=new _e;let t=e.credit;typeof t=="string"&&(t=new Et(t)),this._credit=t,this._availability=void 0,this._tilingScheme=void 0,this._levelZeroMaximumGeometricError=void 0,this._layers=void 0,this._tileCredits=void 0}var WZ={OCT_VERTEX_NORMALS:1,WATER_MASK:2,METADATA:4};function wIe(e){return!l(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 dgt(e,t,n,i,o){let r=new Uint16Array(t,0,e._heightmapWidth*e._heightmapWidth);return new Xc({buffer:r,childTileMask:new Uint8Array(t,r.byteLength,1)[0],waterMask:new Uint8Array(t,r.byteLength+1,t.byteLength-r.byteLength-1),width:e._heightmapWidth,height:e._heightmapWidth,structure:e._heightmapStructure,credits:e._tileCredits})}function hgt(e,t,n,i,o,r){let a=r.littleEndianExtensionSize,s=0,c=3,u=c+1,f=Float64Array.BYTES_PER_ELEMENT*c,h=Float64Array.BYTES_PER_ELEMENT*u,A=Uint16Array.BYTES_PER_ELEMENT*3,m=3,_=Uint16Array.BYTES_PER_ELEMENT,y=_*m,C=new DataView(t),E=new d(C.getFloat64(s,!0),C.getFloat64(s+8,!0),C.getFloat64(s+16,!0));s+=f;let I=C.getFloat32(s,!0);s+=Float32Array.BYTES_PER_ELEMENT;let x=C.getFloat32(s,!0);s+=Float32Array.BYTES_PER_ELEMENT;let S=new le(new d(C.getFloat64(s,!0),C.getFloat64(s+8,!0),C.getFloat64(s+16,!0)),C.getFloat64(s+f,!0));s+=h;let w=new d(C.getFloat64(s,!0),C.getFloat64(s+8,!0),C.getFloat64(s+16,!0));s+=f;let v=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let R=new Uint16Array(t,s,v*3);s+=v*A,v>64*1024&&(_=Uint32Array.BYTES_PER_ELEMENT,y=_*m);let N=R.subarray(0,v),L=R.subarray(v,2*v),g=R.subarray(v*2,3*v);tn.zigZagDeltaDecode(N,L,g),s%_!==0&&(s+=_-s%_);let b=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let T=Ue.createTypedArrayFromArrayBuffer(v,t,s,b*m);s+=b*y;let B=0,M=T.length;for(let re=0;re<M;++re){let ye=T[re];T[re]=B-ye,ye===0&&++B}let O=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let G=Ue.createTypedArrayFromArrayBuffer(v,t,s,O);s+=O*_;let k=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let z=Ue.createTypedArrayFromArrayBuffer(v,t,s,k);s+=k*_;let F=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let H=Ue.createTypedArrayFromArrayBuffer(v,t,s,F);s+=F*_;let Y=C.getUint32(s,!0);s+=Uint32Array.BYTES_PER_ELEMENT;let $=Ue.createTypedArrayFromArrayBuffer(v,t,s,Y);s+=Y*_;let W,K;for(;s<C.byteLength;){let re=C.getUint8(s,!0);s+=Uint8Array.BYTES_PER_ELEMENT;let ye=C.getUint32(s,a);if(s+=Uint32Array.BYTES_PER_ELEMENT,re===WZ.OCT_VERTEX_NORMALS&&e._requestVertexNormals)W=new Uint8Array(t,s,v*2);else if(re===WZ.WATER_MASK&&e._requestWaterMask)K=new Uint8Array(t,s,ye);else if(re===WZ.METADATA&&e._requestMetadata){let Ce=C.getUint32(s,!0);if(Ce>0){let Ne=Pr(new Uint8Array(t),s+Uint32Array.BYTES_PER_ELEMENT,Ce).available;if(l(Ne))for(let Le=0;Le<Ne.length;++Le){let Oe=n+Le+1,nt=Ne[Le],Fe=e._tilingScheme.getNumberOfYTilesAtLevewmi\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 Cf(e){this.imageryPresent=!0,this.protoImagery=void 0,this.terrainPresent=!0,this.negativeAltitudeExponentBias=32,this.negativeAltitudeThreshold=D.EPSILON12,this.providers={},this.key=void 0,this._resource=void 0,this._quadPacketVersion=1,this._tileInfo={},this._subtreePromises={}}Object.defineProperties(Cf.prototype,{url:{get:function(){return this._resource.url}},proxy:{get:function(){return this._resource.proxy}},resource:{get:function(){return this._resource}}});Cf.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 Cf;i._resource=n;try{await Kgt(i),await i.getQuadTreePacket("",i._quadPacketVersion)}catch(o){let r=`An error occurred while accessing ${WIe(i,"",1).url}: ${o}`;throw new ue(r)}return i};Cf.tileXYToQuadKey=function(e,t,n){let i="";for(let o=n;o>=0;--o){let r=1<<o,a=0;Fl(t,r)?Fl(e,r)&&(a|=1):(a|=2,Fl(e,r)||(a|=1)),i+=a}return i};Cf.quadKeyToTileXY=function(e){let t=0,n=0,i=e.length-1;for(let o=i;o>=0;--o){let r=1<<o,a=+e[i-o];Fl(a,2)?Fl(a,1)||(t|=r):(n|=r,Fl(a,1)&&(t|=r))}return{x:t,y:n,level:i}};Cf.prototype.isValid=function(e){let t=this.getTileInformationFromQuadKey(e);if(l(t))return t!==null;let n=!0,i=e,o;for(;i.length>1;)if(o=i.substring(i.length-1),i=i.substring(0,i.length-1),t=this.getTileInformationFromQuadKey(i),l(t)){!t.hasSubtree()&&!t.hasChild(parseInt(o))&&(n=!1);break}else if(t===null){n=!1;break}return n};var HIe=new Zn("decodeGoogleEarthEnterprisePacket");Cf.prototype.getQuadTreePacket=function(e,t,n){t=t??1,e=e??"";let o=WIe(this,e,t,n).fetchArrayBuffer();if(!l(o))return;let r=this._tileInfo,a=this.key;return o.then(function(s){return HIe.scheduleTask({buffer:s,quadKey:e,type:"Metadata",key:a},[s]).then(function(u){let f,h=-1;if(e!==""){h=e.length+1;let m=u[e];f=r[e],f._bits|=m._bits,delete u[e]}let p=Object.keys(u);p.sort(function(m,_){return m.length-_.length});let A=p.length;for(let m=0;m<A;++m){let _=p[m];if(u[_]!==null){let C=OV.clone(u[_]),E=_.length;if(E===h)C.setParent(f);else if(E>1){let I=r[_.substring(0,_.length-1)];C.setParent(I)}r[_]=C}else r[_]=null}})})};Cf.prototype.populateSubtree=function(e,t,n,i){let o=Cf.tileXYToQuadKey(e,t,n);return n$(this,o,i)};function n$(e,t,n){let i=e._tileInfo,o=t,r=i[o];if(l(r)&&(!r.hasSubtree()||r.hasChildren()))return r;for(;r===void 0&&o.length>1;)o=o.substring(0,o.length-1),r=i[o];let a,s=e._subtreePromises,c=s[o];if(l(c))return c.then(function(){return a=new Br({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),n$(e,t,a)});if(!l(r)||!r.hasSubtree())return Promise.reject(new ue(`Couldn't load metadata for tile ${t}`));if(c=e.getQuadTreePacket(o,r.cnodeVersion,n),!!l(c))return s[o]=c,c.then(function(){return a=new Br({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),n$(e,t,a)}).finally(function(){delete s[o]})}Cf.prototype.getTileInformation=function(e,t,n){let i=Cf.tileXYToQuadKey(e,t,n);return this._tileInfo[i]};Cf.prototype.getTileInformationFromQuadKey=function(e){return this._tileInfo[e]};function WIe(e,t,n,i){return e._resource.getDerivedResource({url:`flatfile?q2-0${t}-q.${n.toString()}`,request:i})}var e$,t$;function Kgt(e){let t=e._resource.getDerivedResource({url:"dbRoot.v5",queryParameters:{output:"proto"}});if(!l(t$)){let n=Zt("ThirdParty/google-earth-dbroot-parser.js"),i=window.cesiumGoogleEarthDbRootParser;t$=BI(n).then(function(){e$=window.cesiumGoogleEarthDbRootParser(jgt),l(i)?window.cesiumGoogleEarthDbRootParser=i:delete window.cesiumGoogleEarthDbRootParser})}return t$.then(function(){return t.fetchArrayBuffer()}).then(function(n){let i=e$.EncryptedDbRootProto.decode(new Uint8Array(n)),o=i.encryptionData,r=o.byteOffset,a=r+o.byteLength,s=e.key=o.buffer.slice(r,a);o=i.dbrootData,r=o.byteOffset,a=r+o.byteLength;let c=o.buffer.slice(r,a);return HIe.scheduleTask({buffer:c,type:"DbRlayout (location = 0) out vec4 out_FragData_0;layout (location = 1) out vec4 out_FragData_1;#elselayout (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 n8=`in vec2 v_textureCoordinates;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 alphaRoughness, vec3 N){ float alphaRoughnessSquared = alphaRoughness * alphaRoughness; float phi = 2.0 * M_PI * xi.x; float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 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;}
/** * Estimate the geometric self-shadowing of the microfacets in a surface, * using the Smith Joint GGX visibility function. * Note: Vis = G / (4 * NdotL * NdotV) * see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3 * see Real-Time Rendering. Page 331 to 336. * see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
* * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness. * @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source. * @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera. */float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV){ float alphaRoughnessSq = alphaRoughness * alphaRoughness;
float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq); float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
float GGX = GGXV + GGXL; // 2.0 if NdotL = NdotV = 1.0
if (GGX > 0.0) { return 0.5 / GGX; // 1/4 if NdotL = NdotV = 1.0
} return 0.0;}
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; float alphaRoughness = roughness * roughness; for (int i = 0; i < NumSamples; i++) { vec2 xi = hammersley2D(i, NumSamples); vec3 H = importanceSampleGGX(xi, alphaRoughness, 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 = smithVisibilityGGX(alphaRoughness, NdotL, NdotV); float G_Vis = 4.0 * G * VdotH * NdotL / NdotH; 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);}`;var i8=`uniform sampler2D u_noiseTexture;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 o8=`#ifdef INSTANCEDin vec2 direction;#endifin 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 r8=`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 a8=`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;}`;var s8=`uniform sampler2D u_opaqueDepthTexture;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 c8=`/** * 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; }}`;var l8=`uniform mat3 u_cubeMapPanoramaTransform;
in vec3 position;out vec3 v_texCoord;
void main(){ vec3 p = czm_viewRotation * (u_cubeMapPanoramaTransform * (czm_entireFrustum.y * position)); gl_Position = czm_projection * vec4(p, 1.0); v_texCoord = position.xyz;}`;var u8=`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 f8=`in vec4 position;
out vec4 positionEC;
void main(){ positionEC = czm_modelView * position; gl_Position = czm_projection * positionEC;
czm_vertexLogDepth();}`;var jP=`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 coordinates
vec2 st = czm_ellipsoidTextureCoordinates(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 YP=`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); vec4 pEC = czm_modelView * p; v_positionEC = pEC.xyz; // position in eye coordinates
gl_Position = czm_projection * pEC; // 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();}`;/**
* @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 d8=`/** * @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 source (archived): https://archive.org/details/nvidiagame-works-graphics-samples-master
// Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
// Shader link in fork: https://github.com/lyntel/GraphicsSamples/blob/3d30817ebeeade64fe6a4fc3aa1fe4265c29b6fd/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);}`;var h8=`uniform vec4 u_initialColor;
#if TEXTURE_UNITS > 0uniform sampler2D u_dayTextures[TEXTURE_UNITS];uniform vec4 u_dayTextureTranslationAndScale[TEXTURE_UNITS];uniform bool u_dayTextureUseWebMercatorT[TEXTURE_UNITS];
#ifdef APPLY_ALPHAuniform float u_dayTextureAlpha[TEXTURE_UNITS];#endif
#ifdef APPLY_DAY_NIGHT_ALPHAuniform float u_dayTextureNightAlpha[TEXTURE_UNITS];uniform float u_dayTextureDayAlpha[TEXTURE_UNITS];#endif
#ifdef APPLY_SPLITuniform float u_dayTextureSplit[TEXTURE_UNITS];#endif
#ifdef APPLY_BRIGHTNESSuniform float u_dayTextureBrightness[TEXTURE_UNITS];#endif
#ifdef APPLY_CONTRASTuniform float u_dayTextureContrast[TEXTURE_UNITS];#endif
#ifdef APPLY_HUEuniform float u_dayTextureHue[TEXTURE_UNITS];#endif
#ifdef APPLY_SATURATIONuniform float u_dayTextureSaturation[TEXTURE_UNITS];#endif
#ifdef APPLY_GAMMAuniform float u_dayTextureOneOverGamma[TEXTURE_UNITS];#endif
//\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
#ifdef APPLY_INVERT_COLOR_MARS3Duniform bool u_mars3dTextureInvertColor[TEXTURE_UNITS];#endif
#ifdef APPLY_FILTER_COLOR_MARS3Duniform vec3 u_mars3dTextureFilterColor[TEXTURE_UNITS];#endif//\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
#ifdef APPLY_IMAGERY_CUTOUTuniform vec4 u_dayTextureCutoutRectangles[TEXTURE_UNITS];#endif
#ifdef APPLY_COLOR_TO_ALPHAuniform vec4 u_colorsToAlpha[TEXTURE_UNITS];#endif
uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];#endif
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))uniform sampler2D u_waterMask;uniform vec4 u_waterMaskTranslationAndScale;uniform float u_zoomedOutOceanSpecularIntensity;#endif
#ifdef SHOW_OCEAN_WAVESuniform sampler2D u_oceanNormalMap;#endif
#if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)uniform vec2 u_lightingFadeDistance;#endif
#ifdef TILE_LIMIT_RECTANGLEuniform vec4 u_cartographicLimitRectangle;#endif
#ifdef GROUND_ATMOSPHEREuniform vec2 u_nightFadeDistance;#endif
#ifdef ENABLE_CLIPPING_PLANESuniform highp sampler2D u_clippingPlanes;uniform mat4 u_clippingPlanesMatrix;uniform vec4 u_clippingPlanesEdgeStyle;#endif
#ifdef ENABLE_CLIPPING_POLYGONSuniform highp sampler2D u_clippingDistance;in vec2 v_clippingPosition;flat in int v_regionIndex;#endif
#if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))uniform float u_minimumBrightness;#endif
// Based on colorCorrect
// The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift
// are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider
// - The tileProvider.hue/saturation/brightnessShift are just passed through
// from the Globe hue/saturation/brightness, like atmosphereBrightnessShift
// - The applyFog depends on enableFog, and some tile distance from the viewer
// - The showGroundAtmosphere is a flag that is passed through from the Globe,
// and is true by default when the ellipsoid is WGS84
#ifdef COLOR_CORRECTuniform vec3 u_hsbShift; // Hue, saturation, brightness
#endif
// Based on highlightFillTile
// This is set for terrain tiles when they are "fill" tiles, and
// the terrainProvider.fillHighlightColor was set to a value with
// nonzero alpha
#ifdef HIGHLIGHT_FILL_TILEuniform vec4 u_fillHighlightColor;#endif
// Based on translucent
// This is set depending on the GlobeTranslucencyState
#ifdef TRANSLUCENTuniform vec4 u_frontFaceAlphaByDistance;uniform vec4 u_backFaceAlphaByDistance;uniform vec4 u_translucencyRectangle;#endif
// Based on showUndergroundColor
// This is set when GlobeSurfaceTileProvider.isUndergroundVisible
// returns true, AND the tileProvider.undergroundColor had a value with
// nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance
// was in the right range
#ifdef UNDERGROUND_COLORuniform vec4 u_undergroundColor;uniform vec4 u_undergroundColorAlphaByDistance;#endif
// Based on enableLighting && hasVertexNormals
// The enableLighting flag is passed in directly from the Globe.
// The hasVertexNormals flag is from the tileProvider
#ifdef ENABLE_VERTEX_LIGHTINGuniform 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_MATERIALin float v_height;in float v_slope;in float v_aspect;#endif
//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
#ifdef APPLY_MARS3D_FLOODuniform bool u_mars_flood_enabled;uniform bool u_mars_flood_only;uniform vec4 u_mars_flood_rectangle;uniform highp sampler2D u_mars_flood_texture;#endif//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
#ifdef APPLY_MARS3D_CLIPuniform bool u_mars_clip_enabled;uniform bool u_mars_clip_only;uniform vec4 u_mars_clip_rectangle;uniform highp sampler2D u_mars_clip_texture;#endif//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u7F16\u8F91\u901A\u7528\u7684\u8303\u56F4\u5224\u65AD\u65B9\u6CD5\uFF08\u542B \u5730\u5F62\u62AC\u5347/\u5730\u5F62\u538B\u5E73/\u5730\u5F62\u5F00\u6316/\u5730\u5F62\u533A\u57DF\u6750\u8D28\uFF09
uniform highp float u_mars_inverseTileWidth;uniform highp vec2 u_mars_cartographicTileRectangle;
bool inAreaMars3DRange(vec4 rectangle, sampler2D rangeTexture) { float lo = v_textureCoordinates.x / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.x; float la = v_textureCoordinates.y / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.y;
float newX = (lo - rectangle.x) / rectangle.z; float newY = (la - rectangle.y) / rectangle.w;
if(newX >= 0.0 && newX <= 1.0 && newY >= 0.0 && newY <= 1.0){ vec4 point = texture(rangeTexture, vec2(newX, newY)); return point.r > 0.0; }
return false;}//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u7F16\u8F91\u901A\u7528\u7684\u8303\u56F4\u5224\u65AD\u65B9\u6CD5\uFF08\u542B \u5730\u5F62\u62AC\u5347/\u5730\u5F62\u538B\u5E73/\u5730\u5F62\u5F00\u6316/\u5730\u5F62\u533A\u57DF\u6750\u8D28\uFF09
#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
// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
#ifdef APPLY_MARS3D_UPLIFTuniform vec4 u_mars_uplift_rectangle;uniform highp sampler2D u_mars_uplift_texture;uniform bool u_mars_uplift_enabled;uniform bool u_mars_uplift_hideInsideOrOutside;#endif// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
#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 TRANSLUCENTbool 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, //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
bool textureInvertColor, vec3 texturefilterColor, //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
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 = czm_maximumComponent(colorDiff); 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
//\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
#ifdef APPLY_INVERT_COLOR_MARS3D if(textureInvertColor) { color = vec3(1.0 - color.r, 1.0 - color.g, 1.0 - color.b); }#endif
#ifdef APPLY_FILTER_COLOR_MARS3D if(texturefilterColor.x != 1.0 || texturefilterColor.y != 1.0 || texturefilterColor.z != 1.0) { color = vec3(color.r * texturefilterColor.x, color.g * texturefilterColor.y, color.b * texturefilterColor.z); }#endif//\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
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; if (czm_orthographicIn3D == 1.0) { direction = vec3(0.0, 0.0, -1.0); } else { 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(){
//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
#ifdef APPLY_MARS3D_CLIP if(u_mars_clip_enabled) { if(u_mars_clip_only) { if(!inAreaMars3DRange(u_mars_clip_rectangle, u_mars_clip_texture)) { discard; } } else { if(inAreaMars3DRange(u_mars_clip_rectangle, u_mars_clip_texture)) { discard; } } }#endif//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
#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 coordinates
#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
#if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL)) 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;
#ifdef SHOW_REFLECTIVE_OCEAN if (mask > 0.0) { mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC); vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(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#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; #ifdef HAS_WATER_MASK materialInput.waterMask = mask; #endif
czm_material material = czm_getMaterial(materialInput);
//\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
bool hasAlphaBlend = true; #ifdef APPLY_MARS3D_FLOOD hasAlphaBlend = !u_mars_flood_enabled || (u_mars_flood_enabled && inAreaMars3DRange(u_mars_flood_rectangle, u_mars_flood_texture)); if(u_mars_flood_enabled) { if(u_mars_flood_only) { if(! inAreaMars3DRange(u_mars_flood_rectangle, u_mars_flood_texture)) { discard; } } } #endif //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
if(hasAlphaBlend) { 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 ENABLE_CLIPPING_POLYGONS vec2 clippingPosition = v_clippingPosition; int regionIndex = v_regionIndex; clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);#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
#ifdef COLOR_CORRECT const bool ignoreBlackPixels = true; rayleighColor = czm_applyHSBShift(rayleighColor, u_hsbShift, ignoreBlackPixels); mieColor = czm_applyHSBShift(mieColor, u_hsbShift, ignoreBlackPixels); #endif
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_pbrNeutralTonemapping(fogColor.rgb); fogColor.rgb = czm_inverseGamma(fogColor.rgb); #endif
finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor.rgb, czm_fogVisualDensityScalar), finalColor.a);
#else // Apply ground atmosphere. This happens when the camera is far away from the earth.
// 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
// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
#ifdef APPLY_MARS3D_UPLIFT if(u_mars_uplift_enabled) { bool isInSlopeRampRectangle = inAreaMars3DRange(u_mars_uplift_rectangle, u_mars_uplift_texture); if(isInSlopeRampRectangle == u_mars_uplift_hideInsideOrOutside) { discard; } }#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 m8=`#ifdef QUANTIZATION_BITS12in vec4 compressed0;in float compressed1;#elsein vec4 position3DAndHeight;in vec4 textureCoordAndEncodedNormals;#endif
#ifdef GEODETIC_SURFACE_NORMALSin vec3 geodeticSurfaceNormal;#endif
#ifdef EXAGGERATIONuniform vec2 u_verticalExaggerationAndRelativeHeight;#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_MATERIALout 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
#ifdef ENABLE_CLIPPING_POLYGONSuniform highp sampler2D u_clippingExtents;out vec2 v_clippingPosition;flat out int v_regionIndex;#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); vec4 morphPositionEC = czm_modelView * morphPosition; return czm_projection * morphPositionEC;}
#ifdef QUANTIZATION_BITS12uniform vec2 u_minMaxHeight;uniform mat4 u_scaleAndBias;#endif
// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
#ifdef APPLY_MARS3D_FLATuniform bool u_mars_flat_enabled;uniform vec4 u_mars_flat_rectangle;uniform highp sampler2D u_mars_flat_texture;
uniform highp float u_mars_inverseTileWidth;uniform highp vec2 u_mars_cartographicTileRectangle;
vec4 getAreaMars3DRange(vec4 rectangle, sampler2D rangeTexture, vec2 textureCoordinates) { float lo = textureCoordinates.x / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.x; float la = textureCoordinates.y / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.y;
float newX = (lo - rectangle.x) / rectangle.z; float newY = (la - rectangle.y) / rectangle.w;
vec4 point; if(newX >= 0.0 && newX <= 1.0 && newY >= 0.0 && newY <= 1.0){ vec4 point = texture(rangeTexture, vec2(newX, newY)); return point; }else{ return vec4(0.0); }}#endif// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
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) || defined(APPLY_MATERIAL) 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) || defined(APPLY_MATERIAL) 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_verticalExaggerationAndRelativeHeight.x; float relativeHeight = u_verticalExaggerationAndRelativeHeight.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
// \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
#ifdef APPLY_MARS3D_FLAT if(u_mars_flat_enabled) { vec4 isInside = getAreaMars3DRange(u_mars_flat_rectangle,u_mars_flat_texture,textureCoordinates); if(isInside.r>0.0 || isInside.g>0.0 || isInside.b>0.0 || isInside.a>0.0){ float newHeight = czm_unpackFloat(isInside); if(newHeight>-9999.0 && newHeight<9999.0){ vec3 offset = (newHeight - height) * ellipsoidNormal; position += offset; position3DWC += offset; height = newHeight; // vec3 newPosition = (position3DWC + offset) - u_center3D;
} } }#endif // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
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
#ifdef ENABLE_CLIPPING_POLYGONS vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC); sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi); vec2 minDistance = vec2(czm_infinity); v_clippingPosition = vec2(czm_infinity); v_regionIndex = -1;
for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) { vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex); vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0)); vec2 distance = abs(rectUv - clamped) * extents.wz;
float threshold = 0.01; if (minDistance.x > distance.x || minDistance.y > distance.y) { minDistance = distance; v_clippingPosition = rectUv; if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) { v_regionIndex = regionIndex; } } }#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 qP=`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 KP=`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);}
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 p8=`in vec3 v_outerPositionWC;
uniform vec3 u_hsbShift;
#ifndef PER_FRAGMENT_ATMOSPHEREin vec3 v_mieColor;in vec3 v_rayleighColor;in float v_opacity;in float v_translucent;#endif
void main (void){ float lightEnum = u_radiiAndDynamicAtmosphereColor.z; vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_outerPositionWC, lightEnum);
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_pbrNeutralTonemapping(color.rgb); color.rgb = czm_inverseGamma(color.rgb); #endif
#ifdef COLOR_CORRECT const bool ignoreBlackPixels = true; color.rgb = czm_applyHSBShift(color.rgb, u_hsbShift, ignoreBlackPixels); #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 A8=`in vec4 position;
out vec3 v_outerPositionWC;
#ifndef PER_FRAGMENT_ATMOSPHEREout vec3 v_mieColor;out vec3 v_rayleighColor;out float v_opacity;out float v_translucent;#endif
void main(void){ vec4 positionWC = czm_model * position; float lightEnum = u_radiiAndDynamicAtmosphereColor.z; vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC.xyz, lightEnum);
#ifndef PER_FRAGMENT_ATMOSPHERE computeAtmosphereScattering( positionWC.xyz, lightDirection, v_rayleighColor, v_mieColor, v_opacity, v_translucent ); #endif
v_outerPositionWC = positionWC.xyz; vec4 positionEC = czm_modelView * position; gl_Position = czm_projection * positionEC;}`;var g8=`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 _8=`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;}`;var y8=`uniform sampler2D u_texture;
in vec2 v_textureCoordinates;
void main(){ vec4 color = texture(u_texture, v_textureCoordinates); out_FragColor = czm_gammaCorrect(color);}`;var C8=`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 E8=`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;}`;var I8=`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);}`;async function x$(e,t){let n=t.terrainProvider,i=t.mapProjection,o=i.ellipsoid,r,a=t.camera.getRectangleCameraCoordinates(e);if(t.mode===oe.SCENE3D?r=o.cartesianToCartographic(a):r=i.unproject(a),!l(n))return r;let s=n.availability;if(!l(s)||t.mode===oe.SCENE2D)return r;let c=[ce.center(e),ce.southeast(e),ce.southwest(e),ce.northeast(e),ce.northwest(e)],u=await x$._sampleTerrainMostDetailed(n,c),f=!1,h=u.reduce(function(A,m){return l(m.height)?(f=!0,Math.max(m.height,A)):A},-Number.MAX_VALUE),p=r;return f&&(p.height+=h),p}x$._sampleTerrainMostDetailed=IS;var TS=x$;var uyt=new Q;function fyt(e,t){let n=e.unionClippingRegions,i=e.length,o=Ca.useFloatTexture(t),r=Ca.getTextureResolution(e,t,uyt),a=r.x,s=r.y,c=o?myt(a,s):pyt(a,s);return c+=``,c+=n?dyt(i):hyt(i),c}function dyt(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; // HLSL compiler bug if we discard here: https://bugs.chromium.org/p/angleproject/issues/detail?id=1945#c6
break; } } if (breakAndDiscard) { discard; } return clipAmount;}`}function hyt(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 myt(e,t){let n=1/e,i=1/t,o=`${n}`;o.indexOf(".")===-1&&(o+=".0");let r=`${i}`;return r.indexOf(".")===-1&&(r+=".0"),`vec4 getClippingPlane(highp sampler2D packedClippingPlanes, int clippingPlaneNumber, mat4 transform){ int pixY = clippingPlaneNumber / ${e}; int pixX = clippingPlaneNumber - (pixY * ${e}); // Sample from center of pixel
float u = (float(pixX) + 0.5) * ${o}; float v = (float(pixY) + 0.5) * ${r}; vec4 plane = texture(packedClippingPlanes, vec2(u, v)); return czm_transformPlane(plane, transform);}`}function pyt(e,t){let n=1/e,i=1/t,o=`${n}`;o.indexOf(".")===-1&&(o+=".0");let r=`${i}`;return r.indexOf(".")===-1&&(r+=".0"),`vec4 getClippingPlane(highp sampler2D packedClippingPlanes, int clippingPlaneNumber, mat4 transform){ int clippingPlaneStartIndex = clippingPlaneNumber * 2; int pixY = clippingPlaneStartIndex / ${e}; int pixX = clippingPlaneStartIndex - (pixY * ${e}); // Sample from center of pixel
float u = (float(pixX) + 0.5) * ${o}; float v = (float(pixY) + 0.5) * ${r}; vec4 oct32 = texture(packedClippingPlanes, vec2(u, v)) * 255.0; vec2 oct = vec2(oct32.x * 256.0 + oct32.y, oct32.z * 256.0 + oct32.w); vec4 plane; plane.xyz = czm_octDecode(oct, 65535.0); plane.w = czm_unpackFloat(texture(packedClippingPlanes, vec2(u + ${o}, v))); return czm_transformPlane(plane, transform);}`}var SS=fyt;function Ayt(e,t,n,i,o,r){this.numberOfDayTextures=e,this.flags=t,this.material=n,this.shaderProgram=i,this.clippingShaderState=o,this.clippingPolygonShaderState=r}function T$(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function gyt(e){let t="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPosition3DMode(position, height, textureCoordinates); }",n="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPositionColumbusViewMode(position, height, textureCoordinates); }",i="vec4 getPosition(vec3 position, float height, vec2 textureCoordinates) { return getPositionMorphingMode(position, height, textureCoordinates); }",o;switch(e){case oe.SCENE3D:o=t;break;case oe.SCENE2D:case oe.COLUMBUS_VIEW:o=n;break;case oe.MORPHING:o=i;break}return o}function _yt(e){return e.webgl2?`void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) { czm_clipPolygons(clippingDistance, regionsLength, clippingPosition, regionIndex); }`:`void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) { }`}function yyt(e){return e.webgl2?`vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) { return czm_unpackClippingExtents(extentsTexture, index); }`:`vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) { return vec4(); }`}function Cyt(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}T$.prototype.getShaderProgram=function(e){let t=e.frameState,n=e.surfaceTile,i=e.numberOfDayTextures,o=e.applyBrightness,r=e.applyContrast,a=e.applyHue,s=e.applySaturation,c=e.applyGamma,u=e.applyAlpha,f=e.applyDayNightAlpha,h=e.applySplit,p=e.hasWaterMask,A=e.showReflectiveOcean,m=e.showOceanWaves,_=e.enableLighting,y=e.dynamicAtmosphereLighting,C=e.dynamicAtmosphereLightingFromSun,E=e.showGroundAtmosphere,I=e.perFragmentGroundAtmosphere,x=e.hasVertexNormals,S=e.useWebMercatorProjection,w=e.enableFog,v=e.enableClippingPlanes,R=e.clippingPlanes,N=e.enableClippingPolygons,L=e.clippingPolygons,g=e.clippedByBoundaries,b=e.hasImageryLayerCutout,T=e.colorCorrect,B=e.highlightFillTile,M=e.colorToAlpha,O=e.hasGeodeticSurfaceNormals,G=e.hasExaggeration,k=e.showUndergroundColor,z=e.translucent,F=e.marsOptions||{},H=0,Y="",W=n.renderedMesh.encoding;W.quantization===rc.BITS12&&(H=1,Y="QUANTIZATION_BITS12");let Z=0,pe="";g&&(Z=1,pe="TILE_LIMIT_RECTANGLE");let ge=0,re="";b&&(ge=1,re="APPLY_IMAGERY_CUTOUT");let ye=t.mode,Ce=((ye|o<<2|r<<3|a<<4|s<<5|c<<6|u<<7|p<<8|A<<9|m<<10|_<<11|y<<12|C<<13|E<<14|I<<15|x<<16|S<<17|w<<18|H<<19|h<<20|v<<21|N<<22|Z<<23|ge<<24|T<<25|B<<26|M<<27|O<<28|G<<29|k<<30|z<<31)>>>0)+(f?4294967296:0),ve=0;l(R)&&R.length>0&&(ve=v?R.clippingPlanesState:0);let Ne=0;l(L)&&L.length>0&&(Ne=N?L.clippingPolygonsState:0);let Le=n.surfaceShader;if(l(Le)&&Le.numberOfDayTextures===i&&Le.flags===Ce&&Le.material===this.material&&Le.clippingShaderState===ve&&Le.clippingPolygonShaderState===Ne)return Le.shaderProgram;let Oe=this._shadersByTexturesFlags[i];if(l(Oe)||(Oe=this._shadersByTexturesFlags[i]=[]),Le=Oe[Ce],!l(Le)||Le.material!==this.material||Le.clippingShaderState!==ve||Le.clippingPolygonShaderState!==Ne){let nt=this.baseVertexShaderSource.clone(),Fe=this.baseFragmentShaderSource.clone();ve!==0&&Fe.sources.unshift(SS(R,t.context)),Ne!==0&&(Fe.sources.unshift(_yt(t.context)),nt.sources.unshift(yyt(t.context))),F.enableUplift&&Fe.defines.push("APPLY_MARS3D_UPLIFT"),F.enableFlat&&nt.defines.push("APPLY_MARS3D_FLAT"),F.enableClip&&Fe.defines.push("APPLY_MARS3D_CLIP"),F.enableFlood&&Fe.defines.push("APPLY_MARS3D_FLOOD"),nt.defines.push(Y),Fe.defines.push(`TEXTURE_UNITS ${i}`,pe,re),o&&Fe.defines.push("APPLY_BRIGHTNESS"),r&&Fe.defines.push("APPLY_CONTRAST"),a&&Fe.defines.push("APPLY_HUE"),s&&Fe.defines.push("APPLY_SATURATION"),c&&Fe.defines.push("APPLY_GAMMA"),F.invertColor&&Fe.defines.push("APPLY_INVERT_COLOR_MARS3D"),F.filterColor&&Fe.defines.push("APPLY_FILTER_COLOR_MARS3D"),u&&Fe.defines.push("APPLY_ALPHA"),f&&Fe.defines.push("APPLY_DAY_NIGHT_ALPHA"),p&&Fe.defines.push("HAS_WATER_MASK"),A&&(Fe.defines.push("SHOW_REFLECTIVE_OCEAN"),nt.defines.push("SHOW_REFLECTIVE_OCEAN")),m&&Fe.defines.push("SHOW_OCEAN_WAVES"),M&&Fe.defines.push("APPLY_COLOR_TO_ALPHA"),k&&(nt.defines.push("UNDERGROUND_COLOR"),Fe.defines.push("UNDERGROUND_COLOR")),z&&(nt.defines.push("TRANSLUCENT"),Fe.defines.push("TRANSLUCENT")),_&&(x?(nt.defines.push("ENABLE_VERTEX_LIGHTING"),Fe.defines.push("ENABLE_VERTEX_LIGHTING")):(nt.defines.push("ENABLE_DAYNIGHT_SHADING"),Fe.defines.push("ENABLE_DAYNIGHT_SHADING"))),y&&(nt.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),Fe.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),C&&(nt.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),Fe.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),E&&(nt.defines.push("GROUND_ATMOSPHERE"),Fe.defines.push("GROUND_ATMOSPHERE"),I&&(nt.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"),Fe.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"))),nt.defines.push("INCLUDE_WEB_MERCATOR_Y"),Fe.defines.push("INCLUDE_WEB_MERCATOR_Y"),w&&(nt.defines.push("FOG"),Fe.defines.push("FOG")),h&&Fe.defines.push("APPLY_SPLIT"),v&&Fe.defines.push("ENABLE_CLIPPING_PLANES"),N&&(Fe.defines.push("ENABLE_CLIPPING_POLYGONS"),nt.defines.push("ENABLE_CLIPPING_
{ vec4 color = initialColor;`;b&&(_t+=` vec4 cutoutAndColorResult; bool texelUnclipped;`);for(let je=0;je<i;++je)b?_t+=` cutoutAndColorResult = u_dayTextureCutoutRectangles[${je}]; texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y; cutoutAndColorResult = sampleAndBlend(`:_t+=` color = sampleAndBlend(`,_t+=` color, u_dayTextures[${je}], u_dayTextureUseWebMercatorT[${je}] ? textureCoordinates.xz : textureCoordinates.xy, u_dayTextureTexCoordsRectangle[${je}], u_dayTextureTranslationAndScale[${je}], ${u?`u_dayTextureAlpha[${je}]`:"1.0"}, ${f?`u_dayTextureNightAlpha[${je}]`:"1.0"}, ${f?`u_dayTextureDayAlpha[${je}]`:"1.0"}, ${o?`u_dayTextureBrightness[${je}]`:"0.0"}, ${r?`u_dayTextureContrast[${je}]`:"0.0"}, ${a?`u_dayTextureHue[${je}]`:"0.0"}, ${s?`u_dayTextureSaturation[${je}]`:"0.0"}, ${c?`u_dayTextureOneOverGamma[${je}]`:"0.0"}, //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
${F.invertColor?`u_mars3dTextureInvertColor[${je}]`:"false"}, ${F.filterColor?`u_mars3dTextureFilterColor[${je}]`:"vec3(1.0)"}, //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
${h?`u_dayTextureSplit[${je}]`:"0.0"}, ${M?`u_colorsToAlpha[${je}]`:"vec4(0.0)"}, nightBlend);`,b&&(_t+=` color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);`);_t+=` return color; }`,Fe.sources.push(_t),nt.sources.push(gyt(ye)),nt.sources.push(Cyt(S));let rt=$t.fromCache({context:t.context,vertexShaderSource:nt,fragmentShaderSource:Fe,attributeLocations:W.getAttributeLocations()});Le=Oe[Ce]=new Ayt(i,Ce,this.material,rt,ve,Ne)}return n.surfaceShader=Le,Le.shaderProgram};T$.prototype.destroy=function(){let e,t,n=this._shadersByTexturesFlags;for(let i in n)if(n.hasOwnProperty(i)){let o=n[i];if(!l(o))continue;for(e in o)o.hasOwnProperty(e)&&(t=o[e],l(t)&&t.shaderProgram.destroy())}return fe(this)};var b8=T$;var Eyt={START:0,LOADING:1,DONE:2,FAILED:3},sc=Object.freeze(Eyt);var Iyt={FAILED:0,UNLOADED:1,RECEIVING:2,RECEIVED:3,TRANSFORMING:4,TRANSFORMED:5,READY:6},Lo=Object.freeze(Iyt);function hr(){this.imagery=[],this.waterMaskTexture=void 0,this.waterMaskTranslationAndScale=new ie(0,0,1,1),this.terrainData=void 0,this.vertexArray=void 0,this.tileBoundingRegion=void 0,this.occludeePointInScaledSpace=new d,this.boundingVolumeSourceTile=void 0,this.boundingVolumeIsFromMesh=!1,this.terrainState=Lo.UNLOADED,this.mesh=void 0,this.fill=void 0,this.pickBoundingSphere=new le,this.surfaceShader=void 0,this.isClipped=!0,this.clippedByBoundaries=!1}Object.defineProperties(hr.prototype,{eligibleForUnloading:{get:function(){let e=this.terrainState,n=!(e===Lo.RECEIVING||e===Lo.TRANSFORMING),i=this.imagery;for(let o=0,r=i.length;n&&o<r;++o){let a=i[o];n=!l(a.loadingImagery)||a.loadingImagery.state!==Hn.TRANSITIONING}return n}},renderedMesh:{get:function(){if(l(this.vertexArray))return this.mesh;if(l(this.fill))return this.fill.mesh}}});hr.prototype.pick=function(e,t,n,i,o){if(!l(this.renderedMesh))return;let r=this.renderedMesh.pick(e,i,t,n);return d.clone(r,o)};hr.prototype.freeResources=function(){l(this.waterMaskTexture)&&(--this.waterMaskTexture.referenceCount,this.waterMaskTexture.referenceCount===0&&this.waterMaskTexture.destroy(),this.waterMaskTexture=void 0),this.terrainData=void 0,this.terrainState=Lo.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()};hr.prototype.freeVertexArray=function(){hr._freeVertexArray(this.vertexArray),this.vertexArray=void 0,hr._freeVertexArray(this.wireframeVertexArray),this.wireframeVertexArray=void 0};hr.initialize=function(e,t,n){let i=e.data;l(i)||(i=e.data=new hr),e.state===sc.START&&(byt(e,t,n),e.state=sc.LOADING)};hr.processStateMachine=function(e,t,n,i,o,r,a){hr.initialize(e,n,i);let s=e.data;if(e.state===sc.LOADING&&xyt(e,t,n,i,o,r),a)return;let c=e.renderable;e.renderable=l(s.vertexArray);let u=s.terrainState===Lo.READY;e.upsampledFromParent=l(s.terrainData)&&s.terrainData.wasCreatedByUpsampling();let f=s.processImagery(e,n,t);if(u&&f){let h=e._loadedCallbacks,p={};for(let A in h)h.hasOwnProperty(A)&&(h[A](e)||(p[A]=h[A]));e._loadedCallbacks=p,e.state=sc.DONE}c&&(e.renderable=!0)};hr.prototype.processImagery=function(e,t,n,i){let o=e.data,r=e.upsampledFromParent,a=!1,s=!0,c=o.imagery,u,f;for(u=0,f=c.length;u<f;++u){let h=c[u];if(!l(h.loadingImagery)){r=!1;continue}if(h.loadingImagery.state===Hn.PLACEHOLDER){let A=h.loadingImagery.imageryLayer;if(A.ready){h.freeResources(),c.splice(u,1),A._createTileImagerySkeletons(e,t,u),--u,f=c.length;continue}else r=!1}let p=h.processStateMachine(e,n,i);s=s&&p,a=a||p||l(h.readyImagery),r=r&&l(h.loadingImagery)&&(h.loadingImagery.state===Hn.FAILED||h.loadingImagery.state===Hn.INVALID)}return e.upsampledFromParent=r,e.renderable=e.renderable&&(a||s),s};function Zbe(e,t,n,i){let o=e.renderedMesh,r=o.vertices,a=o.encoding,s=r.length/a.stride,c=Tr.clone(a);c.hasGeodeticSurfaceNormals=t,c=Tr.clone(c);let u=c.stride,f=new Float32Array(s*u);t?a.addGeodeticSurfaceNormals(r,f,n):a.removeGeodeticSurfaceNormals(r,f),o.vertices=f,o.stride=u,o!==e.mesh?(hr._freeVertexArray(e.fill.vertexArray),e.fill.vertexArray=hr._createVertexArrayForMesh(i.context,o)):(hr._freeVertexArray(e.vertexArray),e.vertexArray=hr._createVertexArrayForMesh(i.context,o)),hr._freeVertexArray(e.wireframeVertexArray),e.wireframeVertexArray=vo
.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);}
.cesium-credit-lightbox { background-color: #303336; color: ${aR}; position: relative; min-height: ${k0t}px; margin: auto;}.cesium-credit-lightbox > ul > li a,.cesium-credit-lightbox > ul > li a:visited,.cesium-credit-wrapper a,.cesium-credit-wrapper a:visited { color: ${aR};}.cesium-credit-lightbox > ul > li a:hover { color: ${rH};}.cesium-credit-lightbox.cesium-credit-lightbox-expanded { border: 1px solid #444; border-radius: 5px; max-width: 470px;}.cesium-credit-lightbox.cesium-credit-lightbox-mobile { height: 100%; width: 100%;}.cesium-credit-lightbox-title { padding: 20px 20px 0 20px;}.cesium-credit-lightbox-close { font-size: 18pt; cursor: pointer; position: absolute; top: 0; right: 6px; color: ${aR};}.cesium-credit-lightbox-close:hover { color: ${rH};}.cesium-credit-lightbox > ul { margin: 0; padding: 12px 20px 12px 40px; font-size: 13px;}.cesium-credit-lightbox > ul > li { padding-bottom: 6px;}.cesium-credit-lightbox > ul > li * { padding: 0; margin: 0;}
.cesium-credit-expand-link { padding-left: 5px; cursor: pointer; text-decoration: underline; color: ${aR};}.cesium-credit-expand-link:hover { color: ${rH};}
.cesium-credit-text { color: ${aR};}
.cesium-credit-delimiter { padding: 0 5px;}
.cesium-credit-textContainer *,.cesium-credit-logoContainer * { display: inline;}
.cesium-credit-textContainer a:hover { color: ${rH}}
.cesium-credit-textContainer .cesium-credit-wrapper:first-of-type { padding-left: 5px;}`;function n(r){if(r.shadowRoot)return r.shadowRoot;if(r.getRootNode){let a=r.getRootNode();if(a instanceof ShadowRoot)return a}}let i=n(e)??document.head,o=document.createElement("style");o.innerHTML=t,i.appendChild(o)}function Lr(e,t,n){let i=this;n=n??document.body;let o=document.createElement("div");o.className="cesium-credit-lightbox-overlay",n.appendChild(o);let r=document.createElement("div");r.className="cesium-credit-lightbox",o.appendChild(r);function a(m){r.contains(m.target)||i.hideLightbox()}o.addEventListener("click",a,!1);let s=document.createElement("div");s.className="cesium-credit-lightbox-title",s.textContent="Data provided by:",r.appendChild(s);let c=document.createElement("a");c.onclick=this.hideLightbox.bind(this),c.innerHTML="×",c.className="cesium-credit-lightbox-close",r.appendChild(c);let u=document.createElement("ul");r.appendChild(u);let f=document.createElement("div");f.className="cesium-credit-logoContainer",f.style.display="inline",e.appendChild(f);let h=document.createElement("div");h.className="cesium-credit-textContainer",h.style.display="inline",e.appendChild(h);let p=document.createElement("a");p.className="cesium-credit-expand-link",p.onclick=this.showLightbox.bind(this),p.textContent="Data attribution",e.appendChild(p),V0t(e);let A=Et.clone(Lr.cesiumCredit);this._delimiter=t??"\u2022",this._screenContainer=h,this._cesiumCreditContainer=f,this._lastViewportHeight=void 0,this._lastViewportWidth=void 0,this._lightboxCredits=r,this._creditList=u,this._lightbox=o,this._hideLightbox=a,this._expandLink=p,this._expanded=!1,this._staticCredits=[],this._cesiumCredit=A,this._previousCesiumCredit=void 0,this._currentCesiumCredit=A,this._creditDisplayElementPool=[],this._creditDisplayElementIndex=0,this._currentFrameCredits={screenCredits:new Ft,lightboxCredits:new Ft},this._defaultCredit=void 0,this.viewport=n,this.container=e}function aTe(e,t,n,i){i=i??1;let o=t.get(n.id);if(l(o))o.count<Number.MAX_VALUE&&(o.count+=i);else{let r=e._creditDisplayElementPool,a=e._creditDisplayElementPoolIndex;a<r.length?(o=r[a],o.credit=n,o.count=i):(o=new oTe(n,i),r.push(o)),++e._creditDisplayElementPoolIndex,t.set(n.id,o)}}Lr.prototype.addCreditToNextFrame=function(e){if(e.isIon()){l(this._defaultCredit)||(this._defaultCredit=Et.clone(sTe())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,aTe(this,t,e)};Lr.prototype.addStaticCredit=function(e){let t=this._staticCredits;U0t(t,e)||t.push(e)};Lr.prototype.removeStaticCredit=function(e){let t=this._staticCredits,n=t.indexOf(e);n!==-1&&t.splice(n,1)};Lr.prototype.showLightbox=function(){this._lightbox.style.display="block",this._expanded=!0};Lr.prototype.hideLightbox=function(){this._lightbox.style.display="none",this._expanded=!1};Lr.prototype.update=function(){this._expanded&&G0t(this)};Lr.prototype.beginFrame=function(){let e=this._currentFrameCredits;this._creditDisplayElementPoolIndex=0;let t=e.screenCredits,n=e.lightboxCredits;t.removeAll(),n.removeAll();let i=this._staticCredits;for(let o=0;o<i.length;++o){let r=i[o],a=r.showOnScreen?t:n;r.isIon()&&Et.equals(Lr.cesiumCredit,this._cesiumCredit)||aTe(this,a,r,Number.MAX_VALUE)}Et.equals(Lr.cesiumCredit,this._cesiumCredit)||(this._cesiumCredit=Et.clone(Lr.cesiumCredit)),this._currentCesiumCredit=this._cesiumCredit};Lr.prototype.endFrame=function(){let e=this._currentFrameCredits.screenCredits.values;nTe(this._screenContainer,e,this._delimiter,void 0);let t=this._currentFrameCredits.lightboxCredits.values;this._expandLink.style.display=t.length>0?"inline":"none",nTe(this._creditList,t,void 0,"li"),z0t(this)};Lr.prototype.destroy=function(){return this._lightbox.removeEventListener("click",this._hideLightbox,!1),this.container.removeChild(this._cesiumCreditContainer),this.container.removeChild(this._screenContainer),this.container.removeChild(this._expandLink),this.viewport.removeChild(this._lightbox),fe(this)};Lr.prototype.isDestroyed=function(){return!1};Lr._cesiumCredit=void 0;Lr._cesiumCredit
{ out_FragColor = vec4(1.0);}`;i=new We({sources:[s]})}else if(!o&&a){let s=`void main(){ out_FragColor = vec4(1.0); czm_writeLogDepth();}`;i=new We({defines:["LOG_DEPTH"],sources:[s]})}return e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}function iIt(e,t){let n=e._depthOnlyRenderStateCache,i=n[t.id];if(l(i))return i;let o=Ve.getState(t);o.depthMask=!0,o.colorMask={red:!1,green:!1,blue:!1,alpha:!1};let r=Ve.fromCache(o);return n[t.id]=r,r}RS.createDepthOnlyDerivedCommand=function(e,t,n,i){l(i)||(i={});let o=i.depthOnlyCommand?.shaderProgram,r=i.depthOnlyCommand?.renderState;return i.depthOnlyCommand=it.shallowClone(t,i.depthOnlyCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=nIt(n,t.shaderProgram),i.depthOnlyCommand.renderState=iIt(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=o,i.depthOnlyCommand.renderState=r),i};var oIt=/\s+czm_writeLogDepth\(/,rIt=/\s+czm_vertexLogDepth\(/;function aIt(e,t){if(t.fragmentShaderSource.defines.indexOf("LOG_DEPTH_READ_ONLY")>=0)return t;let i=e.shaderCache.getDerivedShaderProgram(t,"logDepth");if(l(i))return i;let o=t._attributeLocations,r=t.vertexShaderSource.clone(),a=t.fragmentShaderSource.clone();r.defines=l(r.defines)?r.defines.slice(0):[],r.defines.push("LOG_DEPTH"),a.defines=l(a.defines)?a.defines.slice(0):[],a.defines.push("LOG_DEPTH");let s=!1,c=r.sources;for(let f=0;f<c.length;++f)if(rIt.test(c[f])){s=!0;break}if(!s){for(let h=0;h<c.length;++h)c[h]=We.replaceMain(c[h],"czm_log_depth_main");c.push(`
void main(){ czm_log_depth_main(); czm_vertexLogDepth();}`)}c=a.sources,s=!1;for(let f=0;f<c.length;++f)oIt.test(c[f])&&(s=!0);a.defines.indexOf("LOG_DEPTH_WRITE")!==-1&&(s=!0);let u="";if(!s){for(let f=0;f<c.length;f++)c[f]=We.replaceMain(c[f],"czm_log_depth_main");u=`void main(){ czm_log_depth_main(); czm_writeLogDepth();}`}return c.push(u),e.shaderCache.createDerivedShaderProgram(t,"logDepth",{vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:o})}RS.createLogDepthCommand=function(e,t,n){l(n)||(n={});let i=n.command?.shaderProgram;return n.command=it.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=aIt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function sIt(e,t,n){let i=e.shaderCache.getDerivedShaderProgram(t,"pick");if(l(i))return i;Object.prototype.toString.call(n)==="[object Object]"&&(n.color?n=`vec4(${U.floatToByte(n.color.red)}, ${U.floatToByte(n.color.green)}, ${U.floatToByte(n.color.blue)}, ${U.floatToByte(n.color.alpha)})`:n="vec4(1.0)");let o=t._attributeLocations,{sources:r,defines:a}=t.fragmentShaderSource,c=r.some(A=>A.includes("out_FragData"))?"out_FragData_0":"out_FragColor",u=`void main (){ czm_non_pick_main(); if (${c}.a == 0.0) { discard; } ${c} = ${n};} `,f=r.length,h=new Array(f+1);for(let A=0;A<f;++A)h[A]=We.replaceMain(r[A],"czm_non_pick_main");h[f]=u;let p=new We({sources:h,defines:a});return e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:p,attributeLocations:o})}function fTe(e,t){let n=e.picking.pickRenderStateCache,i=n[t.id];if(l(i))return i;let o=Ve.getState(t);o.blending.enabled=!1,o.depthMask=!0;let r=Ve.fromCache(o);return n[t.id]=r,r}RS.createPickDerivedCommand=function(e,t,n,i){l(i)||(i={});let o=i.pickCommand?.shaderProgram,r=i.pickCommand?.renderState;return i.pickCommand=it.shallowClone(t,i.pickCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=sIt(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=fTe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=o,i.pickCommand.renderState=r),i};function PS(e,t,n){let i=e.length;for(let o=0;o<i;o++)e[o].trimStart().split(/\s+/)[0]===t&&(e[o]=`${t} ${n}`)}function cIt(e){return e.isArray?e.arrayLength:It.getComponentCount(e.type)}function dTe(e,t,n){return`((${e} - float(${t})) / float(${n}))`}function hTe(e,t){let n=Qt.getMaximum(t);return`(${e}) / float(${n})`}function lIt(e,t){let n="float(value)";if(t.hasValueTransform){let i=t.offset,o=t.scale;n=dTe(n,i,o)}return e.normalized||(n=hTe(n,e.componentType)),n}function uIt(e,t,n){let o=`float(${`value.${n}`})`;if(t.hasValueTransform){let r=t.offset[n],a=t.scale[n];o=dTe(o,r,a)}return e.normalized||(o=hTe(o,e.componentType)),o}function fIt(e,t,n){let i=n.schemaId,o=n.className,r=n.propertyName,a=`pickMetadata-${i}-${o}-${r}`,s=e.shaderCache.getDerivedShaderProgram(t,a);if(l(s))return s;let c=n.metadataProperty,u=n.classProperty,f=u.getGlslType(),h=["0.0","0.0","0.0","0.0"],p=cIt(u);if(p===1)h[0]=lIt(u,c);else{let y=["x","y","z","w"];for(let C=0;C<p;C++)h[C]=uIt(u,c,y[C])}let A=t.fragmentShaderSource.defines.slice();A.push(rd.METADATA_PICKING_ENABLED),PS(A,rd.METADATA_PICKING_VALUE_TYPE,f),PS(A,rd.METADATA_PICKING_VALUE_STRING,`metadata.${r}`),PS(A,rd.METADATA_PICKING_VALUE_COMPONENT_X,h[0]),PS(A,rd.METADATA_PICKING_VALUE_COMPONENT_Y,h[1]),PS(A,rd.METADATA_PICKING_VALUE_COMPONENT_Z,h[2]),PS(A,rd.METADATA_PICKING_VALUE_COMPONENT_W,h[3]);let m=new We({sources:t.fragmentShaderSource.sources,defines:A});return e.shaderCache.createDerivedShaderProgram(t,a,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:m,attributeLocations:t._attributeLocations})}RS.createPickMetadataDerivedCommand=function(e,t,n,i){return l(i)||(i={}),i.pickMetadataCommand=it.shallowClone(t,i.pickMetadataCommand),i.pickMetadataCommand.shaderProgram=fIt(n,t.shaderProgram,t.pickedMetadataInfo),i.pickMetadataCommand.renderState=fTe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id,i};function dIt(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"HDR");if(l(n))return n;let i=t._attributeLocations,o=t.vertexShaderSource.clone(),r=t.fragmentShaderSource.clone();return o.defines=l(o.defines)?o.defines.slice(0):[],o.defines.push("HDR"),r.defines=l(r.defines)?r.defines.slice(0):[],r.defines.push("HDR"),e.shaderCache.createDerivedShaderProgram(t,"HDR",{vertexShaderSource:o,fragmentShaderSource:r,attributeLocations:i})}RS.createHdrCommand=function(e,t,n){l(n)||(n={});let i=n.command?.shaderProgram;return n.command=it.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=dIt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};var yg=RS;function fH(e){this._scene=e,this._lastAlpha=void 0,this._lastBeta=void 0,this._lastGamma=void 0,this._alpha=void 0,this._beta=void 0,this._gamma=void 0;let t=this;function n(i){let o=i.alpha;if(!l(o)){t._alpha=void 0,t._beta=void 0,t._gamma=void 0;return}t._alpha=D.toRadians(o),t._beta=D.toRadians(i.beta),t._gamma=D.toRadians(i.gamma)}window.addEventListener("deviceorientation",n,!1),this._removeListener=function(){window.removeEventListener("deviceorientation",n,!1)}}var hIt=new Qe,mTe=new Qe,mIt=new J;function pIt(e,t,n,i){let o=e.direction,r=e.right,a=
{ out_FragColor = vec4(1.0); } `;t.sources=[n]}function J$(e,t){let n=t.sources,i=n.length;for(let r=0;r<i;++r)n[r]=We.replaceMain(n[r],"czm_globe_translucency_main");n.push(`
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); } `)}function TTe(e,t){J$(e,t),Fd(e.defines,"GROUND_ATMOSPHERE"),Fd(t.defines,"GROUND_ATMOSPHERE"),Fd(e.defines,"FOG"),Fd(t.defines,"FOG")}function SIt(e,t){J$(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function wIt(e,t){TTe(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function _Te(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 BIt(e,t,n,i,o,r){if(!l(o))return t;if(!i&&l(n))return n;let a=e.shaderCache.getDerivedShaderProgram(t,r);if(!l(a)){let s=t._attributeLocations,c=t.vertexShaderSource.clone(),u=t.fragmentShaderSource.clone();c.defines=l(c.defines)?c.defines.slice(0):[],u.defines=l(u.defines)?u.defines.slice(0):[],o(c,u),a=e.shaderCache.createDerivedShaderProgram(t,r,{vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:s})}return a}function DIt(e){e.cull.face=Li.BACK,e.cull.enabled=!0}function vIt(e){e.cull.face=Li.FRONT,e.cull.enabled=!0}function PIt(e){e.cull.face=Li.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function RIt(e){e.cull.face=Li.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function MIt(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function yTe(e){e.cull.face=Li.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=sn.ALPHA_BLEND}function CTe(e){e.cull.face=Li.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=sn.ALPHA_BLEND}function NIt(e){e.cull.face=Li.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function LIt(e){e.cull.face=Li.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function OIt(e,t,n,i,o){if(!l(i))return e;if(!n&&l(t))return t;let r=o[e.id];if(!l(r)){let a=Ve.getState(e);i(a),r=Ve.fromCache(a),o[e.id]=r}return r}function MS(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function FIt(e,t,n,i,o){return l(o)?!i&&l(n)?n:Pt(t,o(e),!1):t}function rm(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function QIt(){return[new rm({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:xIt,getRenderStateFunction:DIt,getUniformMapFunction:void 0}),new rm({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:TIt,getRenderStateFunction:vIt,getUniformMapFunction:void 0}),new rm({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:X$,getRenderStateFunction:PIt,getUniformMapFunction:void 0}),new rm({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:X$,getRenderStateFunction:RIt,getUniformMapFunction:void 0}),new rm({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:X$,getRenderStateFunction:MIt,getUniformMapFunction:void 0}),new rm({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:J$,getRenderStateFunction:yTe,getUniformMapFunction:MS}),new rm({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:TTe,getRenderStateFunction:CTe,getUniformMapFunction:MS}),new rm({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:SIt,getRenderStateFunction:yTe,getUniformMapFunction:MS}),new rm({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:wIt,getRenderStateFunction:CTe,getUniformMapFunction:MS}),new rm({pass:Be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:_Te,getRenderStateFunction:NIt,getUniformMapFunction:MS}),new rm({pass:Be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:_Te,getRenderStateFunction:LIt,getUniformMapFunction:MS})]}var ETe=new Array(U0),ITe=new Array(U0);z0.prototype.updateDerivedCommands=function(e,t){let n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let o=0;o<i;++o)ITe[o]=this._derivedCommandPacks[n[o]],ETe[o]=xTe[n[o]];kIt(this,e,i,n,ETe,ITe,t)}};function kIt(e,t,n,i,o,r,a){let s=t.derivedCommands.globeTranslucency,c=e._derivedCommandsDirty;if(t.dirty||!l(s)||c){t.dirty=!1,l(s)||(s={},t.derivedCommands.globeTranslucency=s);let u=a.frameNumber,f=s.uniformMapDirtyFrame??0,h=s.shaderProgramDirtyFrame??0,p=s.renderStateDirtyFrame??0,A=s.uniformMap!==t.uniformMap,m=s.shaderProgramId!==t.shaderProgram.id,_=s.renderStateId!==t.renderState.id;A&&(s.uniformMapDirtyFrame=u),m&&(s.shaderProgramDirtyFrame=u),_&&(s.renderStateDirtyFrame=u),s.uniformMap=t.uniformMap,s.shaderProgramId=t.shaderProgram.id,s.renderStateId=t.renderState.id;for(let y=0;y<n;++y){let C=r[y],E=i[y],I=o[y],x=s[I],S,w,v;l(x)?(S=x.uniformMap,w=x.shaderProgram,v=
in vec2 v_textureCoordinates;
void main(){ out_FragColor = texture(colorTexture, v_textureCoordinates);}`;function Up(){this._numSamples=1,this.previousFramebuffer=void 0,this._previousFramebuffer=void 0,this._depthStencilTexture=void 0,this._depthStencilRenderbuffer=void 0,this._fbo=new bi({depthStencil:!0,createDepthAttachments:!1}),this._fboClassified=new bi({depthStencil:!0,createDepthAttachments:!1}),this._rsUnclassified=void 0,this._rsClassified=void 0,this._unclassifiedCommand=void 0,this._classifiedCommand=void 0,this._translucentCommand=void 0,this._clearColorCommand=new ui({color:new U(0,0,0,0),owner:this}),this._clearCommand=new ui({color:new U(0,0,0,0),depth:1,stencil:0});let e=this;this._uniformMap={colorTexture:function(){return e._fbo.getColorTexture()},depthTexture:function(){return e._depthStencilTexture},classifiedTexture:function(){return e._fboClassified.getColorTexture()}}}Object.defineProperties(Up.prototype,{unclassifiedCommand:{get:function(){return this._unclassifiedCommand}}});Up.isTranslucencySupported=function(e){return e.depthTexture&&e.fragmentDepth};var GIt={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ti.EQUAL,frontOperation:{fail:wt.KEEP,zFail:wt.KEEP,zPass:wt.KEEP},backFunction:ti.NEVER,reference:0,mask:Yt.CLASSIFICATION_MASK},blending:sn.ALPHA_BLEND},VIt={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ti.NOT_EQUAL,frontOperation:{fail:wt.KEEP,zFail:wt.KEEP,zPass:wt.KEEP},backFunction:ti.NEVER,reference:0,mask:Yt.CLASSIFICATION_MASK},blending:sn.ALPHA_BLEND},HIt={depthMask:!0,depthTest:{enabled:!0},stencilTest:Yt.setCesium3DTileBit(),stencilMask:Yt.CESIUM_3D_TILE_MASK,blending:sn.ALPHA_BLEND},WIt=`uniform sampler2D colorTexture;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;}`,jIt=`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}`;Up.prototype.update=function(e,t,n){let i=this._fbo.getColorTexture(),o=this.previousFramebuffer!==this._previousFramebuffer;this._previousFramebuffer=this.previousFramebuffer;let r=this._numSamples!==t,a=e.drawingBufferWidth,s=e.drawingBufferHeight,c=!l(i)||i.width!==a||i.height!==s;if((c||o||r)&&(this._numSamples=t,this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),l(this._previousFramebuffer)||(this._depthStencilTexture=new vt({context:e,width:a,height:s,pixelFormat:Ke.DEPTH_STENCIL,pixelDatatype:He.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new Gf({context:e,width:a,height:s,format:Kl.DEPTH24_STENCIL8,numSamples:t})))),!l(this._fbo.framebuffer)||c||o||r){this._fbo.destroy(),this._fboClassified.destroy();let u,f;l(this._previousFramebuffer)?(u=n.getDepthStencilTexture(),f=n.getDepthStencilRenderbuffer()):(u=this._depthStencilTexture,f=this._depthStencilRenderbuffer),this._fbo.setDepthStencilTexture(u),l(f)&&this._fbo.setDepthStencilRenderbuffer(f),this._fbo.update(e,a,s,t),l(this._previousFramebuffer)||(this._fboClassified.setDepthStencilTexture(u),this._fboClassified.update(e,a,s))}if(l(this._rsUnclassified)||(this._rsUnclassified=Ve.fromCache(GIt),this._rsClassified=Ve.fromCache(VIt),this._rsDefault=Ve.fromCache(HIt)),!l(this._unclassifiedCommand)||o||r){l(this._unclassifiedCommand)&&(this._unclassifiedCommand.shaderProgram=this._unclassifiedCommand.shaderProgram&&this._unclassifiedCommand.shaderProgram.destroy(),this._classifiedCommand.shaderProgram=this._classifiedCommand.shaderProgram&&this._classifiedCommand.shaderProgram.destroy());let u=l(this._previousFramebuffer)?jIt:WIt,f=new We({defines:["UNCLASSIFIED"],sources:[u]}),h=new We({sources:[u]});this._unclassifiedCommand=e.createViewportQuadCommand(f,{renderState:l(this._previousFramebuffer)?this._rsUnclassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),this._classifiedCommand=e.createViewportQuadCommand(h,{renderState:l(this._previousFramebuffer)?this._rsClassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),l(this._translucentCommand)&&(this._translucentCommand.shaderProgram=this._translucentCommand.shaderProgram&&this._translucentCommand.shaderProgram.destroy()),l(this._previousFramebuffer)||(this._translucentCommand=e.createViewportQuadCommand(bf,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};Up.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};Up.prototype.clear=function(e,t){l(this._previousFramebuffer)?this._fbo.clear(e,this._clearColorCommand,t):(this._fbo.clear(e,this._clearCommand,t),this._fboClassified.clear(e,this._clearCommand,t))};Up.prototype.executeClassified=function(e,t){if(!l(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)};Up.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};Up.prototype.isDestroyed=function(){return!1};Up.prototype.destroy=function(){return this._fbo.destroy(),this._fboClassified.destroy(),this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),l(this._unclassifiedCommand)&&(this._unclassifiedCommand.shaderProgram=this._unclassifiedCommand.shaderProgram&&this._unclassifiedCommand.shaderProgram.destroy(),this._classifiedCommand.shaderProgram=this._classifiedCommand.shaderProgram&&this._classifiedCommand.shaderProgram.destroy()),fe(this)};var lR=Up;function AH(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties(AH.prototype,{total:{get:function(){return this._total}}});function dC(e){let t=new Array(Uc.NUMBER_OF_JOB_TYPES);t[Uc.TEXTURE]=new AH(l(e)?e
in vec2 v_textureCoordinates;
void main(){ vec4 globeDepthPacked = texture(czm_globeDepthTexture, v_textureCoordinates); float globeDepth = czm_unpackDepth(globeDepthPacked); float depth = texture(colorTexture, v_textureCoordinates).r; out_FragColor = czm_branchFreeTernary(globeDepth <= 0.0 || globeDepth >= 1.0 || depth < globeDepth && depth > 0.0 && depth < 1.0, czm_packDepth(depth), globeDepthPacked);}`,{renderState:Ve.fromCache(),uniformMap:{colorTexture:function(){return e._textureToCopy}},owner:e})),e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}G0.prototype.update=function(e,t){YIt(this,e,t),qIt(this,e,t)};var KIt=new ie,XIt=new ie(1,1/255,1/65025,1/16581375);G0.prototype.getDepth=function(e,t,n){if(!l(this.framebuffer))return;let i=e.readPixels({x:t,y:n,width:1,height:1,framebuffer:this.framebuffer}),o=ie.unpack(i,0,KIt);return ie.divideByScalar(o,255,o),ie.dot(o,XIt)};G0.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};G0.prototype.isDestroyed=function(){return!1};G0.prototype.destroy=function(){return this._framebuffer.destroy(),l(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=l(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),fe(this)};var CH=G0;function mC(e){e=e||{},this._framebufferManager=new bi({colorAttachmentsLength:3,createColorAttachments:!0,depthStencil:!0,supportsDepthTexture:!0,color:!0}),this._framebuffer=void 0,this._colorTexture=void 0,this._idTexture=void 0,this._depthTexture=void 0,this._depthStencilTexture=void 0,this._clearCommand=new ui({color:new U(0,0,0,0),depth:1,stencil:0,owner:this})}Object.defineProperties(mC.prototype,{framebuffer:{get:function(){return this._framebuffer}},colorTexture:{get:function(){return this._colorTexture}},idTexture:{get:function(){return this._idTexture}},depthTexture:{get:function(){return this._depthTexture}},depthStencilTexture:{get:function(){return this._depthStencilTexture}}});mC.prototype.update=function(e,t,n,i,o){let r=t.width,a=t.height,s=n?e.halfFloatingPointTexture?He.HALF_FLOAT:He.FLOAT:He.UNSIGNED_BYTE,c=this._framebufferManager.update(e,r,a,1,s,Ke.RGBA);return this._framebufferManager.framebuffer&&(this._framebuffer=this._framebufferManager.framebuffer,this._colorTexture=l(i)?i:this._framebufferManager.getColorTexture(0),this._idTexture=this._framebufferManager.getColorTexture(1),this._depthTexture=this._framebufferManager.getColorTexture(2),this._depthStencilTexture=l(o)?o:this._framebufferManager.getDepthStencilTexture()),c};mC.prototype.clear=function(e,t,n){this.getClearCommand(n).execute(e,t)};mC.prototype.getClearCommand=function(e){return this._clearCommand.framebuffer=this._framebuffer,l(e)&&U.clone(e,this._clearCommand.color),this._clearCommand};mC.prototype.getFramebuffer=function(e,t,n,i){return this.update(e,t,!1,n,i),this._framebuffer};mC.prototype.isDestroyed=function(){return!1};mC.prototype.destroy=function(){return this._framebufferManager=this._framebufferManager&&this._framebufferManager.destroy(),this._clearCommand=void 0,fe(this)};var EH=mC;function JIt(e,t){this.near=e??0,this.far=t??0;let n=Be.NUMBER_OF_PASSES,i=new Array(n),o=new Array(n);for(let r=0;r<n;++r)i[r]=[],o[r]=0;this.commands=i,this.indices=o}var IH=JIt;var V0=`uniform highp sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main(){ out_FragColor = czm_packDepth(texture(u_depthTexture, v_textureCoordinates).r);}`;function zp(){this._picking=!1,this._numSamples=1,this._tempCopyDepthTexture=void 0,this._pickColorFramebuffer=new bi({depthStencil:!0,supportsDepthTexture:!0}),this._outputFramebuffer=new bi({depthStencil:!0,supportsDepthTexture:!0}),this._copyDepthFramebuffer=new bi,this._tempCopyDepthFramebuffer=new bi,this._updateDepthFramebuffer=new bi({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 et,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(zp.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 wTe(e,t,n,i,o){let r=e._viewport;r.width=n,r.height=i;let a=!et.equals(r,o.viewport),s=a!==e._useScissorTest;e._useScissorTest=a,et.equals(e._scissorRectangle,o.viewport)||(e._scissorRectangle=et.clone(o.viewport,e._scissorRectangle),s=!0),(!l(e._rs)||!et.equals(r,e._rs.viewport)||s)&&(e._rs=Ve.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=Ve.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:sn.ALPHA_BLEND}),e._rsUpdate=Ve.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ti.EQUAL,frontOperation:{fail:wt.KEEP,zFail:wt.KEEP,zPass:wt.KEEP},backFunction:ti.NEVER,reference:Yt.CESIUM_3D_TILE_MASK,mask:Yt.CESIUM_3D_TILE_MASK}})),l(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(V0,{uniformMap:{u_depthTexture:function(){return e.colorFramebufferManager.getDepthStencilTexture()}},owner:e})),e._copyDepthCommand.framebuffer=e._copyDepthFramebuffer.framebuffer,e._copyDepthCommand.renderState=e._rs,l(e._copyColorCommand)||(e._copyColorCommand=t.createViewportQuadCommand(bf,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,l(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(V0,{uniformMap:{u_depthTexture:function(){return e._tempCopyDepthTexture}},owner:e})),e._tempCopyDepthCommand.framebuffer=e._tempCopyDepthFramebuffer.framebuffer,e._tempCopyDepthCommand.renderState=e._rs,l(e._updateDepthCommand)||(e._updateDepthCommand=t.createViewportQuadCommand(bf,{uniformMap:{colorTexture:function(){return e._tempCopyDepthFramebuffer.getColorTexture()}},owner:e})),e._updateDepthCommand.framebuffer=e._updateDepthFramebuffer.framebuffer,e._updateDepthCommand.renderState=e._rsUpdate,l(e._clearGlobeColorCommand)||(e._clearGlobeColorCommand=new ui({color:new U(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}zp.prototype.update=function(e,t,n,i,o,r){let{width:a,height:s}=n,c=o?e.halfFloatingPointTexture?He.HALF_FLOAT:He.FLOAT:He.UNSIGNED_BYTE;this._numSamples=i,this.picking?this._pickColorFramebuffer.update(e,a,s):this._outputFramebuffer.update(e,a,s,i,c),this._copyDepthFramebuffer.update(e,a,s),wTe(this,e,a,s,t),e.uniformState.globeDepthTexture=void 0,this._clearGlobeDepth=r};zp.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};zp.prototype.executeCopyDepth=function(e,t){l(this._copyDepthCommand)&&(this.prepareColorTextures(e),this._copyDepthCommand.execute(e,t),e.uniformState.globeDepthTexture=this._copyDepthFramebuffer.getColorTexture())};zp.prototype.executeUpdateDepth=function(e,t,n){let i=l(n)?n:t.framebuffer.depthStencilTexture;if(!this._clearGlobeDep
float ai = czm_out_FragColor.a; float wzi = czm_alphaWeight(ai); out_FragData_0 = vec4(Ci * wzi, ai); out_FragData_1 = vec4(ai * wzi);`,ubt=` 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;`,fbt=` float ai = czm_out_FragColor.a; out_FragColor = vec4(ai);`;function eee(e,t,n,i){let{shaderCache:o}=e,r=o.getDerivedShaderProgram(t,n);if(l(r))return r;let a=t._attributeLocations,s=t.fragmentShaderSource.clone();s.sources=s.sources.map(function(f){return We.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")}),s.sources.splice(0,0,`#define CESIUM_REDIRECTED_COLOR_OUTPUTvec4 czm_out_FragColor;bool czm_discard = false;`);let c=[...i.matchAll(/out_FragData_(\d+)/g)],u="";for(let f=0;f<c.length;f++){let h=c[f];u=`layout (location = ${h[1]}) out vec4 ${h[0]};${u}`}return s.sources.push(u),s.sources.push(`void main(){ czm_translucent_main(); if (czm_discard) { discard; }${i}}`),o.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:s,attributeLocations:a})}function dbt(e,t){return eee(e,t,"translucentMRT",lbt)}function hbt(e,t){return eee(e,t,"translucentMultipass",ubt)}function mbt(e,t){return eee(e,t,"alphaMultipass",fbt)}Cg.prototype.createDerivedCommands=function(e,t,n){if(l(n)||(n={}),this._translucentMRTSupport){let s,c;return l(n.translucentCommand)&&(s=n.translucentCommand.shaderProgram,c=n.translucentCommand.renderState),n.translucentCommand=it.shallowClone(e,n.translucentCommand),!l(s)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=dbt(t,e.shaderProgram),n.translucentCommand.renderState=abt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=s,n.translucentCommand.renderState=c),n}let i,o,r,a;return l(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,o=n.translucentCommand.renderState,r=n.alphaCommand.shaderProgram,a=n.alphaCommand.renderState),n.translucentCommand=it.shallowClone(e,n.translucentCommand),n.alphaCommand=it.shallowClone(e,n.alphaCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=hbt(t,e.shaderProgram),n.translucentCommand.renderState=sbt(this,t,e.renderState),n.alphaCommand.shaderProgram=mbt(t,e.shaderProgram),n.alphaCommand.renderState=cbt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=i,n.translucentCommand.renderState=o,n.alphaCommand.shaderProgram=r,n.alphaCommand.renderState=a),n};function pbt(e,t,n,i,o,r){let{context:a,frameState:s}=t,{useLogDepth:c,shadowState:u}=s,f=t._hdr,h=i.framebuffer,p=u.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(a,i),i.framebuffer=e._adjustAlphaFBO.framebuffer,e._adjustAlphaCommand.execute(a,i);let A=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;for(let m=0;m<o.length;++m){let _=o[m];_=c?_.derivedCommands.logDepth.command:_,_=f?_.derivedCommands.hdr.command:_;let y=p&&_.receiveShadows?_.derivedCommands.oit.shadows.translucentCommand:_.derivedCommands.oit.translucentCommand;n(y,t,i,A)}if(l(r)){let m=r.unclassifiedCommand,_=p&&m.receiveShadows?m.derivedCommands.oit.shadows.translucentCommand:m.derivedCommands.oit.translucentCommand;n(_,t,i,A)}i.framebuffer=e._alphaFBO.framebuffer;for(let m=0;m<o.length;++m){let _=o[m];_=c?_.derivedCommands.logDepth.command:_,_=f?_.derivedCommands.hdr.command:_;let y=p&&_.receiveShadows?_.derivedCommands.oit.shadows.alphaCommand:_.derivedCommands.oit.alphaCommand;n(y,t,i,A)}if(l(r)){let m=r.unclassifiedCommand,_=p&&m.receiveShadows?m.derivedCommands.oit.shadows.alphaCommand:m.derivedCommands.oit.alphaCommand;n(_,t,i,A)}i.framebuffer=h}function Abt(e,t,n,i,o,r){let{context:a,frameState:s}=t,{useLogDepth:c,shadowState:u}=s,f=t._hdr,h=i.framebuffer,p=u.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(a,i);let A=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;for(let m=0;m<o.length;++m){let _=o[m];_=c?_.derivedCommands.logDepth.command:_,_=f?_.derivedCommands.hdr.command:_;let y=p&&_.receiveShadows?_.derivedCommands.oit.shadows.translucentCommand:_.derivedCommands.oit.translucentCommand;n(y,t,i,A)}if(l(r)){let m=r.unclassifiedCommand,_=p&&m.receiveShadows?m.derivedCommands.oit.shadows.translucentCommand:m.derivedCommands.oit.translucentCommand;n(_,t,i,A)}i.framebuffer=h}Cg.prototype.executeCommands=function(e,t,n,i,o){if(this._translucentMRTSupport){Abt(this,e,t,n,i,o);return}pbt(this,e,t,n,i,o)};Cg.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};Cg.prototype.clear=function(e,t,n){let i=t.framebuffer;t.framebuffer=this._opaqueFBO.framebuffer,U.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.fr
void main() { czm_shadow_cast_main(); v_positionEC = (czm_inverseProjection * gl_Position).xyz; }`)}return new We({defines:i,sources:o})};j0.createShadowCastFragmentShader=function(e,t,n,i){let o=e.defines.slice(0),r=e.sources.slice(0);o.push("SHADOW_MAP");let a=We.findPositionVarying(e),s=l(a);s||(a="v_positionEC");let c=r.length;for(let f=0;f<c;++f)r[f]=We.replaceMain(r[f],"czm_shadow_cast_main");let u="";return t&&(s||(u+=`in vec3 v_positionEC; `),u+=`uniform vec4 shadowMap_lightPositionEC; `),i?u+=`void main() { `:u+=`void main() { czm_shadow_cast_main(); if (out_FragColor.a == 0.0) { discard; } `,t?u+=` float distance = length(${a}); if (distance >= shadowMap_lightPositionEC.w) { discard; } distance /= shadowMap_lightPositionEC.w; // radius
out_FragColor = czm_packDepth(distance); `:n?u+=` out_FragColor = vec4(1.0); `:u+=` out_FragColor = czm_packDepth(gl_FragCoord.z); `,u+=`} `,r.push(u),new We({defines:o,sources:r})};j0.getShadowReceiveShaderKeyword=function(e,t,n,i){let o=e._usesDepthTexture,r=e._polygonOffsetSupported,a=e._isPointLight,s=e._isSpotLight,c=e._numberOfCascades>1,u=e.debugCascadeColors,f=e.softShadows;return`receiveShadow ${o}${r}${a}${s}${c}${u}${f}${t}${n}${i}`};j0.createShadowReceiveVertexShader=function(e,t,n){let i=e.defines.slice(0),o=e.sources.slice(0);return i.push("SHADOW_MAP"),t&&(n?i.push("GENERATE_POSITION_AND_NORMAL"):i.push("GENERATE_POSITION")),new We({defines:i,sources:o})};j0.createShadowReceiveFragmentShader=function(e,t,n,i,o){let r=We.findNormalVarying(e),a=!i&&l(r)||i&&o,s=We.findPositionVarying(e),c=l(s),u=t._usesDepthTexture,f=t._polygonOffsetSupported,h=t._isPointLight,p=t._isSpotLight,A=t._numberOfCascades>1,m=t.debugCascadeColors,_=t.softShadows,y=h?t._pointBias:i?t._terrainBias:t._primitiveBias,C=e.defines.slice(0),E=e.sources.slice(0),I=E.length;for(let w=0;w<I;++w)E[w]=We.replaceMain(E[w],"czm_shadow_receive_main");h?C.push("USE_CUBE_MAP_SHADOW"):u&&C.push("USE_SHADOW_DEPTH_TEXTURE"),_&&!h&&C.push("USE_SOFT_SHADOWS"),A&&n&&i&&(a?C.push("ENABLE_VERTEX_LIGHTING"):C.push("ENABLE_DAYNIGHT_SHADING")),n&&y.normalShading&&a&&(C.push("USE_NORMAL_SHADING"),y.normalShadingSmooth>0&&C.push("USE_NORMAL_SHADING_SMOOTH"));let x="";h?x+=`uniform samplerCube shadowMap_textureCube; `:x+=`uniform sampler2D shadowMap_texture; `;let S;return c?S=` return vec4(${s}, 1.0); `:S=`#ifndef LOG_DEPTH return czm_windowToEyeCoordinates(gl_FragCoord); #else return vec4(v_logPositionEC, 1.0); #endif `,x+=`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() { ${S}} vec3 getNormalEC() { ${a?` return normalize(${r});
`:` return vec3(1.0); `}}
void applyNormalOffset(inout vec4 positionEC, vec3 normalEC, float nDotL) { ${y.normalOffset&&a?` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
float normalOffsetScale = 1.0 - nDotL; vec3 offset = normalOffset * normalOffsetScale * normalEC; positionEC.xyz += offset; `:""}}
`,x+=`void main() { czm_shadow_receive_main(); vec4 positionEC = getPositionEC(); vec3 normalEC = getNormalEC(); float depth = -positionEC.z; `,x+=` czm_shadowParameters shadowParameters; shadowParameters.texelStepSize = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.xy; shadowParameters.depthBias = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.z; shadowParameters.normalShadingSmooth = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.w; shadowParameters.darkness = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.w; `,i?x+=` shadowParameters.depthBias *= max(depth * 0.01, 1.0); `:f||(x+=` shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015); `),h?x+=` 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?x+=` 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); `:A?x+=` 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); `:""}`:x+=` 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); `,x+=` out_FragColor.rgb *= visibility; } `,E.push(x),new We({defines:C,sources:E})};var Ig=j0;function Gp(e){e=e??V.EMPTY_OBJECT;let t=e.context;this._enabled=e.enabled??!0,this._softShadows=e.softShadows??!1,this._normalOffset=e.normalOffset??!0,this.dirty=!0,this.fromLightSource=e.fromLightSource??!0,this.darkness=e.darkness??.3,this._darkness=this.darkness,this.fadingEnabled=e.fadingEnabled??!0,this.maximumDistance=e.maximumDistance??5e3,this._outOfView=!1,this._outOfViewPrevious=!1,this._needsUpdate=!0;let n=!0;(hn.isEdge()||(hn.isChrome()||hn.isFirefox())&&hn.isWindows()&&!t.depthTexture)&&(n=!1),this._polygonOffsetSupported=n;let i=e.depthBiasStep??1;this._terrainBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.5,normalShading:!0,normalShadingSmooth:.3,depthBias:1e-4*i},this._primitiveBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.1,normalShading:!0,normalShadingSmooth:.05,depthBias:2e-5*i},this._pointBias={polygonOffset:!1,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:0,normalShading:!0,normalShadingSmooth:.1,depthBias:5e-4*i},this._depthAttachment=void 0,this._colorAttachment=void 0,this._shadowMapMatrix=new P,this._shadowMapTexture=void 0,this._lightDirectionEC=new d,this._lightPositionEC=new ie,this._distance=0,this._lightCamera=e.lightCamera,this._shadowMapCamera=new BH,this._shadowMapCullingVolume=void 0,this._sceneCamera=void 0,this._boundingSphere=new le,this._isPointLight=e.isPointLight??!1,this._pointLightRadius=e.pointLightRadius??100,this._cascadesEnabled=this._isPointLight?!1:e.cascadesEnabled??!0,this._numberOfCascades=this._cascadesEnabled?e.numberOfCascades??4:0,this._fitNearFar=!0,this._maximumCascadeDistances=[25,150,700,Number.MAX_VALUE],this._textureSize=new Q,this._isSpotLight=!1,this._cascadesEnabled?this._shadowMapCamera.frustum=new Aa:l(this._lightCamera.frustum.fov)&&(this._isSpotLight=!0),this._cascadeSplits=[new ie,new ie],this._cascadeMatrices=[new P,new P,new P,new P],this._cascadeDistances=new ie;let o;this._isPointLight?o=6:this._cascadesEnabled?o=this._numberOfCascades:o=1,this._passes=new Array(o);for(let r=0;r<o;++r)this._passes[r]=new Cbt(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,nee(this),this._clearCommand=new ui({depth:1,color:new U}),this._clearPassState=new ll(t),this._size=e.size??2048,this.size=this._size}Gp.MAXIMUM_DISTANCE=2e4;function Cbt(e){this.camera=new BH,this.passState=new ll(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function tee(e,t){return Ve.fromCache({cull:{enabled:!0,face:Li.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 nee(e){let t=!e._usesDepthTexture;e._primitiveRenderState=tee(t,e._primitiveBias),e._terrainRenderState=tee(t,e._terrainBias),e._pointRenderState=tee(t,e._pointBias)}Gp.prototype.debugCreateRenderStates=function(){nee(this)};Object.defineProperties(Gp.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){Sbt(this,e)}},outOfView:{get:function(
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 Dbt(e,t){let n=t.context,i=t.context.drawingBufferWidth,o=t.context.drawingBufferHeight,r=Math.min(i,o)*.3,a=wbt;a.x=i-r,a.y=0,a.width=r,a.height=r;let s=e._debugShadowViewCommand;l(s)||(s=Bbt(e,n),e._debugShadowViewCommand=s),(!l(s.renderState)||!et.equals(s.renderState.viewport,a))&&(s.renderState=Ve.fromCache({viewport:et.clone(a)})),t.commandList.push(e._debugShadowViewCommand)}var Vp=new Array(8);Vp[0]=new ie(-1,-1,-1,1);Vp[1]=new ie(1,-1,-1,1);Vp[2]=new ie(1,1,-1,1);Vp[3]=new ie(-1,1,-1,1);Vp[4]=new ie(-1,-1,1,1);Vp[5]=new ie(1,-1,1,1);Vp[6]=new ie(1,1,1,1);Vp[7]=new ie(-1,1,1,1);var pC=new P,oee=new Array(8);for(let e=0;e<8;++e)oee[e]=new ie;function vbt(e,t){let n=new Lt({geometry:new Sm({minimum:new d(-.5,-.5,-.5),maximum:new d(.5,.5,.5)}),attributes:{color:Jt.fromColor(t)}}),i=new Lt({geometry:new fy({radius:.5}),attributes:{color:Jt.fromColor(t)}});return new Ln({geometryInstances:[n,i],appearance:new gn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}var Pbt=[U.RED,U.GREEN,U.BLUE,U.MAGENTA],Rbt=new d;function Mbt(e,t){Dbt(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 _g({camera:e._sceneCamera,color:U.CYAN,updateOnChange:!1})),e._debugCameraFrustum.update(t)),e._cascadesEnabled){if(e.debugFreezeFrame){n&&(e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=new _g({camera:e._shadowMapCamera,color:U.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 _g({camera:e._passes[i].camera,color:Pbt[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!l(e._debugLightFrustum)||e._needsUpdate){let i=e._shadowMapCamera.positionWC,o=Qe.IDENTITY,r=e._pointLightRadius*2,a=d.fromElements(r,r,r,Rbt),s=P.fromTranslationQuaternionRotationScale(i,o,a,pC);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=vbt(s,U.YELLOW)}e._debugLightFrustum.update(t)}else(!l(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new _g({camera:e._shadowMapCamera,color:U.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function BH(){this.viewMatrix=new P,this.inverseViewMatrix=new P,this.frustum=void 0,this.positionCartographic=new me,this.positionWC=new d,this.directionWC=d.clone(d.UNIT_Z),this.upWC=d.clone(d.UNIT_Y),this.rightWC=d.clone(d.UNIT_X),this.viewProjectionMatrix=new P}BH.prototype.clone=function(e){P.clone(e.viewMatrix,this.viewMatrix),P.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),me.clone(e.positionCartographic,this.positionCartographic),d.clone(e.positionWC,this.positionWC),d.clone(e.directionWC,this.directionWC),d.clone(e.upWC,this.upWC),d.clone(e.rightWC,this.rightWC)};var Nbt=new P(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);BH.prototype.getViewProjection=function(){let e=this.viewMatrix,t=this.frustum.projectionMatrix;return P.multiply(t,e,this.viewProjectionMatrix),P.multiply(Nbt,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};var Lbt=new Array(5),Obt=new Wi,Fbt=new Array(4),LTe=new d,OTe=new d;function Qbt(e,t){let n=e._shadowMapCamera,i=e._sceneCamera,o=i.frustum.near,r=i.frustum.far,a=e._numberOfCascades,s,c=r-o,u=r/o,f=.9,h=!1;t.shadowState.closestObjectSize<200&&(h=!0,f=.9);let p=Fbt,A=Lbt;for(A[0]=o,A[a]=r,s=0;s<a;++s){let L=(s+1)/a,g=o*Math.pow(u,L),b=o+c*L,T=D.lerp(b,g,f);A[s+1]=T,p[s]=T-A[s]}if(h){for(s=0;s<a;++s)p[s]=Math.min(p[s],e._maximumCascadeDistances[s]);let L=A[0];for(s=0;s<a-1;++s)L+=p[s],A[s+1]=L}ie.unpack(A,0,e._cascadeSplits[0]),ie.unpack(
#ifdef DEBUG_SHOW_DEPTHuniform 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 $bt=!1;function gC(e){this._drawClassificationFBO=new bi({createDepthAttachments:!1}),this._accumulationFBO=new bi({createDepthAttachments:!1}),this._packFBO=new bi,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 ui({color:new U(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new ui({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new et,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(gC.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function kTe(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function UTe(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function ext(e,t,n,i){kTe(e),e._translucentDepthStencilTexture=new vt({context:t,width:n,height:i,pixelFormat:Ke.DEPTH_STENCIL,pixelDatatype:He.UNSIGNED_INT_24_8,sampler:jt.NEAREST})}function txt(e,t,n,i){UTe(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 nxt(e,t,n,i){if(!e.isSupported())return;e._opaqueDepthStencilTexture=i;let o=e._opaqueDepthStencilTexture.width,r=e._opaqueDepthStencilTexture.height;e._drawClassificationFBO.isDirty(o,r)&&(ext(e,t,o,r),txt(e,t,o,r));let a,s;if(l(e._packDepthCommand)||(a=new We({sources:[s8]}),s={u_opaqueDepthTexture:function(){return e._opaqueDepthStencilTexture},u_translucentDepthTexture:function(){return e._translucentDepthStencilTexture}},e._packDepthCommand=t.createViewportQuadCommand(a,{uniformMap:s,owner:e})),!l(e._compositeCommand)){a=new We({sources:[LS]}),s={colorTexture:function(){return e._textureToComposite}},$bt&&(a.defines=["DEBUG_SHOW_DEPTH"],s.u_packedTranslucentDepth=function(){return e._packFBO.getColorTexture()}),e._compositeCommand=t.createViewportQuadCommand(a,{uniformMap:s,owner:e});let f=e._compositeCommand,h=f.shaderProgram,p=t.shaderCache.createDerivedShaderProgram(h,"pick",{vertexShaderSource:h.vertexShaderSource,fragmentShaderSource:new We({sources:a.sources,defines:["PICK"]}),attributeLocations:h._attributeLocations}),A=it.shallowClone(f);A.shaderProgram=p,f.derivedCommands.pick=A}l(e._copyCommand)||(a=new We({sources:[LS]}),s={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(a,{uniformMap:s,owner:e})),l(e._accumulateCommand)||(a=new We({sources:[LS]}),s={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._accumulateCommand=t.createViewportQuadCommand(a,{uniformMap:s,owner:e})),e._viewport.width=o,e._viewport.height=r;let c=!et.equals(e._viewport,n.viewport),u=c!==e._useScissorTest;e._useScissorTest=c,et.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle=et.clone(n.viewport,e._scissorRectangle),u=!0),(!l(e._rsDepth)||!et.equals(e._viewport,e._rsDepth.viewport)||u)&&(e._rsDepth=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}})),l(e._packDepthCommand)&&(e._packDepthCommand.renderState=e._rsDepth),(!l(e._rsAccumulate)||!et.equals(e._viewport,e._rsAccumulate.viewport)||u)&&(e._rsAccumulate=Ve.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ti.EQUAL,reference:Yt.CESIUM_3D_TILE_MASK}})),l(e._accumulateCommand)&&(e._accumulateCommand.renderState=e._rsAccumulate),(!l(e._rsComp)||!et.equals(e._viewport,e._rsComp.viewport)||u)&&(e._rs
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSUREuniform sampler2D autoExposure;#elseuniform float exposure;#endif
void main(){ vec4 fragmentColor = texture(colorTexture, v_textureCoordinates); vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE color /= texture(autoExposure, vec2(0.5)).r;#else color *= vec3(exposure);#endif color = czm_acesTonemapping(color); color = czm_inverseGamma(color);
out_FragColor = vec4(color, fragmentColor.a);}`;var QH=`precision highp float;
uniform sampler2D randomTexture;uniform sampler2D depthTexture;uniform float intensity;uniform float bias;uniform float lengthCap;uniform int stepCount;uniform int directionCount;
vec4 pixelToEye(vec2 screenCoordinate){ vec2 uv = screenCoordinate / czm_viewport.zw; float depth = czm_readDepth(depthTexture, uv); vec2 xy = 2.0 * uv - vec2(1.0); vec4 posEC = czm_inverseProjection * vec4(xy, depth, 1.0); posEC = posEC / posEC.w; // Avoid numerical error at far plane
if (depth >= 1.0) { posEC.z = czm_currentFrustum.y; } return posEC;}
// Reconstruct surface normal in eye coordinates, avoiding edges
vec3 getNormalXEdge(vec3 positionEC){ // Find the 3D surface positions at adjacent screen pixels
vec2 centerCoord = gl_FragCoord.xy; vec3 positionLeft = pixelToEye(centerCoord + vec2(-1.0, 0.0)).xyz; vec3 positionRight = pixelToEye(centerCoord + vec2(1.0, 0.0)).xyz; vec3 positionUp = pixelToEye(centerCoord + vec2(0.0, 1.0)).xyz; vec3 positionDown = pixelToEye(centerCoord + vec2(0.0, -1.0)).xyz;
// Compute potential tangent vectors
vec3 dx0 = positionEC - positionLeft; vec3 dx1 = positionRight - positionEC; vec3 dy0 = positionEC - positionDown; vec3 dy1 = positionUp - positionEC;
// The shorter tangent is more likely to be on the same surface
vec3 dx = length(dx0) < length(dx1) ? dx0 : dx1; vec3 dy = length(dy0) < length(dy1) ? dy0 : dy1;
return normalize(cross(dx, dy));}
const float sqrtTwoPi = sqrt(czm_twoPi);
float gaussian(float x, float standardDeviation) { float argument = x / standardDeviation; return exp(-0.5 * argument * argument) / (sqrtTwoPi * standardDeviation);}
void main(void){ vec4 positionEC = pixelToEye(gl_FragCoord.xy);
// Exit if we are too close to the back of the frustum, where the depth value is invalid.
float maxValidDepth = czm_currentFrustum.y - lengthCap; if (-positionEC.z > maxValidDepth) { out_FragColor = vec4(1.0); return; }
vec3 normalEC = getNormalXEdge(positionEC.xyz); float gaussianVariance = lengthCap * sqrt(-positionEC.z); // Choose a step length such that the marching stops just before 3 * variance.
float stepLength = 3.0 * gaussianVariance / (float(stepCount) + 1.0); float metersPerPixel = czm_metersPerPixel(positionEC, 1.0); // Minimum step is 1 pixel to avoid double sampling
float pixelsPerStep = max(stepLength / metersPerPixel, 1.0); stepLength = pixelsPerStep * metersPerPixel;
float angleStepScale = 1.0 / float(directionCount); float angleStep = angleStepScale * czm_twoPi; float cosStep = cos(angleStep); float sinStep = sin(angleStep); mat2 rotateStep = mat2(cosStep, sinStep, -sinStep, cosStep);
// Initial sampling direction (different for each pixel)
const float randomTextureSize = 255.0; vec2 randomTexCoord = fract(gl_FragCoord.xy / randomTextureSize); float randomVal = texture(randomTexture, randomTexCoord).x; vec2 sampleDirection = vec2(cos(angleStep * randomVal), sin(angleStep * randomVal));
float ao = 0.0; // Loop over sampling directions
#if __VERSION__ == 300 for (int i = 0; i < directionCount; i++) {#else for (int i = 0; i < 16; i++) { if (i >= directionCount) { break; }#endif sampleDirection = rotateStep * sampleDirection;
float localAO = 0.0; vec2 radialStep = pixelsPerStep * sampleDirection;
#if __VERSION__ == 300 for (int j = 0; j < stepCount; j++) {#else for (int j = 0; j < 64; j++) { if (j >= stepCount) { break; }#endif // Step along sampling direction, away from output pixel
vec2 samplePixel = floor(gl_FragCoord.xy + float(j + 1) * radialStep) + vec2(0.5);
// Exit if we stepped off the screen
if (clamp(samplePixel, vec2(0.0), czm_viewport.zw) != samplePixel) { break; }
// Compute step vector from output point to sampled point
vec4 samplePositionEC = pixelToEye(samplePixel); vec3 stepVector = samplePositionEC.xyz - positionEC.xyz;
// Estimate the angle from the surface normal.
float dotVal = clamp(dot(normalEC, normalize(stepVector)), 0.0, 1.0); dotVal = czm_branchFreeTernary(dotVal > bias, dotVal, 0.0); dotVal = czm_branchFreeTernary(-samplePositionEC.z <= maxValidDepth, dotVal, 0.0);
// Weight contribution based on the distance from the output point
float sampleDistance = length(stepVector); float weight = gaussian(sampleDistance, gaussianVariance); localAO += weight * dotVal; } ao += localAO; }
ao *= angleStepScale * stepLength; ao = 1.0 - clamp(ao, 0.0, 1.0); ao = pow(ao, intensity); out_FragColor = vec4(vec3(ao), 1.0);}`;var kH=`uniform sampler2D colorTexture;uniform sampler2D ambientOcclusionTexture;uniform bool ambientOcclusionOnly;in vec2 v_textureCoordinates;
void main(void){ vec4 color = texture(colorTexture, v_textureCoordinates); vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates); out_FragColor = ambientOcclusionOnly ? ao : ao * color;}`;var UH=`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 zH=`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 GH=`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 VH=`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 HH=`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 WH=`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 jH=`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 YH=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSUREuniform sampler2D autoExposure;#elseuniform float exposure;#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;#else color *= vec3(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 qH=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSUREuniform sampler2D autoExposure;#elseuniform float exposure;#endif
void main(){ vec4 fragmentColor = texture(colorTexture, v_textureCoordinates); vec3 color = fragmentColor.rgb;
#ifdef AUTO_EXPOSURE color /= texture(autoExposure, vec2(0.5)).r;#else color *= vec3(exposure);#endif color = czm_pbrNeutralTonemapping(color); color = czm_inverseGamma(color);
out_FragColor = vec4(color, fragmentColor.a);}`;var KH=`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 Y0=`#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_SIZEuniform float stepSize;#elseuniform 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 XH=`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 JH=`uniform sampler2D colorTexture;uniform vec3 white;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSUREuniform sampler2D autoExposure;#elseuniform float exposure;#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;#else color *= vec3(exposure);#endif color = (color * (1.0 + color / white)) / (1.0 + color); color = czm_inverseGamma(color); out_FragColor = vec4(color, fragmentColor.a);}`;var ZH=`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 $H=`uniform sampler2D colorTexture;
in vec2 v_textureCoordinates;
#ifdef AUTO_EXPOSUREuniform sampler2D autoExposure;#elseuniform float exposure;#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;#else color *= vec3(exposure);#endif color = color / (1.0 + color); color = czm_inverseGamma(color); out_FragColor = vec4(color, fragmentColor.a);}`;var e4=`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);}`;function q0(){this._uniformMap=void 0,this._command=void 0,this._colorTexture=void 0,this._depthTexture=void 0,this._ready=!1,this._name="czm_autoexposure",this._logDepthChanged=void 0,this._useLogDepth=void 0,this._framebuffers=void 0,this._previousLuminance=new bi,this._commands=void 0,this._clearCommand=void 0,this._minMaxLuminance=new Q,this.enabled=!0,this._enabled=!0,this.minimumLuminance=.1,this.maximumLuminance=10}Object.defineProperties(q0.prototype,{ready:{get:function(){return this._ready}},name:{get:function(){return this._name}},outputTexture:{get:function(){let e=this._framebuffers;if(l(e))return e[e.length-1].getColorTexture(0)}}});function ZTe(e){let t=e._framebuffers;if(!l(t))return;let n=t.length;for(let i=0;i<n;++i)t[i].destroy();e._framebuffers=void 0,e._previousLuminance.destroy(),e._previousLuminance=void 0}function Oxt(e,t){ZTe(e);let n=e._width,i=e._height,o=t.halfFloatingPointTexture?He.HALF_FLOAT:He.FLOAT,r=Math.ceil(Math.log(Math.max(n,i))/Math.log(3)),a=new Array(r);for(let c=0;c<r;++c)n=Math.max(Math.ceil(n/3),1),i=Math.max(Math.ceil(i/3),1),a[c]=new bi,a[c].update(t,n,i,1,o);let s=a[r-1].getColorTexture(0);e._previousLuminance.update(t,s.width,s.height,1,o),e._framebuffers=a}function $Te(e){let t=e._commands;if(!l(t))return;let n=t.length;for(let i=0;i<n;++i)t[i].shaderProgram.destroy();e._commands=void 0}function Fxt(e,t){let n;if(t===0)n={colorTexture:function(){return e._colorTexture},colorTextureDimensions:function(){return e._colorTexture.dimensions}};else{let i=e._framebuffers[t-1].getColorTexture(0);n={colorTexture:function(){return i},colorTextureDimensions:function(){return i.dimensions}}}return n.minMaxLuminance=function(){return e._minMaxLuminance},n.previousLuminance=function(){return e._previousLuminance.getColorTexture(0)},n}function Qxt(e,t){let n=`uniform sampler2D colorTexture; 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 kxt(e,t){$Te(e);let n=e._framebuffers,i=n.length,o=new Array(i);for(let r=0;r<i;++r)o[r]=t.createViewportQuadCommand(Qxt(r,i),{framebuffer:n[r].framebuffer,uniformMap:Fxt(e,r)});e._commands=o}q0.prototype.clear=function(e){let t=this._framebuffers;if(!l(t))return;let n=this._clearCommand;l(n)||(n=this._clearCommand=new ui({color:new U(0,0,0,0),framebuffer:void 0}));let i=t.length;for(let o=0;o<i;++o)t[o].clear(e,n)};q0.prototype.update=function(e){let t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,Oxt(this,e),kxt(this,e),this._ready||(this._ready=!0)),this._minMaxLuminance.x=this.minimumLuminance,this._minMaxLuminance.y=this.maximumLuminance;let i=this._framebuffers,o=i[i.length-1];i[i.length-1]=this._previousLuminance,this._commands[this._commands.length-1].framebuffer=this._previousLuminance.framebuffer,this._previousLuminance=o};q0.prototype.execute=function(e,t){this._colorTexture=t;let n=this._commands;if(!l(n))return;let i=n.length;for(let o=0;o<i;++o)n[o].execute(e)};q0.prototype.isDestroyed=function(){return!1};q0.prototype.destroy=function(){return ZTe(this),$Te(this),fe(this)};var t4=q0;var Uxt={NEAREST:0,LINEAR:1},Qd=Uxt;function K0(e){e=e??V.EMPTY_OBJECT;let{name:t=Jn(),fragmentShader:n,uniforms:i,textureScale:o=1,forcePowerOfTwo:r=!1,sampleMode:a=Qd.NEAREST,pixelFormat:s=Ke.RGBA,pixelDatatype:c=He.UNSIGNED_BYTE,clearColor:u=U.BLACK,scissorRectangle:f}=e;this._fragmentShader=n,this._uniforms=i,this._textureScale=o,this._forcePowerOfTwo=r,this._sampleMode=a,this._pixelFormat=s,this._pixelDatatype=c,this._clearColor=u,this._uniformMap=void 0,this._command=void 0,this._colorTexture=void 0,this._depthTexture=void 0,this._idTexture=void 0,this._actualUniforms={},this._dirtyUniforms=[],this._texturesToRelease=[],this._texturesToCreate=[],this._texturePromise=void 0;let h=new ll;h.scissorTest={enabled:!0,rectangle:l(f)?et.clone(f):new et},this._passState=h,this._ready=!1,this._name=t,this._logDepthChanged=void 0,this._useLogDepth=void 0,this._selectedIdTexture=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,this._textureCache=void 0,this._index=void 0,this.enabled=!0,this._enabled=!0}Object.defineProperties(K0.prototype,{ready:{get:function(){return this._ready}},name:{get:function(){return this._name}},fragmentShader:{get:function(){return this._fragmentShader}},uniforms:{get:function(){return this._uniforms}},textureScale:{get:function(){return this._textureScale}},forcePowerOfTwo:{get:function(){return this._forcePowerOfTwo}},sampleMode:{get:function(){return this._sampleMode}},pixelFormat:{get:function(){return this._pixelFormat}},pixelDatatype:{get:function(){return this._pixelDatatype}},clearColor:{get:function(){return this._clearColor}},scissorRectangle:{get:function(){return this._passState.scissorTest.rectangle}},outputTexture:{get:function(){if(l(this._textureCache)){let e=this._textureCache.getFramebuffer(this._name);if(l(e))return e.getColorTexture(0)}}},selected:{get:function(){return this._selected},set:function(e){this._selected=e}},parentSelected:{get:function(){return this._parentSelected},set:function(e){this._parentSelected=e}}});var zxt=/uniform\s+sampler2D\s+depthTexture/g;K0.prototype._isSupported=function(e){return!zxt.test(this._fragmentShader)||e.depthTexture};function Gxt(e,t,n){let i=t[n];return(typeof i=="string"||i instanceof HTMLCanvasElement||i instanceof HTMLImageElement||i instanceof HTMLVideoElement||i instanceof ImageData)&&e._dirtyUniforms.push(n),{get:function(){return t[n]},set:function(o){let r=t[n];t[n]=o;let a=e._actualUniforms,s=a[n];l(s)&&s!==r&&s instanceof vt&&!l(e._textureCache.getStageByName(n))&&(e._texturesToRelease.push(s),delete a[n],delete a[`${n}Dimensions`]),r instanceof vt&&e._texturesToRelease.push(r),typeof o=="string"||o instanceof HTMLCanvasElement||o instanceof HTMLIma
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 < ${t}; ++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));}
${e}`}function Yxt(e,t){if(l(e._command)&&!e._logDepthChanged&&!e._selectedDirty)return;let n=e._fragmentShader;if(l(e._selectedIdTexture)){let o=e._selectedIdTexture.width;n=jxt(n,o)}let i=new We({defines:[e._useLogDepth?"LOG_DEPTH":""],sources:[n]});e._command=t.createViewportQuadCommand(i,{uniformMap:e._uniformMap,owner:e})}function qxt(e){let t=e._sampleMode,n,i;t===Qd.LINEAR?(n=Wt.LINEAR,i=si.LINEAR):(n=Wt.NEAREST,i=si.NEAREST);let o=e._sampler;(!l(o)||o.minificationFilter!==n||o.magnificationFilter!==i)&&(e._sampler=new jt({wrapS:pn.CLAMP_TO_EDGE,wrapT:pn.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function Kxt(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function Xxt(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function Jxt(e,t){let n=e._texturesToRelease;for(let s=0;s<n.length;++s){let c=n[s];c=c&&c.destroy()}n.length=0;let i=e._texturesToCreate;for(let s=0;s<i.length;++s){let{name:c,source:u}=i[s];e._actualUniforms[c]=new vt({context:t,source:u})}i.length=0;let o=e._dirtyUniforms;if(o.length===0&&!l(e._texturePromise)){e._ready=!0;return}if(o.length===0||l(e._texturePromise))return;let r=e._uniforms,a=[];for(let s=0;s<o.length;++s){let c=o[s],u=r[c],f=e._textureCache.getStageByName(u);if(l(f))e._actualUniforms[c]=Xxt(e,u);else if(typeof u=="string"){let h=new De({url:u});a.push(h.fetchImage().then(Kxt(e,c)))}else e._texturesToCreate.push({name:c,source:u})}o.length=0,a.length>0?(e._ready=!1,e._texturePromise=Promise.all(a).then(function(){e._ready=!0,e._texturePromise=void 0})):e._ready=!0}function eSe(e){l(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(!l(t))return;let n=e._uniforms,i=e._actualUniforms;for(let o in i){if(!i.hasOwnProperty(o))continue;let r=i[o];r instanceof vt&&(l(t.getStageByName(n[o]))||r.destroy(),e._dirtyUniforms.push(o))}}function Zxt(e){let t=l(e._selected)?e._selected.length:0,n=l(e._parentSelected)?e._parentSelected:0,i=e._selected!==e._selectedShadow||t!==e._selectedLength||e._parentSelected!==e._parentSelectedShadow||n!==e._parentSelectedLength;if(l(e._selected)&&l(e._parentSelected)?e._combinedSelected=e._selected.concat(e._parentSelected):l(e._parentSelected)?e._combinedSelected=e._parentSelected:e._combinedSelected=e._selected,!i&&l(e._combinedSelected)){if(!l(e._combinedSelectedShadow))return!0;for(let o=0;o<e._combinedSelected.length;++o)if(e._combinedSelected[o]!==e._combinedSelectedShadow[o])return!0}return i}function $xt(e,t){if(!e._selectedDirty)return;e._selectedIdTexture=e._selectedIdTexture&&e._selectedIdTexture.destroy(),e._selectedIdTexture=void 0;let n=e._combinedSelected;if(!l(n))return;let i=0;for(let a=0;a<n.length;++a){let s=n[a];l(s.pickIds)?i+=s.pickIds.length:l(s.pickId)&&++i}if(n.length===0||i===0){let a=new Uint8Array([255,255,255,255]);e._selectedIdTexture=new vt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:He.UNSIGNED_BYTE,source:{arrayBufferView:a,width:1,height:1},sampler:jt.NEAREST});return}let o=0,r=new Uint8Array(i*4);for(let a=0;a<n.length;++a){let s=n[a];if(l(s.pickIds)){let c=s.pickIds,u=c.length;for(let f=0;f<u;++f){let h=c[f].color;r[o]=U.floatToByte(h.red),r[o+1]=U.floatToByte(h.green),r[o+2]=U.floatToByte(h.blue),r[o+3]=U.floatToByte(h.alpha),o+=4}}else if(l(s.pickId)){let c=s.pickId.color;r[o]=U.floatToByte(c.red),r[o+1]=U.floatToByte(c.green),r[o+2]=U.floatToByte(c.blue),r[o+3]=U.floatToByte(c.alpha),o+=4}}e._selectedIdTexture=new vt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:He.UNSIGNED_BYTE,source:{arrayBufferView:r,width:i,height:1},sampler:jt.NEAREST})}K0.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&eSe(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=Zxt(this),this._selectedShadow=this._selected,this._parentSelectedShadow=this._parentSelected,this._combinedSelectedShadow=this._combinedSelecte
${Y0}`,r=new Oo({name:`${e}_x_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:Qd.LINEAR}),a=new Oo({name:`${e}_y_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:Qd.LINEAR}),s={};return Object.defineProperties(s,{delta:{get:function(){return r.uniforms.delta},set:function(c){let u=r.uniforms,f=a.uniforms;u.delta=f.delta=c}},sigma:{get:function(){return r.uniforms.sigma},set:function(c){let u=r.uniforms,f=a.uniforms;u.sigma=f.sigma=c}},stepSize:{get:function(){return r.uniforms.stepSize},set:function(c){let u=r.uniforms,f=a.uniforms;u.stepSize=f.stepSize=c}}}),new xf({name:e,stages:[r,a],uniforms:s})}Kr.createBlurStage=function(){return uee("czm_blur")};Kr.createDepthOfFieldStage=function(){let e=uee("czm_depth_of_field_blur"),t=new Oo({name:"czm_depth_of_field_composite",fragmentShader:HH,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 xf({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};Kr.isDepthOfFieldSupported=function(e){return e.context.depthTexture};Kr.createEdgeDetectionStage=function(){let e=Jn();return new Oo({name:`czm_edge_detection_${e}`,fragmentShader:jH,uniforms:{length:.25,color:U.clone(U.BLACK)}})};Kr.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function tTt(e){if(!l(e))return Kr.createEdgeDetectionStage();let t=new xf({name:"czm_edge_detection_multiple",stages:e,inputPreviousStageTexture:!1}),n={},i="",o="";for(let s=0;s<e.length;++s)i+=`uniform sampler2D edgeTexture${s}; `,o+=` vec4 edge${s} = texture(edgeTexture${s}, v_textureCoordinates); if (edge${s}.a > 0.0) { color = edge${s}; break; } `,n[`edgeTexture${s}`]=e[s].name;let r=`${i}in vec2 v_textureCoordinates; void main() { vec4 color = vec4(0.0); for (int i = 0; i < ${e.length}; i++) { ${o} } out_FragColor = color; } `,a=new Oo({name:"czm_edge_detection_combine",fragmentShader:r,uniforms:n});return new xf({name:"czm_edge_detection_composite",stages:[t,a]})}Kr.createSilhouetteStage=function(e){let t=tTt(e),n=new Oo({name:"czm_silhouette_color_edges",fragmentShader:e4,uniforms:{silhouetteTexture:t.name}});return new xf({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};Kr.isSilhouetteSupported=function(e){return e.context.depthTexture};Kr.createBloomStage=function(){let e=new Oo({name:"czm_bloom_contrast_bias",fragmentShader:VH,uniforms:{contrast:128,brightness:-.3}}),t=uee("czm_bloom_blur"),n=new xf({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new Oo({name:"czm_bloom_generate_composite",fragmentShader:zH,uniforms:{glowOnly:!1,bloomTexture:n.name}}),o={};return Object.defineProperties(o,{glowOnly:{get:function(){return i.uniforms.glowOnly},set:function(r){i.uniforms.glowOnly=r}},contrast:{get:function(){return e.uniforms.contrast},set:function(r){e.uniforms.contrast=r}},brightness:{get:function(){return e.uniforms.brightness},set:function(r){e.uniforms.brightness=r}},delta:{get:function(){return t.uniforms.delta},set:function(r){t.uniforms.delta=r}},sigma:{get:function(){return t.uniforms.sigma},set:function(r){t.uniforms.sigma=r}},stepSize:{get:function(){return t.uniforms.stepSize},set:function(r){t.uniforms.stepSize=r}}}),new xf({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};Kr.createAmbientOcclusionStage=function(){let e=new Oo({name:"czm_ambient_occlusion_generate",fragmentShader:QH,uniforms:{intensity:3,bias:.1,lengthCap:.26,directionCount:8,stepCount:32,randomTexture:void 0}}),t=new Oo({name:"czm_ambient_occlusion_composite",fragmentShader:kH,uniforms:{ambientOcclusionOnly:!1,ambientOcclusionTexture:e.name}}),n={};return Object.defineProperties(n,{intensity:{get:function(){return e.uniforms.intensity},set:function(i){e.uniforms.intensity=i}},bias:{get:function(){return e.uniforms.bias},set:function(i){e.uniforms.bias=i}},lengthCap:{get:function(){return e.uniforms.lengthCap},set:function(i){e.uniforms.lengthCap=i}},directionCount:{get:function(){return e.uniforms.directionCount},set:function(i){e.uniforms.directionCount=i}},stepCount:{get:function(){return e.uniforms.stepCount},set:function(i){e.uniforms.stepCount=i}},randomTexture:{get:function(){return e.uniforms.randomTexture},set:function(i){e.uniforms.randomTexture=i}},ambientOcclusionOnly:{get:function(){return t.uniforms.ambientOcclusionOnly},set:function(i){t.uniforms.ambientOcclusionOnly=i}}}),new xf({name:"czm_ambient_occlusion",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};Kr.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};var nTt=`#define FXAA_QUALITY_PRESET 39 ${d8}${KH}`;Kr.createFXAAStage=function(){return new Oo({name:"czm_FXAA",fragmentShader:nTt,sampleMode:Qd.LINEAR})};Kr.createAcesTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=FH,new Oo({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};Kr.createFilmicTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=YH,new Oo({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};Kr.createPbrNeutralTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=qH,new Oo({name:"czm_pbr_neutral",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};Kr.createReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=$H,new Oo({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};Kr.createModifiedReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=JH,new Oo({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:U.WHITE,autoExposure:void 0,exposure:1}})};Kr.createAutoExposureStage=function(){return new t4};Kr.createBlackAndWhiteStage=function(){return new Oo({name:"czm_black_and_white",fragmentShader:UH,uniforms:{gradations:5}})};Kr.createBrightnessStage=function(){return new Oo({name:"czm_brightness",fragmentShader:GH,uniforms:{brightness:.5}})};Kr.createNightVisionStage=function(){return new Oo({name:"czm_night_vision",fragmentShader:ZH})};Kr.createDepthViewStage=function(){return new Oo({name:"czm_depth_view",fragmentShader:WH})};Kr.createLensFlareStage=function(){return new Oo({name:"czm_lens_flare",fragmentShader:XH,uniforms:{dirtTexture:Zt("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:Zt("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:te.WGS84.maximumRadius}})};var kd=Kr;function bg(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function pR(e){for(;l(e.length);)e=e.get(e.length-1);return e.name}function fee(e,t,n,i,o){if(!i.enabled||!i._isSupported(t))return o;let r=n[i.name]={};if(l(o)){let s=e.getStageByName(o);r[pR(s)]=!0}let a=i.uniforms;if(l(a)){let s=Object.getOwnPropertyNames(a),c=s.length;for(let u=0;u<c;++u){let f=a[s[u]];if(typeof f=="string"){let h=e.getStageByName(f);l(h)&&(r[pR(h)]=!0)}}}return i.name}function mR(e,t,n,i,o){if(l(i.enabled)&&!i.enabled||l(i._isSupported)&&!i._isSupported(t))return o;let r=o,a=!l(i.inputPreviousStageTexture)||i.inputPreviousStageTexture,s=o,c=i.length;for(let h=0;h<c;++h){let p=i.get(h);l(p.length)?s=mR(e,t,n,p,o):s=fee(e,t,n,p,o),a&&(o=s)}let u,f;if(a)for(u=1;u<c;++u)f=pR(i.get(u)),l(n[f])||(n[f]={}),n[f][r]=!0;else for(u=1;u<c;++u){f=pR(i.get(u));let h=n[f];for(let p=0;p<u;++p)h[pR(i.get(p))]=!0}return s}function iTt(e,t){let n={};if(l(e.ambientOcclusion)){let i=e.ambientOcclusion,o=e.bloom,r=e._tonemapping,a=e.fxaa,s=mR(e,t,n,i,void 0);s=mR(e,t,n,o,s),s=fee(e,t,n,r,s),s=mR(e,t,n,e,s),fee(e,t,n,a,s)}else mR(e,t,n,e,void 0);return n}function oTt(e,t,n){let o=e._collection.getStageByName(t),r=o._textureScale,a=o._forcePowerOfTwo,s=o._pixelFormat,c=o._pixelDatatype,u=o._clearColor,f,h,p=e._framebuffers,A=p.length;for(f=0;f<A;++f){if(h=p[f],r!==h.textureScale||a!==h.forcePowerOfTwo||s!==h.pixelFormat||c!==h.pixelDatatype||!U.equals(u,h.clearColor))continue;let m=h.stages,_=m.length,y=!1;for(let C=0;C<_;++C)if(n[m[C]]){y=!0;break}if(!y)break}return l(h)&&f<A?(h.stages.push(t),h):(h={textureScale:r,forcePowerOfTwo:a,pixelFormat:s,pixelDatatype:c,clearColor:u,stages:[t],buffer:new bi({pixelFormat:s,pixelDatatype:c}),clear:void 0},p.push(h),h)}function rTt(e,t){let n=iTt(e._collection,t);for(let i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=oTt(e,i,n[i]))}function dee(e){let t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function aTt(e,t){let n=e._width,i=e._height,o=e._framebuffers,r=o.length;for(let a=0;a<r;++a){let s=o[a],c=s.textureScale,u=Math.ceil(n*c),f=Math.ceil(i*c),h=Math.min(u,f);s.forcePowerOfTwo&&(D.isPowerOfTwo(h)||(h=D.nextPowerOfTwo(h)),u=h,f=h),s.buffer.update(t,u,f),s.clear=new ui({color:s.clearColor,framebuffer:s.buffer.framebuffer})}}bg.prototype.updateDependencies=function(){this._updateDependencies=!0};bg.prototype.update=function(e){let t=this._collection,n=this._updateDependencies,i=l(t.ambientOcclusion)&&t.ambientOcclusion.enabled&&t.ambientOcclusion._isSupported(e),o=l(t.bloom)&&t.bloom.enabled&&t.bloom._isSupported(e),r=l(t._tonemapping)&&t._tonemapping.enabled&&t._tonemapping._isSupported(e),a=l(t.fxaa)&&t.fxaa.enabled&&t.fxaa._isSupported(e),s=!l(t._activeStages)||t._activeStages.length>0||i||o||r||a;if((n||!s&&this._framebuffers.length>0)&&(dee(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!s)return;this._framebuffers.length===0&&rTt(this,e);let c=e.drawingBufferWidth,u=e.drawingBufferHeight
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 g4=`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 Tg(){this._sceneFramebuffer=new NS;let e=.125,t=new Array(6);t[0]=new Oo({fragmentShader:bf,textureScale:e,forcePowerOfTwo:!0,sampleMode:Qd.LINEAR});let n=t[1]=new Oo({fragmentShader:g4,uniforms:{avgLuminance:.5,threshold:.25,offset:.1},textureScale:e,forcePowerOfTwo:!0}),i=this;this._delta=1,this._sigma=2,this._blurStep=new Q,t[2]=new Oo({fragmentShader:Y0,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 Oo({fragmentShader:Y0,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 Oo({fragmentShader:bf,sampleMode:Qd.LINEAR}),this._uCenter=new Q,this._uRadius=void 0,t[5]=new Oo({fragmentShader:A4,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new xf({stages:t});let o=new QS(this),r=t.length;for(let a=0;a<r;++a)t[a]._textureCache=o;this._textureCache=o,this.length=t.length}Tg.prototype.get=function(e){return this._stages.get(e)};Tg.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 Pwt=new ie,YSe=new Q,Rwt=new Q,qSe=new P;function Mwt(e,t,n){let i=t.uniformState,o=i.sunPositionWC,r=i.view,a=i.viewProjection,s=i.projection,c=P.computeViewportTransformation(n,0,1,qSe),u=P.multiplyByPoint(r,o,Pwt),f=At.pointToGLWindowCoordinates(a,c,o,YSe);u.x+=D.SOLAR_RADIUS;let h=At.pointToGLWindowCoordinates(s,c,u,u),p=Q.magnitude(Q.subtract(h,f,h))*30*2,A=Rwt;A.x=p,A.y=p,e._uCenter=Q.clone(f,e._uCenter),e._uRadius=Math.max(A.x,A.y)*.15;let m=t.drawingBufferWidth,_=t.drawingBufferHeight,y=e._stages,C=y.get(0),E=C.outputTexture.width,I=C.outputTexture.height,x=new et;x.width=E,x.height=I,c=P.computeViewportTransformation(x,0,1,qSe),f=At.pointToGLWindowCoordinates(a,c,o,YSe),A.x*=E/m,A.y*=I/_;let S=C.scissorRectangle;S.x=Math.max(f.x-A.x*.5,0),S.y=Math.max(f.y-A.y*.5,0),S.width=Math.min(A.x,m),S.height=Math.min(A.y,_);for(let w=1;w<4;++w)et.clone(S,y.get(w).scissorRectangle)}Tg.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)};Tg.prototype.update=function(e){let t=e.context,n=e.viewport,i=this._sceneFramebuffer;i.update(t,n);let o=i.framebuffer;return this._textureCache.update(t),this._stages.update(t,!1),Mwt(this,t,n),o};Tg.prototype.execute=function(e){let t=this._sceneFramebuffer.framebuffer.getColorTexture(0),n=this._stages,i=n.length;n.get(0).execute(e,t);for(let o=1;o<i;++o)n.get(o).execute(e,n.get(o-1).outputTexture)};Tg.prototype.copy=function(e,t){if(!l(this._copyColorCommand)){let n=this;this._copyColorCommand=e.createViewportQuadCommand(bf,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)};Tg.prototype.isDestroyed=function(){return!1};Tg.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),fe(this)};var _4=Tg;function KSe(){this._cachedShowFrustumsShaders={}}function Nwt(e){let t={},n=e.vertexAttributes;for(let i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function Lwt(e,t){let n=e.context,i=t,o=i.fragmentShaderSource.clone(),r=[];o.sources=o.sources.map(function(f){f=We.replaceMain(f,"czm_Debug_main");let h=/out_FragData_(\d+)/g,p;for(;(p=h.exec(f))!==null;)r.indexOf(p[1])===-1&&r.push(p[1]);return f});let a=r.length,s="";s+=`uniform vec3 debugShowCommandsColor;`,s+=`uniform vec3 debugShowFrustumsColor;`,s+=`void main() { czm_Debug_main(); `;let c;if(a>0)for(c=0;c<a;++c)s+=` out_FragData_${r[c]}.rgb *= debugShowCommandsColor;`,s+=` out_FragData_${r[c]}.rgb *= debugShowFrustumsColor;`;else s+=` out_FragColor.rgb *= debugShowCommandsColor;`,s+=` out_FragColor.rgb *= debugShowFrustumsColor;`;s+="}",o.sources.push(s);let u=Nwt(i);return $t.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:o,attributeLocations:u})}var _R=new U;function Owt(e,t){let n;return l(t.uniformMap)?n=t.uniformMap:n={},l(n.debugShowCommandsColor)||l(n.debugShowFrustumsColor)||(n.debugShowCommandsColor=function(){return e.debugShowCommands?(l(t._debugColor)||(t._debugColor=U.fromRandom()),t._debugColor):U.WHITE},n.debugShowFrustumsColor=function(){return e.debugShowFrustums?(_R.red=t.debugOverlappingFrustums&1?1:0,_R.green=t.debugOverlappingFrustums&2?1:0,_R.blue=t.debugOverlappingFrustums&4?1:0,_R.alpha=1,_R):U.WHITE}),n}var Fwt=new it;KSe.prototype.executeDebugShowFrustumsCommand=function(e,t,n){let i=t.shaderProgram.id,o=this._cachedShowFrustumsShaders[i];l(o)||(o=Lwt(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=o);let r=it.shallowClone(t,Fwt);r.shaderProgram=o,r.uniformMap=Owt(e,t),r.execute(e.context,n)};var y4=KSe;function eI(e,t,n){this._primitive=e,this._tileIndex=t,this._sampleIndex=n,this._metadata={},this._orientedBoundingBox=new en}eI.fromKeyframeNode=function(e,t,n,i){let o=new eI(e,t,n),{spatialNode:r,content:a}=i;return o._metadata=Qwt(e,a,n),o._orientedBoundingBox=Uwt(e,r,n,o._orientedBoundingBox),o};function Qwt(e,t,n){if(!l(t)||!l(t.metadata))return;let{names:i,types:o}=e.provider,{metadata:r}=t,a={};for(let s=0;s<i.length;s++){let c=i[s],u=It.getComponentCount(o[s]),f=r[s].slice(n*u,(n+1)*u);a[c]=f}return a}var XSe=new d,kwt=new d;function Uwt(e,t,n,i){let o=t.dimensions,r=o.x*o.y,a=Math.floor(n/r),s=n-a*r,c=Math.floor(s/o.x),u=s-c*o.x,f=d.fromElements(u,c,a,XSe),h=d.divideComponents(d.subtract(f,e._paddingBefore,XSe),e.dimensions,kwt);return e._shape.computeOrientedBoundingBoxForSample(t,e.dimensions,h,i)}Object.defineProperties(eI.prototype,{metadata:{get:function(){return this._metadata}},primitive:{get:function(){return this._primitive}},sampleIndex:{get:function(){return this._sampleIndex}},tileIndex:{get:function(){return this._tileIndex}},orientedBoundingBox:{get:function(){return this._orientedBoundingBox.clone()}}});eI.prototype.hasProperty=function(e){return l(this._metadata[e])};eI.prototype.getNames=function(){return Object.keys(this._metadata)};eI.prototype.getProperty=function(e){return this._metadata[e]};var C4=eI;function zwt(e,t){let{shaderBuilder:n}=e,{names:i,types:o,componentTypes:r,minimumValues:a,maximumValues:s}=t._provider,c=o.length,u=l(a)&&l(s);n.addDefine("METADATA_COUNT",c,he.FRAGMENT),u&&n.addDefine("STATISTICS",void 0,he.FRAGMENT);for(let g=0;g<c;g++){let b=i[g],T=E4(o[g]),B=`PropertyStatistics_${b}`,M=`PropertyStatistics_${b}`;n.addStruct(B,M,he.FRAGMENT),n.addStructField(B,T,"min"),n.addStructField(B,T,"max")}let f="MetadataStatistics",h="MetadataStatistics",p="metadataStatistics";n.addStruct(f,h,he.FRAGMENT);for(let g=0;g<c;g++){let b=i[g],T=`PropertyStatistics_${b}`,B=b;n.addStructField(f,T,B)}let A="Metadata",m="Metadata",_="metadata";n.addStruct(A,m,he.FRAGMENT);for(let g=0;g<c;g++){let b=E4(o[g]);n.addStructField(A,b,i[g])}let y="Attributes",C="Attributes",E="attributes";n.addStruct(y,C,he.FRAGMENT),n.addStructField(y,"vec3","positionEC"),n.addStructField(y,"vec3","normalEC");let I="Voxel",x="Voxel",S="voxel";n.addStruct(I,x,he.FRAGMENT),n.addStructField(I,"vec3","viewDirUv"),n.addStructField(I,"float","travelDistance"),n.addStructField(I,"int","stepCount"),n.addStructField(I,"int","tileIndex"),n.addStructField(I,"int","sampleIndex"),n.addStructField(I,"float","distanceToDepthBuffer");let w="FragmentInput";n.addStruct(w,"FragmentInput",he.FRAGMENT),n.addStructField(w,h,p),n.addStructField(w,m,_),n.addStructField(w,C,E),n.addStructField(w,x,S);let R="Properties",N="Properties",L="properties";n.addStruct(R,N,he.FRAGMENT);for(let g=0;g<c;g++){let b=E4(o[g]);n.addStructField(R,b,i[g])}{let g="clearProperties";n.addFunction(g,`${N} clearProperties()`,he.FRAGMENT),n.addFunctionLines(g,[`${N} ${L};`]);for(let b=0;b<c;b++){let T=E4(o[b],r[b]);n.addFunctionLines(g,[`${L}.${i[b]} = ${T}(0.0);`])}n.addFunctionLines(g,[`return ${L};`])}{let g="sumProp
vec3 pos; vec3 dir;};
float minComponent(in vec3 v) { return min(min(v.x, v.y), v.z);}
float maxComponent(in vec3 v) { return max(max(v.x, v.y), v.z);}`;var x4=`// See Intersection.glsl for the definition of intersectScene
// See IntersectionUtils.glsl for the definition of nextIntersection
// See convertLocalToBoxUv.glsl, convertLocalToCylinderUv.glsl, or convertLocalToEllipsoidUv.glsl
// for the definitions of convertLocalToShapeSpaceDerivative and getTileAndUvCoordinate.
// The appropriate functions are 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
#if defined(PICKING_VOXEL) #define ALPHA_ACCUM_MAX 0.1#else #define ALPHA_ACCUM_MAX 0.98 // Must be > 0.0 and <= 1.0
#endif
uniform mat4 u_transformPositionViewToLocal;uniform mat3 u_transformDirectionViewToLocal;uniform vec3 u_cameraPositionLocal;uniform vec3 u_cameraDirectionLocal;uniform float u_stepSize;
#if defined(PICKING) uniform vec4 u_pickColor;#endif
vec3 getSampleSize(in int level) { vec3 sampleCount = exp2(float(level)) * vec3(u_dimensions); vec3 sampleSizeUv = 1.0 / sampleCount; return scaleShapeUvToShapeSpace(sampleSizeUv);}
#define MINIMUM_STEP_SCALAR (0.02)#define SHIFT_FRACTION (0.001)
/** * Given a coordinate within a tile, and sample spacings along a ray through * the coordinate, find the distance to the points where the ray entered and * exited the voxel cell, along with the surface normals at those points. * The surface normals are returned in shape space coordinates. */RayShapeIntersection getVoxelIntersection(in vec3 tileUv, in vec3 sampleSizeAlongRay) { vec3 voxelCoord = tileUv * vec3(u_dimensions); vec3 directions = sign(sampleSizeAlongRay); vec3 positiveDirections = max(directions, 0.0); vec3 entryCoord = mix(ceil(voxelCoord), floor(voxelCoord), positiveDirections); vec3 exitCoord = entryCoord + directions;
vec3 distanceFromEntry = -abs((entryCoord - voxelCoord) * sampleSizeAlongRay); float lastEntry = maxComponent(distanceFromEntry); bvec3 isLastEntry = equal(distanceFromEntry, vec3(lastEntry)); vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions; vec4 entry = vec4(entryNormal, lastEntry);
vec3 distanceToExit = abs((exitCoord - voxelCoord) * sampleSizeAlongRay); float firstExit = minComponent(distanceToExit); bvec3 isFirstExit = equal(distanceToExit, vec3(firstExit)); vec3 exitNormal = vec3(isFirstExit) * directions; vec4 exit = vec4(exitNormal, firstExit);
return RayShapeIntersection(entry, exit);}
vec4 getStepSize(in SampleData sampleData, in Ray viewRay, in RayShapeIntersection shapeIntersection, in mat3 jacobianT, in float currentT) { vec3 gradient = viewRay.dir * jacobianT; vec3 sampleSizeAlongRay = getSampleSize(sampleData.tileCoords.w) / gradient;
RayShapeIntersection voxelIntersection = getVoxelIntersection(sampleData.tileUv, sampleSizeAlongRay);
// Transform normal from shape space to Cartesian space to eye space
vec3 voxelNormal = jacobianT * voxelIntersection.entry.xyz; voxelNormal = normalize(czm_normal * voxelNormal);
// Compare with the shape intersection, to choose the appropriate normal
vec4 voxelEntry = vec4(voxelNormal, currentT + voxelIntersection.entry.w); vec4 entry = intersectionMax(shapeIntersection.entry, voxelEntry);
float fixedStep = minComponent(abs(sampleSizeAlongRay)) * u_stepSize; float shift = fixedStep * SHIFT_FRACTION; float dt = voxelIntersection.exit.w + shift; if ((currentT + dt) > shapeIntersection.exit.w) { // Stop at end of shape
dt = shapeIntersection.exit.w - currentT + shift; } float stepSize = clamp(dt, fixedStep * MINIMUM_STEP_SCALAR, fixedStep + shift);
return vec4(entry.xyz, stepSize);}
vec2 packIntToVec2(int value) { float shifted = float(value) / 255.0; float lowBits = fract(shifted); float highBits = floor(shifted) / 255.0; return vec2(highBits, lowBits);}
vec2 packFloatToVec2(float value) { float lowBits = fract(value); float highBits = floor(value) / 255.0; return vec2(highBits, lowBits);}
int getSampleIndex(in SampleData sampleData) { // tileUv = 1.0 is a valid coordinate but sampleIndex = u_inputDimensions is not.
// (tileUv = 1.0 corresponds to the far edge of the last sample, at index = u_inputDimensions - 1).
// Clamp to [0, voxelDimensions - 0.5) to avoid numerical error before flooring
vec3 maxCoordinate = vec3(u_inputDimensions) - vec3(0.5); vec3 inputCoordinate = clamp(sampleData.inputCoordinate, vec3(0.0), maxCoordinate); ivec3 sampleIndex = ivec3(floor(inputCoordinate)); // Convert to a 1D index for lookup in a 1D data array
return sampleIndex.x + u_inputDimensions.x * (sampleIndex.y + u_inputDimensions.y * sampleIndex.z);}
/** * Compute the view ray at the current fragment, in the local coordinates of the shape. */Ray getViewRayLocal() { vec4 eyeCoordinates = czm_windowToEyeCoordinates(gl_FragCoord); vec3 origin; vec3 direction; if (czm_orthographicIn3D == 1.0) { eyeCoordinates.z = 0.0; origin = (u_transformPositionViewToLocal * eyeCoordinates).xyz; direction = u_cameraDirectionLocal; } else { origin = u_cameraPositionLocal; direction = u_transformDirectionViewToLocal * normalize(eyeCoordinates.xyz); } return Ray(origin, direction);}
Ray getViewRayEC() { vec4 eyeCoordinates = czm_windowToEyeCoordinates(gl_FragCoord); vec3 viewPosEC = (czm_orthographicIn3D == 1.0) ? vec3(eyeCoordinates.xy, 0.0) : vec3(0.0); vec3 viewDirEC = normalize(eyeCoordinates.xyz); return Ray(viewPosEC, viewDirEC);}
void main(){ Ray viewRayLocal = getViewRayLocal(); Ray viewRayEC = getViewRayEC();
Intersections ix; vec2 screenCoord = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw; // [0,1]
RayShapeIntersection shapeIntersection = intersectScene(screenCoord, viewRayLocal, viewRayEC, ix); // Exit early if the scene was completely missed.
if (shapeIntersection.entry.w == NO_HIT) { discard; }
float currentT = shapeIntersection.entry.w; float endT = shapeIntersection.exit.w;
vec3 positionEC = viewRayEC.pos + currentT * viewRayEC.dir; TileAndUvCoordinate tileAndUv = getTileAndUvCoordinate(positionEC); vec3 positionLocal = viewRayLocal.pos + currentT * viewRayLocal.dir; mat3 jacobianT = convertLocalToShapeSpaceDerivative(positionLocal);
// Traverse the tree from the start position
TraversalData traversalData; SampleData sampleDatas[SAMPLE_COUNT]; traverseOctreeFromBeginning(tileAndUv, traversalData, sampleDatas); vec4 step = getStepSize(sampleDatas[0], viewRayLocal, shapeIntersection, jacobianT, currentT);
FragmentInput fragmentInput; #if defined(STATISTICS) setStatistics(fragmentInput.metadataStatistics); #endif
czm_modelMaterial materialOutput; 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.attributes.positionEC = positionEC; // Re-normalize normals: some shape intersections may have been scaled to encode positive/negative shapes
fragmentInput.attributes.normalEC = normalize(step.xyz);
fragmentInput.voxel.viewDirUv = viewRayLocal.dir;
fragmentInput.voxel.travelDistance = step.w; fragmentInput.voxel.stepCount = stepCount; fragmentInput.voxel.tileIndex = sampleDatas[0].megatextureIndex; fragmentInput.voxel.sampleIndex = getSampleIndex(sampleDatas[0]); fragmentInput.voxel.distanceToDepthBuffer = ix.distanceToDepthBuffer - currentT;
// Run the custom shader
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.001; }
// Keep raymarching
currentT += step.w; // Check if there's more intersections.
if (currentT > endT) { #if (INTERSECTION_COUNT == 1) break; #else shapeIntersection = nextIntersection(ix); if (shapeIntersection.entry.w == NO_HIT) { break; } else { // Found another intersection. Resume raymarching there
currentT = shapeIntersection.entry.w; endT = shapeIntersection.exit.w; } #endif } positionEC = viewRayEC.pos + currentT * viewRayEC.dir; tileAndUv = getTileAndUvCoordinate(positionEC); positionLocal = viewRayLocal.pos + currentT * viewRayLocal.dir; jacobianT = convertLocalToShapeSpaceDerivative(positionLocal);
// 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.
traverseOctreeFromExisting(tileAndUv, traversalData, sampleDatas); step = getStepSize(sampleDatas[0], viewRayLocal, shapeIntersection, jacobianT, currentT); }
// 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; #elif defined(PICKING_VOXEL) // If alpha is 0.0 there is nothing to pick
if (colorAccum.a == 0.0) { discard; } vec2 megatextureId = packIntToVec2(sampleDatas[0].megatextureIndex); vec2 sampleIndex = packIntToVec2(getSampleIndex(sampleDatas[0])); out_FragColor = vec4(megatextureId, sampleIndex); #else out_FragColor = colorAccum; #endif}`;var T4=`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 S4=`/* Intersection defines#define INTERSECTION_COUNT ###*/
#define NO_HIT (-czm_infinity)#define INF_HIT (czm_infinity * 0.5)
struct RayShapeIntersection { vec4 entry; vec4 exit;};
vec4 intersectionMin(in vec4 intersect0, in vec4 intersect1){ if (intersect0.w == NO_HIT) { return intersect1; } else if (intersect1.w == NO_HIT) { return intersect0; } return (intersect0.w <= intersect1.w) ? intersect0 : intersect1;}
vec4 intersectionMax(in vec4 intersect0, in vec4 intersect1){ return (intersect0.w >= intersect1.w) ? intersect0 : intersect1;}
RayShapeIntersection intersectIntersections(in Ray ray, in RayShapeIntersection intersect0, in RayShapeIntersection intersect1){ bool missed = (intersect0.entry.w == NO_HIT) || (intersect1.entry.w == NO_HIT) || (intersect0.exit.w < intersect1.entry.w) || (intersect0.entry.w > intersect1.exit.w); if (missed) { vec4 miss = vec4(normalize(ray.dir), NO_HIT); return RayShapeIntersection(miss, miss); }
vec4 entry = intersectionMax(intersect0.entry, intersect1.entry); vec4 exit = intersectionMin(intersect0.exit, intersect1.exit);
return RayShapeIntersection(entry, 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]; float distanceToDepthBuffer;
#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, /*bool*/ positive, /*bool*/ enter) (ix).intersections[(index)] = encodeIntersectionType((intersection), int(!positive), (enter))#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 = 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 w4=`// 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 ###*/
void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) { float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord)); float entry; float exit; 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; entry = dot(eyeCoordinateDepth.xyz - ray.pos, ray.dir); exit = +INF_HIT; } else { // There's no depth at this location.
entry = NO_HIT; exit = NO_HIT; } ix.distanceToDepthBuffer = entry;#if defined(DEPTH_TEST) setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(entry, exit));#endif}`;var B4=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,
// NO_HIT, setShapeIntersection
/* 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);}
#ifdef CLIPPING_PLANESvoid 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); 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); 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); 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}#endif`;var yR=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, INF_HIT,
// RayShapeIntersection
vec4 transformNormalToEC(in vec4 intersection) { return vec4(normalize(czm_normal * intersection.xyz), intersection.w);}
RayShapeIntersection transformNormalsToEC(in RayShapeIntersection ix) { return RayShapeIntersection(transformNormalToEC(ix.entry), transformNormalToEC(ix.exit));}
vec4 intersectLongitude(in Ray ray, in float angle, in bool positiveNormal) { float normalSign = positiveNormal ? 1.0 : -1.0; vec2 planeNormal = vec2(-sin(angle), cos(angle)) * normalSign;
vec2 position = ray.pos.xy; vec2 direction = ray.dir.xy; float approachRate = dot(direction, planeNormal); float distance = -dot(position, planeNormal);
float t = (approachRate == 0.0) ? NO_HIT : distance / approachRate;
return vec4(planeNormal, 0.0, t);}
RayShapeIntersection intersectHalfSpace(in Ray ray, in float angle, in bool positiveNormal){ vec4 intersection = intersectLongitude(ray, angle, positiveNormal); vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
bool hitFront = (intersection.w > 0.0) == (dot(ray.pos.xy, intersection.xy) > 0.0); if (!hitFront) { return RayShapeIntersection(intersection, farSide); } else { return RayShapeIntersection(-1.0 * farSide, intersection); }}
void intersectFlippedWedge(in Ray ray, in vec2 minMaxAngle, out RayShapeIntersection intersections[2]){ intersections[0] = transformNormalsToEC(intersectHalfSpace(ray, minMaxAngle.x, false)); intersections[1] = transformNormalsToEC(intersectHalfSpace(ray, minMaxAngle.y, true));}
bool hitPositiveHalfPlane(in Ray ray, in vec4 intersection, in bool positiveNormal) { float normalSign = positiveNormal ? 1.0 : -1.0; vec2 planeDirection = vec2(intersection.y, -intersection.x) * normalSign; vec2 hit = ray.pos.xy + intersection.w * ray.dir.xy; return dot(hit, planeDirection) > 0.0;}
void intersectHalfPlane(in Ray ray, in float angle, out RayShapeIntersection intersections[2]) { vec4 intersection = intersectLongitude(ray, angle, true); vec4 farSide = vec4(normalize(ray.dir), INF_HIT); bool hitPositiveSide = hitPositiveHalfPlane(ray, intersection, true);
farSide = transformNormalToEC(farSide);
if (hitPositiveSide) { intersection = transformNormalToEC(intersection); intersections[0].entry = -1.0 * farSide; intersections[0].exit = vec4(-1.0 * intersection.xyz, intersection.w); intersections[1].entry = intersection; intersections[1].exit = farSide; } else { vec4 miss = vec4(normalize(czm_normal * ray.dir), NO_HIT); intersections[0].entry = -1.0 * farSide; intersections[0].exit = farSide; intersections[1].entry = miss; intersections[1].exit = miss; }}
RayShapeIntersection intersectRegularWedge(in Ray ray, in vec2 minMaxAngle){ // Note: works for maxAngle > minAngle + pi, where the "regular wedge"
// is actually a negative volume.
// Compute intersections with the two planes.
// Normals will point toward the "outside" (negative space)
vec4 intersect1 = intersectLongitude(ray, minMaxAngle.x, false); vec4 intersect2 = intersectLongitude(ray, minMaxAngle.y, true);
// Choose intersection with smallest T as the "first", the other as "last"
// Note: first or last could be in the "shadow" wedge, beyond the tip
bool inOrder = intersect1.w <= intersect2.w; vec4 first = inOrder ? intersect1 : intersect2; vec4 last = inOrder ? intersect2 : intersect1;
bool firstIsAhead = first.w >= 0.0; bool startedInsideFirst = dot(ray.pos.xy, first.xy) < 0.0; bool exitFromInside = firstIsAhead == startedInsideFirst; bool lastIsAhead = last.w > 0.0; bool startedOutsideLast = dot(ray.pos.xy, last.xy) >= 0.0; bool enterFromOutside = lastIsAhead == startedOutsideLast;
vec4 farSide = vec4(normalize(ray.dir), INF_HIT); vec4 miss = vec4(normalize(ray.dir), NO_HIT);
if (exitFromInside && enterFromOutside) { // Ray crosses both faces of negative wedge, exiting then entering the positive shape
return transformNormalsToEC(RayShapeIntersection(first, last)); } else if (!exitFromInside && enterFromOutside) { // Ray starts inside wedge. last is in shadow wedge, and first is actually the entry
return transformNormalsToEC(RayShapeIntersection(-1.0 * farSide, first)); } else if (exitFromInside && !enterFromOutside) { // First intersection was in the shadow wedge, so last is actually the exit
return transformNormalsToEC(RayShapeIntersection(last, farSide)); } else { // !exitFromInside && !enterFromOutside
// Both intersections were in the shadow wedge
return transformNormalsToEC(RayShapeIntersection(miss, miss)); }}`;var D4=`// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,
// NO_HIT, Intersections
/* Box defines (set in Scene/VoxelBoxShape.js)#define BOX_INTERSECTION_INDEX ### // always 0
*/
uniform sampler2D u_renderBoundPlanesTexture;
RayShapeIntersection intersectBoundPlanes(in Ray ray) { vec4 lastEntry = vec4(ray.dir, -INF_HIT); vec4 firstExit = vec4(-ray.dir, +INF_HIT); for (int i = 0; i < 6; i++) { vec4 boundPlane = getBoundPlane(u_renderBoundPlanesTexture, i); vec4 intersection = intersectPlane(ray, boundPlane); if (dot(ray.dir, boundPlane.xyz) < 0.0) { lastEntry = intersection.w > lastEntry.w ? intersection : lastEntry; } else { firstExit = intersection.w < firstExit.w ? intersection: firstExit; } }
if (lastEntry.w < firstExit.w) { return RayShapeIntersection(lastEntry, firstExit); } else { return RayShapeIntersection(vec4(-ray.dir, NO_HIT), vec4(ray.dir, NO_HIT)); }}
void intersectShape(in Ray rayUV, in Ray rayEC, inout Intersections ix){ RayShapeIntersection intersection = intersectBoundPlanes(rayEC); setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);}`;var v4=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, Intersections,
// RayShapeIntersection, setSurfaceIntersection, setShapeIntersection,
// intersectIntersections
// See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
// intersectFlippedWedge, intersectRegularWedge
/* Cylinder defines (set in Scene/VoxelCylinderShape.js)#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN#define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_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_ZERO
#define CYLINDER_INTERSECTION_INDEX_RADIUS_MAX#define CYLINDER_INTERSECTION_INDEX_RADIUS_MIN#define CYLINDER_INTERSECTION_INDEX_ANGLE*/
// Cylinder uniforms
uniform vec2 u_cylinderRenderRadiusMinMax;#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE) uniform vec2 u_cylinderRenderAngleMinMax;#endif
uniform sampler2D u_renderBoundPlanesTexture;
RayShapeIntersection intersectBoundPlanes(in Ray ray) { vec4 lastEntry = vec4(ray.dir, -INF_HIT); vec4 firstExit = vec4(-ray.dir, +INF_HIT); for (int i = 0; i < 2; i++) { vec4 boundPlane = getBoundPlane(u_renderBoundPlanesTexture, i); vec4 intersection = intersectPlane(ray, boundPlane); if (dot(ray.dir, boundPlane.xyz) < 0.0) { lastEntry = intersection.w > lastEntry.w ? intersection : lastEntry; } else { firstExit = intersection.w < firstExit.w ? intersection: firstExit; } }
if (lastEntry.w < firstExit.w) { return RayShapeIntersection(lastEntry, firstExit); } else { return RayShapeIntersection(vec4(-ray.dir, NO_HIT), vec4(ray.dir, NO_HIT)); }}
/** * Find the intersection of a ray with a right cylindrical surface of a given radius * about the z-axis. */RayShapeIntersection intersectCylinder(in Ray ray, in float radius, in bool convex){ vec2 position = ray.pos.xy; vec2 direction = ray.dir.xy;
float a = dot(direction, direction); float b = dot(position, direction); float c = dot(position, position) - radius * radius; float determinant = b * b - a * c;
if (determinant < 0.0) { vec4 miss = vec4(normalize(ray.dir), NO_HIT); return RayShapeIntersection(miss, miss); }
determinant = sqrt(determinant); float t1 = (-b - determinant) / a; float t2 = (-b + determinant) / a; float signFlip = convex ? 1.0 : -1.0; vec3 normal1 = vec3((position + t1 * direction) * signFlip, 0.0); vec3 normal2 = vec3((position + t2 * direction) * signFlip, 0.0); // Return normals in eye coordinates
vec4 intersect1 = vec4(normalize(czm_normal * normal1), t1); vec4 intersect2 = vec4(normalize(czm_normal * normal2), t2);
return RayShapeIntersection(intersect1, intersect2);}
/** * Find the intersection of a ray with a right cylindrical solid of given * radius and height bounds. NOTE: The shape is assumed to be convex. */RayShapeIntersection intersectBoundedCylinder(in Ray ray, in Ray rayEC, in float radius){ RayShapeIntersection cylinderIntersection = intersectCylinder(ray, radius, true); RayShapeIntersection heightBoundsIntersection = intersectBoundPlanes(rayEC); return intersectIntersections(ray, cylinderIntersection, heightBoundsIntersection);}
void intersectShape(in Ray ray, in Ray rayEC, inout Intersections ix){ RayShapeIntersection outerIntersect = intersectBoundedCylinder(ray, rayEC, u_cylinderRenderRadiusMinMax.y);
setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);
if (outerIntersect.entry.w == 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.
RayShapeIntersection innerIntersect = intersectCylinder(ray, 1.0, false); setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter
setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter
setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit
setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit
#elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN) RayShapeIntersection innerIntersect = intersectCylinder(ray, u_cylinderRenderRadiusMinMax.x, false); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect); #endif
#if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF) RayShapeIntersection wedgeIntersect = intersectRegularWedge(ray, u_cylinderRenderAngleMinMax); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect); #elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF) RayShapeIntersection wedgeIntersects[2]; intersectFlippedWedge(ray, u_cylinderRenderAngleMinMax, wedgeIntersects); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]); #elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO) RayShapeIntersection wedgeIntersects[2]; intersectHalfPlane(ray, u_cylinderRenderAngleMinMax.x, wedgeIntersects); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]); setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]); #endif}`;var P4=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, INF_HIT, Intersections,
// RayShapeIntersection, setSurfaceIntersection, setShapeIntersection
// See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
// intersectFlippedWedge, intersectRegularWedge
/* 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_OVER_HALF#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_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;#endifuniform float u_eccentricitySquared;uniform vec2 u_ellipsoidRenderLatitudeSinMinMax;uniform vec2 u_clipMinMaxHeight; // Values are negative: clipHeight - maxShapeHeight
RayShapeIntersection intersectZPlane(in Ray ray, in float z) { float t = -ray.pos.z / ray.dir.z;
bool startsOutside = sign(ray.pos.z) == sign(z); bool entry = (t >= 0.0) != startsOutside;
vec4 intersect = vec4(0.0, 0.0, z, t); vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
if (entry) { return RayShapeIntersection(intersect, farSide); } else { return RayShapeIntersection(-1.0 * farSide, intersect); }}
RayShapeIntersection intersectHeight(in Ray ray, in float height, in bool convex){ // Scale the ray by the ellipsoid axes to make it a unit sphere
// Note: approximating ellipsoid + height as an ellipsoid
vec3 radiiCorrection = vec3(1.0) / (u_ellipsoidRadii + height); vec3 position = ray.pos * radiiCorrection; vec3 direction = ray.dir * radiiCorrection;
float a = dot(direction, direction); // ~ 1.0 (or maybe 4.0 if ray is scaled)
float b = dot(direction, position); // roughly inside [-1.0, 1.0] when zoomed in
float c = dot(position, position) - 1.0; // ~ 0.0 when zoomed in.
float determinant = b * b - a * c; // ~ b * b when zoomed in
if (determinant < 0.0) { vec4 miss = vec4(normalize(direction), NO_HIT); return RayShapeIntersection(miss, miss); }
determinant = sqrt(determinant);
// Compute larger root using standard formula
float signB = b < 0.0 ? -1.0 : 1.0; // The other root may suffer from subtractive cancellation in the standard formula.
// Compute it from the first root instead.
float t1 = (-b - signB * determinant) / a; float t2 = c / (a * t1); float tmin = min(t1, t2); float tmax = max(t1, t2);
float directionScale = convex ? 1.0 : -1.0; vec3 d1 = directionScale * (position + tmin * direction); vec3 d2 = directionScale * (position + tmax * direction);
// Return normals in eye coordinates. Use spherical approximation for the normal.
vec3 normal1 = normalize(czm_normal * d1); vec3 normal2 = normalize(czm_normal * d2);
return RayShapeIntersection(vec4(normal1, tmin), vec4(normal2, tmax));}
/** * Given a circular cone around the z-axis, with apex at the origin, * find the parametric distance(s) along a ray where that ray intersects * the cone. * The cone opening angle is described by the squared cosine of * its half-angle (the angle between the Z-axis and the surface) */vec2 intersectDoubleEndedCone(in Ray ray, in float cosSqrHalfAngle){ vec3 o = ray.pos; vec3 d = ray.dir; float sinSqrHalfAngle = 1.0 - cosSqrHalfAngle;
float aSin = d.z * d.z * sinSqrHalfAngle; float aCos = -dot(d.xy, d.xy) * cosSqrHalfAngle; float a = aSin + aCos;
float bSin = d.z * o.z * sinSqrHalfAngle; float bCos = -dot(o.xy, d.xy) * cosSqrHalfAngle; float b = bSin + bCos;
float cSin = o.z * o.z * sinSqrHalfAngle; float cCos = -dot(o.xy, o.xy) * cosSqrHalfAngle; float c = cSin + cCos; // determinant = b * b - a * c. But bSin * bSin = aSin * cSin.
// Avoid subtractive cancellation by expanding to eliminate these terms
float determinant = 2.0 * bSin * bCos + bCos * bCos - aSin * cCos - aCos * cSin - aCos * cCos;
if (determinant < 0.0) { return vec2(NO_HIT); } else if (a == 0.0) { // Ray is parallel to cone surface
return (b == 0.0) ? vec2(NO_HIT) // Ray is on cone surface
: vec2(-0.5 * c / b, NO_HIT); }
determinant = sqrt(determinant);
// Compute larger root using standard formula
float signB = b < 0.0 ? -1.0 : 1.0; float t1 = (-b - signB * determinant) / a; // The other root may suffer from subtractive cancellation in the standard formula.
// Compute it from the first root instead.
float t2 = c / (a * t1); float tmin = min(t1, t2); float tmax = max(t1, t2); return vec2(tmin, tmax);}
/** * Given a point on a conical surface, find the surface normal at that point. */vec3 getConeNormal(in vec3 p, in bool convex) { // Start with radial component pointing toward z-axis
vec2 radial = -abs(p.z) * normalize(p.xy); // Z component points toward opening of cone
float zSign = (p.z < 0.0) ? -1.0 : 1.0; float z = length(p.xy) * zSign; // Flip normal if shape is convex
float flip = (convex) ? -1.0 : 1.0; return normalize(vec3(radial, z) * flip);}
/** * Compute the shift between the ellipsoid origin and the apex of a cone of latitude */float getLatitudeConeShift(in float sinLatitude) { // Find prime vertical radius of curvature:
// the distance along the ellipsoid normal to the intersection with the z-axis
float x2 = u_eccentricitySquared * sinLatitude * sinLatitude; float primeVerticalRadius = u_ellipsoidRadii.x * inversesqrt(1.0 - x2);
// Compute a shift from the origin to the intersection of the cone with the z-axis
return primeVerticalRadius * u_eccentricitySquared * sinLatitude;}
void intersectFlippedCone(in Ray ray, in float cosHalfAngle, out RayShapeIntersection intersections[2]) { // Shift the ray to account for the latitude cone not being centered at the Earth center
ray.pos.z += getLatitudeConeShift(cosHalfAngle);
float cosSqrHalfAngle = cosHalfAngle * cosHalfAngle; vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
vec4 miss = vec4(normalize(ray.dir), NO_HIT); vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
// Initialize output with no intersections
intersections[0].entry = -1.0 * farSide; intersections[0].exit = farSide; intersections[1].entry = miss; intersections[1].exit = miss;
if (intersect.x == NO_HIT) { return; }
// Find the points of intersection
float tmin = intersect.x; float tmax = intersect.y; vec3 p0 = ray.pos + tmin * ray.dir; vec3 p1 = ray.pos + tmax * ray.dir;
vec4 intersect0 = vec4(getConeNormal(p0, true), tmin); vec4 intersect1 = vec4(getConeNormal(p1, true), tmax);
bool p0InShadowCone = sign(p0.z) != sign(cosHalfAngle); bool p1InShadowCone = sign(p1.z) != sign(cosHalfAngle);
if (p0InShadowCone && p1InShadowCone) { // no valid intersections
} else if (p0InShadowCone) { intersections[0].exit = intersect1; } else if (p1InShadowCone) { intersections[0].entry = intersect0; } else { intersections[0].exit = intersect0; intersections[1].entry = intersect1; intersections[1].exit = farSide; }}
RayShapeIntersection intersectRegularCone(in Ray ray, in float cosHalfAngle, in bool convex) { // Shift the ray to account for the latitude cone not being centered at the Earth center
ray.pos.z += getLatitudeConeShift(cosHalfAngle);
float cosSqrHalfAngle = cosHalfAngle * cosHalfAngle; vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
vec4 miss = vec4(normalize(ray.dir), NO_HIT); vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
if (intersect.x == NO_HIT) { return RayShapeIntersection(miss, miss); }
// Find the points of intersection
float tmin = intersect.x; float tmax = intersect.y; vec3 p0 = ray.pos + tmin * ray.dir; vec3 p1 = ray.pos + tmax * ray.dir;
vec4 intersect0 = vec4(getConeNormal(p0, convex), tmin); vec4 intersect1 = vec4(getConeNormal(p1, convex), tmax);
bool p0InShadowCone = sign(p0.z) != sign(cosHalfAngle); bool p1InShadowCone = sign(p1.z) != sign(cosHalfAngle);
if (p0InShadowCone && p1InShadowCone) { return RayShapeIntersection(miss, miss); } else if (p0InShadowCone) { return RayShapeIntersection(intersect1, farSide); } else if (p1InShadowCone) { return RayShapeIntersection(-1.0 * farSide, intersect0); } else { return RayShapeIntersection(intersect0, intersect1); }}
void intersectShape(in Ray ray, in Ray rayEC, inout Intersections ix) { // Outer ellipsoid
RayShapeIntersection outerIntersect = intersectHeight(ray, u_clipMinMaxHeight.y, true); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX, outerIntersect);
// Exit early if the outer ellipsoid was missed.
if (outerIntersect.entry.w == NO_HIT) { return; }
// Inner ellipsoid
RayShapeIntersection innerIntersect = intersectHeight(ray, u_clipMinMaxHeight.x, false);
if (innerIntersect.entry.w == NO_HIT) { setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN, innerIntersect); } else { // When the ellipsoid is 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
// 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.
innerIntersect.entry.w = max(innerIntersect.entry.w, outerIntersect.entry.w); innerIntersect.exit.w = min(innerIntersect.exit.w, outerIntersect.exit.w); setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter
setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter
setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit
setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit
}
// Bottom cone
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF) RayShapeIntersection bottomConeIntersection = intersectRegularCone(ray, u_ellipsoidRenderLatitudeSinMinMax.x, false); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF) RayShapeIntersection bottomConeIntersection = intersectZPlane(ray, -1.0); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF) RayShapeIntersection bottomConeIntersections[2]; intersectFlippedCone(ray, u_ellipsoidRenderLatitudeSinMinMax.x, bottomConeIntersections); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 0, bottomConeIntersections[0]); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 1, bottomConeIntersections[1]); #endif
// Top cone
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF) RayShapeIntersection topConeIntersections[2]; intersectFlippedCone(ray, u_ellipsoidRenderLatitudeSinMinMax.y, topConeIntersections); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 0, topConeIntersections[0]); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 1, topConeIntersections[1]); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF) RayShapeIntersection topConeIntersection = intersectZPlane(ray, 1.0); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF) RayShapeIntersection topConeIntersection = intersectRegularCone(ray, u_ellipsoidRenderLatitudeSinMinMax.y, false); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection); #endif
// Wedge
#if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO) RayShapeIntersection wedgeIntersects[2]; intersectHalfPlane(ray, u_ellipsoidRenderLongitudeMinMax.x, wedgeIntersects); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersects[0]); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersects[1]); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF) RayShapeIntersection wedgeIntersect = intersectRegularWedge(ray, u_ellipsoidRenderLongitudeMinMax); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE, wedgeIntersect); #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF) RayShapeIntersection wedgeIntersects[2]; intersectFlippedWedge(ray, u_ellipsoidRenderLongitudeMinMax, wedgeIntersects); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersects[0]); setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersects[1]); #endif}`;var GS=`// 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, in Ray rayEC, out Intersections ix) { // Do a ray-shape intersection to find the exact starting and ending points.
intersectShape(ray, rayEC, 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
intersectDepth(screenCoord, rayEC, ix);
// 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 R4=`uniform vec3 u_boxLocalToShapeUvScale;uniform vec3 u_boxLocalToShapeUvTranslate;
uniform ivec4 u_cameraTileCoordinates;uniform vec3 u_cameraTileUv;uniform mat3 u_boxEcToXyz;
mat3 convertLocalToShapeSpaceDerivative(in vec3 positionLocal) { // For BOX, local space = shape space, so the Jacobian is the identity matrix.
return mat3(1.0);}
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) { return shapeUv / u_boxLocalToShapeUvScale;}
vec3 convertEcToDeltaTile(in vec3 positionEC) { vec3 dPosition = u_boxEcToXyz * positionEC; return u_boxLocalToShapeUvScale * dPosition * float(1 << u_cameraTileCoordinates.w);}
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) { vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC); vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate; ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum)); tileCoordinate = min(max(ivec3(0), tileCoordinate), ivec3((1 << u_cameraTileCoordinates.w) - 1)); ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz; vec3 tileUv = clamp(tileUvSum - vec3(tileCoordinateChange), 0.0, 1.0); return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);}`;var M4=`uniform vec2 u_cylinderLocalToShapeUvRadius; // x = scale, y = offset
uniform vec2 u_cylinderLocalToShapeUvHeight; // x = scale, y = offset
uniform vec2 u_cylinderLocalToShapeUvAngle; // x = scale, y = offset
uniform float u_cylinderShapeUvAngleRangeOrigin;uniform mat3 u_cylinderEcToRadialTangentUp;uniform ivec4 u_cameraTileCoordinates;uniform vec3 u_cameraTileUv;uniform vec3 u_cameraShapePosition; // (radial distance, angle, height) of camera in shape space
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) { vec3 radial = normalize(vec3(position.xy, 0.0)); vec3 z = vec3(0.0, 0.0, 1.0); vec3 east = normalize(vec3(-position.y, position.x, 0.0)); return mat3(radial, east / length(position.xy), z);}
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) { float radius = shapeUv.x / u_cylinderLocalToShapeUvRadius.x; float angle = shapeUv.y * czm_twoPi / u_cylinderLocalToShapeUvAngle.x; float height = shapeUv.z / u_cylinderLocalToShapeUvHeight.x;
return vec3(radius, angle, height);}
/** * Computes the change in polar coordinates given a change in position. * @param {vec2} dPosition The change in position in Cartesian coordinates. * @param {float} cameraRadialDistance The radial distance of the camera from the origin. * @return {vec2} The change in polar coordinates (radial distance, angle). */vec2 computePolarChange(in vec2 dPosition, in float cameraRadialDistance) { float dAngle = atan(dPosition.y, cameraRadialDistance + dPosition.x); // Find the direction of the radial axis at the output angle, in Cartesian coordinates
vec2 outputRadialAxis = vec2(cos(dAngle), sin(dAngle)); float sinHalfAngle = sin(dAngle / 2.0); float versine = 2.0 * sinHalfAngle * sinHalfAngle; float dRadial = dot(dPosition, outputRadialAxis) - cameraRadialDistance * versine; return vec2(dRadial, dAngle);}
vec3 convertEcToDeltaShape(in vec3 positionEC) { // 1. Rotate to radial, tangent, and up coordinates
vec3 rtu = u_cylinderEcToRadialTangentUp * positionEC; // 2. Compute change in angular and radial coordinates.
vec2 dPolar = computePolarChange(rtu.xy, u_cameraShapePosition.x); return vec3(dPolar.xy, rtu.z);}
vec3 convertEcToDeltaTile(in vec3 positionEC) { vec3 deltaShape = convertEcToDeltaShape(positionEC); // Convert to tileset coordinates in [0, 1]
float dx = u_cylinderLocalToShapeUvRadius.x * deltaShape.x; float dy = deltaShape.y / czm_twoPi;#if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE) // Wrap to ensure dy is not crossing through the unoccupied angle range, where
// angle to tile coordinate conversions would be more complicated
float cameraUvAngle = (u_cameraShapePosition.y + czm_pi) / czm_twoPi; float cameraUvAngleShift = fract(cameraUvAngle - u_cylinderShapeUvAngleRangeOrigin); float rawOutputUvAngle = cameraUvAngleShift + dy; float rotation = floor(rawOutputUvAngle); dy -= rotation;#endif dy *= u_cylinderLocalToShapeUvAngle.x; float dz = u_cylinderLocalToShapeUvHeight.x * deltaShape.z; // Convert to tile coordinate changes
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);}
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) { vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC); vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate; ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum)); int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1; tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate); tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)) ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz; if (tileCoordinate.y < 0) { tileCoordinate.y += (maxTileCoordinate + 1); } else if (tileCoordinate.y > maxTileCoordinate) { tileCoordinate.y -= (maxTileCoordinate + 1); }#else tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate); ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;#endif vec3 tileUv = tileUvSum - vec3(tileCoordinateChange); tileUv.x = clamp(tileUv.x, 0.0, 1.0);#if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)) // If there is only one tile spanning 2*PI angle, the coordinate wraps around
tileUv.y = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.y) : clamp(tileUv.y, 0.0, 1.0);#else tileUv.y = clamp(tileUv.y, 0.0, 1.0);#endif tileUv.z = clamp(tileUv.z, 0.0, 1.0); return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);}`;var N4=`/* 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_MIN_MAX_REVERSED#define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE*/
uniform vec3 u_cameraPositionCartographic; // (longitude, latitude, height) in radians and meters
uniform vec2 u_ellipsoidCurvatureAtLatitude;uniform mat3 u_ellipsoidEcToEastNorthUp;uniform vec3 u_ellipsoidRadii;uniform vec2 u_evoluteScale; // (radii.x ^ 2 - radii.z ^ 2) * vec2(1.0, -1.0) / radii;
uniform vec3 u_ellipsoidInverseRadiiSquared;#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_ellipsoidLocalToShapeUvLongitude; // x = scale, y = offset
uniform float u_ellipsoidShapeUvLongitudeRangeOrigin;#endif#if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE) uniform vec2 u_ellipsoidLocalToShapeUvLatitude; // x = scale, y = offset
#endifuniform float u_ellipsoidInverseHeightDifference;
uniform ivec4 u_cameraTileCoordinates;uniform vec3 u_cameraTileUv;
// 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
// Extended to return radius of curvature along with the point
vec3 nearestPointAndRadiusOnEllipse(vec2 pos, vec2 radii) { vec2 p = abs(pos); vec2 inverseRadii = 1.0 / radii;
// We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
// but store the cos and sin of t in a vec2 for efficiency.
// Initial guess: t = pi/4
vec2 tTrigs = vec2(0.7071067811865476); // Initial guess of point on ellipsoid
vec2 v = radii * tTrigs; // Center of curvature of the ellipse at v
vec2 evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;
const int iterations = 3; for (int i = 0; i < iterations; ++i) { // Find the (approximate) intersection of p - evolute with the ellipsoid.
vec2 q = normalize(p - evolute) * length(v - evolute); // Update the estimate of t.
tTrigs = (q + evolute) * inverseRadii; tTrigs = normalize(clamp(tTrigs, 0.0, 1.0)); v = radii * tTrigs; evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs; }
return vec3(v * sign(pos), length(v - evolute));}
mat3 convertLocalToShapeSpaceDerivative(in vec3 position) { vec3 east = normalize(vec3(-position.y, position.x, 0.0));
// Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z)
// (assume radii.y == radii.x) and find the nearest point on the ellipse and its normal
float distanceFromZAxis = length(position.xy); vec2 posEllipse = vec2(distanceFromZAxis, position.z); vec3 surfacePointAndRadius = nearestPointAndRadiusOnEllipse(posEllipse, u_ellipsoidRadii.xz); vec2 surfacePoint = surfacePointAndRadius.xy;
vec2 normal2d = normalize(surfacePoint * u_ellipsoidInverseRadiiSquared.xz); vec3 north = vec3(-normal2d.y * normalize(position.xy), abs(normal2d.x));
float heightSign = length(posEllipse) < length(surfacePoint) ? -1.0 : 1.0; float height = heightSign * length(posEllipse - surfacePoint); vec3 up = normalize(cross(east, north));
return mat3(east / distanceFromZAxis, north / (surfacePointAndRadius.z + height), up);}
vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) { // Convert from [0, 1] to radians [-pi, pi]
float longitude = shapeUv.x * czm_twoPi; #if defined (ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE) longitude /= u_ellipsoidLocalToShapeUvLongitude.x; #endif
// Convert from [0, 1] to radians [-pi/2, pi/2]
float latitude = shapeUv.y * czm_pi; #if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE) latitude /= u_ellipsoidLocalToShapeUvLatitude.x; #endif
float height = shapeUv.z / u_ellipsoidInverseHeightDifference;
return vec3(longitude, latitude, height);}
vec3 convertEcToDeltaShape(in vec3 positionEC) { vec3 enu = u_ellipsoidEcToEastNorthUp * positionEC;
// 1. Compute the change in longitude from the camera to the ENU point
// First project the camera and ENU positions to the equatorial XY plane,
// positioning the camera on the +x axis, so that enu.x projects along the +y axis
float cosLatitude = cos(u_cameraPositionCartographic.y); float sinLatitude = sin(u_cameraPositionCartographic.y); float primeVerticalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.x; vec2 cameraXY = vec2((primeVerticalRadius + u_cameraPositionCartographic.z) * cosLatitude, 0.0); // Note precision loss in positionXY.x if length(enu) << length(cameraXY)
vec2 positionXY = cameraXY + vec2(-enu.y * sinLatitude + enu.z * cosLatitude, enu.x); float dLongitude = atan(positionXY.y, positionXY.x);
// 2. Find the longitude component of positionXY, by rotating about Z until the y component is zero.
// Use the versine to compute the change in x directly from the change in angle:
// versine(angle) = 2 * sin^2(angle/2)
float sinHalfLongitude = sin(dLongitude / 2.0); float dx = length(positionXY) * 2.0 * sinHalfLongitude * sinHalfLongitude; // Rotate longitude component back to ENU North and Up, and remove from enu
enu += vec3(-enu.x, -dx * sinLatitude, dx * cosLatitude);
// 3. Compute the change in latitude from the camera to the ENU point.
// First project the camera and ENU positions to the meridional ZX plane,
// positioning the camera on the +Z axis, so that enu.y maps to the +X axis.
float meridionalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.y; vec2 cameraZX = vec2(meridionalRadius + u_cameraPositionCartographic.z, 0.0); vec2 positionZX = cameraZX + vec2(enu.z, enu.y); float dLatitude = atan(positionZX.y, positionZX.x);
// 4. Compute the change in height above the ellipsoid
// Find the change in enu.z associated with rotating the point to the latitude of the camera
float sinHalfLatitude = sin(dLatitude / 2.0); float dz = length(positionZX) * 2.0 * sinHalfLatitude * sinHalfLatitude; // The remaining change in enu.z is the change in height above the ellipsoid
float dHeight = enu.z + dz;
return vec3(dLongitude, dLatitude, dHeight);}
vec3 convertEcToDeltaTile(in vec3 positionEC) { vec3 deltaShape = convertEcToDeltaShape(positionEC); // Convert to tileset coordinates in [0, 1]
float dx = deltaShape.x / czm_twoPi;
#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)) // Wrap to ensure dx is not crossing through the unoccupied angle range, where
// angle to tile coordinate conversions would be more complicated
float cameraUvLongitude = (u_cameraPositionCartographic.x + czm_pi) / czm_twoPi; float cameraUvLongitudeShift = fract(cameraUvLongitude - u_ellipsoidShapeUvLongitudeRangeOrigin); float rawOutputUvLongitude = cameraUvLongitudeShift + dx; float rotation = floor(rawOutputUvLongitude); dx -= rotation; dx *= u_ellipsoidLocalToShapeUvLongitude.x;#endif
float dy = deltaShape.y / czm_pi;#if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)) dy *= u_ellipsoidLocalToShapeUvLatitude.x;#endif
float dz = u_ellipsoidInverseHeightDifference * deltaShape.z; // Convert to tile coordinate changes
return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);}
TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) { vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC); vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate; ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum)); int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1; tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate); tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)) ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz; if (tileCoordinate.x < 0) { tileCoordinate.x += (maxTileCoordinate + 1); } else if (tileCoordinate.x > maxTileCoordinate) { tileCoordinate.x -= (maxTileCoordinate + 1); }#else tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate); ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;#endif vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);#if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)) // If there is only one tile spanning 2*PI angle, the coordinate wraps around
tileUv.x = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.x) : clamp(tileUv.x, 0.0, 1.0);#else tileUv.x = clamp(tileUv.x, 0.0, 1.0);#endif tileUv.y = clamp(tileUv.y, 0.0, 1.0); tileUv.z = clamp(tileUv.z, 0.0, 1.0); return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);}`;var L4=`// 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;#endifuniform ivec3 u_dimensions; // does not include padding, and is in the z-up orientation
uniform ivec3 u_inputDimensions; // includes padding, and is in the orientation of the input data
#if defined(PADDING) uniform ivec3 u_paddingBefore;#endif
struct OctreeNodeData { int data; int flag;};
struct TraversalData { ivec4 octreeCoords; int parentOctreeIndex;};
struct TileAndUvCoordinate { ivec4 tileCoords; vec3 tileUv;};
struct SampleData { int megatextureIndex; ivec4 tileCoords; vec3 tileUv; vec3 inputCoordinate; #if (SAMPLE_COUNT > 1) float weight; #endif};
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 = (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 = (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;}
vec3 getTileUv(in TileAndUvCoordinate tileAndUv, in ivec4 octreeCoords) { int levelDifference = tileAndUv.tileCoords.w - octreeCoords.w; float scalar = exp2(-1.0 * float(levelDifference)); vec3 originShift = vec3(tileAndUv.tileCoords.xyz - (octreeCoords.xyz << levelDifference)) * scalar; return tileAndUv.tileUv * scalar + originShift;}
vec3 getClampedTileUv(in TileAndUvCoordinate tileAndUv, in ivec4 octreeCoords) { vec3 tileUv = getTileUv(tileAndUv, octreeCoords); return clamp(tileUv, vec3(0.0), vec3(1.0));}
void addSampleCoordinates(in TileAndUvCoordinate tileAndUv, inout SampleData sampleData) { vec3 tileUv = getClampedTileUv(tileAndUv, sampleData.tileCoords);
vec3 inputCoordinate = tileUv * vec3(u_dimensions);#if defined(PADDING) inputCoordinate += vec3(u_paddingBefore);#endif#if defined(Y_UP_METADATA_ORDER)#if defined(SHAPE_BOX) float inputY = inputCoordinate.y; inputCoordinate.y = inputCoordinate.z; // u_inputDimensions.z is the y-up dimension along the 3D Tiles y-axis.
inputCoordinate.z = float(u_inputDimensions.z) - inputY;#elif defined(SHAPE_CYLINDER) float angle = inputCoordinate.y; float height = inputCoordinate.z; #if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)) // Account for the different 0-angle convention in glTF vs 3DTiles
if (sampleData.tileCoords.w == 0) { float angleCount = float(u_inputDimensions.z); angle = mod(angle + angleCount / 2.0, angleCount); } #endif inputCoordinate.y = height; inputCoordinate.z = angle;#endif#endif
sampleData.tileUv = tileUv; sampleData.inputCoordinate = inputCoordinate;}
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((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 ivec4 tileCoordinate, inout TraversalData traversalData) { OctreeNodeData childData;
for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) { // tileCoordinate.xyz is defined at the level of detail tileCoordinate.w.
// Find the corresponding coordinate at the level traversalData.octreeCoords.w
int level = traversalData.octreeCoords.w + 1; int levelDifference = tileCoordinate.w - level; ivec3 coordinateAtLevel = tileCoordinate.xyz >> levelDifference; traversalData.octreeCoords = ivec4(coordinateAtLevel, level);
ivec3 childCoordinate = coordinateAtLevel & 1; childData = getOctreeChildData(traversalData.parentOctreeIndex, childCoordinate);
if (childData.flag != OCTREE_FLAG_INTERNAL) { // leaf tile - stop traversing
break; }
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 TileAndUvCoordinate tileAndUv, 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(tileAndUv.tileCoords, traversalData); }
#if (SAMPLE_COUNT == 1) getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]); addSampleCoordinates(tileAndUv, sampleDatas[0]); #else getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas); addSampleCoordinates(tileAndUv, sampleDatas[0]); addSampleCoordinates(tileAndUv, sampleDatas[1]); #endif}
bool insideTile(in ivec4 tileCoordinate, in ivec4 octreeCoords) { int levelDifference = tileCoordinate.w - octreeCoords.w; if (levelDifference < 0) { return false; } ivec3 coordinateAtLevel = tileCoordinate.xyz >> levelDifference; return coordinateAtLevel == octreeCoords.xyz;}
void traverseOctreeFromExisting(in TileAndUvCoordinate tileAndUv, inout TraversalData traversalData, inout SampleData sampleDatas[SAMPLE_COUNT]) { ivec4 tileCoords = tileAndUv.tileCoords; if (insideTile(tileCoords, traversalData.octreeCoords)) { for (int i = 0; i < SAMPLE_COUNT; i++) { addSampleCoordinates(tileAndUv, sampleDatas[i]); } return; }
// Go up tree until we find a parent tile containing tileCoords.
// Assumes all parents are available all they way up to the root.
for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) { traversalData.octreeCoords.xyz /= 2; traversalData.octreeCoords.w -= 1;
if (insideTile(tileCoords, traversalData.octreeCoords)) { break; }
traversalData.parentOctreeIndex = getOctreeParentIndex(traversalData.parentOctreeIndex); }
// Go down tree
OctreeNodeData nodeData = traverseOctreeDownwards(tileCoords, traversalData);
#if (SAMPLE_COUNT == 1) getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]); addSampleCoordinates(tileAndUv, sampleDatas[0]); #else getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas); addSampleCoordinates(tileAndUv, sampleDatas[0]); addSampleCoordinates(tileAndUv, sampleDatas[1]); #endif}`;var O4=`// See Octree.glsl for the definitions of SampleData
/* Megatexture defines (set in Scene/VoxelRenderResources.js)#define SAMPLE_COUNT ####define PADDING*/
uniform ivec3 u_megatextureTileCounts; // number of tiles in the megatexture, along each axis
vec3 index1DTo3DTexCoord(int index){ int tilesPerZ = u_megatextureTileCounts.x * u_megatextureTileCounts.y; int iz = index / tilesPerZ; int remainder = index - iz * tilesPerZ; int iy = remainder / u_megatextureTileCounts.x; int ix = remainder - iy * u_megatextureTileCounts.x; return vec3(ix, iy, iz) / vec3(u_megatextureTileCounts);}
Properties getPropertiesFromMegatexture(in SampleData sampleData) { int tileIndex = sampleData.megatextureIndex;
vec3 voxelCoord = sampleData.inputCoordinate;
// UV coordinate of the lower corner of the tile in the megatexture
vec3 tileUvOffset = index1DTo3DTexCoord(tileIndex);
// Voxel location
vec3 tileDimensions = vec3(u_inputDimensions); vec3 clampedVoxelCoord = clamp(voxelCoord, vec3(0.5), tileDimensions - vec3(0.5)); vec3 voxelUv = clampedVoxelCoord / tileDimensions / vec3(u_megatextureTileCounts);
return getPropertiesFromMegatextureAtUv(tileUvOffset + voxelUv);}
// 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}`;var Kwt={Z_UP:0,Y_UP:1},Sg=Object.freeze(Kwt);function Xwt(e){let t=new Xg;this.shaderBuilder=t;let n=e._customShader,i=Pt(e._uniformMap,n.uniformMap);e._uniformMap=i;let o=n.uniforms;for(let m in o)if(o.hasOwnProperty(m)){let _=o[m];t.addUniform(_.type,m,he.FRAGMENT)}t.addUniform("sampler3D","u_megatextureTextures[METADATA_COUNT]",he.FRAGMENT),this.uniformMap=i;let r=e._clippingPlanes,a=l(r)&&r.enabled?r.length:0;this.clippingPlanes=r,this.clippingPlanesLength=a;let s=e._shape.renderBoundPlanes,c=s?.length??0;this.renderBoundPlanes=s,this.renderBoundPlanesLength=c,t.addVertexLines([T4]),e.provider.metadataOrder===Sg.Y_UP&&t.addDefine("Y_UP_METADATA_ORDER",void 0,he.FRAGMENT);let u=e._provider.shape;u==="BOX"?t.addDefine("SHAPE_BOX",void 0,he.FRAGMENT):u==="CYLINDER"?t.addDefine("SHAPE_CYLINDER",void 0,he.FRAGMENT):u==="ELLIPSOID"&&t.addDefine("SHAPE_ELLIPSOID",void 0,he.FRAGMENT),t.addFragmentLines([n.fragmentShaderText,"#line 0",L4,b4,O4,S4,B4,w4]),a>0&&(t.addDefine("CLIPPING_PLANES",void 0,he.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",a,he.FRAGMENT),r.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,he.FRAGMENT)),e._depthTest&&t.addDefine("DEPTH_TEST",void 0,he.FRAGMENT),u==="BOX"?t.addFragmentLines([R4,D4,GS]):u==="CYLINDER"?t.addFragmentLines([M4,yR,v4,GS]):u==="ELLIPSOID"&&t.addFragmentLines([N4,yR,P4,GS]),t.addFragmentLines([x4]);let f=e._shape,h=f.shaderDefines;for(let m in h)if(h.hasOwnProperty(m)){let _=h[m];l(_)&&(_=_===!0?void 0:_,t.addDefine(m,_,he.FRAGMENT))}let p=f.shaderMaximumIntersectionsLength;a>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",p,he.FRAGMENT),a===1?p+=1:r.unionClippingRegions?p+=2:p+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",p,he.FRAGMENT),p+=1),t.addDefine("INTERSECTION_COUNT",p,he.FRAGMENT),(!d.equals(e.paddingBefore,d.ZERO)||!d.equals(e.paddingAfter,d.ZERO))&&t.addDefine("PADDING",void 0,he.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,he.FRAGMENT);let A=e._traversal;t.addDefine("SAMPLE_COUNT",`${A._sampleCount}`,he.FRAGMENT)}var F4=Xwt;var nwe=new Q;function Jwt(e,t){let n=new F4(e);I4(n,e);let{shaderBuilder:i,clippingPlanes:o,clippingPlanesLength:r,renderBoundPlanes:a,renderBoundPlanesLength:s}=n;if(r>0){let I="getClippingPlane",x=`vec4 ${I}(highp sampler2D packedPlanes, int planeNumber)`,S=Ca.getTextureResolution(o,t,nwe),w=iwe(S);i.addFunction(I,x,he.FRAGMENT),i.addFunctionLines(I,[w])}if(s>0){let I="getBoundPlane",x=`vec4 ${I}(highp sampler2D packedPlanes, int planeNumber)`,S=CC.getTextureResolution(a,t,nwe),w=iwe(S);i.addFunction(I,x,he.FRAGMENT),i.addFunctionLines(I,[w])}let c=i.clone();c.addDefine("PICKING",void 0,he.FRAGMENT);let u=i.clone();u.addDefine("PICKING_VOXEL",void 0,he.FRAGMENT);let f=i.buildShaderProgram(t),h=c.buildShaderProgram(t),p=u.buildShaderProgram(t),A=Ve.fromCache({cull:{enabled:!0,face:Li.BACK},depthTest:{enabled:!1},depthMask:!1,blending:sn.PRE_MULTIPLIED_ALPHA_BLEND}),m=t.getViewportQuadVertexArray(),_=e._depthTest,y=new it({vertexArray:m,primitiveType:Pe.TRIANGLES,renderState:A,shaderProgram:f,uniformMap:n.uniformMap,modelMatrix:e._compoundModelMatrix,pass:Be.VOXELS,executeInClosestFrustum:!0,owner:this,cull:_,occlude:_}),C=it.shallowClone(y,new it);C.shaderProgram=h,C.pickOnly=!0;let E=it.shallowClone(y,new it);if(E.shaderProgram=p,E.pickOnly=!0,l(e._drawCommand)){let I=e._drawCommand;I.shaderProgram=I.shaderProgram&&I.shaderProgram.destroy()}if(l(e._drawCommandPick)){let I=e._drawCommandPick;I.shaderProgram=I.shaderProgram&&I.shaderProgram.destroy()}if(l(e._drawCommandPickVoxel)){let I=e._drawCommandPickVoxel;I.shaderProgram=I.shaderProgram&&I.shaderProgram.destroy()}e._drawCommand=y,e._drawCommandPick=C,e._drawCommandPickVoxel=E}function iwe(e){let t=e.x,n=e.y,i=1/t,o=1/n,r=`${i}`;r.indexOf(".")===-1&&(r+=".0");let a=`${o}`;return a.indexOf(".")===-1&&(a+=".0"),`int pixY = planeNumber / ${t}; int pixX = planeNumber - (pixY * ${t}); // Sample from center of pixel
float u = (float(pixX) + 0.5) * ${r}; float v = (float(pixY) + 0.5) * ${a}; return texture(packedPlanes, vec2(u, v));`}var Q4=Jwt;var Zwt={FLOAT:"float",VEC2:"vec2",VEC3:"vec3",VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",MAT2:"mat2",MAT3:"mat3",MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"},CR=Object.freeze(Zwt);function VS(){this._defaultTexture=void 0,this._textures={},this._loadedImages=[],this._lastUpdatedFrame=-1}VS.prototype.getTexture=function(e){return this._textures[e]};function $wt(e,t,n){n.resource.fetchImage().then(function(i){e._loadedImages.push({id:t,image:i,textureUniform:n})}).catch(function(){let i=e._textures[t];l(i)&&i!==e._defaultTexture&&i.destroy(),e._textures[t]=e._defaultTexture})}VS.prototype.loadTexture2D=function(e,t){l(t.typedArray)?this._loadedImages.push({id:e,textureUniform:t}):$wt(this,e,t)};function eBt(e,t,n){let{id:i,textureUniform:o,image:r}=t,a=n.webgl2?k4(o,r,n):tBt(o,r,n),s=e._textures[i];l(s)&&s!==n.defaultTexture&&s.destroy(),e._textures[i]=a}function k4(e,t,n){let{typedArray:i,sampler:o}=e,r=l(i)?rwe(e,n):new vt({context:n,source:t,sampler:o});return owe(o)&&r.generateMipmap(),r}function tBt(e,t,n){let{typedArray:i,sampler:o}=e,r=owe(o),a=o.wrapS===pn.REPEAT||o.wrapS===pn.MIRRORED_REPEAT||o.wrapT===pn.REPEAT||o.wrapT===pn.MIRRORED_REPEAT,{width:s,height:c}=l(i)?e:t,u=[s,c].every(D.isPowerOfTwo);if((r||a)&&!u)if(l(i)){if(e.pixelDatatype===He.UNSIGNED_BYTE){let h=LV(i,s,c),p=dE(h);return k4({sampler:o},p,n)}}else{let h=dE(t);return k4(e,h,n)}else return k4(e,t,n);return r?console.warn("Texture requires resizing for mipmaps but pixelDataType cannot be resized. The texture may be rendered incorrectly."):a&&console.warn("Texture requires resizing for wrapping but pixelDataType cannot be resized. The texture may be rendered incorrectly."),rwe(e,n)}function owe(e){return[Wt.NEAREST_MIPMAP_NEAREST,Wt.NEAREST_MIPMAP_LINEAR,Wt.LINEAR_MIPMAP_NEAREST,Wt.LINEAR_MIPMAP_LINEAR].includes(e.minificationFilter)}function rwe(e,t){let{pixelFormat:n,pixelDatatype:i,width:o,height:r,typedArray:a,sampler:s}=e;return new vt({context:t,pixelFormat:n,pixelDatatype:i,source:{arrayBufferView:a,width:o,height:r},sampler:s,flipY:!1})}VS.prototype.update=function(e){if(e.frameNumber===this._lastUpdatedFrame)return;this._lastUpdatedFrame=e.frameNumber;let t=e.context;this._defaultTexture=t.defaultTexture;let n=this._loadedImages;for(let i=0;i<n.length;i++){let o=n[i];eBt(this,o,t)}n.length=0};VS.prototype.isDestroyed=function(){return!1};VS.prototype.destroy=function(){let e=this._textures;for(let t in e)if(e.hasOwnProperty(t)){let n=e[t];n!==this._defaultTexture&&n.destroy()}return fe(this)};var U4=VS;function ER(e){e=e??V.EMPTY_OBJECT,this.mode=e.mode??U_.MODIFY_MATERIAL,this.lightingModel=e.lightingModel,this.uniforms=e.uniforms??V.EMPTY_OBJECT,this.varyings=e.varyings??V.EMPTY_OBJECT,this.vertexShaderText=e.vertexShaderText,this.fragmentShaderText=e.fragmentShaderText,this.translucencyMode=e.translucencyMode??SE.INHERIT,this._textureManager=new U4,this._defaultTexture=void 0,this.uniformMap=nBt(this),this.usedVariablesVertex={attributeSet:{},featureIdSet:{},metadataSet:{}},this.usedVariablesFragment={attributeSet:{},featureIdSet:{},metadataSet:{},materialSet:{}},rBt(this),aBt(this)}function nBt(e){let t=e.uniforms,n={};for(let i in t)if(t.hasOwnProperty(i)){let o=t[i];o.type===CR.SAMPLER_2D?(e._textureManager.loadTexture2D(i,o.value),n[i]=iBt(e,i)):n[i]=oBt(e,i)}return n}function iBt(e,t){return function(){return e._textureManager.getTexture(t)??e._defaultTexture}}function oBt(e,t){return function(){return e.uniforms[t].value}}function tI(e,t,n){let i;for(;(i=t.exec(e))!==null;){let o=i[1];n[o]=!0}}function rBt(e){let t=/[vf]sInput\.attributes\.(\w+)/g,n=/[vf]sInput\.featureIds\.(\w+)/g,i=/[vf]sInput\.(?:metadata|metadataClass|metadataStatistics)\.(\w+)/g,o,r=e.vertexShaderText;l(r)&&(o=e.usedVariablesVertex.attributeSet,tI(r,t,o),o=e.usedVariablesVertex.featureIdSet,tI(r,n,o),o=e.usedVariablesVertex.metadataSet,tI(r,i,o));let a=e.fragmentShaderText;if(l(a)){o=e.used
{ material.diffuse = vec3(1.0); material.alpha = 1.0;}`});function Pwe(){this.ready=!0,this.shape=Sc.BOX,this.dimensions=new d(1,1,1),this.names=["data"],this.types=[It.SCALAR],this.componentTypes=[Qt.FLOAT32],this.maximumTileCount=1}Pwe.prototype.requestData=function(e){if((l(e)?e.tileLevel??0:0)>=1)return;let n=new WS({metadata:[new Float32Array(1)]});return Promise.resolve(n)};jp.DefaultProvider=new Pwe;var nI=jp;function JDt(e,t,n,i){if(!l(e)||l(t)&&e.id!==t)return;let r=(e.classes||{})[n];if(!l(r))return;let s=(r.properties||{})[i];if(l(s))return s}var Y4=JDt;function ZDt(e,t,n,i,o){this.schemaId=e,this.className=t,this.propertyName=n,this.classProperty=i,this.metadataProperty=o}var q4=ZDt;function $Dt(e,t,n){if(!l(e))return;let i=e.propertyTextures;for(let o of i)if(o.class.id===t){let s=o.properties[n];if(l(s))return s}}var K4=$Dt;var J4=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function _i(e){e=e??V.EMPTY_OBJECT;let t=e.canvas,n=e.creditContainer,i=e.creditViewport,o=e.contextOptions instanceof d1;if(o)this._context=e.contextOptions.createSceneContext(t);else{let u=Ye(e.contextOptions);this._context=new YI(t,u)}let r=this._context,a=l(n);a||(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)),l(i)||(i=t.parentNode),this._id=Jn(),this._jobScheduler=new gH,this._frameState=new mH(r,new sH(n,"\u2022",i),this._jobScheduler),this._frameState.scene3DOnly=e.scene3DOnly??!1,this._removeCreditContainer=!a,this._creditContainer=n,this._canvas=t,this._computeEngine=new eN(r),this._ellipsoid=e.ellipsoid??te.default,this._globe=void 0,this._globeTranslucencyState=new pH,this._primitives=new yu({countReferences:o}),this._groundPrimitives=new yu({countReferences:o}),this._globeHeight=void 0,this._globeHeightDirty=!0,this._cameraUnderground=!1,this._removeUpdateHeightCallback=void 0,this._logDepthBuffer=_i.defaultLogDepthBuffer&&r.fragmentDepth,this._logDepthBufferDirty=!0,this._tweens=new US,this._shaderFrameCount=0,this._sunPostProcess=void 0,this._computeCommandList=[],this._overlayCommandList=[],this._useOIT=e.orderIndependentTranslucency??!0,this._executeOITFunction=void 0,this._depthPlane=new uH(e.depthPlaneEllipsoidOffset),this._clearColorCommand=new ui({color:new U,stencil:0,owner:this}),this._depthClearCommand=new ui({depth:1,owner:this}),this._stencilClearCommand=new ui({stencil:0}),this._classificationStencilClearCommand=new ui({stencil:0,renderState:Ve.fromCache({stencilMask:Yt.CLASSIFICATION_MASK})}),this._depthOnlyRenderStateCache={},this._transitioner=new o4(this),this._preUpdate=new _e,this._postUpdate=new _e,this._renderError=new _e,this._preRender=new _e,this._postRender=new _e,this._minimumDisableDepthTestDistance=0,this._debugInspector=new y4,this._msaaSamples=e.msaaSamples??4,this.rethrowRenderErrors=!1,this.completeMorphOnUserInput=!0,this.morphStart=new _e,this.morphComplete=new _e,this.skyBox=void 0,this.skyAtmosphere=void 0,this.sun=void 0,this.sunBloom=!0,this._sunBloom=void 0,this.moon=void 0,this.backgroundColor=U.clone(U.BLACK),this._mode=oe.SCENE3D,this._mapProjection=l(e.mapProjection)?e.mapProjection:new qi(this._ellipsoid),this.morphTime=1,this.farToNearRatio=1e3,this.logarithmicDepthFarToNearRatio=1e9,this.nearToFarDistance2D=175e4,this.verticalExaggeration=1,this.verticalExaggerationRelativeHeight=0,this.debugCommandFilter=void 0,this.debugShowCommands=!1,this.debugShowFrustums=!1,this.debugShowFramesPerSecond=!1,this.debugShowDepthFrustum=1,this.debugShowFrustumPlanes=!1,this._debugShowFrustumPlanes=!1,this._debugFrustumPlanes=void 0,this.useDepthPicking=!0,this.pickTranslucentDepth=!1,this.cameraEventWaitTime=500,this.atmosphere=new Wb,this.fog=new hH,this.fog.enabled=te.WGS84.equals(this._ellipsoid),te.WGS84.equals(this._ellipsoid)||(Bo.DEFAULT_VIEW_RECTANGLE=ce.fromDegrees(-45,-45,45,45)),this._shadowMapCamera=new Bo(this),this.shadowMap=new AC({context:r,lightCamera:this._shadowMapCamera,enabled:e.shadows??!1}),th
vec4 clippingPlanesEdgeColor = vec4(1.0); clippingPlanesEdgeColor.rgb = ${n}.rgb; float clippingPlanesEdgeWidth = ${n}.a; if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth) { out_FragColor = clippingPlanesEdgeColor; } `}var n9=nPt;var iPt={modifyFragmentShader:function(t){return t=We.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}}},vR=iPt;var rI={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function PR(e){this._parsedContent=void 0,this._drawCommand=void 0,this._isTranslucent=!1,this._styleTranslucent=!1,this._constantColor=U.clone(U.DARKGRAY),this._highlightColor=U.clone(U.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=rI.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=e.opaquePass??Be.OPAQUE,this._cull=e.cull??!0,this.style=void 0,this._style=void 0,this.styleDirty=!1,this.modelMatrix=P.clone(P.IDENTITY),this._modelMatrix=P.clone(P.IDENTITY),this.time=0,this.shadows=Bn.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=e.splitDirection??Qr.NONE,this._splittingEnabled=!1,this._error=void 0,oPt(this,e)}Object.defineProperties(PR.prototype,{pointsLength:{get:function(){return this._pointsLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}},color:{get:function(){return U.clone(this._highlightColor)},set:function(e){this._highlightColor=U.clone(e,this._highlightColor)}},boundingSphere:{get:function(){if(l(this._drawCommand))return this._drawCommand.boundingVolume},set:function(e){this._boundingSphere=le.clone(e,this._boundingSphere)}}});function oPt(e,t){let n=Ix.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&&l(n.batchTableBinary)&&(n.styleableProperties=Um.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),l(n.draco)){let s=n.draco;e._decodingState=rI.NEEDS_DECODE,s.dequantizeInShader=e._dequantizeInShader}let i=n.positions;l(i)&&(e._isQuantized=i.isQuantized,e._quantizedVolumeScale=i.quantizedVolumeScale,e._quantizedVolumeOffset=i.quantizedVolumeOffset,e._quantizedRange=i.quantizedRange);let o=n.normals;l(o)&&(e._isOctEncoded16P=o.octEncoded);let r=n.colors;l(r)&&(l(r.constantColor)&&(e._constantColor=U.clone(r.constantColor,e._constantColor),e._hasColors=!1),e._isRGB565=r.isRGB565);let a=n.batchIds;l(n.batchIds)&&(a.name="BATCH_ID",a.semantic="BATCH_ID",a.setIndex=void 0),n.hasBatchIds&&e._batchTableLoaded(n.batchLength,n.batchTableJson,n.batchTableBinary),e._pointsLength=n.pointsLength}var rPt=new d,aPt=new d,sPt=new d,Vwe,i9;function cPt(e){if(!l(i9)){Vwe=new Wwe.default(0),i9=new Array(e);for(let t=0;t<e;++t)i9[t]=Vwe.random()}return i9}function lPt(e){let n=e.length/3,i=Math.min(n,20),o=cPt(20),r=Number.MAX_VALUE,a=-Number.MAX_VALUE,s=d.fromElements(r,r,r,rPt),c=d.fromElements(a,a,a,aPt);for(let f=0;f<i;++f){let h=Math.floor(o[f]*n),p=d.unpack(e,h*3,sPt);d.minimumByComponent(s,p,s),d.maximumByComponent(c,p,c)}let u=le.fromCornerPoints(s,c);return u.radius+=D.EPSILON2,u}function Hwe(e,t){let n=j.fromTypedArray(e);return n===j.INT||n===j.UNSIGNED_INT||n===j.DOUBLE?(bt("Cast pnts property to floats",`Point cloud property "${t}" will be cast to a float array because INT, U`));let n=/czm_3dtiles_builtin_property_(\w+)/g,i=n.exec(e);for(;i!==null;){let o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function nte(e,t){let n=e.numberOfAttributes;for(let i=0;i<n;++i){let o=e.getAttribute(i);if(o.index===t)return o}}var gPt={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 _Pt(e,t,n){let i,o,r,a=t.context,s=l(n),c=e._isQuantized,u=e._isQuantizedDraco,f=e._isOctEncoded16P,h=e._isOctEncodedDraco,p=e._isRGB565,A=e._isTranslucent,m=e._hasColors,_=e._hasNormals,y=e._hasBatchIds,C=e._backFaceCulling,E=e._normalShading,I=e._drawCommand.vertexArray,x=e.clippingPlanes,S=e._attenuation,w,v,R,N=A,L=Ye(gPt),g={},b=e._styleableShaderAttributes;for(o in b)b.hasOwnProperty(o)&&(r=b[o],L[o]=`czm_3dtiles_property_${r.location}`,g[r.location]=r);if(s){let re={translucent:!1},ye="(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)";w=n.getColorShaderFunction(`getColorFromStyle${ye}`,L,re),v=n.getShowShaderFunction(`getShowFromStyle${ye}`,L,re),R=n.getPointSizeShaderFunction(`getPointSizeFromStyle${ye}`,L,re),l(w)&&re.translucent&&(N=!0)}e._styleTranslucent=N;let T=l(w),B=l(v),M=l(R),O=e.isClipped,G=[],k=[];T&&(ete(w,G),tte(w,k)),B&&(ete(v,G),tte(v,k)),M&&(ete(R,G),tte(R,k));let z=k.indexOf("COLOR")>=0,F=k.indexOf("NORMAL")>=0;if(F&&!_)throw new ue("Style references the NORMAL semantic but the point cloud does not have normals");for(o in b)if(b.hasOwnProperty(o)){r=b[o];let re=G.indexOf(r.location)>=0,ye=nte(I,r.location);ye.enabled=re}let H=m&&(!T||z);if(m){let re=nte(I,o9);re.enabled=H}let Y=_&&(E||C||F);if(_){let re=nte(I,ite);re.enabled=Y}let $={a_position:jwe};H&&($.a_color=o9),Y&&($.a_normal=ite),y&&($.a_batchId=Ywe);let W="",K=G.length;for(i=0;i<K;++i){let re=G[i];r=g[re];let ye=r.componentCount,Ce=`czm_3dtiles_property_${re}`,ve;ye===1?ve="float":ve=`vec${ye}`,W+=`in ${ve} ${Ce}; `,$[Ce]=r.location}APt(e,t);let Z=`in vec3 a_position; out vec4 v_color; uniform vec4 u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier; uniform vec4 u_constantColor; uniform vec4 u_highlightColor; `;Z+=`float u_pointSize; float tiles3d_tileset_time; `,S&&(Z+=`float u_geometricError; float u_depthMultiplier; `),Z+=W,H&&(A?Z+=`in vec4 a_color; `:p?Z+=`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; `:Z+=`in vec3 a_color; `),Y&&(f||h?Z+=`in vec2 a_normal; `:Z+=`in vec3 a_normal; `),y&&(Z+=`in float a_batchId; `),(c||u||h)&&(Z+=`uniform vec4 u_quantizedVolumeScaleAndOctEncodedRange; `),T&&(Z+=w),B&&(Z+=v),M&&(Z+=R),Z+=`void main() { u_pointSize = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.x; tiles3d_tileset_time = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.y; `,S&&(Z+=` u_geometricError = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.z; u_depthMultiplier = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.w; `),H?A?Z+=` vec4 color = a_color; `:p?Z+=` 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); `:Z+=` vec4 color = vec4(a_color, 1.0); `:Z+=` vec4 color = u_constantColor; `,c||u?Z+=` vec3 position = a_position * u_quantizedVolumeScaleAndOctEncodedRange.xyz; `:Z+=` vec3 position = a_position; `,Z+=` vec3 position_absolute = vec3(czm_model * vec4(position, 1.0)); `,Y?(f?Z+=` vec3 normal = czm_octDecode(a_normal); `:h?Z+=` vec3 normal = czm_octDecode(a_normal, u_quantizedVolumeScaleAndOctEncodedRange.w).zxy; `:Z+=` vec3 normal = a_normal; `,Z+=` vec3 normalEC = czm_normal * normal; `):Z+=` vec3 normal = vec3(1.0); `,T&&(Z+=` color = getColorFromStyle(position, position_absolute, color, normal); `),B&&(Z+=` float show = float(getShowFromStyle(position, position_absolute, color, normal)); `),M?Z+=` gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal) * czm_pixelRatio; `:S?Z+=` vec4 positionEC = czm_modelView * vec4(position, 1.0); float depth = -positionEC.z; gl_PointSize = min((u_geometricError / depth) * u_depthMultiplier, u_pointSize); `:Z+=` gl_PointSize = u_pointSize; `,Z+=` color = color * u_highlightColor; `,Y&&E&&(Z+=` float diffuseStrength = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC); diffuseStrength = max(diffuseStrength, 0.4); color.xyz *= diffuseStrength * czm_lightColor; `),Z+=` v_color = color; gl_Position = czm_modelViewProjection * vec4(position, 1.0); `,Y&&C&&(Z+=` float visible = step(-normalEC.z, 0.0); gl_Position *= visible; gl_PointSize *= visible; `),B&&(Z+=` gl_Position.w *= float(show); gl_PointSize *= float(show); `),Z+=`} `;let pe=`in vec4 v_color; `;O&&(pe+=`uniform highp sampler2D u_clippingPlanes; uniform mat4 u_clippingPlanesMatrix; uniform vec4 u_clippingPlanesEdgeStyle; `,pe+=``,pe+=SS(x,a),pe+=``),pe+=`void main() { out_FragColor = czm_gammaCorrect(v_color); `,O&&(pe+=n9("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),pe+=`} `,e.splitDirection!==Qr.NONE&&(pe=vR.modifyFragmentShader(pe)),l(e._vertexShaderLoaded)&&(Z=e._vertexShaderLoaded(Z)),l(e._fragmentShaderLoaded)&&(pe=e._fragmentShaderLoaded(pe));let ge=e._drawCommand;l(ge.shaderProgram)&&ge.shaderProgram.destroy(),ge.shaderProgram=$t.fromCache({context:a,vertexShaderSource:Z,fragmentShaderSource:pe,attributeLocations:$});try{ge.shaderProgram._bind()}catch{throw new ue("Error generating style shader: this may be caused by a type mismatch, index out-of-bounds, or other syntax error.")}}function yPt(e,t){if(e._decodingState===rI.READY)return!1;if(e._decodingState===rI.NEEDS_DECODE){let n=e._parsedContent,i=n.draco,o=C_.decodePointCloud(i,t);l(o)&&(e._decodingState=rI.DECODING,o.then(function(r){e._decodingState=rI.READY;let a=l(r.POSITION)?r.POSITION.array:void 0,s=l(r.RGB)?r.RGB.array:void 0,c=l(r.RGBA)?r.RGBA.array:void 0,u=l(r.NORMAL)?r.NORMAL.array:void 0,f=l(r.BATCH_ID)?r.BATCH_ID.array:void 0,h=l(a)&&l(r.POSITION.data.quantization),p=l(u)&&l(r.NORMAL.data.quantization);if(h){let y=r.POSITION.data.quantization,C=y.range;e._quantizedVolumeScale=d.fromElements(C,C,C),e._quantizedVolumeOffset=d.unpack(y.minValues),e._quantizedRange=(1<<y.quantizationBits)-1,e._isQuantizedDraco=!0}p&&(e._octEncodedRange=(1<<r.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let A=n.styleableProperties,m=i.batchTableProperties;for(let y in m)if(m.hasOwnProperty(y)){let C=r[y];l(A)||(A={}),A[y]={typedArray:C.array,componentCount:C.data.componentsPerAttribute}}l(a)&&(n.positions={typedArray:a});let _=c??s;l(_)&&(n.colors={typedArray:_}),l(u)&&(n.normals={typedArray:u}),l(f)&&(n.batchIds={typedArray:f}),n.styleableProperties=A}).catch(function(r){e._decodingState=rI.FAILED,e._error=r}))}return!0}var CPt=new ie,EPt=new d;PR.prototype.update=function(e){let t=e.context;if(l(this._error)){let u=this._error;throw this._error=void 0,u}if(yPt(this,t))return;let i=!1,o=!P.equals(this._modelMatrix,this.modelMatrix);if(this._mode!==e.mode&&(this._mode=e.mode,o=!0),l(this._drawCommand)||(pPt(this,e),o=!0,i=!0,this._ready=!0,this._parsedContent=void 0),o){P.clone(this.modelMatrix,this._modelMatrix);let u=this._drawCommand.modelMatrix;if(P.clone(this._modelMatrix,u),l(this._rtcCenter)&&P.multiplyByTranslation(u,this._rtcCenter,u),l(this._quantizedVolumeOffset)&&P.multiplyByTranslation(u,this._quantizedVolumeOffset,u),e.mode!==oe.SCENE3D){let h=e.mapProjection,p=P.getColumn(u,3,CPt);ie.equals(p,ie.UNIT_W)||At.basisTo2D(h,u,u)}let f=this._drawCommand.boundingVolume;if(le.clone(this._boundingSphere,f),this._cull){let h=f.center;P.multiplyByPoint(u,h,h);let p=P.getScale(u,EPt);f.radius*=d.maximumComponent(p)}}this.clippingPlanesDirty&&(this.clippingPlanesDirty=!1,i=!0),this._attenuation!==this.attenuation&&(this._attenuation=this.attenuation,i=!0),this.backFaceCulling!==this._backFaceCulling&&(this._backFaceCulling=this.backFaceCulling,i=!0),this.normalShading!==this._normalShading&&(this._normalShading=this.normalShading,i=!0),(this._style!==this.style||this.styleDirty)&&(this._style=this.style,this.styleDirty=!1,i=!0);let r=this.splitDirection!==Qr.NONE;this._splittingEnabled!==r&&(this._splittingEnabled=r,i=!0),i&&_Pt(this,e,this._style),this._drawCommand.castShadows=Bn.castShadows(this.shadows),this._drawCommand.receiveShadows=Bn.receiveShadows(this.shadows);let a=this._highlightColor.alpha<1||this._constantColor.alpha<1||this._styleTranslucent;this._drawCommand.renderState=a?this._translucentRenderState:this._opaqueRenderState,this._drawCommand.pass=a?Be.TRANSLUCENT:this._opaquePass;let s=e.commandList,c=e.passes;(c.render||c.pick)&&s.push(this._drawCommand)};PR.prototype.isDestroyed=function(){return!1};PR.prototype.destroy=function(){let e=this._drawCommand;return l(e)&&(e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy()),fe(this)};var r9=PR;function sI(e){e=e??V.EMPTY_OBJECT,this.show=e.show??!0,this.modelMatrix=P.clone(e.modelMatrix??P.IDENTITY),this.shadows=e.shadows??Bn.ENABLED,this.maximumMemoryUsage=e.maximumMemoryUsage??256,this.
${e}`}function bPt(e){return function(t){return Pt(t,{czm_pickColor:function(){return e._pickId.color}})}}function xPt(){return"czm_pickColor"}sI.prototype.makeStyleDirty=function(){this._styleDirty=!0};sI.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};var TPt=new X;function rte(e){let t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function aI(e,t){return e._intervals.indexOf(t.start)}function SPt(e,t){let n=e._intervals,i=e._clock,o=rte(e);if(o===0)return;let r=e._getAverageLoadTime(),a=X.addSeconds(i.currentTime,r*o,TPt),s=n.indexOf(a),c=aI(e,t);return s===c&&(o>=0?++s:--s),n.get(s)}function wPt(e){let t=e._intervals,i=e._clock.currentTime,o=t.indexOf(i);return t.get(o)}function BPt(e,t,n){let i=rte(e),o=aI(e,t),r=aI(e,n);return i>=0?o>=r:o<=r}function Kwe(e,t){return function(n){let i=l(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 DPt(e,t,n){let i=aI(e,t),o=e._frames,r=o[i];if(!l(r)){let a=t.data.transform,s=l(a)?P.fromArray(a):void 0,c=t.data.uri;r={pointCloud:void 0,transform:s,timestamp:ki(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber,uri:c},o[i]=r,De.fetchArrayBuffer({url:c}).then(function(u){r.pointCloud=new r9({arrayBuffer:u,cull:!0,fragmentShaderLoaded:IPt,uniformMapLoaded:bPt(e),pickIdLoaded:xPt})}).catch(Kwe(e,c))}return r}function vPt(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 PPt(e,t,n,i){t.touchedFrameNumber<i.frameNumber-1&&(t.sequential=!1);let o=t.pointCloud;if(l(o)&&!t.ready){let r=i.commandList,a=r.length;if(Xwe(e,t,n,i),o.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=o.geometryByteLength,r.length=a,t.sequential)){let s=(ki()-t.timestamp)/1e3;vPt(e,s)}}t.touchedFrameNumber=i.frameNumber}var RPt=new P;function MPt(e,t){let n=e.shading;return l(n)&&l(n.baseResolution)?n.baseResolution:l(t.boundingSphere)?D.cbrt(t.boundingSphere.volume()/t.pointsLength):0}function NPt(e){let t=e.shading;return l(t)&&l(t.maximumAttenuation)?t.maximumAttenuation:10}var LPt=new TA;function Xwe(e,t,n,i){let o=e.shading??LPt,r=t.pointCloud,a=t.transform??P.IDENTITY;r.modelMatrix=P.multiplyTransformation(e.modelMatrix,a,RPt),r.style=e.style,r.time=n.timeSinceLoad,r.shadows=e.shadows,r.clippingPlanes=e._clippingPlanes,r.isClipped=n.isClipped,r.attenuation=o.attenuation,r.backFaceCulling=o.backFaceCulling,r.normalShading=o.normalShading,r.geometricError=MPt(e,r),r.geometricErrorScale=o.geometricErrorScale,r.maximumAttenuation=NPt(e);try{r.update(i)}catch(s){Kwe(e,t.uri)(s)}t.touchedFrameNumber=i.frameNumber}function ote(e,t,n,i){let o=DPt(e,t,i);PPt(e,o,n,i)}function OPt(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function Jwe(e,t){let n=e._frames,i=n.length;for(let o=0;o<i;++o){let r=n[o];if(l(r)&&(!l(t)||t(r))){let a=r.pointCloud;r.ready&&(e._totalMemoryUsageInBytes-=a.geometryByteLength),l(a)&&a.destroy(),r===e._lastRenderedFrame&&(e._lastRenderedFrame=void 0),n[o]=void 0}}}function FPt(e,t){let n=aI(e,t),i=e._frames[n];if(l(i)&&i.ready)return i}function qwe(e,t,n,i,o){return l(n)?n.ready?!0:(ote(e,t,i,o),n.ready):!1}function QPt(e,t,n,i,o){let r,a,s,c=e._intervals,u=e._frames,f=aI(e,n),h=aI(e,t);if(f>=h){for(r=f;r>=h;--r)if(a=c.get(r),s=u[r],qwe(e,a,s,i,o))return a}else for(r=f;r<=h;++r)if(a=c.get(r),s=u[r],qwe(e,a,s,i,o))return a;return t}function kPt(e,t,n){let i=e._frames,o=i.length;for(let r=0;r<o;++r){let a=i[r];l(a)&&l(a.pointCloud)&&(a.pointCloud.clippingPlanesDirty=t,a.pointCloud.styleDirty=n)}}var ZS={timeSinceLoad:0,isClipped:!1,clippingPlanesDirty:!1};sI.prototype.update=function(e){if(e.mode===oe.MORPHING||!this.show)return;l(this._pickId)||(this._pickId=e.context.createPickId({primitive:this})),l(this._loa
${t}${m}`);let _=document.createElement("div");_.className="cesium-widget-errorPanel-message-details collapsed";let y=document.createElement("span");y.className="cesium-widget-errorPanel-more-details",y.appendChild(document.createTextNode("See more...")),_.appendChild(y),_.onclick=function(C){_.removeChild(y),_.appendChild(document.createTextNode(m)),_.className="cesium-widget-errorPanel-message-details",r.className="cesium-widget-errorPanel-content expanded",_.onclick=void 0},s.appendChild(_)}A.innerHTML=`<p>${t}</p>`}let h=document.createElement("div");h.className="cesium-widget-errorPanel-buttonPanel",r.appendChild(h);let p=document.createElement("button");p.setAttribute("type","button"),p.className="cesium-button",p.appendChild(document.createTextNode("OK")),p.onclick=function(){l(c)&&l(window.removeEventListener)&&window.removeEventListener("resize",c,!1),i.removeChild(o)},h.appendChild(p),i.appendChild(o)};Ko.prototype.isDestroyed=function(){return!1};Ko.prototype.destroy=function(){let e=this.dataSources,t=e.length;for(let n=0;n<t;n++)this._dataSourceRemoved(e,e.get(n));this._dataSourceRemoved(void 0,this._dataSourceDisplay.defaultDataSource),this._dataSourceDisplay=this._dataSourceDisplay.destroy(),l(this._scene)&&(this._scene.renderError.removeEventListener(this._onRenderError),this._scene=this._scene.destroy()),this._container.removeChild(this._element),this._creditContainer.removeChild(this._innerCreditContainer),this._eventHelper.removeAll(),this._destroyDataSourceCollection&&(this._dataSourceCollection=this._dataSourceCollection.destroy()),fe(this)};Ko.prototype.resize=function(){let e=this._canvas;!this._forceResize&&this._canvasClientWidth===e.clientWidth&&this._canvasClientHeight===e.clientHeight&&this._lastDevicePixelRatio===window.devicePixelRatio||(this._forceResize=!1,nBe(this),iBe(this),this._scene.requestRender())};Ko.prototype.render=function(){if(this._canRender){this._scene.initializeFrame();let e=this._clock.tick();this._scene.render(e)}else this._clock.tick()};Ko.prototype._dataSourceAdded=function(e,t){t.entities.collectionChanged.addEventListener(Ko.prototype._onEntityCollectionChanged,this)};Ko.prototype._dataSourceRemoved=function(e,t){let n=t.entities;n.collectionChanged.removeEventListener(Ko.prototype._onEntityCollectionChanged,this),l(this.trackedEntity)&&n.getById(this.trackedEntity.id)===this.trackedEntity&&(this.trackedEntity=void 0)};Ko.prototype._updateCanAnimate=function(e){this._clock.canAnimate=e};var zPt=new le;Ko.prototype._onTick=function(e){let t=e.currentTime,n=this._dataSourceDisplay.update(t);this._allowDataSourcesToSuspendAnimation&&this._canAnimateUpdateCallback(n);let i=this._entityView;if(l(i)){let o=this._trackedEntity;this._dataSourceDisplay.getBoundingSphere(o,!1,i.boundingSphere??zPt)===Ct.DONE&&i.update(t)}};Ko.prototype._onEntityCollectionChanged=function(e,t,n){let i=n.length;for(let o=0;o<i;o++){let r=n[o];this.trackedEntity===r&&(this.trackedEntity=void 0)}};Ko.prototype._clearTrackedObject=function(){this.trackedEntity=void 0};Ko.prototype._onDataSourceChanged=function(e){this.clockTrackedDataSource===e&&eBe(this.clock,e)};Ko.prototype._onDataSourceAdded=function(e,t){this._automaticallyTrackDataSourceClocks&&(this.clockTrackedDataSource=t);let n=t.entities.id,i=this._eventHelper.add(t.changedEvent,Ko.prototype._onDataSourceChanged,this);this._dataSourceChangedListeners[n]=i};Ko.prototype._onDataSourceRemoved=function(e,t){let n=this.clockTrackedDataSource===t,i=t.entities.id;if(this._dataSourceChangedListeners[i](),this._dataSourceChangedListeners[i]=void 0,n){let o=e.length;this._automaticallyTrackDataSourceClocks&&o>0?this.clockTrackedDataSource=e.get(o-1):this.clockTrackedDataSource=void 0}};Ko.prototype.zoomTo=function(e,t){return oBe(this,e,{offset:t},!1)};Ko.prototype.flyTo=function(e,t){return oBe(this,e,t,!0)};function oBe(e,t,n,i){ate(e);let o=new Promise(r=>{e._completeZoom=function(a){r(a)}});return e._zoomPromise=o,e._zoomIsFlight=i,e._zoomOptions=n,Promise.resolve(t).then(function(r){if(e._zoomPromise===o){if(r instanceof Ta){let a;l(r.imageryProv`;else switch(t==="st"&&(i="vec2"),i){case"float":r=`vec4 getColor() { return vec4(vec3(${o}), 1.0); }`;break;case"vec2":r=`vec4 getColor() { return vec4(${o}, 0.0, 1.0); }`;break;case"vec3":r=`vec4 getColor() { return vec4(${o}, 1.0); }`;break;case"vec4":r=`vec4 getColor() { return ${o}; }`;break}let a=`in vec3 position3DHigh;in vec3 position3DLow;in float batchId;${n?"":`in ${i} ${t};
`}out ${i} ${o};
void main(){vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);${n?`${o} = czm_batchTable_${t}(batchId);
`:`${o} = ${t};`}gl_Position = czm_modelViewProjectionRelativeToEye * p;
}`,s=`in ${i} ${o};${r}void main(){out_FragColor = getColor();}`;this.material=void 0,this.translucent=e.translucent??!1,this._vertexShaderSource=e.vertexShaderSource??a,this._fragmentShaderSource=e.fragmentShaderSource??s,this._renderState=xo.getDefaultRenderState(!1,!1,e.renderState),this._closed=e.closed??!1,this._attributeName=t,this._glslDatatype=i}Object.defineProperties(QR.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}}});QR.prototype.getFragmentShaderSource=xo.prototype.getFragmentShaderSource;QR.prototype.isTranslucent=xo.prototype.isTranslucent;QR.prototype.getRenderState=xo.prototype.getRenderState;var TBe=QR;function f9(e){e=e??V.EMPTY_OBJECT,this.length=e.length??1e7,this._length=void 0,this.width=e.width??2,this._width=void 0,this.show=e.show??!0,this.modelMatrix=P.clone(e.modelMatrix??P.IDENTITY),this._modelMatrix=new P,this.id=e.id,this._id=void 0,this._primitive=void 0}f9.prototype.update=function(e){if(this.show){if(!l(this._primitive)||!P.equals(this._modelMatrix,this.modelMatrix)||this._length!==this.length||this._width!==this.width||this._id!==this.id){this._modelMatrix=P.clone(this.modelMatrix,this._modelMatrix),this._length=this.length,this._width=this.width,this._id=this.id,l(this._primitive)&&this._primitive.destroy(),this.modelMatrix[12]===0&&this.modelMatrix[13]===0&&this.modelMatrix[14]===0&&(this.modelMatrix[14]=.01);let t=new Lt({geometry:new Oy({positions:[d.ZERO,d.UNIT_X],width:this.width,vertexFormat:Qa.VERTEX_FORMAT,colors:[U.RED,U.RED],arcType:un.NONE}),modelMatrix:P.multiplyByUniformScale(this.modelMatrix,this.length,new P),id:this.id,pickPrimitive:this}),n=new Lt({geometry:new Oy({positions:[d.ZERO,d.UNIT_Y],width:this.width,vertexFormat:Qa.VERTEX_FORMAT,colors:[U.GREEN,U.GREEN],arcType:un.NONE}),modelMatrix:P.multiplyByUniformScale(this.modelMatrix,this.length,new P),id:this.id,pickPrimitive:this}),i=new Lt({geometry:new Oy({positions:[d.ZERO,d.UNIT_Z],width:this.width,vertexFormat:Qa.VERTEX_FORMAT,colors:[U.BLUE,U.BLUE],arcType:un.NONE}),modelMatrix:P.multiplyByUniformScale(this.modelMatrix,this.length,new P),id:this.id,pickPrimitive:this});this._primitive=new Ln({geometryInstances:[t,n,i],appearance:new Qa,asynchronous:!1})}this._primitive.update(e)}};f9.prototype.isDestroyed=function(){return!1};f9.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),fe(this)};var d9=f9;function jRt(e){this.direction=d.clone(e.direction),this.color=U.clone(e.color??U.WHITE),this.intensity=e.intensity??1}var SBe=jRt;var h9=`in vec3 v_positionMC;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 m9=`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 lI(e){e=e??V.EMPTY_OBJECT;let t=e.translucent??!0,n=e.aboveGround??!1;this.material=l(e.material)?e.material:Xi.fromType(Xi.ColorType),this.translucent=e.translucent??!0,this._vertexShaderSource=e.vertexShaderSource??m9,this._fragmentShaderSource=e.fragmentShaderSource??h9,this._renderState=xo.getDefaultRenderState(t,!n,e.renderState),this._closed=!1,this._flat=e.flat??!1,this._faceForward=e.faceForward??n,this._aboveGround=n}Object.defineProperties(lI.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 lI.VERTEX_FORMAT}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}},aboveGround:{get:function(){return this._aboveGround}}});lI.VERTEX_FORMAT=ke.POSITION_AND_ST;lI.prototype.getFragmentShaderSource=xo.prototype.getFragmentShaderSource;lI.prototype.isTranslucent=xo.prototype.isTranslucent;lI.prototype.getRenderState=xo.prototype.getRenderState;var wBe=lI;var YRt=1e5;function kR(e){e=e??V.EMPTY_OBJECT;let t=e.credit;typeof t=="string"&&(t=new Et(t)),this._credit=t,this._radius=l(e.radius)?e.radius:YRt,this._image=e.image,this._transform=l(e.transform)?e.transform:P.IDENTITY,this._repeatHorizontal=l(e.repeatHorizontal)?e.repeatHorizontal:1,this._repeatVertical=l(e.repeatVertical)?e.repeatVertical:1;let n=new $V({radius:this._radius,vertexFormat:ke.ALL}),i=new Lt({geometry:n,modelMatrix:this._transform}),o=new Xi({fabric:{type:"Image",uniforms:{image:this._image,repeat:new Q(-this._repeatHorizontal,this._repeatVertical)}}});return this._primitive=new Ln({geometryInstances:i,appearance:new _o({material:o,closed:!0,faceForward:!1,translucent:!1,renderState:{cull:{enabled:!1}}}),credit:this._credit}),this}Object.defineProperties(kR.prototype,{radius:{get:function(){return this._radius}},image:{get:function(){return this._image}},transform:{get:function(){return this._transform}},credit:{get:function(){return l(this._credit)?this._credit:void 0}},show:{get:function(){return l(this._primitive)?this._primitive.show:void 0},set:function(e){l(this._primitive)&&(this._primitive.show=e)}}});kR.prototype.update=function(e){return l(this._credit)&&e.creditDisplay.addCreditToNextFrame(this._credit),this._primitive.update(e)};kR.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),fe(this)};kR.prototype.isDestroyed=function(){return this._primitive.isDestroyed()};var BBe=kR;function vu(e){this._scene=e.scene,this.samplingWindow=e.samplingWindow??vu.defaultSettings.samplingWindow,this.quietPeriod=e.quietPeriod??vu.defaultSettings.quietPeriod,this.warmupPeriod=e.warmupPeriod??vu.defaultSettings.warmupPeriod,this.minimumFrameRateDuringWarmup=e.minimumFrameRateDuringWarmup??vu.defaultSettings.minimumFrameRateDuringWarmup,this.minimumFrameRateAfterWarmup=e.minimumFrameRateAfterWarmup??vu.defaultSettings.minimumFrameRateAfterWarmup,this._lowFrameRate=new _e,this._nominalFrameRate=new _e,this._frameTimes=[],this._needsQuietPeriod=!0,this._quietPeriodEndTime=0,this._warmupPeriodEndTime=0,this._frameRateIsLow=!1,this._lastFramesPerSecond=void 0,this._pauseCount=0;let t=this;this._preUpdateRemoveListener=this._scene.preUpdate.addEventListener(function(o,r){qRt(t,r)}),this._hiddenPropertyName=document.hidden!==void 0?"hidden":document.mozHidden!==void 0?"mozHidden":document.msHidden!==void 0?"msHidden":document.webkitHidden!==void 0?"webkitHidden":void 0;let n=document.hidden!==void 0?"visibilitychange":document.mozHidden!==void 0?"mozvisibilitychange":document.msHidden!==void 0?"msvisibilitychange":document.webkitHidden!==void 0?"webkitvisibilitychange":void 0;function i(){KRt(t)}this._visibilityChangeRemoveListener=void 0,l(n)&&(document.addEventListener(n,i,!1),this._visibilityChangeRemoveListener=function(){document.removeEventListener(n,i,!1)})}vu.defaultSettings={samplingWindow:5,quietPeriod:2,warmupPeriod:5,mini
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 jMt(e){e=e??V.EMPTY_OBJECT,this.typedArray=e.typedArray,this.width=e.width,this.height=e.height,this.pixelFormat=e.pixelFormat??Ke.RGBA,this.pixelDatatype=e.pixelDatatype??He.UNSIGNED_BYTE;let t=e.url;typeof t=="string"&&(t=De.createIfNeeded(t)),this.resource=t;let i=e.repeat??!0?pn.REPEAT:pn.CLAMP_TO_EDGE;this.sampler=new jt({wrapS:i,wrapT:i,minificationFilter:e.minificationFilter,magnificationFilter:e.magnificationFilter,maximumAnisotropy:e.maximumAnisotropy})}var hDe=jMt;var YMt={FLOAT:"float",VEC2:"vec2",VEC3:"vec3",VEC4:"vec4",MAT2:"mat2",MAT3:"mat3",MAT4:"mat4"},mDe=Object.freeze(YMt);var qMt={SIGX:"SIGX",SIGY:"SIGY",SIGZ:"SIGZ",VARX:"VARX",VARY:"VARY",VARZ:"VARZ",SIGR:"VARZ"},pDe=Object.freeze(qMt);function KMt(e){async function t({data:i}){let o=[],r={id:i.id,result:void 0,error:void 0};self.CESIUM_BASE_URL=i.baseUrl;try{let a=await e(i.parameters,o);r.result=a}catch(a){a instanceof Error?r.error={name:a.name,message:a.message,stack:a.stack}:r.error=a}i.canTransferArrayBuffer||(o.length=0);try{postMessage(r,o)}catch(a){r.result=void 0,r.error=`postMessage failed with error: ${vA(a)} with responseMessage: ${JSON.stringify(r)}`,postMessage(r)}}function n(i){postMessage({id:i.data?.id,error:`postMessage failed with error: ${JSON.stringify(i)}`})}return self.onmessage=t,self.onmessageerror=n,self}var ADe=KMt;globalThis.CESIUM_VERSION="1.140.0";var KR;typeof ko<"u"&&(KR=ko);(function(){/*!
* Knockout JavaScript library v3.5.1 * (c) The Knockout.js team - http://knockoutjs.com/
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/(function(){(function(e){var t=this||(0,eval)("this"),n=t.document,i=t.navigator,o=t.jQuery,r=t.JSON;o||typeof jQuery>"u"||(o=jQuery),(function(a){a(t.ko={})})(function(a,s){function c(g,b){return g===null||typeof g in _?g===b:!1}function u(g,b){var T;return function(){T||(T=m.a.setTimeout(function(){T=e,g()},b))}}function f(g,b){var T;return function(){clearTimeout(T),T=m.a.setTimeout(g,b)}}function h(g,b){b&&b!=="change"?b==="beforeChange"?this.pc(g):this.gb(g,b):this.qc(g)}function p(g,b){b!==null&&b.s&&b.s()}function A(g,b){var T=this.qd,B=T[x];B.ra||(this.Qb&&this.mb[b]?(T.uc(b,g,this.mb[b]),this.mb[b]=null,--this.Qb):B.I[b]||T.uc(b,g,B.J?{da:g}:T.$c(g)),g.Ja&&g.gd())}var m=typeof a<"u"?a:{};m.b=function(g,b){for(var T=g.split("."),B=m,M=0;M<T.length-1;M++)B=B[T[M]];B[T[T.length-1]]=b},m.L=function(g,b,T){g[b]=T},m.version="3.5.1",m.b("version",m.version),m.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},m.a=(function(){function g(W,K){for(var Z in W)M.call(W,Z)&&K(Z,W[Z])}function b(W,K){if(K)for(var Z in K)M.call(K,Z)&&(W[Z]=K[Z]);return W}function T(W,K){return W.__proto__=K,W}function B(W,K,Z,pe){var ge=W[K].match(Y)||[];m.a.D(Z.match(Y),function(re){m.a.Na(ge,re,pe)}),W[K]=ge.join(" ")}var M=Object.prototype.hasOwnProperty,O={__proto__:[]}instanceof Array,G=typeof Symbol=="function",k={},z={};k[i&&/Firefox\/2/i.test(i.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"],k.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "),g(k,function(W,K){if(K.length)for(var Z=0,pe=K.length;Z<pe;Z++)z[K[Z]]=W});var F={propertychange:!0},H=n&&(function(){for(var W=3,K=n.createElement("div"),Z=K.getElementsByTagName("i");K.innerHTML="<!--[if gt IE "+ ++W+"]><i></i><![endif]-->",Z[0];);return 4<W?W:e})(),Y=/\S+/g,$;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],D:function(W,K,Z){for(var pe=0,ge=W.length;pe<ge;pe++)K.call(Z,W[pe],pe,W)},A:typeof Array.prototype.indexOf=="function"?function(W,K){return Array.prototype.indexOf.call(W,K)}:function(W,K){for(var Z=0,pe=W.length;Z<pe;Z++)if(W[Z]===K)return Z;return-1},Lb:function(W,K,Z){for(var pe=0,ge=W.length;pe<ge;pe++)if(K.call(Z,W[pe],pe,W))return W[pe];return e},Pa:function(W,K){var Z=m.a.A(W,K);0<Z?W.splice(Z,1):Z===0&&W.shift()},wc:function(W){var K=[];return W&&m.a.D(W,function(Z){0>m.a.A(K,Z)&&K.push(Z)}),K},Mb:function(W,K,Z){var pe=[];if(W)for(var ge=0,re=W.length;ge<re;ge++)pe.push(K.call(Z,W[ge],ge));return pe},jb:function(W,K,Z){var pe=[];if(W)for(var ge=0,re=W.length;ge<re;ge++)K.call(Z,W[ge],ge)&&pe.push(W[ge]);return pe},Nb:function(W,K){if(K instanceof Array)W.push.apply(W,K);else for(var Z=0,pe=K.length;Z<pe;Z++)W.push(K[Z]);return W},Na:function(W,K,Z){var pe=m.a.A(m.a.bc(W),K);0>pe?Z&&W.push(K):Z||W.splice(pe,1)},Ba:O,extend:b,setPrototypeOf:T,Ab:O?T:b,P:g,Ga:function(W,K,Z){if(!W)return W;var pe={},ge;for(ge in W)M.call(W,ge)&&(pe[ge]=K.call(Z,W[ge],ge,W));return pe},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"),Z=0,pe=W.length;Z<pe;Z++)K.appendChild(m.oa(W[Z]));return K},Ca:function(W,K){for(var Z=0,pe=W.length,ge=[];Z<pe;Z++){var re=W[Z].cloneNode(!0);ge.push(K?m.oa(re):re)}return ge},va:function(W,K){if(m.a.Tb(W),K)for(var Z=0,pe=K.length;Z<pe;Z++)W.appendChild(K[Z])},Xc:function(W,K){var Z=W.nodeType?[W]:W;if(0<Z.length){for(var pe=Z[0],ge=pe.parentNode,re=0,ye=K.length;re<ye;re++)ge.insertBefore(K[re],pe);for(re=0,ye=Z.length;re<ye;re++)m.removeNode(Z[re])}},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 Z=W[0],pe=W[W.length-1];for(W.length=0;Z!==pe;)W.push(Z),Z=Z.nextSibling;W.push(pe)}}return W},Zc:function(W,K){7>H?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,`;var z=[],F=k.match(B),H,Y=[],$=0;if(1<F.length){for(var W=0,K;K=F[W];++W){var Z=K.charCodeAt(0);if(Z===44){if(0>=$){z.push(H&&Y.length?{key:H,value:Y.join("")}:{unknown:H||Y.join("")}),H=$=0,Y=[];continue}}else if(Z===58){if(!$&&!H&&Y.length===1){H=Y.pop();continue}}else{if(Z===47&&1<K.length&&(K.charCodeAt(1)===47||K.charCodeAt(1)===42))continue;Z===47&&W&&1<K.length?(Z=F[W-1].match(M))&&!O[Z[0]]&&(k=k.substr(k.indexOf(K)+1),F=k.match(B),W=-1,K="/"):Z===40||Z===123||Z===91?++$:Z===41||Z===125||Z===93?--$:H||Y.length||Z!==34&&Z!==39||(K=K.slice(1,-1))}Y.push(K)}if(0<$)throw Error("Unbalanced parentheses, braces, or brackets")}return z}var b=["true","false","null","undefined"],T=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,B=RegExp(`"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|\`(?:\\\\.|[^\`])*\`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*
|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,"'\`{}()/:[\\]]*[^\\s,"'\`{}()/:[\\]]|[^\\s]`,"g"),M=/[\])"'A-Za-z0-9_$]+$/,O={in:1,return:1,typeof:1},G={};return{Ra:[],wa:G,ac:g,vb:function(k,z){function F(Z,pe){var ge;if(!W){var re=m.getBindingHandler(Z);if(re&&re.preprocess&&!(pe=re.preprocess(pe,Z,F)))return;(re=G[Z])&&(ge=pe,0<=m.a.A(b,ge)?ge=!1:(re=ge.match(T),ge=re===null?!1:re[1]?"Object("+re[1]+")"+re[2]:ge),re=ge),re&&Y.push("'"+(typeof G[Z]=="string"?G[Z]:Z)+"':function(_z){"+ge+"=_z}")}$&&(pe="function(){return "+pe+" }"),H.push("'"+Z+"':"+pe)}z=z||{};var H=[],Y=[],$=z.valueAccessors,W=z.bindingParams,K=typeof k=="string"?g(k):k;return m.a.D(K,function(Z){F(Z.key||Z.unknown,Z.value)}),Y.length&&F("_ko_property_writers","{"+Y.join(",")+" }"),H.join(",")},Id:function(k,z){for(var F=0;F<k.length;F++)if(k[F].key==z)return!0;return!1},eb:function(k,z,F,H,Y){k&&m.O(k)?!m.Za(k)||Y&&k.v()===H||k(H):(k=z.get("_ko_property_writers"))&&k[F]&&k[F](H)}}})(),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 g(F){return F.nodeType==8&&O.test(M?F.text:F.nodeValue)}function b(F){return F.nodeType==8&&G.test(M?F.text:F.nodeValue)}function T(F,H){for(var Y=F,$=1,W=[];Y=Y.nextSibling;){if(b(Y)&&(m.a.g.set(Y,z,!0),$--,$===0))return W;W.push(Y),g(Y)&&$++}if(!H)throw Error("Cannot find closing comment tag to match: "+F.nodeValue);return null}function B(F,H){var Y=T(F,H);return Y?0<Y.length?Y[Y.length-1].nextSibling:F.nextSibling:null}var M=n&&n.createComment("test").text==="<!--test-->",O=M?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,G=M?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,k={ul:!0,ol:!0},z="__ko_matchedEndComment__";m.h={ea:{},childNodes:function(F){return g(F)?T(F):F.childNodes},Ea:function(F){if(g(F)){F=m.h.childNodes(F);for(var H=0,Y=F.length;H<Y;H++)m.removeNode(F[H])}else m.a.Tb(F)},va:function(F,H){if(g(F)){m.h.Ea(F);for(var Y=F.nextSibling,$=0,W=H.length;$<W;$++)Y.parentNode.insertBefore(H[$],Y)}else m.a.va(F,H)},Vc:function(F,H){var Y;g(F)?(Y=F.nextSibling,F=F.parentNode):Y=F.firstChild,Y?H!==Y&&F.insertBefore(H,Y):F.appendChild(H)},Wb:function(F,H,Y){Y?(Y=Y.nextSibling,g(F)&&(F=F.parentNode),Y?H!==Y&&F.insertBefore(H,Y):F.appendChild(H)):m.h.Vc(F,H)},firstChild:function(F){if(g(F))return!F.nextSibling||b(F.nextSibling)?null:F.nextSibling;if(F.firstChild&&b(F.firstChild))throw Error("Found invalid end comment, as the first child of "+F);return F.firstChild},nextSibling:function(F){if(g(F)&&(F=B(F)),F.nextSibling&&b(F.nextSibling)){var H=F.nextSibling;if(b(H)&&!m.a.g.get(H,z))throw Error("Found end comment without a matching opening comment, as child of "+F);return null}return F.nextSibling},Cd:g,Vd:function(F){return(F=(M?F.text:F.nodeValue).match(O))?F[1]:null},Sc:function(F){if(k[m.a.R(F)]){var H=F.firstChild;if(H)do if(H.nodeType===1){var Y;Y=H.firstChild;var $=null;if(Y)do if($)$.push(Y);else if(g(Y)){var W=B(Y,!0);W?Y=W:$=[Y]}else b(Y)&&($=[Y]);while(Y=Y.nextSibling);if(Y=$)for($=H.nextSibling,W=0;W<Y.length;W++)$?F.insertBefore(Y[W],$):F.appendChild(Y[W])}while(H=H.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(g){switch(g.nodeType){case 1:return g.getAttribute("data-bind")!=null||m.j.getComponentNameForNode(g);case 8:return m.h.Cd(g);default:return!1}},getBindings:function(g,b){var T=this.getBindingsString(g,b),T=T?this.parseBindingsString(T,b,g):null;return m.j.tc(T,g,b,!1)},getBindingAccessors:function(g,b){var T=this.getBindingsString(g,b),T=T?this.parseBindingsString(T,b,g,Bindings value: `+g+`Message: `+F.message,F}}}),m.ga.instance=new m.ga})(),m.b("bindingProvider",m.ga),(function(){function g(re){var ye=(re=m.a.g.get(re,ge))&&re.N;ye&&(re.N=null,ye.Tc())}function b(re,ye,Ce){this.node=re,this.yc=ye,this.kb=[],this.H=!1,ye.N||m.a.K.za(re,g),Ce&&Ce.N&&(Ce.N.kb.push(re),this.Kb=Ce)}function T(re){return function(){return re}}function B(re){return re()}function M(re){return m.a.Ga(m.u.G(re),function(ye,Ce){return function(){return re()[Ce]}})}function O(re,ye,Ce){return typeof re=="function"?M(re.bind(null,ye,Ce)):m.a.Ga(re,T)}function G(re,ye){return M(this.getBindings.bind(this,re,ye))}function k(re,ye){var Ce=m.h.firstChild(ye);if(Ce){var ve,Ne=m.ga.instance,Le=Ne.preprocessNode;if(Le){for(;ve=Ce;)Ce=m.h.nextSibling(ve),Le.call(Ne,ve);Ce=m.h.firstChild(ye)}for(;ve=Ce;)Ce=m.h.nextSibling(ve),z(re,ve)}m.i.ma(ye,m.i.H)}function z(re,ye){var Ce=re,ve=ye.nodeType===1;ve&&m.h.Sc(ye),(ve||m.ga.instance.nodeHasBindings(ye))&&(Ce=H(ye,null,re).bindingContextForDescendants),Ce&&!Z[m.a.R(ye)]&&k(Ce,ye)}function F(re){var ye=[],Ce={},ve=[];return m.a.P(re,function Ne(Le){if(!Ce[Le]){var Oe=m.getBindingHandler(Le);Oe&&(Oe.after&&(ve.push(Le),m.a.D(Oe.after,function(nt){if(re[nt]){if(m.a.A(ve,nt)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+ve.join(", "));Ne(nt)}}),ve.length--),ye.push({key:Le,Mc:Oe})),Ce[Le]=!0}}),ye}function H(re,ye,Ce){var ve=m.a.g.Ub(re,ge,{}),Ne=ve.hd;if(!ye){if(Ne)throw Error("You cannot apply bindings multiple times to the same element.");ve.hd=!0}Ne||(ve.context=Ce),ve.Zb||(ve.Zb={});var Le;if(ye&&typeof ye!="function")Le=ye;else{var Oe=m.ga.instance,nt=Oe.getBindingAccessors||G,Fe=m.$(function(){return(Le=ye?ye(Ce,re):nt.call(Oe,re,Ce))&&(Ce[$]&&Ce[$](),Ce[K]&&Ce[K]()),Le},null,{l:re});Le&&Fe.ja()||(Fe=null)}var _t=Ce,rt;if(Le){var je=function(){return m.a.Ga(Fe?Fe():Le,B)},st=Fe?function(ft){return function(){return B(Fe()[ft])}}:function(ft){return Le[ft]};je.get=function(ft){return Le[ft]&&B(st(ft))},je.has=function(ft){return ft in Le},m.i.H in Le&&m.i.subscribe(re,m.i.H,function(){var ft=(0,Le[m.i.H])();if(ft){var St=m.h.childNodes(re);St.length&&ft(St,m.Ec(St[0]))}}),m.i.pa in Le&&(_t=m.i.Cb(re,Ce),m.i.subscribe(re,m.i.pa,function(){var ft=(0,Le[m.i.pa])();ft&&m.h.firstChild(re)&&ft(re)})),ve=F(Le),m.a.D(ve,function(ft){var St=ft.Mc.init,be=ft.Mc.update,Se=ft.key;if(re.nodeType===8&&!m.h.ea[Se])throw Error("The binding '"+Se+"' cannot be used with virtual elements");try{typeof St=="function"&&m.u.G(function(){var qt=St(re,st(Se),je,_t.$data,_t);if(qt&&qt.controlsDescendantBindings){if(rt!==e)throw Error("Multiple bindings ("+rt+" and "+Se+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");rt=Se}}),typeof be=="function"&&m.$(function(){be(re,st(Se),je,_t.$data,_t)},null,{l:re})}catch(qt){throw qt.message='Unable to process binding "'+Se+": "+Le[Se]+`"Message: `+qt.message,qt}})}return ve=rt===e,{shouldBindDescendants:ve,bindingContextForDescendants:ve&&_t}}function Y(re,ye){return re&&re instanceof m.fa?re:new m.fa(re,e,e,ye)}var $=m.a.Da("_subscribable"),W=m.a.Da("_ancestorBindingInfo"),K=m.a.Da("_dataDependency");m.c={};var Z={script:!0,textarea:!0,template:!0};m.getBindingHandler=function(re){return m.c[re]};var pe={};m.fa=function(re,ye,Ce,ve,Ne){function Le(){var st=_t?Fe():Fe,ft=m.a.f(st);return ye?(m.a.extend(Oe,ye),W in ye&&(Oe[W]=ye[W])):(Oe.$parents=[],Oe.$root=ft,Oe.ko=m),Oe[$]=rt,nt?ft=Oe.$data:(Oe.$rawData=st,Oe.$data=ft),Ce&&(Oe[Ce]=ft),ve&&ve(Oe,ye,ft),ye&&ye[$]&&!m.S.o().Vb(ye[$])&&ye[$](),je&&(Oe[K]=je),Oe.$data}var Oe=this,nt=re===pe,Fe=nt?e:re,_t=typeof Fe=="function"&&!m.O(Fe),rt,je=Ne&&Ne.dataDependency;Ne&&Ne.exportDependencies?Le():(rt=m.xb(Le),rt.v(),rt.ja()?rt.equalityComparer=null:Oe[$]=e)},m.fa.prototype.createChildContext=function(re,ye,Ce,ve){if(!ve&&ye&&typeof ye=="object"&&(ve=ye,ye=ve.as,Ce=ve.extend),ye&&ve&&ve.noChildContext){var Ne=typeof re=="function"&&!m.O(re);return new m.fa(pe,this,null,function(Le){Ce&&Ce(Le),Le[ye]=Ne?re():re},ve)}return new m.fa(re,this,ye,function(Le,Oe){Le.$parentContext=Oe,Le.$parent=Oe.$data,Le.$parents=(Oe.$parents||[]).slice(0),Le.$parents.unshift(Le.$parent),Ce&&Ce(Le)},ve)},m.fa.prototype.extend=function(re,ye){return new m.fa(pe,this,null,function(Ce){m.a.extend(Ce,typeof re=="function"?re(Ce):re)},ye)};var ge=m.a.g.Z();b.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)},b.prototype.sd=function(re){m.a.Pa(this.kb,re),!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,g),m.i.ma(this.node,m.i.pa),this.Tc())},m.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(re,ye,Ce,ve,Ne){var Le=m.a.g.Ub(re,ge,{});return Le.Fa||(Le.Fa=new m.T),Ne&&Ne.notifyImmediately&&Le.Zb[ye]&&m.u.G(Ce,ve,[re]),Le.Fa.subscribe(Ce,ve,ye)},ma:function(re,ye){var Ce=m.a.g.get(re,ge);if(Ce&&(Ce.Zb[ye]=!0,Ce.Fa&&Ce.Fa.notifySubscribers(re,ye),ye==m.i.H)){if(Ce.N)Ce.N.Cc();else if(Ce.N===e&&Ce.Fa&&Ce.Fa.Wa(m.i.pa))throw Error("descendantsComplete event not supported for bindings on this node")}},Cb:function(re,ye){var Ce=m.a.g.Ub(re,ge,{});return Ce.N||(Ce.N=new b(re,Ce,ye[W])),ye[W]==Ce?ye:ye.extend(function(ve){ve[W]=Ce})}},m.Td=function(re){return(re=m.a.g.get(re,ge))&&re.context},m.ib=function(re,ye,Ce){return re.nodeType===1&&m.h.Sc(re),H(re,ye,Y(Ce))},m.ld=function(re,ye,Ce){return Ce=Y(Ce),m.ib(re,O(ye,Ce,re),Ce)},m.Oa=function(re,ye){ye.nodeType!==1&&ye.nodeType!==8||k(Y(re),ye)},m.vc=function(re,ye,Ce){if(!o&&t.jQuery&&(o=t.jQuery),2>arguments.length){if(ye=n.body,!ye)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!ye||ye.nodeType!==1&&ye.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");z(Y(re,Ce),ye)},m.Dc=function(re){return!re||re.nodeType!==1&&re.nodeType!==8?e:m.Td(re)},m.Ec=function(re){return(re=m.Dc(re))?re.$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(g){function b(G,k){var z=Object.prototype.hasOwnProperty.call(M,G)?M[G]:g,F;z?z.subscribe(k):(z=M[G]=new m.T,z.subscribe(k),T(G,function(H,Y){var $=!(!Y||!Y.synchronous);O[G]={definition:H,Gd:$},delete M[G],F||$?z.notifySubscribers(H):m.na.zb(function(){z.notifySubscribers(H)})}),F=!0)}function T(G,k){B("getConfig",[G],function(z){z?B("loadComponent",[G,z],function(F){k(F,z)}):k(null,null)})}function B(G,k,z,F){F||(F=m.j.loaders.slice(0));var H=F.shift();if(H){var Y=H[G];if(Y){var $=!1;if(Y.apply(H,k.concat(function(W){$?z(null):W!==null?z(W):B(G,k,z,F)}))!==g&&($=!0,!H.suppressLoaderExceptions))throw Error("Compon
* @license * Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5
* Copyright (c) Steve Sanderson * MIT license */var bte="__knockoutObservables",xte="__knockoutSubscribable";function gDe(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=_De(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(o){if(!(o===bte||o===xte)&&!(o in i)){var r=e[o],a=r instanceof Array,s=n.isObservable(r)?r:a?n.observableArray(r):n.observable(r);Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:s,set:n.isWriteableObservable(s)?s:void 0}),i[o]=s,a&&ZMt(n,s)}}),e}function _De(e,t){var n=e[bte];return!n&&t&&(n={},Object.defineProperty(e,bte,{value:n})),n}function JMt(e,t,n){var i=this,o={owner:e,deferEvaluation:!0};if(typeof n=="function")o.read=n;else{if("value"in n)throw new Error('For ko.defineProperty, you must not specify a "value" for the property. You must provide a "get" function.');if(typeof n.get!="function")throw new Error('For ko.defineProperty, the third parameter must be either an evaluator function, or an options object containing a function called "get".');o.read=n.get,o.write=n.set}return e[t]=i.computed(o),gDe.call(i,e,[t]),e}function ZMt(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=$Mt(e,t,i))})}function $Mt(e,t,n){var i=eNt(e,n);return i.subscribe(t)}function eNt(e,t){var n=t[xte];if(!n){n=new e.subscribable,Object.defineProperty(t,xte,{value:n});var i={};tNt(t,n,i),nNt(e,t,n,i)}return n}function tNt(e,t,n){["pop","push","reverse","shift","sort","splice","unshift"].forEach(function(i){var o=e[i];e[i]=function(){var r=o.apply(this,arguments);return n.pause!==!0&&t.notifySubscribers(this),r}})}function nNt(e,t,n,i){["remove","removeAll","destroy","destroyAll","replace"].forEach(function(o){Object.defineProperty(t,o,{enumerable:!1,value:function(){var r;i.pause=!0;try{r=e.observableArray.fn[o].apply(e.observableArray(t),arguments)}finally{i.pause=!1}return n.notifySubscribers(t),r}})})}function yDe(e,t){if(!e)return null;var n=_De(e,!1);return n&&n[t]||null}function iNt(e,t){var n=yDe(e,t);n&&n.valueHasMutated()}function oNt(e){e.track=gDe,e.getObservable=yDe,e.valueHasMutated=iNt,e.defineProperty=JMt}var M9={attachToKo:oNt};var CDe="http://www.w3.org/2000/svg",EDe="cesium-svgPath-svg",rNt={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){let i=document.createElementNS(CDe,"svg:svg");i.setAttribute("class",EDe);let o=document.createElementNS(CDe,"path");return i.appendChild(o),e.virtualElements.setDomNodeChildren(t,[i]),e.computed({read:function(){let r=e.unwrap(n());o.setAttribute("d",e.unwrap(r.path));let a=e.unwrap(r.width),s=e.unwrap(r.height);i.setAttribute("width",a),i.setAttribute("height",s),i.setAttribute("viewBox",`0 0 ${a} ${s}`),r.css&&i.setAttribute("class",`${EDe} ${e.unwrap(r.css)}`)},disposeWhenNodeIsRemoved:t}),{controlsDescendantBindings:!0}}},e.virtualElements.allowedBindings.cesiumSvgPath=!0}},N9=rNt;M9.attachToKo(ow);N9.register(ow);var xe=ow;function XR(e){l(e)||(e=new hp),this._clock=e,this._eventHelper=new Hr,this._eventHelper.add(e.onTick,this.synchronize,this),this.systemTime=xe.observable(X.now()),this.systemTime.equalityComparer=X.equals,this.startTime=xe.observable(e.startTime),this.startTime.equalityComparer=X.equals,this.startTime.subscribe(function(t){e.startTime=t,this.synchronize()},this),this.stopTime=xe.observable(e.stopTime),this.stopTime.equalityComparer=X.equals,this.stopTime.subscribe(function(t){e.stopTime=t,this.synchronize()},this),this.currentTime=xe.observable(e.currentTime),this.currentTime.equalityComparer=X.equals,this.currentTime.subscribe(function(t){e.currentTime=t,this.synchronize()},this),this.multiplier=xe.observable(e.multiplier),this.multiplier.subscribe(function(t){e.multiplier=t,this.synchronize()},this),this.clockStep=xe.observable(e.clockStep),this.clockStep.subscribe(function(t){e.clockStep=t,this.synchronize()},this),this.clockRange=xe.observable(e.clockRange),this.clockRange.subscribe(function(t){e.clockRange=t,this.synchronize()},this),this.canAnimate=xe.observable(e.canAnimate),this.canAnimate.subscribe(function(t) <ul class="cesium-cesiumInspector-statistics"> <li><strong>Geometry Memory (MB): </strong>${$R(e.geometryByteLength)}</li> <li><strong>Texture Memory (MB): </strong>${$R(e.texturesByteLength)}</li> </ul> `}var yNt=[{text:"Highlight",value:Yu.HIGHLIGHT},{text:"Replace",value:Yu.REPLACE},{text:"Mix",value:Yu.MIX}],BDe=new U(1,1,0,.4),CNt=new U,G9=new U;function uc(e,t){let n=this,i=e.canvas;this._eventHandler=new Ld(i),this._scene=e,this._performanceContainer=t,this._canvas=i,this._performanceDisplay=new hC({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,xe.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=xe.observable({}),this.properties=[],xe.defineProperty(this,"properties",function(){let F=[],H=n._properties();for(let Y in H)H.hasOwnProperty(Y)&&F.push(Y);return F});let o=xe.observable();xe.defineProperty(this,"dynamicScreenSpaceError",{get:function(){return o()},set:function(F){o(F),l(n._tileset)&&(n._tileset.dynamicScreenSpaceError=F)}}),this.dynamicScreenSpaceError=!1;let r=xe.observable();xe.defineProperty(this,"colorBlendMode",{get:function(){return r()},set:function(F){r(F),l(n._tileset)&&(n._tileset.colorBlendMode=F,n._scene.requestRender())}}),this.colorBlendMode=Yu.HIGHLIGHT;let a=xe.observable(),s=xe.observable();xe.defineProperty(this,"picking",{get:function(){return s()},set:function(F){s(F),F?n._eventHandler.setInputAction(function(H){let Y=e.pick(H.endPosition);if(Y instanceof Vs?(n.feature=Y,n.tile=Y.content.tile):l(Y)&&l(Y.content)?(n.feature=void 0,n.tile=Y.content.tile):(n.feature=void 0,n.tile=void 0),!!l(n._tileset)){if(a&&l(Y)&&l(Y.content)){let $;e.pickPositionSupported&&($=e.pickPosition(H.endPosition),l($)&&(n._tileset.debugPickPosition=$)),n._tileset.debugPickedTile=Y.content.tile}else n._tileset.debugPickedTile=void 0;n._scene.requestRender()}},Dn.MOUSE_MOVE):(n.feature=void 0,n.tile=void 0,n._eventHandler.removeInputAction(Dn.MOUSE_MOVE))}}),this.picking=!0;let c=xe.observable();xe.defineProperty(this,"colorize",{get:function(){return c()},set:function(F){c(F),l(n._tileset)&&(n._tileset.debugColorizeTiles=F,n._scene.requestRender())}}),this.colorize=!1;let u=xe.observable();xe.defineProperty(this,"wireframe",{get:function(){return u()},set:function(F){u(F),l(n._tileset)&&(n._tileset.debugWireframe=F,n._scene.requestRender())}}),this.wireframe=!1;let f=xe.observable();xe.defineProperty(this,"showBoundingVolumes",{get:function(){return f()},set:function(F){f(F),l(n._tileset)&&(n._tileset.debugShowBoundingVolume=F,n._scene.requestRender())}}),this.showBoundingVolumes=!1;let h=xe.observable();xe.defineProperty(this,"showContentBoundingVolumes",{get:function(){return h()},set:function(F){h(F),l(n._tileset)&&(n._tileset.debugShowContentBoundingVolume=F,n._scene.requestRender())}}),this.showContentBoundingVolumes=!1;let p=xe.observable();xe.defineProperty(this,"showRequestVolumes",{get:function(){return p()},set:function(F){p(F),l(n._tileset)&&(n._tileset.debugShowViewerRequestVolume=F,n._scene.requestRender())}}),this.showRequestVolumes=!1;let A=xe.observable();xe.defineProperty(this,"freezeFrame",{get:function(){return A()},set:function(F){A(F),l(n._tileset)&&(n._tileset.debugFreezeFrame=F,n._scene.debugShowFrustumPlanes=F,n._scene.requestRender())}}),this.freezeFrame=!1,xe.defineProperty(this,"showOnlyPickedTileDebugLabel",{get:function(){return a()},set:function(F){a(F),l(n._tileset)&&(n._tileset.debugPickedTileLabelOnly=F,n._scene.requestRender())}}),this
`),c=s.length,u;if(t.shiftKey)for(u=0;u<c;++u)s[u][0]===" "&&(s[u][1]===" "?(s[u]=s[u].substr(2),r-=2):(s[u]=s[u].substr(1),r-=1));else for(u=0;u<c;++u)s[u]=` ${s[u]}`,r+=2;let f=s.join(``);n.value=n.value.slice(0,i)+f+n.value.slice(o),n.selectionStart=i!==o?i:r,n.selectionEnd=r}else t.ctrlKey&&(t.keyCode===10||t.keyCode===13)&&this.compileStyle();return!0};uc.prototype._update=function(){let e=this._tileset;if(this.performance&&this._performanceDisplay.update(),l(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=eM(e,!1),this._pickStatisticsText=eM(e,!0),this._resourceCacheStatisticsText=vDe())};uc.prototype.isDestroyed=function(){return!1};uc.prototype.destroy=function(){this._eventHandler.destroy(),this._removePostRenderEvent();let e=this;return this._definedProperties.forEach(function(t){xe.getObservable(e,t).dispose()}),fe(this)};uc.getStatistics=eM;var V9=uc;function H9(e,t){e=zn(e);let n=document.createElement("div"),i=document.createElement("div");i.setAttribute("data-bind","visible: performance");let o=new V9(t,i);this._viewModel=o,this._container=e,this._element=n;let r=document.createElement("div");r.textContent="3D Tiles Inspector",r.className="cesium-cesiumInspector-button",r.setAttribute("data-bind","click: toggleInspector"),n.appendChild(r),n.className="cesium-cesiumInspector cesium-3DTilesInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let a=document.createElement("div");a.className="cesium-cesiumInspector-dropDown",n.appendChild(a);let s=Rf.createSection,c=Rf.createCheckbox,u=Rf.createRangeInput,f=Rf.createButton,h=s(a,"Tileset","tilesetVisible","toggleTileset"),p=s(a,"Display","displayVisible","toggleDisplay"),A=s(a,"Update","updateVisible","toggleUpdate"),m=s(a,"Logging","loggingVisible","toggleLogging"),_=s(a,"Tile Debug Labels","tileDebugLabelsVisible","toggleTileDebugLabels"),y=s(a,"Style","styleVisible","toggleStyle"),C=s(a,"Optimization","optimizationVisible","toggleOptimization"),E=document.createElement("div");E.className="field-group";let I=document.createElement("label");I.className="field-label",I.appendChild(document.createTextNode("Properties: "));let x=document.createElement("div");x.setAttribute("data-bind","text: properties"),E.appendChild(I),E.appendChild(x),h.appendChild(E),h.appendChild(f("Pick Tileset","togglePickTileset","pickActive")),h.appendChild(f("Trim Tiles Cache","trimTilesCache")),h.appendChild(c("Enable Picking","picking")),p.appendChild(c("Colorize","colorize"));let S=p.appendChild(c("Wireframe","wireframe","_tileset === undefined || hasEnabledWireframe")),w=document.createElement("p");w.setAttribute("data-bind","visible: _tileset !== undefined && !hasEnabledWireframe"),w.setAttribute("class","cesium-3DTilesInspector-disabledElementsInfo"),w.innerText="Set enableDebugWireframe to true in the tileset constructor to enable this option.",S.appendChild(w),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 v=document.createElement("div");v.setAttribute("data-bind","visible: pointCloudShading"),v.appendChild(u("Geometric Error Scale","geometricErrorScale",0,2,.01)),v.appendChild(u("Maximum Attenuation","maximumAttenuation",0,32,1)),v.appendChild(u("Base Resolution","baseResolution",0,1,.01)),v.appendChild(c("Eye Dome Lighting (EDL)","eyeDomeLighting")),p.appendChild(v);let R=document.createElement("div");R.setAttribute("data-bind","visible: eyeDomeLighting"),R.appendChild(u("EDL Strength","eyeDomeLightingStrength",0,2,.1)),R.appendChild(u("EDL Radius","eyeDomeLightingRadius",0,4,.1)),v.appendChild(R),A.appendChild(c("Freeze Frame","freezeFrame")),A.appendChild(c("Dynamic Screen Space Error","dynamicScreenSpaceError"));let N=document.createElement("div");N.appendChild(u("Maximum Screen Space Error","maximumS
${m}`:l(A)?A:m}),this.buttonImageUrl=void 0,xe.defineProperty(this,"buttonImageUrl",function(){let h=this.selectedImagery;if(l(h))return h.iconUrl}),this.selectedImagery=void 0;let c=xe.observable();this.updateSelectedImageryViewModel=h=>{c(h),this.dropDownVisible=!1},this._currentImageryLayers=[],xe.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(h){if(c()===h){this.dropDownVisible=!1;return}let p=e.map,A,m=this._currentImageryLayers,_=m.length,y=this._globe.imageryLayers,C=!1;if(!p)for(A=0;A<_;A++){let E=y.length;for(let I=0;I<E;I++){let x=y.get(I);if(x===m[A]){y.remove(x),C=!0;break}}}if(l(h))if(p&&h.marsOptions)p.basemap=h.marsOptions.layerId;else if(p&&h.options&&h.isTile)p.basemap=h.options.id;else{let E=h.creationCommand();if(Array.isArray(E)){let I=E.length;for(this._currentImageryLayers=[],A=I-1;A>=0;A--){let x=Ta.fromProviderAsync(E[A]);y.add(x,0),this._currentImageryLayers.push(x)}}else{this._currentImageryLayers=[];let I=Ta.fromProviderAsync(E);if(I.name=h.name,C)y.add(I,0);else{let x=y.get(0);l(x)&&y.remove(x),y.add(I,0)}this._currentImageryLayers.push(I)}}else p&&(p.basemap=void 0);c(h),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;let u=xe.observable();this.updateSelectedTerrainViewModel=h=>{u(h),this.dropDownVisible=!1},xe.defineProperty(this,"selectedTerrain",{get:function(){return u()},set:function(h){if(u()===h){this.dropDownVisible=!1;return}let p;if(l(h)&&(p=h.creationCommand()),l(p)&&!l(p.then)){if(e.map&&h.marsOptions){e.map.terrainProvider=p;return}this._globe.terrainProvider=p}else if(l(p)){let A=!1,m=this._globe.terrainProviderChanged.addEventListener(()=>{A=!0,m()}),y=new v9(p).readyEvent.addEventListener(C=>{if(!A){if(e.map&&h.marsOptions){e.map.terrainProvider=C;return}this._globe.terrainProvider=C,y()}})}u(h),this.dropDownVisible=!1}});let f=this;this._toggleDropDown=Mn(function(){f.dropDownVisible=!f.dropDownVisible}),this.selectedImagery=e.selectedImageryProviderViewModel,this.selectedTerrain=e.selectedTerrainProviderViewModel}Object.defineProperties(PDe.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});var j9=PDe;function Y9(e,t){e=zn(e);let n=new j9(t),i=document.createElement("button");i.type="button",i.className="cesium-button cesium-toolbar-button",i.setAttribute("data-bind","attr: { title: buttonTooltip },click: toggleDropDown"),e.appendChild(i);let o=document.createElement("img");o.setAttribute("draggable","false"),o.className="cesium-baseLayerPicker-selected",o.setAttribute("data-bind","attr: { src: buttonImageUrl }, visible: !!buttonImageUrl"),i.appendChild(o);let r=document.createElement("div");r.className="cesium-baseLayerPicker-dropDown",r.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }'),e.appendChild(r);let a=document.createElement("div");a.className="cesium-baseLayerPicker-sectionTitle",a.setAttribute("data-bind","visible: imageryProviderViewModels.length > 0"),a.innerHTML="Imagery",r.appendChild(a);let s=document.createElement("div");s.className="cesium-baseLayerPicker-section",s.setAttribute("data-bind","foreach: _imageryProviders"),r.appendChild(s);let c=document.createElement("div");c.className="cesium-baseLayerPicker-category",s.appendChild(c);let u=document.createElement("div");u.className="cesium-baseLayerPicker-categoryTitle",u.setAttribute("data-bind","text: name"),c.appendChild(u);let f=document.createElement("div");f.className="cesium-baseLayerPicker-choices",f.setAttribute("data-bind","foreach: providers"),c.appendChild(f);let h=document.createElement("div");h.className="cesium-baseLayerPicker-item",h.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(h);let p=document.createElement("img");p.className="cesium-baseLayerPicker-itemIcon",p.setAttribute("data-bind","attr: { src: iconUrl }"),p.setAttribute("draggable
https://www.arcgis.com/home/item.html?id=10df2279f9684e4a9f6a7f08febac2a9`,category:"Other",creationFunction:function(){return G_.fromBasemapType($m.SATELLITE,{enablePickFeatures:!1})}})),e.push(new mr({name:"ArcGIS World Hillshade",iconUrl:Zt("Widgets/Images/ImageryProviders/ArcGisMapServiceWorldHillshade.png"),tooltip:`ArcGIS World Hillshade map portrays elevation as an artistic hillshade. This map is designed to be used as a backdrop for topographical, soil, hydro, landcover or other outdoor recreational maps. The map was compiled from a variety of sources from several data providers. The basemap has global coverage down to a scale of ~1:72k. In select areas of the United States and Europe, coverage is available down to ~1:9k. For more information on this map, including the terms of use, visit us online at
https://www.arcgis.com/home/item.html?id=1b243539f4514b6ba35e7d995890db1d`,category:"Other",creationFunction:function(){return G_.fromBasemapType($m.HILLSHADE,{enablePickFeatures:!1})}})),e.push(new mr({name:"Esri World Ocean",iconUrl:Zt("Widgets/Images/ImageryProviders/ArcGisMapServiceWorldOcean.png"),tooltip:`ArcGIS World Ocean map is designed to be used as a base map by marine GIS professionals and as a reference map by anyone interested in ocean data. The base map features marine bathymetry. Land features include inland waters and roads overlaid on land cover and shaded relief imagery. The map was compiled from a variety of best available sources from several data providers, including General Bathymetric Chart of the Oceans GEBCO_08 Grid, National Oceanic and Atmospheric Administration (NOAA), and National Geographic, Garmin, HERE, Geonames.org, and Esri, and various other contributors. The base map currently provides coverage for the world down to a scale of ~1:577k, and coverage down to 1:72k in US coastal areas, and various other areas. Coverage down to ~ 1:9k is available limited areas based on regional hydrographic survey data. The base map was designed and developed by Esri. For more information on this map, including our terms of use, visit us online at
https://www.arcgis.com/home/item.html?id=1e126e7520f9466c9ca28b8f28b5e500`,category:"Other",creationFunction:function(){return G_.fromBasemapType($m.OCEANS,{enablePickFeatures:!1})}})),e.push(new mr({name:"Open\xADStreet\xADMap",iconUrl:Zt("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 bC({url:"https://tile.openstreetmap.org/"})}})),e.push(new mr({name:"Stadia x Stamen Watercolor",iconUrl:Zt("Widgets/Images/ImageryProviders/stamenWatercolor.png"),tooltip:`Based on the original basemaps created for the Knight Foundation and reminiscent of hand drawn maps, the watercolor maps from Stamen Design apply raster effect area washes and organic edges over a paper texture to add warm pop to any map.
https://docs.stadiamaps.com/map-styles/stamen-watercolor/`,category:"Other",creationFunction:function(){return new bC({url:"https://tiles.stadiamaps.com/tiles/stamen_watercolor/",fileExtension:"jpg",credit:`© <a href="https://stamen.com/" target="_blank">Stamen Design</a>
© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`})}})),e.push(new mr({name:"Stadia x Stamen Toner",iconUrl:Zt("Widgets/Images/ImageryProviders/stamenToner.png"),tooltip:`Based on the original basemaps created for the Knight Foundation and the most popular of the excellent styles from Stamen Design, these high-contrast B+W (black and white) maps are the perfect backdrop for your colorful and eye-catching overlays.https://docs.stadiamaps.com/map-styles/stamen-toner/`,category:"Other",creationFunction:function(){return new bC({url:"https://tiles.stadiamaps.com/tiles/stamen_toner/",retinaTiles:t,credit:`© <a href="https://stamen.com/" target="_blank">Stamen Design</a>
© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a> © <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`})}})),e.push(new mr({name:"Stadia Alidade Smooth",iconUrl:Zt("Widgets/Images/ImageryProviders/stadiaAlidadeSmooth.png"),tooltip:`Stadia's custom Alidade Smooth style is designed for maps that use a lot of markers or overlays. It features a muted color scheme and fewer points of interest to allow your added data to shine.https://docs.stadiamaps.com/map-styles/alidade-smooth/`,category:"Other",creationFunction:function(){return new bC({url:"https://tiles.stadiamaps.com/tiles/alidade_smooth/",retinaTiles:t,credit:`© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`})}})),e.push(new mr({name:"Stadia Alidade Smooth Dark",iconUrl:Zt("Widgets/Images/ImageryProviders/stadiaAlidadeSmoothDark.png"),tooltip:`Stadia Alidade Smooth Dark, like its lighter cousin, is also designed to stay out of the way. It just flips the dark mode switch on the color scheme. With the lights out, your data can now literally shine.https://docs.stadiamaps.com/map-styles/alidade-smooth-dark/`,category:"Other",creationFunction:function(){return new bC({url:"https://tiles.stadiamaps.com/tiles/alidade_smooth_dark/",retinaTiles:t,credit:`© <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
© <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a> © <a href="https://www.openstreetmap.org/about/" target="_blank">OpenStreetMap contributors</a>`})}})),e.push(new mr({name:"Sentinel-2",iconUrl:Zt("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 du.fromAssetId(3954)}})),e.push(new mr({name:"Blue Marble",iconUrl:Zt("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3845)}})),e.push(new mr({name:"Earth at night",iconUrl:Zt("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 du.fromAssetId(3812)}})),e.push(new mr({name:"Natural Earth\xA0II",iconUrl:Zt("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.http://www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return BE.fromUrl(Zt("Assets/Textures/NaturalEarthII"))}})),e.push(new mr({name:"Google Maps Satellite",iconUrl:Zt("Widgets/Images/ImageryProviders/googleSatellite.png"),tooltip:"Imagery from Google Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3830182)}})),e.push(new mr({name:"Google Maps Satellite with Labels",iconUrl:Zt("Widgets/Images/ImageryProviders/googleSatelliteLabels.png"),tooltip:"Imagery with place labels from Google Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3830183)}})),e.push(new mr({name:"Google Maps Roadmap",iconUrl:Zt("Widgets/Images/ImageryProviders/googleRoadmap.png"),tooltip:"Labeled roads and other features on a base landscape from Google Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3830184)}})),e.push(new mr({name:"Google Maps Contour",iconUrl:Zt("Widgets/Images/ImageryProviders/googleContour.png"),tooltip:"Hillshade mapping, contour lines, natural features (roadmap features hidden) from Google Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3830186)}})),e.push(new mr({name:"Azure Maps Aerial",iconUrl:Zt("Widgets/Images/ImageryProviders/azureAerial.png"),tooltip:"Imagery from Azure Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3891168)}})),e.push(new mr({name:"Azure Maps Roads",iconUrl:Zt("Widgets/Images/ImageryProviders/azureRoads.png"),tooltip:"Labeled roads and other features on a base landscape from Azure Maps",category:"Cesium ion",creationFunction:function(){return du.fromAssetId(3891169)}})),e}var K9=ENt;function INt(){let e=[];return e.push(new mr({name:"WGS84 Ellipsoid",iconUrl:Zt("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new gS({ellipsoid:te.WGS84})}})),e.push(new mr({name:"Cesium World Terrain",iconUrl:Zt("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 mS({requestWaterMask:!0,requestVertexNormals:!0})}})),e}var X9=INt;function bNt(e){let t;if(l(e)){t="Command Statistics";let n=e.commandsInFrustums;for(let i in n)if(n.hasOwnProperty(i)){let o=parseInt(i,10),r;if(o===7)r="1, 2 and 3";else{let a=[];for(let s=2;s>=0;s--){let c=Math.pow(2,s);o>=c&&(a.push(s+1),o-=c)}r=a.reverse().join(" and ")}t+=`<br> ${n[i]} in frustum ${r}`}t+=`<br>Total: ${e.totalCommands}`}return t}function vte(e,t,n){let i=Math.min(n,t);return i=Math.max(i,e),i}var xNt=new In,TNt=new d;function tM(e,t){let n=this,i=e.canvas,o=new Ld(i);this._eventHandler=o,this._scene=e,this._canvas=i,this._primitive=void 0,this._tile=void 0,this._modelMatrixPrimitive=void 0,this._performanceDisplay=void 0,this._performanceContainer=t;let r=this._scene.globe;r.depthTestAgainstTerrain=!0,this.frustums=!1,this.frustumPlanes=!1,this.performance=!1,this.shaderCacheText="",this.primitiveBoundingSphere=!1,this.primitiveReferenceFrame=!1,this.filterPrimitive=!1,this.tileBoundingSphere=!1,this.filterTile=!1,this.wireframe=!1,this.depthFrustum=1,this._numberOfFrustums=1,this.suspendUpdates=!1,this.tileCoordinates=!1,this.frustumStatisticText=!1,this.tileText="",this.hasPickedPrimitive=!1,this.hasPickedTile=!1,this.pickPrimitiveActive=!1,this.pickTileActive=!1,this.dropDownVisible=!0,this.generalVisible=!0,this.primitivesVisible=!1,this.terrainVisible=!1,this.depthFrustumText="",xe.track(this,["frustums","frustumPlanes","performance","shaderCacheText","primitiveBoundingSphere","primitiveReferenceFrame","filterPrimitive","tileBoundingSphere","filterTile","wireframe","depthFrustum","suspendUpdates","tileCoordinates","frustumStatisticText","tileText","hasPickedPrimitive","hasPickedTile","pickPrimitiveActive","pickTileActive","dropDownVisible","generalVisible","primitivesVisible","terrainVisib
<h3>Building explorer</h3> <select data-bind="options: topLayers, optionsText: 'name', optionsAfterRender: setOptionDisable, value: currentLayer" ></select> <div id="bsl-wrapper"> <h3>Select Level</h3> <select data-bind="options: levels, value: currentLevel"></select> <h3>Disciplines & Categories</h3> <ul class="layersList" data-bind="foreach: sublayers"> <ul class="layersList" data-bind="foreach: sublayers.sort(function (l, r) { return l.name.localeCompare(r.name) })"> <li> <div class="li-wrapper"> <span class="expandItem" data-bind="click: $root.expandClickHandler" >+</span > <input type="checkbox" data-bind="checked: visibility, valueUpdate: 'input', attr: { id: name}" /> <label data-bind="attr: { for: name}"> <span data-bind="text: name"></span> </label> </div> <ul class="nested" data-bind="attr: { id: name + '-expander'}"> <li data-bind="foreach: sublayers.sort(function (l, r) { return l.name.localeCompare(r.name) })"> <div class="li-wrapper"> <input type="checkbox" data-bind="checked: visibility, valueUpdate: 'input', attr: { id: name}" /> <label data-bind="attr: { for: name}"> <span data-bind="text: name"></span> </label> </div> </li> </ul> </li> </ul> </ul> </div>`,n.appendChild(i);let o=new f5(t);xe.track(o),xe.applyBindings(o,n),l(o.defaultLayer)&&(o.currentLayer=o.defaultLayer)}var HDe=zNt;var GNt="M 13.84375 7.03125 C 11.412798 7.03125 9.46875 8.975298 9.46875 11.40625 L 9.46875 11.59375 L 2.53125 7.21875 L 2.53125 24.0625 L 9.46875 19.6875 C 9.4853444 22.104033 11.423165 24.0625 13.84375 24.0625 L 25.875 24.0625 C 28.305952 24.0625 30.28125 22.087202 30.28125 19.65625 L 30.28125 11.40625 C 30.28125 8.975298 28.305952 7.03125 25.875 7.03125 L 13.84375 7.03125 z",VNt="M 27.34375 1.65625 L 5.28125 27.9375 L 8.09375 30.3125 L 30.15625 4.03125 L 27.34375 1.65625 z M 13.84375 7.03125 C 11.412798 7.03125 9.46875 8.975298 9.46875 11.40625 L 9.46875 11.59375 L 2.53125 7.21875 L 2.53125 24.0625 L 9.46875 19.6875 C 9.4724893 20.232036 9.5676108 20.7379 9.75 21.21875 L 21.65625 7.03125 L 13.84375 7.03125 z M 28.21875 7.71875 L 14.53125 24.0625 L 25.875 24.0625 C 28.305952 24.0625 30.28125 22.087202 30.28125 19.65625 L 30.28125 11.40625 C 30.28125 9.8371439 29.456025 8.4902779 28.21875 7.71875 z";function Mte(){this._cameraClicked=new _e,this._closeClicked=new _e,this.maxHeight=500,this.enableCamera=!1,this.isCameraTracking=!1,this.showInfo=!1,this.titleText="",this.description="",xe.track(this,["showInfo","titleText","description","maxHeight","enableCamera","isCameraTracking"]),this._loadingIndicatorHtml='<div class="cesium-infoBox-loadingContainer"><span class="cesium-infoBox-loading"></span></div>',this.cameraIconPath=void 0,xe.defineProperty(this,"cameraIconPath",{get:function(){return!this.enableCamera||this.isCameraTracking?VNt:GNt}}),xe.defineProperty(this,"_bodyless",{get:function(){return!l(this.description)||this.description.length===0}})}Mte.prototype.maxHeightOffset=function(e){return`${this.maxHeight-e}px`};Object.defineProperties(Mte.prototype,{cameraClicked:{get:function(){return this._cameraClicked}},closeClicked:{get:function(){return this._closeClicked}}});var d5=Mte;function h5(e){e=zn(e);let t=document.createElement("div");t.className="cesium-infoBox",t.setAttribute("data-bind",'css: { "cesium-infoBox-visible" : showInfo, "cesium-infoBox-bodyless" : _bodyless }'),e.appendChild(t);let n=document.createElement("div");n.className="cesium-infoBox-title",n.setAttribute("data-bind","text: titleText"),t.appendChild(n);let i=document.createElement("button");i.type="button",i.className="cesium-button cesium-infoBox-camera",i.setAttribute("data-bind",'attr: { title: "Focus camera on object" },click: function () { cameraClicked.raiseEvent(this); },enable: enableCamera,cesiumSvgPath: { path: cameraIconPath, width: 32, height: 32 }'),t.appendChild(i);let o=document.createElement("button");o.type="button",o.className="cesium-infoBox-close",o.setAttribute("data-bind","click: function () { closeClicked.raiseEvent(this); }"),o.innerHTML="×",t.appendChild(o);let r=document.createElement("iframe");r.className="cesium-infoBox-iframe",r.setAttribute("sandbox","allow-same-origin allow-popups allow-forms"),r.setAttribute("data-bind","style : { maxHeight : maxHeightOffset(40) }"),r.setAttribute("allowfullscreen",!0),t.appendChild(r);let a=new d5;xe.applyBindings(a,t),this._container=e,this._element=t,this._frame=r,this._viewModel=a,this._descriptionSubscription=void 0;let s=this;r.addEventListener("load",function(){let c=r.contentDocument,u=c.createElement("link");u.href=Zt("Widgets/InfoBox/InfoBoxDescription.css"),u.rel="stylesheet",u.type="text/css";let f=c.createElement("div");f.className="cesium-infoBox-description",c.head.appendChild(u),c.body.appendChild(f),s._descriptionSubscription=wc(a,"description",function(h){r.style.height="5px",f.innerHTML=h;let p=null,A=f.firstElementChild;if(A!==null&&f.childNodes.length===1){let _=window.getComputedStyle(A);if(_!==null){let y=_["background-color"],C=U.fromCssColorString(y);l(C)&&C.alpha!==0&&(p=_["background-color"])}}t.style["background-color"]=p;let m=f.getBoundingClientRect().height;r.style.height=`${m}px`})}),r.setAttribute("src","about:blank")}Object.defineProperties(h5.prototype,{container:{get:function(){return thi`),n;for(n=0;n<t.length&&!t[n].match(/\S/);n++);if(n===t.length)return"";let i="",o=/^\s*/,a=t[n].match(o)[0].length;for(let s=n;s<t.length;s++){let c=t[s];c.match(o)[0].length>=a&&(c=c.slice(a)),i+=`${c}`}return i}function qd(e){this._scene=e,this._voxelPrimitive=void 0,this._customShaderCompilationRemoveCallback=void 0,this._definedProperties=[],this._getPrimitiveFunctions=[],this._modelMatrixReady=!1;let t=this;function n(o){let{name:r,initialValue:a}=o;t._definedProperties.push(r);let s=o.setPrimitiveFunction;s===!0&&(s=function(f){t._voxelPrimitive[r]=f});let c=o.getPrimitiveFunction;c===!0&&(c=function(){t[r]=t._voxelPrimitive[r]}),l(c)&&t._getPrimitiveFunctions.push(c);let u=xe.observable();return xe.defineProperty(t,r,{get:function(){return u()},set:function(f){typeof a=="number"&&typeof f=="string"&&(f=Number(f),isNaN(f)&&(f=a)),typeof a=="boolean"&&typeof f=="number"&&(f=f===1),u(f),l(s)&&l(t._voxelPrimitive)&&(s(f),e.requestRender())}}),t[r]=a,u}function i(o,r){return function(a){let s=t._voxelPrimitive[o].clone();s[r]=a,t._voxelPrimitive[o]=s}}n({name:"inspectorVisible",initialValue:!0}),n({name:"displayVisible",initialValue:!1}),n({name:"transformVisible",initialValue:!1}),n({name:"boundsVisible",initialValue:!1}),n({name:"clippingVisible",initialValue:!1}),n({name:"shaderVisible",initialValue:!1}),n({name:"shaderString",initialValue:"",getPrimitiveFunction:function(){let o=t._voxelPrimitive.customShader.fragmentShaderText;t.shaderString=lve(o)}}),n({name:"shaderCompilationMessage",initialValue:""}),n({name:"shaderCompilationSuccess",initialValue:!0}),n({name:"depthTest",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"show",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"disableUpdate",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"debugDraw",initialValue:!1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"jitter",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"nearestSampling",initialValue:!0,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"screenSpaceError",initialValue:4,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"stepSize",initialValue:1,setPrimitiveFunction:!0,getPrimitiveFunction:!0}),n({name:"shapeIsBox",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsBox=o===Sc.BOX}}),n({name:"shapeIsEllipsoid",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsEllipsoid=o===Sc.ELLIPSOID}}),n({name:"shapeIsCylinder",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsCylinder=o===Sc.CYLINDER}}),n({name:"clippingBoxMaxXMin",initialValue:0,getPrimitiveFunction:function(){t.clippingBoxMaxXMin=t._voxelPrimitive.minBounds.x}}),n({name:"clippingBoxMaxXMax",initialValue:1,getPrimitiveFunction:function(){t.clippingBoxMaxXMax=t._voxelPrimitive.maxBounds.x}}),n({name:"clippingBoxMaxX",initialValue:0,setPrimitiveFunction:i("maxClippingBounds","x"),getPrimitiveFunction:function(){t.clippingBoxMaxX=t._voxelPrimitive.maxClippingBounds.x}}),n({name:"clippingBoxMinXMin",initialValue:0,getPrimitiveFunction:function(){t.clippingBoxMinXMin=t._voxelPrimitive.minBounds.x}}),n({name:"clippingBoxMinXMax",initialValue:1,getPrimitiveFunction:function(){t.clippingBoxMinXMax=t._voxelPrimitive.maxBounds.x}}),n({name:"clippingBoxMinX",initialValue:0,setPrimitiveFunction:i("minClippingBounds","x"),getPrimitiveFunction:function(){t.clippingBoxMinX=t._voxelPrimitive.minClippingBounds.x}}),n({name:"clippingBoxMaxYMin",initialValue:0,getPrimitiveFunction:function(){t.clippingBoxMaxYMin=t._voxelPrimitive.minBounds.y}}),n({name:"clippingBoxMaxYMax",initialValue:1,getPrimitiveFunction:function(){t.clippingBoxMaxYMax=t._voxelPrimitive.maxBounds.y}}),n({name:"clippingBoxMaxY",initialValue:0,setPrimitiveFunction:i("maxClippingBounds","y"),getPrimitiveFunction:function(){t.clippingBoxMaxY=t._voxelPrimitive.maxClippingBounds.y}}),n({name:"clippingBoxMinYMin",initialValue:0,getPrimitiveFunction:function(){t.clippingBoxMinYMin=t._voxelPrimitive.minBounds.y}}),n({name:"clippingBoxMinYMax",initialValue:1,getPrimitiveFunction:function(){t.clippingBoxMinYMax=t._voxelPrimitive.maxBounds.y}}),n({name:"clippingBoxMinY",initialValue:0,setPrimitiveFunction:i("minCli
`),c=s.length,u;if(t.shiftKey)for(u=0;u<c;++u)s[u][0]===" "&&(s[u][1]===" "?(s[u]=s[u].substr(2),r-=2):(s[u]=s[u].substr(1),r-=1));else for(u=0;u<c;++u)s[u]=` ${s[u]}`,r+=2;let f=s.join(``);n.value=n.value.slice(0,i)+f+n.value.slice(o),n.selectionStart=i!==o?i:r,n.selectionEnd=r}else t.ctrlKey&&(t.keyCode===10||t.keyCode===13)&&this.compileShader();return!0};qd.prototype.isDestroyed=function(){return!1};qd.prototype.destroy=function(){let e=this;return this._definedProperties.forEach(function(t){xe.getObservable(e,t).dispose()}),fe(this)};var U5=qd;function z5(e,t){e=zn(e);let n=document.createElement("div"),i=new U5(t);this._viewModel=i,this._container=e,this._element=n;let o=document.createElement("div");o.textContent="Voxel Inspector",o.className="cesium-cesiumInspector-button",o.setAttribute("data-bind","click: toggleInspector"),n.appendChild(o),n.className="cesium-cesiumInspector cesium-VoxelInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let r=document.createElement("div");r.className="cesium-cesiumInspector-dropDown",n.appendChild(r);let{createSection:a,createCheckbox:s,createRangeInput:c,createButton:u}=Rf,f=a(r,"Display","displayVisible","toggleDisplay"),h=a(r,"Transform","transformVisible","toggleTransform"),p=a(r,"Clipping","clippingVisible","toggleClipping"),A=a(r,"Shader","shaderVisible","toggleShader");f.appendChild(s("Depth Test","depthTest")),f.appendChild(s("Show","show")),f.appendChild(s("Disable Update","disableUpdate")),f.appendChild(s("Debug Draw","debugDraw")),f.appendChild(s("Jitter","jitter")),f.appendChild(s("Nearest Sampling","nearestSampling")),f.appendChild(c("Screen Space Error","screenSpaceError",0,128)),f.appendChild(c("Step Size","stepSize",0,2));let m=10,_=10,y=D.PI;h.appendChild(c("Translation X","translationX",-m,+m)),h.appendChild(c("Translation Y","translationY",-m,+m)),h.appendChild(c("Translation Z","translationZ",-m,+m)),h.appendChild(c("Scale X","scaleX",0,+_)),h.appendChild(c("Scale Y","scaleY",0,+_)),h.appendChild(c("Scale Z","scaleZ",0,+_)),h.appendChild(c("Heading","angleX",-y,+y)),h.appendChild(c("Pitch","angleY",-y,+y)),h.appendChild(c("Roll","angleZ",-y,+y)),Gte("Max X","Min X","Max Y","Min Y","Max Z","Min Z","clippingBoxMaxX","clippingBoxMinX","clippingBoxMaxY","clippingBoxMinY","clippingBoxMaxZ","clippingBoxMinZ","shapeIsBox",p),Gte("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","clippingEllipsoidMaxLongitude","clippingEllipsoidMinLongitude","clippingEllipsoidMaxLatitude","clippingEllipsoidMinLatitude","clippingEllipsoidMaxHeight","clippingEllipsoidMinHeight","shapeIsEllipsoid",p),Gte("Max Radius","Min Radius","Max Angle","Min Angle","Max Height","Min Height","clippingCylinderMaxRadius","clippingCylinderMinRadius","clippingCylinderMaxAngle","clippingCylinderMinAngle","clippingCylinderMaxHeight","clippingCylinderMinHeight","shapeIsCylinder",p);let C=document.createElement("div");A.appendChild(C);let E=document.createElement("textarea");E.setAttribute("data-bind","textInput: shaderString, event: { keydown: shaderEditorKeyPress }"),C.className="cesium-cesiumInspector-styleEditor",C.appendChild(E);let I=u("Compile (Ctrl+Enter)","compileShader");C.appendChild(I);let x=document.createElement("label");x.style.display="block",x.setAttribute("data-bind","text: shaderCompilationMessage, style: {color: shaderCompilationSuccess ? 'green' : 'red'}"),C.appendChild(x),xe.applyBindings(i,n)}Object.defineProperties(z5.prototype,{container:{get:function(){return this._container}},viewModel:{get:function(){return this._viewModel}}});z5.prototype.isDestroyed=function(){return!1};z5.prototype.destroy=function(){return xe.cleanNode(this._element),this._container.removeChild(this._element),this.viewModel.destroy(),fe(this)};function Gte(e,t,n,i,o,r,a,s,c,u,f,h,p,A){let m=Rf.createRangeInputWithDynamicMinMax,_=A.appendChild(document.createElement("div"));_.setAttribute("data-bind",`if: ${p}`),_.appendChild(m(e,a)),_.appendChild(m(t,s)),_.appendChild(m(n,c)),_.appendChild(m(i,u)),_.appendChild(m(o,f)),_.appendChild(m(r,h))}var G5=z5;function SLt(e){let t=document.createElement("div");t.className="cesium-viewer-voxelIn
|