|
|
/** * @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.
*/
"use strict";var Cesium=(()=>{var gGe=Object.create;var TR=Object.defineProperty;var bGe=Object.getOwnPropertyDescriptor;var yGe=Object.getOwnPropertyNames;var xGe=Object.getPrototypeOf,CGe=Object.prototype.hasOwnProperty;var TGe=(e,t,n)=>t in e?TR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var UU=(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 nm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),EGe=(e,t)=>{for(var n in t)TR(e,n,{get:t[n],enumerable:!0})},gie=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of yGe(t))!CGe.call(e,o)&&o!==n&&TR(e,o,{get:()=>t[o],enumerable:!(i=bGe(t,o))||i.enumerable});return e};var y=(e,t,n)=>(n=e!=null?gGe(xGe(e)):{},gie(t||!e||!e.__esModule?TR(n,"default",{value:e,enumerable:!0}):n,e)),SGe=e=>gie(TR({},"__esModule",{value:!0}),e);var Bn=(e,t,n)=>TGe(e,typeof t!="symbol"?t+"":t,n);var x=nm(()=>{"use strict";globalThis.CESIUM_WORKERS=atob("dmFyIENlc2l1bVdvcmtlcnM9KCgpPT57dmFyIGhTPU9iamVjdC5jcmVhdGU7dmFyIHF1PU9iamVjdC5kZWZpbmVQcm9wZXJ0eTt2YXIgbVM9T2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcjt2YXIgYlM9T2JqZWN0LmdldE93blByb3BlcnR5TmFtZXM7dmFyIHBTPU9iamVjdC5nZXRQcm90b3R5cGVPZixnUz1PYmplY3QucHJvdG90eXBlLmhhc093blByb3BlcnR5O3ZhciBiYT0oZT0+dHlwZW9mIHJlcXVpcmU8InUiP3JlcXVpcmU6dHlwZW9mIFByb3h5PCJ1Ij9uZXcgUHJveHkoZSx7Z2V0Oih0LG4pPT4odHlwZW9mIHJlcXVpcmU8InUiP3JlcXVpcmU6dClbbl19KTplKShmdW5jdGlvbihlKXtpZih0eXBlb2YgcmVxdWlyZTwidSIpcmV0dXJuIHJlcXVpcmUuYXBwbHkodGhpcyxhcmd1bWVudHMpO3Rocm93IEVycm9yKCdEeW5hbWljIHJlcXVpcmUgb2YgIicrZSsnIiBpcyBub3Qgc3VwcG9ydGVkJyl9KSxjMT1lPT50PT57dmFyIG49ZVt0XTtpZihuKXJldHVybiBuKCk7dGhyb3cgbmV3IEVycm9yKCJNb2R1bGUgbm90IGZvdW5kIGluIGJ1bmRsZTogIit0KX07dmFyIFg9KGUsdCk9PigpPT4oZSYmKHQ9ZShlPTApKSx0KTt2YXIgZW89KGUsdCk9PigpPT4odHx8ZSgodD17ZXhwb3J0czp7fX0pLmV4cG9ydHMsdCksdC5leHBvcnRzKSxydD0oZSx0KT0+e2Zvcih2YXIgbiBpbiB0KXF1KGUsbix7Z2V0OnRbbl0sZW51bWVyYWJsZTohMH0pfSxzMT0oZSx0LG4sbyk9PntpZih0JiZ0eXBlb2YgdD09Im9iamVjdCJ8fHR5cGVvZiB0PT0iZnVuY3Rpb24iKWZvcihsZXQgYSBvZiBiUyh0KSkhZ1MuY2FsbChlLGEpJiZhIT09biYmcXUoZSxhLHtnZXQ6KCk9PnRbYV0sZW51bWVyYWJsZTohKG89bVModCxhKSl8fG8uZW51bWVyYWJsZX0pO3JldHVybiBlfTt2YXIgY2E9KGUsdCxuKT0+KG49ZSE9bnVsbD9oUyhwUyhlKSk6e30sczEodHx8IWV8fCFlLl9fZXNNb2R1bGU/cXUobiwiZGVmYXVsdCIse3ZhbHVlOmUsZW51bWVyYWJsZTohMH0pOm4sZSkpLF9TPWU9PnMxKHF1KHt9LCJfX2VzTW9kdWxlIix7dmFsdWU6ITB9KSxlKTtmdW5jdGlvbiB5UyhlKXtyZXR1cm4gZSE9bnVsbH12YXIgZyxzZT1YKCgpPT57Zz15U30pO2Z1bmN0aW9uIFlpKGUpe3RoaXMubmFtZT0iRGV2ZWxvcGVyRXJyb3IiLHRoaXMubWVzc2FnZT1lO2xldCB0O3RyeXt0aHJvdyBuZXcgRXJyb3J9Y2F0Y2gobil7dD1uLnN0YWNrfXRoaXMuc3RhY2s9dH12YXIgV3QsSmk9WCgoKT0+e3NlKCk7ZyhPYmplY3QuY3JlYXRlKSYmKFlpLnByb3RvdHlwZT1PYmplY3QuY3JlYXRlKEVycm9yLnByb3RvdHlwZSksWWkucHJvdG90eXBlLmNvbnN0cnVjdG9yPVlpKTtZaS5wcm90b3R5cGUudG9TdHJpbmc9ZnVuY3Rpb24oKXtsZXQgZT1gJHt0aGlzLm5hbWV9OiAke3RoaXMubWVzc2FnZX1gO3JldHVybiBnKHRoaXMuc3RhY2spJiYoZSs9YAoke3RoaXMuc3RhY2sudG9TdHJpbmcoKX1gKSxlfTtZaS50aHJvd0luc3RhbnRpYXRpb25FcnJvcj1mdW5jdGlvbigpe3Rocm93IG5ldyBZaSgiVGhpcyBmdW5jdGlvbiBkZWZpbmVzIGFuIGludGVyZmFjZSBhbmQgc2hvdWxkIG5vdCBiZSBjYWxsZWQgZGlyZWN0bHkuIil9O1d0PVlpfSk7ZnVuY3Rpb24gQVMoZSl7cmV0dXJuYCR7ZX0gaXMgcmVxdWlyZWQsIGFjdHVhbCB2YWx1ZSB3YXMgdW5kZWZpbmVkYH1mdW5jdGlvbiBxYyhlLHQsbil7cmV0dXJuYEV4cGVjdGVkICR7bn0gdG8gYmUgdHlwZW9mICR7dH0sIGFjdHVhbCB0eXBlb2Ygd2FzICR7ZX1gfXZhciB0byxNbixVbT1YKCgpPT57c2UoKTtKaSgpO3RvPXt9O3RvLnR5cGVPZj17fTt0by5kZWZpbmVkPWZ1bmN0aW9uKGUsdCl7aWYoIWcodCkpdGhyb3cgbmV3IFd0KEFTKGUpKX07dG8udHlwZU9mLmZ1bmM9ZnVuY3Rpb24oZSx0KXtpZih0eXBlb2YgdCE9ImZ1bmN0aW9uIil0aHJvdyBuZXcgV3QocWModHlwZW9mIHQsImZ1bmN0aW9uIixlKSl9O3RvLnR5cGVPZi5zdHJpbmc9ZnVuY3Rpb24oZSx0KXtpZih0eXBlb2YgdCE9InN0cmluZyIpdGhyb3cgbmV3IFd0KHFjKHR5cGVvZiB0LCJzdHJpbmciLGUpKX07dG8udHlwZU9mLm51bWJlcj1mdW5jdGlvbihlLHQpe2lmKHR5cGVvZiB0IT0ibnVtYmVyIil0aHJvdyBuZXcgV3QocWModHlwZW9mIHQsIm51bWJlciIsZSkpfTt0by50eXBlT2YubnVtYmVyLmxlc3NUaGFuPWZ1bmN0aW9uKGUsdCxuKXtpZih0by50eXBlT2YubnVtYmVyKGUsdCksdD49bil0aHJvdyBuZXcgV3QoYEV4cGVjdGVkICR7ZX0gdG8gYmUgbGVzcyB * 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 cD=="object"&&cD.exports?cD.exports=t():typeof define=="function"&&define.amd?define(t):e.IPv6=t(e)})(Oie,function(e){"use strict";var t=e&&e.IPv6;function n(o){var r=o.toLowerCase(),s=r.split(":"),a=s.length,c=8;s[0]===""&&s[1]===""&&s[2]===""?(s.shift(),s.shift()):s[0]===""&&s[1]===""?s.shift():s[a-1]===""&&s[a-2]===""&&s.pop(),a=s.length,s[a-1].indexOf(".")!==-1&&(c=7);var d;for(d=0;d<a&&s[d]!=="";d++);if(d<c)for(s.splice(d,1,"0000");s.length<c;)s.splice(d,0,"0000");for(var u,h=0;h<c;h++){u=s[h].split("");for(var p=0;p<3&&(u[0]==="0"&&u.length>1);p++)u.splice(0,1);s[h]=u.join("")}var A=-1,f=0,b=0,C=-1,T=!1;for(h=0;h<c;h++)T?s[h]==="0"?b+=1:(T=!1,b>f&&(A=C,f=b)):s[h]==="0"&&(T=!0,C=h,b=1);b>f&&(A=C,f=b),f>1&&s.splice(A,f,""),a=s.length;var E="";for(s[0]===""&&(E=":"),h=0;h<a&&(E+=s[h],h!==a-1);h++)E+=":";return s[a-1]===""&&(E+=":"),E}function i(){return e.IPv6===this&&(e.IPv6=t),this}return{best:n,noConflict:i}})});var Jie=nm((Hie,lD)=>{var LNt=y(x());/*! * 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 lD=="object"&&lD.exports?lD.exports=t():typeof define=="function"&&define.amd?define(t):e.SecondLevelDomains=t(e)})(Hie,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 dD=="object"&&dD.exports?dD.exports=t(Qie(),zie(),Jie()):typeof define=="function"&&define.amd?define(["./punycode","./IPv6","./SecondLevelDomains"],t):e.URI=t(e.punycode,e.IPv6,e.SecondLevelDomains,e)})(Kie,function(e,t,n,i){"use strict";var o=i&&i.URI;function r(_,Z){var G=arguments.length>=1,w=arguments.length>=2;if(!(this instanceof r))return G?w?new r(_,Z):new r(_):new r;if(_===void 0){if(G)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?_=location.href+"":_=""}if(_===null&&G)throw new TypeError("null is not a valid argument for URI");return this.href(_),Z!==void 0?this.absoluteTo(Z):this}function s(_){return/^[0-9]+$/.test(_)}r.version="1.19.11";var a=r.prototype,c=Object.prototype.hasOwnProperty;function d(_){return _.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")}function u(_){return _===void 0?"Undefined":String(Object.prototype.toString.call(_)).slice(8,-1)}function h(_){return u(_)==="Array"}function p(_,Z){var G={},w,X;if(u(Z)==="RegExp")G=null;else if(h(Z))for(w=0,X=Z.length;w<X;w++)G[Z[w]]=!0;else G[Z]=!0;for(w=0,X=_.length;w<X;w++){var k=G&&G[_[w]]!==void 0||!G&&Z.test(_[w]);k&&(_.splice(w,1),X--,w--)}return _}function A(_,Z){var G,w;if(h(Z)){for(G=0,w=Z.length;G<w;G++)if(!A(_,Z[G]))return!1;return!0}var X=u(Z);for(G=0,w=_.length;G<w;G++)if(X==="RegExp"){if(typeof _[G]=="string"&&_[G].match(Z))return!0}else if(_[G]===Z)return!0;return!1}function f(_,Z){if(!h(_)||!h(Z)||_.length!==Z.length)return!1;_.sort(),Z.sort();for(var G=0,w=_.length;G<w;G++)if(_[G]!==Z[G])return!1;return!0}function b(_){var Z=/^\/+|\/+$/g;return _.replace(Z,"")}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(s){var a=n[s];return a||t[s][0].call(a=n[s]={exports:{}},o,a,a.exports),a.exports}var r=o(i[0]);r.util.global.protobuf=r,typeof define=="function"&&define.amd&&define(["long"],function(s){return s&&s.isLong&&(r.util.Long=s,r.configure()),r}),typeof module=="object"&&module&&module.exports&&(module.exports=r)})({1:[function(e,t,n){"use strict";t.exports=i;function i(o,r){for(var s=new Array(arguments.length-1),a=0,c=2,d=!0;c<arguments.length;)s[a++]=arguments[c++];return new Promise(function(h,p){s[a]=function(f){if(d)if(d=!1,f)p(f);else{for(var b=new Array(arguments.length-1),C=0;C<b.length;)b[C++]=arguments[C];h.apply(null,b)}};try{o.apply(r||null,s)}catch(A){d&&(d=!1,p(A))}})}},{}],2:[function(e,t,n){"use strict";var i=n;i.length=function(d){var u=d.length;if(!u)return 0;for(var h=0;--u%4>1&&d.charAt(u)==="=";)++h;return Math.ceil(d.length*3)/4-h};for(var o=new Array(64),r=new Array(123),s=0;s<64;)r[o[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;i.encode=function(d,u,h){for(var p=null,A=[],f=0,b=0,C;u<h;){var T=d[u++];switch(b){case 0:A[f++]=o[T>>2],C=(T&3)<<4,b=1;break;case 1:A[f++]=o[C|T>>4],C=(T&15)<<2,b=2;break;case 2:A[f++]=o[C|T>>6],A[f++]=o[T&63],b=0;break}f>8191&&((p||(p=[])).push(String.fromCharCode.apply(String,A)),f=0)}return b&&(A[f++]=o[C],A[f++]=61,b===1&&(A[f++]=61)),p?(f&&p.push(String.fromCharCode.apply(String,A.slice(0,f))),p.join("")):String.fromCharCode.apply(String,A.slice(0,f))};var a="invalid encoding";i.decode=function(d,u,h){for(var p=h,A=0,f,b=0;b<d.length;){var C=d.charCodeAt(b++);if(C===61&&A>1)break;if((C=r[C])===undefined)throw Error(a);switch(A){case 0:f=C,A=1;break;case 1:u[h++]=f<<2|(C&48)>>4,f=C,A=2;break;case 2:u[h++]=(f&15)<<4|(C&60)>>2,f=C,A=3;break;case 3:u[h++]=(f&3)<<6|C,A=0;break}}if(A===1)throw Error(a);return h-p},i.test=function(d){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(d)}},{}],3:[function(e,t,n){"use strict";t.exports=i;function i(){this._listeners={}}i.prototype.on=function(r,s,a){return(this._listeners[r]||(this._listeners[r]=[])).push({fn:s,ctx:a||this}),this},i.prototype.off=function(r,s){if(r===undefined)this._listeners={};else if(s===undefined)this._listeners[r]=[];else for(var a=this._listeners[r],c=0;c<a.length;)a[c].fn===s?a.splice(c,1):++c;return this},i.prototype.emit=function(r){var s=this._listeners[r];if(s){for(var a=[],c=1;c<arguments.length;)a.push(arguments[c++]);for(c=0;c<s.length;)s[c].fn.apply(s[c++].ctx,a)}return this}},{}],4:[function(e,t,n){"use strict";t.exports=i(i);function i(c){return typeof Float32Array<"u"?(function(){var d=new Float32Array([-0]),u=new Uint8Array(d.buffer),h=u[3]===128;function p(C,T,E){d[0]=C,T[E]=u[0],T[E+1]=u[1],T[E+2]=u[2],T[E+3]=u[3]}function A(C,T,E){d[0]=C,T[E]=u[3],T[E+1]=u[2],T[E+2]=u[1],T[E+3]=u[0]}c.writeFloatLE=h?p:A,c.writeFloatBE=h?A:p;function f(C,T){return u[0]=C[T],u[1]=C[T+1],u[2]=C[T+2],u[3]=C[T+3],d[0]}function b(C,T){return u[3]=C[T],u[2]=C[T+1],u[1]=C[T+2],u[0]=C[T+3],d[0]}c.readFloatLE=h?f:b,c.readFloatBE=h?b:f})():(function(){function d(h,p,A,f){var b=p<0?1:0;if(b&&(p=-p),p===0)h(1/p>0?0:2147483648,A,f);else if(isNaN(p))h(2143289344,A,f);else if(p>34028234663852886e22)h((b<<31|2139095040)>>>0,A,f);else if(p<11754943508222875e-54)h((b<<31|Math.round(p/1401298464324817e-60))>>>0,A,f);else{var C=Math.floor(Math.log(p)/Math.LN2),T=Math.round(p*Math.pow(2,-C)*8388608)&8388607;h((b<<31|C+127<<23|T)>>>0,A,f)}}c.writeFloatLE=d.bind(null,o),c.writeFloatBE=d.bind(null,r);function u(h,p,A){var f=h(p,A),b=(f>>31)*2+1,C=f>>>23&255,T=f&8388607;return C===255?T?NaN:b*(1/0):C===0?b*1401298464324817e-60*T:b*Math.pow(2,C-150)*(T+8388608)}c.readFloatLE=u.bind(null,s),c.readFloatBE=u.bind(null,a)})(),typeof Float64Array<"u"?(function(){var d=new Float64Array([-0]),u=new Uint8Array(d.buffer),h=u[7]===128;function p(C,T,E){d[0]=C,T[E]=u[0],T[E+1]=u[1],T[E+2]=u[2],T[E+3]=u[3],T[E+4]=u[4],T[E+5]=u[5],T[E+6]=u[6],T[E+7]=u[7]}function A(C,T,E){d[0]=C,T[E]=u[7],T[E+1]=u[6],T[E+2]=u[5],T[E+3]=u[4],T[E+4]=u[3],T[E+5]=u[2],T[E+6]=u 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(){iie()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):nie()?this.noSleepTimer&&(console.warn(` NoSleep now disabled for older iOS devices. `),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}};rGe.exports=oie});var B2t={};EGe(B2t,{AlphaMode:()=>pp,AlphaPipelineStage:()=>l2,AnchorPointDirect:()=>mF,AnchorPointIndirect:()=>hF,Animation:()=>eU,AnimationViewModel:()=>tU,Appearance:()=>To,ApproximateTerrainHeights:()=>Gi,ArcGISTiledElevationTerrainProvider:()=>Uq,ArcGisBaseMapType:()=>Jh,ArcGisMapServerImageryProvider:()=>pg,ArcGisMapService:()=>mu,ArcType:()=>un,ArticulationStageType:()=>qc,AssociativeArray:()=>Xt,Atmosphere:()=>CC,AtmospherePipelineStage:()=>DF,AttributeCompression:()=>on,AttributeType:()=>Ut,AutoExposure:()=>yM,AutomaticUniforms:()=>yA,Axis:()=>ro,AxisAlignedBoundingBox:()=>ou,Azure2DImageryProvider:()=>Q2,B3dmLoader:()=>ZF,B3dmParser:()=>SF,BaseLayerPicker:()=>aU,BaseLayerPickerViewModel:()=>sU,BatchTable:()=>wx,BatchTableHierarchy:()=>oC,BatchTexture:()=>Pl,BatchTexturePipelineStage:()=>d2,Billboard:()=>Lo,BillboardCollection:()=>yu,BillboardGraphics:()=>Dc,BillboardLoadState:()=>Ps,BillboardTexture:()=>yg,BillboardVisualizer:()=>e1,BingMapsGeocoderService:()=>kq,BingMapsImageryProvider:()=>w2,BingMapsStyle:()=>Z_,BlendEquation:()=>Ec,BlendFunction:()=>Ko,BlendOption:()=>$o,BlendingState:()=>ln,BoundingRectangle:()=>nt,BoundingSphere:()=>ue,BoundingSphereState:()=>Tt,BoundingVolumeSemantics:()=>T0,BoxEmitter:()=>Mte,BoxGeometry:()=>Cc,BoxGeometryUpdater:()=>mW,BoxGraphics:()=>Dx,BoxOutlineGeometry:()=>Rh,BrdfLutGenerator:()=>_Y,Buffer:()=>it,BufferLoader:()=>dC,BufferPoint:()=>Vd,BufferPointCollection:()=>Rg,BufferPointMaterial:()=>_g,BufferPolygon:()=>wa,BufferPolygonCollection:()=>Gg,BufferPolygonMaterial:()=>Vg,BufferPolyline:()=>zl,BufferPolylineCollection:()=>H0,BufferPolylineMaterial:()=>Lg,BufferPrimitive:()=>qr,BufferPrimitiveCollection:()=>Js,BufferPrimitiveMaterial:()=>Ol,BufferUsage:()=>Be,CPUStylingPipelineStage:()=>f2,CallbackPositionProperty:()=>hW,CallbackProperty:()=>Bh,Camera:()=>Zo,CameraEventAggregator:()=>_M,CameraEventType:()=>to,CameraFlightPath:()=>ZY,Cartesian2:()=>M,Cartesian3:()=>m,Cartesian4:()=>re,CartesianRectangle:()=>Y_,Cartographic:()=>Ae,CartographicGeocoderService:()=>Oq,CatmullRomSpline:()=>zq,Cesium3DContentGroup:()=>iC,Cesium3DTile:()=>vm,Cesium3DTileBatchTable:()=>Xh,Cesium3DTileColorBlendMode:()=>yd,Cesium3DTileContent:()=>vte,Cesium3DTileContentFactory:()=>qC,Cesium3DTileContentState:()=>Ar,Cesium3DTileContentType:()=>ha,Cesium3DTileFeature:()=>Ga,Cesium3DTileFeatureTable:()=>Qh,Cesium3DTileOptimizationHint:()=>Nm,Cesium3DTileOptimizations:()=>Kw,Cesium3DTilePass:()=>sr,Cesium3DTilePassState:()=>rh,Cesium3DTilePointFeature:()=>xg,Cesium3DTileRefine:()=>mr,Cesium3DTileStyle:()=>Wg,Cesium3DTileStyleEngine:()=>nN,Cesium3DTilesInspector:()=>rU,Cesium3DTilesInspectorViewModel:()=>oU,Cesium3DTilesTerrainData:()=>TX,Cesium3DTilesTerrainGeometryProcessor:()=>RZ,Cesium3DTilesTerrainProvider:()=>e$,Cesium3DTilesVoxelProvider:()=>Ute,Cesium3DTileset:()=>js,Cesium3DTilesetBaseTraversal:()=>cN,Cesium3DTilesetCache:()=>$w,Cesium3DTilesetGraphics:()=>Kx,Cesium3DTilesetHeatmap:()=>eN,Cesium3DTilesetMetadata:()=>cT,Cesium3DTilesetMostDetailedTraversal:()=>rN,Cesium3DTilesetSkipTraversal:()=>uN,Cesium3DTilesetStatistics:()=>lf,Cesium3DTilesetTraversal:()=>Xa,Cesium3DTilesetVisualizer:()=>mN,CesiumInspector:()=>mU,CesiumInspectorViewModel:()=>uU,CesiumTerrainProvider:()=>KT,CesiumWidget:()=>Cv,Check:()=>vo,CheckerboardMaterialProperty:()=>dI,CircleEmitter:()=>_v,CircleGeometry:()=>s$,CircleOutlineGeometry:()=>a$,ClassificationModelDrawCommand:()=>LB,ClassificationPipelineStage:()=>u2,ClassificationPrimitive:()=>RS,ClassificationType:()=>ti,ClearCommand:()=>mi,ClippingPlane:()=>zs,ClippingPlaneCollection:()=>ls,ClippingPolygon:()=>a_,ClippingPolygonCollection:()=>Uh,Clock:()=>pf,ClockRange:()=>xs,ClockStep:()=>Xo,ClockViewModel:()=>jv,CloudCollection:()=>Hte,CloudType:()=>cR,Color:()=>U,ColorBlendMode:()=>jc,ColorGeometryInstanceAttribute:()=>$t,ColorMaterialProperty:()=>Kt,Command:()=>Une,ComponentDatatype:()=>H,Composite3DTileContent:()=>TW,CompositeEnti
${this.stack.toString()}`),e};sx.throwInstantiationError=function(){throw new sx("This function defines an interface and should not be called directly.")};var fe=sx;var aa={};aa.typeOf={};function ZGe(e){return`${e} is required, actual value was undefined`}function qE(e,t,n){return`Expected ${n} to be typeof ${t}, actual typeof was ${e}`}aa.defined=function(e,t){if(!l(t))throw new fe(ZGe(e))};aa.typeOf.func=function(e,t){if(typeof t!="function")throw new fe(qE(typeof t,"function",e))};aa.typeOf.string=function(e,t){if(typeof t!="string")throw new fe(qE(typeof t,"string",e))};aa.typeOf.number=function(e,t){if(typeof t!="number")throw new fe(qE(typeof t,"number",e))};aa.typeOf.number.lessThan=function(e,t,n){if(aa.typeOf.number(e,t),t>=n)throw new fe(`Expected ${e} to be less than ${n}, actual value was ${t}`)};aa.typeOf.number.lessThanOrEquals=function(e,t,n){if(aa.typeOf.number(e,t),t>n)throw new fe(`Expected ${e} to be less than or equal to ${n}, actual value was ${t}`)};aa.typeOf.number.greaterThan=function(e,t,n){if(aa.typeOf.number(e,t),t<=n)throw new fe(`Expected ${e} to be greater than ${n}, actual value was ${t}`)};aa.typeOf.number.greaterThanOrEquals=function(e,t,n){if(aa.typeOf.number(e,t),t<n)throw new fe(`Expected ${e} to be greater than or equal to ${n}, actual value was ${t}`)};aa.typeOf.object=function(e,t){if(typeof t!="object")throw new fe(qE(typeof t,"object",e))};aa.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new fe(qE(typeof t,"boolean",e))};aa.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new fe(qE(typeof t,"bigint",e))};aa.typeOf.number.equals=function(e,t,n,i){if(aa.typeOf.number(e,n),aa.typeOf.number(t,i),n!==i)throw new fe(`${e} must be equal to ${t}, the actual values are ${n} and ${i}`)};var vo=aa;var tBt=y(x(),1),$z=y(DU(),1);var gt={};gt.EPSILON1=.1;gt.EPSILON2=.01;gt.EPSILON3=.001;gt.EPSILON4=1e-4;gt.EPSILON5=1e-5;gt.EPSILON6=1e-6;gt.EPSILON7=1e-7;gt.EPSILON8=1e-8;gt.EPSILON9=1e-9;gt.EPSILON10=1e-10;gt.EPSILON11=1e-11;gt.EPSILON12=1e-12;gt.EPSILON13=1e-13;gt.EPSILON14=1e-14;gt.EPSILON15=1e-15;gt.EPSILON16=1e-16;gt.EPSILON17=1e-17;gt.EPSILON18=1e-18;gt.EPSILON19=1e-19;gt.EPSILON20=1e-20;gt.EPSILON21=1e-21;gt.GRAVITATIONALPARAMETER=3986004418e5;gt.SOLAR_RADIUS=6955e5;gt.LUNAR_RADIUS=1737400;gt.SIXTY_FOUR_KILOBYTES=64*1024;gt.FOUR_GIGABYTES=4*1024*1024*1024;gt.sign=Math.sign??function(t){return t=+t,t===0||t!==t?t:t>0?1:-1};gt.signNotZero=function(e){return e<0?-1:1};gt.toSNorm=function(e,t){return t=t??255,Math.round((gt.clamp(e,-1,1)*.5+.5)*t)};gt.fromSNorm=function(e,t){return t=t??255,gt.clamp(e,0,t)/t*2-1};gt.normalize=function(e,t,n){return n=Math.max(n-t,0),n===0?0:gt.clamp((e-t)/n,0,1)};gt.sinh=Math.sinh??function(t){return(Math.exp(t)-Math.exp(-t))/2};gt.cosh=Math.cosh??function(t){return(Math.exp(t)+Math.exp(-t))/2};gt.lerp=function(e,t,n){return(1-n)*e+n*t};gt.PI=Math.PI;gt.ONE_OVER_PI=1/Math.PI;gt.PI_OVER_TWO=Math.PI/2;gt.PI_OVER_THREE=Math.PI/3;gt.PI_OVER_FOUR=Math.PI/4;gt.PI_OVER_SIX=Math.PI/6;gt.THREE_PI_OVER_TWO=3*Math.PI/2;gt.TWO_PI=2*Math.PI;gt.ONE_OVER_TWO_PI=1/(2*Math.PI);gt.RADIANS_PER_DEGREE=Math.PI/180;gt.DEGREES_PER_RADIAN=180/Math.PI;gt.RADIANS_PER_ARCSECOND=gt.RADIANS_PER_DEGREE/3600;gt.toRadians=function(e){return e*gt.RADIANS_PER_DEGREE};gt.toDegrees=function(e){return e*gt.DEGREES_PER_RADIAN};gt.convertLongitudeRange=function(e){let t=gt.TWO_PI,n=e-Math.floor(e/t)*t;return n<-Math.PI?n+t:n>=Math.PI?n-t:n};gt.clampToLatitudeRange=function(e){return gt.clamp(e,-1*gt.PI_OVER_TWO,gt.PI_OVER_TWO)};gt.negativePiToPi=function(e){return e>=-gt.PI&&e<=gt.PI?e:gt.zeroToTwoPi(e+gt.PI)-gt.PI};gt.zeroToTwoPi=function(e){if(e>=0&&e<=gt.TWO_PI)return e;let t=gt.mod(e,gt.TWO_PI);return Math.abs(t)<gt.EPSILON14&&Math.abs(e)>gt.EPSILON14?gt.TWO_PI:t};gt.mod=function(e,t){return gt.sign(e)===gt.sign(t)&&Math.abs(e)<Math.abs(t)?e:(e%t+t)%t};gt.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))};gt.lessThan=function(e,t,n){return e-t<-n};gt.lessThanOrEquals=function(e,t,n){return e-t<n};gt.greaterTha
(${this[1]}, ${this[4]}, ${this[7]})(${this[2]}, ${this[5]}, ${this[8]})`};var $=mt;var yBt=y(x(),1);function _R(e){this.name="RuntimeError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}l(Object.create)&&(_R.prototype=Object.create(Error.prototype),_R.prototype.constructor=_R);_R.prototype.toString=function(){let e=`${this.name}: ${this.message}`;return l(this.stack)&&(e+=`${this.stack.toString()}`),e};var me=_R;function dt(e,t,n,i,o,r,s,a,c,d,u,h,p,A,f,b){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]=d??0,this[7]=A??0,this[8]=n??0,this[9]=s??0,this[10]=u??0,this[11]=f??0,this[12]=i??0,this[13]=a??0,this[14]=h??0,this[15]=b??0}dt.packedLength=16;dt.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};dt.unpack=function(e,t,n){return t=t??0,l(n)||(n=new dt),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};dt.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)dt.pack(e[o],t,o*16);return t};dt.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]=dt.unpack(e,i,t[o])}return t};dt.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 dt(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])};dt.fromArray=dt.unpack;dt.fromColumnMajorArray=function(e,t){return dt.clone(e,t)};dt.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 dt(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])};dt.fromRotationTranslation=function(e,t,n){return t=t??m.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 dt(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)};dt.fromTranslationQuaternionRotationScale=function(e,t,n,i){l(i)||(i=new dt);let o=n.x,r=n.y,s=n.z,a=t.x*t.x,c=t.x*t.y,d=t.x*t.z,u=t.x*t.w,h=t.y*t.y,p=t.y*t.z,A=t.y*t.w,f=t.z*t.z,b=t.z*t.w,C=t.w*t.w,T=a-h-f+C,E=2*(c-b),S=2*(d+A),I=2*(c+b),R=-a+h-f+C,V=2*(p-u),W=2*(d-A),B=2*(p+u),N=-a-h+f+C;return i[0]=T*o,i[1]=I*o,i[2]=W*o,i[3]=0,i[4]=E*r,i[5]=R*r,i[6]=B*r,i[7]=0,i[8]=S*s,i[9]=V*s,i[10]=N*s,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,i};dt.fromTranslationRotationScale=function(e,t){return dt.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,t)};dt.fromTranslation=function(e,t){return dt.fromRotationTranslation($.IDENTITY,e,t)};dt.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 dt(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)};dt.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 dt(e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1)};dt.fromRotation=function(e,t){return l(t)||(t=new dt),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 eS=new m,tS=new m,IR=new m;dt.fromCamera=function(e,t){let n=e.position,i=e.direction,o=e.up;m.normalize(i,eS),m.normalize(m.cross(eS,o,tS),tS),m.normalize(m.cross(tS,eS,IR),IR);let r=tS.x,s=tS.y,a=tS.z,c=eS.x,d=eS.y,u=eS.z,h=IR.x,p=IR.y,A=IR.z,f=n.x,b=n.y,C=n.z,T=r*-f+s*-b+a*-C,E=h*-f+p*-b+A*-C,S=c*f+d*b+u*C;return l(t)?(t[0]=r,t[1]=h,t[2]=-c,t[3]=0,t[4]=s,t[5]=p,t[6]=-d,t[7]=0,t[8]=a,t[9]=A,t[10]=-u,t[11]=0,t[12]=T,t[13]=E,t[14]=S,t[15]=1,t):new dt(r,s,a,T,h,p,A,E,-c,-d,-u,S,0,0,0,1)};dt.computePerspectiveFieldOfView=function(e,t,n,i,o){let s=1/Math.tan(e*.5),a=s/t,c=(i+n)/(n-i),d=2*i*n/(n-i);return o[0]=a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=s,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 F=dt;var GBt=y(x(),1),JGe={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,
`);for(let i=0;i<n.length;++i){let o=n[i],r=o.indexOf(": ");if(r>0){let s=o.substring(0,r),a=o.substring(r+2);t[s]=a}}return t}var LR=a1e;function ioe(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=LR(this.responseHeaders))}ioe.prototype.toString=function(){let e="Request has failed.";return l(this.statusCode)&&(e+=` Status Code: ${this.statusCode}`),e};var Kf=ioe;var UPt=y(x(),1),mD=y(qd(),1);var GPt=y(x(),1);function WR(){this._listeners=new Map,this._toRemove=new Map,this._toAdd=new Map,this._invokingListeners=!1,this._listenerCount=0}Object.defineProperties(WR.prototype,{numberOfListeners:{get:function(){return this._listenerCount}}});WR.prototype.addEventListener=function(e,t){let n=this,i=n._invokingListeners?n._toAdd:n._listeners;return E3(this,i,e,t)&&n._listenerCount++,function(){n.removeEventListener(e,t)}};function E3(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)}WR.prototype.removeEventListener=function(e,t){let n=T3(this,this._listeners,e,t),i=T3(this,this._toAdd,e,t),o=n||i;return o&&this._listenerCount--,o};function T3(e,t,n,i){let o=t.get(n);if(!o||!o.has(i))return!1;if(e._invokingListeners){if(!E3(e,e._toRemove,n,i))return!1}else o.delete(i),o.size===0&&t.delete(n);return!0}WR.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)E3(this,this._listeners,e,n);this._toAdd.clear();for(let[e,t]of this._toRemove.entries())for(let n of t)T3(this,this._listeners,e,n);this._toRemove.clear()};var xe=WR;var FPt=y(x(),1);function ux(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(ux.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 S3(e,t,n){let i=e[t];e[t]=e[n],e[n]=i}ux.prototype.reserve=function(e){e=e??this._length,this._array.length=e};ux.prototype.heapify=function(e){e=e??0;let t=this._length,n=this._comparator,i=this._array,o=-1,r=!0;for(;r;){let s=2*(e+1),a=s-1;a<t&&n(i[a],i[e])<0?o=a:o=e,s<t&&n(i[s],i[o])<0&&(o=s),o!==e?(S3(i,o,e),e=o):r=!1}};ux.prototype.resort=function(){let e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};ux.prototype.insert=function(e){let t=this._array,n=this._comparator,i=this._maximumLength,o=this._length++;for(o<t.length?t[o]=e:t.push(e);o!==0;){let s=Math.floor((o-1)/2);if(n(t[o],t[s])<0)S3(t,o,s),o=s;else break}let r;return l(i)&&this._length>i&&(r=t[i],this._length=i),r};ux.prototype.pop=function(e){if(e=e??0,this._length===0)return;let t=this._array,n=t[e];return S3(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};var FR=ux;function c1e(e,t){return e.priority-t.priority}var xo={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0},sS=20,Xc=new FR({comparator:c1e});Xc.maximumLength=sS;Xc.reserve(sS);var jf=[],EA={},l1e=typeof document<"u"?new mD.default(document.location.href):new mD.default,hD=new xe;function Er(){}Er.maximumRequests=50;Er.maximumRequestsPerServer=18;Er.requestsByServer={};Er.throttleRequests=!0;Er.debugShowStatistics=!1;Er.requestCompletedEvent=hD;Object.defineProperties(Er,{statistics:{get:function(){return xo}},priorityHeapLength:{get:function(){return sS},set:function(e){if(e<sS)for(;Xc.length>e;){let t=Xc.pop();mx(t)}sS=e,Xc.maximumLength=e,Xc.reserve(e)}}});function ooe(e){l(e.priorityFunction)&&(e.priority=e.priorityFunction())}Er.serverHasOpenSlots=function(e,t){t=t??1;let n=Er.requestsByServer[e]??Er.maximumRequestsPerS
in vec2 textureCoordinates;
out vec2 v_textureCoordinates;
void main() { gl_Position = position; v_textureCoordinates = textureCoordinates;}`;var jYt=y(x(),1);var kr={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 vR(e){e=e??Q.EMPTY_OBJECT,this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._modelMatrix=e.modelMatrix,this._primitiveType=e.primitiveType??We.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 vc(e,t){return(e._flags&t)===t}function zb(e,t,n){n?e._flags|=t:e._flags&=~t}Object.defineProperties(vR.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 vc(this,kr.CULL)},set:function(e){vc(this,kr.CULL)!==e&&(zb(this,kr.CULL,e),this.dirty=!0)}},occlude:{get:function(){return vc(this,kr.OCCLUDE)},set:function(e){vc(this,kr.OCCLUDE)!==e&&(zb(this,kr.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 vc(this,kr.CAST_SHADOWS)},set:function(e){vc(this,kr.CAST_SHADOWS)!==e&&(zb(this,kr.CAST_SHADOWS,e),this.dirty=!0)}},receiveShadows:{get:function(){return vc(this,kr.RECEIVE_SHADOWS)},set:function(e){vc(this,kr.RECEIVE_SHADOWS)!==e&&(zb(this,kr.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 vc(this,kr.EXECUTE_IN_CLOSEST_FRUSTUM)},set:function(e){vc(this,kr.EXECUTE_IN_CLOSEST_FRUSTUM)!==e&&(zb(this,kr.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 vc(this,kr.DEBUG_SHOW_BOUNDING_VOLUME)},set:function(e){vc(this,kr.DEBUG_SHOW_BOUNDING_VOLUME)!==e&&(zb(
(${this[1]}, ${this[3]})`};var Qi=an;function TWe(e,t,n,i){switch(t.type){case e.FLOAT:return new zoe(e,t,n,i);case e.FLOAT_VEC2:return new Hoe(e,t,n,i);case e.FLOAT_VEC3:return new Joe(e,t,n,i);case e.FLOAT_VEC4:return new Koe(e,t,n,i);case e.SAMPLER_2D:case e.SAMPLER_3D:case e.SAMPLER_CUBE:case e.SAMPLER_2D_ARRAY:return new ID(e,t,n,i);case e.UNSIGNED_INT_SAMPLER_2D:return new ID(e,t,n,i);case e.INT:case e.BOOL:return new joe(e,t,n,i);case e.INT_VEC2:case e.BOOL_VEC2:return new qoe(e,t,n,i);case e.INT_VEC3:case e.BOOL_VEC3:return new $oe(e,t,n,i);case e.INT_VEC4:case e.BOOL_VEC4:return new ere(e,t,n,i);case e.FLOAT_MAT2:return new tre(e,t,n,i);case e.FLOAT_MAT3:return new nre(e,t,n,i);case e.FLOAT_MAT4:return new ire(e,t,n,i);default:throw new me(`Unrecognized uniform type: ${t.type} for uniform "${n}".`)}}function zoe(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}zoe.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1f(this._location,this.value))};function Hoe(e,t,n,i){this.name=n,this.value=void 0,this._value=new M,this._gl=e,this._location=i}Hoe.prototype.set=function(){let e=this.value;M.equals(e,this._value)||(M.clone(e,this._value),this._gl.uniform2f(this._location,e.x,e.y))};function Joe(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}Joe.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)&&(m.equals(e,this._value)||(this._value=m.clone(e,this._value),this._gl.uniform3f(this._location,e.x,e.y,e.z))))};function Koe(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}Koe.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)&&(re.equals(e,this._value)||(this._value=re.clone(e,this._value),this._gl.uniform4f(this._location,e.x,e.y,e.z,e.w)))};function ID(e,t,n,i){this.name=n,this.value=void 0,this._gl=e,this._location=i,this.textureUnitIndex=void 0}ID.prototype.set=function(){let e=this._gl;e.activeTexture(e.TEXTURE0+this.textureUnitIndex);let t=this.value;t&&e.bindTexture(t._target,t._texture)};ID.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function joe(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}joe.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1i(this._location,this.value))};function qoe(e,t,n,i){this.name=n,this.value=void 0,this._value=new M,this._gl=e,this._location=i}qoe.prototype.set=function(){let e=this.value;M.equals(e,this._value)||(M.clone(e,this._value),this._gl.uniform2i(this._location,e.x,e.y))};function $oe(e,t,n,i){this.name=n,this.value=void 0,this._value=new m,this._gl=e,this._location=i}$oe.prototype.set=function(){let e=this.value;m.equals(e,this._value)||(m.clone(e,this._value),this._gl.uniform3i(this._location,e.x,e.y,e.z))};function ere(e,t,n,i){this.name=n,this.value=void 0,this._value=new re,this._gl=e,this._location=i}ere.prototype.set=function(){let e=this.value;re.equals(e,this._value)||(re.clone(e,this._value),this._gl.uniform4i(this._location,e.x,e.y,e.z,e.w))};var EWe=new Float32Array(4);function tre(e,t,n,i){this.name=n,this.value=void 0,this._value=new Qi,this._gl=e,this._location=i}tre.prototype.set=function(){if(!Qi.equalsArray(this.value,this._value,0)){Qi.clone(this.value,this._value);let e=Qi.toArray(this.value,EWe);this._gl.uniformMatrix2fv(this._location,!1,e)}};var SWe=new Float32Array(9);function nre(e,t,n,i){this.name=n,this.value=void 0,this._value=new $,this._gl=e,this._location=i}nre.prototype.set=function(){if(!$.equalsArray(this.value,this._value,0)){$.clone(this.value,this._value);let e=$.toArray(this.value,SWe);this._gl.uniformMatrix3fv(this._location,!1,e)}};var _We=new Float32Array(16);function ire(e,t,n,i){this.name=n,th
${n}`),d=`Vertex shader failed to compile. Compile log: ${c}`):(c=e.getShaderInfoLog(r),console.error(`${tp}Fragment shader compile log: ${c}`),console.error(`${tp} Fragment shader source:${i}`),d=`Fragment shader failed to compile. Compile log: ${c}`),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(s),new me(d);function h(p,A){if(!l(u))return;let f=u.getTranslatedShaderSource(p);if(f===""){console.error(`${tp}${A} shader translation failed.`);return}console.error(`${tp}Translated ${A} shaderSource:${f}`)}}function GWe(e,t,n){let i={};for(let o=0;o<n;++o){let r=e.getActiveAttrib(t,o),s=e.getAttribLocation(t,r.name);i[r.name]={name:r.name,type:r.type,index:s}}return i}function LWe(e,t){let n={},i=[],o=[],r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){let a=e.getActiveUniform(t,s),c="[0]",d=a.name.indexOf(c,a.name.length-c.length)!==-1?a.name.slice(0,a.name.length-3):a.name;if(d.indexOf("gl_")!==0)if(a.name.indexOf("[")<0){let u=e.getUniformLocation(t,d);if(u!==null){let h=UR(e,a,d,u);n[d]=h,i.push(h),h._setSampler&&o.push(h)}}else{let u,h,p,A,f=d.indexOf("[");if(f>=0){if(u=n[d.slice(0,f)],!l(u))continue;h=u._locations,h.length<=1&&(p=u.value,A=e.getUniformLocation(t,d),A!==null&&(h.push(A),p.push(e.getUniform(t,A))))}else{h=[];for(let b=0;b<a.size;++b)A=e.getUniformLocation(t,`${d}[${b}]`),A!==null&&h.push(A);u=DR(e,a,d,h),n[d]=u,i.push(u),u._setSampler&&o.push(u)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:o}}function WWe(e,t){let n=[],i=[];for(let o in t)if(t.hasOwnProperty(o)){let r=t[o],s=o,a=e._duplicateUniformNames[s];l(a)&&(r.name=a,s=a);let c=yA[s];l(c)?n.push({uniform:r,automaticUniform:c}):i.push(r)}return{automaticUniforms:n,manualUniforms:i}}function FWe(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 ZD(e){l(e._program)||Are(e)}function Are(e){let t=e._program,n=e._gl,i=VWe(n,e,e._debugShaders),o=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),r=LWe(n,i),s=WWe(e,r.uniformsByName);e._program=i,e._numberOfVertexAttributes=o,e._vertexAttributes=GWe(n,i,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=s.automaticUniforms,e._manualUniforms=s.manualUniforms,e.maximumTextureUnitIndex=FWe(n,i,r.samplerUniforms),t&&e._gl.deleteProgram(t),typeof spector<"u"&&(e._program.__SPECTOR_rebuildProgram=function(a,c,d,u){let h=e._vertexShaderText,p=e._fragmentShaderText,A=/ ! = /g;e._vertexShaderText=a.replace(A," != "),e._fragmentShaderText=c.replace(A," != ");try{Are(e),d(e._program)}catch(f){e._vertexShaderText=h,e._fragmentShaderText=p;let C=/(?:Compile|Link) error: ([^]*)/.exec(f.message);u(C?C[1]:f.message)}})}IA.prototype._bind=function(){ZD(this),this._gl.useProgram(this._program)};IA.prototype._setUniforms=function(e,t,n){let i,o;if(l(e)){let a=this._manualUniforms;for(i=a.length,o=0;o<i;++o){let c=a[o];c.value=e[c.name]()}}let r=this._automaticUniforms;for(i=r.length,o=0;o<i;++o){let a=r[o];a.uniform.value=a.automaticUniform.getValue(t)}let s=this._uniforms;for(i=s.length,o=0;o<i;++o)s[o].set();if(n){let a=this._gl,c=this._program;a.validateProgram(c)}};IA.prototype.isDestroyed=function(){return!1};IA.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};IA.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),he(this)};var tn=IA;function RD(e){this._context=e}var kR,BWe=new ot({primitiveType:We.TRIANGLES}),wWe=new mi({color:new U(0,0,0,0)});function NWe(e,t){return new ss({context:e,colorTextures:[t],destroyAttachments:!1})}function PWe(e,t){return tn.fromCache({context:e,vertexShaderSource:Ax,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function XWe(e,t){return(!l(kR)||kR.viewport.width!==e||kR.viewport.height!==t)&&(kR=Qe.fromCache({viewport:new nt(0,0,e,t)})),kR}RD.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(),s=l(e.shaderProgram)?e.shaderProgram:PWe(o,e.fragmentShaderSource),a=NWe(o,t),c=XWe(n,i),d=e.uniformMap,u=wWe;u.framebuffer=a,u.renderState=c,u.execute(o);let h=BWe;h.vertexArray=r,h.renderState=c,h.shaderProgram=s,h.uniformMap=d,h.framebuffer=a,h.execute(o),a.destroy(),e.persists||(s.destroy(),l(e.vertexArray)&&r.destroy()),l(e.postExecute)&&e.postExecute(t)};RD.prototype.isDestroyed=function(){return!1};RD.prototype.destroy=function(){return he(this)};var QR=RD;var z4t=y(x(),1);var Svt=y(x(),1);var wn={BYTE:ne.BYTE,UNSIGNED_BYTE:ne.UNSIGNED_BYTE,SHO
importScripts("${O3(CESIUM_WORKERS)}"); CesiumWorkers["${i}"](); `;return r=O3(a),new Worker(r,o)}if(r=e,n||(r=en(`${ja._workerModulePrefix+i}.js`)),!hn.supportsEsmWebWorkers())throw new me("This browser is not supported. Please update your browser to continue.");return o.type="module",new Worker(r,o)}async function KWe(e,t){let n={modulePath:void 0,wasmBinaryFile:void 0,wasmBinary:void 0};if(!hn.supportsWebAssembly()){if(!l(t.fallbackModulePath))throw new me(`This browser does not support Web Assembly, and no backup module was provided for ${e._workerPath}`);return n.modulePath=en(t.fallbackModulePath),n}n.wasmBinaryFile=en(t.wasmBinaryFile);let i=await Le.fetchArrayBuffer({url:n.wasmBinaryFile});return n.wasmBinary=i,n}function ja(e,t){this._workerPath=e,this._maximumActiveTasks=t??Number.POSITIVE_INFINITY,this._activeTasks=0,this._nextID=0,this._webAssemblyPromise=void 0}var jWe=(e,t,n,i)=>{let o=({data:r})=>{if(r.id===t){if(l(r.error)){let s=r.error;s.name==="RuntimeError"?(s=new me(r.error.message),s.stack=r.error.stack):s.name==="DeveloperError"?(s=new fe(r.error.message),s.stack=r.error.stack):s.name==="Error"&&(s=new Error(r.error.message),s.stack=r.error.stack),z3.raiseEvent(s),i(s)}else z3.raiseEvent(),n(r.result);e.removeEventListener("message",o)}};return o},qWe=[];async function $We(e,t,n){let i=await Promise.resolve(yre());l(n)?i||(n.length=0):n=qWe;let o=e._nextID++,r=new Promise((s,a)=>{e._worker.addEventListener("message",jWe(e._worker,o,s,a))});return e._worker.postMessage({id:o,baseUrl:en.getCesiumBaseUrl().url,parameters:t,canTransferArrayBuffer:i},n),r}async function eFe(e,t,n){++e._activeTasks;try{let i=await $We(e,t,n);return--e._activeTasks,i}catch(i){throw--e._activeTasks,i}}ja.prototype.scheduleTask=function(e,t){if(l(this._worker)||(this._worker=H3(this._workerPath)),!(this._activeTasks>=this._maximumActiveTasks))return eFe(this,e,t)};ja.prototype.initWebAssemblyModule=async function(e){if(l(this._webAssemblyPromise))return this._webAssemblyPromise;let t=async()=>{let n=this._worker=H3(this._workerPath),i=await KWe(this,e),o=await Promise.resolve(yre()),r,s=i.wasmBinary;l(s)&&o&&(r=[s]);let a=new Promise((c,d)=>{n.onmessage=function({data:u}){l(u)?c(u.result):d(new me("Could not configure wasm module"))}});return n.postMessage({canTransferArrayBuffer:o,parameters:{webAssemblyConfig:i}},r),a};return this._webAssemblyPromise=t(),this._webAssemblyPromise};ja.prototype.isDestroyed=function(){return!1};ja.prototype.destroy=function(){return l(this._worker)&&this._worker.terminate(),he(this)};ja.taskCompletedEvent=z3;ja._defaultWorkerModulePrefix="Workers/";ja._workerModulePrefix=ja._defaultWorkerModulePrefix;ja._canTransferArrayBuffer=void 0;var $n=ja;function ZA(){}ZA._transcodeTaskProcessor=new $n("transcodeKTX2",Number.POSITIVE_INFINITY);ZA._readyPromise=void 0;function tFe(){let e=ZA._transcodeTaskProcessor.initWebAssemblyModule({wasmBinaryFile:"ThirdParty/basis_transcoder.wasm"}).then(function(t){if(t)return ZA._transcodeTaskProcessor;throw new me("KTX2 transcoder could not be initialized.")});ZA._readyPromise=e}ZA.transcode=function(e,t){return l(ZA._readyPromise)||tFe(),ZA._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 s=n[r];for(let a=0;a<o.length;a++){let c=s[o[a]];s[o[a]]=new OR(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 zR=ZA;var xre;Cre.setKTX2SupportedFormats=function(e,t,n,i,o,r){xre={s3tc:e,pvrtc:t,astc:n,etc:i,etc1:o,bc7:r}};function Cre(e){let t;return e instanceof ArrayBuffer||ArrayBuffer.isView(e)?t=Promise.resolve(e):t=Le.createIfNeeded(e).fetchArrayBuffer(),t.then(function(n){return zR.transcode(n,xre)})}var md=Cre;var N9t=y(x(),1);var jUt=y(x(),1);var VUt=y(x(),1);var AUt=y(x(),1);function nFe(e,t){this.start=e??0,this.stop=t??0}var Qr=nFe;function _n(e,t){this.center=m.clone(e??m.ZERO),this.radius=t??0}var j3=
* 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 k9t=y(x(),1),sV=`/** * 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 O9t=y(x(),1),aV=`/** * 0.1 * * @name czm_epsilon1 * @glslConstant */const float czm_epsilon1 = 0.1;`;var H9t=y(x(),1),cV=`/** * 0.01 * * @name czm_epsilon2 * @glslConstant */const float czm_epsilon2 = 0.01;`;var K9t=y(x(),1),lV=`/** * 0.001 * * @name czm_epsilon3 * @glslConstant */const float czm_epsilon3 = 0.001;`;var q9t=y(x(),1),dV=`/** * 0.0001 * * @name czm_epsilon4 * @glslConstant */const float czm_epsilon4 = 0.0001;`;var e5t=y(x(),1),uV=`/** * 0.00001 * * @name czm_epsilon5 * @glslConstant */const float czm_epsilon5 = 0.00001;`;var n5t=y(x(),1),mV=`/** * 0.000001 * * @name czm_epsilon6 * @glslConstant */const float czm_epsilon6 = 0.000001;`;var o5t=y(x(),1),hV=`/** * 0.0000001 * * @name czm_epsilon7 * @glslConstant */const float czm_epsilon7 = 0.0000001;`;var s5t=y(x(),1),fV=`/** * 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 c5t=y(x(),1),pV=`/** * 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 d5t=y(x(),1),AV=`/** * 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 m5t=y(x(),1),gV=`/** * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE} * * @name czm_passCesium3DTile * @glslConstant * * @see czm_pass */const float czm_passCesium3DTile = 5.0;`;var f5t=y(x(),1),bV=`/** * 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 A5t=y(x(),1),yV=`/** * 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 b5t=y(x(),1),xV=`/** * 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 x5t=y(x(),1),CV=`/** * The automatic GLSL constant for {@link Pass#CLASSIFICATION} * * @name czm_passClassification * @glslConstant * * @see czm_pass */const float czm_passClassification = 7.0;`;var T5t=y(x(),1),TV=`/** * The automatic GLSL constant for {@link Pass#COMPUTE} * * @name czm_passCompute * @glslConstant * * @see czm_pass */const float czm_passCompute = 1.0;`;var S5t=y(x(),1),EV=`/** * The automatic GLSL constant for {@link Pass#ENVIRONMENT} * * @name czm_passEnvironment * @glslConstant * * @see czm_pass */const float czm_passEnvironment = 0.0;`;var I5t=y(x(),1),SV=`/** * The automatic GLSL constant for {@link Pass#GAUSSIAN_SPLATS} * * @name czm_passGaussianSplats * @glslConstant * * @see czm_pass */const float czm_passGaussianSplats = 11.0;`;var R5t=y(x(),1),_V=`/** * The automatic GLSL constant for {@link Pass#GLOBE} * * @name czm_passGlobe * @glslConstant * * @see czm_pass */const float czm_passGlobe = 2.0;`;var G5t=y(x(),1),IV=`/** * The automatic GLSL constant for {@link Pass#OPAQUE} * * @name czm_passOpaque * @glslConstant * * @see czm_pass */const float czm_passOpaque = 8.0;`;var W5t=y(x(),1),ZV=`/** * The automatic GLSL constant for {@link Pass#OVERLAY} * * @name czm_passOverlay * @glslConstant * * @see czm_pass */const float czm_passOverlay = 12.0;`;var B5t=y(x(),1),RV=`/** * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION} * * @name czm_passTerrainClassification * @glslConstant * * @see czm_pass */const float czm_passTerrainClassification = 3.0;`;var N5t=y(x(),1),VV=`/** * The automatic GLSL constant for {@link Pass#TRANSLUCENT} * * @name czm_passTranslucent * @glslConstant * * @see czm_pass */const float czm_passTranslucent = 9.0;`;var X5t=y(x(),1),GV=`/** * The automatic GLSL constant for {@link Pass#VOXELS} * * @name czm_passVoxels * @glslConstant * * @see czm_pass */const float czm_passVoxels = 10.0;`;var M5t=y(x(),1),LV=`/** * 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 U5t=y(x(),1),WV=`/** * 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 k5t=y(x(),1),FV=`/** * 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 O5t=y(x(),1),BV=`/** * 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 H5t=y(x(),1),wV=`/** * 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 K5t=y(x(),1),NV=`/** * 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 q5t=y(x(),1),PV=`/** * 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 eQt=y(x(),1),XV=`/** * 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 nQt=y(x(),1),YV=`/** * 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 oQt=y(x(),1),MV=`/** * 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 sQt=y(x(),1),vV=`/** * 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 cQt=y(x(),1),UV=`/** * 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 dQt=y(x(),1),DV=`/** * 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 mQt=y(x(),1),kV=`/** * 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 fQt=y(x(),1),QV=`/** * @name czm_depthRangeStruct * @glslStruct */struct czm_depthRangeStruct{ float near; float far;};`;var AQt=y(x(),1),OV=`/** * 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 bQt=y(x(),1),zV=`/** * 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 xQt=y(x(),1),HV=`/** * 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 TQt=y(x(),1),JV=`/** * 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 SQt=y(x(),1),KV=`/** * DOC_TBA * * @name czm_ray * @glslStruct */struct czm_ray{ vec3 origin; vec3 direction;};`;var IQt=y(x(),1),jV=`/** * 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 RQt=y(x(),1),qV=`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 GQt=y(x(),1),$V=`// 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 WQt=y(x(),1),eG=`/** * @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 BQt=y(x(),1),tG=`/** * 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 NQt=y(x(),1),nG=`/** * 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 XQt=y(x(),1),iG=`/** * 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 MQt=y(x(),1),oG=`/** * 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 UQt=y(x(),1),rG=`/** * 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 kQt=y(x(),1),sG=`/** * 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 OQt=y(x(),1),aG=`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 HQt=y(x(),1),cG=`uniform vec4 shadowMap_cascadeDistances;
float czm_cascadeDistance(vec4 weights){ return dot(shadowMap_cascadeDistances, weights);}`;var KQt=y(x(),1),lG=`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 qQt=y(x(),1),dG=`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 eOt=y(x(),1),uG=`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 nOt=y(x(),1),mG=`/** * 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 oOt=y(x(),1),hG=`/** * 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 sOt=y(x(),1),fG=`/** * 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 cOt=y(x(),1),pG=`/** * 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 dOt=y(x(),1),AG=`/** * 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 mOt=y(x(),1),gG=`/** * 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 fOt=y(x(),1),bG=`/** * @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 AOt=y(x(),1),yG=`/** * 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 bOt=y(x(),1),xG=`/** * 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 xOt=y(x(),1),CG=`// 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 TOt=y(x(),1),TG=`/** * 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 SOt=y(x(),1),EG=`/** * 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 IOt=y(x(),1),SG=`/** * 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 ROt=y(x(),1),_G=`/** * 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 GOt=y(x(),1),IG=`/** * 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 WOt=y(x(),1),ZG=`/** * 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 BOt=y(x(),1),RG=`/** * 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 NOt=y(x(),1),VG=`/** * 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 XOt=y(x(),1),GG=`/** * 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 MOt=y(x(),1),LG=`/** * 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 UOt=y(x(),1),WG=`/** * 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 kOt=y(x(),1),FG=`/** * 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 OOt=y(x(),1),BG=`/** * 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 HOt=y(x(),1),wG=`/** * 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 KOt=y(x(),1),NG=`/** * @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 qOt=y(x(),1),PG=`/** * 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 ezt=y(x(),1),XG=`/** * 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 nzt=y(x(),1),YG=`/** * 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 ozt=y(x(),1),MG=`/** * 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 szt=y(x(),1),vG=`/** * 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 czt=y(x(),1),UG=`/** * 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 dzt=y(x(),1),DG=`/** * 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 mzt=y(x(),1),kG=`/** * 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 fzt=y(x(),1),QG=`/** * 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 Azt=y(x(),1),OG=`/** * 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 bzt=y(x(),1),zG=`/** * 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 xzt=y(x(),1),HG=`/** * 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 Tzt=y(x(),1),JG=`/** * 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 Szt=y(x(),1),KG=`/** * 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 Izt=y(x(),1),jG=`/** * 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 Rzt=y(x(),1),qG=` /** * 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 Gzt=y(x(),1),$G=`/** * 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 Wzt=y(x(),1),eL=`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 Bzt=y(x(),1),tL=`// 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 Nzt=y(x(),1),nL=`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 Xzt=y(x(),1),iL=`/** * 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 Mzt=y(x(),1),oL=`/** * 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 Uzt=y(x(),1),rL=`/** * 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 kzt=y(x(),1),sL=`/** * 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 Ozt=y(x(),1),aL=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords){ return czm_reverseLogDepth(texture(depthTexture, texCoords).r);}`;var Hzt=y(x(),1),cL=`/** * 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 Kzt=y(x(),1),lL=`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 qzt=y(x(),1),dL=`/** * 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 e3t=y(x(),1),uL=`/** * 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 n3t=y(x(),1),mL=`/** * 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 o3t=y(x(),1),hL=`/** * 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 s3t=y(x(),1),fL=`/** * 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 c3t=y(x(),1),pL=`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 d3t=y(x(),1),AL=`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 m3t=y(x(),1),gL=`/** * 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 f3t=y(x(),1),bL=`/** * 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 A3t=y(x(),1),yL=`/** * 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 b3t=y(x(),1),xL=`/** * 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 x3t=y(x(),1),CL=`/** * 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 T3t=y(x(),1),TL=`/** * 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 S3t=y(x(),1),EL=`/** * 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 I3t=y(x(),1),SL=`/** * @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 R3t=y(x(),1),_L=`/** * 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 G3t=y(x(),1),IL=`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 W3t=y(x(),1),ZL=`/** * 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 B3t=y(x(),1),RL=`/** * 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 N3t=y(x(),1),VL=`/** * 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 X3t=y(x(),1),GL=`/** * 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 M3t=y(x(),1),LL=`/** * 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 U3t=y(x(),1),WL=`#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 k3t=y(x(),1),FL=`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 O3t=y(x(),1),BL=`// 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 H3t=y(x(),1),wL=`#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 K3t=y(x(),1),NL=`/** * 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 q3t=y(x(),1),PL=`/** * 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 _x={czm_degreesPerRadian:rV,czm_depthRange:sV,czm_epsilon1:aV,czm_epsilon2:cV,czm_epsilon3:lV,czm_epsilon4:dV,czm_epsilon5:uV,czm_epsilon6:mV,czm_epsilon7:hV,czm_infinity:fV,czm_oneOverPi:pV,czm_oneOverTwoPi:AV,czm_passCesium3DTile:gV,czm_passCesium3DTileClassification:bV,czm_passCesium3DTileClassificationIgnoreShow:yV,czm_passCesium3DTileEdges:xV,czm_passClassification:CV,czm_passCompute:TV,czm_passEnvironment:EV,czm_passGaussianSplats:SV,czm_passGlobe:_V,czm_passOpaque:IV,czm_passOverlay:ZV,czm_passTerrainClassification:RV,czm_passTranslucent:VV,czm_passVoxels:GV,czm_pi:LV,czm_piOverFour:WV,czm_piOverSix:FV,czm_piOverThree:BV,czm_piOverTwo:wV,czm_radiansPerDegree:NV,czm_sceneMode2D:PV,czm_sceneMode3D:XV,czm_sceneModeColumbusView:YV,czm_sceneModeMorphing:MV,czm_solarRadius:vV,czm_threePiOver2:UV,czm_twoPi:DV,czm_webMercatorMaxLatitude:kV,czm_depthRangeStruct:QV,czm_material:OV,czm_materialInput:zV,czm_modelMaterial:HV,czm_modelVertexOutput:JV,czm_ray:KV,czm_raySegment:jV,czm_shadowParameters:qV,czm_acesTonemapping:$V,czm_alphaWeight:eG,czm_antialias:tG,czm_applyHSBShift:nG,czm_approximateSphericalCoordinates:iG,czm_approximateTanh:oG,czm_backFacing:rG,czm_branchFreeTernary:sG,czm_cascadeColor:aG,czm_cascadeDistance:cG,czm_cascadeMatrix:lG,czm_cascadeWeights:dG,czm_clipPolygons:uG,czm_columbusViewMorph:mG,czm_computeAtmosphereColor:hG,czm_computeGroundAtmosphereScattering:fG,czm_computePosition:pG,czm_computeScattering:AG,czm_computeTextureTransform:gG,czm_cosineAndSine:bG,czm_decodeRGB8:yG,czm_decompressTextureCoordinates:xG,czm_depthClamp:CG,czm_eastNorthUpToEyeCoordinates:TG,czm_ellipsoidContainsPoint:EG,czm_ellipsoidTextureCoordinates:SG,czm_equalsEpsilon:_G,czm_eyeOffset:IG,czm_eyeToWindowCoordinates:ZG,czm_fastApproximateAtan:RG,czm_fog:VG,czm_gammaCorrect:GG,czm_geodeticSurfaceNormal:LG,czm_getDefaultMaterial:WG,czm_getDynamicAtmosphereLightDirection:FG,czm_getLambertDiffuse:BG,czm_getSpecular:wG,czm_getWaterNoise:NG,czm_HSBToRGB:PG,czm_HSLToRGB:XG,czm_hue:YG,czm_inverseGamma:MG,czm_isEmpty:vG,czm_isFull:UG,czm_latitudeToWebMercatorFraction:DG,czm_linearToSrgb:kG,czm_lineDistance:QG,czm_luminance:OG,czm_maximumComponent:zG,czm_metersPerPixel:HG,czm_modelToWindowCoordinates:JG,czm_multiplyWithColorBalance:KG,czm_nearFarScalar:jG,czm_octDecode:qG,czm_packDepth:$G,czm_pbrLighting:eL,czm_pbrNeutralTonemapping:tL,czm_phong:nL,czm_planeDistance:iL,czm_pointAlongRay:oL,czm_rayEllipsoidIntersectionInterval:rL,czm_raySphereIntersectionInterval:sL,czm_readDepth:aL,czm_readNonPerspective:cL,czm_reverseLogDepth:lL,czm_RGBToHSB:dL,czm_RGBToHSL:uL,czm_RGBToXYZ:mL,czm_round:hL,czm_saturation:fL,czm_shadowDepthCompare:pL,czm_shadowVisibility:AL,czm_signNotZero:gL,czm_sphericalHarmonics:bL,czm_srgbToLinear:yL,czm_tangentToEyeSpaceMatrix:xL,czm_textureCube:CL,czm_transformPlane:TL,czm_translateRelativeToEye:EL,czm_translucentPhong:SL,czm_transpose:_L,czm_unpackClippingExtents:IL,czm_unpackDepth:ZL,czm_unpackFloat:RL,czm_unpackTexture:VL,czm_unpackUint:GL,czm_valueTransform:LL,czm_vertexLogDepth:WL,czm_windowToEyeCoordinates:FL,czm_writeDepthClamp:BL,czm_writeLogDepth:wL,czm_writeNonPerspective:NL,czm_XYZToRGB:PL};var wKt=y(x(),1);function X2e(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 XL=X2e;function dse(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 use(e,t,n){let i;for(let o=0;o<n.length;++o)n[o].name===e&&(i=n[o]);return l(i)||(t=dse(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function mse(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&&Ia._czmBuiltinsAndUniforms.hasOwnProperty(i)){let o=use(i,Ia._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(o),o.requiredBy.push(e),mse(o,t)}}))}function Y2e(e){let t=[],n=[];for(;e.length>0;){let o=e.pop();n.push(o),o.requiredBy.length===0&&t.push(o)}for(;t.length>0;){let o=t.shift();e.push(o);for(let r=0;r<o.dependsOn.length;++r){let s=o.dependsOn[r],a=s.requiredBy.indexOf(o);s.requiredBy.splice(a,1),s.requiredBy.length===0&&t.push(s)}}let i=[];for(let o=0;o<n.length;++o)n[o].requiredBy.length!==0&&i.push(n[o])}function M2e(e){let t=[],n=use("main",e,t);mse(n,t),Y2e(t);let i="";for(let o=t.length-1;o>=0;--o)i=`${i+t[o].glslSource}`;return i.replace(n.glslSource,"")}function hse(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=dse(i);let r;i=i.replace(/#version\s+(.*?)\n/gm,function(A,f){return r=f,``});let s=[];i=i.replace(/#extension.*\n/gm,function(A){return s.push(A),``}),i=i.replace(/precision\s(lowp|mediump|highp)\s(float|int);/,"");let a=e.pickColorQualifier;l(a)&&(i=Ia.createPickFragmentShaderSource(i,a));let c="",d=s.length;for(let A=0;A<d;A++)c+=s[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 u=e.defines;if(l(u))for(let A=0,f=u.length;A<f;++A){let b=u[A];b.length!==0&&(c+=`#define ${b}`)}n.textureFloatLinear&&(c+=`#define OES_texture_float_linear
`),n.floatingPointTexture&&(c+=`#define OES_texture_float
`);let h="";e.includeBuiltIns&&(h=M2e(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=XL(c,t),c}function Ia(e){e=e??Q.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}Ia.prototype.clone=function(){return new Ia({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};Ia.replaceMain=function(e,t){return t=`void ${t}()`,e.replace(/void\s+main\s*\(\s*(?:void)?\s*\)/g,t)};Ia.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}`};Ia.prototype.createCombinedVertexShader=function(e){return hse(this,!1,e)};Ia.prototype.createCombinedFragmentShader=function(e){return hse(this,!0,e)};Ia._czmBuiltinsAndUniforms={};for(let e in _x)_x.hasOwnProperty(e)&&(Ia._czmBuiltinsAndUniforms[e]=_x[e]);for(let e in yA)if(yA.hasOwnProperty(e)){let t=yA[e];typeof t.getDeclaration=="function"&&(Ia._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}Ia.createPickVertexShaderSource=function(e){return`${Ia.replaceMain(e,"czm_old_main")}in vec4 pickColor; out vec4 czm_pickColor; void main() { czm_old_main(); czm_pickColor = pickColor; }`};Ia.createPickFragmentShaderSource=function(e,t){let n=Ia.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 v2e(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 fse(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 pse(e,t){let n=t.length;for(let i=0;i<n;++i){let o=t[i];if(fse(e,o))return o}}var U2e=["v_normalEC","v_normal"];Ia.findNormalVarying=function(e){return fse(e,"#ifdef HAS_NORMALS")?v2e(e,"HAS_NORMALS")?"v_normalEC":void 0:pse(e,U2e)};var D2e=["v_positionEC"];Ia.findPositionVarying=function(e){return pse(e,D2e)};var ze=Ia;function _h(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(_h.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});_h.prototype.replaceShaderProgram=function(e){return l(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function k2e(e){let t=Object.keys(e).sort();return JSON.stringify(e,t)}_h.prototype.getShaderProgram=function(e){let t=e.vertexShaderSource,n=e.fragmentShaderSource,i=e.attributeLocations;typeof t=="string"&&(t=new ze({sources:[t]})),typeof n=="string"&&(n=new ze({sources:[n]}));let o=t.getCacheKey(),r=n.getCacheKey(),s=l(i)?k2e(i):"",a=`${o}:${r}:${s}`,c;if(l(this._shaders[a]))c=this._shaders[a],delete this._shadersToRelease[a];else{let d=this._context,u=t.createCombinedVertexShader(d),h=n.createCombinedFragmentShader(d),p=new tn({gl:d._gl,logShaderCompilation:d.logShaderCompilation,debugShaders:d.debugShaders,vertexShaderSource:t,vertexShaderText:u,fragmentShaderSource:n,fragmentShaderText:h,attributeLocations:i});c={cache:this,shaderProgram:p,keyword:a,derivedKeywords:[],count:0},p._cachedShader=c,this._shaders[a]=c,++this._numberOfShaders}return++c.count,c.shaderProgram};_h.prototype.replaceDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=this._shaders[o];if(l(r)){FH(this,r);let s=i.derivedKeywords.indexOf(t);s>-1&&i.derivedKeywords.splice(s,1)}return this.createDerivedShaderProgram(e,t,n)};_h.prototype.getDerivedShaderProgram=function(e,t){let n=e._cachedShader,i=t+n.keyword,o=this._shaders[i];if(l(o))return o.shaderProgram};_h.prototype.createDerivedShaderProgram=function(e,t,n){let i=e._cachedShader,o=t+i.keyword,r=n.vertexShaderSource,s=n.fragmentShaderSource,a=n.attributeLocations;typeof r=="string"&&(r=new ze({sources:[r]})),typeof s=="string"&&(s=new ze({sources:[s]}));let c=this._context,d=r.createCombinedVertexShader(c),u=s.createCombinedFragmentShader(c),h=new tn({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:r,vertexShaderText:d,fragmentShaderSource:s,fragmentShaderText:u,attributeLocations:a}),p={cache:this,shaderProgram:h,keyword:o,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),h._cachedShader=p,this._shaders[o]=p,h};function FH(e,t){let n=t.derivedKeywords,i=n.length;for(let o=0;o<i;++o){let r=n[o]+t.keyword,s=e._shaders[r];FH(e,s)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}_h.prototype.destroyReleasedShaderPrograms=function(){let e=this._shadersToRelease;for(let t in e)if(e.hasOwnProperty(t)){let n=e[t];FH(this,n),--this._numberOfShaders}this._shadersToRelease={}};_h.prototype.releaseShaderProgram=function(e){if(l(e)){let t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};_h.prototype.isDestroyed=function(){return!1};_h.prototype.destroy=function(){let e=this._shaders;for(let t in e)e.hasOwnProperty(t)&&e[t].shaderProgram.finalDestroy();return he(this)};var YL=_h;var ajt=y(x(),1);function Ih(e){e=e??Q.EMPTY_OBJECT;let{context:t,source:n,pixelFormat:i=Ke.RGBA,pixelDatatype:o=Oe.UNSIGNED_BYTE,flipY:r=!0,skipColorSpaceConversion:s=!1,sampler:a=new Ht}=e,{width:c,height:d}=e;l(n)&&(l(c)||(c=n.videoWidth??n.naturalWidth??n.width),l(d)||(d=n.videoHeight??n.naturalHeight??n.height));let u=e.preMultiplyAlpha||i===Ke.RGB||i===Ke.LUMINANCE,h=Ke.toInternalFormat(i,o,t),p=Ke.isCompressedFormat(h),A=t._gl,f=p?Ke.compressedTextureSizeInBytes(i,c,d):Ke.textureSizeInBytes(i,o,c,d);this._id=e.id??qn(),this._context=t,this._textureFilte
`),r=new ze({defines:this._vertexShaderParts.defineLines,sources:[o]}),s=this._fragmentShaderParts.uniformLines.concat(this._fragmentShaderParts.varyingLines,n.fragmentLines,i.fragmentLines,this._fragmentShaderParts.shaderLines).join(``),a=new ze({defines:this._fragmentShaderParts.defineLines,sources:[s]});return tn.fromCache({context:e,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:this._attributeLocations})};El.prototype.clone=function(){return He(this,!0)};function vwe(e){let t=[],n=[],i,o=e._vertexShaderParts.structIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),ri(t,a);for(o=e._fragmentShaderParts.structIds,i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),ri(n,a);return{vertexLines:t,fragmentLines:n}}function Uwe(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function Dwe(e){let t=[],n=[],i,o=e._vertexShaderParts.functionIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),ri(t,a);for(o=e._fragmentShaderParts.functionIds,i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),ri(n,a);return{vertexLines:t,fragmentLines:n}}var GA=El;var K8t=y(x(),1);function OD(e){this._autoDestroy=e?.autoDestroy??!0,this._canvas=document.createElement("canvas"),this._context=new Zx(this._canvas,He(e?.contextOptions)),this._canvases=[]}OD.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,d=this.drawingBufferWidth;c.width<d&&(c.width=d);let u=this.drawingBufferHeight;c.height<u&&(c.height=u)},s=function(){let c=this.drawingBufferWidth,d=this.drawingBufferHeight,u=n._context.canvas.height-d;t.drawImage(n._context.canvas,0,u,c,d,0,0,c,d),n._context.endFrame()};return new Proxy(this._context,{get(c,d,u){if(d==="isDestroyed")return function(){return i};switch(d){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 s;default:return Reflect.get(c,d,u)}}})};OD.prototype.destroy=function(){this._context.destroy(),he(this)};OD.prototype.isDestroyed=function(){return!1};var JL=OD;var i7t=y(x(),1);function Vx(e){e=e??Q.EMPTY_OBJECT;let t=e.context;if(!t._webgl2)throw new fe("A WebGL 2 context is required to use Sync operations.");let n=t._gl,i=n.fenceSync(ne.SYNC_GPU_COMMANDS_COMPLETE,0);this._gl=n,this._sync=i}Vx.create=function(e){return new Vx(e)};Vx.prototype.getStatus=function(){return this._gl.getSyncParameter(this._sync,ne.SYNC_STATUS)};Vx.prototype.isDestroyed=function(){return!1};Vx.prototype.destroy=function(){return this._gl.deleteSync(this._sync),he(this)};Vx.prototype.waitForSignal=async function(e,t){let n=this;t=t??10;function i(o,r,s){return()=>{n.getStatus()===ne.SIGNALED?o():s<=0?r(new me("Wait for signal timeout")):e(i(o,r,s-1))}}return new Promise((o,r)=>{e(i(o,r,t))})};var KL=Vx;var g7t=y(x(),1);function $b(e){e=e??Q.EMPTY_OBJECT;let{context:t,source:n,pixelFormat:i=Ke.RGBA,pixelDatatype:o=Oe.UNSIGNED_BYTE,flipY:r=!0,skipColorSpaceConversion:s=!1,sampler:a=new Ht}=e;if(!t.webgl2&&!l(t.options.getWebGLStub))throw new fe("WebGL1 does not support texture3D. Please use a WebGL2 context.");let{width:c,height:d,depth:u}=e;l(n)&&(l(c)||(c=n.width),l(d)||(d=n.height),l(u)||(u=n.depth));let h=e.preMultiplyAlpha||i===Ke.RGB||i===Ke.LUMINANCE,p=Ke.toInternalFormat(i,o,t),A=Ke.isCompressedFormat(p),f=t._gl,b=Ke.texture3DSizeInBytes(i,o,c,d,u);if(this._id=e.id??qn(),this._context=t,this._textureFilterAnisotropic=t._textureFilterAnisotropic,this._textureTarget=f.TEXTURE_3D,this._texture=f.createTexture(),this._internalFormat=p,this._pixelFormat=i,this._pixelDatatype=o,this._width=c,this._height=d,this._depth=u,this._dimensions=new m(c,d,u),this._hasMipmap=!1,this._sizeInBytes=b,this._preMultiplyAlpha=h,this._flipY=r,this._initialized=!1,this._sampler=void 0,this._sampler=a,$se(this,a),f.activeTexture(f.TEXTURE0),f.bindTexture(this._textureTarget,this._texture),l(n)){if(s?f.pixelStorei(f.UNPACK_COLORSPACE_CONVERSION_WEBGL,f.NONE):f.pixelStorei(f.UNPACK_COLORSPACE_CONVERSIO
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 Xqt=y(x(),1),o1=`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 Mqt=y(x(),1),r1=`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 Uqt=y(x(),1),s1=`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 kqt=y(x(),1),a1=`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 Oqt=y(x(),1),c1=`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 h$t=y(x(),1);var n$t=y(x(),1);var Jqt=y(x(),1);var INe={ADD:ne.FUNC_ADD,SUBTRACT:ne.FUNC_SUBTRACT,REVERSE_SUBTRACT:ne.FUNC_REVERSE_SUBTRACT,MIN:ne.MIN,MAX:ne.MAX},Ec=Object.freeze(INe);var qqt=y(x(),1);var ZNe={ZERO:ne.ZERO,ONE:ne.ONE,SOURCE_COLOR:ne.SRC_COLOR,ONE_MINUS_SOURCE_COLOR:ne.ONE_MINUS_SRC_COLOR,DESTINATION_COLOR:ne.DST_COLOR,ONE_MINUS_DESTINATION_COLOR:ne.ONE_MINUS_DST_COLOR,SOURCE_ALPHA:ne.SRC_ALPHA,ONE_MINUS_SOURCE_ALPHA:ne.ONE_MINUS_SRC_ALPHA,DESTINATION_ALPHA:ne.DST_ALPHA,ONE_MINUS_DESTINATION_ALPHA:ne.ONE_MINUS_DST_ALPHA,CONSTANT_COLOR:ne.CONSTANT_COLOR,ONE_MINUS_CONSTANT_COLOR:ne.ONE_MINUS_CONSTANT_COLOR,CONSTANT_ALPHA:ne.CONSTANT_ALPHA,ONE_MINUS_CONSTANT_ALPHA:ne.ONE_MINUS_CONSTANT_ALPHA,SOURCE_ALPHA_SATURATE:ne.SRC_ALPHA_SATURATE},Ko=Object.freeze(ZNe);var RNe={DISABLED:Object.freeze({enabled:!1}),ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:Ec.ADD,equationAlpha:Ec.ADD,functionSourceRgb:Ko.SOURCE_ALPHA,functionSourceAlpha:Ko.ONE,functionDestinationRgb:Ko.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Ko.ONE_MINUS_SOURCE_ALPHA}),PRE_MULTIPLIED_ALPHA_BLEND:Object.freeze({enabled:!0,equationRgb:Ec.ADD,equationAlpha:Ec.ADD,functionSourceRgb:Ko.ONE,functionSourceAlpha:Ko.ONE,functionDestinationRgb:Ko.ONE_MINUS_SOURCE_ALPHA,functionDestinationAlpha:Ko.ONE_MINUS_SOURCE_ALPHA}),ADDITIVE_BLEND:Object.freeze({enabled:!0,equationRgb:Ec.ADD,equationAlpha:Ec.ADD,functionSourceRgb:Ko.SOURCE_ALPHA,functionSourceAlpha:Ko.ONE,functionDestinationRgb:Ko.ONE,functionDestinationAlpha:Ko.ONE})},ln=Object.freeze(RNe);var r$t=y(x(),1);var VNe={FRONT:ne.FRONT,BACK:ne.BACK,FRONT_AND_BACK:ne.FRONT_AND_BACK},wi=Object.freeze(VNe);function SS(e){e=e??Q.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(SS.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}}});SS.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(``)};SS.prototype.isTranslucent=function(){return l(this.material)&&this.material.isTranslucent()||!l(this.material)&&this.translucent};SS.prototype.getRenderState=function(){let e=this.isTranslucent(),t=He(this.renderState,!1);return e?(t.depthMask=!1,t.blending=ln.ALPHA_BLEND):t.depthMask=!0,t};SS.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=ln.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:wi.BACK}),l(n)&&(i=Ft(n,i,!0)),i};var To=SS;var Nen=y(x(),1);var p$t=y(x(),1),l1=`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 g$t=y(x(),1),d1=`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 y$t=y(x(),1),u1=`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 C$t=y(x(),1),m1=`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 E$t=y(x(),1),h1=`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 _$t=y(x(),1),f1=`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 Z$t=y(x(),1),p1=`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 V$t=y(x(),1),A1=`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 L$t=y(x(),1),g1=`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 F$t=y(x(),1),b1=`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 w$t=y(x(),1),y1=`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 P$t=y(x(),1),x1=`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 Y$t=y(x(),1),C1=`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 v$t=y(x(),1),T1=`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 D$t=y(x(),1),E1=`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 Q$t=y(x(),1),S1=`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 z$t=y(x(),1),_1=`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 J$t=y(x(),1),I1=`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 j$t=y(x(),1),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 tt(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??zt.LINEAR,this._magnificationFilter=e.magnificationFilter??li.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,GNe(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(tt._uniformList[this.type])||(tt._uniformList[this.type]=Object.keys(this._uniforms))}tt._uniformList={};tt.fromType=function(e,t){let n=new tt({fabric:{type:e}});if(l(t))for(let i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};tt.fromTypeAsync=async function(e,t){let n=[],i=new tt({fabric:{type:e,uniforms:t}});if(dae(i,n),await Promise.all(n),n.length=0,l(i._initializationError))throw i._initializationError;return i};function dae(e,t){t.push(...e._initializationPromises);let n=e.materials;for(let i in n)if(n.hasOwnProperty(i)){let o=n[i];dae(o,t)}}tt.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};tt.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 d=c.image,u;Array.isArray(d)&&(u=d.slice(1,d.length).map(function(b){return b.bufferView}),d=d[0]);let h=new Ht({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter}),p;l(d.internalFormat)?p=new Lt({context:e,pixelFormat:d.internalFormat,width:d.width,height:d.height,source:{arrayBufferView:d.bufferView,mipLevels:u},sampler:h}):p=new Lt({context:e,source:d,sampler:h});let A=this._textures[n];l(A)&&A!==this._defaultTexture&&A.destroy(),this._textures[n]=p;let f=`${n}Dimensions`;if(this.uniforms.hasOwnProperty(f)){let b=this.uniforms[f];b.x=p._width,b.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 d=c.images,u=new Or({context:e,source:{positiveX:d[0],negativeX:d[1],positiveY:d[2],negativeY:d[3],positiveZ:d[4],negativeZ:d[5]},sampler:new Ht({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[n]=u}r.length=0;let s=this._updateFunctions;for(o=s.length,t=0;t<o;++t)s[t](this,e);let a=this.materials;for(let c in a)a.hasOwnProperty(c)&&a[c].update(e)};tt.prototype.isDestroyed=function(){return!1};tt.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 he(this)};function GNe(e,t){e=e??Q.EMPTY_OBJECT,t._strict=e.strict??!1,t._count=e.count??0,t._template=He(e.fabric??Q.EMPTY_OBJECT),t.fabric=He(e.fabric??Q.EMPTY_OBJECT),t._template.uniforms=He(t._template.uniforms??Q.EMPTY_OBJECT),t._template.materials=He(t._template.materials??Q.EMPTY_OBJECT),t.type=l(t._template.type)?t._template.type:qn(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];let n,i=tt._materialCache.getMaterial(t.type);if(l(i)){let r=He(i.fabric,!0);t._template=Ft(t._template,r,!0),n=i.translucent}BNe(t),NNe(t),MNe(t),UNe(t),l(i)||tt._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 s=i&&wNe(t[o],e)?t[o]:`czm_gammaCorrect(${t[o]})`;e.shaderSource+=`material.${o} = ${s}; `}else o==="alpha"?e.shaderSource+=`material.alpha = ${t.alpha}; `:e.shaderSource+=`material.${o} = ${t[o]};`}e.shaderSource+=`return material;}`}}var lae={mat2:Qi,mat3:$,mat4:F},PNe=/\.ktx2$/i;function XNe(e){let t;return function(n,i){let o=n.uniforms,r=o[e],s=t!==r,a=!l(r)||r===tt.DefaultImageId;t=r;let c=n._textures[e],d,u;if(r instanceof HTMLVideoElement){if(r.readyState>=2){if(s&&l(c)&&(c!==i.defaultTexture&&c.destroy(),c=void 0),!l(c)||c===i.defaultTexture){let h=new Ht({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new Lt({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 Lt&&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,d=`${e}Dimensions`,o.hasOwnProperty(d)&&(u=o[d],u.x=r._width,u.y=r._height);return}if(s&&l(c)&&a&&(c!==n._defaultTexture&&c.destroy(),c=void 0,n._texturePaths[e]=void 0),l(c)||(c=n._textures[e]=n._defaultTexture,d=`${e}Dimensions`,o.hasOwnProperty(d)&&(u=o[d],u.x=c._width,u.y=c._height)),!a){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}uae(n,e)}}}function uae(e,t){let i=e.uniforms[t];if(i===tt.DefaultImageId)return Promise.resolve();let o=Le.createIfNeeded(i);if(!(o instanceof Le))return Promise.resolve();let r=Le.createIfNeeded(e._texturePaths[t]);if(!(!l(r)||r.url!==o.url))return Promise.resolve();let a;return PNe.test(o.url)?a=md(o.url):a=o.fetchImage(),Promise.resolve(a).then(function(c){e._loadedImages.push({id:t,image:c})}).catch(function(c){e._initializationError=c;let d=e._textures[t];l(d)&&d!==e._defaultTexture&&d.destroy(),e._textures[t]=e._defaultTexture}),e._texturePaths[t]=i,a}function YNe(e){return function(t,n){let i=t.uniforms[e];if(i instanceof Or){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),mae(t,e)}}function mae(e,t){let i=e.uniforms[t];if(i===tt.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=[Le.createIfNeeded(i.positiveX).fetchImage(),Le.createIfNeeded(i.negativeX).fetchImage(),Le.createIfNeeded(i.positiveY).fetchImage(),Le.createIfNeeded(i.negativeY).fetchImage(),Le.createIfNeeded(i.positiveZ).fetchImage(),Le.createIfNeeded(i.negativeZ).fetchImage()],s=Promise.all(r);return s.then(function(a){e._loadedCubeMaps.push({id:t,images:a})}).catch(function(a){e._initializationError=a}),e._texturePaths[t]=o,s}function MNe(e){let t=e._template.uniforms;for(let n in t)t.hasOwnProperty(n)&&hae(e,n)}function hae(e,t){let n=e._strict,i=e._template.uniforms,o=i[t],r=vNe(o),s;if(r==="channels")s=R1(e,t,o,!1);else{if(r==="sampler2D"){let d=`${t}Dimensions`;DNe(e,d)>0&&(i[d]={type:"ivec3",x:1,y:1},hae(e,d))}if(!new RegExp(`uniform\\s+${r}\\s+${t}\\s*;`).test(e.shaderSource)){let d=`uniform ${r} ${t};`;e.shaderSource=d+e.shaderSource}let c=`${t}_${e._count++}`;if(s=R1(e,t,c),e.uniforms[t]=o,r==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(XNe(t)),e._initializationPromises.push(uae(e,t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(YNe(t)),e._initializationPromises.push(mae(e,t));else if(r.indexOf("mat")!==-1){let d=new lae[r];e._uniforms[c]=function(){return lae[r].fromColumnMajorArray(e.uniforms[t],d)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function vNe(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 Le||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof ImageBitmap||e instanceof OffscreenCanvas||e instanceof Lt)/^([rgba]){1,4}$/i.test(e)?t="channels":e===tt.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 $en=y(x(),1),G1=`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 ttn=y(x(),1),Bx=`in vec4 v_color;
void main(){ out_FragColor = czm_gammaCorrect(v_color);}`;var itn=y(x(),1),L1=`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 WA(e){e=e??Q.EMPTY_OBJECT;let t=e.translucent??!0,n=e.closed??!1,i=e.flat??!1,o=i?L1:G1,r=i?Bx:V1,s=i?WA.FLAT_VERTEX_FORMAT:WA.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??o,this._fragmentShaderSource=e.fragmentShaderSource??r,this._renderState=To.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=e.faceForward??!n}Object.defineProperties(WA.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}}});WA.VERTEX_FORMAT=ve.POSITION_AND_NORMAL;WA.FLAT_VERTEX_FORMAT=ve.POSITION_ONLY;WA.prototype.getFragmentShaderSource=To.prototype.getFragmentShaderSource;WA.prototype.isTranslucent=To.prototype.isTranslucent;WA.prototype.getRenderState=To.prototype.getRenderState;var yn=WA;var xtn=y(x(),1);function _S(e){this._definitionChanged=new xe,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(_S.prototype,{isConstant:{get:function(){return K.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:be("color")});_S.prototype.getType=function(e){return"Color"};var kNe=new q;_S.prototype.getValue=function(e,t){return l(e)||(e=q.now(kNe)),l(t)||(t={}),t.color=K.getValueOrClonedDefault(this._color,e,U.WHITE,t.color),t};_S.prototype.equals=function(e){return this===e||e instanceof _S&&K.equals(this._color,e._color)};var Kt=_S;var qrn=y(x(),1);var Lrn=y(x(),1);var vtn=y(x(),1);var Vtn=y(x(),1);function n0(e){e=e??Q.EMPTY_OBJECT,this._ellipsoid=e.ellipsoid??ie.default,this._rectangle=e.rectangle??de.MAX_VALUE,this._projection=new ki(this._ellipsoid),this._numberOfLevelZeroTilesX=e.numberOfLevelZeroTilesX??2,this._numberOfLevelZeroTilesY=e.numberOfLevelZeroTilesY??1}Object.defineProperties(n0.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});n0.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};n0.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};n0.prototype.rectangleToNativeRectangle=function(e,t){let n=L.toDegrees(e.west),i=L.toDegrees(e.south),o=L.toDegrees(e.east),r=L.toDegrees(e.north);return l(t)?(t.west=n,t.south=i,t.east=o,t.north=r,t):new de(n,i,o,r)};n0.prototype.tileXYToNativeRectangle=function(e,t,n,i){let o=this.tileXYToRectangle(e,t,n,i);return o.west=L.toDegrees(o.west),o.south=L.toDegrees(o.south),o.east=L.toDegrees(o.east),o.north=L.toDegrees(o.north),o};n0.prototype.tileXYToRectangle=function(e,t,n,i){let o=this._rectangle,r=this.getNumberOfXTilesAtLevel(n),s=this.getNumberOfYTilesAtLevel(n),a=o.width/r,c=e*a+o.west,d=(e+1)*a+o.west,u=o.height/s,h=o.north-t*u,p=o.north-(t+1)*u;return l(i)||(i=new de(c,p,d,h)),i.west=c,i.south=p,i.east=d,i.north=h,i};n0.prototype.positionToTileXY=function(e,t,n){let i=this._rectangle;if(!de.contains(i,e))return;let o=this.getNumberOfXTilesAtLevel(t),r=this.getNumberOfYTilesAtLevel(t),s=i.width/o,a=i.height/r,c=e.longitude;i.east<i.west&&(c+=L.TWO_PI);let d=(c-i.west)/s|0;d>=o&&(d=o-1);let u=(i.north-e.latitude)/a|0;return u>=r&&(u=r-1),l(n)?(n.x=d,n.y=u,n):new M(d,u)};var zi=n0;var fae=new m,pae=new m,Aae=new Ae,OH=new m,QNe=new m,gae=new ue,ONe=new zi,W1=[new Ae,new Ae,new Ae,new Ae],F1=new M,Zs={};Zs.initialize=function(){let e=Zs._initPromise;return l(e)||(e=Le.fetchJson(en("Assets/approximateTerrainHeights.json")).then(function(t){Zs._terrainHeights=t}),Zs._initPromise=e),e};Zs.getMinimumMaximumHeights=function(e,t){t=t??ie.default;let n=bae(e),i=Zs._defaultMinTerrainHeight,o=Zs._defaultMaxTerrainHeight;if(l(n)){let r=`${n.level}-${n.x}-${n.y}`,s=Zs._terrain
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 Gnn=y(x(),1),i0=`#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 Wnn=y(x(),1),Vae={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};Vae.NUMBER_OF_CLASSIFICATION_TYPES=3;var ti=Object.freeze(Vae);var wnn=y(x(),1);var PPe={NEVER:ne.NEVER,LESS:ne.LESS,EQUAL:ne.EQUAL,LESS_OR_EQUAL:ne.LEQUAL,GREATER:ne.GREATER,NOT_EQUAL:ne.NOTEQUAL,GREATER_OR_EQUAL:ne.GEQUAL,ALWAYS:ne.ALWAYS},ec=Object.freeze(PPe);var don=y(x(),1);var Pnn=y(x(),1);function XPe(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 w1=XPe;var jnn=y(x(),1);function FA(e,t,n){if(this._attributes=t,this._numberOfInstances=n,t.length===0)return;let i=YPe(t),o=e.floatingPointTexture,r=i===Oe.FLOAT&&!o,s=MPe(t,r),a=vPe(s,t,r),c=Math.floor(Bt.maximumTextureSize/a),d=Math.min(n,c),u=a*d,h=Math.ceil(n/d),p=1/u,A=p*.5,f=1/h,b=f*.5;this._textureDimensions=new M(u,h),this._textureStep=new re(p,A,f,b),this._pixelDatatype=r?Oe.UNSIGNED_BYTE:i,this._packFloats=r,this._offsets=s,this._stride=a,this._texture=void 0;let C=4*u*h;this._batchValues=i===Oe.FLOAT&&!r?new Float32Array(C):new Uint8Array(C),this._batchValuesDirty=!1}Object.defineProperties(FA.prototype,{attributes:{get:function(){return this._attributes}},numberOfInstances:{get:function(){return this._numberOfInstances}}});function YPe(e){let t=!1,n=e.length;for(let i=0;i<n;++i)if(e[i].componentDatatype!==H.UNSIGNED_BYTE){t=!0;break}return t?Oe.FLOAT:Oe.UNSIGNED_BYTE}function Lae(e,t){let n=e[t].componentsPerAttribute;return n===2?M:n===3?m:n===4?re:Number}function MPe(e,t){let n=new Array(e.length),i=0,o=e.length;for(let r=0;r<o;++r){let a=e[r].componentDatatype;n[r]=i,a!==H.UNSIGNED_BYTE&&t?i+=4:++i}return n}function vPe(e,t,n){let i=e.length,o=e[i-1];return t[i-1].componentDatatype!==H.UNSIGNED_BYTE&&n?o+4:o+1}var N1=new re;function UPe(e,t,n){let i=re.unpack(e,t,N1),o=re.unpackFloat(i);i=re.unpack(e,t+4,N1);let r=re.unpackFloat(i);i=re.unpack(e,t+8,N1);let s=re.unpackFloat(i);i=re.unpack(e,t+12,N1);let a=re.unpackFloat(i);return re.fromElements(o,r,s,a,n)}function DPe(e,t,n){let i=re.packFloat(e.x,N1);re.pack(i,t,n),i=re.packFloat(e.y,i),re.pack(i,t,n+4),i=re.packFloat(e.z,i),re.pack(i,t,n+8),i=re.packFloat(e.w,i),re.pack(i,t,n+12)}var Gae=new re;FA.prototype.getBatchedAttribute=function(e,t,n){let i=this._attributes,o=this._offsets[t],s=4*this._stride*e+4*o,a;this._packFloats&&i[t].componentDatatype!==Oe.UNSIGNED_BYTE?a=UPe(this._batchValues,s,Gae):a=re.unpack(this._batchValues,s,Gae);let c=Lae(i,t);return l(c.fromCartesian4)?c.fromCartesian4(a,n):l(c.clone)?c.clone(a,n):a.x};var kPe=[void 0,void 0,new M,new m,new re],QPe=new re;FA.prototype.setBatchedAttribute=function(e,t,n){let i=this._attributes,o=kPe[i[t].componentsPerAttribute],r=this.getBatchedAttribute(e,t,o),s=Lae(this._attributes,t);if(l(s.equals)?s.equals(r,n):r===n)return;let c=QPe;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 d=this._offsets[t],h=4*this._stride*e+4*d;this._packFloats&&i[t].componentDatatype!==Oe.UNSIGNED_BYTE?DPe(c,this._batchValues,h):re.pack(c,this._batchValues,h),this._batchValuesDirty=!0};function OPe(e,t){let n=e._textureDimensions;e._texture=new Lt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:e._pixelDatatype,width:n.x,height:n.y,sampler:Ht.NEAREST,flipY:!1})}function zPe(e){let t=e._textureDimensions;e._texture.copyFrom({source:{width:t.x,height:t.y,arrayBufferView:e._batchValues}})}FA.prototype.update=function(e){l(this._texture)&&!this._batchValuesDirty||this._attributes.length===0||(this._batchValuesDirty=!1,l(this._texture)||OPe(this,e.context),zPe(this))};FA.prototype.getUniformMapCallback=function(){let e=this;return function(t){return e._attributes.length===0?t:Ft(t,{batchTexture:function(){return e._texture},batchTextureDimensions:function(){return e._textureDimensions},batchTextureStep:function(){return e._textureStep}})}};function HPe(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 JPe(e){return e===1?"float":`vec${e}`}function KPe(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function jPe(e,t){let i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,s=JPe(o),a=KPe(o),c=e._offsets[t],d=`${s} ${r}(float batchId) { vec2 st = computeSt(batchId); st.x += batchTextureStep.x * float(${c}); `;return e._packFloats&&i.componentDatatype!==Oe.UNSIGNED_BYTE?d+=`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))); `:d+=` vec4 textureValue = texture(batchTexture, st); `,d+=` ${s} value = textureValue${a}; `,e._pixelDatatype===Oe.UNSIGNED_BYTE&&i.componentDatatype===H.UNSIGNED_BYTE&&!i.normalize?d+=`value *= 255.0; `:e._pixelDatatype===Oe.FLOAT&&i.componentDatatype===H.UNSIGNED_BYTE&&i.normalize&&(d+=`value /= 255.0; `),d+=` return value; } `,d}FA.prototype.getVertexShaderCallback=function(){let e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture; `;t+=`${HPe(this)}`;let n=e.length;for(let i=0;i<n;++i)t+=jPe(this,i);return function(i){let o=i.indexOf("void main"),r=i.substring(0,o),s=i.substring(o);return`${r}${t}${s}`}};FA.prototype.isDestroyed=function(){return!1};FA.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),he(this)};var wx=FA;var yin=y(x(),1);var oin=y(x(),1);function Ad(e){this._ellipsoid=e??ie.WGS84,this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(Ad.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});Ad.mercatorAngleToGeodeticLatitude=function(e){return L.PI_OVER_TWO-2*Math.atan(Math.exp(-e))};Ad.geodeticLatitudeToMercatorAngle=function(e){e>Ad.MaximumLatitude?e=Ad.MaximumLatitude:e<-Ad.MaximumLatitude&&(e=-Ad.MaximumLatitude);let t=Math.sin(e);return .5*Math.log((1+t)/(1-t))};Ad.MaximumLatitude=Ad.mercatorAngleToGeodeticLatitude(Math.PI);Ad.prototype.project=function(e,t){let n=this._semimajorAxis,i=e.longitude*n,o=Ad.geodeticLatitudeToMercatorAngle(e.latitude)*n,r=e.height;return l(t)?(t.x=i,t.y=o,t.z=r,t):new m(i,o,r)};Ad.prototype.unproject=function(e,t){let n=this._oneOverSemimajorAxis,i=e.x*n,o=Ad.mercatorAngleToGeodeticLatitude(e.y*n),r=e.z;return l(t)?(t.longitude=i,t.latitude=o,t.height=r,t):new Ae(i,o,r)};var pi=Ad;function qPe(e,t,n){let i=!n,o=e.length,r;if(!i&&o>1){let s=e[0].modelMatrix;for(r=1;r<o;++r)if(!F.equals(s,e[r].modelMatrix)){i=!0;break}}if(i)for(r=0;r<o;++r)l(e[r].geometry)&&zn.transformToWorldCoordinates(e[r]);else F.multiplyTransformation(t,e[0].modelMatrix,t)}function HH(e,t){let n=e.attributes,i=n.position,o=i.values.length/i.componentsPerAttribute;n.batchId=new we({componentDatatype:H.FLOAT,componentsPerAttribute:1,values:new Float32Array(o)});let r=n.batchId.values;for(let s=0;s<o;++s)r[s]=t}function $Pe(e){let t=e.length;for(let n=0;n<t;++n){let i=e[n];l(i.geometry)?HH(i.geometry,n):l(i.westHemisphereGeometry)&&l(i.eastHemisphereGeometry)&&(HH(i.westHemisphereGeometry,n),HH(i.eastHemisphereGeometry,n))}}function eXe(e){let t=e.instances,n=e.projection,i=e.elementIndexUintSupported,o=e.scene3DOnly,r=e.vertexCacheOptimize,s=e.compressVertices,a=e.modelMatrix,c,d,u,h=t.length;for(c=0;c<h;++c)if(l(t[c].geometry)){u=t[c].geometry.primitiveType;break}if(qPe(t,a,o),!o)for(c=0;c<h;++c)l(t[c].geometry)&&zn.splitLongitude(t[c]);if($Pe(t),r)for(c=0;c<h;++c){let A=t[c];l(A.geometry)?(zn.reorderForPostVertexCache(A.geometry),zn.reorderForPreVertexCache(A.geometry)):l(A.westHemisphereGeometry)&&l(A.eastHemisphereGeometry)&&(zn.reorderForPostVertexCache(A.westHemisphereGeometry),zn.reorderForPreVertexCache(A.westHemisphereGeometry),zn.reorderForPostVertexCache(A.eastHemisphereGeometry),zn.reorderForPreVertexCache(A.eastHemisphereGeometry))}let p=zn.combineInstances(t);for(h=p.length,c=0;c<h;++c){d=p[c];let A=d.attributes;if(o)for(let f in A)A.hasOwnProperty(f)&&A[f].componentDatatype===H.DOUBLE&&zn.encodeAttribute(d,f,`${f}3DHigh`,`${f}3DLow`);else for(let f in A)if(A.hasOwnProperty(f)&&A[f].componentDatatype===H.DOUBLE){let b=`${f}3D`,C=`${f}2D`;zn.projectTo2D(d,f,b,C,n),l(d.boundingSphere)&&f==="position"&&(d.boundingSphereCV=ue.fromVertices(d.attributes.position2D.values)),zn.encodeAttribute(d,b,`${b}High`,`${b}Low`),zn.encodeAttribute(d,C,`${C}High`,`${C}Low`)}s&&zn.compressVertices(d)}if(!i){let A=[];for(h=p.length,c=0;c<h;++c)d=p[c],A=A.concat(zn.fitToUnsignedShortIndices(d));p=A}return p}function JH(e,t,n,i){let o,r,s,a=i.length-1;if(a>=0){let d=i[a];o=d.offset+d.count,s=d.index,r=n[s].indices.length}else o=0,s=0,r=n[s].indices.length;let c=e.length;for(let d=0;d<c;++d){let h=e[d][t];if(!l(h))continue;let p=h.indices.length;o+p>r&&(o=0,r=n[++s].indices.length),i.push({index:s,offset:o,count:p}),o+=p}}function tXe(e,t){let n=[];return JH(e,"geometry",t,n),JH(e,"westHemisphereGeometry",t,n),JH(e,"eastHemisphereGeometry",t,n),n}var BA={};BA.combineGeometry=function(e){let t,n,i=e.instances,o=i.length,r,s,a=!1;o>0&&(t=eXe(e),t.length>0&&(n=zn.createAttributeLocations(t[0]),e.createPickOffsets&&(r=tXe(i,t))),l(i[0].attributes)&&l(i[0].attributes.offset)&&(s=new Array(o),a=!0));let c=new Array(o),d=new Array(o);for(let u=0;u<o;++u){let h=i[u],p=h.geometry;l(p)&&(c[u]=p.boun
`),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;`,s+=`${c}{ return u_modifiedModelView * position;}
`,t=t.replace(/czm_modelViewRelativeToEye\s+\*\s+/g,""),t=t.replace(/czm_modelViewProjectionRelativeToEye/g,"czm_projection")):n?s+=`${c}{ return czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow);}
`:(r+=`in vec3 ${a}2DHigh;in vec3 ${a}2DLow;`,s+=`${c}{ vec4 p; if (czm_morphTime == 1.0) { p = czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow); } else if (czm_morphTime == 0.0) { p = czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy); } else { p = czm_columbusViewMorph( czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy), czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow), czm_morphTime); } return p;}
`)}return[o,r,t,s].join(``)};Jr._appendShowToShader=function(e,t){return l(e._batchTableAttributeIndices.show)?`${ze.replaceMain(t,"czm_non_show_main")}void main() { czm_non_show_main(); gl_Position *= czm_batchTable_show(batchId); }`:t};Jr._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 Bae(e){return`${ze.replaceMain(e,"czm_non_pick_main")}out vec4 v_pickColor; void main() { czm_non_pick_main(); v_pickColor = czm_batchTable_pickColor(batchId); }`}function wae(e){return`in vec4 v_pickColor;${e}`}Jr._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};Jr._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};Jr._appendDistanceDisplayConditionToShader=function(e,t,n){if(!l(e._batchTableAttributeIndices.distanceDisplayCondition))return t;let i=ze.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 Nae(e,t){if(!e.compressVertices)return t;let n=t.search(/in\s+vec3\s+normal;/g)!==-1,i=t.search(/in\s+vec2\s+st;/g)!==-1;if(!n&&!i)return t;let o=t.search(/in\s+vec3\s+tangent;/g)!==-1,r=t.search(/in\s+vec3\s+bitangent;/g)!==-1,s=i&&n?2:1;s+=o||r?1:0;let a=s>1?`vec${s}`:"float",c="compressedAttributes",d=`in ${a} ${c};`,u="",h="";if(i){u+=`vec2 st;`;let f=s>1?`${c}.x`:c;h+=` st = czm_decompressTextureCoordinates(${f});`}n&&o&&r?(u+=`vec3 normal;vec3 tangent;vec3 bitangent;`,h+=` czm_octDecode(${c}.${i?"yz":"xy"}, normal, tangent, bitangent);`):(n&&(u+=`vec3 normal;`,h+=` normal = czm_octDecode(${c}${s>1?`.${i?"y":"x"}`:""});`),o&&(u+=`vec3 tangent;`,h+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"});`),r&&(u+=`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=ze.replaceMain(p,"czm_non_compressed_main");let A=`void main() { ${h} czm_non_compressed_main(); }`;return[d,u,p,A].join(``)}function AXe(e){let t=ze.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() { czm_non_depth_clamp_main(); gl_Position = czm_depthClamp(gl_Position);}`,t}function gXe(e){let t=ze.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 Pae(e,t){let n=e.vertexAttributes}function bXe(e,t){return function(){return e[t]}}var KH=Math.max(hn.hardwareConcurrency-1,1),jD,yXe=new $n("combineGeometry");function xXe(e,t){let n,i,o,r,s=e._instanceIds;if(e._state===Hr.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let a=e._numberOfInstances=n.length,c=[],d=[];for(o=0;o<a;++o)i=n[o].geometry,s.push(n[o].id),d.push({moduleName:i._workerName,modulePath:i._workerPath,geometry:i});if(!l(jD))for(jD=new Array(KH),o=0;o<KH;o++)jD[o]=new $n("createGeometry");let u;for(d=w1(d,KH),o=0;o<d.length;o++){let h=0,p=d[o],A=p.length;for(r=0;r<A;++r)u=p[r],i=u.geometry,l(i.constructor.pack)&&(u.offset=h,h+=i.constructor.packedLength??i.packedLength);let f;if(h>0){let b=new Float64Array(h);for(f=[b.buffer],r=0;r<A;++r)u=p[r],i=u.geometry,l(i.constructor.pack)&&(i.constructor.pack(i,b,u.offset),u.geometry=b)}c.push(jD[o].scheduleTask({subTasks:d[o]},f))}e._state=Hr.CREATING,Promise.all(c).then(function(h){e._createGeometryResults=h,e._state=Hr.CREATED}).catch(function(h){X1(e,t,Hr.FAILED,h)})}else if(e._state===Hr.CREATED){let a=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];let c=t.scene3DOnly,d=t.mapProjection,u=yXe.scheduleTask(Nx.packCombineGeometryParameters({createGeometryResults:e._createGeometryResults,instances:n,ellipsoid:d.ellipsoid,projection:d,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:c,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets},a),a);e._createGeometryResults=void 0,e._state=Hr.COMBINING,Promise.resolve(u).then(function(h){let p=Nx.unpackCombineGeometryResults(h);e._geometries=p.geometries,e._attributeLocations=p.attributeLocations,e.modelMatrix=F.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=Hr.COMBINED):X1(e,t,Hr.FAILED,void 0)}).catch(function(h){X1(e,t,Hr.FAILED,h)})}}function CXe(e,t){let n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,o=new Array(i),r=e._instanceIds,s,a,c=0;for(a=0;a<i;a++){s=n[a];let p=s.geometry,A;l(p.attributes)&&l(p.primitiveType)?A=hXe(p):A=p.constructor.createGeometry(p),o[c++]=fXe(s,A),r.push(s.id)}o.length=c;let d=t.scene3DOnly,u=t.mapProjection,h=Nx.combineGeometry({instances:o,ellipsoid:u.ellipsoid,projection:u,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:d,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets});e._geometries=h.geometries,e._attributeLocations=h.attributeLocations,e.modelMatrix=F.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=Hr.COMBINED):X1(e,t,Hr.FAILED,void 0)}function TXe(e,t){let n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!l(n)){e._recomputeBoundingSpheres=!1;return}let i,o=e._offsetInstanceExtend,r=e._instanceBoundingSpheres,s=r.length,a=e._tempBoundingSpheres;if(!l(a)){for(a=new Array(s),i=0;i<s;i++)a[i]=new ue;e._tempBoundingSpheres=a}for(i=0;i<s;++i){let b=a[i],C=e._batchTable.getBatchedAttribute(i,n,new m);b=r[i].clone(b),zae(b,C,o[i])}let c=[],d=[],u=[];for(i=0;i<s;++i){let b=a[i];b.center.x-b.radius>0||ue.intersectPlane(b,dn.ORIGIN_ZX_PLANE)!==qt.INTERSECTING?c.push(b):(d.push(b),u.push(b))}let h=c[0],p=u[0],A=d[0];for(i=1;i<c.length;i++)h=ue.union(h,c[i]);for(i=1;i<u.length;i++)p=ue.union(p,u[i]);for(i=1;i<d.length;i++)A=ue.union(A,d[i]);let f=[];for(l(h)&&f.push(h),l(p)&&f.push(p),l(A)&&f.push(A),i=0;i<f.length;i++){let b=f[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 fm(e,t,n){this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};let i=new qH;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;let o=new qH;if(o.requiresTextureCoordinates=e,n instanceof yn)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}fm.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 yn&&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 yn||(o=t.material.shaderSource),new ze({defines:i,sources:[o,IS]})};fm.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 ze({defines:n,sources:[IS],pickColorQualifier:"in"})};fm.prototype.createVertexShader=function(e,t,n,i){return tce(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};fm.prototype.createPickVertexShader=function(e,t,n,i){return tce(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};var Hae=new m,Jae=new Ae,Kae={high:0,low:0};function tce(e,t,n,i,o,r,s,a){let c=i.slice();if(a.eastMostYhighDefine===""){let d=Jae;d.longitude=L.PI,d.latitude=0,d.height=0;let u=s.project(d,Hae),h=In.encode(u.x,Kae);a.eastMostYhighDefine=`EAST_MOST_X_HIGH ${h.high.toFixed(`${h.high}`.length+1)}`,a.eastMostYlowDefine=`EAST_MOST_X_LOW ${h.low.toFixed(`${h.low}`.length+1)}`;let p=Jae;p.longitude=-L.PI,p.latitude=0,p.height=0;let A=s.project(p,Hae);h=In.encode(A.x,Kae),a.westMostYhighDefine=`WEST_MOST_X_HIGH ${h.high.toFixed(`${h.high}`.length+1)}`,a.westMostYlowDefine=`WEST_MOST_X_LOW ${h.low.toFixed(`${h.low}`.length+1)}`}return n&&(c.push(a.eastMostYhighDefine),c.push(a.eastMostYlowDefine),c.push(a.westMostYhighDefine),c.push(a.westMostYlowDefine)),l(r)&&r instanceof yn&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new ze({defines:c,sources:[o]})}function qH(){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(qH.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);`,s=t;s=s.replace(/in\s+vec3\s+extrudeDirection;/g,""),s=ze.replaceMain(s,"czm_non_compressed_main");let a=`void main() { ${r} czm_non_compressed_main(); }`;return[i,o,s,a].join(``)}}function nYe(e,t){let n=t.context,i=e._primitive,o=B1;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=Nn._appendDistanceDisplayConditionToShader(i,o),o=Nn._modifyShaderPosition(e,o,t.scene3DOnly),o=Nn._updateColorAttribute(i,o);let r=e._hasPlanarExtentsAttributes,s=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=tYe(i,o));let a=e._extruded?"EXTRUDED_GEOMETRY":"",c=new ze({defines:[a],sources:[o]}),d=new ze({sources:[i0]}),u=e._primitive._attributeLocations,h=new su(s,r,e.appearance);if(e._spStencil=tn.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:d,attributeLocations:u}),e._primitive.allowPicking){let f=ze.createPickVertexShaderSource(o);f=Nn._appendShowToShader(i,f),f=Nn._updatePickColorAttribute(f);let b=h.createPickFragmentShader(!1),C=h.createPickVertexShader([a],f,!1,t.mapProjection);if(e._spPick=tn.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:C,fragmentShaderSource:b,attributeLocations:u}),s){let T=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!l(T)){let E=h.createPickFragmentShader(!0),S=h.createPickVertexShader([a],f,!0,t.mapProjection);T=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:S,fragmentShaderSource:E,attributeLocations:u})}e._spPick2D=T}}else e._spPick=tn.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:d,attributeLocations:u});o=Nn._appendShowToShader(i,o),c=new ze({defines:[a],sources:[o]}),e._sp=tn.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:d,attributeLocations:u});let p=h.createFragmentShader(!1),A=h.createVertexShader([a],o,!1,t.mapProjection);if(e._spColor=tn.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:A,fragmentShaderSource:p,attributeLocations:u}),s){let f=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!l(f)){let b=h.createFragmentShader(!0),C=h.createVertexShader([a],o,!0,t.mapProjection);f=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:C,fragmentShaderSource:b,attributeLocations:u})}e._spColor2D=f}}function iYe(e,t){let n=e._primitive,i=n._va.length*2;t.length=i;let o,r,s,a=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap),d=e._needs2DShader;for(o=0;o<i;o+=2){let A=n._va[a++];r=t[o],l(r)||(r=t[o]=new ot({owner:e,primitiveType:n._primitiveType})),r.vertexArray=A,r.renderState=e._rsStencilDepthPass,r.shaderProgram=e._sp,r.uniformMap=c,r.pass=Ge.TERRAIN_CLASSIFICATION,s=ot.shallowClone(r,r.derivedCommands.tileset),s.renderState=e._rsStencilDepthPass3DTiles,s.pass=Ge.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,r=t[o+1],l(r)||(r=t[o+1]=new ot({owner:e,primitiveType:n._primitiveType})),r.vertexArray=A,r.renderState=e._rsColorPass,r.shaderProgram=e._spColor,r.pass=Ge.TERRAIN_CLASSIFICATION;let b=e.appearance.material;if(l(b)&&(c=Ft(c,b._uniforms)),r.uniformMap=c,s=ot.shallowClone(r,r.derivedCommands.tileset),s.pass=Ge.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,d){let C=ot.shallowClone(r,r.derivedCommands.appearance2D);C.shaderProgram=e._spColor2D,r.derivedCommands.appearance2D=C,C=ot.shallowClone(s,s.derivedCommands.appearance2D),C.shaderProgram=e._spColor2D,s.derivedCommands.appearance2D=C}}let u=e._commandsIgnoreShow,h=e._spStencil,p=0;i=u.length=i/2;for(let A=0;A<i;++A){let f=u[A]=ot.shallowClone(t[p],u[A]);f.shaderProgram=h,f.pass=Ge.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,p+=2}}function oYe(e,t){let n=e._usePickOffsets,i=e._primitive,o=i._va.length*2,r,s=0,a;n&&(r=i._pickOffsets,o=r.length*2),t.length=o;let c,d,u,h=0,p=i._batchTable.getUniformMapCallback()(e._uniformMap),A=e._needs2DShader;for(c=0;c<o;c+=2){let f=i._va[h++];if(n&&(a=r[s++],f=i._va[a.index]),d=t[c],l(d)||(d=t[c]=new ot({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),d.vertexArray=f,d.renderState=e._rsStencilDepthPass,d.shaderProgram=e._sp,d.uniformMap=p,d.pass=Ge.TERRAIN_CLASSIFICATION,n&&(d.offset=a.offset,d.count=a.count),u=ot.shallowClone(d,d.derivedCommands.tileset),u.renderState=e._rsStencilDepthPass3DTiles,u.pass=Ge.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 qsn=y(x(),1),D1=`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 ean=y(x(),1),k1=`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 nan=y(x(),1),Q1=`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 fan=y(x(),1);var oan=y(x(),1),O1=`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 san=y(x(),1),Zl=`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 AMe=`#define CLIP_POLYLINE ${Zl}${O1}`,gMe=Bx;function Mx(e){e=e??Q.EMPTY_OBJECT;let t=e.translucent??!0,n=!1,i=Mx.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??AMe,this._fragmentShaderSource=e.fragmentShaderSource??gMe,this._renderState=To.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Mx.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}}});Mx.VERTEX_FORMAT=ve.POSITION_ONLY;Mx.prototype.getFragmentShaderSource=To.prototype.getFragmentShaderSource;Mx.prototype.isTranslucent=To.prototype.isTranslucent;Mx.prototype.getRenderState=To.prototype.getRenderState;var Vs=Mx;var Ran=y(x(),1);var Aan=y(x(),1),z1=`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 ban=y(x(),1),vx=`#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 bMe=`#define CLIP_POLYLINE ${Zl}${z1}`,yMe=vx;function Ux(e){e=e??Q.EMPTY_OBJECT;let t=e.translucent??!0,n=!1,i=Ux.VERTEX_FORMAT;this.material=l(e.material)?e.material:Oi.fromType(Oi.ColorType),this.translucent=t,this._vertexShaderSource=e.vertexShaderSource??bMe,this._fragmentShaderSource=e.fragmentShaderSource??yMe,this._renderState=To.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Ux.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}}});Ux.VERTEX_FORMAT=ve.POSITION_AND_ST;Ux.prototype.getFragmentShaderSource=To.prototype.getFragmentShaderSource;Ux.prototype.isTranslucent=To.prototype.isTranslucent;Ux.prototype.getRenderState=To.prototype.getRenderState;var tc=Ux;function YA(e){e=e??Q.EMPTY_OBJECT,this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;l(t)||(t=new tc),this.appearance=t,this.show=e.show??!0,this.classificationType=e.classificationType??ti.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=Dce(!1),this._renderState3DTiles=Dce(!0),this._renderStateMorph=Qe.fromCache({cull:{enabled:!0,face:wi.FRONT},depthTest:{enabled:!0},blending:ln.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(YA.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}}});YA.initializeTerrainHeights=function(){return Gi.initialize()};function xMe(e,t,n){let i=t.context,o=e._primitive,r=o._attributeLocations,s=o._batchTable.getVertexShaderCallback()(Q1);s=Nn._appendShowToShader(o,s),s=Nn._appendDistanceDisplayConditionToShader(o,s),s=Nn._modifyShaderPosition(e,s,t.scene3DOnly);let a=o._batchTable.getVertexShaderCallback()(k1);a=Nn._appendShowToShader(o,a),a=Nn._appendDistanceDisplayConditionToShader(o,a),a=Nn._modifyShaderPosition(e,a,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(U1),d=[`GLOBE_MINIMUM_ALTITUDE ${t.mapProjection.ellipsoid.minimumRadius.toFixed(1)}`],u="",h="";l(n.material)?(h=l(n.material)?n.material.shaderSource:"",h.search(/in\s+float\s+v_polylineAngle;/g)!==-1&&d.push("ANGLE_VARYING"),h.search(/in\s+float\s+v_width;/g)!==-1&&d.push("WIDTH_VARYING")):u="PER_INSTANCE_COLOR",d.push(u);let p=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",u]:[u],A=new ze({defines:d,sources:[s]}),f=new ze({defines:p,sources:[h,c]});e._sp=tn.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:A,fragmentShaderSource:f,attributeLocations:r});let b=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!l(b)){let T=new ze({defines:d.concat(["COLUMBUS_VIEW_2D"]),sources:[s]});b=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:T,fragmentShaderSource:f,attributeLocations:r})}e._sp2D=b;let C=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!l(C)){let T=new ze({defines:d.concat([`MAX_TERRAIN_HEIGHT ${Gi._defaultMaxTerrainHeight.toFixed(1)}`]),sources:[a]});c=o._batchTable.getVertexShaderCallback()(D1);let E=new ze({defines:p,sources:[h,c]});C=i.shaderCache.createDerivedShaderProgram(e._sp,"MorphColor",{context:i,shaderProgram:e._spMorph,vertexShaderSource:T,fragmentShaderSource:E,attributeLocations:r})}e._spMorph=C}function Dce(e){return Qe.fromCache({cull:{enabled:!0},blending:ln.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1,stencilTest:{enabled:e,frontFunction:ni.EQUAL,frontOperation:{fail:Vt.KEEP,zFail:Vt.KEEP,zPass:Vt.KEEP},backFunction:ni.EQUAL,backOperation:{fa
`+_s),Ne&&rk([_,Z,G],pl=>{_s=pW(_s,pl," ")}),I&&Je?I.createHTML(_s):_s},t.setConfig=function(){let sn=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Di(sn),st=!0},t.clearConfig=function(){Ho=null,st=!1},t.isValidAttribute=function(sn,Ve,ut){Ho||Di({});let cn=Pn(sn),po=Pn(Ve);return zf(cn,po,ut)},t.addHook=function(sn,Ve){typeof Ve=="function"&&fW(g[sn],Ve)},t.removeHook=function(sn,Ve){if(Ve!==void 0){let ut=uve(g[sn],Ve);return ut===-1?void 0:mve(g[sn],ut,1)[0]}return nle(g[sn])},t.removeHooks=function(sn){g[sn]=[]},t.removeAllHooks=function(){g=cle()},t}var hle=mle();var Vve=0,_J={};function cp(e,t){let n,i=e;l(_J[i])?n=_J[i]:(n=Vve++,_J[i]=n),t=t??!1,this._id=n,this._html=e,this._showOnScreen=t,this._element=void 0}Object.defineProperties(cp.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=hle.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}}});cp.equals=function(e,t){return e===t||l(e)&&l(t)&&e._id===t._id&&e._showOnScreen===t._showOnScreen};cp.prototype.equals=function(e){return cp.equals(this,e)};cp.prototype.isIon=function(){return this.html.indexOf("ion-credit.png")!==-1};cp.getIonCredit=function(e){let t=l(e.collapsible)&&!e.collapsible;return new cp(e.html,t)};cp.clone=function(e){if(l(e))return new cp(e.html,e.showOnScreen)};var Et=cp;var _hn=y(x(),1);function Gve(e,t){_t(e,t)}var Va=Gve;var Dhn=y(x(),1);var Nhn=y(x(),1);function tC(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 xe}Object.defineProperties(tC.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}}});tC.isSupported=function(e){return(e.colorBufferHalfFloat&&e.halfFloatingPointTexture||e.floatingPointTexture&&e.colorBufferFloat)&&e.supportsTextureLod};function IJ(e){e._cubeMapBuffers=void 0}tC.prototype.update=function(e){let{context:t}=e;if(!tC.isSupported(t))return;if(l(this._texture)){IJ(this);return}if(!l(this._texture)&&!this._loading){let u=t.textureCache.getTexture(this._url);l(u)&&(IJ(this),this._texture=u,this._maximumMipmapLevel=this._texture.maximumMipmapLevel,this._ready=!0)}let n=this._cubeMapBuffers;if(!l(n)&&!this._loading){let u=this;md(this._url).then(function(h){u._cubeMapBuffers=h,u._loading=!1}).catch(function(h){u.isDestroyed()||u._errorEvent.raiseEvent(h)}),this._loading=!0}if(!l(this._cubeMapBuffers))return;let{pixelDatatype:i}=n[0].positiveX;l(i)||(i=t.halfFloatingPointTexture?Oe.HALF_FLOAT:Oe.FLOAT);let o=Ke.RGBA,r=n.length;this._maximumMipmapLevel=r-1;let s=n[0].positiveX.width,a=Math.log2(s)+1;if(r!==a){let u={};Object.values(Or.FaceName).forEach(h=>{u[h]=void 0});for(let h=r;h<a;h++)n.push(u)}let c=new Ht({minificationFilter:zt.LINEAR_MIPMAP_LINEAR}),d=new Or({context:t,source:n[0],flipY:!1,pixelDatatype:i,pixelFormat:o,sampler:c});d.loadMipmaps(n.slice(1)),this._texture=d,this._texture.maximumMipmapLevel=this._maximumMipmapLevel,t.textureCache.addTexture(this._url,this._texture),this._ready=!0};tC.prototype.isDestroyed=function(){return!1};tC.prototype.destroy=function(){return IJ(this),this._texture=this._texture&&this._texture.destroy(),he(this)};var wh=tC;function yW(e){e=e??Q.EMPTY_OBJECT;let t=l(e.imageBasedLightingFactor)?M.clone(e.imageBasedLightingFactor):new M(1,1);this._imageBasedLightingFactor=t;let n=e.sphericalHarmonicCoefficients;this._sphericalHarmonicCoefficients=n,this._specularEnvironmentMaps=e.specularEnvironmentMaps,this._specularEnvironmentCubeMap=void 0,this._specularEnvi
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)); } `}Do.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;let i=this;return function(o){let r=Ele(o,n,!1),s;return Bt.maximumVertexTextureImageUnits>0?(s="",e&&(s+=`uniform bool tile_translucentCommand; `),s+=`uniform sampler2D tile_batchTexture; out vec4 tile_featureColor; out vec2 tile_featureSt; void main() { vec2 st = computeSt(${t}); vec4 featureProperties = texture(tile_batchTexture, st); tile_color(featureProperties); float show = ceil(featureProperties.a); gl_Position *= show; `,e&&(s+=` bool isStyleTranslucent = (featureProperties.a != 1.0); if (czm_pass == czm_passTranslucent) { if (!isStyleTranslucent && !tile_translucentCommand) { gl_Position *= 0.0; } } else { if (isStyleTranslucent) { gl_Position *= 0.0; } } `),s+=` tile_featureColor = featureProperties; tile_featureSt = st; }`):s=`out vec2 tile_featureSt; void main() { tile_color(vec4(1.0)); tile_featureSt = computeSt(${t}); }`,`${r}${oUe(i)}${s}`}};function Cle(e,t){return e=ze.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 rUe(e,t){let n=`texture(${t}`,i=0,o=e.indexOf(n,i),r;for(;o>-1;){let s=0;for(let d=o;d<e.length;++d){let u=e.charAt(d);if(u==="(")++s;else if(u===")"&&(--s,s===0)){r=d+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 Ele(e,t,n){if(!l(t))return Cle(e,n);let i=new RegExp(`(uniform|attribute|in)\\s+(vec[34]|sampler2D)\\s+${t};`),o=e.match(i);if(!l(o))return Cle(e,n);let r=o[0],s=o[2];e=ze.replaceMain(e,"tile_main"),e=e.replace(r,"");let a=`bool isWhite(vec3 color) { return all(greaterThan(color, vec3(1.0 - czm_epsilon3))); } vec4 tile_diffuse_final(vec4 sourceDiffuse, vec4 tileDiffuse) { vec4 blendDiffuse = mix(sourceDiffuse, tileDiffuse, tile_colorBlend); vec4 diffuse = isWhite(tileDiffuse.rgb) ? sourceDiffuse : blendDiffuse; return vec4(diffuse.rgb, sourceDiffuse.a); } `,c=` tile_featureColor = czm_gammaCorrect(tile_featureColor); out_FragColor.a *= tile_featureColor.a; float highlight = ceil(tile_colorBlend); out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight); `,d;if(s==="vec3"||s==="vec4"){let u=s==="vec3"?`vec4(${t}, 1.0)`:t,h=s==="vec3"?"tile_diffuse.xyz":"tile_diffuse";i=new RegExp(t,"g"),e=e.replace(i,h),d=` vec4 source = ${u}; tile_diffuse = tile_diffuse_final(source, tile_featureColor); tile_main(); `}else s==="sampler2D"&&(e=rUe(e,t),d=` tile_diffuse = tile_featureColor; tile_main(); `);return e=`uniform float tile_colorBlend; vec4 tile_diffuse = vec4(1.0); ${a}${r}${e}void tile_color(vec4 tile_featureColor) { ${d}`,n&&(e+=c),e+=`} `,e}Do.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=Ele(i,t,!0),Bt.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 sUe(e){let t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n===yd.HIGHLIGHT)return 0;if(n===yd.REPLACE)return 1;if(n===yd.MIX)return L.clamp(i,L.EPSILON4,1)}Do.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;let e=this;return function(t){return Ft(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 sUe(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};Do.prototype.getPickId=function(){return"texture(tile_pickTexture, tile_featureSt)"};var l0={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};Do.prototype.addDerivedCommands=function(e,t){let n=e.commandList,i=n.length,o=this._content._tile,r=o._finalResolution,s=o.tileset,a=s.isSkippingLevelOfDetail&&s.hasMixedContent&&e.context.stencilBuffer,c=aUe(this);for(let d=t;d<i;++d){let u=n[d];if(u.pass===Ge.COMPUTE)continue;let h=u.derivedCommands.tileset;(!l(h)||u.dirty)&&(h={},u.derivedCommands.tileset=h,h.originalCommand=cUe(u),u.dirty=!1);let p=h.originalCommand;c!==l0.ALL_OPAQUE&&u.pass!==Ge.TRANSLUCENT&&(l(h.translucent)||(h.translucent=lUe(p))),c!==l0.ALL_TRANSLUCENT&&u.pass!==Ge.TRANSLUCENT&&(l(h.opaque)||(h.opaque=dUe(p)),a&&(r||(l(h.zback)||(h.zback=mUe(e.context,p)),s._backfaceCommands.push(h.zback)),(!l(h.stencil)||o._selectionDepth!==fUe(h.stencil))&&(u.renderState.depthMask?h.stencil=hUe(p,o._selectionDepth):h.stencil=h.opaque)));let A=a?h.stencil:h.opaque,f=h.translucent;u.pass!==Ge.TRANSLUCENT?(c===l0.ALL_OPAQUE&&(n[d]=A),c===l0.ALL_TRANSLUCENT&&(n[d]=f),c===l0.OPAQUE_AND_TRANSLUCENT&&(n[d]=A,n.push(f))):n[d]=p}};function aUe(e){let t=e._batchTexture.translucentFeaturesLength;return t===0?l0.ALL_OPAQUE:t===e.featuresLength?l0.ALL_TRANSLUCENT:l0.OPAQUE_AND_TRANSLUCENT}function cUe(e){let t=ot.shallowClone(e),n=t.pass===Ge.TRANSLUCENT;return t.uniformMap=l(t.uniformMap)?t.uniformMap:{},t.uniformMap.tile_translucentCommand=function(){return n},t}function lUe(e){let t=ot.shallowClone(e);return t.pass=Ge.TRANSLUCENT,t.renderState=pUe(e.renderState),t}function dUe(e){let t=ot.shallowClone(e);return t.renderState=AUe(e.renderState),t}function uUe(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 mUe(e,t){let n=ot.shallowClone(t),i=He(n.renderState,!0);i.cull.enabled=!0,i.cull.face=wi.FRONT,i.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i.polygonOffset={enabled:!0,factor:5,units:5},i.stencilTest=Jt.setCesium3DTileBit(),i.stencilMask=Jt.CESIUM_3D_TILE_MASK,n.renderState=Qe.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=He(t.uniformMap);let o=new M(5,5);return n.uniformMap.u_polygonOffset=function(){return o},n.shaderProgram=uUe(e,t.shaderProgram),n}function hUe(e,t){let n=ot.shallowClone(e),i=He(n.renderState,!0);return i.stencilTest.enabled=!0,i.stencilTest.mask=Jt.SKIP_LOD_MASK,i.stencilTest.reference=Jt.CESIUM_3D_TILE_MASK|t<<Jt.SKIP_LOD_BIT_SHIFT,i.stencilTest.frontFunction=ni.GREATER_OR_EQUAL,i.stencilTest.frontOperation.zPass=Vt.REPLACE,i.stencilTest.backFunction=ni.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=Vt.REPLACE,i.stencilMask=Jt.CESIUM_3D_TILE_MASK|Jt.SKIP_LOD_MASK,n.renderState=Qe.fromCache(i),n}function fUe(e){return(e.renderState.stencilTest.reference&Jt.SKIP_LOD_MASK)>>>Jt.SKIP_LOD_BIT_SHIFT}function pUe(e){let t=He(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=ln.ALPHA_BLEND,t.stencilTest=Jt.setCesium3DTileBit(),t.stencilMask=Jt.CESIUM_3D_TILE_MASK,Qe.fromCache(t)}function AUe(e){let t=He(e,!0);return t.stencilTest=Jt.setCesium3DTileBit(),t.stencilMask=Jt.CES
in float a_batchId;
uniform mat4 u_modifiedModelViewProjection;
void main(){ gl_Position = czm_depthClamp(u_modifiedModelViewProjection * vec4(position, 1.0));}`;var Mpn=y(x(),1);var LJ=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 s=t.tile,a=s.metadata;if(l(a)){if(a.hasPropertyBySemantic(i))return a.getPropertyBySemantic(i);if(a.hasProperty(i))return a.getProperty(i)}let c;if(l(s.implicitSubtree)&&(c=s.implicitSubtree.metadata),l(c)){if(c.hasPropertyBySemantic(i))return c.getPropertyBySemantic(i);if(c.hasProperty(i))return c.getProperty(i)}let d=l(t.group)?t.group.metadata:void 0;if(l(d)){if(d.hasPropertyBySemantic(i))return d.getPropertyBySemantic(i);if(d.hasProperty(i))return d.getProperty(i)}let u=t.tileset.metadata;if(l(u)){if(u.hasPropertyBySemantic(i))return u.getPropertyBySemantic(i);if(u.hasProperty(i))return u.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)}},Ga=LJ;var tAn=y(x(),1);var Upn=y(x(),1),WJ=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)})}},FJ=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)})}},xd=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
`;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 s=n.length;s<o;s++)n.push(null)}}else if(n.length!==o&&o!==0)this.throwError("Expected comma");else{let s=this.gobbleExpression();(!s||s.type===e.COMPOUND)&&this.throwError("Expected comma"),n.push(s)}}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)}}},bUe=new WJ;Object.assign(xd,{hooks:bUe,plugins:new FJ(xd),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"});xd.max_unop_len=xd.getMaxKeyLen(xd.unary_ops);xd.max_binop_len=xd.getMaxKeyLen(xd.binary_ops);var d0=e=>new xd(e).parse(),yUe=Object.getOwnPropertyNames(xd);yUe.forEach(e=>{d0[e]===void 0&&e!=="prototype"&&(d0[e]=xd[e])});d0.Jsep=xd;var xUe="ConditionalExpression",CUe={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:xUe,test:i,consequent:o,alternate:r},i.operator&&e.binary_ops[i.operator]<=.9){let s=i;for(;s.right.operator&&e.binary_ops[s.right.operator]<=.9;)s=s.right;n.node.test=s.right,s.right=n.node,n.node=i}}else this.throwError("Expected :")}})}};d0.plugins.register(CUe);var kpn=y(x(),1),TUe={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},Gt=Object.freeze(TUe);function Yh(e,t){this._expression=e,e=wUe(e,t),e=PUe(NUe(e)),d0.addBinaryOp("=~",0),d0.addBinaryOp("!~",0);let n;try{n=d0(e)}catch(i){throw new me(i)}this._runtimeAst=vi(this,n)}Object.defineProperties(Yh.prototype,{expression:{get:function(){return this._expression}}});var Dn={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new M],cartesian3Array:[new m],cartesian4Array:[new re],reset:function(){this.arrayIndex=0,this.cartesian2Index=0,this.cartesian3Index=0,this.cartesian4In
{ return ${o};}`,o};Yh.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};Yh.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};var EUe=["!","-","+"],Sle=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],SW=/\${(.*?)}/g,SUe=/\\/g,_Ue="@#%",IUe=/@#%/g,mk=new U,hk={abs:La(Math.abs),sqrt:La(Math.sqrt),cos:La(Math.cos),sin:La(Math.sin),tan:La(Math.tan),acos:La(Math.acos),asin:La(Math.asin),atan:La(Math.atan),radians:La(L.toRadians),degrees:La(L.toDegrees),sign:La(L.sign),floor:La(Math.floor),ceil:La(Math.ceil),round:La(Math.round),exp:La(Math.exp),exp2:La(RUe),log:La(Math.log),log2:La(VUe),fract:La(ZUe),length:GUe,normalize:LUe},fk={atan2:dk(Math.atan2,!1),pow:dk(Math.pow,!1),min:dk(Math.min,!0),max:dk(Math.max,!0),distance:WUe,dot:FUe,cross:BUe},NJ={clamp:_le(L.clamp,!0),mix:_le(L.lerp,!0)};function ZUe(e){return e-Math.floor(e)}function RUe(e){return Math.pow(2,e)}function VUe(e){return L.log2(e)}function La(e){return function(t,n){if(typeof n=="number")return e(n);if(n instanceof M)return M.fromElements(e(n.x),e(n.y),Dn.getCartesian2());if(n instanceof m)return m.fromElements(e(n.x),e(n.y),e(n.z),Dn.getCartesian3());if(n instanceof re)return re.fromElements(e(n.x),e(n.y),e(n.z),e(n.w),Dn.getCartesian4());throw new me(`Function "${t}" requires a vector or number argument. Argument is ${n}.`)}}function dk(e,t){return function(n,i,o){if(t&&typeof o=="number"){if(typeof i=="number")return e(i,o);if(i instanceof M)return M.fromElements(e(i.x,o),e(i.y,o),Dn.getCartesian2());if(i instanceof m)return m.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),Dn.getCartesian3());if(i instanceof re)return re.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),e(i.w,o),Dn.getCartesian4())}if(typeof i=="number"&&typeof o=="number")return e(i,o);if(i instanceof M&&o instanceof M)return M.fromElements(e(i.x,o.x),e(i.y,o.y),Dn.getCartesian2());if(i instanceof m&&o instanceof m)return m.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),Dn.getCartesian3());if(i instanceof re&&o instanceof re)return re.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),e(i.w,o.w),Dn.getCartesian4());throw new me(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i} and ${o}.`)}}function _le(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 M&&o instanceof M)return M.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),Dn.getCartesian2());if(i instanceof m&&o instanceof m)return m.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),Dn.getCartesian3());if(i instanceof re&&o instanceof re)return re.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r),e(i.w,o.w,r),Dn.getCartesian4())}if(typeof i=="number"&&typeof o=="number"&&typeof r=="number")return e(i,o,r);if(i instanceof M&&o instanceof M&&r instanceof M)return M.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),Dn.getCartesian2());if(i instanceof m&&o instanceof m&&r instanceof m)return m.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),Dn.getCartesian3());if(i instanceof re&&o instanceof re&&r instanceof re)return re.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z),e(i.w,o.w,r.w),Dn.getCartesian4());throw new me(`Function "${n}" requires vector or number arguments of matching types. Arguments are ${i}, ${o}, and ${r}.`)}}function GUe(e,t){if(typeof t=="number")return Math.abs(t);if(t instanceof M)return M.magnitude(t);if(t instanceof m)return m.magnitude(t);if(t instanceof re)return re.magnitude(t);throw new me(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function LUe(e,t){if(typeof t=="number")return 1;if(t instanceof M)return M.normalize(t,Dn.getCartesian2());if(t instanceof m)return m.normalize(t,Dn.getCartesian3());if(t instanceof re)return re.normalize(t,Dn.getCartesian4());throw new me(`Function "${e}" requires a vector or number argument. Argument is ${t}.`)}function WUe(e,t,n){if(typeof t=="number"&&typeof n=="number")return Math.abs(t-n);if(t instanceof M
{ czm_non_pick_main(); out_FragColor = ${o}; } `,e._spPick=tn.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:i});return}let a=n.getVertexShaderCallback(!1,"a_batchId",void 0)(NS),c=n.getFragmentShaderCallback(!1,void 0,!0)(i0);o=n.getPickId();let d=new ze({sources:[a]}),u=new ze({defines:["VECTOR_TILE"],sources:[c]});e._sp=tn.fromCache({context:t,vertexShaderSource:d,fragmentShaderSource:u,attributeLocations:i}),d=new ze({sources:[NS]}),u=new ze({defines:["VECTOR_TILE"],sources:[i0]}),e._spStencil=tn.fromCache({context:t,vertexShaderSource:d,fragmentShaderSource:u,attributeLocations:i}),c=ze.replaceMain(c,"czm_non_pick_main"),c=`${c}void main() { czm_non_pick_main(); out_FragColor = ${o}; } `;let h=new ze({sources:[a]}),p=new ze({defines:["VECTOR_TILE"],sources:[c]});e._spPick=tn.fromCache({context:t,vertexShaderSource:h,fragmentShaderSource:p,attributeLocations:i})}function Gle(e){let t=e?ni.EQUAL:ni.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:t,frontOperation:{fail:Vt.KEEP,zFail:Vt.DECREMENT_WRAP,zPass:Vt.KEEP},backFunction:t,backOperation:{fail:Vt.KEEP,zFail:Vt.INCREMENT_WRAP,zPass:Vt.KEEP},reference:Jt.CESIUM_3D_TILE_MASK,mask:Jt.CESIUM_3D_TILE_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:ec.LESS_OR_EQUAL},depthMask:!1}}var nDe={stencilTest:{enabled:!0,frontFunction:ni.NOT_EQUAL,frontOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},backFunction:ni.NOT_EQUAL,backOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},reference:0,mask:Jt.CLASSIFICATION_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:ln.PRE_MULTIPLIED_ALPHA_BLEND},iDe={stencilTest:{enabled:!0,frontFunction:ni.NOT_EQUAL,frontOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},backFunction:ni.NOT_EQUAL,backOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},reference:0,mask:Jt.CLASSIFICATION_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function oDe(e){l(e._rsStencilDepthPass)||(e._rsStencilDepthPass=Qe.fromCache(Gle(!1)),e._rsStencilDepthPass3DTiles=Qe.fromCache(Gle(!0)),e._rsColorPass=Qe.fromCache(nDe),e._rsPickPass=Qe.fromCache(iDe))}var sC=new F,Lle=new m;function rDe(e,t){if(l(e._uniformMap))return;let n={u_modifiedModelViewProjection:function(){let i=t.uniformState.view,o=t.uniformState.projection;return F.clone(i,sC),F.multiplyByPoint(sC,e._center,Lle),F.setTranslation(sC,Lle,sC),F.multiply(o,sC,sC),sC},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function PJ(e,t,n,i,o,r,s){let a=e.constructor.BYTES_PER_ELEMENT,c=r.length;for(let d=0;d<c;++d){let u=r[d],h=s[u],p=i[h],A=o[h],f=new e.constructor(e.buffer,a*p,A);t.set(f,n),i[h]=n,n+=A}return n}function sDe(e,t){let n=e._indices,i=e._indexOffsets,o=e._indexCounts,r=e._batchIdLookUp,s=new n.constructor(n.length),a=t.pop(),c=[a],d=PJ(n,s,0,i,o,a.batchIds,r);for(a.offset=0,a.count=d;t.length>0;){let u=t.pop();if(U.equals(u.color,a.color))d=PJ(n,s,d,i,o,u.batchIds,r),a.batchIds=a.batchIds.concat(u.batchIds),a.count=d-a.offset;else{let h=d;d=PJ(n,s,d,i,o,u.batchIds,r),u.offset=h,u.count=d-h,c.push(u),a=u}}e._va.indexBuffer.copyFromArrayView(s),e._indices=s,e._batchedIndices=c}function XJ(e,t,n,i,o,r,s){let a=e.bytesPerIndex,c=r.length;for(let d=0;d<c;++d){let u=r[d],h=s[u],p=i[h],A=o[h];t.copyFromBuffer(e,p*a,n*a,A*a),i[h]=n,n+=A}return n}function aDe(e,t){let n=e._indexOffsets,i=e._indexCounts,o=e._batchIdLookUp,r=t.pop(),s=[r],a=e._va.indexBuffer,c=e._vaSwap.indexBuffer,d=XJ(a,c,0,n,i,r.batchIds,o);for(r.offset=0,r.count=d;t.length>0;){let h=t.pop();if(U.equals(h.color,r.color))d=XJ(a,c,d,n,i,h.batchIds,o),r.batchIds=r.batchIds.concat(h.batchIds),r.count=d-r.offset;else{let p=d;d=XJ(a,c,d,n,i,h.batchIds,o),h.offset=p,h.count=d-p,s.push(h),r=h}}let u=e._va;e._va=e._vaSwap,e._vaSwap=u,e._batchedIndices=s}function cDe(e,t){return t.color.toRgba()-e.color.toRgba()}function lDe(e,t){if(!e._batchDirty)return!1;let n=e._batchedIndices,i=n.length,o=!1,r={};for(let s=0;s<i;++s){let c=n[s].color.toRgba();if(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(cDe),t.webgl2?aDe(e,n):sDe(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function dDe(e,t){let n=lDe(e,t),i=e._commands,o=e._batchedIndices,r=o.length,s=r*2;if(l(i)&&!n&&i.length===s)return;i.length=s;let a=e._va,c=e._sp,d=e._modelMatrix??F.IDENTITY,u=e._uniformMap,h=e._boundingVolume;for(let p=0;p<r;++p){let A=o[p].offset,f=o[p].count,b=i[p*2];l(b)||(b=i[p*2]=new ot({owner:e})),b.vertexArray=a,b.modelMatrix=d,b.offset=A,b.count=f,b.renderState=e._rsStencilDepthPass,b.sh
${n.message}`);let i=new me(t);return l(n)&&(i.stack=`Original stack:${n.stack}Handler stack:${i.stack}`),i}isDestroyed(){return!1}destroy(){return this.unload(),he(this)}},Hi=QJ;var Lbn=y(x(),1),Ake={UNLOADED:0,LOADING:1,LOADED:2,PROCESSING:3,READY:4,FAILED:5},yt=Object.freeze(Ake);var xk=class extends Hi{constructor(t){super(),t=t??Q.EMPTY_OBJECT;let n=t.typedArray,i=t.resource,o=t.cacheKey;this._typedArray=n,this._resource=i,this._cacheKey=o,this._state=yt.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=gke(this),this._promise)}static _fetchArrayBuffer(t){return t.fetchArrayBuffer()}unload(){this._typedArray=void 0}};async function gke(e){let t=e._resource;e._state=yt.LOADING;try{let n=await xk._fetchArrayBuffer(t);return e.isDestroyed()?void 0:(e._typedArray=new Uint8Array(n),e._state=yt.READY,e)}catch(n){if(e.isDestroyed())return;e._state=yt.FAILED;let i=`Failed to load external buffer: ${t.url}`;throw e.getError(i,n)}}var dC=xk;var c0n=y(x(),1);var Kbn=y(x(),1);var Mbn=y(x(),1),Xbn=(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;qofhoincdhQcbhwinaQaoawfRbbcb9hfhQawcefgwcz9hmbkclhCcbhwinaCaoawfRbbcd0fhCawcefgwcz9hmbkcwhYcbhwinaYaoawfRbbcP0fhYawcefgwcz9hmbkaQaCaQaC6EgwaYawaY6Egwczawcz6Ea8Afh8AaoczfhoaLczfgLaK6mbka8Ja8ABdbka8Kcefh8Ka8Lcefg8Lcl9hmbkagcefggaO9hmbka8Eamfh8Ea8Faxfh8Fa3amfh3aEaxfgEai6mbkcbhoceh
${n.message}`);let o=new me(i);return l(n)&&(o.stack=`Original stack:${n.stack}Handler stack:${o.stack}`),o};Hc.getNodeTransform=function(e){return l(e.matrix)?e.matrix:F.fromTranslationQuaternionRotationScale(l(e.translation)?e.translation:m.ZERO,l(e.rotation)?e.rotation:Me.IDENTITY,l(e.scale)?e.scale:m.ONE)};Hc.getAttributeBySemantic=function(e,t,n){let i=e.attributes,o=i.length;for(let r=0;r<o;++r){let s=i[r],a=l(n)?s.setIndex===n:!0;if(s.semantic===t&&a)return s}};Hc.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}};Hc.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}};Hc.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};Hc.getAttributeInfo=function(e){let t=e.semantic,n=e.setIndex,i,o=!1;l(t)?(i=ct.getVariableName(t,n),o=!0):(i=e.name,i=i.replace(/^_/,""),i=i.toLowerCase());let r=/^color_\d+$/.test(i),s=e.type,a=Ut.getGlslType(s);r&&(a="vec4");let c=l(e.quantization),d;return c&&(d=r?"vec4":Ut.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:o,glslType:a,quantizedGlslType:d}};var O9e=new m,z9e=new m;Hc.getPositionMinMax=function(e,t,n){let i=Hc.getAttributeBySemantic(e,"POSITION"),o=i.max,r=i.min;return l(n)&&l(t)&&(r=m.add(r,t,z9e),o=m.add(o,n,O9e)),{min:r,max:o}};Hc.getAxisCorrectionMatrix=function(e,t,n){return n=F.clone(F.IDENTITY,n),e===ro.Y?n=F.clone(ro.Y_UP_TO_Z_UP,n):e===ro.X&&(n=F.clone(ro.X_UP_TO_Z_UP,n)),t===ro.Z&&(n=F.multiplyTransformation(n,ro.Z_UP_TO_X_UP,n)),n};var H9e=new $;Hc.getCullFace=function(e,t){if(!We.isTriangles(t))return wi.BACK;let n=F.getMatrix3(e,H9e);return $.determinant(n)<0?wi.FRONT:wi.BACK};Hc.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^\d/.test(t)&&(t=`_${t}`),t};Hc.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};Hc.checkSupportedExtensions=function(e){let t=e.length;for(let n=0;n<t;n++){let i=e[n];if(!Hc.supportedExtensions[i])throw new me(`Unsupported glTF Extension: ${i}`)}};var It=Hc;var iK=class extends Hi{constructor(t){super(),t=t??Q.EMPTY_OBJECT;let n=t.resourceCache,i=t.gltfResource,o=t.baseResource,r=t.typedArray,s=t.gltfJson,a=t.cacheKey;this._resourceCache=n,this._gltfResource=i,this._baseResource=o,this._typedArray=r,this._gltfJson=s,this._cacheKey=a,this._gltf=void 0,this._bufferLoaders=[],this._state=yt.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=yt.LOADING,l(this._gltfJson)?(this._promise=hde(this,this._gltfJson),this._promise):l(this._typedArray)?(this._promise=fde(this,this._typedArray),this._promise):(this._promise=J9e(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 J9e(e){let t;try{let n=await e._fetchGltf();if(e.isDestroyed())return;t=new Uint8Array(n)}catch(n){if(e.isDestroyed())return;oK(e,n)}return fde(e,t)}function oK(e,t){e.unload(),e._state=yt.FAILED;let n=`Failed to load glTF: ${e._gltfResource.url}`;throw e.getError(n,t)}async function K9e(e,t){if(l(t.asset)&&t.asset.version==="2.
`,Ln&&(pn+=`var destructors = [];`);var Is=Ln?"destructors":"null",Kd="humanName throwBindingError invoker fn runDestructors fromRetWire toClassParamWire".split(" ");for(Wt&&(pn+=`var thisWired = toClassParamWire(${Is}, this);`),pt=0;pt<je;++pt){var Al=`toArg${pt}Wire`;pn+=`var arg${pt}Wired = ${Al}(${Is}, arg${pt});`,Kd.push(Al)}if(pn+=(Se||Zt?"var rv = ":"")+`invoker(${Jn});`,Ln)pn+=`runDestructors(destructors);`;else for(pt=Wt?1:2;pt<oe.length;++pt)Zt=pt===1?"thisWired":"arg"+(pt-2)+"Wired",oe[pt].V!==null&&(pn+=`${Zt}_dtor(${Zt});`,Kd.push(`${Zt}_dtor`));return Se&&(pn+=`var ret = fromRetWire(rv);return ret;`),oe=new Function(Kd,pn+`}`)(...Ze),At(ce,oe)}for(var Ca=ce=>{ce=ce.trim();let oe=ce.indexOf("(");return oe===-1?ce:ce.slice(0,oe)},Ss=[],Wr=[0,1,,1,null,1,!0,1,!1,1],Ta=ce=>{9<ce&&--Wr[ce+1]===0&&(Wr[ce]=void 0,Ss.push(ce))},zd=ce=>{if(!ce)throw new Ye(`Cannot use deleted val. handle = ${ce}`);return Wr[ce]},Hd=ce=>{switch(ce){case void 0:return 2;case null:return 4;case!0:return 6;case!1:return 8;default:let oe=Ss.pop()||Wr.length;return Wr[oe]=ce,Wr[oe+1]=1,oe}},Jd={name:"emscripten::val",N:ce=>{var oe=zd(ce);return Ta(ce),oe},T:(ce,oe)=>Hd(oe),X:Ce,V:null},ph=(ce,oe,Se)=>{switch(oe){case 1:return Se?function(Ze){return this.N(I[Ze])}:function(Ze){return this.N(R[Ze])};case 2:return Se?function(Ze){return this.N(V[Ze>>1])}:function(Ze){return this.N(W[Ze>>1])};case 4:return Se?function(Ze){return this.N(B[Ze>>2])}:function(Ze){return this.N(N[Ze>>2])};default:throw new TypeError(`invalid integer width (${oe}): ${ce}`)}},Ja=(ce,oe)=>{var Se=Fe[ce];if(Se===void 0)throw ce=`${oe} has unknown type ${Ho(ce)}`,new Ye(ce);return Se},Nb=(ce,oe)=>{switch(oe){case 4:return function(Se){return this.N(P[Se>>2])};case 8:return function(Se){return this.N(g[Se>>3])};default:throw new TypeError(`invalid float width (${oe}): ${ce}`)}},zf=Object.assign({optional:!0},Jd),Cr=(ce,oe,Se)=>{var Ze=R;if(!(0<Se))return 0;var je=oe;Se=oe+Se-1;for(var Zt=0;Zt<ce.length;++Zt){var pt=ce.codePointAt(Zt);if(127>=pt){if(oe>=Se)break;Ze[oe++]=pt}else if(2047>=pt){if(oe+1>=Se)break;Ze[oe++]=192|pt>>6,Ze[oe++]=128|pt&63}else if(65535>=pt){if(oe+2>=Se)break;Ze[oe++]=224|pt>>12,Ze[oe++]=128|pt>>6&63,Ze[oe++]=128|pt&63}else{if(oe+3>=Se)break;Ze[oe++]=240|pt>>18,Ze[oe++]=128|pt>>12&63,Ze[oe++]=128|pt>>6&63,Ze[oe++]=128|pt&63,Zt++}}return Ze[oe]=0,oe-je},ra=ce=>{for(var oe=0,Se=0;Se<ce.length;++Se){var Ze=ce.charCodeAt(Se);127>=Ze?oe++:2047>=Ze?oe+=2:55296<=Ze&&57343>=Ze?(oe+=4,++Se):oe+=3}return oe},sa=new TextDecoder,sn=(ce,oe,Se,Ze)=>{if(Se=oe+Se,Ze)return Se;for(;ce[oe]&&!(oe>=Se);)++oe;return oe},Ve=new TextDecoder("utf-16le"),ut=(ce,oe,Se)=>(ce>>=1,Ve.decode(W.subarray(ce,sn(W,ce,oe/2,Se)))),cn=(ce,oe,Se)=>{if(Se??(Se=2147483647),2>Se)return 0;Se-=2;var Ze=oe;Se=Se<2*ce.length?Se/2:ce.length;for(var je=0;je<Se;++je)V[oe>>1]=ce.charCodeAt(je),oe+=2;return V[oe>>1]=0,oe-Ze},po=ce=>2*ce.length,vs=(ce,oe,Se)=>{var Ze="";ce>>=2;for(var je=0;!(je>=oe/4);je++){var Zt=N[ce+je];if(!Zt&&!Se)break;Ze+=String.fromCodePoint(Zt)}return Ze},mo=(ce,oe,Se)=>{if(Se??(Se=2147483647),4>Se)return 0;var Ze=oe;Se=Ze+Se-4;for(var je=0;je<ce.length;++je){var Zt=ce.codePointAt(je);if(65535<Zt&&je++,B[oe>>2]=Zt,oe+=4,oe+4>Se)break}return B[oe>>2]=0,oe-Ze},_s=ce=>{for(var oe=0,Se=0;Se<ce.length;++Se)65535<ce.codePointAt(Se)&&Se++,oe+=4;return oe},pl=[],Pb=ce=>{var oe=pl.length;return pl.push(ce),oe},yR=(ce,oe)=>{for(var Se=Array(ce),Ze=0;Ze<ce;++Ze)Se[Ze]=Ja(N[oe+4*Ze>>2],`parameter ${Ze}`);return Se},Ea=(ce,oe,Se)=>{var Ze=[];return ce=ce(Ze,Se),Ze.length&&(N[oe>>2]=Hd(Ze)),ce},MU={},vU=ce=>{var oe=MU[ce];return oe===void 0?st(ce):oe},Qz={},fie=()=>{if(!Oz){var ce={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"},oe;for(oe in Qz)Qz[oe]===void 0?delete ce[oe]:ce[oe]=Qz[oe];var Se=[];for(oe in ce)Se.push(`${oe}=${ce[oe]}`);Oz=Se}return Oz},Oz,pGe=[null,[],[]],pA=new Uint8Array(123),Xb=25;0<=Xb;--Xb)pA[48+Xb]=52+Xb,pA[65+Xb]=Xb,pA[97+Xb]=26+Xb;pA[43]=62,pA[47]=63,(()=>{let ce=jt.prototype;Object.assign(ce,{isAliasOf:function(Se){if(!(this instanceof jt&&Se instanceof jt))return!1;var Ze=this.L.P.M,je=this.L.O;Se.L=Se.L;var Zt=Se.L.P.M;for(Se=Se.L.O;Ze.U;)je=Ze.ea(je),Ze=Ze.U;for(;Zt.U;)Se=Zt.ea(Se),Zt=Zt.U;return Ze===Zt&&je===Se},clone:function(){if(this.L.O||ht(this),this.L.da)return this.L.count.value+=1,this;var Se=Re,Ze=Object,je=Ze.create,Zt=Object.getPrototypeOf(this),pt=this.L;return Se=Se(je.call(Ze,Zt,{L:{value:{count:pt.count,ba:pt.ba,da:pt.da,O:pt.O,P:pt.P,S:pt.S,W:pt.W}}})),Se.L.count.value+=1,Se.L.ba=!1,Se},delete(){if(this.L.O||ht(this),this.L.ba&&!this.L.da)t
${Wt} }`,Se=new Function(Object.keys(pt),Wt)(...Object.values(pt)),Wt=`methodCaller<(${je.map(Ln=>Ln.name)}) => ${Ze.name}>`,Pb(At(Wt,Se))},E:Ta,o:(ce,oe,Se,Ze,je)=>pl[ce](oe,Se,Ze,je),D:ce=>{var oe=zd(ce);ae(oe),Ta(ce)},s:(ce,oe,Se,Ze)=>{var je=new Date().getFullYear(),Zt=new Date(je,0,1).getTimezoneOffset();je=new Date(je,6,1).getTimezoneOffset(),N[ce>>2]=60*Math.max(Zt,je),B[oe>>2]=+(Zt!=je),oe=pt=>{var Wt=Math.abs(pt);return`UTC${0<=pt?"-":"+"}${String(Math.floor(Wt/60)).padStart(2,"0")}${String(Wt%60).padStart(2,"0")}`},ce=oe(Zt),oe=oe(je),je<Zt?(Cr(ce,Se,17),Cr(oe,Ze,17)):(Cr(ce,Ze,17),Cr(oe,Se,17))},y:ce=>{var oe=R.length;if(ce>>>=0,2147483648<ce)return!1;for(var Se=1;4>=Se;Se*=2){var Ze=oe*(1+.2/Se);Ze=Math.min(Ze,ce+100663296);e:{Ze=(Math.min(2147483648,65536*Math.ceil(Math.max(ce,Ze)/65536))-S.buffer.byteLength+65535)/65536|0;try{S.grow(Ze),w();var je=1;break e}catch{}je=void 0}if(je)return!0}return!1},t:(ce,oe)=>{var Se=0,Ze=0,je;for(je of fie()){var Zt=oe+Se;N[ce+Ze>>2]=Zt,Se+=Cr(je,Zt,1/0)+1,Ze+=4}return 0},u:(ce,oe)=>{var Se=fie();N[ce>>2]=Se.length,ce=0;for(var Ze of Se)ce+=ra(Ze)+1;return N[oe>>2]=ce,0},v:()=>52,w:function(){return 70},k:(ce,oe,Se,Ze)=>{for(var je=0,Zt=0;Zt<Se;Zt++){var pt=N[oe>>2],Wt=N[oe+4>>2];oe+=8;for(var Ln=0;Ln<Wt;Ln++){var Jn=ce,pn=R[pt+Ln],Is=pGe[Jn];pn===0||pn===10?(Jn=Jn===1?p:A,pn=sn(Is,0),pn=sa.decode(Is.buffer?Is.subarray(0,pn):new Uint8Array(Is.slice(0,pn))),Jn(pn),Is.length=0):Is.push(pn)}je+=Wt}return N[Ze>>2]=je,0}},KE=await(async function(){var ce;function oe(Ze){var je;return KE=Ze.exports,S=KE.F,w(),Sn=KE.H,Ze=KE,pie=Ze.I,i._malloc=zz=Ze.J,i._free=Yb=Ze.K,X--,(je=i.monitorRunDependencies)==null||je.call(i,X),X==0&&k&&(Ze=k,k=null,Ze()),KE}X++,(ce=i.monitorRunDependencies)==null||ce.call(i,X);var Se={a:AGe};return i.instantiateWasm?new Promise(Ze=>{i.instantiateWasm(Se,(je,Zt)=>{Ze(oe(je))})}):(D??(D=ge("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 Ws(e){e=e??Q.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 xe,this.polygonRemoved=new xe,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(Ws.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}}});Ws.prototype.add=function(e){let t=this._polygons.length;return this._polygons.push(e),this.polygonAdded.raiseEvent(e,t),e};Ws.prototype.get=function(e){return this._polygons[e]};Ws.prototype.contains=function(e){return this._polygons.some(t=>a_.equals(t,e))};Ws.prototype.remove=function(e){let t=this._polygons,n=t.findIndex(i=>a_.equals(i,e));return n===-1?!1:(t.splice(n,1),this.polygonRemoved.raiseEvent(e,n),!0)};function VOe(e,t,n){let i=Math.max(e.height*t,0),o=Math.max(e.width*t,0),r=de.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 GOe(e,t){let i=[],o=e.length;for(let a=0;a<o;++a){let c=VOe(t[a],2.5),d=-1;for(let u=0;u<i.length;++u)if(l(de.simpleIntersection(i[u].extent,c))){d=u;break}if(d===-1)i.push({extent:c,polygonIndices:[a]});else{let u=i[d];u.polygonIndices.push(a),de.union(u.extent,c,u.extent);for(let h=0;h<i.length;++h)h!==d&&l(de.simpleIntersection(i[h].extent,u.extent))&&(u.polygonIndices.push(...i[h].polygonIndices),de.union(u.extent,i[h].extent,u.extent),i.splice(h,1),h<d&&d--,h=-1)}}let r=i.map(a=>a.extent),s=new Map;return i.forEach((a,c)=>a.polygonIndices.forEach(d=>s.set(d,c))),{extentsList:r,extentsIndexByPolygon:s}}Ws.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 LOe(e){let t=e._float32View,n=e._extentsFloat32View,i=e._polygons,o=i.map(u=>u.computeSphericalExtents()),{extentsList:r,extentsIndexByPolygon:s}=GOe(i,o),a=Array.from(i.keys()).sort((u,h)=>s.get(u)-s.get(h)),c=0;for(let u of a){let h=i[u],p=h.length;t[c++]=p,t[c++]=s.get(u);let A=o[u];t[c++]=A.south,t[c++]=A.west,t[c++]=A.north-A.south,t[c++]=A.east-A.west;for(let f=0;f<p;++f){let b=h.positions[f],C=Math.hypot(b.x,b.y),T=L.fastApproximateAtan2(C,b.z),E=L.fastApproximateAtan2(b.x,b.y);t[c++]=T,t[c++]=E}}let d=0;for(let u of r){let h=1/(u.east-u.west),p=1/(u.north-u.south);n[d++]=u.south,n[d++]=u.west,n[d++]=p,n[d++]=h}e._extentsCount=r.length}var HK=new M;Ws.prototype.update=function(e){let t=e.context;if(!Ws.isSupported(e))throw new me("ClippingPolygonCollections are only supported for WebGL 2.");this.debugShowDistanceTexture&&l(this._signedDistanceTexture)&&(l(this.debugCommand)||(this.debugCommand=WOe(this._signedDistanceTexture,e.context)),e.commandList.push(this.debugCommand));let n=this._polygons.reduce((s,a)=>s+a.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 s=i.width*i.height;(s<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=Ge.OVERLAY,i}Ws.prototype.queueCommands=function(e){l(this._signedDistanceComputeCommand)&&e.commandList.push(this._signedDistanceComputeCommand)};function FOe(e){let t=e._polygonsTexture,n=e._extentsTexture;return new yl({fragmentShaderSource:jW,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 mue=new de,BOe=new de,wOe=new de;Ws.prototype.computeIntersectionWithBoundingVolume=function(e,t){let n=this._polygons,i=n.length,o=qt.OUTSIDE;this.inverse&&(o=qt.INSIDE);let r=e.rectangle;if(!l(r)&&l(e.boundingVolume?.computeCorners)){let s=e.boundingVolume.computeCorners();r=de.fromCartesianArray(s,t,mue)}l(r)||(r=de.fromBoundingSphere(e.boundingSphere,t,mue));for(let s=0;s<i;++s){let c=n[s].computeRectangle(wOe),d=de.simpleIntersection(r,c,BOe);if(l(d))return qt.INTERSECTING}return o};Ws.setOwner=function(e,t,n){e!==t[n]&&(t[n]=t[n]&&t[n].destroy(),l(e)&&(e._owner=t,t[n]=e))};Ws.isSupported=function(e){return e?.context.webgl2};Ws.getTextureResolution=function(e,t,n){if(l(e))return n.x=e.width,n.y=e.height,n;let i=Bt.maximumTextureSize;return n.x=Math.min(t,i),n.y=Math.ceil(t/n.x),n.y*=2,n};Ws.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(Bt.maximumTextureSize,o),t.y=Math.min(Bt.maximumTextureSize,o),t};Ws.getClippingExtentsTextureResolution=function(e,t){let n=e.extentsTexture;return l(n)?(t.x=n.width,t.y=n.height,t):Ws.getTextureResolution(n,e.pixelsNeededForExtents,t)};Ws.prototype.isDestroyed=function(){return!1};Ws.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(),he(this)};var Uh=Ws;var CRn=y(x(),1);var BZn=y(x(),1);var VZn=y(x(),1),qW={NONE:0,SCENE_LIGHT:1,SUNLIGHT:2};qW.fromGlobeFlags=function(e){return e.enableLighting&&e.dynamicAtmosphereLighting?e.dynamicAtmosphereLightingFromSun?qW.SUNLIGHT:qW.SCENE_LIGHT:qW.NONE};var og=Object.freeze(qW);function hue(){this.lightIntensity=10,this.rayleighCoefficient=new m(55e-7,13e-6,284e-7),this.mieCoefficient=new m(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=og.NONE}hue.requiresColorCorrect=function(e){return!(L.equalsEpsilon(e.hueShift,0,L.EPSILON7)&&L.equalsEpsilon(e.saturationShift,0,L.EPSILON7)&&L.equalsEpsilon(e.brightnessShift,0,L.EPSILON7))};var CC=hue;var NZn=y(x(),1),Dh=`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 XZn=y(x(),1),$W=`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 MZn=y(x(),1),eF=`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 UZn=y(x(),1),tF=`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 kZn=y(x(),1),nF=`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 bi(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??Q.EMPTY_OBJECT;let t=Math.max(Math.floor(Math.min(e.mipmapLevels??7,Math.log2(Bt.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=bi.DEFAULT_SPHERICAL_HARMONIC_COEFFICIENTS.slice(),this._lastTime=new q;let i=Math.max(Math.pow(2,t-1),1);this._textureDimensions=new M(i,i),this._radiiAndDynamicAtmosphereColor=new m,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??bi.AVERAGE_EARTH_GROUND_COLOR,this.groundAlbedo=e.groundAlbedo??.31}Object.defineProperties(bi.prototype,{owner:{get:function(){return this._owner}},shouldRegenerateShaders:{get:function(){return this._shouldRegenerateShaders}},position:{get:function(){return this._position},set:function(e){m.equalsEpsilon(e,this._position,0,this.maximumPositionEpsilon)||(this._position=m.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}}});bi._maximumComputeCommandCount=8;bi._activeComputeCommandCount=0;bi._nextFrameCommandQueue=[];bi._queueCommand=(e,t)=>{if(bi._activeComputeCommandCount>=bi._maximumComputeCommandCount){bi._nextFrameCommandQueue.push(e);return}t.commandList.push(e),bi._activeComputeCommandCount++};bi._updateCommandQueue=e=>{if(bi._maximumComputeCommandCount=Math.log2(Bt.maximumCubeMapSize),bi._nextFrameCommandQueue.length>0&&bi._activeComputeCommandCount<bi._maximumComputeCommandCount){let t=bi._nextFrameCommandQueue.shift();for(;l(t)&&bi._activeComputeCommandCount<bi._maximumComputeCommandCount;){if(t.owner.isDestroyed()||t.canceled){t=bi._nextFrameCommandQueue.shift();continue}e.commandList.push(t),bi._activeComputeCommandCount++,t=bi._nextFrameCommandQueue.shift()}l(t)&&bi._nextFrameCommandQueue.push(t)}};bi.setOwner=function(e,t,n){e!==t[n]&&(t[n]=t[n]&&t[n].destroy(),l(e)&&(e._owner=t,t[n]=e))};bi.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 NOe=new m,POe=new m;function XOe(e,t){let n=e._position,i=t.atmosphere,o=t.mapProjection.ellipsoid,r=o.scaleToGeodeticSurface(n,POe),s=1.025,a=NOe,c=l(r)?m.magnitude(r):o.maximumRadius;return a.x=c*s,a.y=c,a.z=i.dynamicLighting,!m.equalsEpsilon(e._radiiAndDynamicAtmosphereColor,a)||t.environmentMap!==e._sceneEnvironmentMap||t.backgroundColor!==e._backgroundColor?(m.clone(a,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 m_(){this._framebuffer=new Ti({colorAttachmentsLength:2,depth:!0,supportsDepthTexture:!0}),this._drawCommand=void 0,this._clearCommand=void 0,this._strength=1,this._radius=1}Object.defineProperties(m_.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 THe(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}var rj=new M;function EHe(e,t){let n=new ze({defines:["LOG_DEPTH_WRITE"],sources:[TF]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return rj.x=e._radius,rj.y=e._strength,rj}},o=Qe.fromCache({blending:ln.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:Jt.setCesium3DTileBit(),stencilMask:Jt.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:o,pass:Ge.CESIUM_3D_TILE,owner:e}),e._clearCommand=new mi({framebuffer:e.framebuffer,color:new U(0,0,0,0),depth:1,renderState:Qe.fromCache(),pass:Ge.CESIUM_3D_TILE,owner:e})}function SHe(e,t){let n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),EHe(e,t)}function Oue(e){return e.drawBuffers&&e.fragmentDepth}m_.isSupported=Oue;function _He(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=ze.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}m_.prototype.update=function(e,t,n,i){if(!Oue(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,SHe(this,e.context);let o,r=e.commandList,s=r.length;for(o=t;o<s;++o){let d=r[o];if(d.primitiveType!==We.POINTS||d.pass===Ge.TRANSLUCENT)continue;let u,h,p=d.derivedCommands.pointCloudProcessor;l(p)&&(u=p.command,h=p.originalShaderProgram),(!l(u)||d.dirty||h!==d.shaderProgram||u.framebuffer!==this.framebuffer)&&(u=ot.shallowClone(d,u),u.framebuffer=this.framebuffer,u.shaderProgram=_He(e.context,d.shaderProgram),u.castShadows=!1,u.receiveShadows=!1,l(p)||(p={command:u,originalShaderProgram:d.shaderProgram},d.derivedCommands.pointCloudProcessor=p),p.originalShaderProgram=d.shaderProgram),r[o]=u}let a=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,r.push(c),r.push(a)};m_.prototype.isDestroyed=function(){return!1};m_.prototype.destroy=function(){return THe(this),he(this)};var cg=m_;function zue(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}zue.isSupported=function(e){return cg.isSupported(e.context)};var gp=zue;var F1n=y(x(),1);var Rc={},IHe=new re(0,0,0,1),$c=new re,ZHe=new nt,sj=new M,aj=new M;Rc.worldToWindowCoordinates=function(e,t,n){return Rc.worldWithEyeOffsetToWindowCoordinates(e,t,m.ZERO,n)};var Hue=new re,Jue=new m;function EF(e,t,n,i){let o=n.viewMatrix,r=F.multiplyByVector(o,re.fromElements(e.x,e.y,e.z,1,Hue),Hue),s=m.multiplyComponents(t,m.normalize(r,Jue),Jue);return r.x+=t.x+s.x,r.y+=t.y+s.y,r.z+=s.z,F.multiplyByVector(n.frustum.projectionMatrix,r,i)}var RHe=new Ae(Math.PI,L.PI_OVER_TWO),VHe=new m,GHe=new m;Rc.worldWithEyeOffsetToWindowCoordinates=function(e,t,n,i){let o=e.frameState,r=Rc.computeActualEllipsoidPosition(o,t,IHe);if(!l(r))return;let s=e.canvas,a=ZHe;a.x=0,a.y=0,a.width=s.clientWidth,a.height=s.clientHeight;let c=e.camera,d=!1;if(o.mode===se.SCENE2D){let u=e.mapProjection,h=RHe,p=u.project(h,VHe),A=m.clone(c.position,GHe),f=c.frustum.clone(),b=F.computeViewportTransformation(a,0,1,new F),C=c.frustum.projectionMatrix,T=c.positionWC.y,E=m.fromElements(L.sign(T)*p.x-T,0,-c.positionWC.x),S=bt.pointToGLWindowCoordinates(C,b,E);if(T===0||S.x<=0||S.x>=s.clientWidth)d=!0;else{if(S.x>s.clientWidth*.5){a.width=S.x,c.frustum.right=p.x-T,$c=EF(r,n,c,$c),Rc.clipToGLWindowCoordinates(a,$c,sj),a.x+=S.x,c.position.x=-c.position.x;let I=c.frustum.right;c.frustum.right=-c.frustum.left,c.frustum.left=-I,$c=EF(r,n,c,$c),Rc.clipToGLWindowCoordinates(a,$c,aj)}else{a.x+=S.x,a.width-=S.x,c.frustum.left=-p.x-T,$c=EF(r,n,c,$c),Rc.clipToGLWindowCoordinates(a,$c,sj),a.x=a.x-a.width,c.position.x=-c.position.x;let I=c.frustum.left;c.frustum.left=-c.frustum.right,c.frustum.right=-I,$c=EF(r,n,c,$c),Rc.clipToGLWindowCoordinates(a,$c,aj)}m.clone(A,c.position),c.frustum=f.clone(),i=M.clone(sj,i),(i.x<0||i.x>s.clientWidth)&&(i.x=aj.x)}}if(o.mode!==se.SCENE2D||d){if($c=EF(r,n,c,$c),$c.z<0&&!(c.frustum instanceof bn)&&!(c.frustum instanceof as))return;i=Rc.clipToGLWindowCoordinates(a,$c,i)}return i.y=s.clientHeight-i.y,i};Rc.worldToDrawingBufferCoordinates=function(e,t,n){if(n=Rc.worldToWindowCoordinates(e,t,n),!!l(n))return Rc.transformWindowToDrawingBuffer(e,n,n)};var lg=new m,LHe=new Ae;Rc.computeActualEllipsoidPosition=function(e,t,n){let i=e.mode;if(i===se.SCENE3D)return m.clone(t,n);let o=e.mapProjection,r=o.ellipsoid.cartesianToCartographic(t,LHe);if(!l(r))return;if(o.project(r,lg),i===se.COLUMBUS_VIEW)return m.fromElements(lg.z,lg.x,lg.y,n);if(i===se.SCENE2D)return m.fromElements(0,lg.x,lg.y,n);let s=e.morphTime;return m.fromElements(L.lerp(lg.z,t.x
// 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 CBn=y(x(),1),UF=`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 fme={name:"AtmospherePipelineStage"};fme.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_ATMOSPHERE",void 0,pe.BOTH),i.addDefine("COMPUTE_POSITION_WC_ATMOSPHERE",void 0,pe.BOTH),i.addVarying("vec3","v_atmosphereRayleighColor"),i.addVarying("vec3","v_atmosphereMieColor"),i.addVarying("float","v_atmosphereOpacity"),i.addVertexLines([UF]),i.addFragmentLines([vF]),i.addUniform("bool","u_isInFog",pe.FRAGMENT),e.uniformMap.u_isInFog=function(){let o=m.distance(n.camera.positionWC,t.boundingSphere.center);return L.fog(o,n.fog.density)>L.EPSILON3}};var DF=fme;var XBn=y(x(),1);var GBn=y(x(),1),kF=`#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 pme={name:"ImageBasedLightingPipelineStage"},SJe=new M;pme.process=function(e,t,n){let i=t.imageBasedLighting,o=t.environmentMapManager,r=e.shaderBuilder,s;l(i.specularEnvironmentMaps)||(s=o.radianceCubeMap);let a=i.sphericalHarmonicCoefficients??o.sphericalHarmonicCoefficients;r.addDefine("USE_IBL_LIGHTING",void 0,pe.FRAGMENT),r.addUniform("vec2","model_iblFactor",pe.FRAGMENT),wh.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&r.addUniform("mat3","model_iblReferenceFrameMatrix",pe.FRAGMENT),l(s)&&r.addDefine("COMPUTE_POSITION_WC_ATMOSPHERE",void 0,pe.BOTH),l(a)&&l(a[0])?(r.addDefine("DIFFUSE_IBL",void 0,pe.FRAGMENT),r.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,pe.FRAGMENT),r.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",pe.FRAGMENT)):i.useDefaultSphericalHarmonics&&r.addDefine("DIFFUSE_IBL",void 0,pe.FRAGMENT),l(i.specularEnvironmentCubeMap)&&i.specularEnvironmentCubeMap.ready||l(s)?(r.addDefine("SPECULAR_IBL",void 0,pe.FRAGMENT),r.addDefine("CUSTOM_SPECULAR_IBL",void 0,pe.FRAGMENT),r.addUniform("samplerCube","model_specularEnvironmentMaps",pe.FRAGMENT),r.addUniform("float","model_specularEnvironmentMapsMaximumLOD",pe.FRAGMENT)):t.useDefaultSpecularMaps&&r.addDefine("SPECULAR_IBL",void 0,pe.FRAGMENT)),r.addFragmentLines(kF);let c={model_iblFactor:function(){return M.multiplyByScalar(i.imageBasedLightingFactor,o?.intensity||1,SJe)},model_iblReferenceFrameMatrix:function(){return t._iblReferenceFrameMatrix},model_sphericalHarmonicCoefficients:function(){return a},model_specularEnvironmentMaps:function(){return i.specularEnvironmentCubeMap.texture},model_specularEnvironmentMapsMaximumLOD:function(){return i.specularEnvironmentCubeMap.maximumMipmapLevel}};l(s)&&(c.model_specularEnvironmentMaps=function(){return s},c.model_specularEnvironmentMapsMaximumLOD=function(){return o.maximumMipmapLevel}),e.uniformMap=Ft(c,e.uniformMap)};var QF=pme;var qBn=y(x(),1);var OBn=y(x(),1);var _Je=L.EPSILON16;function bj(e){e=e??Q.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(bj.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=L.clamp(e,this.minimumValue,this.maximumValue),L.equalsEpsilon(this._currentValue,e,_Je)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});var IJe=new m,gj=new $;bj.prototype.applyStageToMatrix=function(e){let t=this.type,n=this.currentValue,i=IJe,o;switch(t){case qc.XROTATE:o=$.fromRotationX(L.toRadians(n),gj),e=F.multiplyByMatrix3(e,o,e);break;case qc.YROTATE:o=$.fromRotationY(L.toRadians(n),gj),e=F.multiplyByMatrix3(e,o,e);break;case qc.ZROTATE:o=$.fromRotationZ(L.toRadians(n),gj),e=F.multiplyByMatrix3(e,o,e);break;case qc.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=F.multiplyByTranslation(e,i,e);break;case qc.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=F.multiplyByTranslation(e,i,e);break;case qc.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=F.multiplyByTranslation(e,i,e);break;case qc.XSCALE:i.x=n,i.y=1,i.z=1,e=F.multiplyByScale(e,i,e);break;case qc.YSCALE:i.x=1,i.y=n,i.z=1,e=F.multiplyByScale(e,i,e);break;case qc.ZSCALE:i.x=1,i.y=1,i.z=n,e=F.multiplyByScale(e,i,e);break;case qc.UNIFORMSCALE:e=F.multiplyByUniformScale(e,n,e);break;default:break}return e};var OF=bj;function Jk(e){e=e??Q.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,ZJe(this)}Object.defineProperties(Jk.prototype,{articulation:{get:function(){return this._articulation}},sceneGraph:{get:function(){return this._sceneGraph
{ material.diffuse = mix(material.diffuse, model_color.rgb, model_colorBlend); float highlight = ceil(model_colorBlend); material.diffuse *= mix(model_color.rgb, vec3(1.0), highlight); material.alpha *= model_color.a;}`;var T_={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};T_.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,pe.FRAGMENT),i.addFragmentLines(HF);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=Ge.TRANSLUCENT),i.addUniform("vec4",T_.COLOR_UNIFORM_NAME,pe.FRAGMENT),o[T_.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",T_.COLOR_BLEND_UNIFORM_NAME,pe.FRAGMENT),o[T_.COLOR_BLEND_UNIFORM_NAME]=function(){return jc.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=Ft(o,e.uniformMap)};var F0=T_;var gwn=y(x(),1);var lwn=y(x(),1),JF=`#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 Ame={name:"ModelClippingPlanesPipelineStage"},GJe=new M;Ame.process=function(e,t,n){let i=t.clippingPlanes,o=n.context,r=e.shaderBuilder;r.addDefine("HAS_CLIPPING_PLANES",void 0,pe.FRAGMENT),r.addDefine("CLIPPING_PLANES_LENGTH",i.length,pe.FRAGMENT),i.unionClippingRegions&&r.addDefine("UNION_CLIPPING_REGIONS",void 0,pe.FRAGMENT),ls.useFloatTexture(o)&&r.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,pe.FRAGMENT);let s=ls.getTextureResolution(i,o,GJe);r.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",s.x,pe.FRAGMENT),r.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",s.y,pe.FRAGMENT),r.addUniform("sampler2D","model_clippingPlanes",pe.FRAGMENT),r.addUniform("vec4","model_clippingPlanesEdgeStyle",pe.FRAGMENT),r.addUniform("mat4","model_clippingPlanesMatrix",pe.FRAGMENT),r.addFragmentLines(JF);let a={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=Ft(a,e.uniformMap)};var KF=Ame;var Zwn=y(x(),1);var ywn=y(x(),1),jF=`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 Cwn=y(x(),1),qF=`void modelClippingPolygonsStage(){ vec2 clippingPosition = v_clippingPosition; int regionIndex = v_regionIndex; czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);}`;var gme={name:"ModelClippingPolygonsPipelineStage"};gme.process=function(e,t,n){let i=t.clippingPolygons,o=e.shaderBuilder;o.addDefine("ENABLE_CLIPPING_POLYGONS",void 0,pe.BOTH),i.inverse&&o.addDefine("CLIPPING_INVERSE",void 0,pe.FRAGMENT),o.addDefine("CLIPPING_POLYGON_REGIONS_LENGTH",i.extentsCount,pe.BOTH),o.addUniform("sampler2D","model_clippingDistance",pe.FRAGMENT),o.addUniform("sampler2D","model_clippingExtents",pe.VERTEX),o.addVarying("vec2","v_clippingPosition"),o.addVarying("int","v_regionIndex","flat"),o.addVertexLines(jF),o.addFragmentLines(qF);let r={model_clippingDistance:function(){return i.clippingTexture??n.context.defaultTexture},model_clippingExtents:function(){return i.extentsTexture??n.context.defaultTexture}};e.uniformMap=Ft(r,e.uniformMap)};var $F=gme;var Gwn=y(x(),1);function bme(e,t){this._model=e,this._runtimeNode=t}Object.defineProperties(bme.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 e2=bme;var SNn=y(x(),1);var rNn=y(x(),1);var Wwn=y(x(),1),t2=`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 Bwn=y(x(),1),n2=`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 Nwn=y(x(),1),i2=`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 Kk=new F,LJe=new F,WJe=new F,xme={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:_me,_transformsToTypedArray:xj};xme.process=function(e,t,n){let i=t.instances,o=i.attributes[0].count,r=e.shaderBuilder;r.addDefine("HAS_INSTANCING"),r.addVertexLines(t2);let s=e.model,a=s.sceneGraph,c=e.runtimeNode,d=n.mode!==se.SCENE3D&&!n.scene3DOnly&&s._projectTo2D,u=s._enablePick&&!n.context.webgl2,h=[];zJe(e,n,i,h,d,u),KJe(e,n,i,h);let p={};if(i.transformInWorldSpace?(r.addDefine("USE_LEGACY_INSTANCING",void 0,pe.VERTEX),r.addUniform("mat4","u_instance_modifiedModelView",pe.VERTEX),r.addUniform("mat4","u_instance_nodeTransform",pe.VERTEX),p.u_instance_modifiedModelView=function(){let A=F.multiplyTransformation(s.modelMatrix,a.components.transform,Kk);return d?F.multiplyTransformation(n.context.uniformState.view3D,A,Kk):(n.mode!==se.SCENE3D&&(A=bt.basisTo2D(n.mapProjection,A,Kk)),F.multiplyTransformation(n.context.uniformState.view,A,Kk))},p.u_instance_nodeTransform=function(){return F.multiplyTransformation(a.axisCorrectionMatrix,c.computedTransform,LJe)},r.addVertexLines(i2)):r.addVertexLines(n2),d){r.addDefine("USE_2D_INSTANCING",void 0,pe.VERTEX),r.addUniform("mat4","u_modelView2D",pe.VERTEX);let A=n.context,f=F.fromTranslation(c.instancingReferencePoint2D,new F);p.u_modelView2D=function(){return F.multiplyTransformation(A.uniformState.view,f,WJe)}}e.uniformMap=Ft(p,e.uniformMap),e.instanceCount=o,ri(e.attributes,h)};var o2=new F,FJe=new m;function BJe(e,t,n,i,o){let r=F.multiplyTransformation(t,e,o2);return r=F.multiplyTransformation(r,n,o2),o=bt.basisTo2D(i.mapProjection,r,o),o}function wJe(e,t,n,i,o){let r=F.fromTranslation(e,o2),s=F.multiplyTransformation(t,r,o2);s=F.multiplyTransformation(s,n,o2);let a=F.getTranslation(s,FJe);return o=so.computeActualEllipsoidPosition(i,a,o),o}function Cme(e,t,n){let i=e.model,o=i.sceneGraph;e.runtimeNode.node.instances.transformInWorldSpace?(t=F.multiplyTransformation(i.modelMatrix,o.components.transform,t),n=F.multiplyTransformation(o.axisCorrectionMatrix,e.runtimeNode.computedTransform,n)):(t=F.clone(o.computedModelMatrix,t),t=F.multiplyTransformation(t,e.runtimeNode.computedTransform,t),n=F.clone(F.IDENTITY,n))}var Tme=new F,Eme=new F,NJe=new F,PJe=new m;function XJe(e,t,n,i){let o=Tme,r=Eme;Cme(t,o,r);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let d=0;d<c;d++){let u=e[d],h=BJe(u,o,r,n,NJe),p=F.getTranslation(h,PJe),A=m.subtract(p,a,p);i[d]=F.setTranslation(h,A,i[d])}return i}function YJe(e,t,n,i){let o=Tme,r=Eme;Cme(t,o,r);let a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let d=0;d<c;d++){let u=e[d],h=wJe(u,o,r,n,u);i[d]=m.subtract(h,a,i[d])}return i}var MJe=new m,vJe=new m;function Sme(e,t){let n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,o=F.multiplyByPoint(i,n.instancingTranslationMin,MJe),r=so.computeActualEllipsoidPosition(t,o,o),s=F.multiplyByPoint(i,n.instancingTranslationMax,vJe),a=so.computeActualEllipsoidPosition(t,s,s);n.instancingReferencePoint2D=m.lerp(r,a,.5,new m)}function xj(e){let n=e.length,i=new Float32Array(n*12);for(let o=0;o<n;o++){let r=e[o],s=12*o;i[s+0]=r[0],i[s+1]=r[4],i[s+2]=r[8],i[s+3]=r[12],i[s+4]=r[1],i[s+5]=r[5],i[s+6]=r[9],i[s+7]=r[13],i[s+8]=r[2],i[s+9]=r[6],i[s+10]=r[10],i[s+11]=r[14]}return i}function UJe(e){let n=e.length,i=new Float32Array(n*3);for(let o=0;o<n;o++){let r=e[o],s=3*o;i[s+0]=r[0],i[s+1]=r[4],i[s+2]=r[8]}return i}var DJe=new m,kJe=new Me,QJe=new m;function _me(e,t,n){let i=new Array(t),o=It.getAttributeBySemantic(e,Fs.TRANSLATION),r=It.getAttributeBySemantic(e,Fs.ROTATION),s=It.getAttributeBySemantic(e,Fs.SCALE),a=new m(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=new m(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),d=l(o),u=l(r),h=l(s),p=d?o.typedArray:new Float32Array(t*3),A=u?r.typedArray:new Float32Array(t*4);u&&r.normalized&&(A=on.dequantize(A,r.componentDatatype,r.type,t));let f;h?f=s.typedArray:(f=new Float32Array(t*3),f.fill(1));for(let C=0;C<t;C++){let T=new m(p[C*3],p[C*3+1],p[C*3+2],DJe);m.maximumByComponent(a,T,a),m.minimumByComponent(c,T,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 kNn=y(x(),1),h2=`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 Fme={name:"CPUStylingPipelineStage"};Fme.process=function(e,t,n){let i=e.model,o=e.shaderBuilder;o.addVertexLines(m2),o.addFragmentLines(h2),o.addDefine("USE_CPU_STYLING",void 0,pe.BOTH),l(i.color)||(o.addUniform("float",F0.COLOR_BLEND_UNIFORM_NAME,pe.FRAGMENT),e.uniformMap[F0.COLOR_BLEND_UNIFORM_NAME]=function(){return jc.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),o.addUniform("bool","model_commandTranslucent",pe.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===Ge.TRANSLUCENT}};var f2=Fme;var tPn=y(x(),1),Bme={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};Bme.getDefineName=function(e){return`CUSTOM_SHADER_${e}`};var fg=Object.freeze(Bme);var eXn=y(x(),1);var iPn=y(x(),1),p2=`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 rPn=y(x(),1),A2=`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 TPn=y(x(),1);var aPn=y(x(),1),g2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) { initializeFeatureIds(featureIds, attributes); initializeFeatureIdAliases(featureIds);}`;var lPn=y(x(),1),b2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) { initializeFeatureIds(featureIds, attributes); initializeFeatureIdAliases(featureIds); setFeatureIdVaryings();}`;var ao={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()"};ao.process=function(e,t,n){let i=e.shaderBuilder;eKe(i);let o=e.runtimeNode.node.instances;l(o)&&tKe(e,o,n),nKe(e,t,n),i.addVertexLines(b2),i.addFragmentLines(g2)};function eKe(e){e.addStruct(ao.STRUCT_ID_FEATURE_IDS_VS,ao.STRUCT_NAME_FEATURE_IDS,pe.VERTEX),e.addStruct(ao.STRUCT_ID_FEATURE_IDS_FS,ao.STRUCT_NAME_FEATURE_IDS,pe.FRAGMENT),e.addFunction(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,ao.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,pe.VERTEX),e.addFunction(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,ao.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,pe.FRAGMENT),e.addFunction(ao.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,ao.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,pe.VERTEX),e.addFunction(ao.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,ao.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,pe.FRAGMENT),e.addFunction(ao.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,ao.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,pe.VERTEX)}function tKe(e,t,n){let i=t.featureIds,o=t.attributes[0].count;for(let r=0;r<i.length;r++){let s=i[r],a=s.positionalLabel;s instanceof Tn.FeatureIdAttribute?iKe(e,s,a):wme(e,s,a,o,1,n);let c=s.label;l(c)&&Nme(e,a,c,pe.BOTH)}}function nKe(e,t,n){let i=t.featureIds,r=It.getAttributeBySemantic(t,ct.POSITION).count;for(let s=0;s<i.length;s++){let a=i[s],c=a.positionalLabel,d=pe.BOTH;a instanceof Tn.FeatureIdAttribute?oKe(e,a,c):a instanceof Tn.FeatureIdImplicitRange?wme(e,a,c,r,void 0,n):(rKe(e,a,c,s,n),d=pe.FRAGMENT);let u=a.label;l(u)&&Nme(e,c,u,d)}}function iKe(e,t,n){let i=e.shaderBuilder;i.addStructField(ao.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ao.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),s=`a_${r}${o}`,a=`v_${r}${o}`,c=`featureIds.${n} = int(czm_round(${s}));`,d=`featureIds.${n} = int(czm_round(${a}));`;i.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[d]),i.addVarying("float",a),i.addFunctionLines(ao.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${a} = ${s};`])}function oKe(e,t,n){let i=e.shaderBuilder;i.addStructField(ao.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ao.STRUCT_ID_FEATURE_IDS_FS,"int",n);let o=t.setIndex,r=n.replace(/_\d+$/,"_"),s=[`featureIds.${n} = int(czm_round(attributes.${r}${o}));`];i.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,s),i.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,s)}function wme(e,t,n,i,o,r){sKe(e,t,i,o,r);let s=e.shaderBuilder,a=`a_implicit_${n}`;s.addAttribute("float",a);let c=`v_implicit_${n}`;s.addVarying("float",c),s.addStructField(ao.STRUCT_ID_FEATURE_IDS_VS,"int",n),s.addStructField(ao.STRUCT_ID_FEATURE_IDS_FS,"int",n),s.addFunctionLines(ao.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[`${c} = ${a};`]),s.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[`featureIds.${n} = int(czm_round(${a}));`]),s.addFunctionLines(ao.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[`featureIds.${n} = int(czm_round(${c}));`])}function rKe(e,t,n,i,o){let r=`u_featureIdTexture_${i}`,s=e.uniformMap,a=t.textureReader;s[r]=function(){return a.texture??o.context.defaultTexture};let c=a.channels,d=e.shaderBuilder;d.addStructField(ao.STRUCT_ID_FEATURE_IDS_FS,"int",n),d.addUniform("sampler2D",r,pe.FRAGMENT);let h=`v_texCoord_${a.texCoord}`,p=h,A=a.transform;if(l(A)&&
FeatureIds featureIds, out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes ){ initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);}`;var IPn=y(x(),1),x2=`void metadataStage( FeatureIds featureIds, out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes ){ initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes); setMetadataVaryings();}`;var Zi={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"}]};Zi.process=function(e,t,n){let{shaderBuilder:i,model:o}=e,{structuralMetadata:r={},content:s}=o,a=s?.tileset.metadataExtension?.statistics,c=n.context.webgl2,d=IKe(o,t),u=cKe(r.propertyAttributes,t,a),h=dKe(r.propertyTextures,a),p=hKe(r.propertyTables,t,e,a,d),A=u.concat(h).concat(p);AKe(i,A),yKe(i),i.addVertexLines(x2),i.addFragmentLines(y2);for(let f=0;f<u.length;f++){let b=u[f];xKe(e,b)}for(let f=0;f<h.length;f++){let b=h[f];TKe(e,b,c)}for(let f=0;f<p.length;f++){let b=p[f];SKe(e,b,c)}};function cKe(e,t,n){return l(e)?e.flatMap(i=>lKe(i,t,n)):[]}function lKe(e,t,n){let{getAttributeByName:i,getAttributeInfo:o,sanitizeGlslIdentifier:r}=It,s=e.class.id,a=n?.classes[s],c=Object.entries(e.properties),d=new Array(c.length);for(let u=0;u<c.length;u++){let[h,p]=c[u],A=i(t,p.attribute),{glslType:f,variableName:b}=o(A);d[u]={metadataVariable:r(h),property:p,classProperty:p.classProperty,type:p.classProperty.type,glslType:f,variableName:b,propertyStatistics:a?.properties[h],shaderDestination:pe.BOTH}}return d}function dKe(e,t){return l(e)?e.flatMap(n=>uKe(n,t)):[]}function uKe(e,t){let{sanitizeGlslIdentifier:n}=It,i=e.class.id,o=t?.classes[i],r=Object.entries(e.properties).filter(([a,c])=>{let d=c.textureReader.channels.length;return c.classProperty.isGpuCompatible(d)}),s=new Array(r.length);for(let a=0;a<r.length;a++){let[c,d]=r[a];s[a]={metadataVariable:n(c),property:d,classProperty:d.classProperty,type:d.classProperty.type,glslType:d.classProperty.getGlslType(),propertyStatistics:o?.properties[c],shaderDestination:pe.FRAGMENT}}return s}var mKe=4;function hKe(e,t,n,i,o){if(!l(e))return[];let r=pKe(n,t);return e.filter(s=>l(s.class)&&r.has(String(s.id))).flatMap(s=>fKe(s,r,i,o))}function fKe(e,t,n,i){let{sanitizeGlslIdentifier:o}=It,r=e.class,s=n?.classes[r.id],a=t.get(String(e.id))??{},c=a.shaderDestination??pe.BOTH,d=e.properties,u=r.properties,h=[],p=0;for(let[A,f]of Object.entries(u)){if(!f.isGpuCompatible(mKe))continue;let b=d[A],C=pe.intersection(VKe(A,i),c);if(C===pe.NONE){p++;continue}h.push({metadataVariable:o(A),property:b,classProperty:f,type:f.type,glslType:f.getGlslType(),propertyStatistics:s?.properties[A],shaderDestination:C,propertyTable:e,featureIdVariableName:a.variableName,propertyInfoIndex:p}),p++}return h}function pKe(e,t){let n=new Map;function i(a,c){let d=a?.propertyTableId;if(!l(d))return;let u=String(d),h={variableName:a.positionalLabel,shaderDestination:c},p=n.get(u);l(p)&&console.warn(`Multiple feature ID sets reference the same property table ${d} in primitive. Only one will be used.`),n.set(u,h)}let o=t?.featureIds??[];for(let a=0;a<o.length;a++){let c=o[a],d=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 Dme={name:"EdgeDetectionPipelineStage"};Dme.process=function(e){e.shaderBuilder.addFragmentLines([S2])};var _2=Dme;var JXn=y(x(),1);var fXn=y(x(),1),I2=`// 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 AXn=y(x(),1),Z2=`#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 VXn=y(x(),1);var Zj=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,s=t.count,a=n;return i&&(a=on.dequantize(n,t.componentDatatype,r,s)),l(o)?e.dequantize(a,s,r,o):a}static readAttributeAsRawCompactTypedArray(t){let n=t.type,i=t.count,o=Ut.getNumberOfComponents(n),r=i*o,s=t.componentDatatype,a=t.quantization;l(a)&&(s=a.componentDatatype);let c=t.buffer,d=t.byteOffset,u=t.byteStride,h=H.getSizeInBytes(s),p=o*h;if(!l(u)||u===p){let S=H.createTypedArray(s,r);return c.getBufferData(S,d),S}let A=new Uint8Array(c.sizeInBytes);c.getBufferData(A);let f=H.createTypedArray(s,r),b=u??p,C=new DataView(A.buffer,A.byteOffset,A.byteLength),T=new Array(o),E=e.createComponentsReader(s);for(let S=0;S<i;++S){let I=d+S*b;E(C,I,o,T);for(let R=0;R<o;++R)f[S*o+R]=T[R]}return f}static dequantize(t,n,i,o){if(o.octEncoded){let a=e.octDecode(t,n,o.normalizationRange,void 0);return o.octEncodedZXY&&e.convertZxyToXyz(a,a),a}let r=o.quantizedVolumeStepSize,s=o.quantizedVolumeOffset;if(i===Ut.SCALAR)return e.dequantize1D(t,n,r,s,void 0);if(i===Ut.VEC2)return e.dequantize2D(t,n,r,s,void 0);if(i===Ut.VEC3)return e.dequantize3D(t,n,r,s,void 0);if(i===Ut.VEC4)return e.dequantize4D(t,n,r,s,void 0);throw new fe(`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 m;for(let s=0;s<n;s++)m.unpack(t,s*3,r),on.octDecodeInRange(r,i,r),m.pack(o,r,s*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 s=t[o+0],a=t[o+1],c=t[o+2];i[o+0]=a,i[o+1]=c,i[o+2]=s}return i}static dequantize1D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));for(let s=0;s<n;s++){let c=t[s]*i+o;r[s]=c}return r}static dequantize2D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let s=new M;for(let a=0;a<n;a++)M.unpack(t,a*2,s),M.multiplyComponents(s,i,s),M.add(s,o,s),M.pack(s,r,a*2);return r}static dequantize3D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let s=new m;for(let a=0;a<n;a++)m.unpack(t,a*3,s),m.multiplyComponents(s,i,s),m.add(s,o,s),m.pack(s,r,a*3);return r}static dequantize4D(t,n,i,o,r){l(r)||(r=new Float32Array(t.length));let s=new re;for(let a=0;a<n;a++)re.unpack(t,a*4,s),re.multiplyComponents(s,i,s),re.add(s,o,s),re.pack(s,r,a*4);return r}static createComponentsReader(t){let n=e.createComponentReader(t),i=H.getSizeInBytes(t);return function(o,r,s,a){let c=r;for(let d=0;d<s;++d)a[d]=n(o,c),c+=i}}static createComponentReader(t){switch(t){case H.BYTE:return function(n,i){return n.getInt8(i)};case H.UNSIGNED_BYTE:return function(n,i){return n.getUint8(i)};case H.SHORT:return function(n,i){return n.getInt16(i,!0)};case H.UNSIGNED_SHORT:return function(n,i){return n.getUint16(i,!0)};case H.INT:return function(n,i){return n.getInt32(i,!0)};case H.UNSIGNED_INT:return function(n,i){return n.getUint32(i,!0)};case H.FLOAT:return function(n,i){return n.getFloat32(i,!0)};case H.DOUBLE:return function(n,i){return n.getFloat64(i,!0)}}throw new fe(`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 m,r=t.length/3;for(let s=0;s<r;s++)m.unpack(t,s*3,o),F.multiplyByPoint(n,o,o),m.pack(o,i,s*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,s=e.createIndexTypedArray(r,o);return i.getBufferData(s),s}static readIndicesAsTriangleIndicesTypedArray(t,n){let i=e.readIndicesAsTypedArray(t);if(n===We.TRIANGLES)return i;if(n===We.TRIANGLE_STRIP)return e.convertTriangleStripToTriangleIndices(i);if(n===We.TRIANGLE_FAN)return e.convertTriangleFanToTriangleIndices(i);throw new fe(`The primitiveType must be TRIANGLES (${We.TRIANGLES}, TRIANGLE_STRIP (${We.TRIANGLE_STRIP}, or TRIANGLE_FAN (${We.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
{ 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 $Xn=y(x(),1),G2=`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 cYn=y(x(),1);var tYn=y(x(),1),S_=`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 L2={name:"SelectedFeatureIdPipelineStage",STRUCT_ID_SELECTED_FEATURE:"SelectedFeature",STRUCT_NAME_SELECTED_FEATURE:"SelectedFeature"};L2.process=function(e,t,n){let i=e.shaderBuilder;e.hasPropertyTable=!0;let o=e.model,r=e.runtimeNode.node,s=$Ke(o,r,t),a=s.shaderDestination;i.addDefine("HAS_SELECTED_FEATURE_ID",void 0,a),i.addDefine("SELECTED_FEATURE_ID",s.variableName,a),i.addDefine(s.featureIdDefine,void 0,a),eje(i);let c=s.featureIds.nullFeatureId,d=e.uniformMap;l(c)&&(i.addDefine("HAS_NULL_FEATURE_ID",void 0,a),i.addUniform("int","model_nullFeatureId",a),d.model_nullFeatureId=function(){return c}),s.shaderDestination===pe.BOTH&&i.addVertexLines(S_),i.addFragmentLines(S_)};function Qme(e){return e instanceof Tn.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function Ome(e){return e instanceof Tn.FeatureIdTexture?pe.FRAGMENT:pe.BOTH}function $Ke(e,t,n){let i,o;return l(t.instances)&&(o=It.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),l(o))?(i=o.label??o.positionalLabel,{featureIds:o,variableName:i,shaderDestination:Ome(o),featureIdDefine:Qme(o)}):(o=It.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=o.label??o.positionalLabel,{featureIds:o,variableName:i,shaderDestination:Ome(o),featureIdDefine:Qme(o)})}function eje(e){e.addStructField(L2.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(L2.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(L2.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}var N0=L2;var Fa={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)"};Fa.process=function(e,t,n){let{shaderBuilder:i,model:o}=e;i.addStruct(Fa.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",pe.VERTEX),i.addStruct(Fa.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",pe.FRAGMENT),i.addStruct(N0.STRUCT_ID_SELECTED_FEATURE,N0.STRUCT_NAME_SELECTED_FEATURE,pe.BOTH),i.addFunction(Fa.FUNCTION_ID_INITIALIZE_ATTRIBUTES,Fa.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,pe.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(Fa.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(Fa.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(Fa.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,Fa.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,pe.VERTEX),i.addFunction(Fa.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,Fa.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,pe.FRAGMENT),o.type===Nr.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,pe.FRAGMENT);let r=n.mode!==se.SCENE3D&&!n.scene3DOnly&&o._projectTo2D,s=l(e.runtimeNode.node.instances),a=r&&!s,c=t.attributes.length;for(let d=0;d<c;d++){let u=t.attributes[d],h=Ut.getAttributeLocationCount(u.type),p=u.semantic===ct.POSITION,A;h>1?(A=e.attributeIndex,e.attributeIndex+=h):p&&!a?A=0:A=e.attributeIndex++;let f=!p&&t.primitiveType===We.POINTS&&n.context.webgl2?"flat":void 0;tje(e,u,A,h,r,s,f)}dje(i,t.attributes),t.primitiveType===We.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines(G2),i.addFragmentLines(V2)};function tje(e,t,n,i,o,r,s){let a=e.shaderBuilder,c=It.getAttributeInfo(t),d=o&&!r;i>1?oje(e,t,n,i):ije(e,t,n,d),sje(a,c,d),rje(a,c,s),l(t.semantic)&&nje(a,t),aje(a,c,o),cje(a,c,d),lje(a,c)}function nje(e,t){let{semantic:n,setIndex:i}=t;switch(n){case ct.NORMAL:e.addDefine("HAS_NORMALS");break;case ct.TANGENT:e.addDefine("HAS_TANGENTS");break;case ct.FEATURE_ID:e.addDefine(`HAS${n}_${i}`);break;case ct.TEXCOORD:case ct.COLOR:e.addDefine(`HAS_${n}_${i}`)}}function ije(e,t,n,i){let{quantization:o,semantic:r,setIndex:s}=t,{type:a,compone
${o}`),t}var yp=Aje;function jk(e,t,n,i,o,r,s){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=o,this.timesRetried=r??0,this.retry=!1,this.error=s}jk.reportError=function(e,t,n,i,o,r,s,a){let c=e;return l(e)?(c.provider=t,c.message=i,c.x=o,c.y=r,c.level=s,c.retry=!1,c.error=a,++c.timesRetried):c=new jk(t,i,o,r,s,0,a),l(n)&&n.numberOfListeners>0?n.raiseEvent(c):l(t)&&console.log(`An error occurred in "${t.constructor.name}": ${yp(i)}`),c};jk.reportSuccess=function(e){l(e)&&(e.timesRetried=-1)};var qo=jk;var VMn=y(x(),1),gje={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"},Z_=Object.freeze(gje);var WMn=y(x(),1);function B2(e){}B2.prototype.isReady=function(){return!0};B2.prototype.shouldDiscardImage=function(e){return B2.EMPTY_IMAGE===e};var qk;Object.defineProperties(B2,{EMPTY_IMAGE:{get:function(){return l(qk)||(qk=new Image,qk.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),qk}}});var R_=B2;function Kme(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}Kme.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 s=0,a=o.coverageAreas.length;s<a;++s){let c=r[s],d=c.bbox;c.bbox=new de(L.toRadians(d[1]),L.toRadians(d[0]),L.toRadians(d[3]),L.toRadians(d[2]))}}};function bje(e,t){if(e.resourceSets.length!==1)throw new me("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 yje(e,t,n){let i=`An error occurred while accessing ${e.url}`;throw l(t)&&l(t.message)&&(i+=`: ${t.message}`),qo.reportError(void 0,n,l(n)?n._errorEvent:void 0,i,void 0,void 0,void 0,t),new me(i)}async function xje(e,t,n){let i=e.url,o=da._metadataCache[i];l(o)||(o=e.fetchJson(),da._metadataCache[i]=o);try{let r=await o;return bje(r,t)}catch(r){yje(e,r,n)}}function da(e){e=e??Q.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??Z_.AERIAL,this._mapLayer=e.mapLayer,this._culture=e.culture??"",this._key=e.key,this._tileDiscardPolicy=e.tileDiscardPolicy,l(this._tileDiscardPolicy)||(this._tileDiscardPolicy=new R_),this._proxy=e.proxy,this._credit=new Et(`<a href="https://www.microsoft.com/en-us/maps/bing-maps/product"><img src="${da.logoUrl}" title="Bing Imagery"/></a>`),this._tilingScheme=new ws({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 xe}Object.defineProperties(da.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(){retur
in vec2 v_textureCoordinates;
void main(){ out_FragColor = texture(u_texture, v_textureCoordinates);}`;var ODn=y(x(),1),z2=`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 $Dn=y(x(),1);var HDn=y(x(),1),Q4e={UNLOADED:0,TRANSITIONING:1,RECEIVED:2,TEXTURE_LOADED:3,READY:4,FAILED:5,INVALID:6,PLACEHOLDER:7},Qn=Object.freeze(Q4e);function N_(e,t,n,i,o){if(this.imageryLayer=e,this.x=t,this.y=n,this.level=i,this.request=void 0,i!==0){let r=t/2|0,s=n/2|0,a=i-1;this.parent=e.getImageryFromCache(r,s,a)}this.state=Qn.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}N_.createPlaceholder=function(e){let t=new N_(e,0,0,0);return t.addReference(),t.state=Qn.PLACEHOLDER,t};N_.prototype.addReference=function(){++this.referenceCount};N_.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(),he(this),0):this.referenceCount};N_.prototype.processStateMachine=function(e,t,n){this.state===Qn.UNLOADED&&!n&&(this.state=Qn.TRANSITIONING,this.imageryLayer._requestImagery(this)),this.state===Qn.RECEIVED&&(this.state=Qn.TRANSITIONING,this.imageryLayer._createTexture(e.context,this));let i=this.state===Qn.READY&&t&&!this.texture;(this.state===Qn.TEXTURE_LOADED||i)&&(this.state=Qn.TRANSITIONING,this.imageryLayer._reprojectTexture(e,this,t))};var P_=N_;var ikn=y(x(),1);function Xj(e,t,n){this.readyImagery=void 0,this.loadingImagery=e,this.textureCoordinateRectangle=t,this.textureTranslationAndScale=void 0,this.useWebMercatorT=n}Xj.prototype.freeResources=function(){l(this.readyImagery)&&this.readyImagery.releaseReference(),l(this.loadingImagery)&&this.loadingImagery.releaseReference()};Xj.prototype.processStateMachine=function(e,t,n){let i=this.loadingImagery,o=i.imageryLayer;if(i.processStateMachine(t,!this.useWebMercatorT,n),i.state===Qn.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,s;for(;l(r)&&(r.state!==Qn.READY||!this.useWebMercatorT&&!l(r.texture));)r.state!==Qn.FAILED&&r.state!==Qn.INVALID&&(s=s||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===Qn.FAILED||i.state===Qn.INVALID?l(s)?(s.processStateMachine(t,!this.useWebMercatorT,n),!1):!0:!1};var X_=Xj;function Pi(e,t){this._imageryProvider=e,this._readyEvent=new xe,this._errorEvent=new xe,t=t??Q.EMPTY_OBJECT,e=e??Q.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??Pi.DEFAULT_BRIGHTNESS,this.contrast=t.contrast??e._defaultContrast??Pi.DEFAULT_CONTRAST,this.hue=t.hue??e._defaultHue??Pi.DEFAULT_HUE,this.saturation=t.saturation??e._defaultSaturation??Pi.DEFAULT_SATURATION,this.gamma=t.gamma??e._defaultGamma??Pi.DEFAULT_GAMMA,this.splitDirection=t.splitDirection??Pi.DEFAULT_SPLIT,this.minificationFilter=t.minificationFilter??e._defaultMinificationFilter??Pi.DEFAULT_MINIFICATION_FILTER,this.magnificationFilter=t.magnificationFilter??e._defaultMagnificationFilter??Pi.DEFAULT_MAGNIFICATION_FILTER,this.show=t.show??!0,this._minimumTerrainLevel=t.minimumTerrainLevel,this._maximumTerrainLevel=t.maximumTerrainLevel,this._rectangle=t.rectangle??de.MAX_VALUE,this._maximumAnisotropy=t.maximumAnisotropy,this._imageryCache={},this._skeletonPlaceholder=new X_(P_.createPlaceholder(this)),this._show=!0,this._layerIndex=-1,this._isBaseLayer=!1,this._requestImageError=void 0,this._reprojectComputeCommands=[],this.cutoutRectangle=t.cutoutRectangle,thi
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 Q9n=y(x(),1),r8e={UNLIT:0,PBR:1},Cp=Object.freeze(r8e);var _he={name:"LightingPipelineStage"};_he.process=function(e,t){let{model:n,lightingOptions:i,shaderBuilder:o}=e;if(l(n.lightColor)){o.addDefine("USE_CUSTOM_LIGHT_COLOR",void 0,pe.FRAGMENT),o.addUniform("vec3","model_lightColorHdr",pe.FRAGMENT);let s=e.uniformMap;s.model_lightColorHdr=function(){return n.lightColor}}let{lightingModel:r}=i;r===Cp.PBR?o.addDefine("LIGHTING_PBR",void 0,pe.FRAGMENT):o.addDefine("LIGHTING_UNLIT",void 0,pe.FRAGMENT),o.addFragmentLines(q2)};var $2=_he;var T5n=y(x(),1);var $9n=y(x(),1),eB=`// 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 t5n=y(x(),1),tB=`#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 i5n=y(x(),1),nB=`#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:s8e,MetallicRoughness:Hj,SpecularGlossiness:Jj,Specular:Ihe,Clearcoat:Zhe}=Tn,Rhe={name:"MaterialPipelineStage",_processTexture:Zd,_processTextureTransform:Vhe};Rhe.process=function(e,t,n){let i=t.material,{model:o,uniformMap:r,shaderBuilder:s}=e;l(r.u_constantLodDistance)||(r.u_constantLodDistance=function(){let T=o.boundingSphere,E=n.camera;if(l(T)&&l(E)){let S=m.distance(E.positionWC,T.center);return Math.max(S,.1)}return 1});let a=l(o.classificationType),c=a,{defaultTexture:d,defaultNormalTexture:u,defaultEmissiveTexture:h}=n.context;d8e(i,r,s,d,u,h,c,e),l(i.specularGlossiness)?u8e(i.specularGlossiness,r,s,d,c,e):(l(i.specular)&&It.supportedExtensions.KHR_materials_specular&&m8e(i.specular,r,s,d,c),l(i.anisotropy)&&It.supportedExtensions.KHR_materials_anisotropy&&f8e(i.anisotropy,r,s,d,c),l(i.clearcoat)&&It.supportedExtensions.KHR_materials_clearcoat&&p8e(i.clearcoat,r,s,d,c),A8e(i.metallicRoughness,r,s,d,c,e));let p=It.getAttributeBySemantic(t,ct.NORMAL),A=l(o.pointCloudShading)&&!o.pointCloudShading.normalShading,f=e.lightingOptions;i.unlit||!p||a||A?f.lightingModel=Cp.UNLIT:f.lightingModel=Cp.PBR;let b=o.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=b;let C=e.alphaOptions;i.alphaMode===pp.BLEND?C.pass=Ge.TRANSLUCENT:i.alphaMode===pp.MASK&&(C.alphaCutoff=i.alphaCutoff),l(i.pointDiameter)&&(s.addDefine("HAS_POINT_DIAMETER",void 0,pe.BOTH),s.addUniform("float","u_pointDiameter",pe.VERTEX),r.u_pointDiameter=function(){return i.pointDiameter*n.pixelRatio}),l(i.lineStyle)&&c8e(i.lineStyle,t,n,r,s),s.addFragmentLines(eB),i.doubleSided&&s.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,pe.BOTH)};function a8e(e,t,n,i,o,r){let s=n.constantLod;if(!l(s)||!l(r))return;let a=`HAS_${o}_CONSTANT_LOD`;if(e.addDefine(a,void 0,pe.BOTH),!l(t.u_constantLodOffset)){e.addDefine("HAS_CONSTANT_LOD",void 0,pe.BOTH),e.addVarying("vec3","v_constantLodUvCustom"),e.addUniform("vec2","u_constantLodOffset",pe.VERTEX),e.addUniform("float","u_constantLodDistance",pe.VERTEX),e.addUniform("mat4","u_constantLodWorldToEnu",pe.VERTEX),e.addFragmentLines(nB);let d=tB.split(``).filter(u=>!u.trim().startsWith("//")||u.includes("#"));e.addFunctionLines("setDynamicVaryingsVS",d)}let c=`${i}ConstantLodParams`;if(e.addUniform("vec3",c,pe.FRAGMENT),t[c]=function(){return new m(s.minClampDistance,s.maxClampDistance,s.repetitions)},!l(t.u_constantLodOffset)){t.u_constantLodOffset=function(){return s.offset};let d=F.clone(F.IDENTITY),u=!1;t.u_constantLodWorldToEnu=function(){if(!u){let h=r.model.boundingSphere;if(l(h)){let p=h.center,A=bt.eastNorthUpToFixedFrame(p);F.inverse(A,d),u=!0}}return u?d:F.IDENTITY}}}function c8e(e,t,n,i,o){let{width:r,pattern:s}=e;l(r)&&(o.addUniform("float","u_lineWidth",pe.VERTEX),i.u_lineWidth=function(){return r*n.pixelRatio}),l(s)&&(o.addDefine("HAS_LINE_PATTERN",void 0,pe.BOTH),o.addUniform("float","u_linePattern",pe.FRAGMENT),o.addVarying("float","v_lineCoord"),i.u_linePattern=function(){return s});let a=It.getAttributeBySemantic(t,ct.CUMULATIVE_DISTANCE);if(l(s)&&l(a)&&(t.primitiveType===We.LINES||t.primitiveType===We.TRIANGLE_STRIP)){o.addDefine("HAS_LINE_CUMULATIVE_DISTANCE",void 0,pe.VERTEX),a.normalized&&o.addDefine("LINE_CUM_DIST_NORMALIZED",void 0,pe.VERTEX),o.addUniform("float","u_cumulativeDistanceMax",pe.VERTEX),o.addUniform("float","u_pixelsPerWorld",pe.VERTEX);let c=l(a.max)?a.max:1;i.u_cumulativeDistanceMax=function(){return c},i.u_pixelsPerWorld=function(){let u=n.camera.frustum,h=1,p;return l(u.right)&&l(u.left)?p=u.right-u.left:l(u.width)&&(p=u.width),l(p)&&p>0&&(h=n.context.drawingBufferWidth/p),h};let d=It.getAttributeInfo(a).variableName;o.addVertexLines(`#ifdef HAS_LINE_CUMULATIVE_DISTANCEvoid lineStyleStageVS(in ProcessedAttributes attributes){ float cumDist = attributes.${d};#ifdef LINE_CUM_DIST_NORMALIZED cumDist *= u_cumulativeDistanceMax;#endif const float textureCoordinateBase = 8192.0; v_lineCoord = textureCoordinateBase + cumDist * u_pixelsPerWorld;}#endif`)}else l(s)&&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 Vhe(e,t,n,i,o){let r=`HAS_${o}_TEXTURE_TRANSFORM`;e.addDefine(r,void 0,pe.FRAGMENT);let s=`${i}Transform`;e.addUniform("mat3",s,pe.FRAGMENT),t[s]=function(){return n.transform}}function l8e(e,t,n,i,o){let r=`HAS_${o}_TEXTURE_SCALE`;e.addDefine(r,void 0,pe.FRAGMENT);let s=`${i}Scale`;e.addUniform("float",s,pe.FRAGMENT),t[s]=function(){return n.scale}}function Zd(e,t,n,i,o,r,s){e.addUniform("sampler2D",i,pe.FRAGMENT),t[i]=function(){return n.texture??r};let a=`HAS_${o}_TEXTURE`;e.addDefine(a,void 0,pe.FRAGMENT);let d=`v_texCoord_${n.texCoord}`,u=`TEXCOORD_${o}`;e.addDefine(u,d,pe.FRAGMENT);let h=n.transform;l(h)&&!$.equals(h,$.IDENTITY)&&Vhe(e,t,n,i,o);let{scale:p}=n;l(p)&&p!==1&&l8e(e,t,n,i,o),a8e(e,t,n,i,o,s)}function d8e(e,t,n,i,o,r,s,a){let{emissiveFactor:c,emissiveTexture:d,normalTexture:u,occlusionTexture:h}=e;l(c)&&!m.equals(c,s8e.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",pe.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,pe.FRAGMENT),l(d)&&!s&&Zd(n,t,d,"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(u)&&!s){let A=u;l(u.constantLod)&&l(p)&&(A=Object.create(Object.getPrototypeOf(u)),Object.assign(A,u),A.constantLod=p),Zd(n,t,A,"u_normalTexture","NORMAL",o,a)}l(h)&&!s&&Zd(n,t,h,"u_occlusionTexture","OCCLUSION",i)}function u8e(e,t,n,i,o,r){let{diffuseTexture:s,diffuseFactor:a,specularGlossinessTexture:c,specularFactor:d,glossinessFactor:u}=e;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,pe.FRAGMENT),l(s)&&!o&&Zd(n,t,s,"u_diffuseTexture","DIFFUSE",i,r),l(a)&&!re.equals(a,Jj.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",pe.FRAGMENT),t.u_diffuseFactor=function(){return e.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,pe.FRAGMENT)),l(c)&&!o&&Zd(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i),l(d)&&!m.equals(d,Jj.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_legacySpecularFactor",pe.FRAGMENT),t.u_legacySpecularFactor=function(){return e.specularFactor},n.addDefine("HAS_LEGACY_SPECULAR_FACTOR",void 0,pe.FRAGMENT)),l(u)&&u!==Jj.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",pe.FRAGMENT),t.u_glossinessFactor=function(){return e.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,pe.FRAGMENT))}function m8e(e,t,n,i,o){let{specularTexture:r,specularFactor:s,specularColorTexture:a,specularColorFactor:c}=e;n.addDefine("USE_SPECULAR",void 0,pe.FRAGMENT),l(r)&&!o&&Zd(n,t,r,"u_specularTexture","SPECULAR",i),l(s)&&s!==Ihe.DEFAULT_SPECULAR_FACTOR&&(n.addUniform("float","u_specularFactor",pe.FRAGMENT),t.u_specularFactor=function(){return e.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,pe.FRAGMENT)),l(a)&&!o&&Zd(n,t,a,"u_specularColorTexture","SPECULAR_COLOR",i),l(c)&&!m.equals(c,Ihe.DEFAULT_SPECULAR_COLOR_FACTOR)&&(n.addUniform("vec3","u_specularColorFactor",pe.FRAGMENT),t.u_specularColorFactor=function(){return e.specularColorFactor},n.addDefine("HAS_SPECULAR_COLOR_FACTOR",void 0,pe.FRAGMENT))}var h8e=new m;function f8e(e,t,n,i,o){let{anisotropyStrength:r,anisotropyRotation:s,anisotropyTexture:a}=e;n.addDefine("USE_ANISOTROPY",void 0,pe.FRAGMENT),l(a)&&!o&&Zd(n,t,a,"u_anisotropyTexture","ANISOTROPY",i);let c=Math.cos(s),d=Math.sin(s);n.addUniform("vec3","u_anisotropy",pe.FRAGMENT),t.u_anisotropy=function(){return m.fromElements(c,d,r,h8e)}}function p8e(e,t,n,i,o){let{clearcoatFactor:r,clearcoatTexture:s,clearcoatRoughnessFactor:a,clearcoatRoughnessTexture:c,clearcoatNormalTexture:d}=e;n.addDefine("USE_CLEARCOAT",void 0,pe.FRAGMENT),l(r)&&r!==Zhe.DEFAULT_CLEARCOAT_FACTOR&&(n.addUniform("float","u_clearcoatFactor",pe.FRAGMENT),t.u_clearcoatFactor=function(){return e.clearcoatFactor},n.addDefine("HAS_CLEARCOAT_FACTOR",void 0,pe.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 Vc={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)"};Vc.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,pe.VERTEX),T8e(n);let i=t.morphTargets.length;for(let a=0;a<i;a++){let c=t.morphTargets[a].attributes,d=c.length;for(let u=0;u<d;u++){let h=c[u],p=h.semantic;p!==ct.POSITION&&p!==ct.NORMAL&&p!==ct.TANGENT||(b8e(e,h,e.attributeIndex,a),e.attributeIndex++)}}E8e(n);let r=e.runtimeNode.morphWeights.length;n.addUniform("float",`u_morphWeights[${r}]`,pe.VERTEX),n.addVertexLines(oB);let s={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=Ft(s,e.uniformMap)};var g8e={attributeString:void 0,functionId:void 0};function b8e(e,t,n,i){let o=e.shaderBuilder;y8e(e,t,n);let r=x8e(t,g8e);C8e(o,r,i)}function y8e(e,t,n){let i={index:n,value:l(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:Ut.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function x8e(e,t){switch(e.semantic){case ct.POSITION:t.attributeString="Position",t.functionId=Vc.FUNCTION_ID_GET_MORPHED_POSITION;break;case ct.NORMAL:t.attributeString="Normal",t.functionId=Vc.FUNCTION_ID_GET_MORPHED_NORMAL;break;case ct.TANGENT:t.attributeString="Tangent",t.functionId=Vc.FUNCTION_ID_GET_MORPHED_TANGENT;break;default:break}return t}function C8e(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 T8e(e){e.addFunction(Vc.FUNCTION_ID_GET_MORPHED_POSITION,Vc.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,pe.VERTEX),e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_POSITION,["vec3 morphedPosition = position;"]),e.addFunction(Vc.FUNCTION_ID_GET_MORPHED_NORMAL,Vc.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,pe.VERTEX),e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_NORMAL,["vec3 morphedNormal = normal;"]),e.addFunction(Vc.FUNCTION_ID_GET_MORPHED_TANGENT,Vc.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,pe.VERTEX),e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_TANGENT,["vec3 morphedTangent = tangent;"])}function E8e(e){e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_POSITION,["return morphedPosition;"]),e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_NORMAL,["return morphedNormal;"]),e.addFunctionLines(Vc.FUNCTION_ID_GET_MORPHED_TANGENT,["return morphedTangent;"])}var rB=Vc;var Q5n=y(x(),1);var Ghe={name:"PickingPipelineStage"};Ghe.process=function(e,t,n){let i=n.context,o=e.runtimeNode,r=e.shaderBuilder,s=e.model,a=o.node.instances;if(e.hasPropertyTable)S8e(e,t,a,i);else if(l(a))_8e(e,i);else{let c=Lhe(e),d=i.createPickId(c);s._pipelineResources.push(d),s._pickIds.push(d),r.addUniform("vec4","czm_pickColor",pe.FRAGMENT);let u=e.uniformMap;u.czm_pickColor=function(){return d.color},e.pickId="czm_pickColor"}};function Lhe(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(Nr.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 S8e(e,t,n){let i=e.model,o,r,s=i.featureIdLabel,a=i.instanceFeatureIdLabel;l(i.featureTableId)?o=i.featureTableId:l(n)?(r=It.getFeatureIdsByLabel(n.featureIds,a),o=r.propertyTableId):(r=It.getFeatureIdsByLabel(t.featureIds,s),o=r.propertyTableId);let c=i.featureTables[o];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",pe.FRAGMENT);let u=c.batchTexture;e.uniformMap.model_pickTexture=function(){return u.pickTexture??u.defaultTexture},e.pickId="((selectedFeature.id < int(model_featuresLength)) ? tex
// 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 Z8e=new re,Fhe={name:"PointCloudStylingPipelineStage"};Fhe.process=function(e,t,n){let i=e.shaderBuilder,o=e.model,r=o.style,s=o.structuralMetadata,a=l(s)?s.propertyAttributes:void 0,c=l(o.featureTableId)&&o.featureTables[o.featureTableId].featuresLength>0,d=!l(a)&&c;if(l(r)&&!d){let b=L8e(a),C=W8e(r,b);F8e(i,C);let E=B8e(C).indexOf("normalMC")>=0,S=It.getAttributeBySemantic(t,ct.NORMAL);if(E&&!S)throw new me("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,pe.VERTEX),C.styleTranslucent&&(e.alphaOptions.pass=Ge.TRANSLUCENT)}let u=o.pointCloudShading;u.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,pe.VERTEX),u.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,pe.VERTEX);let h,p,A;Nr.is3DTiles(o.type)&&(p=!0,h=o.content,A=h.tile.refine===mr.ADD),i.addUniform("vec4","model_pointCloudParameters",pe.VERTEX),i.addVertexLines(aB);let f=e.uniformMap;f.model_pointCloudParameters=function(){let b=Z8e,C=1;p&&(C=A?5:h.tileset.memoryAdjustedScreenSpaceError),b.x=u.maximumAttenuation??C,b.x*=n.pixelRatio;let T=R8e(e,t,u,h);b.y=T*u.geometricErrorScale;let E=n.context,S=n.camera.frustum,I;return n.mode===se.SCENE2D||S instanceof bn?I=Number.POSITIVE_INFINITY:I=E.drawingBufferHeight/n.camera.frustum.sseDenominator,b.z=I,p&&(b.w=h.tileset.timeSinceLoad),b}};var Whe=new m;function R8e(e,t,n,i){if(l(i)){let u=i.tile.geometricError;if(u>0)return u}if(l(n.baseResolution))return n.baseResolution;let o=It.getAttributeBySemantic(t,ct.POSITION),r=o.count,s=e.runtimeNode.transform,a=m.subtract(o.max,o.min,Whe);a=F.multiplyByPointAsVector(s,a,Whe);let c=a.x*a.y*a.z;return L.cbrt(c/r)}var V8e={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},G8e={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function L8e(e){let t=He(G8e);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 Kj="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function W8e(e,t){let n=V8e,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction(`getColorFromStyle(${Kj})`,t,i),n.showStyleFunction=e.getShowShaderFunction(`getShowFromStyle(${Kj})`,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction(`getPointSizeFromStyle(${Kj})`,t,i),n.styleTranslucent=l(n.colorStyleFunction)&&i.translucent,n}function F8e(e,t){let n=t.colorStyleFunction;l(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,pe.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));let i=t.showStyleFunction;l(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,pe.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,pe.VERTEX),e.addVertexLines(o))}function jj(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 B8e(e){let t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,o=[];return l(t)&&jj(t,o),l(n)&&jj(n,o),l(i)&&jj(i,o),o}var cB=Fhe;var SQn=y(x(),1);var pQn=y(x(),1),lB=`void primitiveOutlineStage() { v_outlineCoordinates = a_outlineCoordinates;}`;var gQn=y(x(),1),dB=`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 Bhe={name:"PrimitiveOutlinePipelineStage"};Bhe.process=function(e,t,n){let i=e.shaderBuilder,o=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,pe.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");let r=t.outlineCoordinates,s={index:e.attributeIndex++,vertexBuffer:r.buffer,componentsPerAttribute:Ut.getNumberOfComponents(r.type),componentDatatype:r.componentDatatype,offsetInBytes:r.byteOffset,strideInBytes:r.byteStride,normalize:r.normalized};e.attributes.push(s),i.addUniform("sampler2D","model_outlineTexture",pe.FRAGMENT);let a=EC.createTexture(n.context);o.model_outlineTexture=function(){return a};let c=e.model;i.addUniform("vec4","model_outlineColor",pe.FRAGMENT),o.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",pe.FRAGMENT),o.model_showOutline=function(){return c.showOutline},i.addVertexLines(lB),i.addFragmentLines(dB)};var uB=Bhe;var GQn=y(x(),1);var whe={name:"PrimitiveStatisticsPipelineStage",_countGeometry:Nhe,_count2DPositions:Phe,_countMorphTargetAttributes:Xhe,_countMaterialTextures:Yhe,_countFeatureIdTextures:Mhe,_countBinaryMetadata:vhe};whe.process=function(e,t,n){let i=e.model,o=i.statistics;Nhe(o,t),Phe(o,e.runtimePrimitive),Xhe(o,t),Yhe(o,t.material),Mhe(o,t.featureIds),vhe(o,i)};function Nhe(e,t){let n=l(t.indices)?t.indices.count:It.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===We.POINTS?e.pointsLength+=n:We.isTriangles(i)&&(e.trianglesLength+=w8e(i,n));let o=t.attributes,r=o.length;for(let c=0;c<r;c++){let d=o[c];if(l(d.buffer)){let u=l(d.typedArray);e.addBuffer(d.buffer,u)}}let s=t.outlineCoordinates;l(s)&&l(s.buffer)&&e.addBuffer(s.buffer,!1);let a=t.indices;if(l(a)&&l(a.buffer)){let c=l(a.typedArray);e.addBuffer(a.buffer,c)}}function w8e(e,t){switch(e){case We.TRIANGLES:return t/3;case We.TRIANGLE_STRIP:case We.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function Phe(e,t){let n=t.positionBuffer2D;l(n)&&e.addBuffer(n,!0)}function Xhe(e,t){let n=t.morphTargets;if(!l(n))return;let i=!1,o=n.length;for(let r=0;r<o;r++){let s=n[r].attributes,a=s.length;for(let c=0;c<a;c++){let d=s[c];l(d.buffer)&&e.addBuffer(d.buffer,i)}}}function Yhe(e,t){let n=N8e(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 N8e(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 Mhe(e,t){let n=t.length;for(let i=0;i<n;i++){let o=t[i];if(o instanceof Tn.FeatureIdTexture){let r=o.textureReader;l(r.texture)&&e.addTexture(r.texture)}}}function vhe(e,t){let n=t.structuralMetadata;l(n)&&(P8e(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 s=i[r];e.addBatchTexture(s.batchTexture)}}function P8e(e,t){let n=t.propertyTextures;if(!l(n))return;let i=n.length;for(let o=0;o<i;o++){let s=n[o].properties;for(let a in s)if(s.hasOwnProperty(a)){let d=s[a].textureReader;l(d.texture)&&e.addTexture(d.texture)}}}var mB=whe;var QQn=y(x(),1);var X8e=new F,Y8e=new F,Uhe={name:"SceneMode2DPipelineStage"};Uhe.process=function(e,t,n){let i=It.getAttributeBySemantic(t,ct.POSITION),o=e.shaderBuilder,r=e.model,s=r.sceneGraph.computedModelMatrix,a=e.runtimeNode.computedTransform,c=F.multiplyTransformation(s,a,X8e),d=U8e(e,c,n),u=e.runtimePrimitive;u.boundingSphere2D=d;let h=e.runtimeNode.node.instances;if(l(h))return;if(l(i.typedArray)){let b=Q8e(i,c,d,n);u.positionBuffer2D=b,r._modelResources.push(b),i.typedArray=void 0}o.addDefine("USE_2D_POSITIONS",void 0,pe.VERTEX),o.addUniform("mat4","u_modelView2D",pe.VERTEX);let p=F.fromTranslation(d.center,new F),A=n.context,f={u_modelView2D:function(){return F.multiplyTransformation(A.uniformState.view,p,Y8e)}};e.uniformMap=Ft(f,e.uniformMap)};var M8e=new m,v8e=new m;function U8e(e,t,n){let i=F.multiplyByPoint(t,e.positionMin,M8e),o=so.computeActualEllipsoidPositi
{ 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 LC={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};LC.process=function(e,t){let n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,pe.VERTEX),z8e(n,t);let i=e.runtimeNode,o=i.computedJointMatrices;n.addUniform("mat4",`u_jointMatrices[${o.length}]`,pe.VERTEX),n.addVertexLines(fB);let r={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=Ft(r,e.uniformMap)};function O8e(e){let t=-1,n=e.attributes,i=n.length;for(let o=0;o<i;o++){let r=n[o];(r.semantic===ct.JOINTS||r.semantic===ct.WEIGHTS)&&(t=Math.max(t,r.setIndex))}return t}function z8e(e,t){e.addFunction(LC.FUNCTION_ID_GET_SKINNING_MATRIX,LC.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,pe.VERTEX),e.addFunctionLines(LC.FUNCTION_ID_GET_SKINNING_MATRIX,["mat4 skinnedMatrix = mat4(0);"]);let i,o,r=["x","y","z","w"],s=O8e(t);for(i=0;i<=s;i++)for(o=0;o<=3;o++){let c=r[o],d=`skinnedMatrix += a_weights_${i}.${c} * u_jointMatrices[int(a_joints_${i}.${c})];`;e.addFunctionLines(LC.FUNCTION_ID_GET_SKINNING_MATRIX,[d])}e.addFunctionLines(LC.FUNCTION_ID_GET_SKINNING_MATRIX,["return skinnedMatrix;"])}var pB=LC;var sOn=y(x(),1);var tOn=y(x(),1),AB=`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 khe={name:"VerticalExaggerationPipelineStage"},H8e=new M;khe.process=function(e,t,n){let{shaderBuilder:i,uniformMap:o}=e;i.addVertexLines(AB),i.addDefine("HAS_VERTICAL_EXAGGERATION",void 0,pe.VERTEX),i.addUniform("vec2","u_verticalExaggerationAndRelativeHeight",pe.VERTEX),o.u_verticalExaggerationAndRelativeHeight=function(){return M.fromElements(n.verticalExaggeration,n.verticalExaggerationRelativeHeight,H8e)}};var gB=khe;var TOn=y(x(),1);var uOn=y(x(),1);var qj={};function J8e(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 K8e(e,t){let n=t.length,i=Ue.createTypedArray(e,n*2),o=0;for(let r=0;r<n;r+=3){let s=t[r],a=t[r+1],c=t[r+2];i[o++]=s,i[o++]=a,i[o++]=a,i[o++]=c,i[o++]=c,i[o++]=s}return i}function j8e(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 q8e(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),s=0;r[s++]=t[0],r[s++]=t[1];for(let a=0;a<i;a++){let c=t[a],d=t[a+1],u=t[a+2];r[s++]=d,r[s++]=u,r[s++]=u,r[s++]=c}return r}function $8e(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 e7e(e,t){let i=t.length-2,o=2+i*4,r=Ue.createTypedArray(e,o),s=0,a=t[0];r[s++]=a,r[s++]=t[1];for(let c=0;c<i;c++){let d=t[c+1],u=t[c+2];r[s++]=d,r[s++]=u,r[s++]=u,r[s++]=a}return r}qj.createWireframeIndices=function(e,t,n){let i=l(n);if(e===We.TRIANGLES)return i?K8e(t,n):J8e(t);if(e===We.TRIANGLE_STRIP)return i?q8e(t,n):j8e(t);if(e===We.TRIANGLE_FAN)return i?e7e(t,n):$8e(t)};qj.getWireframeIndicesCount=function(e,t){return e===We.TRIANGLES?t*2:e===We.TRIANGLE_STRIP||e===We.TRIANGLE_FAN?2+(t-2)*4:t};var v_=qj;var Qhe={name:"WireframePipelineStage"};Qhe.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,pe.FRAGMENT);let o=e.model,r=t7e(t,e.indices,n);o._pipelineResources.push(r),e.wireframeIndexBuffer=r,o.statistics.addBuffer(r,!1);let a=e.primitiveType,c=e.count;e.primitiveType=We.LINES,e.count=v_.getWireframeIndicesCount(a,c)};function t7e(e,t,n){let o=It.getAttributeBySemantic(e,ct.POSITION).count,r=n.context.webgl2,s;if(l(t)){let u=t.buffer,h=t.count;l(u)&&r?(s=u.sizeInBytes===h?new Uint8Array(h):Ue.createTypedArray(o,h),u.getBufferData(s)):s=t.typedArray}let a=e.primitiveType,c=v_.createWireframeIndices(a,o,s),d=Ue.fromSizeInBytes(c.BYTES_PER_ELEMENT);return it.createIndexBuffer({context:n.context,typedArray:c,usage:Be.STATIC_DRAW,indexDatatype:d})}var bB=Qhe;function Ohe(e){e=e??Q.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=[]}Ohe.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=gA.getCache(o._marsOptions.customShaders);for(let _ in g)if(Object.prototype.hasOwnProperty.call(g,_)){r=g[_];break}}let s=o.style,a=e.context.webgl2,d=e.mode!==se.SCENE3D&&!e.scene3DOnly&&o._projectTo2D,u=e.verticalExaggeration!==1&&o.hasVerticalExaggeration,h=l(n.morphTargets)&&n.morphTargets.length>0,p=l(i.skin),A=l(o.imageryLayers),f=l(r),C=!(f&&l(r.fragmentShaderText))||r.mode!==fg.REPLACE_MATERIAL,T=It.hasQuantizedAttributes(n.attributes),E=o.debugWireframe&&We.isTriangles(n.primitiveType)&&(o._enableDebugWireframe||a),S=o.pointCloudShading,I=l(S)&&S.attenuation,R=l(S)&&S.backFaceCulling,V=n.primitiveType===We.POINTS&&(l(s)||I||R),W=o._enableShowOutline&&l(n.outlineCoordinates),B=l(n.edgeVisibility),N=n7e(o,i,n),P=l(o.classificationType);d&&t.push(hB),t.push(W2),E&&t.push(bB),P&&t.push(u2),h&&t.push(rB),p&&t.push(pB),V&&t.push(cB),T&&t.push(E2),A&&(W?_t("outlines-and-draping","Primitive outlines disable imagery draping"):t.push(j2))
if(model_silhouettePass) { color = czm_gammaCorrect(model_silhouetteColor); }}`;var yzn=y(x(),1),EB=`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 a9={name:"ModelSilhouettePipelineStage"};a9.silhouettesLength=0;a9.process=function(e,t,n){l(t._silhouetteId)||(t._silhouetteId=++a9.silhouettesLength);let i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,pe.BOTH),i.addVertexLines(EB),i.addFragmentLines(TB),i.addUniform("vec4","model_silhouetteColor",pe.FRAGMENT),i.addUniform("float","model_silhouetteSize",pe.VERTEX),i.addUniform("bool","model_silhouettePass",pe.BOTH);let o={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=Ft(o,e.uniformMap),e.hasSilhouette=!0};var SB=a9;var Fzn=y(x(),1);var Rzn=y(x(),1),_B=`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 c9={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};c9.process=function(e,t,n){let i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,pe.FRAGMENT),i.addFragmentLines(_B);let o={};i.addUniform("float",c9.SPLIT_DIRECTION_UNIFORM_NAME,pe.FRAGMENT),o[c9.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=Ft(o,e.uniformMap)};var IB=c9;var Nzn=y(x(),1);function s7e(e,t){this.model=e.model,this.shaderBuilder=e.shaderBuilder.clone(),this.uniformMap=He(e.uniformMap),this.alphaOptions=He(e.alphaOptions),this.renderStateOptions=He(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 ZB=s7e;var Hzn=y(x(),1);var Mzn=y(x(),1);function a7e(e){e=e??Q.EMPTY_OBJECT,this.lightingModel=e.lightingModel??Cp.UNLIT}var RB=a7e;function c7e(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=He(e.uniformMap),this.alphaOptions=He(e.alphaOptions),this.renderStateOptions=He(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:It.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;let i=It.getPositionMinMax(n,this.runtimeNode.instancingTranslationMin,this.runtimeNode.instancingTranslationMax);this.positionMin=m.clone(i.min,new m),this.positionMax=m.clone(i.max,new m),this.boundingSphere=ue.fromCornerPoints(this.positionMin,this.positionMax,new ue),this.lightingOptions=new RB,this.pickId=void 0}var VB=c7e;var K3n=y(x(),1);var l3n=y(x(),1);function t4(e){e=e??Q.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!==ti.CESIUM_3D_TILE,this._classifies3DTiles=o!==ti.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[],m7e(this)}function l7e(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:Vt.KEEP,zFail:Vt.DECREMENT_WRAP,zPass:Vt.KEEP},backFunction:e,backOperation:{fail:Vt.KEEP,zFail:Vt.INCREMENT_WRAP,zPass:Vt.KEEP},reference:Jt.CESIUM_3D_TILE_MASK,mask:Jt.CESIUM_3D_TILE_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:ec.LESS_OR_EQUAL},depthMask:!1}}var d7e={stencilTest:{enabled:!0,frontFunction:ni.NOT_EQUAL,frontOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},backFunction:ni.NOT_EQUAL,backOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},reference:0,mask:Jt.CLASSIFICATION_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:ln.PRE_MULTIPLIED_ALPHA_BLEND},u7e={stencilTest:{enabled:!0,frontFunction:ni.NOT_EQUAL,frontOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},backFunction:ni.NOT_EQUAL,backOperation:{fail:Vt.ZERO,zFail:Vt.ZERO,zPass:Vt.ZERO},reference:0,mask:Jt.CLASSIFICATION_MASK},stencilMask:Jt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},Khe=[];function m7e(e){let t=e._command,n=Khe;if(e._useDebugWireframe){t.pass=Ge.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=GB(e,n,e._commandListDebugWireframe);let r=e._commandListDebugWirefr
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 B3n=y(x(),1),wB=`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 jhe(){}jhe.buildModelDrawCommand=function(e,t){let n=e.shaderBuilder,i=G7e(e,n,t),o=L7e(e,i,t),r=e.model;return l(r.classificationType)?new LB({primitiveRenderResources:e,command:o}):new FB({primitiveRenderResources:e,command:o})};function G7e(e,t,n){t.addVertexLines(BB),t.addFragmentLines(wB);let i=e.model,o=t.buildShaderProgram(n.context);return i._pipelineResources.push(o),o}function L7e(e,t,n){let i=W7e(e),o=new kn({context:n.context,indexBuffer:i,attributes:e.attributes}),r=e.model;r._pipelineResources.push(o);let s=e.alphaOptions.pass,a=r.sceneGraph,c=n.mode===se.SCENE3D,d,u;if(!c&&!n.scene3DOnly&&r._projectTo2D)d=F.multiplyTransformation(a._computedModelMatrix,e.runtimeNode.computedTransform,new F),u=e.runtimePrimitive.boundingSphere2D;else{let T=c?a._computedModelMatrix:a._computedModelMatrix2D;d=F.multiplyTransformation(T,e.runtimeNode.computedTransform,new F),u=ue.transform(e.boundingSphere,d)}let h=He(Qe.fromCache(e.renderStateOptions),!0);h.cull.face=It.getCullFace(d,e.primitiveType),h=Qe.fromCache(h);let p=l(r.classificationType),A=p?!1:Vn.castShadows(r.shadows),f=p?!1:Vn.receiveShadows(r.shadows),b=p?void 0:e.pickId,C=new ot({boundingVolume:u,modelMatrix:d,uniformMap:e.uniformMap,renderState:h,vertexArray:o,shaderProgram:t,cull:r.cull,pass:s,count:e.count,owner:r,pickId:b,pickMetadataAllowed:!0,instanceCount:e.instanceCount,primitiveType:e.primitiveType,debugShowBoundingVolume:r.debugShowBoundingVolume,castShadows:A,receiveShadows:f});return r._marsOptions?.updateDrawCommand&&r._marsOptions.updateDrawCommand(C),C}function W7e(e){let t=e.wireframeIndexBuffer;if(l(t))return t;let n=e.indices;if(l(n))return n.buffer}var NB=jhe;function tl(e){e=e??Q.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=F.clone(F.IDENTITY),this._computedModelMatrix2D=F.clone(F.IDENTITY),this._axisCorrectionMatrix=It.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new F),this._runtimeArticulations={},F7e(this)}Object.defineProperties(tl.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 F7e(e){let t=e._components,n=t.scene,o=e._model.modelMatrix;qhe(e,o);let r=t.articulations,s=r.length,a=e._runtimeArticulations;for(let E=0;E<s;E++){let S=r[E],I=new zF({articulation:S,sceneGraph:e}),R=I.name;a[R]=I}let c=t.nodes,d=c.length;e._runtimeNodes=new Array(d);let h=n.nodes.length,p=F.IDENTITY;for(let E=0;E<h;E++){let S=n.nodes[E],I=$he(e,S,p);e._rootNodes.push(I)}let A=t.skins,f=e._runtimeSkins,b=A.length;for(let E=0;E<b;E++){let S=A[E];f.push(new xB({skin:S,sceneGraph:e}))}let C=e._skinnedNodes,T=C.length;for(let E=0;E<T;E++){let S=C[E],I=e._runtimeNodes[S],V=c[S].skin.index;I._runtimeSkin=f[V],I.updateJointMatrices()}e.applyArticulations()}function qhe(e,t){let n=e._components,i=e._model;e._computedModelMatrix=F.multiplyTransformation(t,n.transform,e._computedModelMatrix),e._computedModelMatrix=F.multiplyTransformation(e._computedModelMatrix,e._axisCorrectionMatrix,e._computedModelMatrix),e._computedModelMatrix=F.multiplyByUniformScale(e._computedModelMatrix,i.computedScale,e._computedModelMatrix)}var B7e=new m;function w7e(e,t){let n=e._computedModelMatrix,i=F.getTranslation(n,B7e);if(!m.equals(i,m.ZERO))e._computedModelMatrix2D=bt.basisTo2D(t.mapProjection,n,e._computedModelMatrix2D);else{let o=e.boundingSphere.center,r=bt.ellipsoidTo2DModelMatrix(t.mapProjection,o,e._computedModelMatrix2D);e._computedModelMatrix2D=F.multiply(r,n,e._computedModelMatrix2D)}e._boundingSphere2D=ue.transform(e._boundingSphere,e._computedModelMatrix2D,e._boundingSphere2D)}function $he(e,t,n){let i=[],o=It.getNodeTransform(t),r=t.children.length;for(let u=0;u<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 HKn=y(x(),1),zB=`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 _jn=y(x(),1);var ejn=y(x(),1);var KKn=y(x(),1),hqe=Object.freeze({NONE:0,LOADING:2,LOADED:3,ERROR:4,FAILED:5}),Ps=hqe;function qh(e){this._billboardCollection=e,this._id=void 0,this._loadState=Ps.NONE,this._loadError=void 0,this._index=-1,this._width=void 0,this._height=void 0,this._hasSubregion=!1,this.dirty=!1}Object.defineProperties(qh.prototype,{loadError:{get:function(){return this._loadError}},loadState:{get:function(){return this._loadState}},ready:{get:function(){return this._loadState===Ps.LOADED}},hasImage:{get:function(){return this._loadState!==Ps.NONE}},id:{get:function(){return this._id}},width:{get:function(){return this._width}},height:{get:function(){return this._height}}});qh.prototype.unload=async function(){this._loadState!==Ps.NONE&&(this._id=void 0,this._loadError=void 0,this._loadState=Ps.NONE,this._index=-1,this._width=void 0,this._height=void 0,this.dirty=!0)};qh.prototype.loadImage=async function(e,t,n,i){if(this._id===e)return;let o=this._billboardCollection,r=o.billboardTextureCache,s=r.get(e);if(l(s)&&t.loadState===Ps.LOADING||t.loadState===Ps.LOADED){qh.clone(s,this);return}l(s)||(s=new qh(o),r.set(e,s)),s._id=this._id=e,s._loadState=this._loadState=Ps.LOADING,s._loadError=this._loadError=void 0;let a,c=this._billboardCollection.textureAtlas;try{a=c.addImage(e,t,n,i),a instanceof Promise&&(a=await a)}catch(u){if(s._loadState=Ps.ERROR,s._loadError=u,this._id!==e)return;this._loadState=Ps.ERROR,this._loadError=u;return}if(!l(a)||a===-1){if(s._loadState=Ps.FAILED,s._index=-1,this._id!==e)return;this._loadState=Ps.FAILED,this._index=-1;return}s._index=a,s._loadState=Ps.LOADED;let d=c.rectangles[a];s._width=d.width,s._height=d.height,this._id===e&&(this._index=a,this._loadState=Ps.LOADED,this._width=d.width,this._height=d.height,this.dirty=!0)};qh.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)};qh.prototype.loadImageSubRegion=async function(e,t,n){let i;try{this._loadState=Ps.LOADING,i=await n}catch(o){this._loadState=Ps.ERROR,this._loadError=o;return}this._id===e&&(this._loadState=Ps.LOADED,this.setImageSubRegion(i,t))};qh.prototype.setImageSubRegion=function(e,t){if(this._index!==e){if(!l(e)||e===-1){this._loadState=Ps.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}};qh.prototype.computeTextureCoordinates=function(e){return this._billboardCollection.textureAtlas.computeTextureCoordinates(this._index,e)};qh.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 yg=qh;function Li(e,t){e=e??Q.EMPTY_OBJECT;let n=e.translucencyByDistance,i=e.pixelOffsetScaleByDistance,o=e.scaleByDistance,r=e.distanceDisplayCondition;l(n)&&(n=Ot.clone(n)),l(i)&&(i=Ot.clone(i)),l(o)&&(o=Ot.clone(o)),l(r)&&(r=Dt.clone(r)),this._show=e.show??!0,this._position=m.clone(e.position??m.ZERO),this._actualPosition=m.clone(this._position),this._pixelOffset=M.clone(e.pixelOffset??M.ZERO),this._translate=new M(0,0),this._eyeOffset=m.clone(e.eyeOffset??m.ZERO),this._heightReference=e.heightReference??rt.NONE,this._verticalOrigin=e.verticalOrigin??Hn.CENTER,this._horizontalOrigin=e.horizontalOrigin??Bi.CENTER,this._scale=e.scale??1,this._color=U.clone(e.color??U.WHITE),this._rotation=e.rotation??0,this._alignedAxis=m.clone(e.alignedAxis??m.ZERO),this._width=e.width,this._height=e.height,this._scaleByDistance=o,this._translucencyByDistance=n,this._pixelOffsetScaleByDistance=i,this._sizeInMeters=e.sizeInMeters??!
in vec2 v_textureCoordinates; void main() { out_FragColor = texture(billboard_texture, v_textureCoordinates); } `,{uniformMap:{billboard_texture:function(){return e.textureAtlas.texture}}});return i.pass=Ge.OVERLAY,i}var Hqe=[];Gm.prototype.update=function(e){if(g4(this),!this.show)return;let t=e.context;if(!t.instancedArrays||!(Bt.maximumVertexTextureImageUnits>0))throw new fe("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 W=0;W<i;++W){let B=n[W];l(B.loadError)&&(console.error(`Error loading image for billboard: ${B.loadError}`),B.image=void 0),B.textureDirty&&this._updateBillboard(B,NC),B.show&&(o=o&&B.ready)}let r=this._textureAtlas;if(e.afterRender.push(()=>{if(!this.isDestroyed())return r.update(e.context)}),!l(r.texture))return;Qqe(this,e),n=this._billboards,i=n.length;let s=this._billboardsToUpdate,a=this._billboardsToUpdateIndex,c=this._propertiesChanged,d=r.guid,u=this._createVertexArray||this._textureAtlasGUID!==d;this._textureAtlasGUID=d;let h,p=e.passes,A=p.pick;if(u||!A&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let W=0;W<A4;++W)c[W]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),i>0){this._vaf=Xqe(t,i,this._buffersUsage,this._batchTable,this._sdf),h=this._vaf.writers;for(let W=0;W<i;++W){let B=this._billboards[W];B._dirty=!1,B.textureDirty=!1,kqe(this,e,h,B)}this._vaf.commit(yfe(t))}this._billboardsToUpdateIndex=0}else if(a>0){let W=Hqe;W.length=0,(c[HB]||c[Fqe]||c[Wqe])&&W.push(Gfe),(c[NC]||c[xfe]||c[Gqe]||c[Lqe]||c[Vqe])&&(W.push(Wfe),W.push(p4)),(c[NC]||c[Bqe]||c[Sfe])&&(W.push(Ffe),W.push(f4)),(c[NC]||c[Tfe])&&W.push(f4),(c[NC]||c[Cfe])&&W.push(p4),c[Efe]&&W.push(Bfe),c[_fe]&&W.push(wfe),(c[Ife]||c[wqe]||c[NC]||c[HB])&&W.push(Nfe),(c[NC]||c[HB])&&W.push(Pfe),c[Zfe]&&W.push(Xfe),c[Rfe]&&W.push(Yfe);let B=W.length;if(h=this._vaf.writers,a/i>.1){for(let N=0;N<a;++N){let P=s[N];P._dirty=!1,P.textureDirty=!1;for(let g=0;g<B;++g)W[g](this,e,h,P)}this._vaf.commit(yfe(t))}else{for(let N=0;N<a;++N){let P=s[N];P._dirty=!1,P.textureDirty=!1;for(let g=0;g<B;++g)W[g](this,e,h,P);this._vaf.subCommit(P._index,1)}this._vaf.endSubCommits()}this._billboardsToUpdateIndex=0}if(a>i*1.5&&(s.length=i),!l(this._vaf)||!l(this._vaf.va))return;this._boundingVolumeDirty&&(this._boundingVolumeDirty=!1,ue.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let f,b=F.IDENTITY;e.mode===se.SCENE3D?(b=this.modelMatrix,f=ue.clone(this._baseVolumeWC,this._boundingVolume)):f=ue.clone(this._baseVolume2D,this._boundingVolume),Oqe(this,e,f);let C=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,C){this._blendOption===$o.OPAQUE||this._blendOption===$o.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=Qe.fromCache({depthTest:{enabled:!0,func:ne.LESS},depthMask:!0}):this._rsOpaque=void 0;let W=this._blendOption===$o.TRANSLUCENT;this._blendOption===$o.TRANSLUCENT||this._blendOption===$o.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=Qe.fromCache({depthTest:{enabled:!0,func:W?ne.LEQUAL:ne.LESS},depthMask:W,blending:ln.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let T,E,S,I,R;if(C||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){T=zB,E=OB,R=["INSTANCED"],l(this._batchTable)&&(R.push("VECTOR_TILE"),T=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(T),E=this._batchTable.getFragmentShaderCallback(
`),n="";for(let i=0;i<t.length;i++){let o=t[i],r=Ofe.test(o.charAt(0)),s=o$e(o,Ofe),a=0,c="";for(let d=0;d<s.length;++d){let u=s[d],h=u.Type===Hs.BRACKETS?s$e(u.Word):r$e(u.Word);r?u.Type===Hs.RTL?(c=h+c,a=0):u.Type===Hs.LTR?(c=qB(c,a,u.Word),a+=u.Word.length):(u.Type===Hs.WEAK||u.Type===Hs.BRACKETS)&&(u.Type===Hs.WEAK&&s[d-1].Type===Hs.BRACKETS?c=h+c:s[d-1].Type===Hs.RTL?(c=h+c,a=0):s.length>d+1?s[d+1].Type===Hs.RTL?(c=h+c,a=0):(c=qB(c,a,u.Word),a+=u.Word.length):c=qB(c,0,h)):u.Type===Hs.RTL?c=qB(c,a,h):u.Type===Hs.LTR?(c+=u.Word,a=c.length):(u.Type===Hs.WEAK||u.Type===Hs.BRACKETS)&&(d>0&&s[d-1].Type===Hs.RTL?s.length>d+1?s[d+1].Type===Hs.RTL?c=qB(c,a,h):(c+=u.Word,a=c.length):c+=u.Word:(c+=u.Word,a=c.length))}n+=c,i<t.length-1&&(n+=``)}return n}var D0=ef;var qfe=y(Hfe(),1);function u$e(){this.dimensions=void 0,this.billboardTexture=void 0,this.billboard=void 0}var m$e=1.2,Jfe="ID_WHITE_PIXEL",y4=new M(4,4),h$e=new nt(1,1,1,1);function f$e(e,t){let n=t._backgroundBillboardTexture;if(!n.hasImage){let o=document.createElement("canvas");o.width=y4.x,o.height=y4.y;let r=o.getContext("2d");r.fillStyle="#fff",r.fillRect(0,0,o.width,o.height),n.loadImage(Jfe,o),n.addImageSubRegion(Jfe,h$e)}let i=e.add({collection:t});return i.setImageTexture(n),i._positionFromParent=!0,i._labelTranslate=new M,i}var Cg={};function p$e(e,t,n,i,o,r){return Cg.font=t,Cg.fillColor=n,Cg.strokeColor=i,Cg.strokeWidth=o,Cg.padding=Ba.PADDING,Cg.fill=r===hr.FILL||r===hr.FILL_AND_OUTLINE,Cg.stroke=r===hr.OUTLINE||r===hr.FILL_AND_OUTLINE,Cg.backgroundColor=U.BLACK,MC(e,Cg)}function x4(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 A$e=new qfe.default,g$e=/\s/;function b$e(e,t){let n=t._renderedText,i=A$e.splitGraphemes(n),o=i.length,r=t._glyphs,s=r.length;if(t._relativeSize=t._fontSize/Ba.FONT_SIZE,o<s)for(let p=o;p<s;++p)x4(e,r[p]);r.length=o;let a=t._backgroundBillboard,c=e._backgroundBillboardCollection;t._showBackground&&!l(a)&&(a=f$e(c,e),t._backgroundBillboard=a),y$e(c,t,a);let d=e._glyphBillboardCollection,u=d.billboardTextureCache,h=e._textDimensionsCache;for(let p=0;p<o;++p){let A=i[p],f=t._verticalOrigin,b=JSON.stringify([A,t._fontFamily,t._fontStyle,t._fontWeight,+f]),C=h[b],T=u.get(b);if(!l(T)||!l(C)){T=new yg(d),u.set(b,T);let R=`${t._fontStyle} ${t._fontWeight} ${Ba.FONT_SIZE}px ${t._fontFamily}`,V=p$e(A,R,U.WHITE,U.WHITE,0,hr.FILL);if(C=V.dimensions,h[b]=C,V.width>0&&V.height>0&&!g$e.test(A)){let W=(0,jfe.default)(V,{cutoff:Ba.CUTOFF,radius:Ba.RADIUS}),B=V.getContext("2d"),N=V.width,P=V.height,g=B.getImageData(0,0,N,P);for(let _=0;_<N;_++)for(let Z=0;Z<P;Z++){let G=Z*N+_,w=W[G]*255,X=G*4;g.data[X+0]=w,g.data[X+1]=w,g.data[X+2]=w,g.data[X+3]=w}B.putImageData(g,0,0),T.loadImage(b,V)}}let E=r[p];if(l(E)||(E=new u$e,E.dimensions=C,E.billboardTexture=T,r[p]=E),E.billboardTexture.id!==b&&(E.billboardTexture=T,E.dimensions=C),!T.hasImage){x4(e,E);continue}let S=E.billboard,I=e._spareBillboards;l(S)||(I.length>0?S=I.pop():(S=d.add({collection:e}),S._labelDimensions=new M,S._labelTranslate=new M,S._positionFromParent=!0),E.billboard=S),S.setImageTexture(T),S.show=t._show,S.position=t._position,S.eyeOffset=t._eyeOffset,S.pixelOffset=t._pixelOffset,S.horizontalOrigin=Bi.LEFT,S.verticalOrigin=t._verticalOrigin,S.heightReference=t._heightReference,l(t._clampedPosition)&&(S._clampedPosition=t._clampedPosition),S.scale=t.totalScale,S.pickPrimitive=t,S.id=t._id,S.translucencyByDistance=t._translucencyByDistance,S.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,S.scaleByDistance=t._scaleByDistance,S.distanceDisplayCondition=t._distanceDisplayCondition,S.disableDepthTestDistance=t._disableDepthTestDistance,S._batchIndex=t._batchIndex,S.outlineColor=t.outlineColor,t.style===hr.FILL_AND_OUTLINE?(S.color=t._fillColor,S.outlineWidth=t.outlineWidth):t.style===hr.FILL?(S.color=t._fillColor,S.outlineWidth=0):t.style===hr.OUTLINE&&(S.color=U.TRANSPARENT,S.outlineWidth=t.outlineWidth)}t._repositionAllGlyphs=!0}function y$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=Bi.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 Kfe(e,t,n){return t===Bi.CENTER?-e/2:t===Bi.RIGHT?-(e+n.x):n.x}var Pr=new M,x$e=new M;function C$e(e){let t=e._glyphs,n=e._renderedText,i=0,o=0,r=[],s=Number.NEGATIVE_INFINITY,a=0,c=1,d=t.length,u=e._backgroundBillboard,h=M.clone(l(u)?e._backgroundPadding:M.ZERO,x$e);h.x/=e._relativeSize,h.y/=e._relativeSize;for(let N=0;N<d;++N){if(n.charAt(N)===``){r.push(i),++c,i=0;continue}let g=t[N].dimensions;l(g)&&(a=Math.max(a,g.height-g.descent),s=Math.max(s,g.descent),i+=g.width-g.minx,N<d-1&&(i+=t[N+1].dimensions.minx),o=Math.max(o,i))}r.push(i);let p=a+s,A=e.totalScale,f=e._horizontalOrigin,b=e._verticalOrigin,C=0,T=r[C],E=Kfe(T,f,h),S=(l(e._lineHeight)?e._lineHeight:m$e*e._fontSize)/e._relativeSize,I=S*(c-1),R=o,V=p+I;l(u)&&(R+=h.x*2,V+=h.y*2,u._labelHorizontalOrigin=f),Pr.x=E*A,Pr.y=0;let W=!0,B=0;for(let N=0;N<d;++N){if(n.charAt(N)===``){++C,B+=S,T=r[C],E=Kfe(T,f,h),Pr.x=E*A,W=!0;continue}let P=t[N],g=P.dimensions;if(l(g)&&(b===Hn.TOP?(Pr.y=g.height-a-h.y,Pr.y+=Ba.PADDING):b===Hn.CENTER?Pr.y=(I+g.height-a)/2:b===Hn.BASELINE?(Pr.y=I,Pr.y-=Ba.PADDING):(Pr.y=I+s+h.y,Pr.y-=Ba.PADDING),Pr.y=(Pr.y-g.descent-B)*A,W&&(Pr.x-=Ba.PADDING*A,W=!1),l(P.billboard)&&(P.billboard._setTranslate(Pr),P.billboard._labelDimensions.x=R,P.billboard._labelDimensions.y=V,P.billboard._labelHorizontalOrigin=f,hm(e.heightReference)&&(P.billboard._labelTranslate=M.clone(Pr,P.billboard._labelTranslate))),N<d-1)){let _=t[N+1];Pr.x+=(g.width-g.minx+_.dimensions.minx)*A}}l(u)&&n.split(``).join("").length>0&&(f===Bi.CENTER?E=-o/2-h.x:f===Bi.RIGHT?E=-(o+h.x*2):E=0,Pr.x=E*A,b===Hn.TOP?Pr.y=p-a-s:b===Hn.CENTER?Pr.y=(p-a)/2-s:b===Hn.BASELINE?Pr.y=-h.y-s:Pr.y=0,Pr.y=Pr.y*A,u.width=R,u.height=V,u._setTranslate(Pr),u._labelTranslate=M.clone(Pr,u._labelTranslate))}function $fe(e,t){let n=t._glyphs;for(let i=0,o=n.length;i<o;++i)x4(e,n[i]);l(t._backgroundBillboard)&&(e._backgroundBillboardCollection.remove(t._backgroundBillboard),t._backgroundBillboard=void 0),t._labelCollection=void 0,l(t._removeCallbackFunc)&&t._removeCallbackFunc(),he(t)}function Ep(e){e=e??Q.EMPTY_OBJECT,this._scene=e.scene,this._batchTable=e.batchTable;let t=new yu({scene:this._scene,textureAtlas:new Gx({initialSize:y4}),coarseDepthTestDistance:e.coarseDepthTestDistance,threePointDepthTestDistance:e.threePointDepthTestDistance});this._backgroundBillboardCollection=t,this._backgroundBillboardTexture=new yg(t),this._glyphBillboardCollection=new yu({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=F.clone(e.modelMatrix??F.IDENTITY),this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this.blendOption=e.blendOption??$o.OPAQUE_AND_TRANSLUCENT}Object.defineProperties(Ep.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}}});Ep.prototype.add=function(e){let t=new D0(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};Ep.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),$fe(this,e),!0}return!1};Ep.prototype.removeAll=function(){let e=this._labels;for(let t=0,n=e.length;t<n;++t)$fe(this,e[t]);e.length=0};Ep.prototype.contains=function(e){return l(e)&&e._labelCollection===this};Ep.prototype.get=function(e){return this._labels[e]};Ep.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 s=this._labelsToUpdate[r];if(s.isDestroyed())continue;let a=s._glyphs.length;s._rebindAllGlyphs&&(b$e(this,s),s._rebindAllGlyphs=!1),s._repositionAllGlyphs&&(C$e(s),s._repositionAllGlyphs=!1);let c=s._glyphs.length-a;this._totalGlyphCount+=c}let o=n.length>0?$o.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)};Ep.prototype.isDestroyed=function(){return!1};Ep.prototype.destroy=function(){return this.removeAll(),this._glyphBillboardCollection=this._glyphBillboardCollection.destroy(),this._backgroundBillboardCollection=this._backgroundBillboardCollection.destroy(),he(this)};var Sp=Ep;var Z7n=y(x(),1);var y8n=y(x(),1),$B=`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 D8n=y(x(),1);var L8n=y(x(),1);var Ql={};Ql.numberOfPoints=function(e,t,n){let i=m.distance(e,t);return Math.ceil(i/n)};Ql.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 T$e=new Ae;Ql.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,T$e).height}return i};var E$e=new F,S$e=new m,epe=new m,_$e=new dn(m.UNIT_X,0),tpe=new m,I$e=new dn(m.UNIT_X,0),Z$e=new m,R$e=new m,T4=[];function ipe(e,t,n){let i=T4;i.length=e;let o;if(t===n){for(o=0;o<e;o++)i[o]=t;return i}let s=(n-t)/e;for(o=0;o<e;o++){let a=t+o*s;i[o]=a}return i}var b9=new Ae,g9=new Ae,k0=new m,E4=new m,V$e=new m,C4=new NA,ew=new Sc;function G$e(e,t,n,i,o,r,s,a){let c=i.scaleToGeodeticSurface(e,E4),d=i.scaleToGeodeticSurface(t,V$e),u=Ql.numberOfPoints(e,t,n),h=i.cartesianToCartographic(c,b9),p=i.cartesianToCartographic(d,g9),A=ipe(u,o,r);C4.setEndPoints(h,p);let f=C4.surfaceDistance/u,b=a;h.height=o;let C=i.cartographicToCartesian(h,k0);m.pack(C,s,b),b+=3;for(let T=1;T<u;T++){let E=C4.interpolateUsingSurfaceDistance(T*f,g9);E.height=A[T],C=i.cartographicToCartesian(E,k0),m.pack(C,s,b),b+=3}return b}function L$e(e,t,n,i,o,r,s,a){let c=i.cartesianToCartographic(e,b9),d=i.cartesianToCartographic(t,g9),u=Ql.numberOfPointsRhumbLine(c,d,n);c.height=0,d.height=0;let h=ipe(u,o,r);ew.ellipsoid.equals(i)||(ew=new Sc(void 0,void 0,i)),ew.setEndPoints(c,d);let p=ew.surfaceDistance/u,A=a;c.height=o;let f=i.cartographicToCartesian(c,k0);m.pack(f,s,A),A+=3;for(let b=1;b<u;b++){let C=ew.interpolateUsingSurfaceDistance(b*p,g9);C.height=h[b],f=i.cartographicToCartesian(C,k0),m.pack(f,s,A),A+=3}return A}Ql.wrapLongitude=function(e,t){let n=[],i=[];if(l(e)&&e.length>0){t=t??F.IDENTITY;let o=F.inverseTransformation(t,E$e),r=F.multiplyByPoint(o,m.ZERO,S$e),s=m.normalize(F.multiplyByPointAsVector(o,m.UNIT_Y,epe),epe),a=dn.fromPointNormal(r,s,_$e),c=m.normalize(F.multiplyByPointAsVector(o,m.UNIT_X,tpe),tpe),d=dn.fromPointNormal(r,c,I$e),u=1;n.push(m.clone(e[0]));let h=n[0],p=e.length;for(let A=1;A<p;++A){let f=e[A];if(dn.getPointDistance(d,h)<0||dn.getPointDistance(d,f)<0){let b=hi.lineSegmentPlane(h,f,a,Z$e);if(l(b)){let C=m.multiplyByScalar(s,5e-9,R$e);dn.getPointDistance(a,h)<0&&m.negate(C,C),n.push(m.add(b,C,new m)),i.push(u+1),m.negate(C,C),n.push(m.add(b,C,new m)),u=1}}n.push(m.clone(e[A])),u++,h=f}i.push(u)}return{positions:n,lengths:i}};Ql.generateArc=function(e){l(e)||(e={});let t=e.positions,n=t.length,i=e.ellipsoid??ie.default,o=e.height??0,r=Array.isArray(o);if(n<1)return[];if(n===1){let b=i.scaleToGeodeticSurface(t[0],E4);if(o=r?o[0]:o,o!==0){let C=i.geodeticSurfaceNormal(b,k0);m.multiplyByScalar(C,o,C),m.add(b,C,b)}return[b.x,b.y,b.z]}let s=e.minDistance;if(!l(s)){let b=e.granularity??L.RADIANS_PER_DEGREE;s=L.chordLength(b,i.maximumRadius)}let a=0,c;for(c=0;c<n-1;c++)a+=Ql.numberOfPoints(t[c],t[c+1],s);let d=(a+1)*3,u=new Array(d),h=0;for(c=0;c<n-1;c++){let b=t[c],C=t[c+1],T=r?o[c]:o,E=r?o[c+1]:o;h=G$e(b,C,s,i,T,E,u,h)}T4.length=0;let p=t[n-1],A=i.cartesianToCartographic(p,b9);A.height=r?o[n-1]:o;let f=i.cartographicToCartesian(A,k0);return m.pack(f,u,d-3),u};var npe=new Ae,W$e=new Ae;Ql.generateRhumbArc=function(e){l(e)||(e={});let t=e.positions,n=t.length,i=e.ellipsoid??ie.default,o=e.height??0,r=Array.isArray(o);if(n<1)return[];if(n===1){let T=i.scaleToGeodeticSurface(t[0],E4);if(o=r?o[0]:o,o!==0){let E=i.geodeticSurfaceNormal(T,k0);m.multiplyByScalar(E,o,E),m.add(T,E,T)}return[T.x,T.y,T.z]}let s=e.granularity??L.RADIANS_PER_DEGREE,a=0,c,d=i.cartesianToCartographic(t[0],npe),u;for(c=0;c<n-1;c++)u=i.cartesianToCartographic(t[c+1],W$e),a+=Ql.numberOfPointsRhumbLine(d,u,s),d=Ae.clone(u,npe);let h=(a+1)*3,p=new Array(h),A=0;for(c=0;c<n-1;c++){let T=t[c],E=t[c+1],S=r?o[c]:o,I=r?o[c+1]:o;A=L$e(T,E,s,i,S,I,p,A)}T4.length=0;let f=t[n-1],b=i.cartesianToCartographic(f,b9);b.height=r?o[n-1]:o;let C=i.cartographicToCartesian(b,k0);return m.pack(C,p,h-3),p};Ql.generateCartesianArc=function(
`,this.material.shaderSource,vx]}),r=t.getVertexShaderCallback()($B),s=new ze({defines:i,sources:[Zl,r]});this.shaderProgram=tn.fromCache({context:e,vertexShaderSource:s,fragmentShaderSource:o,attributeLocations:Rd})};function ype(e){return m.dot(m.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(dn.ORIGIN_ZX_PLANE)===qt.INTERSECTING}_p.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===se.SCENE3D||!ype(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 ma=new m,Wm=new m,Fm=new m,x9=new m,H$e=new re,J$e=new M;_p.prototype.write=function(e,t,n,i,o,r,s,a){let c=this.mode,d=a.ellipsoid.maximumRadius*L.PI,u=this.polylines,h=u.length;for(let p=0;p<h;++p){let A=u[p],f=A.width,b=A.show&&f>0,C=A._index,T=this.getSegments(A,a),E=T.positions,S=T.lengths,I=E.length,R=A.getPickId(s).color,V=0,W=0,B;for(let k=0;k<I;++k){k===0?A._loop?B=E[I-2]:(B=x9,m.subtract(E[0],E[1],B),m.add(E[0],B,B)):B=E[k-1],m.clone(B,Wm),m.clone(E[k],ma),k===I-1?A._loop?B=E[1]:(B=x9,m.subtract(E[I-1],E[I-2],B),m.add(E[I-1],B,B)):B=E[k+1],m.clone(B,Fm);let v=S[V];k===W+v&&(W+=v,++V);let D=k-W===0,Y=k===W+S[V]-1;c===se.SCENE2D&&(Wm.z=0,ma.z=0,Fm.z=0),(c===se.SCENE2D||c===se.MORPHING)&&(D||Y)&&d-Math.abs(ma.x)<1&&((ma.x<0&&Wm.x>0||ma.x>0&&Wm.x<0)&&m.clone(ma,Wm),(ma.x<0&&Fm.x>0||ma.x>0&&Fm.x<0)&&m.clone(ma,Fm));let O=D?2:0,J=Y?2:4;for(let te=O;te<J;++te){In.writeElements(ma,e,n),In.writeElements(Wm,e,n+6),In.writeElements(Fm,e,n+12);let z=te-2<0?-1:1;t[o]=k/(I-1),t[o+1]=2*(te%2)-1,t[o+2]=z,t[o+3]=C,n+=18,o+=4}}let N=H$e;N.x=U.floatToByte(R.red),N.y=U.floatToByte(R.green),N.z=U.floatToByte(R.blue),N.w=U.floatToByte(R.alpha);let P=J$e;P.x=f,P.y=b?1:0;let g=c===se.SCENE2D?A._boundingVolume2D:A._boundingVolumeWC,_=In.fromCartesian(g.center,fpe),Z=_.high,G=re.fromElements(_.low.x,_.low.y,_.low.z,g.radius,ppe),w=Ape;w.x=0,w.y=Number.MAX_VALUE;let X=A.distanceDisplayCondition;l(X)&&(w.x=X.near,w.y=X.far),r.setBatchedAttribute(C,0,P),r.setBatchedAttribute(C,1,N),r.attributes.length>2&&(r.setBatchedAttribute(C,2,Z),r.setBatchedAttribute(C,3,G),r.setBatchedAttribute(C,4,w))}};var K$e=new m,j$e=new m,q$e=new m,dpe=new m;_p.prototype.writeForMorph=function(e,t){let n=this.modelMatrix,i=this.polylines,o=i.length;for(let r=0;r<o;++r){let s=i[r],a=s._segments.positions,c=s._segments.lengths,d=a.length,u=0,h=0;for(let p=0;p<d;++p){let A;p===0?s._loop?A=a[d-2]:(A=dpe,m.subtract(a[0],a[1],A),m.add(a[0],A,A)):A=a[p-1],A=F.multiplyByPoint(n,A,j$e);let f=F.multiplyByPoint(n,a[p],K$e),b;p===d-1?s._loop?b=a[1]:(b=dpe,m.subtract(a[d-1],a[d-2],b),m.add(a[d-1],b,b)):b=a[p+1],b=F.multiplyByPoint(n,b,q$e);let C=c[u];p===h+C&&(h+=C,++u);let T=p-h===0,E=p===h+c[u]-1,S=T?2:0,I=E?2:4;for(let R=S;R<I;++R)In.writeElements(f,e,t),In.writeElements(A,e,t+6),In.writeElements(b,e,t+12),t+=18}}};var $$e=new Array(1);_p.prototype.updateIndices=function(e,t,n,i){let o=n.length-1,r=new S4(0,i,this);n[o].push(r);let s=0,a=e[e.length-1],c=0;a.length>0&&(c=a[a.length-1]+1);let d=this.polylines,u=d.length;for(let h=0;h<u;++h){let p=d[h];p._locatorBuckets=[];let A;if(this.mode===se.SCENE3D){A=$$e;let b=p._actualPositions.length;if(b>0)A[0]=b;else continue}else A=p._segments.lengths;let f=A.length;if(f>0){let b=0;for(let C=0;C<f;++C){let T=A[C]-1;for(let E=0;E<T;++E)c+4>L.SIXTY_FOUR_KILOBYTES&&(p._locatorBuckets.push({locator:r,count:b}),b=0,t.push(4),a=[],e.push(a),c=0,r.count=s,s=0,i=0,r=new S4(0,0,this),n[++o]=[r]),a.push(c,c+2,c+1),a.push(c+1,c+2,c+3),b+=6,s+=6,i+=6,c+=4}p._locatorBuckets.push({locator:r,count:b}),c+4>L.SIXTY_FOUR_KILOBYTES&&(t.push(0),a=[],e.push(a),c=0,r.count=s,i=0,s=0,r=new S4(0,0,this),n[++o]=[r])}p._clean()}return r.count=s,i};_p.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 k_={positions:void 0,lengths:void 0},upe=new Array(1),eet=new m,tet=new Ae;_p.prototype.getSegments=function(e,t){let n=e._actualPositions;if(this.mode===se.SCENE3D)return upe[0]=n.le
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 of(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=e.ellipsoid??ie.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(of.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function xet(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,s=2+de.packedLength+ie.packedLength+m.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,de.pack(t,a,c),c+=de.packedLength,ie.pack(o,a,c),c+=ie.packedLength,m.pack(r,a,c),a}var Cet=new $n("createVectorTilePolylines",5),Q_={previousPosition:0,currentPosition:1,nextPosition:2,expandAndWidth:3,a_batchId:4};function Tet(e,t){if(l(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,s=e._packedBuffer;l(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=xet(e));let a=[n.buffer,i.buffer,o.buffer,r.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},d=Cet.scheduleTask(c,a);if(l(d))return d.then(function(u){if(e.isDestroyed())return;e._keepDecodedPositions&&(e._decodedPositions=new Float64Array(u.decodedPositions),e._decodedPositionOffsets=new Uint32Array(u.decodedPositionOffsets)),e._currentPositions=new Float32Array(u.currentPositions),e._previousPositions=new Float32Array(u.previousPositions),e._nextPositions=new Float32Array(u.nextPositions),e._expandAndWidth=new Float32Array(u.expandAndWidth),e._vertexBatchIds=new Uint16Array(u.batchIds);let h=u.indexDatatype;e._indices=h===Ue.UNSIGNED_SHORT?new Uint16Array(u.indices):new Uint32Array(u.indices),Eet(e,t),e._ready=!0}).catch(u=>{e.isDestroyed()||(e._error=u)})}function Eet(e,t){if(!l(e._va)){let n=e._currentPositions,i=e._previousPositions,o=e._nextPositions,r=e._expandAndWidth,s=e._vertexBatchIds,a=e._indices,c=i.byteLength+n.byteLength+o.byteLength;c+=r.byteLength+s.byteLength+a.byteLength,e._trianglesLength=a.length/3,e._geometryByteLength=c;let d=it.createVertexBuffer({context:t,typedArray:i,usage:Be.STATIC_DRAW}),u=it.createVertexBuffer({context:t,typedArray:n,usage:Be.STATIC_DRAW}),h=it.createVertexBuffer({context:t,typedArray:o,usage:Be.STATIC_DRAW}),p=it.createVertexBuffer({context:t,typedArray:r,usage:Be.STATIC_DRAW}),A=it.createVertexBuffer({context:t,typedArray:s,usage:Be.STATIC_DRAW}),f=it.createIndexBuffer({context:t,typedArray:a,usage:Be.STATIC_DRAW,indexDatatype:a.BYTES_PER_ELEMENT===2?Ue.UNSIGNED_SHORT:Ue.UNSIGNED_INT}),b=[{index:Q_.previousPosition,vertexBuffer:d,componentDatatype:H.FLOAT,componentsPerAttribute:3},{index:Q_.currentPosition,vertexBuffer:u,componentDatatype:H.FLOAT,componentsPerAttribute:3},{index:Q_.nextPosition,vertexBuffer:h,componentDatatype:H.FLOAT,componentsPerAttribute:3},{index:Q_.expandAndWidth,vertexBuffer:p,componentDatatype:H.FLOAT,componentsPerAttribute:2},{index:Q_.a_batchId,vertexBuffer:A,componentDatatype:H.UNSIGNED_SHORT,componentsPerAttribute:1}];e._va=new kn({context:t,attributes:b,indexBuffer:f}),e._positions=void 0,e._widths=void 0,e._coun
void main(){ out_FragColor = u_highlightColor;}`;function Ret(e,t){if(l(e._sp))return;let n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(aw),o=n.getFragmentShaderCallback(!1,void 0,!1)(Zet),r=new ze({defines:["VECTOR_TILE","CLIP_POLYLINE"],sources:[Zl,i]}),s=new ze({defines:["VECTOR_TILE"],sources:[o]});e._sp=tn.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:Q_})}function Vet(e,t){if(!l(e._command)){let n=e._batchTable.getUniformMapCallback()(e._uniformMap);e._command=new ot({owner:e,vertexArray:e._va,renderState:e._rs,shaderProgram:e._sp,uniformMap:n,boundingVolume:e._boundingVolume,pass:Ge.TRANSLUCENT,pickId:e._batchTable.getPickId()})}t.commandList.push(e._command)}of.getPolylinePositions=function(e,t){let n=e._batchIds,i=e._decodedPositions,o=e._decodedPositionOffsets;if(!l(n)||!l(i))return;let r,s,a=n.length,c=0,d=0;for(r=0;r<a;++r)n[r]===t&&(c+=o[r+1]-o[r]);if(c===0)return;let u=new Float64Array(c*3);for(r=0;r<a;++r)if(n[r]===t){let h=o[r],p=o[r+1]-h;for(s=0;s<p;++s){let A=(h+s)*3;u[d++]=i[A],u[d++]=i[A+1],u[d++]=i[A+2]}}return u};of.prototype.getPositions=function(e){return of.getPolylinePositions(this,e)};of.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 Ga(e,r)}};of.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function Get(e,t){let n=e._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],s=t[r];s.show=!0,s.color=U.WHITE}}var Let=new U,Wet=U.WHITE,Fet=!0;of.prototype.applyStyle=function(e,t){if(!l(e)){Get(this,t);return}let n=this._batchIds,i=n.length;for(let o=0;o<i;++o){let r=n[o],s=t[r];s.color=l(e.color)?e.color.evaluateColor(s,Let):Wet,s.show=l(e.show)?e.show.evaluate(s):Fet}};of.prototype.update=function(e){let t=e.context;if(!this._ready){if(l(this._promise)||(this._promise=Tet(this,t)),l(this._error)){let i=this._error;throw this._error=void 0,i}return}_et(this,t),Ret(this,t),Iet(this);let n=e.passes;(n.render||n.pick)&&Vet(this,e)};of.prototype.isDestroyed=function(){return!1};of.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),he(this)};var UC=of;var gqn=y(x(),1);var w6n=y(x(),1),lw=`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 P6n=y(x(),1),dw=`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 Sg(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=e.ellipsoid??ie.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 M(Gi._defaultMinTerrainHeight,Gi._defaultMaxTerrainHeight),this._boundingVolume=nn.fromRectangle(e.rectangle,Gi._defaultMinTerrainHeight,Gi._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(Sg.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}}});function Bet(e,t,n){let i=Gi.getMinimumMaximumHeights(t,n),o=i.minimumTerrainHeight,r=i.maximumTerrainHeight,s=e._minimumMaximumVectorHeights;s.x=o,s.y=r;let a=e._boundingVolume,c=e._rectangle;nn.fromRectangle(c,o,r,n,a)}function wet(e){let t=e._rectangle,n=e._minimumHeight,i=e._maximumHeight,o=e._ellipsoid,r=e._center,s=2+de.packedLength+ie.packedLength+m.packedLength,a=new Float64Array(s),c=0;return a[c++]=n,a[c++]=i,de.pack(t,a,c),c+=de.packedLength,ie.pack(o,a,c),c+=ie.packedLength,m.pack(r,a,c),a}var Net=new $n("createVectorTileClampedPolylines"),O0={startEllipsoidNormal:0,endEllipsoidNormal:1,startPositionAndHeight:2,endPositionAndHeight:3,startFaceNormalAndVertexCorner:4,endFaceNormalAndHalfWidth:5,a_batchId:6};function Pet(e,t){if(l(e._va))return;let n=e._positions,i=e._widths,o=e._counts,r=e._transferrableBatchIds,s=e._packedBuffer;l(s)||(n=e._positions=n.slice(),i=e._widths=i.slice(),o=e._counts=o.slice(),r=e._transferrableBatchIds=e._batchIds.slice(),s=e._packedBuffer=wet(e));let a=[n.buffer,i.buffer,o.buffer,r.buffer,s.buffer],c={positions:n.buffer,widths:i.buffer,counts:o.buffer,batchIds:r.buffer,packedBuffer:s.buffer,keepDecodedPositions:e._keepDecodedPositions},d=Net.scheduleTask(c,a);if(l(d))return d.then(function(u){if(e.isDestroyed())return;e._keepDecodedPositions&&(e._decodedPositions=new Float64Array(u.decodedPositions),e._decodedPositionOffsets=new Uint32Array(u.decodedPositionOffsets)),e._startEllipsoidNormals=new Float32Array(u.startEllipsoidNormals),e._endEllipsoidNormals=new Float32Array(u.endEllipsoidNormals),e._startPositionAndHeights=new Float32Array(u.startPositionAndHeights),e._startFaceNormalAndVertexCornerIds=new Float32Array(u.startFaceNormalAndVertexCornerIds),e._endPositionAndHeights=new Float32Array(u.endPositionAndHeights),e._endFaceNormalAndHalfWidths=new Float32Array(u.endFaceNormalAndHalfWidths),e._vertexBatchIds=new Uint16Array(u.vertexBatchIds);let h=u.indexDatatype;e._indices=h===Ue.UNSIGNED_SHORT?new Uint16Array(u.indices):new Uint32Array(u.indices),Xet(e,t),e._ready=!0}).catch(u=>{e.isDestroyed()||(e._error=u)})}function Xet(e,t){if(!l(e._va)){let n=e._startEllipsoidNormals,i=e._endEllipsoidNormals,o=e._startPositionAndHeights,r=e._endPositionAndHeights,s=e._startFaceNormalAndVertexCornerIds,a=e._endFaceNormalAndHalfWidths,c=e._vertexBatchIds,d=e._indices,u=n.byteLength+i.byteLength;u+=o.byteLength+r.byteLength,u+=s.byteLength+a.byteLength,u+=c.byteLength+d.byteLength,e._trianglesLength=d.length/3,e._geometryByteLength=u;let h=it.createVertexBuffer({context:t,typedArray:n,usage:Be.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 f$n=y(x(),1),Aw=`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 E$n=y(x(),1);var b$n=y(x(),1);var gw=class{constructor(t=Q.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}}};Bn(gw,"Layout",{COLOR_U32:0,OUTLINE_COLOR_U32:4,OUTLINE_WIDTH_U8:8,__BYTE_LENGTH:12}),Bn(gw,"DEFAULT_MATERIAL");var Ol=gw;var bw=class bw extends Ol{constructor(t=Q.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}}};Bn(bw,"Layout",{...Ol.Layout,SIZE_U8:Ol.Layout.__BYTE_LENGTH,__BYTE_LENGTH:Ol.Layout.__BYTE_LENGTH+4}),Bn(bw,"DEFAULT_MATERIAL",Object.freeze(new bw));var B4=bw,_g=B4;var Ig={positionHigh:0,positionLow:1,pickColor:2,showSizeAndColor:3,outlineWidthAndOutlineColor:4},Zg=new Vd,yw=new _g,xw=new U,Epe=new m,DC=new In;function ott(e,t,n){let i=t.context;if(n=n||{destroy:stt},!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,s=o.positionHigh,a=o.positionLow,c=o.pickColor,d=o.showSizeAndColor,u=o.outlineWidthAndOutlineColor,{_dirtyOffset:h,_dirtyCount:p}=e;for(let A=h,f=h+p;A<f;A++)if(e.get(A,Zg),!!Zg._dirty){if(e._allowPicking&&Zg._pickId===0){let b=i.createPickId({collection:e,index:A,get primitive(){return e.get(this.index,new Vd)}});Zg._pickId=b.key,r.push(b)}Zg.getPosition(Epe),In.fromCartesian(Epe,DC),Zg.getMaterial(yw),U.fromRgba(Zg._pickId,xw),s[A*3]=DC.high.x,s[A*3+1]=DC.high.y,s[A*3+2]=DC.high.z,a[A*3]=DC.low.x,a[A*3+1]=DC.low.y,a[A*3+2]=DC.low.z,c[A*4]=U.floatToByte(xw.red),c[A*4+1]=U.floatToByte(xw.green),c[A*4+2]=U.floatToByte(xw.blue),c[A*4+3]=U.floatToByte(xw.alpha),d[A*3]=Zg.show?1:0,d[A*3+1]=yw.size,d[A*3+2]=on.encodeRGB8(yw.color),u[A*2]=yw.outlineWidth,u[A*2+1]=on.encodeRGB8(yw.outlineColor),Zg._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){for(let o in Ig)if(Object.hasOwn(Ig,o)){let r=o;n.vertexArray.copyAttributeFromRange(Ig[r],n.attributeArrays[r],e._dirtyOffset,e._dirtyCount)}}}else{let{attributeArrays:o}=n;n.vertexArray=new kn({context:i,attributes:[{index:Ig.positionHigh,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Be.STATIC_DRAW})},{index:Ig.positionLow,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Be.STATIC_DRAW})},{index:Ig.pickColor,componentDatatype:H.UNSIGNED_BYTE,componentsPerAttribute:4,vertexBuffer:it.createVertexBuffer({typedArray:o.pickColor,context:i,usage:Be.STATIC_DRAW})},{index:Ig.showSizeAndColor,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.showSizeAndColor,context:i,usage:Be.STATIC_DRAW})},{index:Ig.outlineWidthAndOutlineColor,componentDatatype:H.FLOAT,componentsPerAttribute:2,vertexBuffer:it.createVertexBuffer({typedArray:o.outlineWidthAndOutlineColor,context:i,usage:Be.STATIC_DRAW})}]})}return l(n.renderState)||(n.renderState=Qe.fromCache({blending:ln.ALPHA_BLEND,depthTest:{enabled:!0}})),l(n.shaderProgram)||(n.shaderProgram=tn.fromCache({context:i,
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 pei=y(x(),1),Ew=`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 yei=y(x(),1);var T9=class T9 extends Ol{constructor(t=Q.EMPTY_OBJECT){super(t)}};Bn(T9,"DEFAULT_MATERIAL",Object.freeze(new T9));var P4=T9,Vg=P4;var z0={positionHigh:0,positionLow:1,pickColor:2,showAndColor:3},Xs=new wa,Spe=new Vg,Sw=new U,_pe=new m,kC=new In;function att(e,t,n){let i=t.context;if(n=n||{destroy:dtt},!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:s,_dirtyCount:a}=e,c=n.indexArray,d=o.positionHigh,u=o.positionLow,h=o.pickColor,p=o.showAndColor;for(let A=s,f=s+a;A<f;A++){if(e.get(A,Xs),!Xs._dirty)continue;if(e._allowPicking&&Xs._pickId===0){let R=i.createPickId({collection:e,index:A,get primitive(){return e.get(A,new wa)}});Xs._pickId=R.key,r.push(R)}let b=Xs.triangleOffset,C=Xs.vertexOffset,T=Xs.getTriangles();for(let R=0,V=Xs.triangleCount;R<V;R++)c[b*3]=C+T[R*3],c[b*3+1]=C+T[R*3+1],c[b*3+2]=C+T[R*3+2],b++;let E=Xs.show,S=Xs.getPositions();Xs.getMaterial(Spe);let I=on.encodeRGB8(Spe.color);U.fromRgba(Xs._pickId,Sw);for(let R=0,V=Xs.vertexCount;R<V;R++)m.fromArray(S,R*3,_pe),In.fromCartesian(_pe,kC),d[C*3]=kC.high.x,d[C*3+1]=kC.high.y,d[C*3+2]=kC.high.z,u[C*3]=kC.low.x,u[C*3+1]=kC.low.y,u[C*3+2]=kC.low.z,h[C*4]=U.floatToByte(Sw.red),h[C*4+1]=U.floatToByte(Sw.green),h[C*4+2]=U.floatToByte(Sw.blue),h[C*4+3]=U.floatToByte(Sw.alpha),p[C*2]=E?1:0,p[C*2+1]=I,C++;Xs._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){let{indexOffset:o,indexCount:r,vertexOffset:s,vertexCount:a}=ltt(e);n.vertexArray.copyIndexFromRange(n.indexArray,o,r);for(let c in z0)if(Object.hasOwn(z0,c)){let d=c;n.vertexArray.copyAttributeFromRange(z0[d],n.attributeArrays[d],s,a)}}}else{let{attributeArrays:o}=n;n.vertexArray=new kn({context:i,indexBuffer:it.createIndexBuffer({context:i,typedArray:n.indexArray,usage:Be.STATIC_DRAW,indexDatatype:Ue.fromTypedArray(n.indexArray)}),attributes:[{index:z0.positionHigh,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Be.STATIC_DRAW})},{index:z0.positionLow,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Be.STATIC_DRAW})},{index:z0.pickColor,componentDatatype:H.UNSIGNED_BYTE,componentsPerAttribute:4,vertexBuffer:it.createVertexBuffer({typedArray:o.pickColor,context:i,usage:Be.STATIC_DRAW})},{index:z0.showAndColor,componentDatatype:H.FLOAT,componentsPerAttribute:2,vertexBuffer:it.createVertexBuffer({typedArray:o.showAndColor,context:i,usage:Be.STATIC_DRAW})}]})}return l(n.renderState)||(n.renderState=Qe.fromCache({blending:ln.DISABLED,depthTest:{enabled:!0}})),l(n.shaderProgram)||(n.shaderProgram=tn.fromCache({context:i,vertexShaderSource:new ze({sources:[Tw]}),fragmentShaderSource:new ze({sources:[Ew]}),attributeLocations:z0})),(!l(n.command)||ctt(e,n.command))&&(n.command=new ot({vertexArray:n.vertexArray,renderState:n.renderState,shaderProgram:n.shaderProgram,primitiveType:We.TRIANGLES,pass:Ge.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 ctt(e,t){let n=F.equals(e.modelMatrix,t._modelMatrix),i=ue.equals(e.boundingVolumeWC,t._boundingVolume);return e.triangleCount*3!==t._count||e.debugShowBoundingVolume!==t.debugShowBoundingVolume||!n||!i}function ltt(e){let{_dirtyOffset:t,_dirtyCount:n}=e;e.get(t,Xs);let i=Xs.vertexOffset,o=Xs.triangleOffset*3;e.get(t+n-1,Xs);let r=Xs.vertexOffset+Xs.vertexCount-i,s=(Xs.triangleOffset+Xs.triangleCount)*3-o;return{indexOffset:o,indexCount:s,vertexOffset:i,vertexCount:r}}function dtt(){let e=this;if(l(e.vertexArray)&&e.vertexArray.destroy(),l(e.shaderProgram)&&e.shaderProgram.destroy(),
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 hti=y(x(),1),Zw=`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 gti=y(x(),1);var Rw=class Rw extends Ol{constructor(t=Q.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}}};Bn(Rw,"Layout",{...Ol.Layout,WIDTH_U8:Ol.Layout.__BYTE_LENGTH,__BYTE_LENGTH:Ol.Layout.__BYTE_LENGTH+4}),Bn(Rw,"DEFAULT_MATERIAL",Object.freeze(new Rw));var M4=Rw,Lg=M4;var wm={positionHigh:0,positionLow:1,prevPositionHigh:2,prevPositionLow:3,nextPositionHigh:4,nextPositionLow:5,pickColor:6,showColorWidthAndTexCoord:7},oc=new zl,v4=new Lg,Vw=new U,H_=new m,QC=new m,OC=new m,zC=new In,HC=new In,JC=new In;function utt(e,t,n){let i=t.context;if(n=n||{destroy:ftt},!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:s,pickIds:a}=n,c=n.indexArray,d=s.positionHigh,u=s.positionLow,h=s.prevPositionHigh,p=s.prevPositionLow,A=s.nextPositionHigh,f=s.nextPositionLow,b=s.pickColor,C=s.showColorWidthAndTexCoord;for(let T=o,E=o+r;T<E;T++){if(e.get(T,oc),!oc._dirty)continue;if(e._allowPicking&&oc._pickId===0){let B=i.createPickId({collection:e,index:T,get primitive(){return e.get(T,new zl)}});oc._pickId=B.key,a.push(B)}let S=oc.getPositions();oc.getMaterial(v4);let I=on.encodeRGB8(v4.color);U.fromRgba(oc._pickId,Vw);let R=oc.show,V=oc.vertexOffset*2,W=(oc.vertexOffset-T)*6;for(let B=0,N=oc.vertexCount;B<N;B++){let P=B===0,g=B===N-1;m.fromArray(S,B*3,H_),P?(m.fromArray(S,(B+1)*3,OC),m.subtract(H_,OC,QC),m.add(H_,QC,QC)):g?(m.fromArray(S,(B-1)*3,QC),m.subtract(H_,QC,OC),m.add(H_,OC,OC)):(m.fromArray(S,(B-1)*3,QC),m.fromArray(S,(B+1)*3,OC)),g||(c[W]=V,c[W+1]=V+1,c[W+2]=V+2,c[W+3]=V+2,c[W+4]=V+1,c[W+5]=V+3,W+=6),In.fromCartesian(H_,zC),In.fromCartesian(QC,HC),In.fromCartesian(OC,JC);for(let _=0;_<2;_++)d[V*3]=zC.high.x,d[V*3+1]=zC.high.y,d[V*3+2]=zC.high.z,u[V*3]=zC.low.x,u[V*3+1]=zC.low.y,u[V*3+2]=zC.low.z,h[V*3]=HC.high.x,h[V*3+1]=HC.high.y,h[V*3+2]=HC.high.z,p[V*3]=HC.low.x,p[V*3+1]=HC.low.y,p[V*3+2]=HC.low.z,A[V*3]=JC.high.x,A[V*3+1]=JC.high.y,A[V*3+2]=JC.high.z,f[V*3]=JC.low.x,f[V*3+1]=JC.low.y,f[V*3+2]=JC.low.z,b[V*4]=U.floatToByte(Vw.red),b[V*4+1]=U.floatToByte(Vw.green),b[V*4+2]=U.floatToByte(Vw.blue),b[V*4+3]=U.floatToByte(Vw.alpha),C[V*4]=R?1:0,C[V*4+1]=I,C[V*4+2]=v4.width,C[V*4+3]=B/(N-1),V++}oc._dirty=!1}}if(l(n.vertexArray)){if(e._dirtyCount>0){let{indexOffset:o,indexCount:r,vertexOffset:s,vertexCount:a}=htt(e);n.vertexArray.copyIndexFromRange(n.indexArray,o,r);for(let c in wm)if(Object.hasOwn(wm,c)){let d=c;n.vertexArray.copyAttributeFromRange(wm[d],n.attributeArrays[d],s,a)}}}else{let o=n.attributeArrays;n.vertexArray=new kn({context:i,indexBuffer:it.createIndexBuffer({context:i,typedArray:n.indexArray,usage:Be.STATIC_DRAW,indexDatatype:Ue.fromTypedArray(n.indexArray)}),attributes:[{index:wm.positionHigh,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionHigh,context:i,usage:Be.STATIC_DRAW})},{index:wm.positionLow,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.positionLow,context:i,usage:Be.STATIC_DRAW})},{index:wm.prevPositionHigh,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.prevPositionHigh,context:i,usage:Be.STATIC_DRAW})},{index:wm.prevPositionLow,componentDatatype:H.FLOAT,componentsPerAttribute:3,vertexBuffer:it.createVertexBuffer({typedArray:o.prevPositionLow,context:i,usage:Be.STATIC_DRAW})},{index:wm.nextPositionHigh,component
{ return ${u}; }`}return r=`${i} ${e}{${r} return ${i}(1.0);}`,r};J_.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];ri(e,o.condition.getVariables()),ri(e,o.expression.getVariables())}return e=e.filter(function(i,o,r){return r.indexOf(i)===o}),e};var Lw=J_;function J0(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,gtt(this,e)}function gtt(e,t){t=He(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??Q.EMPTY_OBJECT;for(let r in o)o.hasOwnProperty(r)&&(n[r]=new ym(o[r],i))}e._meta=n,e._ready=!0}function fr(e,t){let n=(e._style??Q.EMPTY_OBJECT).defines;if(l(t)){if(typeof t=="boolean"||typeof t=="number")return new ym(String(t));if(typeof t=="string")return new ym(t,n);if(l(t.conditions))return new Lw(t,n)}else return;return t}function pr(e){if(l(e)){if(l(e.expression))return e.expression;if(l(e.conditionsExpression))return He(e.conditionsExpression,!0)}else return;return e}Object.defineProperties(J0.prototype,{style:{get:function(){return this._style}},show:{get:function(){return this._show},set:function(e){this._show=fr(this,e),this._style.show=pr(this._show),this._showShaderFunctionReady=!1}},color:{get:function(){return this._color},set:function(e){this._color=fr(this,e),this._style.color=pr(this._color),this._colorShaderFunctionReady=!1}},pointSize:{get:function(){return this._pointSize},set:function(e){this._pointSize=fr(this,e),this._style.pointSize=pr(this._pointSize),this._pointSizeShaderFunctionReady=!1}},pointOutlineColor:{get:function(){return this._pointOutlineColor},set:function(e){this._pointOutlineColor=fr(this,e),this._style.pointOutlineColor=pr(this._pointOutlineColor)}},pointOutlineWidth:{get:function(){return this._pointOutlineWidth},set:function(e){this._pointOutlineWidth=fr(this,e),this._style.pointOutlineWidth=pr(this._pointOutlineWidth)}},labelColor:{get:function(){return this._labelColor},set:function(e){this._labelColor=fr(this,e),this._style.labelColor=pr(this._labelColor)}},labelOutlineColor:{get:function(){return this._labelOutlineColor},set:function(e){this._labelOutlineColor=fr(this,e),this._style.labelOutlineColor=pr(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 bii=y(x(),1),Pw=`//
// 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 jC=new F,Ype=new F,Xw=new F,yi=new $,Yw=new Me,Itt=new m,Ztt=new Me,Rtt=new m,Vtt=1e-12,E9=1e-5,H4=1e-7,Na={IDLE:0,WAITING:1,SORTING:2,SORTED:3,ERROR:4},Ys={BUILDING:"BUILDING",TEXTURE_PENDING:"TEXTURE_PENDING",TEXTURE_READY:"TEXTURE_READY",SORTING:"SORTING",READY:"READY"},Gtt=2,Ltt=30,Wtt=3,Ftt=.008726646259971648,Btt=1;function wtt(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||m.distance(i.positionWC,e._lastSteadySortCameraPosition)>=Btt?!0:m.angleBetween(i.directionWC,e._lastSteadySortCameraDirection)>=Ftt:!1}function Bpe(e,t){e._lastSteadySortFrameNumber=t.frameNumber;let n=t.camera;l(n)&&(m.clone(n.positionWC,e._lastSteadySortCameraPosition),e._hasLastSteadySortCameraPosition=!0,m.clone(n.directionWC,e._lastSteadySortCameraDirection),e._hasLastSteadySortCameraDirection=!0)}function Ntt(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 wpe(e,t){return l(t)&&t.requestId===e._sortRequestId&&t.dataGeneration===e._splatDataGeneration}function J4(e){l(e)&&(l(e.gaussianSplatTexture)&&(e.gaussianSplatTexture.destroy(),e.gaussianSplatTexture=void 0),l(e.sphericalHarmonicsTexture)&&(e.sphericalHarmonicsTexture.destroy(),e.sphericalHarmonicsTexture=void 0))}function Npe(e,t,n){if(!l(t))return;e._retiredTextures.push({texture:t,frameNumber:n})}function Ptt(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 Xtt(e,t){let n=e?.[t];return l(n)?n.buffer:void 0}function Ytt(e,t,n,i){let o=e._aggregateScratchBuffers[t];l(o)||(o=[],e._aggregateScratchBuffers[t]=o);let r=Xtt(e._snapshot,t);for(let a=0;a<o.length;a++){let c=o[a];if(c.length>=i&&c.buffer!==r)return c}let s=H.createTypedArray(n,i);return o.push(s),s}function Mtt(e,t){return e.length===t?e:e.subarray(0,t)}function vtt(e,t,n){if(!l(t.indexes)||t.state!==Ys.READY)throw new fe("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&&Npe(e,r,i);let s=l(o)?o.sphericalHarmonicsTexture:e.sphericalHarmonicsTexture;l(s)&&s!==t.sphericalHarmonicsTexture&&Npe(e,s,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=Na.IDLE,e._dirty=!1}async function Utt(e,t,n,i){try{let o=await i,r=Bt.maximumTextureSize,s=r,a=Math.ceil(n.numSplats/(r/2)),c=Math.log2(r/2),d=r/2-1;if(a>r){let A=n.numSplats;a=r;let f=s/2;if(n.numSplats=r*f,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 b=n.shData.length/A;n.shData=n.shData.subarray(0,Math.floor(n.numSplats*b))}n.splatBudgetSSEScale=A/n.numSplats,console.warn(`[GaussianSplat][HARD CAP] ${A} splats exceed the maximum texture capacity (${r}\xD7${f} = ${n.numSplats} splats at width=${s}). 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(Cu.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 Qtt(e){return`${e.startsWith("KHR_gaussian_splatting:")?"KHR_gaussian_splatting:":"_"}SH_DEGREE_`}function Ott(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 Mpe=new ArrayBuffer(4),ztt=new Float32Array(Mpe),Htt=new Uint32Array(Mpe);function K4(e){ztt[0]=e;let t=Htt[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 s=i-127+15;s>=31?r=n<<15|31744:s<=0?r=n<<15:r=n<<15|s<<10|o>>>13}return r}function Jtt(e){let t=Qtt(e),n="_COEF_",i=t.length,o=e.indexOf(n,i),r=parseInt(e.slice(i,o),10),s=parseInt(e.slice(o+n.length),10);return{l:r,n:s}}function Ktt(e){let t=e.sphericalHarmonicsDegree,n=e.sphericalHarmonicsCoefficientCount,i=e.pointsLength*(n*(2/3)),o=new Uint32Array(i),r=e.gltfPrimitive.attributes.filter(d=>d.name.includes("SH_DEGREE_")),s=0,a=[0,9,24];switch(t){case 1:s=9;break;case 2:s=24;break;case 3:s=45;break}r.sort((d,u)=>d.name<u.name?-1:d.name>u.name?1:0);let c=s*(2/3);for(let d=0;d<r.length;d++){let{l:u,n:h}=Jtt(r[d].name);for(let p=0;p<e.pointsLength;p++){let A=a[u-1]*2/3,f=p*c+A+h*2,b=p*3;o[f]=K4(r[d].typedArray[b])|K4(r[d].typedArray[b+1])<<16,o[f+1]=K4(r[d].typedArray[b+2])}}return o}Cu.fromGltf=async function(e,t,n,i){let o=n,r=Le.createIfNeeded(o),s={releaseGltfJson:!1,upAxis:ro.Y,forwardAxis:ro.Z};l(i.asset)?(s.gltfJson=i,s.baseResource=r,s.gltfResource=r):i instanceof Uint8Array?(s.typedArray=i,s.baseResource=r,s.gltfResource=r):s.gltfResource=Le.createIfNeeded(i);let a=new uu(s);try{await a.load()}catch(c){throw a.destroy(),new me(`Failed to load glTF: ${c.message}`)}return new Cu(a,e,t,n)};Cu.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=It.getAttributeBySemantic(this.gltfPrimitive,ct.POSITION).typedArray.slice(),this._rotations=It.getAttributeBySemantic(this.gltfPrimitive,ct.ROTATION).typedArray.slice(),this._scales=It.getAttributeBySemantic(this.gltfPrimitive,ct.SCALE).typedArray.slice();let{l:i,n:o}=Ott(this.gltfPrimitive.attributes);this._sphericalHarmonicsDegree=i,this._sphericalHarmonicsCoefficientCount=o,this._packedSphericalHarmonicsData=Ktt(this);return}this._resourcesLoaded=n.process(t)}};Cu.prototype.hasProperty=function(e,t){return!1};Cu.prototype.getFeature=function(e){};Cu.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: ${FAe(e.content.texturesByteLength)}`,i+=`Geometry Memory: ${FAe(e.content.geometryByteLength)}`,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+=`Urls:`;let s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+=`- ${s[a]}`;o+=s.length}else i+=`Url: ${e._contentHeader.uri}`,o++;let r={text:i.substring(1),position:n,font:`${19-o}px sans-serif`,showBackground:!0,disableDepthTestDistance:Number.POSITIVE_INFINITY};return t._tileDebugLabels.add(r)}function cot(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 s=l(e.debugPickPosition)?e.debugPickPosition:C8(e.debugPickedTile),a=T8(e.debugPickedTile,e,s);a.pixelOffset=new M(15,-15)}}else{for(let s=0;s<i;++s){let a=n[s];T8(a,e,C8(a))}for(let s=0;s<r;++s){let a=o[s];(a.hasTilesetContent||a.hasImplicitContent)&&T8(a,e,C8(a))}}e._tileDebugLabels.update(t)}function lot(e,t,n){e._styleEngine.applyStyle(e),e._styleApplied=!0;let{commandList:i,context:o}=t,r=i.length,s=e._selectedTiles,a=e.isSkippingLevelOfDetail&&e._hasMixedContent&&o.stencilBuffer&&s.length>0;e._backfaceCommands.length=0,a&&(l(e._stencilClearCommand)||(e._stencilClearCommand=new mi({stencil:0,pass:Ge.CESIUM_3D_TILE,renderState:Qe.fromCache({stencilMask:Jt.SKIP_LOD_MASK})})),i.push(e._stencilClearCommand));let{statistics:c,tileVisible:d}=e,u=n.isRender,h=i.length;for(let f=0;f<s.length;++f){let b=s[f];u&&d.raiseEvent(b),iot(e,b,t),b.update(e,t,n),c.incrementSelectionCounts(b.content),++c.selected}let p=e._emptyTiles;for(let f=0;f<p.length;++f)p[f].update(e,t,n);let A=i.length-h;if(e._backfaceCommands.trim(),a){let f=e._backfaceCommands.values,b=f.length;i.length+=b;for(let C=A-1;C>=0;--C)i[h+b+C]=i[h+C];for(let C=0;C<b;++C)i[h+C]=f[C]}A=i.length-r,c.numberOfCommands=A,u&&(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 Sp),cot(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}var NAe=[];function dot(e,t){let n=t,i=NAe;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&&(uot(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function PAe(e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function uot(e,t){e._cache.unloadTile(e,t,PAe),t.destroy()}ar.prototype.trimLoadedTiles=function(){this._cache.trim()};function mot(e,t){let n=e._statistics,i=e._statisticsLast,o=n.numberOfPendingRequests,r=n.numberOfTilesProcessing,s=i.numberOfPendingRequests,a=i.numberOfTilesProcessing;lf.clone(n,i);let c=o!==s||r!==a;c&&t.afterRender.push(function(){return e.loadProgress.raiseEvent(o,r),!0}),e._tilesLoaded=n.numberOfPendingRequests===0&&n.numberOfTilesProcessing===0&&n.numberOfAttemptedRequests===0,c&&e._tilesLoaded&&(t.afterRender.push(function(){return e.allTilesLoaded.raiseEvent(),!0}),e._initialTilesLoaded||(e._initialTilesLoaded=!0,t.afterRender.push(function(){return e.initialTilesLoaded.raiseEvent(),!0})))}function hot(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 fot(e,t){t.frameNumber===e._updatedModelMatrixFrame&&l(e._previousModelMatrix)||(e._updatedModelMatrixFrame=t.frameNumber,e._modelMatrixChanged=!F.equals(e.modelMatrix,e._previousModelMatrix),e._modelMatrixChanged&&(e._previousModelMatrix=F.clone(e.modelMatrix,e._previousModelMatrix)))}function pot(e,t,n,i){if(t.mode===se.MORPHING||!l(e._root))return!1;let o=e._statistics;o.clear(),++e._updatedVisibilityFrame,hot(e),fot(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;let r=e.getTraversal(i).selectTiles(e,t);if(i.requestTiles&&qit(e),lot(e,t,i),lf.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 Bpi=y(x(),1),TN=`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 Frt=pa.SHOW_INDEX,v8=pa.POSITION_INDEX,Bge=pa.COLOR_INDEX,Brt=pa.OUTLINE_COLOR_INDEX,wrt=pa.OUTLINE_WIDTH_INDEX,Nrt=pa.PIXEL_SIZE_INDEX,wge=pa.SCALE_BY_DISTANCE_INDEX,Nge=pa.TRANSLUCENCY_BY_DISTANCE_INDEX,Pge=pa.DISTANCE_DISPLAY_CONDITION_INDEX,Prt=pa.DISABLE_DEPTH_DISTANCE_INDEX,Xrt=pa.SPLIT_DIRECTION_INDEX,U8=pa.NUMBER_OF_PROPERTIES,rl={positionHighAndSize:0,positionLowAndOutline:1,compressedAttribute0:2,compressedAttribute1:3,scaleByDistance:4,distanceDisplayConditionAndDisableDepthAndSplitDirection:5};function km(e){e=e??Q.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(U8),this._maxPixelSize=1,this._baseVolume=new ue,this._baseVolumeWC=new ue,this._baseVolume2D=new ue,this._boundingVolume=new ue,this._boundingVolumeDirty=!1,this._colorCommands=[],this.show=e.show??!0,this.modelMatrix=F.clone(e.modelMatrix??F.IDENTITY),this._modelMatrix=F.clone(F.IDENTITY),this.debugShowBoundingVolume=e.debugShowBoundingVolume??!1,this.blendOption=e.blendOption??$o.OPAQUE_AND_TRANSLUCENT,this._blendOption=void 0,this._mode=se.SCENE3D,this._maxTotalPointSize=1,this._buffersUsage=[Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW,Be.STATIC_DRAW];let t=this;this._uniforms={u_maxTotalPointSize:function(){return t._maxTotalPointSize}}}Object.defineProperties(km.prototype,{length:{get:function(){return D8(this),this._pointPrimitives.length}}});function Xge(e){let t=e.length;for(let n=0;n<t;++n)e[n]&&e[n]._destroy()}km.prototype.add=function(e){let t=new pa(e,this);return t._index=this._pointPrimitives.length,this._pointPrimitives.push(t),this._createVertexArray=!0,t};km.prototype.remove=function(e){return this.contains(e)?(this._pointPrimitives[e._index]=null,this._pointPrimitivesRemoved=!0,this._createVertexArray=!0,e._destroy(),!0):!1};km.prototype.removeAll=function(){Xge(this._pointPrimitives),this._pointPrimitives=[],this._pointPrimitivesToUpdate=[],this._pointPrimitivesToUpdateIndex=0,this._pointPrimitivesRemoved=!1,this._createVertexArray=!0};function D8(e){if(e._pointPrimitivesRemoved){e._pointPrimitivesRemoved=!1;let t=[],n=e._pointPrimitives,i=n.length;for(let o=0,r=0;o<i;++o){let s=n[o];s&&(s._index=r++,t.push(s))}e._pointPrimitives=t}}km.prototype._updatePointPrimitive=function(e,t){e._dirty||(this._pointPrimitivesToUpdate[this._pointPrimitivesToUpdateIndex++]=e),++this._propertiesChanged[t]};km.prototype.contains=function(e){return l(e)&&e._pointPrimitiveCollection===this};km.prototype.get=function(e){return D8(this),this._pointPrimitives[e]};km.prototype.computeNewBuffersUsage=function(){let e=this._buffersUsage,t=!1,n=this._propertiesChanged;for(let i=0;i<U8;++i){let o=n[i]===0?Be.STATIC_DRAW:Be.STREAM_DRAW;t=t||e[i]!==o,e[i]=o}return t};function Yrt(e,t,n){return new LA(e,[{index:rl.positionHighAndSize,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[v8]},{index:rl.positionLowAndShow,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[v8]},{index:rl.compressedAttribute0,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[Bge]},{index:rl.compressedAttribute1,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[Nge]},{index:rl.scaleByDistance,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[wge]},{index:rl.distanceDisplayConditionAndDisableDepthAndSplitDirection,componentsPerAttribute:4,componentDatatype:H.FLOAT,usage:n[Pge]}],t)}var Y8=new In,k9=new U;function Yge(e,t,n,i){let o=i._index,r=i._getActualPosition();e._mode===se.SCENE3
${t.message}`),e.previousError=qo.reportError(e.previousError,n,l(n)?n._errorEvent:void 0,i),e.previousError.retry)return o$(e,n);throw new me(i)}async function ggt(e,t,n){await zEe(e,t,n);let i=e.overallAvailability.length;if(i>0){let o=e.availability=new Wf(e.tilingScheme,e.overallMaxZoom);for(let r=0;r<i;++r){let s=e.overallAvailability[r];for(let a=0;a<s.length;++a){let c=s[a];o.addAvailableTileRange(r,c[0],c[1],c[2],c[3])}}}if(e.attribution.length>0){let o=new Et(e.attribution);e.tileCredits.push(o)}return!0}async function o$(e,t){try{let n=await e.layerJsonResource.fetchJson();return ggt(e,n,t)}catch(n){return l(n)&&n.statusCode===404?(await zEe(e,{tilejson:"2.1.0",format:"heightmap-1.0",version:"1.0.0",scheme:"tms",tiles:["{z}/{x}/{y}.terrain?v={version}"]},t),!0):Agt(e,n,t)}}function wf(e){e=e??Q.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 xe;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 n$={OCT_VERTEX_NORMALS:1,WATER_MASK:2,METADATA:4};function QEe(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 bgt(e,t,n,i,o){let r=new Uint16Array(t,0,e._heightmapWidth*e._heightmapWidth);return new Fc({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 ygt(e,t,n,i,o,r){let s=r.littleEndianExtensionSize,a=0,c=3,d=c+1,u=Float64Array.BYTES_PER_ELEMENT*c,h=Float64Array.BYTES_PER_ELEMENT*d,A=Uint16Array.BYTES_PER_ELEMENT*3,f=3,b=Uint16Array.BYTES_PER_ELEMENT,C=b*f,T=new DataView(t),E=new m(T.getFloat64(a,!0),T.getFloat64(a+8,!0),T.getFloat64(a+16,!0));a+=u;let S=T.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let I=T.getFloat32(a,!0);a+=Float32Array.BYTES_PER_ELEMENT;let R=new ue(new m(T.getFloat64(a,!0),T.getFloat64(a+8,!0),T.getFloat64(a+16,!0)),T.getFloat64(a+u,!0));a+=h;let V=new m(T.getFloat64(a,!0),T.getFloat64(a+8,!0),T.getFloat64(a+16,!0));a+=u;let W=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let B=new Uint16Array(t,a,W*3);a+=W*A,W>64*1024&&(b=Uint32Array.BYTES_PER_ELEMENT,C=b*f);let N=B.subarray(0,W),P=B.subarray(W,2*W),g=B.subarray(W*2,3*W);on.zigZagDeltaDecode(N,P,g),a%b!==0&&(a+=b-a%b);let _=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let Z=Ue.createTypedArrayFromArrayBuffer(W,t,a,_*f);a+=_*C;let G=0,w=Z.length;for(let ae=0;ae<w;++ae){let Ce=Z[ae];Z[ae]=G-Ce,Ce===0&&++G}let X=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let k=Ue.createTypedArrayFromArrayBuffer(W,t,a,X);a+=X*b;let v=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let D=Ue.createTypedArrayFromArrayBuffer(W,t,a,v);a+=v*b;let Y=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let O=Ue.createTypedArrayFromArrayBuffer(W,t,a,Y);a+=Y*b;let J=T.getUint32(a,!0);a+=Uint32Array.BYTES_PER_ELEMENT;let te=Ue.createTypedArrayFromArrayBuffer(W,t,a,J);a+=J*b;let z,j;for(;a<T.byteLength;){let ae=T.getUint8(a,!0);a+=Uint8Array.BYTES_PER_ELEMENT;let Ce=T.getUint32(a,s);if(a+=Uint32Array.BYTES_PER_ELEMENT,ae===n$.OCT_VERTEX_NORMALS&&e._requestVertexNormals)z=new Uint8Array(t,a,W*2);else if(ae===n$.WATER_MASK&&e._requestWaterMask)j=new Uint8Array(t,a,Ce);else if(ae===n$.METADATA&&e._requestMetadata){let Te=T.getUint32(a,!0);if(Te>0){let Ne=Zr(new Uint8Array(t),a+Uint32Array.BYTES_PER_ELEMENT,Te).available;if(l(Ne))for(let Pe=0;Pe<Ne.length;++Pe){let Xe=n+Pe+1,st=Ne[Pe],Ye=e._tilingScheme.getNumberOfYTilesAtLevwmi\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 vu(e){this.imageryPresent=!0,this.protoImagery=void 0,this.terrainPresent=!0,this.negativeAltitudeExponentBias=32,this.negativeAltitudeThreshold=L.EPSILON12,this.providers={},this.key=void 0,this._resource=void 0,this._quadPacketVersion=1,this._tileInfo={},this._subtreePromises={}}Object.defineProperties(vu.prototype,{url:{get:function(){return this._resource.url}},proxy:{get:function(){return this._resource.proxy}},resource:{get:function(){return this._resource}}});vu.fromUrl=async function(e){let t=e;typeof t!="string"&&!(t instanceof Le)&&(t=e.url);let n=Le.createIfNeeded(t);n.appendForwardSlash();let i=new vu;i._resource=n;try{await tbt(i),await i.getQuadTreePacket("",i._quadPacketVersion)}catch(o){let r=`An error occurred while accessing ${oSe(i,"",1).url}: ${o}`;throw new me(r)}return i};vu.tileXYToQuadKey=function(e,t,n){let i="";for(let o=n;o>=0;--o){let r=1<<o,s=0;cl(t,r)?cl(e,r)&&(s|=1):(s|=2,cl(e,r)||(s|=1)),i+=s}return i};vu.quadKeyToTileXY=function(e){let t=0,n=0,i=e.length-1;for(let o=i;o>=0;--o){let r=1<<o,s=+e[i-o];cl(s,2)?cl(s,1)||(t|=r):(n|=r,cl(s,1)&&(t|=r))}return{x:t,y:n,level:i}};vu.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 iSe=new $n("decodeGoogleEarthEnterprisePacket");vu.prototype.getQuadTreePacket=function(e,t,n){t=t??1,e=e??"";let o=oSe(this,e,t,n).fetchArrayBuffer();if(!l(o))return;let r=this._tileInfo,s=this.key;return o.then(function(a){return iSe.scheduleTask({buffer:a,quadKey:e,type:"Metadata",key:s},[a]).then(function(d){let u,h=-1;if(e!==""){h=e.length+1;let f=d[e];u=r[e],u._bits|=f._bits,delete d[e]}let p=Object.keys(d);p.sort(function(f,b){return f.length-b.length});let A=p.length;for(let f=0;f<A;++f){let b=p[f];if(d[b]!==null){let T=GX.clone(d[b]),E=b.length;if(E===h)T.setParent(u);else if(E>1){let S=r[b.substring(0,b.length-1)];T.setParent(S)}r[b]=T}else r[b]=null}})})};vu.prototype.populateSubtree=function(e,t,n,i){let o=vu.tileXYToQuadKey(e,t,n);return b$(this,o,i)};function b$(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 s,a=e._subtreePromises,c=a[o];if(l(c))return c.then(function(){return s=new Tr({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),b$(e,t,s)});if(!l(r)||!r.hasSubtree())return Promise.reject(new me(`Couldn't load metadata for tile ${t}`));if(c=e.getQuadTreePacket(o,r.cnodeVersion,n),!!l(c))return a[o]=c,c.then(function(){return s=new Tr({throttle:n.throttle,throttleByServer:n.throttleByServer,type:n.type,priorityFunction:n.priorityFunction}),b$(e,t,s)}).finally(function(){delete a[o]})}vu.prototype.getTileInformation=function(e,t,n){let i=vu.tileXYToQuadKey(e,t,n);return this._tileInfo[i]};vu.prototype.getTileInformationFromQuadKey=function(e){return this._tileInfo[e]};function oSe(e,t,n,i){return e._resource.getDerivedResource({url:`flatfile?q2-0${t}-q.${n.toString()}`,request:i})}var A$,g$;function tbt(e){let t=e._resource.getDerivedResource({url:"dbRoot.v5",queryParameters:{output:"proto"}});if(!l(g$)){let n=en("ThirdParty/google-earth-dbroot-parser.js"),i=window.cesiumGoogleEarthDbRootParser;g$=lx(n).then(function(){A$=window.cesiumGoogleEarthDbRootParser(qgt),l(i)?window.cesiumGoogleEarthDbRootParser=i:delete window.cesiumGoogleEarthDbRootParser})}return g$.then(function(){return t.fetchArrayBuffer()}).then(function(n){let i=A$.EncryptedDbRootProto.decode(new Uint8Array(n)),o=i.encryptionData,r=o.byteOffset,s=r+o.byteLength,a=e.key=o.buffer.slice(r,s);o=i.dbrootData,r=o.byteOffset,s=r+o.byteLength;let c=o.buffer.slice(r,s);return iSe.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 fKi=y(x(),1),UX=`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 AKi=y(x(),1),DX=`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 bKi=y(x(),1),kX=`#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 xKi=y(x(),1),QX=`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 TKi=y(x(),1),OX=`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 SKi=y(x(),1),zX=`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 IKi=y(x(),1),HX=`/** * 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 RKi=y(x(),1),JX=`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 GKi=y(x(),1),KX=`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 WKi=y(x(),1),jX=`in vec4 position;
out vec4 positionEC;
void main(){ positionEC = czm_modelView * position; gl_Position = czm_projection * positionEC;
czm_vertexLogDepth();}`;var BKi=y(x(),1),XZ=`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 NKi=y(x(),1),YZ=`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();}`;var XKi=y(x(),1);/**
* @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 qX=`/** * @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 MKi=y(x(),1),$X=`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 UKi=y(x(),1),eY=`#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 kKi=y(x(),1),MZ=`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 OKi=y(x(),1),vZ=`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 HKi=y(x(),1),tY=`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 KKi=y(x(),1),nY=`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 qKi=y(x(),1),iY=`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 eji=y(x(),1),oY=`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 nji=y(x(),1),rY=`uniform sampler2D u_texture;
in vec2 v_textureCoordinates;
void main(){ vec4 color = texture(u_texture, v_textureCoordinates); out_FragColor = czm_gammaCorrect(color);}`;var oji=y(x(),1),sY=`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 sji=y(x(),1),aY=`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 cji=y(x(),1),cY=`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);}`;var jbo=y(x(),1);var fji=y(x(),1);async function nee(e,t){let n=t.terrainProvider,i=t.mapProjection,o=i.ellipsoid,r,s=t.camera.getRectangleCameraCoordinates(e);if(t.mode===se.SCENE3D?r=o.cartesianToCartographic(s):r=i.unproject(s),!l(n))return r;let a=n.availability;if(!l(a)||t.mode===se.SCENE2D)return r;let c=[de.center(e),de.southeast(e),de.southwest(e),de.northeast(e),de.northwest(e)],d=await nee._sampleTerrainMostDetailed(n,c),u=!1,h=d.reduce(function(A,f){return l(f.height)?(u=!0,Math.max(f.height,A)):A},-Number.MAX_VALUE),p=r;return u&&(p.height+=h),p}nee._sampleTerrainMostDetailed=iE;var aE=nee;var v7i=y(x(),1);var Iji=y(x(),1);var bji=y(x(),1);var A0t=new M;function g0t(e,t){let n=e.unionClippingRegions,i=e.length,o=ls.useFloatTexture(t),r=ls.getTextureResolution(e,t,A0t),s=r.x,a=r.y,c=o?x0t(s,a):C0t(s,a);return c+=``,c+=n?b0t(i):y0t(i),c}function b0t(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 y0t(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 x0t(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 C0t(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 cE=g0t;function T0t(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 iee(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function E0t(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 se.SCENE3D:o=t;break;case se.SCENE2D:case se.COLUMBUS_VIEW:o=n;break;case se.MORPHING:o=i;break}return o}function S0t(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 _0t(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 I0t(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}iee.prototype.getShaderProgram=function(e){let t=e.frameState,n=e.surfaceTile,i=e.numberOfDayTextures,o=e.applyBrightness,r=e.applyContrast,s=e.applyHue,a=e.applySaturation,c=e.applyGamma,d=e.applyAlpha,u=e.applyDayNightAlpha,h=e.applySplit,p=e.hasWaterMask,A=e.showReflectiveOcean,f=e.showOceanWaves,b=e.enableLighting,C=e.dynamicAtmosphereLighting,T=e.dynamicAtmosphereLightingFromSun,E=e.showGroundAtmosphere,S=e.perFragmentGroundAtmosphere,I=e.hasVertexNormals,R=e.useWebMercatorProjection,V=e.enableFog,W=e.enableClippingPlanes,B=e.clippingPlanes,N=e.enableClippingPolygons,P=e.clippingPolygons,g=e.clippedByBoundaries,_=e.hasImageryLayerCutout,Z=e.colorCorrect,G=e.highlightFillTile,w=e.colorToAlpha,X=e.hasGeodeticSurfaceNormals,k=e.hasExaggeration,v=e.showUndergroundColor,D=e.translucent,Y=e.marsOptions||{},O=0,J="",z=n.renderedMesh.encoding;z.quantization===Da.BITS12&&(O=1,J="QUANTIZATION_BITS12");let ee=0,ge="";g&&(ee=1,ge="TILE_LIMIT_RECTANGLE");let ye=0,ae="";_&&(ye=1,ae="APPLY_IMAGERY_CUTOUT");let Ce=t.mode,Te=((Ce|o<<2|r<<3|s<<4|a<<5|c<<6|d<<7|p<<8|A<<9|f<<10|b<<11|C<<12|T<<13|E<<14|S<<15|I<<16|R<<17|V<<18|O<<19|h<<20|W<<21|N<<22|ee<<23|ye<<24|Z<<25|G<<26|w<<27|X<<28|k<<29|v<<30|D<<31)>>>0)+(u?4294967296:0),Fe=0;l(B)&&B.length>0&&(Fe=W?B.clippingPlanesState:0);let Ne=0;l(P)&&P.length>0&&(Ne=N?P.clippingPolygonsState:0);let Pe=n.surfaceShader;if(l(Pe)&&Pe.numberOfDayTextures===i&&Pe.flags===Te&&Pe.material===this.material&&Pe.clippingShaderState===Fe&&Pe.clippingPolygonShaderState===Ne)return Pe.shaderProgram;let Xe=this._shadersByTexturesFlags[i];if(l(Xe)||(Xe=this._shadersByTexturesFlags[i]=[]),Pe=Xe[Te],!l(Pe)||Pe.material!==this.material||Pe.clippingShaderState!==Fe||Pe.clippingPolygonShaderState!==Ne){let st=this.baseVertexShaderSource.clone(),Ye=this.baseFragmentShaderSource.clone();Fe!==0&&Ye.sources.unshift(cE(B,t.context)),Ne!==0&&(Ye.sources.unshift(S0t(t.context)),st.sources.unshift(_0t(t.context))),Y.enableUplift&&Ye.defines.push("APPLY_MARS3D_UPLIFT"),Y.enableFlat&&st.defines.push("APPLY_MARS3D_FLAT"),Y.enableClip&&Ye.defines.push("APPLY_MARS3D_CLIP"),Y.enableFlood&&Ye.defines.push("APPLY_MARS3D_FLOOD"),st.defines.push(J),Ye.defines.push(`TEXTURE_UNITS ${i}`,ge,ae),o&&Ye.defines.push("APPLY_BRIGHTNESS"),r&&Ye.defines.push("APPLY_CONTRAST"),s&&Ye.defines.push("APPLY_HUE"),a&&Ye.defines.push("APPLY_SATURATION"),c&&Ye.defines.push("APPLY_GAMMA"),Y.invertColor&&Ye.defines.push("APPLY_INVERT_COLOR_MARS3D"),Y.filterColor&&Ye.defines.push("APPLY_FILTER_COLOR_MARS3D"),d&&Ye.defines.push("APPLY_ALPHA"),u&&Ye.defines.push("APPLY_DAY_NIGHT_ALPHA"),p&&Ye.defines.push("HAS_WATER_MASK"),A&&(Ye.defines.push("SHOW_REFLECTIVE_OCEAN"),st.defines.push("SHOW_REFLECTIVE_OCEAN")),f&&Ye.defines.push("SHOW_OCEAN_WAVES"),w&&Ye.defines.push("APPLY_COLOR_TO_ALPHA"),v&&(st.defines.push("UNDERGROUND_COLOR"),Ye.defines.push("UNDERGROUND_COLOR")),D&&(st.defines.push("TRANSLUCENT"),Ye.defines.push("TRANSLUCENT")),b&&(I?(st.defines.push("ENABLE_VERTEX_LIGHTING"),Ye.defines.push("ENABLE_VERTEX_LIGHTING")):(st.defines.push("ENABLE_DAYNIGHT_SHADING"),Ye.defines.push("ENABLE_DAYNIGHT_SHADING"))),C&&(st.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),Ye.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),T&&(st.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),Ye.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),E&&(st.defines.push("GROUND_ATMOSPHERE"),Ye.defines.push("GROUND_ATMOSPHERE"),S&&(st.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"),Ye.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"))),st.defines.push("INCLUDE_WEB_MERCATOR_Y"),Ye.defines.push("INCLUDE_WEB_MERCATOR_Y"),V&&(st.defines.push("FOG"),Ye.defines.push("FOG")),h&&Ye.defines.push("APPLY_SPLIT"),W&&Ye.defines.push("ENABLE_CLIPPING_PLANES"),N&&(Ye.defines.push("ENABLE_CLIPPING_POLYGONS"),st.defines.push("ENABLE_CLIPP
{ vec4 color = initialColor;`;_&&(xt+=` vec4 cutoutAndColorResult; bool texelUnclipped;`);for(let Je=0;Je<i;++Je)_?xt+=` 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(`:xt+=` color = sampleAndBlend(`,xt+=` color, u_dayTextures[${Je}], u_dayTextureUseWebMercatorT[${Je}] ? textureCoordinates.xz : textureCoordinates.xy, u_dayTextureTexCoordsRectangle[${Je}], u_dayTextureTranslationAndScale[${Je}], ${d?`u_dayTextureAlpha[${Je}]`:"1.0"}, ${u?`u_dayTextureNightAlpha[${Je}]`:"1.0"}, ${u?`u_dayTextureDayAlpha[${Je}]`:"1.0"}, ${o?`u_dayTextureBrightness[${Je}]`:"0.0"}, ${r?`u_dayTextureContrast[${Je}]`:"0.0"}, ${s?`u_dayTextureHue[${Je}]`:"0.0"}, ${a?`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
${Y.invertColor?`u_mars3dTextureInvertColor[${Je}]`:"false"}, ${Y.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"}, ${w?`u_colorsToAlpha[${Je}]`:"vec4(0.0)"}, nightBlend);`,_&&(xt+=` color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);`);xt+=` return color; }`,Ye.sources.push(xt),st.sources.push(E0t(Ce)),st.sources.push(I0t(R));let at=tn.fromCache({context:t.context,vertexShaderSource:st,fragmentShaderSource:Ye,attributeLocations:z.getAttributeLocations()});Pe=Xe[Te]=new T0t(i,Te,this.material,at,Fe,Ne)}return n.surfaceShader=Pe,Pe.shaderProgram};iee.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 he(this)};var lY=iee;var _8i=y(x(),1);var t4i=y(x(),1);var Rji=y(x(),1),Z0t={START:0,LOADING:1,DONE:2,FAILED:3},Qa=Object.freeze(Z0t);var Gji=y(x(),1),R0t={FAILED:0,UNLOADED:1,RECEIVING:2,RECEIVED:3,TRANSFORMING:4,TRANSFORMED:5,READY:6},Wo=Object.freeze(R0t);function xr(){this.imagery=[],this.waterMaskTexture=void 0,this.waterMaskTranslationAndScale=new re(0,0,1,1),this.terrainData=void 0,this.vertexArray=void 0,this.tileBoundingRegion=void 0,this.occludeePointInScaledSpace=new m,this.boundingVolumeSourceTile=void 0,this.boundingVolumeIsFromMesh=!1,this.terrainState=Wo.UNLOADED,this.mesh=void 0,this.fill=void 0,this.pickBoundingSphere=new ue,this.surfaceShader=void 0,this.isClipped=!0,this.clippedByBoundaries=!1}Object.defineProperties(xr.prototype,{eligibleForUnloading:{get:function(){let e=this.terrainState,n=!(e===Wo.RECEIVING||e===Wo.TRANSFORMING),i=this.imagery;for(let o=0,r=i.length;n&&o<r;++o){let s=i[o];n=!l(s.loadingImagery)||s.loadingImagery.state!==Qn.TRANSITIONING}return n}},renderedMesh:{get:function(){if(l(this.vertexArray))return this.mesh;if(l(this.fill))return this.fill.mesh}}});xr.prototype.pick=function(e,t,n,i,o){if(!l(this.renderedMesh))return;let r=this.renderedMesh.pick(e,i,t,n);return m.clone(r,o)};xr.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=Wo.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()};xr.prototype.freeVertexArray=function(){xr._freeVertexArray(this.vertexArray),this.vertexArray=void 0,xr._freeVertexArray(this.wireframeVertexArray),this.wireframeVertexArray=void 0};xr.initialize=function(e,t,n){let i=e.data;l(i)||(i=e.data=new xr),e.state===Qa.START&&(V0t(e,t,n),e.state=Qa.LOADING)};xr.processStateMachine=function(e,t,n,i,o,r,s){xr.initialize(e,n,i);let a=e.data;if(e.state===Qa.LOADING&&G0t(e,t,n,i,o,r),s)return;let c=e.renderable;e.renderable=l(a.vertexArray);let d=a.terrainState===Wo.READY;e.upsampledFromParent=l(a.terrainData)&&a.terrainData.wasCreatedByUpsampling();let u=a.processImagery(e,n,t);if(d&&u){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=Qa.DONE}c&&(e.renderable=!0)};xr.prototype.processImagery=function(e,t,n,i){let o=e.data,r=e.upsampledFromParent,s=!1,a=!0,c=o.imagery,d,u;for(d=0,u=c.length;d<u;++d){let h=c[d];if(!l(h.loadingImagery)){r=!1;continue}if(h.loadingImagery.state===Qn.PLACEHOLDER){let A=h.loadingImagery.imageryLayer;if(A.ready){h.freeResources(),c.splice(d,1),A._createTileImagerySkeletons(e,t,d),--d,u=c.length;continue}else r=!1}let p=h.processStateMachine(e,n,i);a=a&&p,s=s||p||l(h.readyImagery),r=r&&l(h.loadingImagery)&&(h.loadingImagery.state===Qn.FAILED||h.loadingImagery.state===Qn.INVALID)}return e.upsampledFromParent=r,e.renderable=e.renderable&&(s||a),a};function JSe(e,t,n,i){let o=e.renderedMesh,r=o.vertices,s=o.encoding,a=r.length/s.stride,c=yr.clone(s);c.hasGeodeticSurfaceNormals=t,c=yr.clone(c);let d=c.stride,u=new Float32Array(a*d);t?s.addGeodeticSurfaceNormals(r,u,n):s.removeGeodeticSurfaceNormals(r,u),o.vertices=u,o.stride=d,o!==e.mesh?(xr._freeVertexArray(e.fill.vertexArray),e.fill.vertexArray=xr._createVertexArrayForMesh(i.context,o)):(xr._freeVertexArray(e.vertexArray),e.vertexArray=xr._createVertexArrayForMesh(i.context,o)),xr._fre
.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: ${GY}; position: relative; min-height: ${QCt}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: ${GY};}.cesium-credit-lightbox > ul > li a:hover { color: ${VO};}.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: ${GY};}.cesium-credit-lightbox-close:hover { color: ${VO};}.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: ${GY};}.cesium-credit-expand-link:hover { color: ${VO};}
.cesium-credit-text { color: ${GY};}
.cesium-credit-delimiter { padding: 0 5px;}
.cesium-credit-textContainer *,.cesium-credit-logoContainer * { display: inline;}
.cesium-credit-textContainer a:hover { color: ${VO}}
.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 s=r.getRootNode();if(s instanceof ShadowRoot)return s}}let i=n(e)??document.head,o=document.createElement("style");o.innerHTML=t,i.appendChild(o)}function Ur(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 s(f){r.contains(f.target)||i.hideLightbox()}o.addEventListener("click",s,!1);let a=document.createElement("div");a.className="cesium-credit-lightbox-title",a.textContent="Data provided by:",r.appendChild(a);let c=document.createElement("a");c.onclick=this.hideLightbox.bind(this),c.innerHTML="×",c.className="cesium-credit-lightbox-close",r.appendChild(c);let d=document.createElement("ul");r.appendChild(d);let u=document.createElement("div");u.className="cesium-credit-logoContainer",u.style.display="inline",e.appendChild(u);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),JCt(e);let A=Et.clone(Ur.cesiumCredit);this._delimiter=t??"\u2022",this._screenContainer=h,this._cesiumCreditContainer=u,this._lastViewportHeight=void 0,this._lastViewportWidth=void 0,this._lightboxCredits=r,this._creditList=d,this._lightbox=o,this._hideLightbox=s,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 Xt,lightboxCredits:new Xt},this._defaultCredit=void 0,this.viewport=n,this.container=e}function iIe(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,s=e._creditDisplayElementPoolIndex;s<r.length?(o=r[s],o.credit=n,o.count=i):(o=new tIe(n,i),r.push(o)),++e._creditDisplayElementPoolIndex,t.set(n.id,o)}}Ur.prototype.addCreditToNextFrame=function(e){if(e.isIon()){l(this._defaultCredit)||(this._defaultCredit=Et.clone(oIe())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,iIe(this,t,e)};Ur.prototype.addStaticCredit=function(e){let t=this._staticCredits;OCt(t,e)||t.push(e)};Ur.prototype.removeStaticCredit=function(e){let t=this._staticCredits,n=t.indexOf(e);n!==-1&&t.splice(n,1)};Ur.prototype.showLightbox=function(){this._lightbox.style.display="block",this._expanded=!0};Ur.prototype.hideLightbox=function(){this._lightbox.style.display="none",this._expanded=!1};Ur.prototype.update=function(){this._expanded&&HCt(this)};Ur.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],s=r.showOnScreen?t:n;r.isIon()&&Et.equals(Ur.cesiumCredit,this._cesiumCredit)||iIe(this,s,r,Number.MAX_VALUE)}Et.equals(Ur.cesiumCredit,this._cesiumCredit)||(this._cesiumCredit=Et.clone(Ur.cesiumCredit)),this._currentCesiumCredit=this._cesiumCredit};Ur.prototype.endFrame=function(){let e=this._currentFrameCredits.screenCredits.values;$_e(this._screenContainer,e,this._delimiter,void 0);let t=this._currentFrameCredits.lightboxCredits.values;this._expandLink.style.display=t.length>0?"inline":"none",$_e(this._creditList,t,void 0,"li"),zCt(this)};Ur.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),he(this)};Ur.prototype.isDestroyed=function(){return!1};Ur._cesiumCredit=void 0;Ur._cesiumCredit
{ out_FragColor = vec4(1.0);}`;i=new ze({sources:[a]})}else if(!o&&s){let a=`void main(){ out_FragColor = vec4(1.0); czm_writeLogDepth();}`;i=new ze({defines:["LOG_DEPTH"],sources:[a]})}return e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}function lTt(e,t){let n=e._depthOnlyRenderStateCache,i=n[t.id];if(l(i))return i;let o=Qe.getState(t);o.depthMask=!0,o.colorMask={red:!1,green:!1,blue:!1,alpha:!1};let r=Qe.fromCache(o);return n[t.id]=r,r}HZ.createDepthOnlyDerivedCommand=function(e,t,n,i){l(i)||(i={});let o=i.depthOnlyCommand?.shaderProgram,r=i.depthOnlyCommand?.renderState;return i.depthOnlyCommand=ot.shallowClone(t,i.depthOnlyCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=cTt(n,t.shaderProgram),i.depthOnlyCommand.renderState=lTt(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=o,i.depthOnlyCommand.renderState=r),i};var dTt=/\s+czm_writeLogDepth\(/,uTt=/\s+czm_vertexLogDepth\(/;function mTt(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(),s=t.fragmentShaderSource.clone();r.defines=l(r.defines)?r.defines.slice(0):[],r.defines.push("LOG_DEPTH"),s.defines=l(s.defines)?s.defines.slice(0):[],s.defines.push("LOG_DEPTH");let a=!1,c=r.sources;for(let u=0;u<c.length;++u)if(uTt.test(c[u])){a=!0;break}if(!a){for(let h=0;h<c.length;++h)c[h]=ze.replaceMain(c[h],"czm_log_depth_main");c.push(`
void main(){ czm_log_depth_main(); czm_vertexLogDepth();}`)}c=s.sources,a=!1;for(let u=0;u<c.length;++u)dTt.test(c[u])&&(a=!0);s.defines.indexOf("LOG_DEPTH_WRITE")!==-1&&(a=!0);let d="";if(!a){for(let u=0;u<c.length;u++)c[u]=ze.replaceMain(c[u],"czm_log_depth_main");d=`void main(){ czm_log_depth_main(); czm_writeLogDepth();}`}return c.push(d),e.shaderCache.createDerivedShaderProgram(t,"logDepth",{vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:o})}HZ.createLogDepthCommand=function(e,t,n){l(n)||(n={});let i=n.command?.shaderProgram;return n.command=ot.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=mTt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function hTt(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:s}=t.fragmentShaderSource,c=r.some(A=>A.includes("out_FragData"))?"out_FragData_0":"out_FragColor",d=`void main (){ czm_non_pick_main(); if (${c}.a == 0.0) { discard; } ${c} = ${n};} `,u=r.length,h=new Array(u+1);for(let A=0;A<u;++A)h[A]=ze.replaceMain(r[A],"czm_non_pick_main");h[u]=d;let p=new ze({sources:h,defines:s});return e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:p,attributeLocations:o})}function cIe(e,t){let n=e.picking.pickRenderStateCache,i=n[t.id];if(l(i))return i;let o=Qe.getState(t);o.blending.enabled=!1,o.depthMask=!0;let r=Qe.fromCache(o);return n[t.id]=r,r}HZ.createPickDerivedCommand=function(e,t,n,i){l(i)||(i={});let o=i.pickCommand?.shaderProgram,r=i.pickCommand?.renderState;return i.pickCommand=ot.shallowClone(t,i.pickCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=hTt(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=cIe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=o,i.pickCommand.renderState=r),i};function zZ(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 fTt(e){return e.isArray?e.arrayLength:St.getComponentCount(e.type)}function lIe(e,t,n){return`((${e} - float(${t})) / float(${n}))`}function dIe(e,t){let n=Yt.getMaximum(t);return`(${e}) / float(${n})`}function pTt(e,t){let n="float(value)";if(t.hasValueTransform){let i=t.offset,o=t.scale;n=lIe(n,i,o)}return e.normalized||(n=dIe(n,e.componentType)),n}function ATt(e,t,n){let o=`float(${`value.${n}`})`;if(t.hasValueTransform){let r=t.offset[n],s=t.scale[n];o=lIe(o,r,s)}return e.normalized||(o=dIe(o,e.componentType)),o}function gTt(e,t,n){let i=n.schemaId,o=n.className,r=n.propertyName,s=`pickMetadata-${i}-${o}-${r}`,a=e.shaderCache.getDerivedShaderProgram(t,s);if(l(a))return a;let c=n.metadataProperty,d=n.classProperty,u=d.getGlslType(),h=["0.0","0.0","0.0","0.0"],p=fTt(d);if(p===1)h[0]=pTt(d,c);else{let C=["x","y","z","w"];for(let T=0;T<p;T++)h[T]=ATt(d,c,C[T])}let A=t.fragmentShaderSource.defines.slice();A.push(Au.METADATA_PICKING_ENABLED),zZ(A,Au.METADATA_PICKING_VALUE_TYPE,u),zZ(A,Au.METADATA_PICKING_VALUE_STRING,`metadata.${r}`),zZ(A,Au.METADATA_PICKING_VALUE_COMPONENT_X,h[0]),zZ(A,Au.METADATA_PICKING_VALUE_COMPONENT_Y,h[1]),zZ(A,Au.METADATA_PICKING_VALUE_COMPONENT_Z,h[2]),zZ(A,Au.METADATA_PICKING_VALUE_COMPONENT_W,h[3]);let f=new ze({sources:t.fragmentShaderSource.sources,defines:A});return e.shaderCache.createDerivedShaderProgram(t,s,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:f,attributeLocations:t._attributeLocations})}HZ.createPickMetadataDerivedCommand=function(e,t,n,i){return l(i)||(i={}),i.pickMetadataCommand=ot.shallowClone(t,i.pickMetadataCommand),i.pickMetadataCommand.shaderProgram=gTt(n,t.shaderProgram,t.pickedMetadataInfo),i.pickMetadataCommand.renderState=cIe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id,i};function bTt(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})}HZ.createHdrCommand=function(e,t,n){l(n)||(n={});let i=n.command?.shaderProgram;return n.command=ot.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=bTt(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};var nA=HZ;var v$i=y(x(),1);function FO(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=L.toRadians(o),t._beta=L.toRadians(i.beta),t._gamma=L.toRadians(i.gamma)}window.addEventListener("deviceorientation",n,!1),this._removeListener=function(){window.removeEventListener("deviceorientation",n,!1)}}var yTt=new Me,uIe=new Me,xTt=new $;function CTt(e,t,n,i){let o=e.direc
{ out_FragColor = vec4(1.0); } `;t.sources=[n]}function Vee(e,t){let n=t.sources,i=n.length;for(let r=0;r<i;++r)n[r]=ze.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 TIe(e,t){Vee(e,t),sh(e.defines,"GROUND_ATMOSPHERE"),sh(t.defines,"GROUND_ATMOSPHERE"),sh(e.defines,"FOG"),sh(t.defines,"FOG")}function WTt(e,t){Vee(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function FTt(e,t){TIe(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function pIe(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 BTt(e,t,n,i,o,r){if(!l(o))return t;if(!i&&l(n))return n;let s=e.shaderCache.getDerivedShaderProgram(t,r);if(!l(s)){let a=t._attributeLocations,c=t.vertexShaderSource.clone(),d=t.fragmentShaderSource.clone();c.defines=l(c.defines)?c.defines.slice(0):[],d.defines=l(d.defines)?d.defines.slice(0):[],o(c,d),s=e.shaderCache.createDerivedShaderProgram(t,r,{vertexShaderSource:c,fragmentShaderSource:d,attributeLocations:a})}return s}function wTt(e){e.cull.face=wi.BACK,e.cull.enabled=!0}function NTt(e){e.cull.face=wi.FRONT,e.cull.enabled=!0}function PTt(e){e.cull.face=wi.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function XTt(e){e.cull.face=wi.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function YTt(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function AIe(e){e.cull.face=wi.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=ln.ALPHA_BLEND}function gIe(e){e.cull.face=wi.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=ln.ALPHA_BLEND}function MTt(e){e.cull.face=wi.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function vTt(e){e.cull.face=wi.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function UTt(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 s=Qe.getState(e);i(s),r=Qe.fromCache(s),o[e.id]=r}return r}function JZ(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function DTt(e,t,n,i,o){return l(o)?!i&&l(n)?n:Ft(t,o(e),!1):t}function Yf(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function kTt(){return[new Yf({pass:Ge.GLOBE,pickOnly:!1,getShaderProgramFunction:GTt,getRenderStateFunction:wTt,getUniformMapFunction:void 0}),new Yf({pass:Ge.GLOBE,pickOnly:!1,getShaderProgramFunction:LTt,getRenderStateFunction:NTt,getUniformMapFunction:void 0}),new Yf({pass:Ge.GLOBE,pickOnly:!1,getShaderProgramFunction:Ree,getRenderStateFunction:PTt,getUniformMapFunction:void 0}),new Yf({pass:Ge.GLOBE,pickOnly:!1,getShaderProgramFunction:Ree,getRenderStateFunction:XTt,getUniformMapFunction:void 0}),new Yf({pass:Ge.GLOBE,pickOnly:!1,getShaderProgramFunction:Ree,getRenderStateFunction:YTt,getUniformMapFunction:void 0}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Vee,getRenderStateFunction:AIe,getUniformMapFunction:JZ}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:TIe,getRenderStateFunction:gIe,getUniformMapFunction:JZ}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:WTt,getRenderStateFunction:AIe,getUniformMapFunction:JZ}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:FTt,getRenderStateFunction:gIe,getUniformMapFunction:JZ}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:pIe,getRenderStateFunction:MTt,getUniformMapFunction:JZ}),new Yf({pass:Ge.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:pIe,getRenderStateFunction:vTt,getUniformMapFunction:JZ})]}var bIe=new Array(dE),yIe=new Array(dE);uE.prototype.updateDerivedCommands=function(e,t){let n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let o=0;o<i;++o)yIe[o]=this._derivedCommandPacks[n[o]],bIe[o]=CIe[n[o]];QTt(this,e,i,n,bIe,yIe,t)}};function QTt(e,t,n,i,o,r,s){let a=t.derivedCommands.globeTranslucency,c=e._derivedCommandsDirty;if(t.dirty||!l(a)||c){t.dirty=!1,l(a)||(a={},t.derivedCommands.globeTranslucency=a);let d=s.frameNumber,u=a.uniformMapDirtyFrame??0,h=a.shaderProgramDirtyFrame??0,p=a.renderStateDirtyFrame??0,A=a.uniformMap!==t.uniformMap,f=a.shaderProgramId!==t.shaderProgram.id,b=a.renderStateId!==t.renderState.id;A&&(a.uniformMapDirtyFrame=d),f&&(a.shaderProgramDirtyFrame=d),b&&(a.renderStateDirtyFrame=d),a.uniformMap=t.uniformMap,a.shaderProgramId=t.shaderProgram.id,a.renderStateId=t.renderState.id;for(let C=0;C<n;++C){let T=r[C],E=i[C],S=o[C],I=a[S],R,V,W;l(I)?(R=I.uniformMap,V=I.shaderProgra
in vec2 v_textureCoordinates;
void main(){ out_FragColor = texture(colorTexture, v_textureCoordinates);}`;function iA(){this._numSamples=1,this.previousFramebuffer=void 0,this._previousFramebuffer=void 0,this._depthStencilTexture=void 0,this._depthStencilRenderbuffer=void 0,this._fbo=new Ti({depthStencil:!0,createDepthAttachments:!1}),this._fboClassified=new Ti({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 mi({color:new U(0,0,0,0),owner:this}),this._clearCommand=new mi({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(iA.prototype,{unclassifiedCommand:{get:function(){return this._unclassifiedCommand}}});iA.isTranslucencySupported=function(e){return e.depthTexture&&e.fragmentDepth};var HTt={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ni.EQUAL,frontOperation:{fail:Vt.KEEP,zFail:Vt.KEEP,zPass:Vt.KEEP},backFunction:ni.NEVER,reference:0,mask:Jt.CLASSIFICATION_MASK},blending:ln.ALPHA_BLEND},JTt={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ni.NOT_EQUAL,frontOperation:{fail:Vt.KEEP,zFail:Vt.KEEP,zPass:Vt.KEEP},backFunction:ni.NEVER,reference:0,mask:Jt.CLASSIFICATION_MASK},blending:ln.ALPHA_BLEND},KTt={depthMask:!0,depthTest:{enabled:!0},stencilTest:Jt.setCesium3DTileBit(),stencilMask:Jt.CESIUM_3D_TILE_MASK,blending:ln.ALPHA_BLEND},jTt=`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;}`,qTt=`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}`;iA.prototype.update=function(e,t,n){let i=this._fbo.getColorTexture(),o=this.previousFramebuffer!==this._previousFramebuffer;this._previousFramebuffer=this.previousFramebuffer;let r=this._numSamples!==t,s=e.drawingBufferWidth,a=e.drawingBufferHeight,c=!l(i)||i.width!==s||i.height!==a;if((c||o||r)&&(this._numSamples=t,this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),l(this._previousFramebuffer)||(this._depthStencilTexture=new Lt({context:e,width:s,height:a,pixelFormat:Ke.DEPTH_STENCIL,pixelDatatype:Oe.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new nu({context:e,width:s,height:a,format:Tl.DEPTH24_STENCIL8,numSamples:t})))),!l(this._fbo.framebuffer)||c||o||r){this._fbo.destroy(),this._fboClassified.destroy();let d,u;l(this._previousFramebuffer)?(d=n.getDepthStencilTexture(),u=n.getDepthStencilRenderbuffer()):(d=this._depthStencilTexture,u=this._depthStencilRenderbuffer),this._fbo.setDepthStencilTexture(d),l(u)&&this._fbo.setDepthStencilRenderbuffer(u),this._fbo.update(e,s,a,t),l(this._previousFramebuffer)||(this._fboClassified.setDepthStencilTexture(d),this._fboClassified.update(e,s,a))}if(l(this._rsUnclassified)||(this._rsUnclassified=Qe.fromCache(HTt),this._rsClassified=Qe.fromCache(JTt),this._rsDefault=Qe.fromCache(KTt)),!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 d=l(this._previousFramebuffer)?qTt:jTt,u=new ze({defines:["UNCLASSIFIED"],sources:[d]}),h=new ze({sources:[d]});this._unclassifiedCommand=e.createViewportQuadCommand(u,{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(vd,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};iA.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};iA.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))};iA.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)};iA.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};iA.prototype.isDestroyed=function(){return!1};iA.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()),he(this)};var KZ=iA;var weo=y(x(),1);function BO(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties(BO.prototype,{total:{get:function(){return this._total}}});function Qy(e){let t=new Array(Ic.NUMBER_OF_JOB_TYPES);t[Ic.TEXTU
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:Qe.fromCache(),uniformMap:{colorTexture:function(){return e._textureToCopy}},owner:e})),e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}mE.prototype.update=function(e,t){$Tt(this,e,t),eEt(this,e,t)};var tEt=new re,nEt=new re(1,1/255,1/65025,1/16581375);mE.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=re.unpack(i,0,tEt);return re.divideByScalar(o,255,o),re.dot(o,nEt)};mE.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};mE.prototype.isDestroyed=function(){return!1};mE.prototype.destroy=function(){return this._framebuffer.destroy(),l(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=l(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),he(this)};var vY=mE;var Voo=y(x(),1);var Ato=y(x(),1);function Oy(e){e=e||{},this._framebufferManager=new Ti({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 mi({color:new U(0,0,0,0),depth:1,stencil:0,owner:this})}Object.defineProperties(Oy.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}}});Oy.prototype.update=function(e,t,n,i,o){let r=t.width,s=t.height,a=n?e.halfFloatingPointTexture?Oe.HALF_FLOAT:Oe.FLOAT:Oe.UNSIGNED_BYTE,c=this._framebufferManager.update(e,r,s,1,a,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};Oy.prototype.clear=function(e,t,n){this.getClearCommand(n).execute(e,t)};Oy.prototype.getClearCommand=function(e){return this._clearCommand.framebuffer=this._framebuffer,l(e)&&U.clone(e,this._clearCommand.color),this._clearCommand};Oy.prototype.getFramebuffer=function(e,t,n,i){return this.update(e,t,!1,n,i),this._framebuffer};Oy.prototype.isDestroyed=function(){return!1};Oy.prototype.destroy=function(){return this._framebufferManager=this._framebufferManager&&this._framebufferManager.destroy(),this._clearCommand=void 0,he(this)};var UY=Oy;var yto=y(x(),1);function iEt(e,t){this.near=e??0,this.far=t??0;let n=Ge.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 DY=iEt;var Pto=y(x(),1);var Cto=y(x(),1),zy=`uniform highp sampler2D u_depthTexture;
in vec2 v_textureCoordinates;
void main(){ out_FragColor = czm_packDepth(texture(u_depthTexture, v_textureCoordinates).r);}`;function oA(){this._picking=!1,this._numSamples=1,this._tempCopyDepthTexture=void 0,this._pickColorFramebuffer=new Ti({depthStencil:!0,supportsDepthTexture:!0}),this._outputFramebuffer=new Ti({depthStencil:!0,supportsDepthTexture:!0}),this._copyDepthFramebuffer=new Ti,this._tempCopyDepthFramebuffer=new Ti,this._updateDepthFramebuffer=new Ti({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 nt,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(oA.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 SIe(e,t,n,i,o){let r=e._viewport;r.width=n,r.height=i;let s=!nt.equals(r,o.viewport),a=s!==e._useScissorTest;e._useScissorTest=s,nt.equals(e._scissorRectangle,o.viewport)||(e._scissorRectangle=nt.clone(o.viewport,e._scissorRectangle),a=!0),(!l(e._rs)||!nt.equals(r,e._rs.viewport)||a)&&(e._rs=Qe.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=Qe.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:ln.ALPHA_BLEND}),e._rsUpdate=Qe.fromCache({viewport:r,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ni.EQUAL,frontOperation:{fail:Vt.KEEP,zFail:Vt.KEEP,zPass:Vt.KEEP},backFunction:ni.NEVER,reference:Jt.CESIUM_3D_TILE_MASK,mask:Jt.CESIUM_3D_TILE_MASK}})),l(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(zy,{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(vd,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,l(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(zy,{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(vd,{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 mi({color:new U(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}oA.prototype.update=function(e,t,n,i,o,r){let{width:s,height:a}=n,c=o?e.halfFloatingPointTexture?Oe.HALF_FLOAT:Oe.FLOAT:Oe.UNSIGNED_BYTE;this._numSamples=i,this.picking?this._pickColorFramebuffer.update(e,s,a):this._outputFramebuffer.update(e,s,a,i,c),this._copyDepthFramebuffer.update(e,s,a),SIe(this,e,s,a,t),e.uniformState.globeDepthTexture=void 0,this._clearGlobeDepth=r};oA.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};oA.prototype.executeCopyDepth=function(e,t){l(this._copyDepthCommand)&&(this.prepareColorTextures(e),this._copyDepthCommand.execute(e,t),e.uniformState.globeDepthTexture=this._copyDepthFramebuffer.getColorTexture())};oA.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);`,AEt=` 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;`,gEt=` float ai = czm_out_FragColor.a; out_FragColor = vec4(ai);`;function Wee(e,t,n,i){let{shaderCache:o}=e,r=o.getDerivedShaderProgram(t,n);if(l(r))return r;let s=t._attributeLocations,a=t.fragmentShaderSource.clone();a.sources=a.sources.map(function(u){return ze.replaceMain(u,"czm_translucent_main").replace(/out_FragColor/g,"czm_out_FragColor").replace(/layout\s*\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,"").replace(/\bdiscard\b/g,"czm_discard = true").replace(/czm_phong/g,"czm_translucentPhong")}),a.sources.splice(0,0,`#define CESIUM_REDIRECTED_COLOR_OUTPUTvec4 czm_out_FragColor;bool czm_discard = false;`);let c=[...i.matchAll(/out_FragData_(\d+)/g)],d="";for(let u=0;u<c.length;u++){let h=c[u];d=`layout (location = ${h[1]}) out vec4 ${h[0]};${d}`}return a.sources.push(d),a.sources.push(`void main(){ czm_translucent_main(); if (czm_discard) { discard; }${i}}`),o.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:a,attributeLocations:s})}function bEt(e,t){return Wee(e,t,"translucentMRT",pEt)}function yEt(e,t){return Wee(e,t,"translucentMultipass",AEt)}function xEt(e,t){return Wee(e,t,"alphaMultipass",gEt)}Eb.prototype.createDerivedCommands=function(e,t,n){if(l(n)||(n={}),this._translucentMRTSupport){let a,c;return l(n.translucentCommand)&&(a=n.translucentCommand.shaderProgram,c=n.translucentCommand.renderState),n.translucentCommand=ot.shallowClone(e,n.translucentCommand),!l(a)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=bEt(t,e.shaderProgram),n.translucentCommand.renderState=mEt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=a,n.translucentCommand.renderState=c),n}let i,o,r,s;return l(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,o=n.translucentCommand.renderState,r=n.alphaCommand.shaderProgram,s=n.alphaCommand.renderState),n.translucentCommand=ot.shallowClone(e,n.translucentCommand),n.alphaCommand=ot.shallowClone(e,n.alphaCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=yEt(t,e.shaderProgram),n.translucentCommand.renderState=hEt(this,t,e.renderState),n.alphaCommand.shaderProgram=xEt(t,e.shaderProgram),n.alphaCommand.renderState=fEt(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=i,n.translucentCommand.renderState=o,n.alphaCommand.shaderProgram=r,n.alphaCommand.renderState=s),n};function CEt(e,t,n,i,o,r){let{context:s,frameState:a}=t,{useLogDepth:c,shadowState:d}=a,u=t._hdr,h=i.framebuffer,p=d.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(s,i),i.framebuffer=e._adjustAlphaFBO.framebuffer,e._adjustAlphaCommand.execute(s,i);let A=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;for(let f=0;f<o.length;++f){let b=o[f];b=c?b.derivedCommands.logDepth.command:b,b=u?b.derivedCommands.hdr.command:b;let C=p&&b.receiveShadows?b.derivedCommands.oit.shadows.translucentCommand:b.derivedCommands.oit.translucentCommand;n(C,t,i,A)}if(l(r)){let f=r.unclassifiedCommand,b=p&&f.receiveShadows?f.derivedCommands.oit.shadows.translucentCommand:f.derivedCommands.oit.translucentCommand;n(b,t,i,A)}i.framebuffer=e._alphaFBO.framebuffer;for(let f=0;f<o.length;++f){let b=o[f];b=c?b.derivedCommands.logDepth.command:b,b=u?b.derivedCommands.hdr.command:b;let C=p&&b.receiveShadows?b.derivedCommands.oit.shadows.alphaCommand:b.derivedCommands.oit.alphaCommand;n(C,t,i,A)}if(l(r)){let f=r.unclassifiedCommand,b=p&&f.receiveShadows?f.derivedCommands.oit.shadows.alphaCommand:f.derivedCommands.oit.alphaCommand;n(b,t,i,A)}i.framebuffer=h}function TEt(e,t,n,i,o,r){let{context:s,frameState:a}=t,{useLogDepth:c,shadowState:d}=a,u=t._hdr,h=i.framebuffer,p=d.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(s,i);let A=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;for(let f=0;f<o.length;++f){let b=o[f];b=c?b.derivedCommands.logDepth.command:b,b=u?b.derivedCommands.hdr.command:b;let C=p&&b.receiveShadows?b.derivedCommands.oit.shadows.translucentCommand:b.derivedCommands.oit.translucentCommand;n(C,t,i,A)}if(l(r)){let f=r.unclassifiedCommand,b=p&&f.receiveShadows?f.derivedCommands.oit.shadows.translucentCommand:f.derivedCommands.oit.translucentCommand;n(b,t,i,A)}i.framebuffer=h}Eb.prototype.executeCommands=function(e,t,n,i,o){if(this._translucentMRTSupport){TEt(this,e,t,n,i,o);return}CEt(this,e,t,n,i,o)};Eb.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};Eb.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 ze({defines:i,sources:o})};AE.createShadowCastFragmentShader=function(e,t,n,i){let o=e.defines.slice(0),r=e.sources.slice(0);o.push("SHADOW_MAP");let s=ze.findPositionVarying(e),a=l(s);a||(s="v_positionEC");let c=r.length;for(let u=0;u<c;++u)r[u]=ze.replaceMain(r[u],"czm_shadow_cast_main");let d="";return t&&(a||(d+=`in vec3 v_positionEC; `),d+=`uniform vec4 shadowMap_lightPositionEC; `),i?d+=`void main() { `:d+=`void main() { czm_shadow_cast_main(); if (out_FragColor.a == 0.0) { discard; } `,t?d+=` float distance = length(${s}); if (distance >= shadowMap_lightPositionEC.w) { discard; } distance /= shadowMap_lightPositionEC.w; // radius
out_FragColor = czm_packDepth(distance); `:n?d+=` out_FragColor = vec4(1.0); `:d+=` out_FragColor = czm_packDepth(gl_FragCoord.z); `,d+=`} `,r.push(d),new ze({defines:o,sources:r})};AE.getShadowReceiveShaderKeyword=function(e,t,n,i){let o=e._usesDepthTexture,r=e._polygonOffsetSupported,s=e._isPointLight,a=e._isSpotLight,c=e._numberOfCascades>1,d=e.debugCascadeColors,u=e.softShadows;return`receiveShadow ${o}${r}${s}${a}${c}${d}${u}${t}${n}${i}`};AE.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 ze({defines:i,sources:o})};AE.createShadowReceiveFragmentShader=function(e,t,n,i,o){let r=ze.findNormalVarying(e),s=!i&&l(r)||i&&o,a=ze.findPositionVarying(e),c=l(a),d=t._usesDepthTexture,u=t._polygonOffsetSupported,h=t._isPointLight,p=t._isSpotLight,A=t._numberOfCascades>1,f=t.debugCascadeColors,b=t.softShadows,C=h?t._pointBias:i?t._terrainBias:t._primitiveBias,T=e.defines.slice(0),E=e.sources.slice(0),S=E.length;for(let V=0;V<S;++V)E[V]=ze.replaceMain(E[V],"czm_shadow_receive_main");h?T.push("USE_CUBE_MAP_SHADOW"):d&&T.push("USE_SHADOW_DEPTH_TEXTURE"),b&&!h&&T.push("USE_SOFT_SHADOWS"),A&&n&&i&&(s?T.push("ENABLE_VERTEX_LIGHTING"):T.push("ENABLE_DAYNIGHT_SHADING")),n&&C.normalShading&&s&&(T.push("USE_NORMAL_SHADING"),C.normalShadingSmooth>0&&T.push("USE_NORMAL_SHADING_SMOOTH"));let I="";h?I+=`uniform samplerCube shadowMap_textureCube; `:I+=`uniform sampler2D shadowMap_texture; `;let R;return c?R=` return vec4(${a}, 1.0); `:R=`#ifndef LOG_DEPTH return czm_windowToEyeCoordinates(gl_FragCoord); #else return vec4(v_logPositionEC, 1.0); #endif `,I+=`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() { ${R}} vec3 getNormalEC() { ${s?` return normalize(${r});
`:` return vec3(1.0); `}}
void applyNormalOffset(inout vec4 positionEC, vec3 normalEC, float nDotL) { ${C.normalOffset&&s?` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
float normalOffsetScale = 1.0 - nDotL; vec3 offset = normalOffset * normalOffsetScale * normalEC; positionEC.xyz += offset; `:""}}
`,I+=`void main() { czm_shadow_receive_main(); vec4 positionEC = getPositionEC(); vec3 normalEC = getNormalEC(); float depth = -positionEC.z; `,I+=` czm_shadowParameters shadowParameters; shadowParameters.texelStepSize = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.xy; shadowParameters.depthBias = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.z; shadowParameters.normalShadingSmooth = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.w; shadowParameters.darkness = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.w; `,i?I+=` shadowParameters.depthBias *= max(depth * 0.01, 1.0); `:u||(I+=` shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015); `),h?I+=` 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?I+=` 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?I+=` 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); ${f?` // Draw cascade colors for debugging
out_FragColor *= czm_cascadeColor(weights); `:""}`:I+=` 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); `,I+=` out_FragColor.rgb *= visibility; } `,E.push(I),new ze({defines:T,sources:E})};var rA=AE;function sA(e){e=e??Q.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 F,this._shadowMapTexture=void 0,this._lightDirectionEC=new m,this._lightPositionEC=new re,this._distance=0,this._lightCamera=e.lightCamera,this._shadowMapCamera=new NO,this._shadowMapCullingVolume=void 0,this._sceneCamera=void 0,this._boundingSphere=new ue,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 M,this._isSpotLight=!1,this._cascadesEnabled?this._shadowMapCamera.frustum=new as:l(this._lightCamera.frustum.fov)&&(this._isSpotLight=!0),this._cascadeSplits=[new re,new re],this._cascadeMatrices=[new F,new F,new F,new F],this._cascadeDistances=new re;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 IEt(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,Bee(this),this._clearCommand=new mi({depth:1,color:new U}),this._clearPassState=new Uc(t),this._size=e.size??2048,this.size=this._size}sA.MAXIMUM_DISTANCE=2e4;function IEt(e){this.camera=new NO,this.passState=new Uc(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function Fee(e,t){return Qe.fromCache({cull:{enabled:!0,face:wi.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 Bee(e){let t=!e._usesDepthTexture;e._primitiveRenderState=Fee(t,e._primitiveBias),e._terrainRenderState=Fee(t,e._terrainBias),e._pointRenderState=Fee(t,e._pointBias)}sA.prototype.debugCreateRenderStates=function(){Bee(this)};Object.defineProperties(sA.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){WEt(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=Ge.OVERLAY,i}function wEt(e,t){let n=t.context,i=t.context.drawingBufferWidth,o=t.context.drawingBufferHeight,r=Math.min(i,o)*.3,s=FEt;s.x=i-r,s.y=0,s.width=r,s.height=r;let a=e._debugShadowViewCommand;l(a)||(a=BEt(e,n),e._debugShadowViewCommand=a),(!l(a.renderState)||!nt.equals(a.renderState.viewport,s))&&(a.renderState=Qe.fromCache({viewport:nt.clone(s)})),t.commandList.push(e._debugShadowViewCommand)}var aA=new Array(8);aA[0]=new re(-1,-1,-1,1);aA[1]=new re(1,-1,-1,1);aA[2]=new re(1,1,-1,1);aA[3]=new re(-1,1,-1,1);aA[4]=new re(-1,-1,1,1);aA[5]=new re(1,-1,1,1);aA[6]=new re(1,1,1,1);aA[7]=new re(-1,1,1,1);var Hy=new F,Nee=new Array(8);for(let e=0;e<8;++e)Nee[e]=new re;function NEt(e,t){let n=new wt({geometry:new Rh({minimum:new m(-.5,-.5,-.5),maximum:new m(.5,.5,.5)}),attributes:{color:$t.fromColor(t)}}),i=new wt({geometry:new Yg({radius:.5}),attributes:{color:$t.fromColor(t)}});return new Nn({geometryInstances:[n,i],appearance:new yn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}var PEt=[U.RED,U.GREEN,U.BLUE,U.MAGENTA],XEt=new m;function YEt(e,t){wEt(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 tA({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 tA({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 tA({camera:e._passes[i].camera,color:PEt[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!l(e._debugLightFrustum)||e._needsUpdate){let i=e._shadowMapCamera.positionWC,o=Me.IDENTITY,r=e._pointLightRadius*2,s=m.fromElements(r,r,r,XEt),a=F.fromTranslationQuaternionRotationScale(i,o,s,Hy);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=NEt(a,U.YELLOW)}e._debugLightFrustum.update(t)}else(!l(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new tA({camera:e._shadowMapCamera,color:U.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function NO(){this.viewMatrix=new F,this.inverseViewMatrix=new F,this.frustum=void 0,this.positionCartographic=new Ae,this.positionWC=new m,this.directionWC=m.clone(m.UNIT_Z),this.upWC=m.clone(m.UNIT_Y),this.rightWC=m.clone(m.UNIT_X),this.viewProjectionMatrix=new F}NO.prototype.clone=function(e){F.clone(e.viewMatrix,this.viewMatrix),F.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),Ae.clone(e.positionCartographic,this.positionCartographic),m.clone(e.positionWC,this.positionWC),m.clone(e.directionWC,this.directionWC),m.clone(e.upWC,this.upWC),m.clone(e.rightWC,this.rightWC)};var MEt=new F(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);NO.prototype.getViewProjection=function(){let e=this.viewMatrix,t=this.frustum.projectionMatrix;return F.multiply(t,e,this.viewProjectionMatrix),F.multiply(MEt,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};var vEt=new Array(5),UEt=new Ui,DEt=new Array(4),WIe=new m,FIe=new m;function kEt(e,t){let n=e._shadowMapCamera,i=e._sceneCamera,o=i.frustum.near,r=i.frustum.far,s=e._numberOfCascades,a,c=r-o,d=r/o,u=.9,h=!1;t.shadowState.closestObjectSize<200&&(h=!0,u=.9);let p=DEt,A=vEt;for(A[0]=o,A[s]=r,a=0;a<s;++a){let P=(a+1)/s,g=o*Math.pow(d,P),_=o+c*P,Z=L.lerp(_,g,u);A[a+1]=Z,p[a]=Z-A[a]}if(h){for(a=0;a<s;++a)p[a]=Math.min(p[a],e._maximumCascadeDistances[a]);let P=A[0];for(a=0;a<s-1;++a)P+=p[a],A[a+1]=P}re.unpack(A,0,e._cascadeSplits[0]),re.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 rSt=!1;function Jy(e){this._drawClassificationFBO=new Ti({createDepthAttachments:!1}),this._accumulationFBO=new Ti({createDepthAttachments:!1}),this._packFBO=new Ti,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 mi({color:new U(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new mi({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new nt,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(Jy.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function NIe(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function PIe(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function sSt(e,t,n,i){NIe(e),e._translucentDepthStencilTexture=new Lt({context:t,width:n,height:i,pixelFormat:Ke.DEPTH_STENCIL,pixelDatatype:Oe.UNSIGNED_INT_24_8,sampler:Ht.NEAREST})}function aSt(e,t,n,i){PIe(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 cSt(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)&&(sSt(e,t,o,r),aSt(e,t,o,r));let s,a;if(l(e._packDepthCommand)||(s=new ze({sources:[zX]}),a={u_opaqueDepthTexture:function(){return e._opaqueDepthStencilTexture},u_translucentDepthTexture:function(){return e._translucentDepthStencilTexture}},e._packDepthCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),!l(e._compositeCommand)){s=new ze({sources:[gE]}),a={colorTexture:function(){return e._textureToComposite}},rSt&&(s.defines=["DEBUG_SHOW_DEPTH"],a.u_packedTranslucentDepth=function(){return e._packFBO.getColorTexture()}),e._compositeCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e});let u=e._compositeCommand,h=u.shaderProgram,p=t.shaderCache.createDerivedShaderProgram(h,"pick",{vertexShaderSource:h.vertexShaderSource,fragmentShaderSource:new ze({sources:s.sources,defines:["PICK"]}),attributeLocations:h._attributeLocations}),A=ot.shallowClone(u);A.shaderProgram=p,u.derivedCommands.pick=A}l(e._copyCommand)||(s=new ze({sources:[gE]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),l(e._accumulateCommand)||(s=new ze({sources:[gE]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._accumulateCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),e._viewport.width=o,e._viewport.height=r;let c=!nt.equals(e._viewport,n.viewport),d=c!==e._useScissorTest;e._useScissorTest=c,nt.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle=nt.clone(n.viewport,e._scissorRectangle),d=!0),(!l(e._rsDepth)||!nt.equals(e._viewport,e._rsDepth.viewport)||d)&&(e._rsDepth=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}})),l(e._packDepthCommand)&&(e._packDepthCommand.renderState=e._rsDepth),(!l(e._rsAccumulate)||!nt.equals(e._viewport,e._rsAccumulate.viewport)||d)&&(e._rsAccumulate=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ni.EQUAL,reference:Jt.CESIUM_3D_TILE_MASK}})),l(e._accumulateCommand)&&(e._accumulateCommand.renderState=e._rsAccumulate),(!l(e._rsComp)||!nt.equals(e._viewport,e._rsComp.viewport)||d)&&(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 sro=y(x(),1),nM=`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 cro=y(x(),1),iM=`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 dro=y(x(),1),oM=`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 mro=y(x(),1),rM=`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 fro=y(x(),1),sM=`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 Aro=y(x(),1),aM=`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 bro=y(x(),1),cM=`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 xro=y(x(),1),lM=`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 Tro=y(x(),1),dM=`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 Sro=y(x(),1),uM=`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 Iro=y(x(),1),mM=`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 Rro=y(x(),1),hM=`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 Gro=y(x(),1),Ky=`#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 Wro=y(x(),1),fM=`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 Bro=y(x(),1),pM=`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 Nro=y(x(),1),AM=`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 Xro=y(x(),1),gM=`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 Mro=y(x(),1),bM=`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);}`;var Jro=y(x(),1);function yE(){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 Ti,this._commands=void 0,this._clearCommand=void 0,this._minMaxLuminance=new M,this.enabled=!0,this._enabled=!0,this.minimumLuminance=.1,this.maximumLuminance=10}Object.defineProperties(yE.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 JIe(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 USt(e,t){JIe(e);let n=e._width,i=e._height,o=t.halfFloatingPointTexture?Oe.HALF_FLOAT:Oe.FLOAT,r=Math.ceil(Math.log(Math.max(n,i))/Math.log(3)),s=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),s[c]=new Ti,s[c].update(t,n,i,1,o);let a=s[r-1].getColorTexture(0);e._previousLuminance.update(t,a.width,a.height,1,o),e._framebuffers=s}function KIe(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 DSt(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 kSt(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 QSt(e,t){KIe(e);let n=e._framebuffers,i=n.length,o=new Array(i);for(let r=0;r<i;++r)o[r]=t.createViewportQuadCommand(kSt(r,i),{framebuffer:n[r].framebuffer,uniformMap:DSt(e,r)});e._commands=o}yE.prototype.clear=function(e){let t=this._framebuffers;if(!l(t))return;let n=this._clearCommand;l(n)||(n=this._clearCommand=new mi({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)};yE.prototype.update=function(e){let t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,USt(this,e),QSt(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};yE.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)};yE.prototype.isDestroyed=function(){return!1};yE.prototype.destroy=function(){return JIe(this),KIe(this),he(this)};var yM=yE;var bso=y(x(),1);var jro=y(x(),1),OSt={NEAREST:0,LINEAR:1},Qu=OSt;function xE(e){e=e??Q.EMPTY_OBJECT;let{name:t=qn(),fragmentShader:n,uniforms:i,textureScale:o=1,forcePowerOfTwo:r=!1,sampleMode:s=Qu.NEAREST,pixelFormat:a=Ke.RGBA,pixelDatatype:c=Oe.UNSIGNED_BYTE,clearColor:d=U.BLACK,scissorRectangle:u}=e;this._fragmentShader=n,this._uniforms=i,this._textureScale=o,this._forcePowerOfTwo=r,this._sampleMode=s,this._pixelFormat=a,this._pixelDatatype=c,this._clearColor=d,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 Uc;h.scissorTest={enabled:!0,rectangle:l(u)?nt.clone(u):new nt},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(xE.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 zSt=/uniform\s+sampler2D\s+depthTexture/g;xE.prototype._isSupported=function(e){return!zSt.test(this._fragmentShader)||e.depthTexture};function HSt(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 s=e._actualUniforms,a=s[n];l(a)&&a!==r&&a instanceof Lt&&!l(e._textureCache.getStageByName(n))&&(e._texturesToRelease.push(a),delete s[n],delete s[`${n}Dimensions`]),r instanceof Lt&&e._texturesToRelease.push(r),typeof o=="string"||o instanceof HTMLCanva
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 $St(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=qSt(n,o)}let i=new ze({defines:[e._useLogDepth?"LOG_DEPTH":""],sources:[n]});e._command=t.createViewportQuadCommand(i,{uniformMap:e._uniformMap,owner:e})}function e_t(e){let t=e._sampleMode,n,i;t===Qu.LINEAR?(n=zt.LINEAR,i=li.LINEAR):(n=zt.NEAREST,i=li.NEAREST);let o=e._sampler;(!l(o)||o.minificationFilter!==n||o.magnificationFilter!==i)&&(e._sampler=new Ht({wrapS:gn.CLAMP_TO_EDGE,wrapT:gn.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function t_t(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function n_t(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function i_t(e,t){let n=e._texturesToRelease;for(let a=0;a<n.length;++a){let c=n[a];c=c&&c.destroy()}n.length=0;let i=e._texturesToCreate;for(let a=0;a<i.length;++a){let{name:c,source:d}=i[a];e._actualUniforms[c]=new Lt({context:t,source:d})}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,s=[];for(let a=0;a<o.length;++a){let c=o[a],d=r[c],u=e._textureCache.getStageByName(d);if(l(u))e._actualUniforms[c]=n_t(e,d);else if(typeof d=="string"){let h=new Le({url:d});s.push(h.fetchImage().then(t_t(e,c)))}else e._texturesToCreate.push({name:c,source:d})}o.length=0,s.length>0?(e._ready=!1,e._texturePromise=Promise.all(s).then(function(){e._ready=!0,e._texturePromise=void 0})):e._ready=!0}function jIe(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 Lt&&(l(t.getStageByName(n[o]))||r.destroy(),e._dirtyUniforms.push(o))}}function o_t(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 r_t(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 s=0;s<n.length;++s){let a=n[s];l(a.pickIds)?i+=a.pickIds.length:l(a.pickId)&&++i}if(n.length===0||i===0){let s=new Uint8Array([255,255,255,255]);e._selectedIdTexture=new Lt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:Oe.UNSIGNED_BYTE,source:{arrayBufferView:s,width:1,height:1},sampler:Ht.NEAREST});return}let o=0,r=new Uint8Array(i*4);for(let s=0;s<n.length;++s){let a=n[s];if(l(a.pickIds)){let c=a.pickIds,d=c.length;for(let u=0;u<d;++u){let h=c[u].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(a.pickId)){let c=a.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 Lt({context:t,pixelFormat:Ke.RGBA,pixelDatatype:Oe.UNSIGNED_BYTE,source:{arrayBufferView:r,width:i,height:1},sampler:Ht.NEAREST})}xE.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&jIe(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=o_t(this),this._selectedShadow=this._selected,this._parentSelectedShadow=this._parentSelected,this._combinedSelectedShadow=this._combinedSelecte
${Ky}`,r=new Fo({name:`${e}_x_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:Qu.LINEAR}),s=new Fo({name:`${e}_y_direction`,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:Qu.LINEAR}),a={};return Object.defineProperties(a,{delta:{get:function(){return r.uniforms.delta},set:function(c){let d=r.uniforms,u=s.uniforms;d.delta=u.delta=c}},sigma:{get:function(){return r.uniforms.sigma},set:function(c){let d=r.uniforms,u=s.uniforms;d.sigma=u.sigma=c}},stepSize:{get:function(){return r.uniforms.stepSize},set:function(c){let d=r.uniforms,u=s.uniforms;d.stepSize=u.stepSize=c}}}),new Ud({name:e,stages:[r,s],uniforms:a})}ns.createBlurStage=function(){return Uee("czm_blur")};ns.createDepthOfFieldStage=function(){let e=Uee("czm_depth_of_field_blur"),t=new Fo({name:"czm_depth_of_field_composite",fragmentShader:cM,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 Ud({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};ns.isDepthOfFieldSupported=function(e){return e.context.depthTexture};ns.createEdgeDetectionStage=function(){let e=qn();return new Fo({name:`czm_edge_detection_${e}`,fragmentShader:dM,uniforms:{length:.25,color:U.clone(U.BLACK)}})};ns.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function a_t(e){if(!l(e))return ns.createEdgeDetectionStage();let t=new Ud({name:"czm_edge_detection_multiple",stages:e,inputPreviousStageTexture:!1}),n={},i="",o="";for(let a=0;a<e.length;++a)i+=`uniform sampler2D edgeTexture${a}; `,o+=` vec4 edge${a} = texture(edgeTexture${a}, v_textureCoordinates); if (edge${a}.a > 0.0) { color = edge${a}; break; } `,n[`edgeTexture${a}`]=e[a].name;let r=`${i}in vec2 v_textureCoordinates; void main() { vec4 color = vec4(0.0); for (int i = 0; i < ${e.length}; i++) { ${o} } out_FragColor = color; } `,s=new Fo({name:"czm_edge_detection_combine",fragmentShader:r,uniforms:n});return new Ud({name:"czm_edge_detection_composite",stages:[t,s]})}ns.createSilhouetteStage=function(e){let t=a_t(e),n=new Fo({name:"czm_silhouette_color_edges",fragmentShader:bM,uniforms:{silhouetteTexture:t.name}});return new Ud({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};ns.isSilhouetteSupported=function(e){return e.context.depthTexture};ns.createBloomStage=function(){let e=new Fo({name:"czm_bloom_contrast_bias",fragmentShader:aM,uniforms:{contrast:128,brightness:-.3}}),t=Uee("czm_bloom_blur"),n=new Ud({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new Fo({name:"czm_bloom_generate_composite",fragmentShader:rM,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 Ud({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};ns.createAmbientOcclusionStage=function(){let e=new Fo({name:"czm_ambient_occlusion_generate",fragmentShader:nM,uniforms:{intensity:3,bias:.1,lengthCap:.26,directionCount:8,stepCount:32,randomTexture:void 0}}),t=new Fo({name:"czm_ambient_occlusion_composite",fragmentShader:iM,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 Ud({name:"czm_ambient_occlusion",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};ns.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};var c_t=`#define FXAA_QUALITY_PRESET 39 ${qX}${hM}`;ns.createFXAAStage=function(){return new Fo({name:"czm_FXAA",fragmentShader:c_t,sampleMode:Qu.LINEAR})};ns.createAcesTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=tM,new Fo({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};ns.createFilmicTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=uM,new Fo({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};ns.createPbrNeutralTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=mM,new Fo({name:"czm_pbr_neutral",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};ns.createReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=gM,new Fo({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0,exposure:1}})};ns.createModifiedReinhardTonemappingStage=function(e){let t=e?`#define AUTO_EXPOSURE`:"";return t+=pM,new Fo({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:U.WHITE,autoExposure:void 0,exposure:1}})};ns.createAutoExposureStage=function(){return new yM};ns.createBlackAndWhiteStage=function(){return new Fo({name:"czm_black_and_white",fragmentShader:oM,uniforms:{gradations:5}})};ns.createBrightnessStage=function(){return new Fo({name:"czm_brightness",fragmentShader:sM,uniforms:{brightness:.5}})};ns.createNightVisionStage=function(){return new Fo({name:"czm_night_vision",fragmentShader:AM})};ns.createDepthViewStage=function(){return new Fo({name:"czm_depth_view",fragmentShader:lM})};ns.createLensFlareStage=function(){return new Fo({name:"czm_lens_flare",fragmentShader:fM,uniforms:{dirtTexture:en("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:en("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:ie.WGS84.maximumRadius}})};var Ou=ns;var lao=y(x(),1);function Ib(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function CM(e){for(;l(e.length);)e=e.get(e.length-1);return e.name}function Dee(e,t,n,i,o){if(!i.enabled||!i._isSupported(t))return o;let r=n[i.name]={};if(l(o)){let a=e.getStageByName(o);r[CM(a)]=!0}let s=i.uniforms;if(l(s)){let a=Object.getOwnPropertyNames(s),c=a.length;for(let d=0;d<c;++d){let u=s[a[d]];if(typeof u=="string"){let h=e.getStageByName(u);l(h)&&(r[CM(h)]=!0)}}}return i.name}function xM(e,t,n,i,o){if(l(i.enabled)&&!i.enabled||l(i._isSupported)&&!i._isSupported(t))return o;let r=o,s=!l(i.inputPreviousStageTexture)||i.inputPreviousStageTexture,a=o,c=i.length;for(let h=0;h<c;++h){let p=i.get(h);l(p.length)?a=xM(e,t,n,p,o):a=Dee(e,t,n,p,o),s&&(o=a)}let d,u;if(s)for(d=1;d<c;++d)u=CM(i.get(d)),l(n[u])||(n[u]={}),n[u][r]=!0;else for(d=1;d<c;++d){u=CM(i.get(d));let h=n[u];for(let p=0;p<d;++p)h[CM(i.get(p))]=!0}return a}function l_t(e,t){let n={};if(l(e.ambientOcclusion)){let i=e.ambientOcclusion,o=e.bloom,r=e._tonemapping,s=e.fxaa,a=xM(e,t,n,i,void 0);a=xM(e,t,n,o,a),a=Dee(e,t,n,r,a),a=xM(e,t,n,e,a),Dee(e,t,n,s,a)}else xM(e,t,n,e,void 0);return n}function d_t(e,t,n){let o=e._collection.getStageByName(t),r=o._textureScale,s=o._forcePowerOfTwo,a=o._pixelFormat,c=o._pixelDatatype,d=o._clearColor,u,h,p=e._framebuffers,A=p.length;for(u=0;u<A;++u){if(h=p[u],r!==h.textureScale||s!==h.forcePowerOfTwo||a!==h.pixelFormat||c!==h.pixelDatatype||!U.equals(d,h.clearColor))continue;let f=h.stages,b=f.length,C=!1;for(let T=0;T<b;++T)if(n[f[T]]){C=!0;break}if(!C)break}return l(h)&&u<A?(h.stages.push(t),h):(h={textureScale:r,forcePowerOfTwo:s,pixelFormat:a,pixelDatatype:c,clearColor:d,stages:[t],buffer:new Ti({pixelFormat:a,pixelDatatype:c}),clear:void 0},p.push(h),h)}function u_t(e,t){let n=l_t(e._collection,t);for(let i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=d_t(e,i,n[i]))}function kee(e){let t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function m_t(e,t){let n=e._width,i=e._height,o=e._framebuffers,r=o.length;for(let s=0;s<r;++s){let a=o[s],c=a.textureScale,d=Math.ceil(n*c),u=Math.ceil(i*c),h=Math.min(d,u);a.forcePowerOfTwo&&(L.isPowerOfTwo(h)||(h=L.nextPowerOfTwo(h)),d=h,u=h),a.buffer.update(t,d,u),a.clear=new mi({color:a.clearColor,framebuffer:a.buffer.framebuffer})}}Ib.prototype.updateDependencies=function(){this._updateDependencies=!0};Ib.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),s=l(t.fxaa)&&t.fxaa.enabled&&t.fxaa._isSupported(e),a=!l(t._activeStages)||t._activeStages.length>0||i||o||r||s;if((n||!a&&this._framebuffers.length>0)&&(kee(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!a)return;this._framebuffers.length===0&&u_t(this,e);let c=e.drawingBufferWidth,d=e.dr
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 Dco=y(x(),1),VM=`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 Vb(){this._sceneFramebuffer=new pE;let e=.125,t=new Array(6);t[0]=new Fo({fragmentShader:vd,textureScale:e,forcePowerOfTwo:!0,sampleMode:Qu.LINEAR});let n=t[1]=new Fo({fragmentShader:VM,uniforms:{avgLuminance:.5,threshold:.25,offset:.1},textureScale:e,forcePowerOfTwo:!0}),i=this;this._delta=1,this._sigma=2,this._blurStep=new M,t[2]=new Fo({fragmentShader:Ky,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 Fo({fragmentShader:Ky,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 Fo({fragmentShader:vd,sampleMode:Qu.LINEAR}),this._uCenter=new M,this._uRadius=void 0,t[5]=new Fo({fragmentShader:RM,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new Ud({stages:t});let o=new TE(this),r=t.length;for(let s=0;s<r;++s)t[s]._textureCache=o;this._textureCache=o,this.length=t.length}Vb.prototype.get=function(e){return this._stages.get(e)};Vb.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 PZt=new re,kZe=new M,XZt=new M,QZe=new F;function YZt(e,t,n){let i=t.uniformState,o=i.sunPositionWC,r=i.view,s=i.viewProjection,a=i.projection,c=F.computeViewportTransformation(n,0,1,QZe),d=F.multiplyByPoint(r,o,PZt),u=bt.pointToGLWindowCoordinates(s,c,o,kZe);d.x+=L.SOLAR_RADIUS;let h=bt.pointToGLWindowCoordinates(a,c,d,d),p=M.magnitude(M.subtract(h,u,h))*30*2,A=XZt;A.x=p,A.y=p,e._uCenter=M.clone(u,e._uCenter),e._uRadius=Math.max(A.x,A.y)*.15;let f=t.drawingBufferWidth,b=t.drawingBufferHeight,C=e._stages,T=C.get(0),E=T.outputTexture.width,S=T.outputTexture.height,I=new nt;I.width=E,I.height=S,c=F.computeViewportTransformation(I,0,1,QZe),u=bt.pointToGLWindowCoordinates(s,c,o,kZe),A.x*=E/f,A.y*=S/b;let R=T.scissorRectangle;R.x=Math.max(u.x-A.x*.5,0),R.y=Math.max(u.y-A.y*.5,0),R.width=Math.min(A.x,f),R.height=Math.min(A.y,b);for(let V=1;V<4;++V)nt.clone(R,C.get(V).scissorRectangle)}Vb.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)};Vb.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),YZt(this,t,n),o};Vb.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)};Vb.prototype.copy=function(e,t){if(!l(this._copyColorCommand)){let n=this;this._copyColorCommand=e.createViewportQuadCommand(vd,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)};Vb.prototype.isDestroyed=function(){return!1};Vb.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),he(this)};var GM=Vb;var plo=y(x(),1);function OZe(){this._cachedShowFrustumsShaders={}}function MZt(e){let t={},n=e.vertexAttributes;for(let i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function vZt(e,t){let n=e.context,i=t,o=i.fragmentShaderSource.clone(),r=[];o.sources=o.sources.map(function(u){u=ze.replaceMain(u,"czm_Debug_main");let h=/out_FragData_(\d+)/g,p;for(;(p=h.exec(u))!==null;)r.indexOf(p[1])===-1&&r.push(p[1]);return u});let s=r.length,a="";a+=`uniform vec3 debugShowCommandsColor;`,a+=`uniform vec3 debugShowFrustumsColor;`,a+=`void main() { czm_Debug_main(); `;let c;if(s>0)for(c=0;c<s;++c)a+=` out_FragData_${r[c]}.rgb *= debugShowCommandsColor;`,a+=` out_FragData_${r[c]}.rgb *= debugShowFrustumsColor;`;else a+=` out_FragColor.rgb *= debugShowCommandsColor;`,a+=` out_FragColor.rgb *= debugShowFrustumsColor;`;a+="}",o.sources.push(a);let d=MZt(i);return tn.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:o,attributeLocations:d})}var LM=new U;function UZt(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?(LM.red=t.debugOverlappingFrustums&1?1:0,LM.green=t.debugOverlappingFrustums&2?1:0,LM.blue=t.debugOverlappingFrustums&4?1:0,LM.alpha=1,LM):U.WHITE}),n}var DZt=new ot;OZe.prototype.executeDebugShowFrustumsCommand=function(e,t,n){let i=t.shaderProgram.id,o=this._cachedShowFrustumsShaders[i];l(o)||(o=vZt(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=o);let r=ot.shallowClone(t,DZt);r.shaderProgram=o,r.uniformMap=UZt(e,t),r.execute(e.context,n)};var WM=OZe;var Clo=y(x(),1);function ZE(e,t,n){this._primitive=e,this._tileIndex=t,this._sampleIndex=n,this._metadata={},this._orientedBoundingBox=new nn}ZE.fromKeyframeNode=function(e,t,n,i){let o=new ZE(e,t,n),{spatialNode:r,content:s}=i;return o._metadata=kZt(e,s,n),o._orientedBoundingBox=OZt(e,r,n,o._orientedBoundingBox),o};function kZt(e,t,n){if(!l(t)||!l(t.metadata))return;let{names:i,types:o}=e.provider,{metadata:r}=t,s={};for(let a=0;a<i.length;a++){let c=i[a],d=St.getComponentCount(o[a]),u=r[a].slice(n*d,(n+1)*d);s[c]=u}return s}var zZe=new m,QZt=new m;function OZt(e,t,n,i){let o=t.dimensions,r=o.x*o.y,s=Math.floor(n/r),a=n-s*r,c=Math.floor(a/o.x),d=a-c*o.x,u=m.fromElements(d,c,s,zZe),h=m.divideComponents(m.subtract(u,e._paddingBefore,zZe),e.dimensions,QZt);return e._shape.computeOrientedBoundingBoxForSample(t,e.dimensions,h,i)}Object.defineProperties(ZE.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()}}});ZE.prototype.hasProperty=function(e){return l(this._metadata[e])};ZE.prototype.getNames=function(){return Object.keys(this._metadata)};ZE.prototype.getProperty=function(e){return this._metadata[e]};var FM=ZE;var Kho=y(x(),1);var luo=y(x(),1);var Ilo=y(x(),1);function zZt(e,t){let{shaderBuilder:n}=e,{names:i,types:o,componentTypes:r,minimumValues:s,maximumValues:a}=t._provider,c=o.length,d=l(s)&&l(a);n.addDefine("METADATA_COUNT",c,pe.FRAGMENT),d&&n.addDefine("STATISTICS",void 0,pe.FRAGMENT);for(let g=0;g<c;g++){let _=i[g],Z=$O(o[g]),G=`PropertyStatistics_${_}`,w=`PropertyStatistics_${_}`;n.addStruct(G,w,pe.FRAGMENT),n.addStructField(G,Z,"min"),n.addStructField(G,Z,"max")}let u="MetadataStatistics",h="MetadataStatistics",p="metadataStatistics";n.addStruct(u,h,pe.FRAGMENT);for(let g=0;g<c;g++){let _=i[g],Z=`PropertyStatistics_${_}`,G=_;n.addStructField(u,Z,G)}let A="Metadata",f="Metadata",b="metadata";n.addStruct(A,f,pe.FRAGMENT);for(let g=0;g<c;g++){let _=$O(o[g]);n.addStructField(A,_,i[g])}let C="Attributes",T="Attributes",E="attributes";n.addStruct(C,T,pe.FRAGMENT),n.addStructField(C,"vec3","positionEC"),n.addStructField(C,"vec3","normalEC");let S="Voxel",I="Voxel",R="voxel";n.addStruct(S,I,pe.FRAGMENT),n.addStructField(S,"vec3","viewDirUv"),n.addStructField(S,"float","travelDistance"),n.addStructField(S,"int","stepCount"),n.addStructField(S,"int","tileIndex"),n.addStructField(S,"int","sampleIndex"),n.addStructField(S,"float","distanceToDepthBuffer");let V="FragmentInput";n.addStruct(V,"FragmentInput",pe.FRAGMENT),n.addStructField(V,h,p),n.addStructField(V,f,b),n.addStructField(V,T,E),n.addStructField(V,I,R);let B="Properties",N="Properties",P="properties";n.addStruct(B,N,pe.FRAGMENT);for(let g=0;g<c;g++){let _=$O(o[g]);n.addStructField(B,_,i[g])}{let g="clearProperties";n.addFunction(g,`${N} clearProperties()`,pe.FRAGMENT),n.addFunctionLines(g,[`${N} ${P};`]);for(let _=0;_<c;_++){let Z=$O(o[_],r[_]);n.addFunctionLines(g,[`${P}.${i[_]} = 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 Hlo=y(x(),1),NM=`// 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 Klo=y(x(),1),PM=`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 qlo=y(x(),1),XM=`/* 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 edo=y(x(),1),YM=`// 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 ndo=y(x(),1),MM=`// 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 odo=y(x(),1),eR=`// 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 sdo=y(x(),1),vM=`// 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 cdo=y(x(),1),UM=`// 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 ddo=y(x(),1),DM=`// 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 mdo=y(x(),1),RE=`// 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 fdo=y(x(),1),kM=`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 Ado=y(x(),1),QM=`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 bdo=y(x(),1),OM=`/* 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 xdo=y(x(),1),zM=`// 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 Tdo=y(x(),1),HM=`// 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 Sdo=y(x(),1),tRt={Z_UP:0,Y_UP:1},lA=Object.freeze(tRt);function nRt(e){let t=new GA;this.shaderBuilder=t;let n=e._customShader,i=Ft(e._uniformMap,n.uniformMap);e._uniformMap=i;let o=n.uniforms;for(let f in o)if(o.hasOwnProperty(f)){let b=o[f];t.addUniform(b.type,f,pe.FRAGMENT)}t.addUniform("sampler3D","u_megatextureTextures[METADATA_COUNT]",pe.FRAGMENT),this.uniformMap=i;let r=e._clippingPlanes,s=l(r)&&r.enabled?r.length:0;this.clippingPlanes=r,this.clippingPlanesLength=s;let a=e._shape.renderBoundPlanes,c=a?.length??0;this.renderBoundPlanes=a,this.renderBoundPlanesLength=c,t.addVertexLines([PM]),e.provider.metadataOrder===lA.Y_UP&&t.addDefine("Y_UP_METADATA_ORDER",void 0,pe.FRAGMENT);let d=e._provider.shape;d==="BOX"?t.addDefine("SHAPE_BOX",void 0,pe.FRAGMENT):d==="CYLINDER"?t.addDefine("SHAPE_CYLINDER",void 0,pe.FRAGMENT):d==="ELLIPSOID"&&t.addDefine("SHAPE_ELLIPSOID",void 0,pe.FRAGMENT),t.addFragmentLines([n.fragmentShaderText,"#line 0",zM,wM,HM,XM,MM,YM]),s>0&&(t.addDefine("CLIPPING_PLANES",void 0,pe.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",s,pe.FRAGMENT),r.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,pe.FRAGMENT)),e._depthTest&&t.addDefine("DEPTH_TEST",void 0,pe.FRAGMENT),d==="BOX"?t.addFragmentLines([kM,vM,RE]):d==="CYLINDER"?t.addFragmentLines([QM,eR,UM,RE]):d==="ELLIPSOID"&&t.addFragmentLines([OM,eR,DM,RE]),t.addFragmentLines([NM]);let u=e._shape,h=u.shaderDefines;for(let f in h)if(h.hasOwnProperty(f)){let b=h[f];l(b)&&(b=b===!0?void 0:b,t.addDefine(f,b,pe.FRAGMENT))}let p=u.shaderMaximumIntersectionsLength;s>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",p,pe.FRAGMENT),s===1?p+=1:r.unionClippingRegions?p+=2:p+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",p,pe.FRAGMENT),p+=1),t.addDefine("INTERSECTION_COUNT",p,pe.FRAGMENT),(!m.equals(e.paddingBefore,m.ZERO)||!m.equals(e.paddingAfter,m.ZERO))&&t.addDefine("PADDING",void 0,pe.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,pe.FRAGMENT);let A=e._traversal;t.addDefine("SAMPLE_COUNT",`${A._sampleCount}`,pe.FRAGMENT)}var JM=nRt;var $Ze=new M;function iRt(e,t){let n=new JM(e);BM(n,e);let{shaderBuilder:i,clippingPlanes:o,clippingPlanesLength:r,renderBoundPlanes:s,renderBoundPlanesLength:a}=n;if(r>0){let S="getClippingPlane",I=`vec4 ${S}(highp sampler2D packedPlanes, int planeNumber)`,R=ls.getTextureResolution(o,t,$Ze),V=eRe(R);i.addFunction(S,I,pe.FRAGMENT),i.addFunctionLines(S,[V])}if(a>0){let S="getBoundPlane",I=`vec4 ${S}(highp sampler2D packedPlanes, int planeNumber)`,R=Gb.getTextureResolution(s,t,$Ze),V=eRe(R);i.addFunction(S,I,pe.FRAGMENT),i.addFunctionLines(S,[V])}let c=i.clone();c.addDefine("PICKING",void 0,pe.FRAGMENT);let d=i.clone();d.addDefine("PICKING_VOXEL",void 0,pe.FRAGMENT);let u=i.buildShaderProgram(t),h=c.buildShaderProgram(t),p=d.buildShaderProgram(t),A=Qe.fromCache({cull:{enabled:!0,face:wi.BACK},depthTest:{enabled:!1},depthMask:!1,blending:ln.PRE_MULTIPLIED_ALPHA_BLEND}),f=t.getViewportQuadVertexArray(),b=e._depthTest,C=new ot({vertexArray:f,primitiveType:We.TRIANGLES,renderState:A,shaderProgram:u,uniformMap:n.uniformMap,modelMatrix:e._compoundModelMatrix,pass:Ge.VOXELS,executeInClosestFrustum:!0,owner:this,cull:b,occlude:b}),T=ot.shallowClone(C,new ot);T.shaderProgram=h,T.pickOnly=!0;let E=ot.shallowClone(C,new ot);if(E.shaderProgram=p,E.pickOnly=!0,l(e._drawCommand)){let S=e._drawCommand;S.shaderProgram=S.shaderProgram&&S.shaderProgram.destroy()}if(l(e._drawCommandPick)){let S=e._drawCommandPick;S.shaderProgram=S.shaderProgram&&S.shaderProgram.destroy()}if(l(e._drawCommandPickVoxel)){let S=e._drawCommandPickVoxel;S.shaderProgram=S.shaderProgram&&S.shaderProgram.destroy()}e._drawCommand=C,e._drawCommandPick=T,e._drawCommandPickVoxel=E}function eRe(e){let t=e.x,n=e.y,i=1/t,o=1/n,r=`${i}`;r.indexOf(".")===-1&&(r+=".0");let s=`${o}`;return s.indexOf(".")===-1&&(s+=".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) * ${s}; return texture(packedPlanes, vec2(u, v));`}var KM=iRt;var Wuo=y(x(),1);var uuo=y(x(),1),oRt={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"},tR=Object.freeze(oRt);var Tuo=y(x(),1);function nR(){this._defaultTexture=void 0,this._textures={},this._loadedImages=[],this._lastUpdatedFrame=-1}nR.prototype.getTexture=function(e){return this._textures[e]};function rRt(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})}nR.prototype.loadTexture2D=function(e,t){l(t.typedArray)?this._loadedImages.push({id:e,textureUniform:t}):rRt(this,e,t)};function sRt(e,t,n){let{id:i,textureUniform:o,image:r}=t,s=n.webgl2?ez(o,r,n):aRt(o,r,n),a=e._textures[i];l(a)&&a!==n.defaultTexture&&a.destroy(),e._textures[i]=s}function ez(e,t,n){let{typedArray:i,sampler:o}=e,r=l(i)?nRe(e,n):new Lt({context:n,source:t,sampler:o});return tRe(o)&&r.generateMipmap(),r}function aRt(e,t,n){let{typedArray:i,sampler:o}=e,r=tRe(o),s=o.wrapS===gn.REPEAT||o.wrapS===gn.MIRRORED_REPEAT||o.wrapT===gn.REPEAT||o.wrapT===gn.MIRRORED_REPEAT,{width:a,height:c}=l(i)?e:t,d=[a,c].every(L.isPowerOfTwo);if((r||s)&&!d)if(l(i)){if(e.pixelDatatype===Oe.UNSIGNED_BYTE){let h=VX(i,a,c),p=y0(h);return ez({sampler:o},p,n)}}else{let h=y0(t);return ez(e,h,n)}else return ez(e,t,n);return r?console.warn("Texture requires resizing for mipmaps but pixelDataType cannot be resized. The texture may be rendered incorrectly."):s&&console.warn("Texture requires resizing for wrapping but pixelDataType cannot be resized. The texture may be rendered incorrectly."),nRe(e,n)}function tRe(e){return[zt.NEAREST_MIPMAP_NEAREST,zt.NEAREST_MIPMAP_LINEAR,zt.LINEAR_MIPMAP_NEAREST,zt.LINEAR_MIPMAP_LINEAR].includes(e.minificationFilter)}function nRe(e,t){let{pixelFormat:n,pixelDatatype:i,width:o,height:r,typedArray:s,sampler:a}=e;return new Lt({context:t,pixelFormat:n,pixelDatatype:i,source:{arrayBufferView:s,width:o,height:r},sampler:a,flipY:!1})}nR.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];sRt(this,o,t)}n.length=0};nR.prototype.isDestroyed=function(){return!1};nR.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 he(this)};var jM=nR;function qM(e){e=e??Q.EMPTY_OBJECT,this.mode=e.mode??fg.MODIFY_MATERIAL,this.lightingModel=e.lightingModel,this.uniforms=e.uniforms??Q.EMPTY_OBJECT,this.varyings=e.varyings??Q.EMPTY_OBJECT,this.vertexShaderText=e.vertexShaderText,this.fragmentShaderText=e.fragmentShaderText,this.translucencyMode=e.translucencyMode??w0.INHERIT,this._textureManager=new jM,this._defaultTexture=void 0,this.uniformMap=cRt(this),this.usedVariablesVertex={attributeSet:{},featureIdSet:{},metadataSet:{}},this.usedVariablesFragment={attributeSet:{},featureIdSet:{},metadataSet:{},materialSet:{}},uRt(this),mRt(this)}function cRt(e){let t=e.uniforms,n={};for(let i in t)if(t.hasOwnProperty(i)){let o=t[i];o.type===tR.SAMPLER_2D?(e._textureManager.loadTexture2D(i,o.value),n[i]=lRt(e,i)):n[i]=dRt(e,i)}return n}function lRt(e,t){return function(){return e._textureManager.getTexture(t)??e._defaultTexture}}function dRt(e,t){return function(){return e.uniforms[t].value}}function VE(e,t,n){let i;for(;(i=t.exec(e))!==null;){let o=i[1];n[o]=!0}}function uRt(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,VE(r,t,o),o=e.usedVariablesVertex.featureIdSet,VE(r,n,o),o=e.usedVariablesVertex.metadataSet,VE(r,i,o
{ material.diffuse = vec3(1.0); material.alpha = 1.0;}`});function RRe(){this.ready=!0,this.shape=Ac.BOX,this.dimensions=new m(1,1,1),this.names=["data"],this.types=[St.SCALAR],this.componentTypes=[Yt.FLOAT32],this.maximumTileCount=1}RRe.prototype.requestData=function(e){if((l(e)?e.tileLevel??0:0)>=1)return;let n=new LE({metadata:[new Float32Array(1)]});return Promise.resolve(n)};uA.DefaultProvider=new RRe;var $y=uA;var $ho=y(x(),1);function iGt(e,t,n,i){if(!l(e)||l(t)&&e.id!==t)return;let r=(e.classes||{})[n];if(!l(r))return;let a=(r.properties||{})[i];if(l(a))return a}var av=iGt;var tfo=y(x(),1);function oGt(e,t,n,i,o){this.schemaId=e,this.className=t,this.propertyName=n,this.classProperty=i,this.metadataProperty=o}var cv=oGt;var ofo=y(x(),1);function rGt(e,t,n){if(!l(e))return;let i=e.propertyTextures;for(let o of i)if(o.class.id===t){let a=o.properties[n];if(l(a))return a}}var lv=rGt;var rz=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function Ci(e){e=e??Q.EMPTY_OBJECT;let t=e.canvas,n=e.creditContainer,i=e.creditViewport,o=e.contextOptions instanceof JL;if(o)this._context=e.contextOptions.createSceneContext(t);else{let d=He(e.contextOptions);this._context=new Zx(t,d)}let r=this._context,s=l(n);s||(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=qn(),this._jobScheduler=new YY,this._frameState=new PY(r,new LY(n,"\u2022",i),this._jobScheduler),this._frameState.scene3DOnly=e.scene3DOnly??!1,this._removeCreditContainer=!s,this._creditContainer=n,this._canvas=t,this._computeEngine=new QR(r),this._ellipsoid=e.ellipsoid??ie.default,this._globe=void 0,this._globeTranslucencyState=new XY,this._primitives=new $l({countReferences:o}),this._groundPrimitives=new $l({countReferences:o}),this._globeHeight=void 0,this._globeHeightDirty=!0,this._cameraUnderground=!1,this._removeUpdateHeightCallback=void 0,this._logDepthBuffer=Ci.defaultLogDepthBuffer&&r.fragmentDepth,this._logDepthBufferDirty=!0,this._tweens=new _E,this._shaderFrameCount=0,this._sunPostProcess=void 0,this._computeCommandList=[],this._overlayCommandList=[],this._useOIT=e.orderIndependentTranslucency??!0,this._executeOITFunction=void 0,this._depthPlane=new BY(e.depthPlaneEllipsoidOffset),this._clearColorCommand=new mi({color:new U,stencil:0,owner:this}),this._depthClearCommand=new mi({depth:1,owner:this}),this._stencilClearCommand=new mi({stencil:0}),this._classificationStencilClearCommand=new mi({stencil:0,renderState:Qe.fromCache({stencilMask:Jt.CLASSIFICATION_MASK})}),this._depthOnlyRenderStateCache={},this._transitioner=new SM(this),this._preUpdate=new xe,this._postUpdate=new xe,this._renderError=new xe,this._preRender=new xe,this._postRender=new xe,this._minimumDisableDepthTestDistance=0,this._debugInspector=new WM,this._msaaSamples=e.msaaSamples??4,this.rethrowRenderErrors=!1,this.completeMorphOnUserInput=!0,this.morphStart=new xe,this.morphComplete=new xe,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=se.SCENE3D,this._mapProjection=l(e.mapProjection)?e.mapProjection:new ki(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 CC,this.fog=new NY,this.fog.enabled=ie.WGS84.equals(this._ellipsoid),ie.WGS84.equals(this._ellipsoid)||(Zo.DEFAULT_VIEW_RECTANGLE=de.fromDegrees(-45,-45,45,45)),this._shadowMapCamera=new Zo(this),this.shadowMap=new _b({context:r,lightCame
vec4 clippingPlanesEdgeColor = vec4(1.0); clippingPlanesEdgeColor.rgb = ${n}.rgb; float clippingPlanesEdgeWidth = ${n}.a; if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth) { out_FragColor = clippingPlanesEdgeColor; } `}var gv=cLt;var fgo=y(x(),1);var lLt={modifyFragmentShader:function(t){return t=ze.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}}},rR=lLt;var XE={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function bv(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=XE.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??Ge.OPAQUE,this._cull=e.cull??!0,this.style=void 0,this._style=void 0,this.styleDirty=!1,this.modelMatrix=F.clone(F.IDENTITY),this._modelMatrix=F.clone(F.IDENTITY),this.time=0,this.shadows=Vn.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??Br.NONE,this._splittingEnabled=!1,this._error=void 0,dLt(this,e)}Object.defineProperties(bv.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=ue.clone(e,this._boundingSphere)}}});function dLt(e,t){let n=wC.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=Xh.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),l(n.draco)){let a=n.draco;e._decodingState=XE.NEEDS_DECODE,a.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 s=n.batchIds;l(n.batchIds)&&(s.name="BATCH_ID",s.semantic="BATCH_ID",s.setIndex=void 0),n.hasBatchIds&&e._batchTableLoaded(n.batchLength,n.batchTableJson,n.batchTableBinary),e._pointsLength=n.pointsLength}var uLt=new m,mLt=new m,hLt=new m,MRe,sz;function fLt(e){if(!l(sz)){MRe=new URe.default(0),sz=new Array(e);for(let t=0;t<e;++t)sz[t]=MRe.random()}return sz}function pLt(e){let n=e.length/3,i=Math.min(n,20),o=fLt(20),r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=m.fromElements(r,r,r,uLt),c=m.fromElements(s,s,s,mLt);for(let u=0;u<i;++u){let h=Math.floor(o[u]*n),p=m.unpack(e,h*3,hLt);m.minimumByComponent(a,p,a),m.maximumByComponent(c,p,c)}let d=ue.fromCornerPoints(a,c);return d.radius+=L.EPSILON2,d}function vRe(e,t){let n=H.fromTypedArray(e);return n===H.INT||n===H.UNSIGNED_INT||n===H.DOUBLE?(_t("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 Bte(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 ELt={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 SLt(e,t,n){let i,o,r,s=t.context,a=l(n),c=e._isQuantized,d=e._isQuantizedDraco,u=e._isOctEncoded16P,h=e._isOctEncodedDraco,p=e._isRGB565,A=e._isTranslucent,f=e._hasColors,b=e._hasNormals,C=e._hasBatchIds,T=e._backFaceCulling,E=e._normalShading,S=e._drawCommand.vertexArray,I=e.clippingPlanes,R=e._attenuation,V,W,B,N=A,P=He(ELt),g={},_=e._styleableShaderAttributes;for(o in _)_.hasOwnProperty(o)&&(r=_[o],P[o]=`czm_3dtiles_property_${r.location}`,g[r.location]=r);if(a){let ae={translucent:!1},Ce="(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)";V=n.getColorShaderFunction(`getColorFromStyle${Ce}`,P,ae),W=n.getShowShaderFunction(`getShowFromStyle${Ce}`,P,ae),B=n.getPointSizeShaderFunction(`getPointSizeFromStyle${Ce}`,P,ae),l(V)&&ae.translucent&&(N=!0)}e._styleTranslucent=N;let Z=l(V),G=l(W),w=l(B),X=e.isClipped,k=[],v=[];Z&&(Wte(V,k),Fte(V,v)),G&&(Wte(W,k),Fte(W,v)),w&&(Wte(B,k),Fte(B,v));let D=v.indexOf("COLOR")>=0,Y=v.indexOf("NORMAL")>=0;if(Y&&!b)throw new me("Style references the NORMAL semantic but the point cloud does not have normals");for(o in _)if(_.hasOwnProperty(o)){r=_[o];let ae=k.indexOf(r.location)>=0,Ce=Bte(S,r.location);Ce.enabled=ae}let O=f&&(!Z||D);if(f){let ae=Bte(S,az);ae.enabled=O}let J=b&&(E||T||Y);if(b){let ae=Bte(S,wte);ae.enabled=J}let te={a_position:DRe};O&&(te.a_color=az),J&&(te.a_normal=wte),C&&(te.a_batchId=kRe);let z="",j=k.length;for(i=0;i<j;++i){let ae=k[i];r=g[ae];let Ce=r.componentCount,Te=`czm_3dtiles_property_${ae}`,Fe;Ce===1?Fe="float":Fe=`vec${Ce}`,z+=`in ${Fe} ${Te}; `,te[Te]=r.location}TLt(e,t);let ee=`in vec3 a_position; out vec4 v_color; uniform vec4 u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier; uniform vec4 u_constantColor; uniform vec4 u_highlightColor; `;ee+=`float u_pointSize; float tiles3d_tileset_time; `,R&&(ee+=`float u_geometricError; float u_depthMultiplier; `),ee+=z,O&&(A?ee+=`in vec4 a_color; `:p?ee+=`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; `:ee+=`in vec3 a_color; `),J&&(u||h?ee+=`in vec2 a_normal; `:ee+=`in vec3 a_normal; `),C&&(ee+=`in float a_batchId; `),(c||d||h)&&(ee+=`uniform vec4 u_quantizedVolumeScaleAndOctEncodedRange; `),Z&&(ee+=V),G&&(ee+=W),w&&(ee+=B),ee+=`void main() { u_pointSize = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.x; tiles3d_tileset_time = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.y; `,R&&(ee+=` u_geometricError = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.z; u_depthMultiplier = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.w; `),O?A?ee+=` vec4 color = a_color; `:p?ee+=` 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); `:ee+=` vec4 color = vec4(a_color, 1.0); `:ee+=` vec4 color = u_constantColor; `,c||d?ee+=` vec3 position = a_position * u_quantizedVolumeScaleAndOctEncodedRange.xyz; `:ee+=` vec3 position = a_position; `,ee+=` vec3 position_absolute = vec3(czm_model * vec4(position, 1.0)); `,J?(u?ee+=` vec3 normal = czm_octDecode(a_normal); `:h?ee+=` vec3 normal = czm_octDecode(a_normal, u_quantizedVolumeScaleAndOctEncodedRange.w).zxy; `:ee+=` vec3 normal = a_normal; `,ee+=` vec3 normalEC = czm_normal * normal; `):ee+=` vec3 normal = vec3(1.0); `,Z&&(ee+=` color = getColorFromStyle(position, position_absolute, color, normal); `),G&&(ee+=` float show = float(getShowFromStyle(position, position_absolute, color, normal)); `),w?ee+=` gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal) * czm_pixelRatio; `:R?ee+=` vec4 positionEC = czm_modelView * vec4(position, 1.0); float depth = -positionEC.z; gl_PointSize = min((u_geometricError / depth) * u_depthMultiplier, u_pointSize); `:ee+=` gl_PointSize = u_pointSize; `,ee+=` color = color * u_highlightColor; `,J&&E&&(ee+=` float diffuseStrength = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC); diffuseStrength = max(diffuseStrength, 0.4); color.xyz *= diffuseStrength * czm_lightColor; `),ee+=` v_color = color; gl_Position = czm_modelViewProjection * vec4(position, 1.0); `,J&&T&&(ee+=` float visible = step(-normalEC.z, 0.0); gl_Position *= visible; gl_PointSize *= visible; `),G&&(ee+=` gl_Position.w *= float(show); gl_PointSize *= float(show); `),ee+=`} `;let ge=`in vec4 v_color; `;X&&(ge+=`uniform highp sampler2D u_clippingPlanes; uniform mat4 u_clippingPlanesMatrix; uniform vec4 u_clippingPlanesEdgeStyle; `,ge+=``,ge+=cE(I,s),ge+=``),ge+=`void main() { out_FragColor = czm_gammaCorrect(v_color); `,X&&(ge+=gv("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),ge+=`} `,e.splitDirection!==Br.NONE&&(ge=rR.modifyFragmentShader(ge)),l(e._vertexShaderLoaded)&&(ee=e._vertexShaderLoaded(ee)),l(e._fragmentShaderLoaded)&&(ge=e._fragmentShaderLoaded(ge));let ye=e._drawCommand;l(ye.shaderProgram)&&ye.shaderProgram.destroy(),ye.shaderProgram=tn.fromCache({context:s,vertexShaderSource:ee,fragmentShaderSource:ge,attributeLocations:te});try{ye.shaderProgram._bind()}catch{throw new me("Error generating style shader: this may be caused by a type mismatch, index out-of-bounds, or other syntax error.")}}function _Lt(e,t){if(e._decodingState===XE.READY)return!1;if(e._decodingState===XE.NEEDS_DECODE){let n=e._parsedContent,i=n.draco,o=qA.decodePointCloud(i,t);l(o)&&(e._decodingState=XE.DECODING,o.then(function(r){e._decodingState=XE.READY;let s=l(r.POSITION)?r.POSITION.array:void 0,a=l(r.RGB)?r.RGB.array:void 0,c=l(r.RGBA)?r.RGBA.array:void 0,d=l(r.NORMAL)?r.NORMAL.array:void 0,u=l(r.BATCH_ID)?r.BATCH_ID.array:void 0,h=l(s)&&l(r.POSITION.data.quantization),p=l(d)&&l(r.NORMAL.data.quantization);if(h){let C=r.POSITION.data.quantization,T=C.range;e._quantizedVolumeScale=m.fromElements(T,T,T),e._quantizedVolumeOffset=m.unpack(C.minValues),e._quantizedRange=(1<<C.quantizationBits)-1,e._isQuantizedDraco=!0}p&&(e._octEncodedRange=(1<<r.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let A=n.styleableProperties,f=i.batchTableProperties;for(let C in f)if(f.hasOwnProperty(C)){let T=r[C];l(A)||(A={}),A[C]={typedArray:T.array,componentCount:T.data.componentsPerAttribute}}l(s)&&(n.positions={typedArray:s});let b=c??a;l(b)&&(n.colors={typedArray:b}),l(d)&&(n.normals={typedArray:d}),l(u)&&(n.batchIds={typedArray:u}),n.styleableProperties=A}).catch(function(r){e._decodingState=XE.FAILED,e._error=r}))}return!0}var ILt=new re,ZLt=new m;bv.prototype.update=function(e){let t=e.context;if(l(this._error)){let d=this._error;throw this._error=void 0,d}if(_Lt(this,t))return;let i=!1,o=!F.equals(this._modelMatrix,this.modelMatrix);if(this._mode!==e.mode&&(this._mode=e.mode,o=!0),l(this._drawCommand)||(CLt(this,e),o=!0,i=!0,this._ready=!0,this._parsedContent=void 0),o){F.clone(this.modelMatrix,this._modelMatrix);let d=this._drawCommand.modelMatrix;if(F.clone(this._modelMatrix,d),l(this._rtcCenter)&&F.multiplyByTranslation(d,this._rtcCenter,d),l(this._quantizedVolumeOffset)&&F.multiplyByTranslation(d,this._quantizedVolumeOffset,d),e.mode!==se.SCENE3D){let h=e.mapProjection,p=F.getColumn(d,3,ILt);re.equals(p,re.UNIT_W)||bt.basisTo2D(h,d,d)}let u=this._drawCommand.boundingVolume;if(ue.clone(this._boundingSphere,u),this._cull){let h=u.center;F.multiplyByPoint(d,h,h);let p=F.getScale(d,ZLt);u.radius*=m.maximumComponent(p)}}this.clippingPlanesDirty&&(this.clippingPlanesDirty=!1,i=!0),this._attenuation!==this.attenuation&&(this._attenuation=this.attenuation,i=!0),this.backFaceCulling!==this._backFaceCulling&&(this._backFaceCulling=this.backFaceCulling,i=!0),this.normalShading!==this._normalShading&&(this._normalShading=this.normalShading,i=!0),(this._style!==this.style||this.styleDirty)&&(this._style=this.style,this.styleDirty=!1,i=!0);let r=this.splitDirection!==Br.NONE;this._splittingEnabled!==r&&(this._splittingEnabled=r,i=!0),i&&SLt(this,e,this._style),this._drawCommand.castShadows=Vn.castShadows(this.shadows),this._drawCommand.receiveShadows=Vn.receiveShadows(this.shadows);let s=this._highlightColor.alpha<1||this._constantColor.alpha<1||this._styleTranslucent;this._drawCommand.renderState=s?this._translucentRenderState:this._opaqueRenderState,this._drawCommand.pass=s?Ge.TRANSLUCENT:this._opaquePass;let a=e.commandList,c=e.passes;(c.render||c.pick)&&a.push(this._drawCommand)};bv.prototype.isDestroyed=function(){return!1};bv.prototype.destroy=function(){let e=this._drawCommand;return l(e)&&(e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy()),he(this)};var yv=bv;function ME(e){e=e??Q.EMPTY_OBJECT,this.show=e.show??!0,this.modelMatrix=F.clone(e.modelMatrix??F.IDENTITY),this.shadows=e.shadows??Vn.ENABLED,this.maximumMemoryUsage=e.maximumMemoryUsage??256,t
${e}`}function VLt(e){return function(t){return Ft(t,{czm_pickColor:function(){return e._pickId.color}})}}function GLt(){return"czm_pickColor"}ME.prototype.makeStyleDirty=function(){this._styleDirty=!0};ME.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};var LLt=new q;function Pte(e){let t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function YE(e,t){return e._intervals.indexOf(t.start)}function WLt(e,t){let n=e._intervals,i=e._clock,o=Pte(e);if(o===0)return;let r=e._getAverageLoadTime(),s=q.addSeconds(i.currentTime,r*o,LLt),a=n.indexOf(s),c=YE(e,t);return a===c&&(o>=0?++a:--a),n.get(a)}function FLt(e){let t=e._intervals,i=e._clock.currentTime,o=t.indexOf(i);return t.get(o)}function BLt(e,t,n){let i=Pte(e),o=YE(e,t),r=YE(e,n);return i>=0?o>=r:o<=r}function ORe(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 wLt(e,t,n){let i=YE(e,t),o=e._frames,r=o[i];if(!l(r)){let s=t.data.transform,a=l(s)?F.fromArray(s):void 0,c=t.data.uri;r={pointCloud:void 0,transform:a,timestamp:Xi(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber,uri:c},o[i]=r,Le.fetchArrayBuffer({url:c}).then(function(d){r.pointCloud=new yv({arrayBuffer:d,cull:!0,fragmentShaderLoaded:RLt,uniformMapLoaded:VLt(e),pickIdLoaded:GLt})}).catch(ORe(e,c))}return r}function NLt(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 PLt(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,s=r.length;if(zRe(e,t,n,i),o.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=o.geometryByteLength,r.length=s,t.sequential)){let a=(Xi()-t.timestamp)/1e3;NLt(e,a)}}t.touchedFrameNumber=i.frameNumber}var XLt=new F;function YLt(e,t){let n=e.shading;return l(n)&&l(n.baseResolution)?n.baseResolution:l(t.boundingSphere)?L.cbrt(t.boundingSphere.volume()/t.pointsLength):0}function MLt(e){let t=e.shading;return l(t)&&l(t.maximumAttenuation)?t.maximumAttenuation:10}var vLt=new gp;function zRe(e,t,n,i){let o=e.shading??vLt,r=t.pointCloud,s=t.transform??F.IDENTITY;r.modelMatrix=F.multiplyTransformation(e.modelMatrix,s,XLt),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=YLt(e,r),r.geometricErrorScale=o.geometricErrorScale,r.maximumAttenuation=MLt(e);try{r.update(i)}catch(a){ORe(e,t.uri)(a)}t.touchedFrameNumber=i.frameNumber}function Nte(e,t,n,i){let o=wLt(e,t,i);PLt(e,o,n,i)}function ULt(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function HRe(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 s=r.pointCloud;r.ready&&(e._totalMemoryUsageInBytes-=s.geometryByteLength),l(s)&&s.destroy(),r===e._lastRenderedFrame&&(e._lastRenderedFrame=void 0),n[o]=void 0}}}function DLt(e,t){let n=YE(e,t),i=e._frames[n];if(l(i)&&i.ready)return i}function QRe(e,t,n,i,o){return l(n)?n.ready?!0:(Nte(e,t,i,o),n.ready):!1}function kLt(e,t,n,i,o){let r,s,a,c=e._intervals,d=e._frames,u=YE(e,n),h=YE(e,t);if(u>=h){for(r=u;r>=h;--r)if(s=c.get(r),a=d[r],QRe(e,s,a,i,o))return s}else for(r=u;r<=h;++r)if(s=c.get(r),a=d[r],QRe(e,s,a,i,o))return s;return t}function QLt(e,t,n){let i=e._frames,o=i.length;for(let r=0;r<o;++r){let s=i[r];l(s)&&l(s.pointCloud)&&(s.pointCloud.clippingPlanesDirty=t,s.pointCloud.styleDirty=n)}}var sR={timeSinceLoad:0,isClipped:!1,clippingPlanesDirty:!1};ME.prototype.update=function(e){if(e.mode===se.MORPHING||!this.show)return;l(this._pickId)||(this._pickId=e.context.createPickId({primitive:this})),l(this._loa
${t}${f}`);let b=document.createElement("div");b.className="cesium-widget-errorPanel-message-details collapsed";let C=document.createElement("span");C.className="cesium-widget-errorPanel-more-details",C.appendChild(document.createTextNode("See more...")),b.appendChild(C),b.onclick=function(T){b.removeChild(C),b.appendChild(document.createTextNode(f)),b.className="cesium-widget-errorPanel-message-details",r.className="cesium-widget-errorPanel-content expanded",b.onclick=void 0},a.appendChild(b)}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)};tr.prototype.isDestroyed=function(){return!1};tr.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()),he(this)};tr.prototype.resize=function(){let e=this._canvas;!this._forceResize&&this._canvasClientWidth===e.clientWidth&&this._canvasClientHeight===e.clientHeight&&this._lastDevicePixelRatio===window.devicePixelRatio||(this._forceResize=!1,$Re(this),eVe(this),this._scene.requestRender())};tr.prototype.render=function(){if(this._canRender){this._scene.initializeFrame();let e=this._clock.tick();this._scene.render(e)}else this._clock.tick()};tr.prototype._dataSourceAdded=function(e,t){t.entities.collectionChanged.addEventListener(tr.prototype._onEntityCollectionChanged,this)};tr.prototype._dataSourceRemoved=function(e,t){let n=t.entities;n.collectionChanged.removeEventListener(tr.prototype._onEntityCollectionChanged,this),l(this.trackedEntity)&&n.getById(this.trackedEntity.id)===this.trackedEntity&&(this.trackedEntity=void 0)};tr.prototype._updateCanAnimate=function(e){this._clock.canAnimate=e};var zLt=new ue;tr.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??zLt)===Tt.DONE&&i.update(t)}};tr.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)}};tr.prototype._clearTrackedObject=function(){this.trackedEntity=void 0};tr.prototype._onDataSourceChanged=function(e){this.clockTrackedDataSource===e&&jRe(this.clock,e)};tr.prototype._onDataSourceAdded=function(e,t){this._automaticallyTrackDataSourceClocks&&(this.clockTrackedDataSource=t);let n=t.entities.id,i=this._eventHelper.add(t.changedEvent,tr.prototype._onDataSourceChanged,this);this._dataSourceChangedListeners[n]=i};tr.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}};tr.prototype.zoomTo=function(e,t){return tVe(this,e,{offset:t},!1)};tr.prototype.flyTo=function(e,t){return tVe(this,e,t,!0)};function tVe(e,t,n,i){Xte(e);let o=new Promise(r=>{e._completeZoom=function(s){r(s)}});return e._zoomPromise=o,e._zoomIsFlight=i,e._zoomOptions=n,Promise.resolve(t).then(function(r){if(e._zoomPromise===o){if(r instanceof fs){let s;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 s=`in vec3 position3DHigh;in vec3 position3DLow;in float batchId;${n?"":`in ${i} ${t};
`}out ${i} ${o};
void main(){vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);${n?`${o} = czm_batchTable_${t}(batchId);
`:`${o} = ${t};`}gl_Position = czm_modelViewProjectionRelativeToEye * p;
}`,a=`in ${i} ${o};${r}void main(){out_FragColor = getColor();}`;this.material=void 0,this.translucent=e.translucent??!1,this._vertexShaderSource=e.vertexShaderSource??s,this._fragmentShaderSource=e.fragmentShaderSource??a,this._renderState=To.getDefaultRenderState(!1,!1,e.renderState),this._closed=e.closed??!1,this._attributeName=t,this._glslDatatype=i}Object.defineProperties(Zv.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}}});Zv.prototype.getFragmentShaderSource=To.prototype.getFragmentShaderSource;Zv.prototype.isTranslucent=To.prototype.isTranslucent;Zv.prototype.getRenderState=To.prototype.getRenderState;var tne=Zv;var Xxo=y(x(),1);function dz(e){e=e??Q.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=F.clone(e.modelMatrix??F.IDENTITY),this._modelMatrix=new F,this.id=e.id,this._id=void 0,this._primitive=void 0}dz.prototype.update=function(e){if(this.show){if(!l(this._primitive)||!F.equals(this._modelMatrix,this.modelMatrix)||this._length!==this.length||this._width!==this.width||this._id!==this.id){this._modelMatrix=F.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 wt({geometry:new ab({positions:[m.ZERO,m.UNIT_X],width:this.width,vertexFormat:Vs.VERTEX_FORMAT,colors:[U.RED,U.RED],arcType:un.NONE}),modelMatrix:F.multiplyByUniformScale(this.modelMatrix,this.length,new F),id:this.id,pickPrimitive:this}),n=new wt({geometry:new ab({positions:[m.ZERO,m.UNIT_Y],width:this.width,vertexFormat:Vs.VERTEX_FORMAT,colors:[U.GREEN,U.GREEN],arcType:un.NONE}),modelMatrix:F.multiplyByUniformScale(this.modelMatrix,this.length,new F),id:this.id,pickPrimitive:this}),i=new wt({geometry:new ab({positions:[m.ZERO,m.UNIT_Z],width:this.width,vertexFormat:Vs.VERTEX_FORMAT,colors:[U.BLUE,U.BLUE],arcType:un.NONE}),modelMatrix:F.multiplyByUniformScale(this.modelMatrix,this.length,new F),id:this.id,pickPrimitive:this});this._primitive=new Nn({geometryInstances:[t,n,i],appearance:new Vs,asynchronous:!1})}this._primitive.update(e)}};dz.prototype.isDestroyed=function(){return!1};dz.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),he(this)};var Rv=dz;var Uxo=y(x(),1);function q1t(e){this.direction=m.clone(e.direction),this.color=U.clone(e.color??U.WHITE),this.intensity=e.intensity??1}var nne=q1t;var tCo=y(x(),1);var kxo=y(x(),1),Vv=`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 Oxo=y(x(),1),Gv=`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 UE(e){e=e??Q.EMPTY_OBJECT;let t=e.translucent??!0,n=e.aboveGround??!1;this.material=l(e.material)?e.material:Oi.fromType(Oi.ColorType),this.translucent=e.translucent??!0,this._vertexShaderSource=e.vertexShaderSource??Gv,this._fragmentShaderSource=e.fragmentShaderSource??Vv,this._renderState=To.getDefaultRenderState(t,!n,e.renderState),this._closed=!1,this._flat=e.flat??!1,this._faceForward=e.faceForward??n,this._aboveGround=n}Object.defineProperties(UE.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 UE.VERTEX_FORMAT}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}},aboveGround:{get:function(){return this._aboveGround}}});UE.VERTEX_FORMAT=ve.POSITION_AND_ST;UE.prototype.getFragmentShaderSource=To.prototype.getFragmentShaderSource;UE.prototype.isTranslucent=To.prototype.isTranslucent;UE.prototype.getRenderState=To.prototype.getRenderState;var ine=UE;var pCo=y(x(),1);var $1t=1e5;function Lv(e){e=e??Q.EMPTY_OBJECT;let t=e.credit;typeof t=="string"&&(t=new Et(t)),this._credit=t,this._radius=l(e.radius)?e.radius:$1t,this._image=e.image,this._transform=l(e.transform)?e.transform:F.IDENTITY,this._repeatHorizontal=l(e.repeatHorizontal)?e.repeatHorizontal:1,this._repeatVertical=l(e.repeatVertical)?e.repeatVertical:1;let n=new MX({radius:this._radius,vertexFormat:ve.ALL}),i=new wt({geometry:n,modelMatrix:this._transform}),o=new Oi({fabric:{type:"Image",uniforms:{image:this._image,repeat:new M(-this._repeatHorizontal,this._repeatVertical)}}});return this._primitive=new Nn({geometryInstances:i,appearance:new go({material:o,closed:!0,faceForward:!1,translucent:!1,renderState:{cull:{enabled:!1}}}),credit:this._credit}),this}Object.defineProperties(Lv.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)}}});Lv.prototype.update=function(e){return l(this._credit)&&e.creditDisplay.addCreditToNextFrame(this._credit),this._primitive.update(e)};Lv.prototype.destroy=function(){return this._primitive=this._primitive&&this._primitive.destroy(),he(this)};Lv.prototype.isDestroyed=function(){return this._primitive.isDestroyed()};var one=Lv;var TCo=y(x(),1);function kd(e){this._scene=e.scene,this.samplingWindow=e.samplingWindow??kd.defaultSettings.samplingWindow,this.quietPeriod=e.quietPeriod??kd.defaultSettings.quietPeriod,this.warmupPeriod=e.warmupPeriod??kd.defaultSettings.warmupPeriod,this.minimumFrameRateDuringWarmup=e.minimumFrameRateDuringWarmup??kd.defaultSettings.minimumFrameRateDuringWarmup,this.minimumFrameRateAfterWarmup=e.minimumFrameRateAfterWarmup??kd.defaultSettings.minimumFrameRateAfterWarmup,this._lowFrameRate=new xe,this._nominalFrameRate=new xe,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){eWt(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(){tWt(t)}this._visibilityChangeRemoveListener=void 0,l(n)&&(document.addEventListener(n,i,!1),this._visibilityChangeRemoveListener=function(){document.removeEventListener(n,i,!1)})}kd.defaultSettings={samplingWindow:5
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);}`;var j_o=y(x(),1);function qWt(e){e=e??Q.EMPTY_OBJECT,this.typedArray=e.typedArray,this.width=e.width,this.height=e.height,this.pixelFormat=e.pixelFormat??Ke.RGBA,this.pixelDatatype=e.pixelDatatype??Oe.UNSIGNED_BYTE;let t=e.url;typeof t=="string"&&(t=Le.createIfNeeded(t)),this.resource=t;let i=e.repeat??!0?gn.REPEAT:gn.CLAMP_TO_EDGE;this.sampler=new Ht({wrapS:i,wrapT:i,minificationFilter:e.minificationFilter,magnificationFilter:e.magnificationFilter,maximumAnisotropy:e.maximumAnisotropy})}var Nne=qWt;var $_o=y(x(),1),$Wt={FLOAT:"float",VEC2:"vec2",VEC3:"vec3",VEC4:"vec4",MAT2:"mat2",MAT3:"mat3",MAT4:"mat4"},Pne=Object.freeze($Wt);var tIo=y(x(),1),eFt={SIGX:"SIGX",SIGY:"SIGY",SIGZ:"SIGZ",VARX:"VARX",VARY:"VARY",VARZ:"VARZ",SIGR:"VARZ"},Xne=Object.freeze(eFt);var oIo=y(x(),1);function tFt(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 s=await e(i.parameters,o);r.result=s}catch(s){s instanceof Error?r.error={name:s.name,message:s.message,stack:s.stack}:r.error=s}i.canTransferArrayBuffer||(o.length=0);try{postMessage(r,o)}catch(s){r.result=void 0,r.error=`postMessage failed with error: ${yp(s)} 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 Yne=tFt;globalThis.CESIUM_VERSION="1.140.0";var dKo=y(x(),1);var vQo=y(x(),1);var PQo=y(x(),1);var RQo=y(x(),1),zv;typeof ko<"u"&&(zv=ko);(function(){/*!
* Knockout JavaScript library v3.5.1 * (c) The Knockout.js team - http://knockoutjs.com/
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
*/(function(){(function(e){var t=this||(0,eval)("this"),n=t.document,i=t.navigator,o=t.jQuery,r=t.JSON;o||typeof jQuery>"u"||(o=jQuery),(function(s){s(t.ko={})})(function(s,a){function c(g,_){return g===null||typeof g in b?g===_:!1}function d(g,_){var Z;return function(){Z||(Z=f.a.setTimeout(function(){Z=e,g()},_))}}function u(g,_){var Z;return function(){clearTimeout(Z),Z=f.a.setTimeout(g,_)}}function h(g,_){_&&_!=="change"?_==="beforeChange"?this.pc(g):this.gb(g,_):this.qc(g)}function p(g,_){_!==null&&_.s&&_.s()}function A(g,_){var Z=this.qd,G=Z[I];G.ra||(this.Qb&&this.mb[_]?(Z.uc(_,g,this.mb[_]),this.mb[_]=null,--this.Qb):G.I[_]||Z.uc(_,g,G.J?{da:g}:Z.$c(g)),g.Ja&&g.gd())}var f=typeof s<"u"?s:{};f.b=function(g,_){for(var Z=g.split("."),G=f,w=0;w<Z.length-1;w++)G=G[Z[w]];G[Z[Z.length-1]]=_},f.L=function(g,_,Z){g[_]=Z},f.version="3.5.1",f.b("version",f.version),f.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},f.a=(function(){function g(z,j){for(var ee in z)w.call(z,ee)&&j(ee,z[ee])}function _(z,j){if(j)for(var ee in j)w.call(j,ee)&&(z[ee]=j[ee]);return z}function Z(z,j){return z.__proto__=j,z}function G(z,j,ee,ge){var ye=z[j].match(J)||[];f.a.D(ee.match(J),function(ae){f.a.Na(ye,ae,ge)}),z[j]=ye.join(" ")}var w=Object.prototype.hasOwnProperty,X={__proto__:[]}instanceof Array,k=typeof Symbol=="function",v={},D={};v[i&&/Firefox\/2/i.test(i.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"],v.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "),g(v,function(z,j){if(j.length)for(var ee=0,ge=j.length;ee<ge;ee++)D[j[ee]]=z});var Y={propertychange:!0},O=n&&(function(){for(var z=3,j=n.createElement("div"),ee=j.getElementsByTagName("i");j.innerHTML="<!--[if gt IE "+ ++z+"]><i></i><![endif]-->",ee[0];);return 4<z?z:e})(),J=/\S+/g,te;return{Jc:["authenticity_token",/^__RequestVerificationToken(_.*)?$/],D:function(z,j,ee){for(var ge=0,ye=z.length;ge<ye;ge++)j.call(ee,z[ge],ge,z)},A:typeof Array.prototype.indexOf=="function"?function(z,j){return Array.prototype.indexOf.call(z,j)}:function(z,j){for(var ee=0,ge=z.length;ee<ge;ee++)if(z[ee]===j)return ee;return-1},Lb:function(z,j,ee){for(var ge=0,ye=z.length;ge<ye;ge++)if(j.call(ee,z[ge],ge,z))return z[ge];return e},Pa:function(z,j){var ee=f.a.A(z,j);0<ee?z.splice(ee,1):ee===0&&z.shift()},wc:function(z){var j=[];return z&&f.a.D(z,function(ee){0>f.a.A(j,ee)&&j.push(ee)}),j},Mb:function(z,j,ee){var ge=[];if(z)for(var ye=0,ae=z.length;ye<ae;ye++)ge.push(j.call(ee,z[ye],ye));return ge},jb:function(z,j,ee){var ge=[];if(z)for(var ye=0,ae=z.length;ye<ae;ye++)j.call(ee,z[ye],ye)&&ge.push(z[ye]);return ge},Nb:function(z,j){if(j instanceof Array)z.push.apply(z,j);else for(var ee=0,ge=j.length;ee<ge;ee++)z.push(j[ee]);return z},Na:function(z,j,ee){var ge=f.a.A(f.a.bc(z),j);0>ge?ee&&z.push(j):ee||z.splice(ge,1)},Ba:X,extend:_,setPrototypeOf:Z,Ab:X?Z:_,P:g,Ga:function(z,j,ee){if(!z)return z;var ge={},ye;for(ye in z)w.call(z,ye)&&(ge[ye]=j.call(ee,z[ye],ye,z));return ge},Tb:function(z){for(;z.firstChild;)f.removeNode(z.firstChild)},Yb:function(z){z=f.a.la(z);for(var j=(z[0]&&z[0].ownerDocument||n).createElement("div"),ee=0,ge=z.length;ee<ge;ee++)j.appendChild(f.oa(z[ee]));return j},Ca:function(z,j){for(var ee=0,ge=z.length,ye=[];ee<ge;ee++){var ae=z[ee].cloneNode(!0);ye.push(j?f.oa(ae):ae)}return ye},va:function(z,j){if(f.a.Tb(z),j)for(var ee=0,ge=j.length;ee<ge;ee++)z.appendChild(j[ee])},Xc:function(z,j){var ee=z.nodeType?[z]:z;if(0<ee.length){for(var ge=ee[0],ye=ge.parentNode,ae=0,Ce=j.length;ae<Ce;ae++)ye.insertBefore(j[ae],ge);for(ae=0,Ce=ee.length;ae<Ce;ae++)f.removeNode(ee[ae])}},Ua:function(z,j){if(z.length){for(j=j.nodeType===8&&j.parentNode||j;z.length&&z[0].parentNode!==j;)z.splice(0,1);for(;1<z.length&&z[z.length-1].parentNode!==j;)z.length--;if(1<z.length){var ee=z[0],ge=z[z.length-1];for(z.length=0;ee!==ge;)z.push(ee),ee=ee.nextSibling;z.push(ge)}}return z},Zc:function(z,j){7>O?z.setAttribute("selected",j):z.selected=j},Db:function(z){return z===null||z===e?"":z.trim?z.trim():z.toStri,`;var D=[],Y=v.match(G),O,J=[],te=0;if(1<Y.length){for(var z=0,j;j=Y[z];++z){var ee=j.charCodeAt(0);if(ee===44){if(0>=te){D.push(O&&J.length?{key:O,value:J.join("")}:{unknown:O||J.join("")}),O=te=0,J=[];continue}}else if(ee===58){if(!te&&!O&&J.length===1){O=J.pop();continue}}else{if(ee===47&&1<j.length&&(j.charCodeAt(1)===47||j.charCodeAt(1)===42))continue;ee===47&&z&&1<j.length?(ee=Y[z-1].match(w))&&!X[ee[0]]&&(v=v.substr(v.indexOf(j)+1),Y=v.match(G),z=-1,j="/"):ee===40||ee===123||ee===91?++te:ee===41||ee===125||ee===93?--te:O||J.length||ee!==34&&ee!==39||(j=j.slice(1,-1))}J.push(j)}if(0<te)throw Error("Unbalanced parentheses, braces, or brackets")}return D}var _=["true","false","null","undefined"],Z=/^(?:[$_a-z][$\w]*|(.+)(\.\s*[$_a-z][$\w]*|\[.+\]))$/i,G=RegExp(`"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|\`(?:\\\\.|[^\`])*\`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*
|/(?:\\\\.|[^/])+/w*|[^\\s:,/][^,"'\`{}()/:[\\]]*[^\\s,"'\`{}()/:[\\]]|[^\\s]`,"g"),w=/[\])"'A-Za-z0-9_$]+$/,X={in:1,return:1,typeof:1},k={};return{Ra:[],wa:k,ac:g,vb:function(v,D){function Y(ee,ge){var ye;if(!z){var ae=f.getBindingHandler(ee);if(ae&&ae.preprocess&&!(ge=ae.preprocess(ge,ee,Y)))return;(ae=k[ee])&&(ye=ge,0<=f.a.A(_,ye)?ye=!1:(ae=ye.match(Z),ye=ae===null?!1:ae[1]?"Object("+ae[1]+")"+ae[2]:ye),ae=ye),ae&&J.push("'"+(typeof k[ee]=="string"?k[ee]:ee)+"':function(_z){"+ye+"=_z}")}te&&(ge="function(){return "+ge+" }"),O.push("'"+ee+"':"+ge)}D=D||{};var O=[],J=[],te=D.valueAccessors,z=D.bindingParams,j=typeof v=="string"?g(v):v;return f.a.D(j,function(ee){Y(ee.key||ee.unknown,ee.value)}),J.length&&Y("_ko_property_writers","{"+J.join(",")+" }"),O.join(",")},Id:function(v,D){for(var Y=0;Y<v.length;Y++)if(v[Y].key==D)return!0;return!1},eb:function(v,D,Y,O,J){v&&f.O(v)?!f.Za(v)||J&&v.v()===O||v(O):(v=D.get("_ko_property_writers"))&&v[Y]&&v[Y](O)}}})(),f.b("expressionRewriting",f.m),f.b("expressionRewriting.bindingRewriteValidators",f.m.Ra),f.b("expressionRewriting.parseObjectLiteral",f.m.ac),f.b("expressionRewriting.preProcessBindings",f.m.vb),f.b("expressionRewriting._twoWayBindings",f.m.wa),f.b("jsonExpressionRewriting",f.m),f.b("jsonExpressionRewriting.insertPropertyAccessorsIntoJson",f.m.vb),(function(){function g(Y){return Y.nodeType==8&&X.test(w?Y.text:Y.nodeValue)}function _(Y){return Y.nodeType==8&&k.test(w?Y.text:Y.nodeValue)}function Z(Y,O){for(var J=Y,te=1,z=[];J=J.nextSibling;){if(_(J)&&(f.a.g.set(J,D,!0),te--,te===0))return z;z.push(J),g(J)&&te++}if(!O)throw Error("Cannot find closing comment tag to match: "+Y.nodeValue);return null}function G(Y,O){var J=Z(Y,O);return J?0<J.length?J[J.length-1].nextSibling:Y.nextSibling:null}var w=n&&n.createComment("test").text==="<!--test-->",X=w?/^\x3c!--\s*ko(?:\s+([\s\S]+))?\s*--\x3e$/:/^\s*ko(?:\s+([\s\S]+))?\s*$/,k=w?/^\x3c!--\s*\/ko\s*--\x3e$/:/^\s*\/ko\s*$/,v={ul:!0,ol:!0},D="__ko_matchedEndComment__";f.h={ea:{},childNodes:function(Y){return g(Y)?Z(Y):Y.childNodes},Ea:function(Y){if(g(Y)){Y=f.h.childNodes(Y);for(var O=0,J=Y.length;O<J;O++)f.removeNode(Y[O])}else f.a.Tb(Y)},va:function(Y,O){if(g(Y)){f.h.Ea(Y);for(var J=Y.nextSibling,te=0,z=O.length;te<z;te++)J.parentNode.insertBefore(O[te],J)}else f.a.va(Y,O)},Vc:function(Y,O){var J;g(Y)?(J=Y.nextSibling,Y=Y.parentNode):J=Y.firstChild,J?O!==J&&Y.insertBefore(O,J):Y.appendChild(O)},Wb:function(Y,O,J){J?(J=J.nextSibling,g(Y)&&(Y=Y.parentNode),J?O!==J&&Y.insertBefore(O,J):Y.appendChild(O)):f.h.Vc(Y,O)},firstChild:function(Y){if(g(Y))return!Y.nextSibling||_(Y.nextSibling)?null:Y.nextSibling;if(Y.firstChild&&_(Y.firstChild))throw Error("Found invalid end comment, as the first child of "+Y);return Y.firstChild},nextSibling:function(Y){if(g(Y)&&(Y=G(Y)),Y.nextSibling&&_(Y.nextSibling)){var O=Y.nextSibling;if(_(O)&&!f.a.g.get(O,D))throw Error("Found end comment without a matching opening comment, as child of "+Y);return null}return Y.nextSibling},Cd:g,Vd:function(Y){return(Y=(w?Y.text:Y.nodeValue).match(X))?Y[1]:null},Sc:function(Y){if(v[f.a.R(Y)]){var O=Y.firstChild;if(O)do if(O.nodeType===1){var J;J=O.firstChild;var te=null;if(J)do if(te)te.push(J);else if(g(J)){var z=G(J,!0);z?J=z:te=[J]}else _(J)&&(te=[J]);while(J=J.nextSibling);if(J=te)for(te=O.nextSibling,z=0;z<J.length;z++)te?Y.insertBefore(J[z],te):Y.appendChild(J[z])}while(O=O.nextSibling)}}}})(),f.b("virtualElements",f.h),f.b("virtualElements.allowedBindings",f.h.ea),f.b("virtualElements.emptyNode",f.h.Ea),f.b("virtualElements.insertAfter",f.h.Wb),f.b("virtualElements.prepend",f.h.Vc),f.b("virtualElements.setDomNodeChildren",f.h.va),(function(){f.ga=function(){this.nd={}},f.a.extend(f.ga.prototype,{nodeHasBindings:function(g){switch(g.nodeType){case 1:return g.getAttribute("data-bind")!=null||f.j.getComponentNameForNode(g);case 8:return f.h.Cd(g);default:return!1}},getBindings:function(g,_){var Z=this.getBindingsString(g,_),Z=Z?this.parseBindingsString(Z,_,g):null;return f.j.tc(Z,g,_,!1)},getBindingAccessors:function(g,_){var Z=this.getBindingsString(g,_),Z=Z?Bindings value: `+g+`Message: `+Y.message,Y}}}),f.ga.instance=new f.ga})(),f.b("bindingProvider",f.ga),(function(){function g(ae){var Ce=(ae=f.a.g.get(ae,ye))&&ae.N;Ce&&(ae.N=null,Ce.Tc())}function _(ae,Ce,Te){this.node=ae,this.yc=Ce,this.kb=[],this.H=!1,Ce.N||f.a.K.za(ae,g),Te&&Te.N&&(Te.N.kb.push(ae),this.Kb=Te)}function Z(ae){return function(){return ae}}function G(ae){return ae()}function w(ae){return f.a.Ga(f.u.G(ae),function(Ce,Te){return function(){return ae()[Te]}})}function X(ae,Ce,Te){return typeof ae=="function"?w(ae.bind(null,Ce,Te)):f.a.Ga(ae,Z)}function k(ae,Ce){return w(this.getBindings.bind(this,ae,Ce))}function v(ae,Ce){var Te=f.h.firstChild(Ce);if(Te){var Fe,Ne=f.ga.instance,Pe=Ne.preprocessNode;if(Pe){for(;Fe=Te;)Te=f.h.nextSibling(Fe),Pe.call(Ne,Fe);Te=f.h.firstChild(Ce)}for(;Fe=Te;)Te=f.h.nextSibling(Fe),D(ae,Fe)}f.i.ma(Ce,f.i.H)}function D(ae,Ce){var Te=ae,Fe=Ce.nodeType===1;Fe&&f.h.Sc(Ce),(Fe||f.ga.instance.nodeHasBindings(Ce))&&(Te=O(Ce,null,ae).bindingContextForDescendants),Te&&!ee[f.a.R(Ce)]&&v(Te,Ce)}function Y(ae){var Ce=[],Te={},Fe=[];return f.a.P(ae,function Ne(Pe){if(!Te[Pe]){var Xe=f.getBindingHandler(Pe);Xe&&(Xe.after&&(Fe.push(Pe),f.a.D(Xe.after,function(st){if(ae[st]){if(f.a.A(Fe,st)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+Fe.join(", "));Ne(st)}}),Fe.length--),Ce.push({key:Pe,Mc:Xe})),Te[Pe]=!0}}),Ce}function O(ae,Ce,Te){var Fe=f.a.g.Ub(ae,ye,{}),Ne=Fe.hd;if(!Ce){if(Ne)throw Error("You cannot apply bindings multiple times to the same element.");Fe.hd=!0}Ne||(Fe.context=Te),Fe.Zb||(Fe.Zb={});var Pe;if(Ce&&typeof Ce!="function")Pe=Ce;else{var Xe=f.ga.instance,st=Xe.getBindingAccessors||k,Ye=f.$(function(){return(Pe=Ce?Ce(Te,ae):st.call(Xe,ae,Te))&&(Te[te]&&Te[te](),Te[j]&&Te[j]()),Pe},null,{l:ae});Pe&&Ye.ja()||(Ye=null)}var xt=Te,at;if(Pe){var Je=function(){return f.a.Ga(Ye?Ye():Pe,G)},lt=Ye?function(ht){return function(){return G(Ye()[ht])}}:function(ht){return Pe[ht]};Je.get=function(ht){return Pe[ht]&&G(lt(ht))},Je.has=function(ht){return ht in Pe},f.i.H in Pe&&f.i.subscribe(ae,f.i.H,function(){var ht=(0,Pe[f.i.H])();if(ht){var Rt=f.h.childNodes(ae);Rt.length&&ht(Rt,f.Ec(Rt[0]))}}),f.i.pa in Pe&&(xt=f.i.Cb(ae,Te),f.i.subscribe(ae,f.i.pa,function(){var ht=(0,Pe[f.i.pa])();ht&&f.h.firstChild(ae)&&ht(ae)})),Fe=Y(Pe),f.a.D(Fe,function(ht){var Rt=ht.Mc.init,_e=ht.Mc.update,Re=ht.key;if(ae.nodeType===8&&!f.h.ea[Re])throw Error("The binding '"+Re+"' cannot be used with virtual elements");try{typeof Rt=="function"&&f.u.G(function(){var jt=Rt(ae,lt(Re),Je,xt.$data,xt);if(jt&&jt.controlsDescendantBindings){if(at!==e)throw Error("Multiple bindings ("+at+" and "+Re+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");at=Re}}),typeof _e=="function"&&f.$(function(){_e(ae,lt(Re),Je,xt.$data,xt)},null,{l:ae})}catch(jt){throw jt.message='Unable to process binding "'+Re+": "+Pe[Re]+`"Message: `+jt.message,jt}})}return Fe=at===e,{shouldBindDescendants:Fe,bindingContextForDescendants:Fe&&xt}}function J(ae,Ce){return ae&&ae instanceof f.fa?ae:new f.fa(ae,e,e,Ce)}var te=f.a.Da("_subscribable"),z=f.a.Da("_ancestorBindingInfo"),j=f.a.Da("_dataDependency");f.c={};var ee={script:!0,textarea:!0,template:!0};f.getBindingHandler=function(ae){return f.c[ae]};var ge={};f.fa=function(ae,Ce,Te,Fe,Ne){function Pe(){var lt=xt?Ye():Ye,ht=f.a.f(lt);return Ce?(f.a.extend(Xe,Ce),z in Ce&&(Xe[z]=Ce[z])):(Xe.$parents=[],Xe.$root=ht,Xe.ko=f),Xe[te]=at,st?ht=Xe.$data:(Xe.$rawData=lt,Xe.$data=ht),Te&&(Xe[Te]=ht),Fe&&Fe(Xe,Ce,ht),Ce&&Ce[te]&&!f.S.o().Vb(Ce[te])&&Ce[te](),Je&&(Xe[j]=Je),Xe.$data}var Xe=this,st=ae===ge,Ye=st?e:ae,xt=typeof Ye=="function"&&!f.O(Ye),at,Je=Ne&&Ne.dataDependency;Ne&&Ne.exportDependencies?Pe():(at=f.xb(Pe),at.v(),at.ja()?at.equalityComparer=null:Xe[te]=e)},f.fa.prototype.createChildContext=function(ae,Ce,Te,Fe){if(!Fe&&Ce&&typeof Ce=="object"&&(Fe=Ce,Ce=Fe.as,Te=Fe.extend),Ce&&Fe&&Fe.noChildContext){var Ne=typeof ae=="function"&&!f.O(ae);return new f.fa(ge,this,null,function(Pe){Te&&Te(Pe),Pe[Ce]=Ne?ae():ae},Fe)}return new f.fa(ae,this,Ce,function(Pe,Xe){Pe.$parentContext=Xe,Pe.$parent=Xe.$data,Pe.$parents=(Xe.$parents||[]).slice(0),Pe.$parents.unshift(Pe.$parent),Te&&Te(Pe)},Fe)},f.fa.prototype.extend=function(ae,Ce){return new f.fa(ge,this,null,function(Te){f.a.extend(Te,typeof ae=="function"?ae(Te):ae)},Ce)};var ye=f.a.g.Z();_.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)},_.prototype.sd=function(ae){f.a.Pa(this.kb,ae),!this.kb.length&&this.H&&this.Cc()},_.prototype.Cc=function(){this.H=!0,this.yc.N&&!this.kb.length&&(this.yc.N=null,f.a.K.yb(this.node,g),f.i.ma(this.node,f.i.pa),this.Tc())},f.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(ae,Ce,Te,Fe,Ne){var Pe=f.a.g.Ub(ae,ye,{});return Pe.Fa||(Pe.Fa=new f.T),Ne&&Ne.notifyImmediately&&Pe.Zb[Ce]&&f.u.G(Te,Fe,[ae]),Pe.Fa.subscribe(Te,Fe,Ce)},ma:function(ae,Ce){var Te=f.a.g.get(ae,ye);if(Te&&(Te.Zb[Ce]=!0,Te.Fa&&Te.Fa.notifySubscribers(ae,Ce),Ce==f.i.H)){if(Te.N)Te.N.Cc();else if(Te.N===e&&Te.Fa&&Te.Fa.Wa(f.i.pa))throw Error("descendantsComplete event not supported for bindings on this node")}},Cb:function(ae,Ce){var Te=f.a.g.Ub(ae,ye,{});return Te.N||(Te.N=new _(ae,Te,Ce[z])),Ce[z]==Te?Ce:Ce.extend(function(Fe){Fe[z]=Te})}},f.Td=function(ae){return(ae=f.a.g.get(ae,ye))&&ae.context},f.ib=function(ae,Ce,Te){return ae.nodeType===1&&f.h.Sc(ae),O(ae,Ce,J(Te))},f.ld=function(ae,Ce,Te){return Te=J(Te),f.ib(ae,X(Ce,Te,ae),Te)},f.Oa=function(ae,Ce){Ce.nodeType!==1&&Ce.nodeType!==8||v(J(ae),Ce)},f.vc=function(ae,Ce,Te){if(!o&&t.jQuery&&(o=t.jQuery),2>arguments.length){if(Ce=n.body,!Ce)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!Ce||Ce.nodeType!==1&&Ce.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");D(J(ae,Te),Ce)},f.Dc=function(ae){return!ae||ae.nodeType!==1&&ae.nodeType!==8?e:f.Td(ae)},f.Ec=function(ae){return(ae=f.Dc(ae))?ae.$data:e},f.b("bindingHandlers",f.c),f.b("bindingEvent",f.i),f.b("bindingEvent.subscribe",f.i.subscribe),f.b("bindingEvent.startPossiblyAsyncContentBinding",f.i.Cb),f.b("applyBindings",f.vc),f.b("applyBindingsToDescendants",f.Oa),f.b("applyBindingAccessorsToNode",f.ib),f.b("applyBindingsToNode",f.ld),f.b("contextFor",f.Dc),f.b("dataFor",f.Ec)})(),(function(g){function _(k,v){var D=Object.prototype.hasOwnProperty.call(w,k)?w[k]:g,Y;D?D.subscribe(v):(D=w[k]=new f.T,D.subscribe(v),Z(k,function(O,J){var te=!(!J||!J.synchronous);X[k]={definition:O,Gd:te},delete w[k],Y||te?D.notifySubscribers(O):f.na.zb(function(){D.notifySubscribers(O)})}),Y=!0)}function Z(k,v){G("getConfig",[k],function(D){D?G("loadComponent",[k,D],function(Y){v(Y,D)}):v(null,null)})}function G(k,v,D,Y){Y||(Y=f.j.loaders.slice(0));var O=Y.shift();if(O){var J=O[k];if(J){var te=!1;if(J.apply(O,v.concat(function(z){te?D(null):z!==null?D(z):G(k,v,D,Y)}))!==g&&(te=!0,!O.suppressLoaderExceptions))throw
* @license * Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5
* Copyright (c) Steve Sanderson * MIT license */var Mne="__knockoutObservables",vne="__knockoutSubscribable";function VVe(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=GVe(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(o){if(!(o===Mne||o===vne)&&!(o in i)){var r=e[o],s=r instanceof Array,a=n.isObservable(r)?r:s?n.observableArray(r):n.observable(r);Object.defineProperty(e,o,{configurable:!0,enumerable:!0,get:a,set:n.isWriteableObservable(a)?a:void 0}),i[o]=a,s&&oFt(n,a)}}),e}function GVe(e,t){var n=e[Mne];return!n&&t&&(n={},Object.defineProperty(e,Mne,{value:n})),n}function iFt(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),VVe.call(i,e,[t]),e}function oFt(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=rFt(e,t,i))})}function rFt(e,t,n){var i=sFt(e,n);return i.subscribe(t)}function sFt(e,t){var n=t[vne];if(!n){n=new e.subscribable,Object.defineProperty(t,vne,{value:n});var i={};aFt(t,n,i),cFt(e,t,n,i)}return n}function aFt(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 cFt(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 LVe(e,t){if(!e)return null;var n=GVe(e,!1);return n&&n[t]||null}function lFt(e,t){var n=LVe(e,t);n&&n.valueHasMutated()}function dFt(e){e.track=VVe,e.getObservable=LVe,e.valueHasMutated=lFt,e.defineProperty=iFt}var Hv={attachToKo:dFt};var WQo=y(x(),1),WVe="http://www.w3.org/2000/svg",FVe="cesium-svgPath-svg",uFt={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){let i=document.createElementNS(WVe,"svg:svg");i.setAttribute("class",FVe);let o=document.createElementNS(WVe,"path");return i.appendChild(o),e.virtualElements.setDomNodeChildren(t,[i]),e.computed({read:function(){let r=e.unwrap(n());o.setAttribute("d",e.unwrap(r.path));let s=e.unwrap(r.width),a=e.unwrap(r.height);i.setAttribute("width",s),i.setAttribute("height",a),i.setAttribute("viewBox",`0 0 ${s} ${a}`),r.css&&i.setAttribute("class",`${FVe} ${e.unwrap(r.css)}`)},disposeWhenNodeIsRemoved:t}),{controlsDescendantBindings:!0}}},e.virtualElements.allowedBindings.cesiumSvgPath=!0}},Jv=uFt;Hv.attachToKo(OE);Jv.register(OE);var Ie=OE;function Kv(e){l(e)||(e=new pf),this._clock=e,this._eventHelper=new Xr,this._eventHelper.add(e.onTick,this.synchronize,this),this.systemTime=Ie.observable(q.now()),this.systemTime.equalityComparer=q.equals,this.startTime=Ie.observable(e.startTime),this.startTime.equalityComparer=q.equals,this.startTime.subscribe(function(t){e.startTime=t,this.synchronize()},this),this.stopTime=Ie.observable(e.stopTime),this.stopTime.equalityComparer=q.equals,this.stopTime.subscribe(function(t){e.stopTime=t,this.synchronize()},this),this.currentTime=Ie.observable(e.currentTime),this.currentTime.equalityComparer=q.equals,this.currentTime.subscribe(function(t){e.currentTime=t,this.synchronize()},this),this.multiplier=Ie.observable(e.multiplier),this.multiplier.subscribe(function(t){e.multiplier=t,this.synchronize()},this),this.clockStep=Ie.observable(e.clockStep),this.clockStep.subscribe(function(t){e.clockStep=t,this.synchronize()},this),this.clockRange=Ie.observable(e.clockRange),this.clockRange.subscribe(function(t){e.clockRange=t,this.synchronize()},this),this.canAnimate=Ie.observable(e.canAnimate),this.canAnimate.subscrib <ul class="cesium-cesiumInspector-statistics"> <li><strong>Geometry Memory (MB): </strong>${nU(e.geometryByteLength)}</li> <li><strong>Texture Memory (MB): </strong>${nU(e.texturesByteLength)}</li> </ul> `}var _Ft=[{text:"Highlight",value:yd.HIGHLIGHT},{text:"Replace",value:yd.REPLACE},{text:"Mix",value:yd.MIX}],YVe=new U(1,1,0,.4),IFt=new U,Sz=new U;function bc(e,t){let n=this,i=e.canvas;this._eventHandler=new Du(i),this._scene=e,this._performanceContainer=t,this._canvas=i,this._performanceDisplay=new Tb({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,Ie.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=Ie.observable({}),this.properties=[],Ie.defineProperty(this,"properties",function(){let Y=[],O=n._properties();for(let J in O)O.hasOwnProperty(J)&&Y.push(J);return Y});let o=Ie.observable();Ie.defineProperty(this,"dynamicScreenSpaceError",{get:function(){return o()},set:function(Y){o(Y),l(n._tileset)&&(n._tileset.dynamicScreenSpaceError=Y)}}),this.dynamicScreenSpaceError=!1;let r=Ie.observable();Ie.defineProperty(this,"colorBlendMode",{get:function(){return r()},set:function(Y){r(Y),l(n._tileset)&&(n._tileset.colorBlendMode=Y,n._scene.requestRender())}}),this.colorBlendMode=yd.HIGHLIGHT;let s=Ie.observable(),a=Ie.observable();Ie.defineProperty(this,"picking",{get:function(){return a()},set:function(Y){a(Y),Y?n._eventHandler.setInputAction(function(O){let J=e.pick(O.endPosition);if(J instanceof Ga?(n.feature=J,n.tile=J.content.tile):l(J)&&l(J.content)?(n.feature=void 0,n.tile=J.content.tile):(n.feature=void 0,n.tile=void 0),!!l(n._tileset)){if(s&&l(J)&&l(J.content)){let te;e.pickPositionSupported&&(te=e.pickPosition(O.endPosition),l(te)&&(n._tileset.debugPickPosition=te)),n._tileset.debugPickedTile=J.content.tile}else n._tileset.debugPickedTile=void 0;n._scene.requestRender()}},Gn.MOUSE_MOVE):(n.feature=void 0,n.tile=void 0,n._eventHandler.removeInputAction(Gn.MOUSE_MOVE))}}),this.picking=!0;let c=Ie.observable();Ie.defineProperty(this,"colorize",{get:function(){return c()},set:function(Y){c(Y),l(n._tileset)&&(n._tileset.debugColorizeTiles=Y,n._scene.requestRender())}}),this.colorize=!1;let d=Ie.observable();Ie.defineProperty(this,"wireframe",{get:function(){return d()},set:function(Y){d(Y),l(n._tileset)&&(n._tileset.debugWireframe=Y,n._scene.requestRender())}}),this.wireframe=!1;let u=Ie.observable();Ie.defineProperty(this,"showBoundingVolumes",{get:function(){return u()},set:function(Y){u(Y),l(n._tileset)&&(n._tileset.debugShowBoundingVolume=Y,n._scene.requestRender())}}),this.showBoundingVolumes=!1;let h=Ie.observable();Ie.defineProperty(this,"showContentBoundingVolumes",{get:function(){return h()},set:function(Y){h(Y),l(n._tileset)&&(n._tileset.debugShowContentBoundingVolume=Y,n._scene.requestRender())}}),this.showContentBoundingVolumes=!1;let p=Ie.observable();Ie.defineProperty(this,"showRequestVolumes",{get:function(){return p()},set:function(Y){p(Y),l(n._tileset)&&(n._tileset.debugShowViewerRequestVolume=Y,n._scene.requestRender())}}),this.showRequestVolumes=!1;let A=Ie.observable();Ie.defineProperty(this,"freezeFrame",{get:function(){return A()},set:function(Y){A(Y),l(n._tileset)&&(n._tileset.debugFreezeFrame=Y,n._scene.debugShowFrustumPlanes=Y,n._scene.requestRender())}}),this.freezeFrame=!1,Ie.defineProperty(this,"showOnlyPickedTileDebugLabel",{get:function(){return s()},set:function(Y){s(Y),l(n._tileset)&&(n._tileset.debugPickedTileLabelOnly=Y,n._scene.requestRender())}}),
`),c=a.length,d;if(t.shiftKey)for(d=0;d<c;++d)a[d][0]===" "&&(a[d][1]===" "?(a[d]=a[d].substr(2),r-=2):(a[d]=a[d].substr(1),r-=1));else for(d=0;d<c;++d)a[d]=` ${a[d]}`,r+=2;let u=a.join(``);n.value=n.value.slice(0,i)+u+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};bc.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=iU(e,!1),this._pickStatisticsText=iU(e,!0),this._resourceCacheStatisticsText=vVe())};bc.prototype.isDestroyed=function(){return!1};bc.prototype.destroy=function(){this._eventHandler.destroy(),this._removePostRenderEvent();let e=this;return this._definedProperties.forEach(function(t){Ie.getObservable(e,t).dispose()}),he(this)};bc.getStatistics=iU;var oU=bc;function _z(e,t){e=vn(e);let n=document.createElement("div"),i=document.createElement("div");i.setAttribute("data-bind","visible: performance");let o=new oU(t,i);this._viewModel=o,this._container=e,this._element=n;let r=document.createElement("div");r.textContent="3D Tiles Inspector",r.className="cesium-cesiumInspector-button",r.setAttribute("data-bind","click: toggleInspector"),n.appendChild(r),n.className="cesium-cesiumInspector cesium-3DTilesInspector",n.setAttribute("data-bind",'css: { "cesium-cesiumInspector-visible" : inspectorVisible, "cesium-cesiumInspector-hidden" : !inspectorVisible}'),e.appendChild(n);let s=document.createElement("div");s.className="cesium-cesiumInspector-dropDown",n.appendChild(s);let a=Od.createSection,c=Od.createCheckbox,d=Od.createRangeInput,u=Od.createButton,h=a(s,"Tileset","tilesetVisible","toggleTileset"),p=a(s,"Display","displayVisible","toggleDisplay"),A=a(s,"Update","updateVisible","toggleUpdate"),f=a(s,"Logging","loggingVisible","toggleLogging"),b=a(s,"Tile Debug Labels","tileDebugLabelsVisible","toggleTileDebugLabels"),C=a(s,"Style","styleVisible","toggleStyle"),T=a(s,"Optimization","optimizationVisible","toggleOptimization"),E=document.createElement("div");E.className="field-group";let S=document.createElement("label");S.className="field-label",S.appendChild(document.createTextNode("Properties: "));let I=document.createElement("div");I.setAttribute("data-bind","text: properties"),E.appendChild(S),E.appendChild(I),h.appendChild(E),h.appendChild(u("Pick Tileset","togglePickTileset","pickActive")),h.appendChild(u("Trim Tiles Cache","trimTilesCache")),h.appendChild(c("Enable Picking","picking")),p.appendChild(c("Colorize","colorize"));let R=p.appendChild(c("Wireframe","wireframe","_tileset === undefined || hasEnabledWireframe")),V=document.createElement("p");V.setAttribute("data-bind","visible: _tileset !== undefined && !hasEnabledWireframe"),V.setAttribute("class","cesium-3DTilesInspector-disabledElementsInfo"),V.innerText="Set enableDebugWireframe to true in the tileset constructor to enable this option.",R.appendChild(V),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 W=document.createElement("div");W.setAttribute("data-bind","visible: pointCloudShading"),W.appendChild(d("Geometric Error Scale","geometricErrorScale",0,2,.01)),W.appendChild(d("Maximum Attenuation","maximumAttenuation",0,32,1)),W.appendChild(d("Base Resolution","baseResolution",0,1,.01)),W.appendChild(c("Eye Dome Lighting (EDL)","eyeDomeLighting")),p.appendChild(W);let B=document.createElement("div");B.setAttribute("data-bind","visible: eyeDomeLighting"),B.appendChild(d("EDL Strength","eyeDomeLightingStrength",0,2,.1)),B.appendChild(d("EDL Radius","eyeDomeLightingRadius",0,4,.1)),W.appendChild(B),A.appendChild(c("Freeze Frame","freezeFrame")),A.appendChild(c("Dynamic Screen Space Error","dynamicScreenSpaceError"));let N=document.createElement("div");N.appendChild(d("Maximum Screen Space Error","maximumS
${f}`:l(A)?A:f}),this.buttonImageUrl=void 0,Ie.defineProperty(this,"buttonImageUrl",function(){let h=this.selectedImagery;if(l(h))return h.iconUrl}),this.selectedImagery=void 0;let c=Ie.observable();this.updateSelectedImageryViewModel=h=>{c(h),this.dropDownVisible=!1},this._currentImageryLayers=[],Ie.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(h){if(c()===h){this.dropDownVisible=!1;return}let p=e.map,A,f=this._currentImageryLayers,b=f.length,C=this._globe.imageryLayers,T=!1;if(!p)for(A=0;A<b;A++){let E=C.length;for(let S=0;S<E;S++){let I=C.get(S);if(I===f[A]){C.remove(I),T=!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 S=E.length;for(this._currentImageryLayers=[],A=S-1;A>=0;A--){let I=fs.fromProviderAsync(E[A]);C.add(I,0),this._currentImageryLayers.push(I)}}else{this._currentImageryLayers=[];let S=fs.fromProviderAsync(E);if(S.name=h.name,T)C.add(S,0);else{let I=C.get(0);l(I)&&C.remove(I),C.add(S,0)}this._currentImageryLayers.push(S)}}else p&&(p.basemap=void 0);c(h),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;let d=Ie.observable();this.updateSelectedTerrainViewModel=h=>{d(h),this.dropDownVisible=!1},Ie.defineProperty(this,"selectedTerrain",{get:function(){return d()},set:function(h){if(d()===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,f=this._globe.terrainProviderChanged.addEventListener(()=>{A=!0,f()}),C=new kv(p).readyEvent.addEventListener(T=>{if(!A){if(e.map&&h.marsOptions){e.map.terrainProvider=T;return}this._globe.terrainProvider=T,C()}})}d(h),this.dropDownVisible=!1}});let u=this;this._toggleDropDown=Fn(function(){u.dropDownVisible=!u.dropDownVisible}),this.selectedImagery=e.selectedImageryProviderViewModel,this.selectedTerrain=e.selectedTerrainProviderViewModel}Object.defineProperties(UVe.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});var sU=UVe;function Iz(e,t){e=vn(e);let n=new sU(t),i=document.createElement("button");i.type="button",i.className="cesium-button cesium-toolbar-button",i.setAttribute("data-bind","attr: { title: buttonTooltip },click: toggleDropDown"),e.appendChild(i);let o=document.createElement("img");o.setAttribute("draggable","false"),o.className="cesium-baseLayerPicker-selected",o.setAttribute("data-bind","attr: { src: buttonImageUrl }, visible: !!buttonImageUrl"),i.appendChild(o);let r=document.createElement("div");r.className="cesium-baseLayerPicker-dropDown",r.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }'),e.appendChild(r);let s=document.createElement("div");s.className="cesium-baseLayerPicker-sectionTitle",s.setAttribute("data-bind","visible: imageryProviderViewModels.length > 0"),s.innerHTML="Imagery",r.appendChild(s);let a=document.createElement("div");a.className="cesium-baseLayerPicker-section",a.setAttribute("data-bind","foreach: _imageryProviders"),r.appendChild(a);let c=document.createElement("div");c.className="cesium-baseLayerPicker-category",a.appendChild(c);let d=document.createElement("div");d.className="cesium-baseLayerPicker-categoryTitle",d.setAttribute("data-bind","text: name"),c.appendChild(d);let u=document.createElement("div");u.className="cesium-baseLayerPicker-choices",u.setAttribute("data-bind","foreach: providers"),c.appendChild(u);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; }'),u.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 pg.fromBasemapType(Jh.SATELLITE,{enablePickFeatures:!1})}})),e.push(new cr({name:"ArcGIS World Hillshade",iconUrl:en("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 pg.fromBasemapType(Jh.HILLSHADE,{enablePickFeatures:!1})}})),e.push(new cr({name:"Esri World Ocean",iconUrl:en("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 pg.fromBasemapType(Jh.OCEANS,{enablePickFeatures:!1})}})),e.push(new cr({name:"Open\xADStreet\xADMap",iconUrl:en("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 Fb({url:"https://tile.openstreetmap.org/"})}})),e.push(new cr({name:"Stadia x Stamen Watercolor",iconUrl:en("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 Fb({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 cr({name:"Stadia x Stamen Toner",iconUrl:en("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 Fb({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 cr({name:"Stadia Alidade Smooth",iconUrl:en("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 Fb({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 cr({name:"Stadia Alidade Smooth Dark",iconUrl:en("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 Fb({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 cr({name:"Sentinel-2",iconUrl:en("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 Dl.fromAssetId(3954)}})),e.push(new cr({name:"Blue Marble",iconUrl:en("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3845)}})),e.push(new cr({name:"Earth at night",iconUrl:en("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 Dl.fromAssetId(3812)}})),e.push(new cr({name:"Natural Earth\xA0II",iconUrl:en("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.http://www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return X0.fromUrl(en("Assets/Textures/NaturalEarthII"))}})),e.push(new cr({name:"Google Maps Satellite",iconUrl:en("Widgets/Images/ImageryProviders/googleSatellite.png"),tooltip:"Imagery from Google Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3830182)}})),e.push(new cr({name:"Google Maps Satellite with Labels",iconUrl:en("Widgets/Images/ImageryProviders/googleSatelliteLabels.png"),tooltip:"Imagery with place labels from Google Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3830183)}})),e.push(new cr({name:"Google Maps Roadmap",iconUrl:en("Widgets/Images/ImageryProviders/googleRoadmap.png"),tooltip:"Labeled roads and other features on a base landscape from Google Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3830184)}})),e.push(new cr({name:"Google Maps Contour",iconUrl:en("Widgets/Images/ImageryProviders/googleContour.png"),tooltip:"Hillshade mapping, contour lines, natural features (roadmap features hidden) from Google Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3830186)}})),e.push(new cr({name:"Azure Maps Aerial",iconUrl:en("Widgets/Images/ImageryProviders/azureAerial.png"),tooltip:"Imagery from Azure Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3891168)}})),e.push(new cr({name:"Azure Maps Roads",iconUrl:en("Widgets/Images/ImageryProviders/azureRoads.png"),tooltip:"Labeled roads and other features on a base landscape from Azure Maps",category:"Cesium ion",creationFunction:function(){return Dl.fromAssetId(3891169)}})),e}var cU=ZFt;var azo=y(x(),1);function RFt(){let e=[];return e.push(new cr({name:"WGS84 Ellipsoid",iconUrl:en("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new qT({ellipsoid:ie.WGS84})}})),e.push(new cr({name:"Cesium World Terrain",iconUrl:en("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 jT({requestWaterMask:!0,requestVertexNormals:!0})}})),e}var lU=RFt;var Czo=y(x(),1);var hzo=y(x(),1);function VFt(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 s=[];for(let a=2;a>=0;a--){let c=Math.pow(2,a);o>=c&&(s.push(a+1),o-=c)}r=s.reverse().join(" and ")}t+=`<br> ${n[i]} in frustum ${r}`}t+=`<br>Total: ${e.totalCommands}`}return t}function Hne(e,t,n){let i=Math.min(n,t);return i=Math.max(i,e),i}var GFt=new Cn,LFt=new m;function dU(e,t){let n=this,i=e.canvas,o=new Du(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="",Ie.track(this,["frustums","frustumPlanes","performance","shaderCacheText","primitiveBoundingSphere","primitiveReferenceFrame","filterPrimitive","tileBoundingSphere","filterTile","wireframe","depthFrustum","suspendUpdates","tileCoordinates","frustumStatisticText","tileText","hasPickedPrimitive","hasPickedTile","pickPrimitiveActive","pickTileActive","dropDownVisible"
<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 yU(t);Ie.track(o),Ie.applyBindings(o,n),l(o.defaultLayer)&&(o.currentLayer=o.defaultLayer)}var jne=zFt;var _3o=y(x(),1);var b3o=y(x(),1);var HFt="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",JFt="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 qne(){this._cameraClicked=new xe,this._closeClicked=new xe,this.maxHeight=500,this.enableCamera=!1,this.isCameraTracking=!1,this.showInfo=!1,this.titleText="",this.description="",Ie.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,Ie.defineProperty(this,"cameraIconPath",{get:function(){return!this.enableCamera||this.isCameraTracking?JFt:HFt}}),Ie.defineProperty(this,"_bodyless",{get:function(){return!l(this.description)||this.description.length===0}})}qne.prototype.maxHeightOffset=function(e){return`${this.maxHeight-e}px`};Object.defineProperties(qne.prototype,{cameraClicked:{get:function(){return this._cameraClicked}},closeClicked:{get:function(){return this._closeClicked}}});var xU=qne;function Fz(e){e=vn(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 s=new xU;Ie.applyBindings(s,t),this._container=e,this._element=t,this._frame=r,this._viewModel=s,this._descriptionSubscription=void 0;let a=this;r.addEventListener("load",function(){let c=r.contentDocument,d=c.createElement("link");d.href=en("Widgets/InfoBox/InfoBoxDescription.css"),d.rel="stylesheet",d.type="text/css";let u=c.createElement("div");u.className="cesium-infoBox-description",c.head.appendChild(d),c.body.appendChild(u),a._descriptionSubscription=gc(s,"description",function(h){r.style.height="5px",u.innerHTML=h;let p=null,A=u.firstElementChild;if(A!==null&&u.childNodes.length===1){let b=window.getComputedStyle(A);if(b!==null){let C=b["background-color"],T=U.fromCssColorString(C);l(T)&&T.alpha!==0&&(p=b["background-color"])}}t.style["background-color"]=p;let f=u.getBoundingClientRect().height;r.style.height=`${f}px`})}),r.setAttribute("src","about:blank")}Object.defineProperties(Fz.prototype,{co`),n;for(n=0;n<t.length&&!t[n].match(/\S/);n++);if(n===t.length)return"";let i="",o=/^\s*/,s=t[n].match(o)[0].length;for(let a=n;a<t.length;a++){let c=t[a];c.match(o)[0].length>=s&&(c=c.slice(s)),i+=`${c}`}return i}function fh(e){this._scene=e,this._voxelPrimitive=void 0,this._customShaderCompilationRemoveCallback=void 0,this._definedProperties=[],this._getPrimitiveFunctions=[],this._modelMatrixReady=!1;let t=this;function n(o){let{name:r,initialValue:s}=o;t._definedProperties.push(r);let a=o.setPrimitiveFunction;a===!0&&(a=function(u){t._voxelPrimitive[r]=u});let c=o.getPrimitiveFunction;c===!0&&(c=function(){t[r]=t._voxelPrimitive[r]}),l(c)&&t._getPrimitiveFunctions.push(c);let d=Ie.observable();return Ie.defineProperty(t,r,{get:function(){return d()},set:function(u){typeof s=="number"&&typeof u=="string"&&(u=Number(u),isNaN(u)&&(u=s)),typeof s=="boolean"&&typeof u=="number"&&(u=u===1),d(u),l(a)&&l(t._voxelPrimitive)&&(a(u),e.requestRender())}}),t[r]=s,d}function i(o,r){return function(s){let a=t._voxelPrimitive[o].clone();a[r]=s,t._voxelPrimitive[o]=a}}n({name:"inspectorVisible",initialValue:!0}),n({name:"displayVisible",initialValue:!1}),n({name:"transformVisible",initialValue:!1}),n({name:"boundsVisible",initialValue:!1}),n({name:"clippingVisible",initialValue:!1}),n({name:"shaderVisible",initialValue:!1}),n({name:"shaderString",initialValue:"",getPrimitiveFunction:function(){let o=t._voxelPrimitive.customShader.fragmentShaderText;t.shaderString=fGe(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===Ac.BOX}}),n({name:"shapeIsEllipsoid",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsEllipsoid=o===Ac.ELLIPSOID}}),n({name:"shapeIsCylinder",getPrimitiveFunction:function(){let o=t._voxelPrimitive.shape;t.shapeIsCylinder=o===Ac.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=a.length,d;if(t.shiftKey)for(d=0;d<c;++d)a[d][0]===" "&&(a[d][1]===" "?(a[d]=a[d].substr(2),r-=2):(a[d]=a[d].substr(1),r-=1));else for(d=0;d<c;++d)a[d]=` ${a[d]}`,r+=2;let u=a.join(``);n.value=n.value.slice(0,i)+u+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};fh.prototype.isDestroyed=function(){return!1};fh.prototype.destroy=function(){let e=this;return this._definedProperties.forEach(function(t){Ie.getObservable(e,t).dispose()}),he(this)};var XU=fh;function kz(e,t){e=vn(e);let n=document.createElement("div"),i=new XU(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:s,createCheckbox:a,createRangeInput:c,createButton:d}=Od,u=s(r,"Display","displayVisible","toggleDisplay"),h=s(r,"Transform","transformVisible","toggleTransform"),p=s(r,"Clipping","clippingVisible","toggleClipping"),A=s(r,"Shader","shaderVisible","toggleShader");u.appendChild(a("Depth Test","depthTest")),u.appendChild(a("Show","show")),u.appendChild(a("Disable Update","disableUpdate")),u.appendChild(a("Debug Draw","debugDraw")),u.appendChild(a("Jitter","jitter")),u.appendChild(a("Nearest Sampling","nearestSampling")),u.appendChild(c("Screen Space Error","screenSpaceError",0,128)),u.appendChild(c("Step Size","stepSize",0,2));let f=10,b=10,C=L.PI;h.appendChild(c("Translation X","translationX",-f,+f)),h.appendChild(c("Translation Y","translationY",-f,+f)),h.appendChild(c("Translation Z","translationZ",-f,+f)),h.appendChild(c("Scale X","scaleX",0,+b)),h.appendChild(c("Scale Y","scaleY",0,+b)),h.appendChild(c("Scale Z","scaleZ",0,+b)),h.appendChild(c("Heading","angleX",-C,+C)),h.appendChild(c("Pitch","angleY",-C,+C)),h.appendChild(c("Roll","angleZ",-C,+C)),mie("Max X","Min X","Max Y","Min Y","Max Z","Min Z","clippingBoxMaxX","clippingBoxMinX","clippingBoxMaxY","clippingBoxMinY","clippingBoxMaxZ","clippingBoxMinZ","shapeIsBox",p),mie("Max Longitude","Min Longitude","Max Latitude","Min Latitude","Max Height","Min Height","clippingEllipsoidMaxLongitude","clippingEllipsoidMinLongitude","clippingEllipsoidMaxLatitude","clippingEllipsoidMinLatitude","clippingEllipsoidMaxHeight","clippingEllipsoidMinHeight","shapeIsEllipsoid",p),mie("Max Radius","Min Radius","Max Angle","Min Angle","Max Height","Min Height","clippingCylinderMaxRadius","clippingCylinderMinRadius","clippingCylinderMaxAngle","clippingCylinderMinAngle","clippingCylinderMaxHeight","clippingCylinderMinHeight","shapeIsCylinder",p);let T=document.createElement("div");A.appendChild(T);let E=document.createElement("textarea");E.setAttribute("data-bind","textInput: shaderString, event: { keydown: shaderEditorKeyPress }"),T.className="cesium-cesiumInspector-styleEditor",T.appendChild(E);let S=d("Compile (Ctrl+Enter)","compileShader");T.appendChild(S);let I=document.createElement("label");I.style.display="block",I.setAttribute("data-bind","text: shaderCompilationMessage, style: {color: shaderCompilationSuccess ? 'green' : 'red'}"),T.appendChild(I),Ie.applyBindings(i,n)}Object.defineProperties(kz.prototype,{container:{get:function(){return this._container}},viewModel:{get:function(){return this._viewModel}}});kz.prototype.isDestroyed=function(){return!1};kz.prototype.destroy=function(){return Ie.cleanNode(this._element),this._container.removeChild(this._element),this.viewModel.destroy(),he(this)};function mie(e,t,n,i,o,r,s,a,c,d,u,h,p,A){let f=Od.createRangeInputWithDynamicMinMax,b=A.appendChild(document.createElement("div"));b.setAttribute("data-bind",`if: ${p}`),b.appendChild(f(e,s)),b.appendChild(f(t,a)),b.appendChild(f(n,c)),b.appendChild(f(i,d)),b.appendChild(f(o,u)),b.appendChild(f(r,h))}var YU=kz;function W2t(e){let t=document.createElement("div");t.className="cesium-viewer-voxelIn
|