园林绿化
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17126 lines
5.5 MiB

  1. /**
  2. * @license
  3. * Cesium - https://github.com/CesiumGS/cesium
  4. * Version 1.140.0
  5. *
  6. * Copyright 2011-2022 Cesium Contributors
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. *
  20. * Columbus View (Pat. Pend.)
  21. *
  22. * Portions licensed separately.
  23. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details.
  24. */
  25. "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
  26. * URI.js - Mutating URLs
  27. * IPv6 Support
  28. *
  29. * Version: 1.19.11
  30. *
  31. * Author: Rodney Rehm
  32. * Web: http://medialize.github.io/URI.js/
  33. *
  34. * Licensed under
  35. * MIT License http://www.opensource.org/licenses/mit-license
  36. *
  37. */(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());/*!
  38. * URI.js - Mutating URLs
  39. * Second Level Domain (SLD) Support
  40. *
  41. * Version: 1.19.11
  42. *
  43. * Author: Rodney Rehm
  44. * Web: http://medialize.github.io/URI.js/
  45. *
  46. * Licensed under
  47. * MIT License http://www.opensource.org/licenses/mit-license
  48. *
  49. */(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
  50. * URI.js - Mutating URLs
  51. *
  52. * Version: 1.19.11
  53. *
  54. * Author: Rodney Rehm
  55. * Web: http://medialize.github.io/URI.js/
  56. *
  57. * Licensed under
  58. * MIT License http://www.opensource.org/licenses/mit-license
  59. *
  60. */(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
  61. * protobuf.js v8.0.1 (c) 2016, daniel wirtz
  62. * compiled sat, 04 apr 2026 19:23:15 utc
  63. * licensed under the bsd-3-clause license
  64. * see: https://github.com/dcodeio/protobuf.js for details
  65. */(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
  66. NoSleep enabled for older iOS devices. This can interrupt
  67. active or long-running network requests from completing successfully.
  68. See https://github.com/richtr/NoSleep.js/issues/15 for more details.
  69. `),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(`
  70. NoSleep now disabled for older iOS devices.
  71. `),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
  72. ${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
  73. (${this[1]}, ${this[4]}, ${this[7]})
  74. (${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+=`
  75. ${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]
  76. (${this[1]}, ${this[5]}, ${this[9]}, ${this[13]})
  77. (${this[2]}, ${this[6]}, ${this[10]}, ${this[14]})
  78. (${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,
  79. `);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
  80. in vec2 textureCoordinates;
  81. out vec2 v_textureCoordinates;
  82. void main()
  83. {
  84. gl_Position = position;
  85. v_textureCoordinates = textureCoordinates;
  86. }
  87. `;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(
  88. (${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
  89. ${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:
  90. ${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:
  91. ${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
  92. importScripts("${O3(CESIUM_WORKERS)}");
  93. CesiumWorkers["${i}"]();
  94. `;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=
  95. * A built-in GLSL floating-point constant for converting radians to degrees.
  96. *
  97. * @alias czm_degreesPerRadian
  98. * @glslConstant
  99. *
  100. * @see CesiumMath.DEGREES_PER_RADIAN
  101. *
  102. * @example
  103. * // GLSL declaration
  104. * const float czm_degreesPerRadian = ...;
  105. *
  106. * // Example
  107. * float deg = czm_degreesPerRadian * rad;
  108. */
  109. const float czm_degreesPerRadian = 57.29577951308232;
  110. `;var k9t=y(x(),1),sV=`/**
  111. * A built-in GLSL vec2 constant for defining the depth range.
  112. * This is a workaround to a bug where IE11 does not implement gl_DepthRange.
  113. *
  114. * @alias czm_depthRange
  115. * @glslConstant
  116. *
  117. * @example
  118. * // GLSL declaration
  119. * float depthRangeNear = czm_depthRange.near;
  120. * float depthRangeFar = czm_depthRange.far;
  121. *
  122. */
  123. const czm_depthRangeStruct czm_depthRange = czm_depthRangeStruct(0.0, 1.0);
  124. `;var O9t=y(x(),1),aV=`/**
  125. * 0.1
  126. *
  127. * @name czm_epsilon1
  128. * @glslConstant
  129. */
  130. const float czm_epsilon1 = 0.1;
  131. `;var H9t=y(x(),1),cV=`/**
  132. * 0.01
  133. *
  134. * @name czm_epsilon2
  135. * @glslConstant
  136. */
  137. const float czm_epsilon2 = 0.01;
  138. `;var K9t=y(x(),1),lV=`/**
  139. * 0.001
  140. *
  141. * @name czm_epsilon3
  142. * @glslConstant
  143. */
  144. const float czm_epsilon3 = 0.001;
  145. `;var q9t=y(x(),1),dV=`/**
  146. * 0.0001
  147. *
  148. * @name czm_epsilon4
  149. * @glslConstant
  150. */
  151. const float czm_epsilon4 = 0.0001;
  152. `;var e5t=y(x(),1),uV=`/**
  153. * 0.00001
  154. *
  155. * @name czm_epsilon5
  156. * @glslConstant
  157. */
  158. const float czm_epsilon5 = 0.00001;
  159. `;var n5t=y(x(),1),mV=`/**
  160. * 0.000001
  161. *
  162. * @name czm_epsilon6
  163. * @glslConstant
  164. */
  165. const float czm_epsilon6 = 0.000001;
  166. `;var o5t=y(x(),1),hV=`/**
  167. * 0.0000001
  168. *
  169. * @name czm_epsilon7
  170. * @glslConstant
  171. */
  172. const float czm_epsilon7 = 0.0000001;
  173. `;var s5t=y(x(),1),fV=`/**
  174. * DOC_TBA
  175. *
  176. * @name czm_infinity
  177. * @glslConstant
  178. */
  179. const float czm_infinity = 5906376272000.0; // Distance from the Sun to Pluto in meters. TODO: What is best given lowp, mediump, and highp?
  180. `;var c5t=y(x(),1),pV=`/**
  181. * A built-in GLSL floating-point constant for <code>1/pi</code>.
  182. *
  183. * @alias czm_oneOverPi
  184. * @glslConstant
  185. *
  186. * @see CesiumMath.ONE_OVER_PI
  187. *
  188. * @example
  189. * // GLSL declaration
  190. * const float czm_oneOverPi = ...;
  191. *
  192. * // Example
  193. * float pi = 1.0 / czm_oneOverPi;
  194. */
  195. const float czm_oneOverPi = 0.3183098861837907;
  196. `;var d5t=y(x(),1),AV=`/**
  197. * A built-in GLSL floating-point constant for <code>1/2pi</code>.
  198. *
  199. * @alias czm_oneOverTwoPi
  200. * @glslConstant
  201. *
  202. * @see CesiumMath.ONE_OVER_TWO_PI
  203. *
  204. * @example
  205. * // GLSL declaration
  206. * const float czm_oneOverTwoPi = ...;
  207. *
  208. * // Example
  209. * float pi = 2.0 * czm_oneOverTwoPi;
  210. */
  211. const float czm_oneOverTwoPi = 0.15915494309189535;
  212. `;var m5t=y(x(),1),gV=`/**
  213. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
  214. *
  215. * @name czm_passCesium3DTile
  216. * @glslConstant
  217. *
  218. * @see czm_pass
  219. */
  220. const float czm_passCesium3DTile = 5.0;
  221. `;var f5t=y(x(),1),bV=`/**
  222. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}
  223. *
  224. * @name czm_passCesium3DTileClassification
  225. * @glslConstant
  226. *
  227. * @see czm_pass
  228. */
  229. const float czm_passCesium3DTileClassification = 6.0;
  230. `;var A5t=y(x(),1),yV=`/**
  231. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}
  232. *
  233. * @name czm_passCesium3DTileClassificationIgnoreShow
  234. * @glslConstant
  235. *
  236. * @see czm_pass
  237. */
  238. const float czm_passCesium3DTileClassificationIgnoreShow = 7.0;
  239. `;var b5t=y(x(),1),xV=`/**
  240. * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_EDGES}
  241. *
  242. * @name czm_passCesium3DTileEdges
  243. * @glslConstant
  244. *
  245. * @see czm_pass
  246. */
  247. const float czm_passCesium3DTileEdges = 4.0;
  248. `;var x5t=y(x(),1),CV=`/**
  249. * The automatic GLSL constant for {@link Pass#CLASSIFICATION}
  250. *
  251. * @name czm_passClassification
  252. * @glslConstant
  253. *
  254. * @see czm_pass
  255. */
  256. const float czm_passClassification = 7.0;
  257. `;var T5t=y(x(),1),TV=`/**
  258. * The automatic GLSL constant for {@link Pass#COMPUTE}
  259. *
  260. * @name czm_passCompute
  261. * @glslConstant
  262. *
  263. * @see czm_pass
  264. */
  265. const float czm_passCompute = 1.0;
  266. `;var S5t=y(x(),1),EV=`/**
  267. * The automatic GLSL constant for {@link Pass#ENVIRONMENT}
  268. *
  269. * @name czm_passEnvironment
  270. * @glslConstant
  271. *
  272. * @see czm_pass
  273. */
  274. const float czm_passEnvironment = 0.0;
  275. `;var I5t=y(x(),1),SV=`/**
  276. * The automatic GLSL constant for {@link Pass#GAUSSIAN_SPLATS}
  277. *
  278. * @name czm_passGaussianSplats
  279. * @glslConstant
  280. *
  281. * @see czm_pass
  282. */
  283. const float czm_passGaussianSplats = 11.0;
  284. `;var R5t=y(x(),1),_V=`/**
  285. * The automatic GLSL constant for {@link Pass#GLOBE}
  286. *
  287. * @name czm_passGlobe
  288. * @glslConstant
  289. *
  290. * @see czm_pass
  291. */
  292. const float czm_passGlobe = 2.0;
  293. `;var G5t=y(x(),1),IV=`/**
  294. * The automatic GLSL constant for {@link Pass#OPAQUE}
  295. *
  296. * @name czm_passOpaque
  297. * @glslConstant
  298. *
  299. * @see czm_pass
  300. */
  301. const float czm_passOpaque = 8.0;
  302. `;var W5t=y(x(),1),ZV=`/**
  303. * The automatic GLSL constant for {@link Pass#OVERLAY}
  304. *
  305. * @name czm_passOverlay
  306. * @glslConstant
  307. *
  308. * @see czm_pass
  309. */
  310. const float czm_passOverlay = 12.0;
  311. `;var B5t=y(x(),1),RV=`/**
  312. * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}
  313. *
  314. * @name czm_passTerrainClassification
  315. * @glslConstant
  316. *
  317. * @see czm_pass
  318. */
  319. const float czm_passTerrainClassification = 3.0;
  320. `;var N5t=y(x(),1),VV=`/**
  321. * The automatic GLSL constant for {@link Pass#TRANSLUCENT}
  322. *
  323. * @name czm_passTranslucent
  324. * @glslConstant
  325. *
  326. * @see czm_pass
  327. */
  328. const float czm_passTranslucent = 9.0;
  329. `;var X5t=y(x(),1),GV=`/**
  330. * The automatic GLSL constant for {@link Pass#VOXELS}
  331. *
  332. * @name czm_passVoxels
  333. * @glslConstant
  334. *
  335. * @see czm_pass
  336. */
  337. const float czm_passVoxels = 10.0;
  338. `;var M5t=y(x(),1),LV=`/**
  339. * A built-in GLSL floating-point constant for <code>Math.PI</code>.
  340. *
  341. * @alias czm_pi
  342. * @glslConstant
  343. *
  344. * @see CesiumMath.PI
  345. *
  346. * @example
  347. * // GLSL declaration
  348. * const float czm_pi = ...;
  349. *
  350. * // Example
  351. * float twoPi = 2.0 * czm_pi;
  352. */
  353. const float czm_pi = 3.141592653589793;
  354. `;var U5t=y(x(),1),WV=`/**
  355. * A built-in GLSL floating-point constant for <code>pi/4</code>.
  356. *
  357. * @alias czm_piOverFour
  358. * @glslConstant
  359. *
  360. * @see CesiumMath.PI_OVER_FOUR
  361. *
  362. * @example
  363. * // GLSL declaration
  364. * const float czm_piOverFour = ...;
  365. *
  366. * // Example
  367. * float pi = 4.0 * czm_piOverFour;
  368. */
  369. const float czm_piOverFour = 0.7853981633974483;
  370. `;var k5t=y(x(),1),FV=`/**
  371. * A built-in GLSL floating-point constant for <code>pi/6</code>.
  372. *
  373. * @alias czm_piOverSix
  374. * @glslConstant
  375. *
  376. * @see CesiumMath.PI_OVER_SIX
  377. *
  378. * @example
  379. * // GLSL declaration
  380. * const float czm_piOverSix = ...;
  381. *
  382. * // Example
  383. * float pi = 6.0 * czm_piOverSix;
  384. */
  385. const float czm_piOverSix = 0.5235987755982988;
  386. `;var O5t=y(x(),1),BV=`/**
  387. * A built-in GLSL floating-point constant for <code>pi/3</code>.
  388. *
  389. * @alias czm_piOverThree
  390. * @glslConstant
  391. *
  392. * @see CesiumMath.PI_OVER_THREE
  393. *
  394. * @example
  395. * // GLSL declaration
  396. * const float czm_piOverThree = ...;
  397. *
  398. * // Example
  399. * float pi = 3.0 * czm_piOverThree;
  400. */
  401. const float czm_piOverThree = 1.0471975511965976;
  402. `;var H5t=y(x(),1),wV=`/**
  403. * A built-in GLSL floating-point constant for <code>pi/2</code>.
  404. *
  405. * @alias czm_piOverTwo
  406. * @glslConstant
  407. *
  408. * @see CesiumMath.PI_OVER_TWO
  409. *
  410. * @example
  411. * // GLSL declaration
  412. * const float czm_piOverTwo = ...;
  413. *
  414. * // Example
  415. * float pi = 2.0 * czm_piOverTwo;
  416. */
  417. const float czm_piOverTwo = 1.5707963267948966;
  418. `;var K5t=y(x(),1),NV=`/**
  419. * A built-in GLSL floating-point constant for converting degrees to radians.
  420. *
  421. * @alias czm_radiansPerDegree
  422. * @glslConstant
  423. *
  424. * @see CesiumMath.RADIANS_PER_DEGREE
  425. *
  426. * @example
  427. * // GLSL declaration
  428. * const float czm_radiansPerDegree = ...;
  429. *
  430. * // Example
  431. * float rad = czm_radiansPerDegree * deg;
  432. */
  433. const float czm_radiansPerDegree = 0.017453292519943295;
  434. `;var q5t=y(x(),1),PV=`/**
  435. * The constant identifier for the 2D {@link SceneMode}
  436. *
  437. * @name czm_sceneMode2D
  438. * @glslConstant
  439. * @see czm_sceneMode
  440. * @see czm_sceneModeColumbusView
  441. * @see czm_sceneMode3D
  442. * @see czm_sceneModeMorphing
  443. */
  444. const float czm_sceneMode2D = 2.0;
  445. `;var eQt=y(x(),1),XV=`/**
  446. * The constant identifier for the 3D {@link SceneMode}
  447. *
  448. * @name czm_sceneMode3D
  449. * @glslConstant
  450. * @see czm_sceneMode
  451. * @see czm_sceneMode2D
  452. * @see czm_sceneModeColumbusView
  453. * @see czm_sceneModeMorphing
  454. */
  455. const float czm_sceneMode3D = 3.0;
  456. `;var nQt=y(x(),1),YV=`/**
  457. * The constant identifier for the Columbus View {@link SceneMode}
  458. *
  459. * @name czm_sceneModeColumbusView
  460. * @glslConstant
  461. * @see czm_sceneMode
  462. * @see czm_sceneMode2D
  463. * @see czm_sceneMode3D
  464. * @see czm_sceneModeMorphing
  465. */
  466. const float czm_sceneModeColumbusView = 1.0;
  467. `;var oQt=y(x(),1),MV=`/**
  468. * The constant identifier for the Morphing {@link SceneMode}
  469. *
  470. * @name czm_sceneModeMorphing
  471. * @glslConstant
  472. * @see czm_sceneMode
  473. * @see czm_sceneMode2D
  474. * @see czm_sceneModeColumbusView
  475. * @see czm_sceneMode3D
  476. */
  477. const float czm_sceneModeMorphing = 0.0;
  478. `;var sQt=y(x(),1),vV=`/**
  479. * A built-in GLSL floating-point constant for one solar radius.
  480. *
  481. * @alias czm_solarRadius
  482. * @glslConstant
  483. *
  484. * @see CesiumMath.SOLAR_RADIUS
  485. *
  486. * @example
  487. * // GLSL declaration
  488. * const float czm_solarRadius = ...;
  489. */
  490. const float czm_solarRadius = 695500000.0;
  491. `;var cQt=y(x(),1),UV=`/**
  492. * A built-in GLSL floating-point constant for <code>3pi/2</code>.
  493. *
  494. * @alias czm_threePiOver2
  495. * @glslConstant
  496. *
  497. * @see CesiumMath.THREE_PI_OVER_TWO
  498. *
  499. * @example
  500. * // GLSL declaration
  501. * const float czm_threePiOver2 = ...;
  502. *
  503. * // Example
  504. * float pi = (2.0 / 3.0) * czm_threePiOver2;
  505. */
  506. const float czm_threePiOver2 = 4.71238898038469;
  507. `;var dQt=y(x(),1),DV=`/**
  508. * A built-in GLSL floating-point constant for <code>2pi</code>.
  509. *
  510. * @alias czm_twoPi
  511. * @glslConstant
  512. *
  513. * @see CesiumMath.TWO_PI
  514. *
  515. * @example
  516. * // GLSL declaration
  517. * const float czm_twoPi = ...;
  518. *
  519. * // Example
  520. * float pi = czm_twoPi / 2.0;
  521. */
  522. const float czm_twoPi = 6.283185307179586;
  523. `;var mQt=y(x(),1),kV=`/**
  524. * The maximum latitude, in radians, both North and South, supported by a Web Mercator
  525. * (EPSG:3857) projection. Technically, the Mercator projection is defined
  526. * for any latitude up to (but not including) 90 degrees, but it makes sense
  527. * to cut it off sooner because it grows exponentially with increasing latitude.
  528. * The logic behind this particular cutoff value, which is the one used by
  529. * Google Maps, Bing Maps, and Esri, is that it makes the projection
  530. * square. That is, the rectangle is equal in the X and Y directions.
  531. *
  532. * The constant value is computed as follows:
  533. * czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))
  534. *
  535. * @name czm_webMercatorMaxLatitude
  536. * @glslConstant
  537. */
  538. const float czm_webMercatorMaxLatitude = 1.4844222297453324;
  539. `;var fQt=y(x(),1),QV=`/**
  540. * @name czm_depthRangeStruct
  541. * @glslStruct
  542. */
  543. struct czm_depthRangeStruct
  544. {
  545. float near;
  546. float far;
  547. };
  548. `;var AQt=y(x(),1),OV=`/**
  549. * Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.
  550. *
  551. * @name czm_material
  552. * @glslStruct
  553. *
  554. * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
  555. * @property {float} specular Intensity of incoming light reflecting in a single direction.
  556. * @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
  557. * @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.
  558. * @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
  559. * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
  560. */
  561. struct czm_material
  562. {
  563. vec3 diffuse;
  564. float specular;
  565. float shininess;
  566. vec3 normal;
  567. vec3 emission;
  568. float alpha;
  569. };
  570. `;var bQt=y(x(),1),zV=`/**
  571. * Used as input to every material's czm_getMaterial function.
  572. *
  573. * @name czm_materialInput
  574. * @glslStruct
  575. *
  576. * @property {float} s 1D texture coordinates.
  577. * @property {vec2} st 2D texture coordinates.
  578. * @property {vec3} str 3D texture coordinates.
  579. * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
  580. * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
  581. * @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.
  582. * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.
  583. * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
  584. * @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.
  585. * @property {float} waterMask The value of the water mask. 0 is land, 1 is water. Only available for globe materials.
  586. */
  587. struct czm_materialInput
  588. {
  589. float s;
  590. vec2 st;
  591. vec3 str;
  592. vec3 normalEC;
  593. mat3 tangentToEyeMatrix;
  594. vec3 positionToEyeEC;
  595. float height;
  596. float slope;
  597. float aspect;
  598. float waterMask;
  599. };
  600. `;var xQt=y(x(),1),HV=`/**
  601. * Struct for representing a material for a {@link Model}. The model
  602. * rendering pipeline will pass this struct between material, custom shaders,
  603. * and lighting stages. This is not to be confused with {@link czm_material}
  604. * which is used by the older Fabric materials system, although they are similar.
  605. * <p>
  606. * All color values (diffuse, specular, emissive) are in linear color space.
  607. * </p>
  608. *
  609. * @name czm_modelMaterial
  610. * @glslStruct
  611. *
  612. * @property {vec4} baseColor The base color of the material.
  613. * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
  614. * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
  615. * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature.
  616. * @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.
  617. * @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.
  618. * @property {float} occlusion Ambient occlusion recieved at this point on the material. 1.0 means fully lit, 0.0 means fully occluded.
  619. * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
  620. */
  621. struct czm_modelMaterial {
  622. vec4 baseColor;
  623. vec3 diffuse;
  624. float alpha;
  625. vec3 specular;
  626. float roughness;
  627. vec3 normalEC;
  628. float occlusion;
  629. vec3 emissive;
  630. #ifdef USE_SPECULAR
  631. float specularWeight;
  632. #endif
  633. #ifdef USE_ANISOTROPY
  634. vec3 anisotropicT;
  635. vec3 anisotropicB;
  636. float anisotropyStrength;
  637. #endif
  638. #ifdef USE_CLEARCOAT
  639. float clearcoatFactor;
  640. float clearcoatRoughness;
  641. vec3 clearcoatNormal;
  642. // Add clearcoatF0 when KHR_materials_ior is implemented
  643. #endif
  644. };
  645. `;var TQt=y(x(),1),JV=`/**
  646. * Struct for representing the output of a custom vertex shader.
  647. *
  648. * @name czm_modelVertexOutput
  649. * @glslStruct
  650. *
  651. * @see {@link CustomShader}
  652. * @see {@link Model}
  653. *
  654. * @property {vec3} positionMC The position of the vertex in model coordinates
  655. * @property {float} pointSize A custom value for gl_PointSize. This is only used for point primitives.
  656. */
  657. struct czm_modelVertexOutput {
  658. vec3 positionMC;
  659. float pointSize;
  660. };
  661. `;var SQt=y(x(),1),KV=`/**
  662. * DOC_TBA
  663. *
  664. * @name czm_ray
  665. * @glslStruct
  666. */
  667. struct czm_ray
  668. {
  669. vec3 origin;
  670. vec3 direction;
  671. };
  672. `;var IQt=y(x(),1),jV=`/**
  673. * DOC_TBA
  674. *
  675. * @name czm_raySegment
  676. * @glslStruct
  677. */
  678. struct czm_raySegment
  679. {
  680. float start;
  681. float stop;
  682. };
  683. /**
  684. * DOC_TBA
  685. *
  686. * @name czm_emptyRaySegment
  687. * @glslConstant
  688. */
  689. const czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity);
  690. /**
  691. * DOC_TBA
  692. *
  693. * @name czm_fullRaySegment
  694. * @glslConstant
  695. */
  696. const czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity);
  697. `;var RQt=y(x(),1),qV=`struct czm_shadowParameters
  698. {
  699. #ifdef USE_CUBE_MAP_SHADOW
  700. vec3 texCoords;
  701. #else
  702. vec2 texCoords;
  703. #endif
  704. float depthBias;
  705. float depth;
  706. float nDotL;
  707. vec2 texelStepSize;
  708. float normalShadingSmooth;
  709. float darkness;
  710. };
  711. `;var GQt=y(x(),1),$V=`// See:
  712. // https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
  713. vec3 czm_acesTonemapping(vec3 color) {
  714. float g = 0.985;
  715. float a = 0.065;
  716. float b = 0.0001;
  717. float c = 0.433;
  718. float d = 0.238;
  719. color = (color * (color + a) - b) / (color * (g * color + c) + d);
  720. color = clamp(color, 0.0, 1.0);
  721. return color;
  722. }
  723. `;var WQt=y(x(),1),eG=`/**
  724. * @private
  725. */
  726. float czm_alphaWeight(float a)
  727. {
  728. float z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
  729. // See Weighted Blended Order-Independent Transparency for examples of different weighting functions:
  730. // http://jcgt.org/published/0002/02/09/
  731. 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))));
  732. }
  733. `;var BQt=y(x(),1),tG=`/**
  734. * Procedural anti-aliasing by blurring two colors that meet at a sharp edge.
  735. *
  736. * @name czm_antialias
  737. * @glslFunction
  738. *
  739. * @param {vec4} color1 The color on one side of the edge.
  740. * @param {vec4} color2 The color on the other side of the edge.
  741. * @param {vec4} currentcolor The current color, either <code>color1</code> or <code>color2</code>.
  742. * @param {float} dist The distance to the edge in texture coordinates.
  743. * @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.
  744. * @returns {vec4} The anti-aliased color.
  745. *
  746. * @example
  747. * // GLSL declarations
  748. * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);
  749. * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);
  750. *
  751. * // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
  752. * float dist = abs(textureCoordinates.t - 0.5);
  753. * vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));
  754. * vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);
  755. */
  756. vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)
  757. {
  758. float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);
  759. float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);
  760. val1 = val1 * (1.0 - val2);
  761. val1 = val1 * val1 * (3.0 - (2.0 * val1));
  762. val1 = pow(val1, 0.5); //makes the transition nicer
  763. vec4 midColor = (color1 + color2) * 0.5;
  764. return mix(midColor, currentColor, val1);
  765. }
  766. vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)
  767. {
  768. return czm_antialias(color1, color2, currentColor, dist, 0.1);
  769. }
  770. `;var NQt=y(x(),1),nG=`/**
  771. * Apply a HSB color shift to an RGB color.
  772. *
  773. * @param {vec3} rgb The color in RGB space.
  774. * @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
  775. * @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.
  776. *
  777. * @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.
  778. */
  779. vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {
  780. // Convert rgb color to hsb
  781. vec3 hsb = czm_RGBToHSB(rgb);
  782. // Perform hsb shift
  783. // Hue cycles around so no clamp is needed.
  784. hsb.x += hsbShift.x; // hue
  785. hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation
  786. // brightness
  787. //
  788. // Some shaders such as atmosphere-related effects need to leave black
  789. // pixels unchanged
  790. if (ignoreBlackPixels) {
  791. hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;
  792. } else {
  793. hsb.z = hsb.z + hsbShift.z;
  794. }
  795. hsb.z = clamp(hsb.z, 0.0, 1.0);
  796. // Convert shifted hsb back to rgb
  797. return czm_HSBToRGB(hsb);
  798. }
  799. `;var XQt=y(x(),1),iG=`/**
  800. * Approximately computes spherical coordinates given a normal.
  801. * Uses approximate inverse trigonometry for speed and consistency,
  802. * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
  803. *
  804. * @name czm_approximateSphericalCoordinates
  805. * @glslFunction
  806. *
  807. * @param {vec3} normal arbitrary-length normal.
  808. *
  809. * @returns {vec2} Approximate latitude and longitude spherical coordinates.
  810. */
  811. vec2 czm_approximateSphericalCoordinates(vec3 normal) {
  812. // Project into plane with vertical for latitude
  813. float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
  814. float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
  815. return vec2(latitudeApproximation, longitudeApproximation);
  816. }
  817. `;var MQt=y(x(),1),oG=`/**
  818. * Compute a rational approximation to tanh(x)
  819. *
  820. * @param {float} x A real number input
  821. * @returns {float} An approximation for tanh(x)
  822. */
  823. float czm_approximateTanh(float x) {
  824. float x2 = x * x;
  825. return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
  826. }
  827. `;var UQt=y(x(),1),rG=`/**
  828. * Determines if the fragment is back facing
  829. *
  830. * @name czm_backFacing
  831. * @glslFunction
  832. *
  833. * @returns {bool} <code>true</code> if the fragment is back facing; otherwise, <code>false</code>.
  834. */
  835. bool czm_backFacing()
  836. {
  837. // !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.
  838. return gl_FrontFacing == false;
  839. }
  840. `;var kQt=y(x(),1),sG=`/**
  841. * Branchless ternary operator to be used when it's inexpensive to explicitly
  842. * evaluate both possibilities for a float expression.
  843. *
  844. * @name czm_branchFreeTernary
  845. * @glslFunction
  846. *
  847. * @param {bool} comparison A comparison statement
  848. * @param {float} a Value to return if the comparison is true.
  849. * @param {float} b Value to return if the comparison is false.
  850. *
  851. * @returns {float} equivalent of comparison ? a : b
  852. */
  853. float czm_branchFreeTernary(bool comparison, float a, float b) {
  854. float useA = float(comparison);
  855. return a * useA + b * (1.0 - useA);
  856. }
  857. /**
  858. * Branchless ternary operator to be used when it's inexpensive to explicitly
  859. * evaluate both possibilities for a vec2 expression.
  860. *
  861. * @name czm_branchFreeTernary
  862. * @glslFunction
  863. *
  864. * @param {bool} comparison A comparison statement
  865. * @param {vec2} a Value to return if the comparison is true.
  866. * @param {vec2} b Value to return if the comparison is false.
  867. *
  868. * @returns {vec2} equivalent of comparison ? a : b
  869. */
  870. vec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {
  871. float useA = float(comparison);
  872. return a * useA + b * (1.0 - useA);
  873. }
  874. /**
  875. * Branchless ternary operator to be used when it's inexpensive to explicitly
  876. * evaluate both possibilities for a vec3 expression.
  877. *
  878. * @name czm_branchFreeTernary
  879. * @glslFunction
  880. *
  881. * @param {bool} comparison A comparison statement
  882. * @param {vec3} a Value to return if the comparison is true.
  883. * @param {vec3} b Value to return if the comparison is false.
  884. *
  885. * @returns {vec3} equivalent of comparison ? a : b
  886. */
  887. vec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {
  888. float useA = float(comparison);
  889. return a * useA + b * (1.0 - useA);
  890. }
  891. /**
  892. * Branchless ternary operator to be used when it's inexpensive to explicitly
  893. * evaluate both possibilities for a vec4 expression.
  894. *
  895. * @name czm_branchFreeTernary
  896. * @glslFunction
  897. *
  898. * @param {bool} comparison A comparison statement
  899. * @param {vec3} a Value to return if the comparison is true.
  900. * @param {vec3} b Value to return if the comparison is false.
  901. *
  902. * @returns {vec3} equivalent of comparison ? a : b
  903. */
  904. vec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {
  905. float useA = float(comparison);
  906. return a * useA + b * (1.0 - useA);
  907. }
  908. `;var OQt=y(x(),1),aG=`
  909. vec4 czm_cascadeColor(vec4 weights)
  910. {
  911. return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +
  912. vec4(0.0, 1.0, 0.0, 1.0) * weights.y +
  913. vec4(0.0, 0.0, 1.0, 1.0) * weights.z +
  914. vec4(1.0, 0.0, 1.0, 1.0) * weights.w;
  915. }
  916. `;var HQt=y(x(),1),cG=`
  917. uniform vec4 shadowMap_cascadeDistances;
  918. float czm_cascadeDistance(vec4 weights)
  919. {
  920. return dot(shadowMap_cascadeDistances, weights);
  921. }
  922. `;var KQt=y(x(),1),lG=`
  923. uniform mat4 shadowMap_cascadeMatrices[4];
  924. mat4 czm_cascadeMatrix(vec4 weights)
  925. {
  926. return shadowMap_cascadeMatrices[0] * weights.x +
  927. shadowMap_cascadeMatrices[1] * weights.y +
  928. shadowMap_cascadeMatrices[2] * weights.z +
  929. shadowMap_cascadeMatrices[3] * weights.w;
  930. }
  931. `;var qQt=y(x(),1),dG=`
  932. uniform vec4 shadowMap_cascadeSplits[2];
  933. vec4 czm_cascadeWeights(float depthEye)
  934. {
  935. // One component is set to 1.0 and all others set to 0.0.
  936. vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));
  937. vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);
  938. return near * far;
  939. }
  940. `;var eOt=y(x(),1),uG=`float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {
  941. float signedDistance = texture(clippingDistance, uv).r;
  942. return (signedDistance - 0.5) * 2.0;
  943. }
  944. void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {
  945. // Position is completely outside of polygons bounds
  946. vec2 rectUv = clippingPosition;
  947. if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {
  948. #ifdef CLIPPING_INVERSE
  949. discard;
  950. #endif
  951. return;
  952. }
  953. vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));
  954. vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));
  955. float dimension = float(extentsLength);
  956. if (extentsLength > 2) {
  957. dimension = ceil(log2(float(extentsLength)));
  958. }
  959. vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;
  960. vec2 uv = textureOffset + rectUv / dimension;
  961. float signedDistance = getSignedDistance(uv, clippingDistance);
  962. #ifdef CLIPPING_INVERSE
  963. if (signedDistance > 0.0) {
  964. discard;
  965. }
  966. #else
  967. if (signedDistance < 0.0) {
  968. discard;
  969. }
  970. #endif
  971. }
  972. `;var nOt=y(x(),1),mG=`/**
  973. * DOC_TBA
  974. *
  975. * @name czm_columbusViewMorph
  976. * @glslFunction
  977. */
  978. vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
  979. {
  980. // Just linear for now.
  981. // We're manually doing the equivalent of a \`mix\` here because, some GPUs
  982. // (NVidia GeForce 3070 Ti and Intel Arc A750, to name two), \`mix\` seems to
  983. // use an alternate formulation that introduces jitter even when \`time\` is
  984. // 0.0 or 1.0. That is, the value of \`p\` won't be exactly \`position2D.xyz\`
  985. // when \`time\` is 0.0 and it won't be exactly \`position3D.xyz\` when \`time\` is
  986. // 1.0. The "textbook" formulation here, while probably a bit slower,
  987. // does not have this problem.
  988. vec3 p = position2D.xyz * (1.0 - time) + position3D.xyz * time;
  989. return vec4(p, 1.0);
  990. }
  991. `;var oOt=y(x(),1),hG=`/**
  992. * Compute the atmosphere color, applying Rayleigh and Mie scattering. This
  993. * builtin uses automatic uniforms so the atmophere settings are synced with the
  994. * state of the Scene, even in other contexts like Model.
  995. *
  996. * @name czm_computeAtmosphereColor
  997. * @glslFunction
  998. *
  999. * @param {vec3} positionWC Position of the fragment in world coords (low precision)
  1000. * @param {vec3} lightDirection Light direction from the sun or other light source.
  1001. * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
  1002. * @param {vec3} mieColor The Mie scattering color computed by a scattering function
  1003. * @param {float} opacity The opacity computed by a scattering function.
  1004. */
  1005. vec4 czm_computeAtmosphereColor(
  1006. vec3 positionWC,
  1007. vec3 lightDirection,
  1008. vec3 rayleighColor,
  1009. vec3 mieColor,
  1010. float opacity
  1011. ) {
  1012. // Setup the primary ray: from the camera position to the vertex position.
  1013. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
  1014. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
  1015. float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
  1016. float cosAngleSq = cosAngle * cosAngle;
  1017. float G = czm_atmosphereMieAnisotropy;
  1018. float GSq = G * G;
  1019. // The Rayleigh phase function.
  1020. float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
  1021. // The Mie phase function.
  1022. 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));
  1023. // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
  1024. vec3 rayleigh = rayleighPhase * rayleighColor;
  1025. vec3 mie = miePhase * mieColor;
  1026. vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
  1027. return vec4(color, opacity);
  1028. }
  1029. /**
  1030. * Compute the atmosphere color, applying Rayleigh and Mie scattering. This
  1031. * builtin uses automatic uniforms so the atmophere settings are synced with the
  1032. * state of the Scene, even in other contexts like Model.
  1033. *
  1034. * @name czm_computeAtmosphereColor
  1035. * @glslFunction
  1036. *
  1037. * @param {czm_ray} primaryRay Ray from the origin to sky fragment to in world coords (low precision)
  1038. * @param {vec3} lightDirection Light direction from the sun or other light source.
  1039. * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
  1040. * @param {vec3} mieColor The Mie scattering color computed by a scattering function
  1041. * @param {float} opacity The opacity computed by a scattering function.
  1042. */
  1043. vec4 czm_computeAtmosphereColor(
  1044. czm_ray primaryRay,
  1045. vec3 lightDirection,
  1046. vec3 rayleighColor,
  1047. vec3 mieColor,
  1048. float opacity
  1049. ) {
  1050. vec3 direction = normalize(primaryRay.direction);
  1051. float cosAngle = dot(direction, lightDirection);
  1052. float cosAngleSq = cosAngle * cosAngle;
  1053. float G = czm_atmosphereMieAnisotropy;
  1054. float GSq = G * G;
  1055. // The Rayleigh phase function.
  1056. float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
  1057. // The Mie phase function.
  1058. 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));
  1059. // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
  1060. vec3 rayleigh = rayleighPhase * rayleighColor;
  1061. vec3 mie = miePhase * mieColor;
  1062. vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
  1063. return vec4(color, opacity);
  1064. }
  1065. `;var sOt=y(x(),1),fG=`/**
  1066. * Compute atmosphere scattering for the ground atmosphere and fog. This method
  1067. * uses automatic uniforms so it is always synced with the scene settings.
  1068. *
  1069. * @name czm_computeGroundAtmosphereScattering
  1070. * @glslfunction
  1071. *
  1072. * @param {vec3} positionWC The position of the fragment in world coordinates.
  1073. * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
  1074. * @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
  1075. * @param {vec3} mieColor The variable the Mie scattering will be written to.
  1076. * @param {float} opacity The variable the transmittance will be written to.
  1077. */
  1078. void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
  1079. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
  1080. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
  1081. czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
  1082. float atmosphereInnerRadius = length(positionWC);
  1083. czm_computeScattering(
  1084. primaryRay,
  1085. length(cameraToPositionWC),
  1086. lightDirection,
  1087. atmosphereInnerRadius,
  1088. rayleighColor,
  1089. mieColor,
  1090. opacity
  1091. );
  1092. }
  1093. `;var cOt=y(x(),1),pG=`/**
  1094. * Returns a position in model coordinates relative to eye taking into
  1095. * account the current scene mode: 3D, 2D, or Columbus view.
  1096. * <p>
  1097. * This uses standard position attributes, <code>position3DHigh</code>,
  1098. * <code>position3DLow</code>, <code>position2DHigh</code>, and <code>position2DLow</code>,
  1099. * and should be used when writing a vertex shader for an {@link Appearance}.
  1100. * </p>
  1101. *
  1102. * @name czm_computePosition
  1103. * @glslFunction
  1104. *
  1105. * @returns {vec4} The position relative to eye.
  1106. *
  1107. * @example
  1108. * vec4 p = czm_computePosition();
  1109. * v_positionEC = (czm_modelViewRelativeToEye * p).xyz;
  1110. * gl_Position = czm_modelViewProjectionRelativeToEye * p;
  1111. *
  1112. * @see czm_translateRelativeToEye
  1113. */
  1114. vec4 czm_computePosition();
  1115. `;var dOt=y(x(),1),AG=`/**
  1116. * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
  1117. * the transmittance value for the ray. This function uses automatic uniforms
  1118. * so the atmosphere settings are always synced with the current scene.
  1119. *
  1120. * @name czm_computeScattering
  1121. * @glslfunction
  1122. *
  1123. * @param {czm_ray} primaryRay The ray from the camera to the position.
  1124. * @param {float} primaryRayLength The length of the primary ray.
  1125. * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
  1126. * @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
  1127. * @param {vec3} mieColor The variable the Mie scattering will be written to.
  1128. * @param {float} opacity The variable the transmittance will be written to.
  1129. */
  1130. void czm_computeScattering(
  1131. czm_ray primaryRay,
  1132. float primaryRayLength,
  1133. vec3 lightDirection,
  1134. float atmosphereInnerRadius,
  1135. out vec3 rayleighColor,
  1136. out vec3 mieColor,
  1137. out float opacity
  1138. ) {
  1139. const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
  1140. const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
  1141. 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.
  1142. // Initialize the default scattering amounts to 0.
  1143. rayleighColor = vec3(0.0);
  1144. mieColor = vec3(0.0);
  1145. opacity = 0.0;
  1146. float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
  1147. vec3 origin = vec3(0.0);
  1148. // Calculate intersection from the camera to the outer ring of the atmosphere.
  1149. czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);
  1150. // Return empty colors if no intersection with the atmosphere geometry.
  1151. if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
  1152. return;
  1153. }
  1154. // To deal with smaller values of PRIMARY_STEPS (e.g. 4)
  1155. // we implement a split strategy: sky or horizon.
  1156. // For performance reasons, instead of a if/else branch
  1157. // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
  1158. float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
  1159. // Value close to 0.0: close to the horizon
  1160. // Value close to 1.0: above in the sky
  1161. float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
  1162. // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
  1163. float start_0 = primaryRayAtmosphereIntersect.start;
  1164. primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
  1165. // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
  1166. primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
  1167. // For the number of ray steps, distinguish inside or outside atmosphere (outer space)
  1168. // (1) from outer space we have to use more ray steps to get a realistic rendering
  1169. // (2) within atmosphere we need fewer steps for faster rendering
  1170. 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
  1171. float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));
  1172. 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.
  1173. 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.
  1174. // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
  1175. float rayPositionLength = primaryRayAtmosphereIntersect.start;
  1176. // (1) Outside the atmosphere: constant rayStepLength
  1177. // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
  1178. float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;
  1179. float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));
  1180. float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
  1181. vec3 rayleighAccumulation = vec3(0.0);
  1182. vec3 mieAccumulation = vec3(0.0);
  1183. vec2 opticalDepth = vec2(0.0);
  1184. vec2 heightScale = vec2(czm_atmosphereRayleighScaleHeight, czm_atmosphereMieScaleHeight);
  1185. // Sample positions on the primary ray.
  1186. for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
  1187. // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
  1188. // loop with non-constant condition, so it has to break early instead
  1189. if (i >= PRIMARY_STEPS) {
  1190. break;
  1191. }
  1192. // Calculate sample position along viewpoint ray.
  1193. vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
  1194. // Calculate height of sample position above ellipsoid.
  1195. float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
  1196. // Calculate and accumulate density of particles at the sample position.
  1197. vec2 sampleDensity = exp(-sampleHeight / heightScale) * rayStepLength;
  1198. opticalDepth += sampleDensity;
  1199. // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
  1200. czm_ray lightRay = czm_ray(samplePosition, lightDirection);
  1201. czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
  1202. float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
  1203. float lightPositionLength = 0.0;
  1204. vec2 lightOpticalDepth = vec2(0.0);
  1205. // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
  1206. for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {
  1207. // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
  1208. // loop with non-constant condition, so it has to break early instead
  1209. if (j >= LIGHT_STEPS) {
  1210. break;
  1211. }
  1212. // Calculate sample position along light ray.
  1213. vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
  1214. // Calculate height of the light sample position above ellipsoid.
  1215. float lightHeight = length(lightPosition) - atmosphereInnerRadius;
  1216. // Calculate density of photons at the light sample position.
  1217. lightOpticalDepth += exp(-lightHeight / heightScale) * lightStepLength;
  1218. // Increment distance on light ray.
  1219. lightPositionLength += lightStepLength;
  1220. }
  1221. // Compute attenuation via the primary ray and the light ray.
  1222. vec3 attenuation = exp(-((czm_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (czm_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));
  1223. // Accumulate the scattering.
  1224. rayleighAccumulation += sampleDensity.x * attenuation;
  1225. mieAccumulation += sampleDensity.y * attenuation;
  1226. // Increment distance on primary ray.
  1227. rayPositionLength += (rayStepLength += rayStepLengthIncrease);
  1228. }
  1229. // Compute the scattering amount.
  1230. rayleighColor = czm_atmosphereRayleighCoefficient * rayleighAccumulation;
  1231. mieColor = czm_atmosphereMieCoefficient * mieAccumulation;
  1232. // Compute the transmittance i.e. how much light is passing through the atmosphere.
  1233. opacity = length(exp(-((czm_atmosphereMieCoefficient * opticalDepth.y) + (czm_atmosphereRayleighCoefficient * opticalDepth.x))));
  1234. }
  1235. `;var mOt=y(x(),1),gG=`/**
  1236. * Applies a 2D texture transformation matrix to texture coordinates.
  1237. * This function applies translation, rotation, and scaling transformations
  1238. * as specified by the KHR_texture_transform glTF extension.
  1239. *
  1240. * @name czm_computeTextureTransform
  1241. * @glslFunction
  1242. *
  1243. * @param {vec2} texCoord The texture coordinates to transform.
  1244. * @param {mat3} textureTransform The 3x3 transformation matrix.
  1245. *
  1246. * @returns {vec2} The transformed texture coordinates.
  1247. *
  1248. * @example
  1249. * // GLSL declaration
  1250. * vec2 czm_computeTextureTransform(vec2 texCoord, mat3 textureTransform);
  1251. *
  1252. * // Apply texture transform to UV coordinates
  1253. * vec2 transformedUV = czm_computeTextureTransform(uv, u_textureTransform);
  1254. */
  1255. vec2 czm_computeTextureTransform(vec2 texCoord, mat3 textureTransform)
  1256. {
  1257. return vec2(textureTransform * vec3(texCoord, 1.0));
  1258. }`;var fOt=y(x(),1),bG=`/**
  1259. * @private
  1260. */
  1261. vec2 cordic(float angle)
  1262. {
  1263. // Scale the vector by the appropriate factor for the 24 iterations to follow.
  1264. vec2 vector = vec2(6.0725293500888267e-1, 0.0);
  1265. // Iteration 1
  1266. float sense = (angle < 0.0) ? -1.0 : 1.0;
  1267. // float factor = sense * 1.0; // 2^-0
  1268. mat2 rotation = mat2(1.0, sense, -sense, 1.0);
  1269. vector = rotation * vector;
  1270. angle -= sense * 7.8539816339744828e-1; // atan(2^-0)
  1271. // Iteration 2
  1272. sense = (angle < 0.0) ? -1.0 : 1.0;
  1273. float factor = sense * 5.0e-1; // 2^-1
  1274. rotation[0][1] = factor;
  1275. rotation[1][0] = -factor;
  1276. vector = rotation * vector;
  1277. angle -= sense * 4.6364760900080609e-1; // atan(2^-1)
  1278. // Iteration 3
  1279. sense = (angle < 0.0) ? -1.0 : 1.0;
  1280. factor = sense * 2.5e-1; // 2^-2
  1281. rotation[0][1] = factor;
  1282. rotation[1][0] = -factor;
  1283. vector = rotation * vector;
  1284. angle -= sense * 2.4497866312686414e-1; // atan(2^-2)
  1285. // Iteration 4
  1286. sense = (angle < 0.0) ? -1.0 : 1.0;
  1287. factor = sense * 1.25e-1; // 2^-3
  1288. rotation[0][1] = factor;
  1289. rotation[1][0] = -factor;
  1290. vector = rotation * vector;
  1291. angle -= sense * 1.2435499454676144e-1; // atan(2^-3)
  1292. // Iteration 5
  1293. sense = (angle < 0.0) ? -1.0 : 1.0;
  1294. factor = sense * 6.25e-2; // 2^-4
  1295. rotation[0][1] = factor;
  1296. rotation[1][0] = -factor;
  1297. vector = rotation * vector;
  1298. angle -= sense * 6.2418809995957350e-2; // atan(2^-4)
  1299. // Iteration 6
  1300. sense = (angle < 0.0) ? -1.0 : 1.0;
  1301. factor = sense * 3.125e-2; // 2^-5
  1302. rotation[0][1] = factor;
  1303. rotation[1][0] = -factor;
  1304. vector = rotation * vector;
  1305. angle -= sense * 3.1239833430268277e-2; // atan(2^-5)
  1306. // Iteration 7
  1307. sense = (angle < 0.0) ? -1.0 : 1.0;
  1308. factor = sense * 1.5625e-2; // 2^-6
  1309. rotation[0][1] = factor;
  1310. rotation[1][0] = -factor;
  1311. vector = rotation * vector;
  1312. angle -= sense * 1.5623728620476831e-2; // atan(2^-6)
  1313. // Iteration 8
  1314. sense = (angle < 0.0) ? -1.0 : 1.0;
  1315. factor = sense * 7.8125e-3; // 2^-7
  1316. rotation[0][1] = factor;
  1317. rotation[1][0] = -factor;
  1318. vector = rotation * vector;
  1319. angle -= sense * 7.8123410601011111e-3; // atan(2^-7)
  1320. // Iteration 9
  1321. sense = (angle < 0.0) ? -1.0 : 1.0;
  1322. factor = sense * 3.90625e-3; // 2^-8
  1323. rotation[0][1] = factor;
  1324. rotation[1][0] = -factor;
  1325. vector = rotation * vector;
  1326. angle -= sense * 3.9062301319669718e-3; // atan(2^-8)
  1327. // Iteration 10
  1328. sense = (angle < 0.0) ? -1.0 : 1.0;
  1329. factor = sense * 1.953125e-3; // 2^-9
  1330. rotation[0][1] = factor;
  1331. rotation[1][0] = -factor;
  1332. vector = rotation * vector;
  1333. angle -= sense * 1.9531225164788188e-3; // atan(2^-9)
  1334. // Iteration 11
  1335. sense = (angle < 0.0) ? -1.0 : 1.0;
  1336. factor = sense * 9.765625e-4; // 2^-10
  1337. rotation[0][1] = factor;
  1338. rotation[1][0] = -factor;
  1339. vector = rotation * vector;
  1340. angle -= sense * 9.7656218955931946e-4; // atan(2^-10)
  1341. // Iteration 12
  1342. sense = (angle < 0.0) ? -1.0 : 1.0;
  1343. factor = sense * 4.8828125e-4; // 2^-11
  1344. rotation[0][1] = factor;
  1345. rotation[1][0] = -factor;
  1346. vector = rotation * vector;
  1347. angle -= sense * 4.8828121119489829e-4; // atan(2^-11)
  1348. // Iteration 13
  1349. sense = (angle < 0.0) ? -1.0 : 1.0;
  1350. factor = sense * 2.44140625e-4; // 2^-12
  1351. rotation[0][1] = factor;
  1352. rotation[1][0] = -factor;
  1353. vector = rotation * vector;
  1354. angle -= sense * 2.4414062014936177e-4; // atan(2^-12)
  1355. // Iteration 14
  1356. sense = (angle < 0.0) ? -1.0 : 1.0;
  1357. factor = sense * 1.220703125e-4; // 2^-13
  1358. rotation[0][1] = factor;
  1359. rotation[1][0] = -factor;
  1360. vector = rotation * vector;
  1361. angle -= sense * 1.2207031189367021e-4; // atan(2^-13)
  1362. // Iteration 15
  1363. sense = (angle < 0.0) ? -1.0 : 1.0;
  1364. factor = sense * 6.103515625e-5; // 2^-14
  1365. rotation[0][1] = factor;
  1366. rotation[1][0] = -factor;
  1367. vector = rotation * vector;
  1368. angle -= sense * 6.1035156174208773e-5; // atan(2^-14)
  1369. // Iteration 16
  1370. sense = (angle < 0.0) ? -1.0 : 1.0;
  1371. factor = sense * 3.0517578125e-5; // 2^-15
  1372. rotation[0][1] = factor;
  1373. rotation[1][0] = -factor;
  1374. vector = rotation * vector;
  1375. angle -= sense * 3.0517578115526096e-5; // atan(2^-15)
  1376. // Iteration 17
  1377. sense = (angle < 0.0) ? -1.0 : 1.0;
  1378. factor = sense * 1.52587890625e-5; // 2^-16
  1379. rotation[0][1] = factor;
  1380. rotation[1][0] = -factor;
  1381. vector = rotation * vector;
  1382. angle -= sense * 1.5258789061315762e-5; // atan(2^-16)
  1383. // Iteration 18
  1384. sense = (angle < 0.0) ? -1.0 : 1.0;
  1385. factor = sense * 7.62939453125e-6; // 2^-17
  1386. rotation[0][1] = factor;
  1387. rotation[1][0] = -factor;
  1388. vector = rotation * vector;
  1389. angle -= sense * 7.6293945311019700e-6; // atan(2^-17)
  1390. // Iteration 19
  1391. sense = (angle < 0.0) ? -1.0 : 1.0;
  1392. factor = sense * 3.814697265625e-6; // 2^-18
  1393. rotation[0][1] = factor;
  1394. rotation[1][0] = -factor;
  1395. vector = rotation * vector;
  1396. angle -= sense * 3.8146972656064961e-6; // atan(2^-18)
  1397. // Iteration 20
  1398. sense = (angle < 0.0) ? -1.0 : 1.0;
  1399. factor = sense * 1.9073486328125e-6; // 2^-19
  1400. rotation[0][1] = factor;
  1401. rotation[1][0] = -factor;
  1402. vector = rotation * vector;
  1403. angle -= sense * 1.9073486328101870e-6; // atan(2^-19)
  1404. // Iteration 21
  1405. sense = (angle < 0.0) ? -1.0 : 1.0;
  1406. factor = sense * 9.5367431640625e-7; // 2^-20
  1407. rotation[0][1] = factor;
  1408. rotation[1][0] = -factor;
  1409. vector = rotation * vector;
  1410. angle -= sense * 9.5367431640596084e-7; // atan(2^-20)
  1411. // Iteration 22
  1412. sense = (angle < 0.0) ? -1.0 : 1.0;
  1413. factor = sense * 4.76837158203125e-7; // 2^-21
  1414. rotation[0][1] = factor;
  1415. rotation[1][0] = -factor;
  1416. vector = rotation * vector;
  1417. angle -= sense * 4.7683715820308884e-7; // atan(2^-21)
  1418. // Iteration 23
  1419. sense = (angle < 0.0) ? -1.0 : 1.0;
  1420. factor = sense * 2.384185791015625e-7; // 2^-22
  1421. rotation[0][1] = factor;
  1422. rotation[1][0] = -factor;
  1423. vector = rotation * vector;
  1424. angle -= sense * 2.3841857910155797e-7; // atan(2^-22)
  1425. // Iteration 24
  1426. sense = (angle < 0.0) ? -1.0 : 1.0;
  1427. factor = sense * 1.1920928955078125e-7; // 2^-23
  1428. rotation[0][1] = factor;
  1429. rotation[1][0] = -factor;
  1430. vector = rotation * vector;
  1431. // angle -= sense * 1.1920928955078068e-7; // atan(2^-23)
  1432. return vector;
  1433. }
  1434. /**
  1435. * Computes the cosine and sine of the provided angle using the CORDIC algorithm.
  1436. *
  1437. * @name czm_cosineAndSine
  1438. * @glslFunction
  1439. *
  1440. * @param {float} angle The angle in radians.
  1441. *
  1442. * @returns {vec2} The resulting cosine of the angle (as the x coordinate) and sine of the angle (as the y coordinate).
  1443. *
  1444. * @example
  1445. * vec2 v = czm_cosineAndSine(czm_piOverSix);
  1446. * float cosine = v.x;
  1447. * float sine = v.y;
  1448. */
  1449. vec2 czm_cosineAndSine(float angle)
  1450. {
  1451. if (angle < -czm_piOverTwo || angle > czm_piOverTwo)
  1452. {
  1453. if (angle < 0.0)
  1454. {
  1455. return -cordic(angle + czm_pi);
  1456. }
  1457. else
  1458. {
  1459. return -cordic(angle - czm_pi);
  1460. }
  1461. }
  1462. else
  1463. {
  1464. return cordic(angle);
  1465. }
  1466. }
  1467. `;var AOt=y(x(),1),yG=`/**
  1468. * Decodes RGB values packed into a single float at 8-bit precision. Encoded
  1469. * representation is equivalent to 0xFFFFFF in JavaScript.
  1470. *
  1471. * @name czm_decodeRGB8
  1472. * @glslFunction
  1473. *
  1474. * @param {float} encoded Float-encoded RGB values.
  1475. * @returns {vec4} Decoded RGB values.
  1476. */
  1477. vec4 czm_decodeRGB8(float encoded) {
  1478. const float SHIFT_RIGHT16 = 1.0 / 65536.0;
  1479. const float SHIFT_RIGHT8 = 1.0 / 256.0;
  1480. const float SHIFT_LEFT16 = 65536.0;
  1481. const float SHIFT_LEFT8 = 256.0;
  1482. vec4 color = vec4(255.0);
  1483. color.r = floor(encoded * SHIFT_RIGHT16);
  1484. color.g = floor((encoded - color.r * SHIFT_LEFT16) * SHIFT_RIGHT8);
  1485. color.b = floor(encoded - color.r * SHIFT_LEFT16 - color.g * SHIFT_LEFT8);
  1486. return color / 255.0;
  1487. }
  1488. `;var bOt=y(x(),1),xG=`/**
  1489. * Decompresses texture coordinates that were packed into a single float.
  1490. *
  1491. * @name czm_decompressTextureCoordinates
  1492. * @glslFunction
  1493. *
  1494. * @param {float} encoded The compressed texture coordinates.
  1495. * @returns {vec2} The decompressed texture coordinates.
  1496. */
  1497. vec2 czm_decompressTextureCoordinates(float encoded)
  1498. {
  1499. float temp = encoded / 4096.0;
  1500. float xZeroTo4095 = floor(temp);
  1501. float stx = xZeroTo4095 / 4095.0;
  1502. float sty = (encoded - xZeroTo4095 * 4096.0) / 4095.0;
  1503. return vec2(stx, sty);
  1504. }
  1505. `;var xOt=y(x(),1),CG=`// emulated noperspective
  1506. #if (__VERSION__ == 300 || defined(GL_EXT_frag_depth)) && !defined(LOG_DEPTH)
  1507. out float v_WindowZ;
  1508. #endif
  1509. /**
  1510. * Emulates GL_DEPTH_CLAMP, which is not available in WebGL 1 or 2.
  1511. * GL_DEPTH_CLAMP clamps geometry that is outside the near and far planes,
  1512. * capping the shadow volume. More information here:
  1513. * https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_depth_clamp.txt.
  1514. *
  1515. * When GL_EXT_frag_depth is available we emulate GL_DEPTH_CLAMP by ensuring
  1516. * no geometry gets clipped by setting the clip space z value to 0.0 and then
  1517. * sending the unaltered screen space z value (using emulated noperspective
  1518. * interpolation) to the frag shader where it is clamped to [0,1] and then
  1519. * written with gl_FragDepth (see czm_writeDepthClamp). This technique is based on:
  1520. * https://stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv.
  1521. *
  1522. * When GL_EXT_frag_depth is not available, which is the case on some mobile
  1523. * devices, we must attempt to fix this only in the vertex shader.
  1524. * The approach is to clamp the z value to the far plane, which closes the
  1525. * shadow volume but also distorts the geometry, so there can still be artifacts
  1526. * on frustum seams.
  1527. *
  1528. * @name czm_depthClamp
  1529. * @glslFunction
  1530. *
  1531. * @param {vec4} coords The vertex in clip coordinates.
  1532. * @returns {vec4} The modified vertex.
  1533. *
  1534. * @example
  1535. * gl_Position = czm_depthClamp(czm_modelViewProjection * vec4(position, 1.0));
  1536. *
  1537. * @see czm_writeDepthClamp
  1538. */
  1539. vec4 czm_depthClamp(vec4 coords)
  1540. {
  1541. #ifndef LOG_DEPTH
  1542. #if __VERSION__ == 300 || defined(GL_EXT_frag_depth)
  1543. v_WindowZ = (0.5 * (coords.z / coords.w) + 0.5) * coords.w;
  1544. coords.z = 0.0;
  1545. #else
  1546. coords.z = min(coords.z, coords.w);
  1547. #endif
  1548. #endif
  1549. return coords;
  1550. }
  1551. `;var TOt=y(x(),1),TG=`/**
  1552. * Computes a 3x3 rotation matrix that transforms vectors from an ellipsoid's east-north-up coordinate system
  1553. * to eye coordinates. In east-north-up coordinates, x points east, y points north, and z points along the
  1554. * surface normal. East-north-up can be used as an ellipsoid's tangent space for operations such as bump mapping.
  1555. * <br /><br />
  1556. * The ellipsoid is assumed to be centered at the model coordinate's origin.
  1557. *
  1558. * @name czm_eastNorthUpToEyeCoordinates
  1559. * @glslFunction
  1560. *
  1561. * @param {vec3} positionMC The position on the ellipsoid in model coordinates.
  1562. * @param {vec3} normalEC The normalized ellipsoid surface normal, at <code>positionMC</code>, in eye coordinates.
  1563. *
  1564. * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
  1565. *
  1566. * @example
  1567. * // Transform a vector defined in the east-north-up coordinate
  1568. * // system, (0, 0, 1) which is the surface normal, to eye
  1569. * // coordinates.
  1570. * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
  1571. * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
  1572. */
  1573. mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
  1574. {
  1575. vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
  1576. vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordinates
  1577. vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
  1578. return mat3(
  1579. tangentEC.x, tangentEC.y, tangentEC.z,
  1580. bitangentEC.x, bitangentEC.y, bitangentEC.z,
  1581. normalEC.x, normalEC.y, normalEC.z);
  1582. }
  1583. `;var SOt=y(x(),1),EG=`/**
  1584. * DOC_TBA
  1585. *
  1586. * @name czm_ellipsoidContainsPoint
  1587. * @glslFunction
  1588. *
  1589. */
  1590. bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)
  1591. {
  1592. vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;
  1593. return (dot(scaled, scaled) <= 1.0);
  1594. }
  1595. `;var IOt=y(x(),1),SG=`/**
  1596. * Approximate uv coordinates based on the ellipsoid normal.
  1597. *
  1598. * @name czm_ellipsoidTextureCoordinates
  1599. * @glslFunction
  1600. */
  1601. vec2 czm_ellipsoidTextureCoordinates(vec3 normal)
  1602. {
  1603. return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
  1604. }
  1605. `;var ROt=y(x(),1),_G=`/**
  1606. * Compares <code>left</code> and <code>right</code> componentwise. Returns <code>true</code>
  1607. * if they are within <code>epsilon</code> and <code>false</code> otherwise. The inputs
  1608. * <code>left</code> and <code>right</code> can be <code>float</code>s, <code>vec2</code>s,
  1609. * <code>vec3</code>s, or <code>vec4</code>s.
  1610. *
  1611. * @name czm_equalsEpsilon
  1612. * @glslFunction
  1613. *
  1614. * @param {} left The first vector.
  1615. * @param {} right The second vector.
  1616. * @param {float} epsilon The epsilon to use for equality testing.
  1617. * @returns {bool} <code>true</code> if the components are within <code>epsilon</code> and <code>false</code> otherwise.
  1618. *
  1619. * @example
  1620. * // GLSL declarations
  1621. * bool czm_equalsEpsilon(float left, float right, float epsilon);
  1622. * bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
  1623. * bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
  1624. * bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
  1625. */
  1626. bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
  1627. return all(lessThanEqual(abs(left - right), vec4(epsilon)));
  1628. }
  1629. bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
  1630. return all(lessThanEqual(abs(left - right), vec3(epsilon)));
  1631. }
  1632. bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
  1633. return all(lessThanEqual(abs(left - right), vec2(epsilon)));
  1634. }
  1635. bool czm_equalsEpsilon(float left, float right, float epsilon) {
  1636. return (abs(left - right) <= epsilon);
  1637. }
  1638. `;var GOt=y(x(),1),IG=`/**
  1639. * DOC_TBA
  1640. *
  1641. * @name czm_eyeOffset
  1642. * @glslFunction
  1643. *
  1644. * @param {vec4} positionEC DOC_TBA.
  1645. * @param {vec3} eyeOffset DOC_TBA.
  1646. *
  1647. * @returns {vec4} DOC_TBA.
  1648. */
  1649. vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)
  1650. {
  1651. // This equation is approximate in x and y.
  1652. vec4 p = positionEC;
  1653. vec4 zEyeOffset = normalize(p) * eyeOffset.z;
  1654. p.xy += eyeOffset.xy + zEyeOffset.xy;
  1655. p.z += zEyeOffset.z;
  1656. return p;
  1657. }
  1658. `;var WOt=y(x(),1),ZG=`/**
  1659. * Transforms a position from eye to window coordinates. The transformation
  1660. * from eye to clip coordinates is done using {@link czm_projection}.
  1661. * The transform from normalized device coordinates to window coordinates is
  1662. * done using {@link czm_viewportTransformation}, which assumes a depth range
  1663. * of <code>near = 0</code> and <code>far = 1</code>.
  1664. * <br /><br />
  1665. * This transform is useful when there is a need to manipulate window coordinates
  1666. * in a vertex shader as done by {@link BillboardCollection}.
  1667. *
  1668. * @name czm_eyeToWindowCoordinates
  1669. * @glslFunction
  1670. *
  1671. * @param {vec4} position The position in eye coordinates to transform.
  1672. *
  1673. * @returns {vec4} The transformed position in window coordinates.
  1674. *
  1675. * @see czm_modelToWindowCoordinates
  1676. * @see czm_projection
  1677. * @see czm_viewportTransformation
  1678. * @see BillboardCollection
  1679. *
  1680. * @example
  1681. * vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
  1682. */
  1683. vec4 czm_eyeToWindowCoordinates(vec4 positionEC)
  1684. {
  1685. vec4 q = czm_projection * positionEC; // clip coordinates
  1686. q.xyz /= q.w; // normalized device coordinates
  1687. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
  1688. return q;
  1689. }
  1690. `;var BOt=y(x(),1),RG=`/**
  1691. * Approxiamtes atan over the range [0, 1]. Safe to flip output for negative input.
  1692. *
  1693. * Based on Michal Drobot's approximation from ShaderFastLibs, which in turn is based on
  1694. * "Efficient approximations for the arctangent function," Rajan, S. Sichun Wang Inkol, R. Joyal, A., May 2006.
  1695. * Adapted from ShaderFastLibs under MIT License.
  1696. *
  1697. * Chosen for the following characteristics over range [0, 1]:
  1698. * - basically no error at 0 and 1, important for getting around range limit (naive atan2 via atan requires infinite range atan)
  1699. * - no visible artifacts from first-derivative discontinuities, unlike latitude via range-reduced sqrt asin approximations (at equator)
  1700. *
  1701. * The original code is x * (-0.1784 * abs(x) - 0.0663 * x * x + 1.0301);
  1702. * Removed the abs() in here because it isn't needed, the input range is guaranteed as [0, 1] by how we're approximating atan2.
  1703. *
  1704. * @name czm_fastApproximateAtan
  1705. * @glslFunction
  1706. *
  1707. * @param {float} x Value between 0 and 1 inclusive.
  1708. *
  1709. * @returns {float} Approximation of atan(x)
  1710. */
  1711. float czm_fastApproximateAtan(float x) {
  1712. return x * (-0.1784 * x - 0.0663 * x * x + 1.0301);
  1713. }
  1714. /**
  1715. * Approximation of atan2.
  1716. *
  1717. * Range reduction math based on nvidia's cg reference implementation for atan2: http://developer.download.nvidia.com/cg/atan2.html
  1718. * However, we replaced their atan curve with Michael Drobot's (see above).
  1719. *
  1720. * @name czm_fastApproximateAtan
  1721. * @glslFunction
  1722. *
  1723. * @param {float} x Value between -1 and 1 inclusive.
  1724. * @param {float} y Value between -1 and 1 inclusive.
  1725. *
  1726. * @returns {float} Approximation of atan2(x, y)
  1727. */
  1728. float czm_fastApproximateAtan(float x, float y) {
  1729. // atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
  1730. // So range-reduce using abs and by flipping whether x or y is on top.
  1731. float t = abs(x); // t used as swap and atan result.
  1732. float opposite = abs(y);
  1733. float adjacent = max(t, opposite);
  1734. opposite = min(t, opposite);
  1735. t = czm_fastApproximateAtan(opposite / adjacent);
  1736. // Undo range reduction
  1737. t = czm_branchFreeTernary(abs(y) > abs(x), czm_piOverTwo - t, t);
  1738. t = czm_branchFreeTernary(x < 0.0, czm_pi - t, t);
  1739. t = czm_branchFreeTernary(y < 0.0, -t, t);
  1740. return t;
  1741. }
  1742. `;var NOt=y(x(),1),VG=`/**
  1743. * Gets the color with fog at a distance from the camera.
  1744. *
  1745. * @name czm_fog
  1746. * @glslFunction
  1747. *
  1748. * @param {float} distanceToCamera The distance to the camera in meters.
  1749. * @param {vec3} color The original color.
  1750. * @param {vec3} fogColor The color of the fog.
  1751. *
  1752. * @returns {vec3} The color adjusted for fog at the distance from the camera.
  1753. */
  1754. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)
  1755. {
  1756. float scalar = distanceToCamera * czm_fogDensity;
  1757. float fog = 1.0 - exp(-(scalar * scalar));
  1758. return mix(color, fogColor, fog);
  1759. }
  1760. /**
  1761. * Gets the color with fog at a distance from the camera.
  1762. *
  1763. * @name czm_fog
  1764. * @glslFunction
  1765. *
  1766. * @param {float} distanceToCamera The distance to the camera in meters.
  1767. * @param {vec3} color The original color.
  1768. * @param {vec3} fogColor The color of the fog.
  1769. * @param {float} fogModifierConstant A constant to modify the appearance of fog.
  1770. *
  1771. * @returns {vec3} The color adjusted for fog at the distance from the camera.
  1772. */
  1773. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)
  1774. {
  1775. float scalar = distanceToCamera * czm_fogDensity;
  1776. float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));
  1777. return mix(color, fogColor, fog);
  1778. }
  1779. `;var XOt=y(x(),1),GG=`/**
  1780. * Converts a color from RGB space to linear space.
  1781. *
  1782. * @name czm_gammaCorrect
  1783. * @glslFunction
  1784. *
  1785. * @param {vec3} color The color in RGB space.
  1786. * @returns {vec3} The color in linear space.
  1787. */
  1788. vec3 czm_gammaCorrect(vec3 color) {
  1789. #ifdef HDR
  1790. color = pow(color, vec3(czm_gamma));
  1791. #endif
  1792. return color;
  1793. }
  1794. vec4 czm_gammaCorrect(vec4 color) {
  1795. #ifdef HDR
  1796. color.rgb = pow(color.rgb, vec3(czm_gamma));
  1797. #endif
  1798. return color;
  1799. }
  1800. `;var MOt=y(x(),1),LG=`/**
  1801. * DOC_TBA
  1802. *
  1803. * @name czm_geodeticSurfaceNormal
  1804. * @glslFunction
  1805. *
  1806. * @param {vec3} positionOnEllipsoid DOC_TBA
  1807. * @param {vec3} ellipsoidCenter DOC_TBA
  1808. * @param {vec3} oneOverEllipsoidRadiiSquared DOC_TBA
  1809. *
  1810. * @returns {vec3} DOC_TBA.
  1811. */
  1812. vec3 czm_geodeticSurfaceNormal(vec3 positionOnEllipsoid, vec3 ellipsoidCenter, vec3 oneOverEllipsoidRadiiSquared)
  1813. {
  1814. return normalize((positionOnEllipsoid - ellipsoidCenter) * oneOverEllipsoidRadiiSquared);
  1815. }
  1816. `;var UOt=y(x(),1),WG=`/**
  1817. * An czm_material with default values. Every material's czm_getMaterial
  1818. * should use this default material as a base for the material it returns.
  1819. * The default normal value is given by materialInput.normalEC.
  1820. *
  1821. * @name czm_getDefaultMaterial
  1822. * @glslFunction
  1823. *
  1824. * @param {czm_materialInput} input The input used to construct the default material.
  1825. *
  1826. * @returns {czm_material} The default material.
  1827. *
  1828. * @see czm_materialInput
  1829. * @see czm_material
  1830. * @see czm_getMaterial
  1831. */
  1832. czm_material czm_getDefaultMaterial(czm_materialInput materialInput)
  1833. {
  1834. czm_material material;
  1835. material.diffuse = vec3(0.0);
  1836. material.specular = 0.0;
  1837. material.shininess = 1.0;
  1838. material.normal = materialInput.normalEC;
  1839. material.emission = vec3(0.0);
  1840. material.alpha = 1.0;
  1841. return material;
  1842. }
  1843. `;var kOt=y(x(),1),FG=`/**
  1844. * Select which direction vector to use for dynamic atmosphere lighting based on an enum value
  1845. *
  1846. * @name czm_getDynamicAtmosphereLightDirection
  1847. * @glslfunction
  1848. * @see DynamicAtmosphereLightingType.js
  1849. *
  1850. * @param {vec3} positionWC the position of the vertex/fragment in world coordinates. This is normalized and returned when dynamic lighting is turned off.
  1851. * @param {float} lightEnum The enum value for selecting between light sources.
  1852. * @return {vec3} The normalized light direction vector. Depending on the enum value, it is either positionWC, czm_lightDirectionWC or czm_sunDirectionWC
  1853. */
  1854. vec3 czm_getDynamicAtmosphereLightDirection(vec3 positionWC, float lightEnum) {
  1855. const float NONE = 0.0;
  1856. const float SCENE_LIGHT = 1.0;
  1857. const float SUNLIGHT = 2.0;
  1858. vec3 lightDirection =
  1859. positionWC * float(lightEnum == NONE) +
  1860. czm_lightDirectionWC * float(lightEnum == SCENE_LIGHT) +
  1861. czm_sunDirectionWC * float(lightEnum == SUNLIGHT);
  1862. return normalize(lightDirection);
  1863. }
  1864. `;var OOt=y(x(),1),BG=`/**
  1865. * Calculates the intensity of diffusely reflected light.
  1866. *
  1867. * @name czm_getLambertDiffuse
  1868. * @glslFunction
  1869. *
  1870. * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
  1871. * @param {vec3} normalEC The surface normal in eye coordinates.
  1872. *
  1873. * @returns {float} The intensity of the diffuse reflection.
  1874. *
  1875. * @see czm_phong
  1876. *
  1877. * @example
  1878. * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
  1879. * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
  1880. * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
  1881. */
  1882. float czm_getLambertDiffuse(vec3 lightDirectionEC, vec3 normalEC)
  1883. {
  1884. return max(dot(lightDirectionEC, normalEC), 0.0);
  1885. }
  1886. `;var HOt=y(x(),1),wG=`/**
  1887. * Calculates the specular intensity of reflected light.
  1888. *
  1889. * @name czm_getSpecular
  1890. * @glslFunction
  1891. *
  1892. * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
  1893. * @param {vec3} toEyeEC Unit vector pointing to the eye position in eye coordinates.
  1894. * @param {vec3} normalEC The surface normal in eye coordinates.
  1895. * @param {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
  1896. *
  1897. * @returns {float} The intensity of the specular highlight.
  1898. *
  1899. * @see czm_phong
  1900. *
  1901. * @example
  1902. * float diffuseIntensity = czm_getLambertDiffuse(lightDirectionEC, normalEC);
  1903. * float specularIntensity = czm_getSpecular(lightDirectionEC, toEyeEC, normalEC, 200);
  1904. * vec3 color = (diffuseColor * diffuseIntensity) + (specularColor * specularIntensity);
  1905. */
  1906. float czm_getSpecular(vec3 lightDirectionEC, vec3 toEyeEC, vec3 normalEC, float shininess)
  1907. {
  1908. vec3 toReflectedLight = reflect(-lightDirectionEC, normalEC);
  1909. float specular = max(dot(toReflectedLight, toEyeEC), 0.0);
  1910. // pow has undefined behavior if both parameters <= 0.
  1911. // Prevent this by making sure shininess is at least czm_epsilon2.
  1912. return pow(specular, max(shininess, czm_epsilon2));
  1913. }
  1914. `;var KOt=y(x(),1),NG=`/**
  1915. * @private
  1916. */
  1917. vec4 czm_getWaterNoise(sampler2D normalMap, vec2 uv, float time, float angleInRadians)
  1918. {
  1919. float cosAngle = cos(angleInRadians);
  1920. float sinAngle = sin(angleInRadians);
  1921. // time dependent sampling directions
  1922. vec2 s0 = vec2(1.0/17.0, 0.0);
  1923. vec2 s1 = vec2(-1.0/29.0, 0.0);
  1924. vec2 s2 = vec2(1.0/101.0, 1.0/59.0);
  1925. vec2 s3 = vec2(-1.0/109.0, -1.0/57.0);
  1926. // rotate sampling direction by specified angle
  1927. s0 = vec2((cosAngle * s0.x) - (sinAngle * s0.y), (sinAngle * s0.x) + (cosAngle * s0.y));
  1928. s1 = vec2((cosAngle * s1.x) - (sinAngle * s1.y), (sinAngle * s1.x) + (cosAngle * s1.y));
  1929. s2 = vec2((cosAngle * s2.x) - (sinAngle * s2.y), (sinAngle * s2.x) + (cosAngle * s2.y));
  1930. s3 = vec2((cosAngle * s3.x) - (sinAngle * s3.y), (sinAngle * s3.x) + (cosAngle * s3.y));
  1931. vec2 uv0 = (uv/103.0) + (time * s0);
  1932. vec2 uv1 = uv/107.0 + (time * s1) + vec2(0.23);
  1933. vec2 uv2 = uv/vec2(897.0, 983.0) + (time * s2) + vec2(0.51);
  1934. vec2 uv3 = uv/vec2(991.0, 877.0) + (time * s3) + vec2(0.71);
  1935. uv0 = fract(uv0);
  1936. uv1 = fract(uv1);
  1937. uv2 = fract(uv2);
  1938. uv3 = fract(uv3);
  1939. vec4 noise = (texture(normalMap, uv0)) +
  1940. (texture(normalMap, uv1)) +
  1941. (texture(normalMap, uv2)) +
  1942. (texture(normalMap, uv3));
  1943. // average and scale to between -1 and 1
  1944. return ((noise / 4.0) - 0.5) * 2.0;
  1945. }
  1946. `;var qOt=y(x(),1),PG=`/**
  1947. * Converts an HSB color (hue, saturation, brightness) to RGB
  1948. * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
  1949. *
  1950. * @name czm_HSBToRGB
  1951. * @glslFunction
  1952. *
  1953. * @param {vec3} hsb The color in HSB.
  1954. *
  1955. * @returns {vec3} The color in RGB.
  1956. *
  1957. * @example
  1958. * vec3 hsb = czm_RGBToHSB(rgb);
  1959. * hsb.z *= 0.1;
  1960. * rgb = czm_HSBToRGB(hsb);
  1961. */
  1962. const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
  1963. vec3 czm_HSBToRGB(vec3 hsb)
  1964. {
  1965. vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www);
  1966. return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y);
  1967. }
  1968. `;var ezt=y(x(),1),XG=`/**
  1969. * Converts an HSL color (hue, saturation, lightness) to RGB
  1970. * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
  1971. *
  1972. * @name czm_HSLToRGB
  1973. * @glslFunction
  1974. *
  1975. * @param {vec3} rgb The color in HSL.
  1976. *
  1977. * @returns {vec3} The color in RGB.
  1978. *
  1979. * @example
  1980. * vec3 hsl = czm_RGBToHSL(rgb);
  1981. * hsl.z *= 0.1;
  1982. * rgb = czm_HSLToRGB(hsl);
  1983. */
  1984. vec3 hueToRGB(float hue)
  1985. {
  1986. float r = abs(hue * 6.0 - 3.0) - 1.0;
  1987. float g = 2.0 - abs(hue * 6.0 - 2.0);
  1988. float b = 2.0 - abs(hue * 6.0 - 4.0);
  1989. return clamp(vec3(r, g, b), 0.0, 1.0);
  1990. }
  1991. vec3 czm_HSLToRGB(vec3 hsl)
  1992. {
  1993. vec3 rgb = hueToRGB(hsl.x);
  1994. float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y;
  1995. return (rgb - 0.5) * c + hsl.z;
  1996. }
  1997. `;var nzt=y(x(),1),YG=`/**
  1998. * Adjusts the hue of a color.
  1999. *
  2000. * @name czm_hue
  2001. * @glslFunction
  2002. *
  2003. * @param {vec3} rgb The color.
  2004. * @param {float} adjustment The amount to adjust the hue of the color in radians.
  2005. *
  2006. * @returns {float} The color with the hue adjusted.
  2007. *
  2008. * @example
  2009. * vec3 adjustHue = czm_hue(color, czm_pi); // The same as czm_hue(color, -czm_pi)
  2010. */
  2011. vec3 czm_hue(vec3 rgb, float adjustment)
  2012. {
  2013. const mat3 toYIQ = mat3(0.299, 0.587, 0.114,
  2014. 0.595716, -0.274453, -0.321263,
  2015. 0.211456, -0.522591, 0.311135);
  2016. const mat3 toRGB = mat3(1.0, 0.9563, 0.6210,
  2017. 1.0, -0.2721, -0.6474,
  2018. 1.0, -1.107, 1.7046);
  2019. vec3 yiq = toYIQ * rgb;
  2020. float hue = atan(yiq.z, yiq.y) + adjustment;
  2021. float chroma = sqrt(yiq.z * yiq.z + yiq.y * yiq.y);
  2022. vec3 color = vec3(yiq.x, chroma * cos(hue), chroma * sin(hue));
  2023. return toRGB * color;
  2024. }
  2025. `;var ozt=y(x(),1),MG=`/**
  2026. * Converts a color in linear space to RGB space.
  2027. *
  2028. * @name czm_inverseGamma
  2029. * @glslFunction
  2030. *
  2031. * @param {vec3} color The color in linear space.
  2032. * @returns {vec3} The color in RGB space.
  2033. */
  2034. vec3 czm_inverseGamma(vec3 color) {
  2035. return pow(color, vec3(1.0 / czm_gamma));
  2036. }
  2037. `;var szt=y(x(),1),vG=`/**
  2038. * Determines if a time interval is empty.
  2039. *
  2040. * @name czm_isEmpty
  2041. * @glslFunction
  2042. *
  2043. * @param {czm_raySegment} interval The interval to test.
  2044. *
  2045. * @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
  2046. *
  2047. * @example
  2048. * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
  2049. * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
  2050. * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
  2051. */
  2052. bool czm_isEmpty(czm_raySegment interval)
  2053. {
  2054. return (interval.stop < 0.0);
  2055. }
  2056. `;var czt=y(x(),1),UG=`/**
  2057. * Determines if a time interval is empty.
  2058. *
  2059. * @name czm_isFull
  2060. * @glslFunction
  2061. *
  2062. * @param {czm_raySegment} interval The interval to test.
  2063. *
  2064. * @returns {bool} <code>true</code> if the time interval is empty; otherwise, <code>false</code>.
  2065. *
  2066. * @example
  2067. * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
  2068. * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
  2069. * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
  2070. */
  2071. bool czm_isFull(czm_raySegment interval)
  2072. {
  2073. return (interval.start == 0.0 && interval.stop == czm_infinity);
  2074. }
  2075. `;var dzt=y(x(),1),DG=`/**
  2076. * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.
  2077. *
  2078. * @name czm_latitudeToWebMercatorFraction
  2079. * @glslFunction
  2080. *
  2081. * @param {float} latitude The geodetic latitude, in radians.
  2082. * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.
  2083. * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.
  2084. *
  2085. * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern
  2086. * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return
  2087. * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.
  2088. */
  2089. float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)
  2090. {
  2091. float sinLatitude = sin(latitude);
  2092. float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));
  2093. return (mercatorY - southMercatorY) * oneOverMercatorHeight;
  2094. }
  2095. `;var mzt=y(x(),1),kG=`/**
  2096. * Converts a linear RGB color to an sRGB color.
  2097. *
  2098. * @param {vec3|vec4} linearIn The color in linear color space.
  2099. * @returns {vec3|vec4} The color in sRGB color space. The vector type matches the input.
  2100. */
  2101. vec3 czm_linearToSrgb(vec3 linearIn)
  2102. {
  2103. return pow(linearIn, vec3(1.0/2.2));
  2104. }
  2105. vec4 czm_linearToSrgb(vec4 linearIn)
  2106. {
  2107. vec3 srgbOut = pow(linearIn.rgb, vec3(1.0/2.2));
  2108. return vec4(srgbOut, linearIn.a);
  2109. }
  2110. `;var fzt=y(x(),1),QG=`/**
  2111. * Computes distance from an point in 2D to a line in 2D.
  2112. *
  2113. * @name czm_lineDistance
  2114. * @glslFunction
  2115. *
  2116. * param {vec2} point1 A point along the line.
  2117. * param {vec2} point2 A point along the line.
  2118. * param {vec2} point A point that may or may not be on the line.
  2119. * returns {float} The distance from the point to the line.
  2120. */
  2121. float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {
  2122. 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);
  2123. }
  2124. `;var Azt=y(x(),1),OG=`/**
  2125. * Computes the luminance of a color.
  2126. *
  2127. * @name czm_luminance
  2128. * @glslFunction
  2129. *
  2130. * @param {vec3} rgb The color.
  2131. *
  2132. * @returns {float} The luminance.
  2133. *
  2134. * @example
  2135. * float light = czm_luminance(vec3(0.0)); // 0.0
  2136. * float dark = czm_luminance(vec3(1.0)); // ~1.0
  2137. */
  2138. float czm_luminance(vec3 rgb)
  2139. {
  2140. // Algorithm from Chapter 10 of Graphics Shaders.
  2141. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  2142. return dot(rgb, W);
  2143. }
  2144. `;var bzt=y(x(),1),zG=`/**
  2145. * Find the maximum component of a vector.
  2146. *
  2147. * @name czm_maximumComponent
  2148. * @glslFunction
  2149. *
  2150. * @param {vec2|vec3|vec4} v The input vector.
  2151. * @returns {float} The value of the largest component.
  2152. */
  2153. float czm_maximumComponent(vec2 v)
  2154. {
  2155. return max(v.x, v.y);
  2156. }
  2157. float czm_maximumComponent(vec3 v)
  2158. {
  2159. return max(max(v.x, v.y), v.z);
  2160. }
  2161. float czm_maximumComponent(vec4 v)
  2162. {
  2163. return max(max(max(v.x, v.y), v.z), v.w);
  2164. }
  2165. `;var xzt=y(x(),1),HG=`/**
  2166. * Computes the size of a pixel in meters at a distance from the eye.
  2167. * <p>
  2168. * Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel.
  2169. * </p>
  2170. * @name czm_metersPerPixel
  2171. * @glslFunction
  2172. *
  2173. * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.
  2174. * @param {float} pixelRatio The scaling factor from pixel space to coordinate space
  2175. *
  2176. * @returns {float} The meters per pixel at positionEC.
  2177. */
  2178. float czm_metersPerPixel(vec4 positionEC, float pixelRatio)
  2179. {
  2180. float width = czm_viewport.z;
  2181. float height = czm_viewport.w;
  2182. float pixelWidth;
  2183. float pixelHeight;
  2184. float top = czm_frustumPlanes.x;
  2185. float bottom = czm_frustumPlanes.y;
  2186. float left = czm_frustumPlanes.z;
  2187. float right = czm_frustumPlanes.w;
  2188. if (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0)
  2189. {
  2190. float frustumWidth = right - left;
  2191. float frustumHeight = top - bottom;
  2192. pixelWidth = frustumWidth / width;
  2193. pixelHeight = frustumHeight / height;
  2194. }
  2195. else
  2196. {
  2197. float distanceToPixel = -positionEC.z;
  2198. float inverseNear = 1.0 / czm_currentFrustum.x;
  2199. float tanTheta = top * inverseNear;
  2200. pixelHeight = 2.0 * distanceToPixel * tanTheta / height;
  2201. tanTheta = right * inverseNear;
  2202. pixelWidth = 2.0 * distanceToPixel * tanTheta / width;
  2203. }
  2204. return max(pixelWidth, pixelHeight) * pixelRatio;
  2205. }
  2206. /**
  2207. * Computes the size of a pixel in meters at a distance from the eye.
  2208. * <p>
  2209. * Use this version when scaling by pixel ratio.
  2210. * </p>
  2211. * @name czm_metersPerPixel
  2212. * @glslFunction
  2213. *
  2214. * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates.
  2215. *
  2216. * @returns {float} The meters per pixel at positionEC.
  2217. */
  2218. float czm_metersPerPixel(vec4 positionEC)
  2219. {
  2220. return czm_metersPerPixel(positionEC, czm_pixelRatio);
  2221. }
  2222. `;var Tzt=y(x(),1),JG=`/**
  2223. * Transforms a position from model to window coordinates. The transformation
  2224. * from model to clip coordinates is done using {@link czm_modelViewProjection}.
  2225. * The transform from normalized device coordinates to window coordinates is
  2226. * done using {@link czm_viewportTransformation}, which assumes a depth range
  2227. * of <code>near = 0</code> and <code>far = 1</code>.
  2228. * <br /><br />
  2229. * This transform is useful when there is a need to manipulate window coordinates
  2230. * in a vertex shader as done by {@link BillboardCollection}.
  2231. * <br /><br />
  2232. * This function should not be confused with {@link czm_viewportOrthographic},
  2233. * which is an orthographic projection matrix that transforms from window
  2234. * coordinates to clip coordinates.
  2235. *
  2236. * @name czm_modelToWindowCoordinates
  2237. * @glslFunction
  2238. *
  2239. * @param {vec4} position The position in model coordinates to transform.
  2240. *
  2241. * @returns {vec4} The transformed position in window coordinates.
  2242. *
  2243. * @see czm_eyeToWindowCoordinates
  2244. * @see czm_modelViewProjection
  2245. * @see czm_viewportTransformation
  2246. * @see czm_viewportOrthographic
  2247. * @see BillboardCollection
  2248. *
  2249. * @example
  2250. * vec4 positionWC = czm_modelToWindowCoordinates(positionMC);
  2251. */
  2252. vec4 czm_modelToWindowCoordinates(vec4 position)
  2253. {
  2254. vec4 positionEC = czm_modelView * position;
  2255. vec4 q = czm_projection * positionEC;
  2256. q.xyz /= q.w; // normalized device coordinates
  2257. q.xyz = (czm_viewportTransformation * vec4(q.xyz, 1.0)).xyz; // window coordinates
  2258. return q;
  2259. }
  2260. `;var Szt=y(x(),1),KG=`/**
  2261. * DOC_TBA
  2262. *
  2263. * @name czm_multiplyWithColorBalance
  2264. * @glslFunction
  2265. */
  2266. vec3 czm_multiplyWithColorBalance(vec3 left, vec3 right)
  2267. {
  2268. // Algorithm from Chapter 10 of Graphics Shaders.
  2269. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  2270. vec3 target = left * right;
  2271. float leftLuminance = dot(left, W);
  2272. float rightLuminance = dot(right, W);
  2273. float targetLuminance = dot(target, W);
  2274. return ((leftLuminance + rightLuminance) / (2.0 * targetLuminance)) * target;
  2275. }
  2276. `;var Izt=y(x(),1),jG=`/**
  2277. * Computes a value that scales with distance. The scaling is clamped at the near and
  2278. * far distances, and does not extrapolate. This function works with the
  2279. * {@link NearFarScalar} JavaScript class.
  2280. *
  2281. * @name czm_nearFarScalar
  2282. * @glslFunction
  2283. *
  2284. * @param {vec4} nearFarScalar A vector with 4 components: Near distance (x), Near value (y), Far distance (z), Far value (w).
  2285. * @param {float} cameraDistSq The square of the current distance from the camera.
  2286. *
  2287. * @returns {float} The value at this distance.
  2288. */
  2289. float czm_nearFarScalar(vec4 nearFarScalar, float cameraDistSq)
  2290. {
  2291. float valueAtMin = nearFarScalar.y;
  2292. float valueAtMax = nearFarScalar.w;
  2293. float nearDistanceSq = nearFarScalar.x * nearFarScalar.x;
  2294. float farDistanceSq = nearFarScalar.z * nearFarScalar.z;
  2295. float t = (cameraDistSq - nearDistanceSq) / (farDistanceSq - nearDistanceSq);
  2296. t = pow(clamp(t, 0.0, 1.0), 0.2);
  2297. return mix(valueAtMin, valueAtMax, t);
  2298. }
  2299. `;var Rzt=y(x(),1),qG=` /**
  2300. * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
  2301. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2302. * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
  2303. *
  2304. * @name czm_octDecode
  2305. * @param {vec2} encoded The oct-encoded, unit-length vector
  2306. * @param {float} range The maximum value of the SNORM range. The encoded vector is stored in log2(rangeMax+1) bits.
  2307. * @returns {vec3} The decoded and normalized vector
  2308. */
  2309. vec3 czm_octDecode(vec2 encoded, float range)
  2310. {
  2311. if (encoded.x == 0.0 && encoded.y == 0.0) {
  2312. return vec3(0.0, 0.0, 0.0);
  2313. }
  2314. encoded = encoded / range * 2.0 - 1.0;
  2315. vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));
  2316. if (v.z < 0.0)
  2317. {
  2318. v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);
  2319. }
  2320. return normalize(v);
  2321. }
  2322. /**
  2323. * Decodes a unit-length vector in 'oct' encoding to a normalized 3-component Cartesian vector.
  2324. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2325. * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
  2326. *
  2327. * @name czm_octDecode
  2328. * @param {vec2} encoded The oct-encoded, unit-length vector
  2329. * @returns {vec3} The decoded and normalized vector
  2330. */
  2331. vec3 czm_octDecode(vec2 encoded)
  2332. {
  2333. return czm_octDecode(encoded, 255.0);
  2334. }
  2335. /**
  2336. * Decodes a unit-length vector in 'oct' encoding packed into a floating-point number to a normalized 3-component Cartesian vector.
  2337. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2338. * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
  2339. *
  2340. * @name czm_octDecode
  2341. * @param {float} encoded The oct-encoded, unit-length vector
  2342. * @returns {vec3} The decoded and normalized vector
  2343. */
  2344. vec3 czm_octDecode(float encoded)
  2345. {
  2346. float temp = encoded / 256.0;
  2347. float x = floor(temp);
  2348. float y = (temp - x) * 256.0;
  2349. return czm_octDecode(vec2(x, y));
  2350. }
  2351. /**
  2352. * Decodes three unit-length vectors in 'oct' encoding packed into two floating-point numbers to normalized 3-component Cartesian vectors.
  2353. * The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors",
  2354. * Cigolle et al 2014: http://jcgt.org/published/0003/02/01/
  2355. *
  2356. * @name czm_octDecode
  2357. * @param {vec2} encoded The packed oct-encoded, unit-length vectors.
  2358. * @param {vec3} vector1 One decoded and normalized vector.
  2359. * @param {vec3} vector2 One decoded and normalized vector.
  2360. * @param {vec3} vector3 One decoded and normalized vector.
  2361. */
  2362. void czm_octDecode(vec2 encoded, out vec3 vector1, out vec3 vector2, out vec3 vector3)
  2363. {
  2364. float temp = encoded.x / 65536.0;
  2365. float x = floor(temp);
  2366. float encodedFloat1 = (temp - x) * 65536.0;
  2367. temp = encoded.y / 65536.0;
  2368. float y = floor(temp);
  2369. float encodedFloat2 = (temp - y) * 65536.0;
  2370. vector1 = czm_octDecode(encodedFloat1);
  2371. vector2 = czm_octDecode(encodedFloat2);
  2372. vector3 = czm_octDecode(vec2(x, y));
  2373. }
  2374. `;var Gzt=y(x(),1),$G=`/**
  2375. * Packs a depth value into a vec4 that can be represented by unsigned bytes.
  2376. *
  2377. * @name czm_packDepth
  2378. * @glslFunction
  2379. *
  2380. * @param {float} depth The floating-point depth.
  2381. * @returns {vec4} The packed depth.
  2382. */
  2383. vec4 czm_packDepth(float depth)
  2384. {
  2385. // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
  2386. // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
  2387. vec4 enc = vec4(1.0, 255.0, 65025.0, 16581375.0) * depth;
  2388. enc = fract(enc);
  2389. enc -= enc.yzww * vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);
  2390. return enc;
  2391. }
  2392. `;var Wzt=y(x(),1),eL=`vec3 lambertianDiffuse(vec3 diffuseColor)
  2393. {
  2394. return diffuseColor / czm_pi;
  2395. }
  2396. vec3 fresnelSchlick2(vec3 f0, vec3 f90, float VdotH)
  2397. {
  2398. float versine = 1.0 - VdotH;
  2399. // pow(versine, 5.0) is slow. See https://stackoverflow.com/a/68793086/10082269
  2400. float versineSquared = versine * versine;
  2401. return f0 + (f90 - f0) * versineSquared * versineSquared * versine;
  2402. }
  2403. #ifdef USE_ANISOTROPY
  2404. /**
  2405. * @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)
  2406. * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
  2407. * @param {vec3} lightDirection The direction from the fragment to the light source, transformed to tangent-bitangent-normal coordinates
  2408. * @param {vec3} viewDirection The direction from the fragment to the camera, transformed to tangent-bitangent-normal coordinates
  2409. */
  2410. float smithVisibilityGGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 lightDirection, vec3 viewDirection)
  2411. {
  2412. vec3 roughnessScale = vec3(tangentialRoughness, bitangentRoughness, 1.0);
  2413. float GGXV = lightDirection.z * length(roughnessScale * viewDirection);
  2414. float GGXL = viewDirection.z * length(roughnessScale * lightDirection);
  2415. float v = 0.5 / (GGXV + GGXL);
  2416. return clamp(v, 0.0, 1.0);
  2417. }
  2418. /**
  2419. * @param {float} bitangentRoughness Material roughness (along the anisotropy bitangent)
  2420. * @param {float} tangentialRoughness Anisotropic roughness (along the anisotropy tangent)
  2421. * @param {vec3} halfwayDirection The unit vector halfway between light and view directions, transformed to tangent-bitangent-normal coordinates
  2422. */
  2423. float GGX_anisotropic(float bitangentRoughness, float tangentialRoughness, vec3 halfwayDirection)
  2424. {
  2425. float roughnessSquared = bitangentRoughness * tangentialRoughness;
  2426. vec3 f = halfwayDirection * vec3(bitangentRoughness, tangentialRoughness, roughnessSquared);
  2427. float w2 = roughnessSquared / dot(f, f);
  2428. return roughnessSquared * w2 * w2 / czm_pi;
  2429. }
  2430. #endif
  2431. /**
  2432. * Estimate the geometric self-shadowing of the microfacets in a surface,
  2433. * using the Smith Joint GGX visibility function.
  2434. * Note: Vis = G / (4 * NdotL * NdotV)
  2435. * see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3
  2436. * see Real-Time Rendering. Page 331 to 336.
  2437. * see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
  2438. *
  2439. * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
  2440. * @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.
  2441. * @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.
  2442. */
  2443. float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)
  2444. {
  2445. float alphaRoughnessSq = alphaRoughness * alphaRoughness;
  2446. float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
  2447. float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
  2448. float GGX = GGXV + GGXL;
  2449. if (GGX > 0.0)
  2450. {
  2451. return 0.5 / GGX;
  2452. }
  2453. return 0.0;
  2454. }
  2455. /**
  2456. * Estimate the fraction of the microfacets in a surface that are aligned with
  2457. * the halfway vector, which is aligned halfway between the directions from
  2458. * the fragment to the camera and from the fragment to the light source.
  2459. *
  2460. * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
  2461. * @param {float} NdotH The cosine of the angle between the surface normal and the halfway vector.
  2462. * @return {float} The fraction of microfacets aligned to the halfway vector.
  2463. */
  2464. float GGX(float alphaRoughness, float NdotH)
  2465. {
  2466. float alphaRoughnessSquared = alphaRoughness * alphaRoughness;
  2467. float f = (NdotH * alphaRoughnessSquared - NdotH) * NdotH + 1.0;
  2468. return alphaRoughnessSquared / (czm_pi * f * f);
  2469. }
  2470. /**
  2471. * Compute the strength of the specular reflection due to direct lighting.
  2472. *
  2473. * @param {vec3} normal The surface normal.
  2474. * @param {vec3} lightDirection The unit vector pointing from the fragment to the light source.
  2475. * @param {vec3} viewDirection The unit vector pointing from the fragment to the camera.
  2476. * @param {vec3} halfwayDirection The unit vector pointing from the fragment to halfway between the light source and the camera.
  2477. * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
  2478. * @return {float} The strength of the specular reflection.
  2479. */
  2480. float computeDirectSpecularStrength(vec3 normal, vec3 lightDirection, vec3 viewDirection, vec3 halfwayDirection, float alphaRoughness)
  2481. {
  2482. float NdotL = clamp(dot(normal, lightDirection), 0.0, 1.0);
  2483. float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
  2484. float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);
  2485. float NdotH = clamp(dot(normal, halfwayDirection), 0.0, 1.0);
  2486. float D = GGX(alphaRoughness, NdotH);
  2487. return G * D;
  2488. }
  2489. /**
  2490. * Compute the diffuse and specular contributions using physically based
  2491. * rendering. This function only handles direct lighting.
  2492. * <p>
  2493. * This function only handles the lighting calculations. Metallic/roughness
  2494. * and specular/glossy must be handled separately. See {@MaterialStageFS}
  2495. * </p>
  2496. *
  2497. * @name czm_pbrLighting
  2498. * @glslFunction
  2499. *
  2500. * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position
  2501. * @param {vec3} normalEC The surface normal in eye coordinates
  2502. * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates.
  2503. * @param {czm_modelMaterial} The material properties.
  2504. * @return {vec3} The computed HDR color
  2505. */
  2506. vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC, czm_modelMaterial material)
  2507. {
  2508. vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC);
  2509. float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0);
  2510. float NdotL = clamp(dot(normalEC, lightDirectionEC), 0.001, 1.0);
  2511. vec3 f0 = material.specular;
  2512. float reflectance = czm_maximumComponent(f0);
  2513. // Typical dielectrics will have reflectance 0.04, so f90 will be 1.0.
  2514. // In this case, at grazing angle, all incident energy is reflected.
  2515. vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0));
  2516. vec3 F = fresnelSchlick2(f0, f90, VdotH);
  2517. #if defined(USE_SPECULAR)
  2518. F *= material.specularWeight;
  2519. #endif
  2520. float alphaRoughness = material.roughness * material.roughness;
  2521. #ifdef USE_ANISOTROPY
  2522. mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC);
  2523. vec3 lightDirection = lightDirectionEC * tbn;
  2524. vec3 viewDirection = viewDirectionEC * tbn;
  2525. vec3 halfwayDirection = halfwayDirectionEC * tbn;
  2526. float anisotropyStrength = material.anisotropyStrength;
  2527. float tangentialRoughness = mix(alphaRoughness, 1.0, anisotropyStrength * anisotropyStrength);
  2528. float bitangentRoughness = clamp(alphaRoughness, 0.001, 1.0);
  2529. float G = smithVisibilityGGX_anisotropic(bitangentRoughness, tangentialRoughness, lightDirection, viewDirection);
  2530. float D = GGX_anisotropic(bitangentRoughness, tangentialRoughness, halfwayDirection);
  2531. vec3 specularContribution = F * G * D;
  2532. #else
  2533. float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alphaRoughness);
  2534. vec3 specularContribution = F * specularStrength;
  2535. #endif
  2536. vec3 diffuseColor = material.diffuse;
  2537. // F here represents the specular contribution
  2538. vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor);
  2539. // Lo = (diffuse + specular) * Li * NdotL
  2540. return (diffuseContribution + specularContribution) * NdotL;
  2541. }
  2542. `;var Bzt=y(x(),1),tL=`// KhronosGroup https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral
  2543. // Input color is non-negative and resides in the Linear Rec. 709 color space.
  2544. // Output color is also Linear Rec. 709, but in the [0, 1] range.
  2545. vec3 czm_pbrNeutralTonemapping(vec3 color) {
  2546. const float startCompression = 0.8 - 0.04;
  2547. const float desaturation = 0.15;
  2548. float x = min(color.r, min(color.g, color.b));
  2549. float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04);
  2550. color -= offset;
  2551. float peak = max(color.r, max(color.g, color.b));
  2552. if (peak < startCompression) return color;
  2553. const float d = 1.0 - startCompression;
  2554. float newPeak = 1.0 - d * d / (peak + d - startCompression);
  2555. color *= newPeak / peak;
  2556. float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0);
  2557. return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g);
  2558. }
  2559. `;var Nzt=y(x(),1),nL=`float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material)
  2560. {
  2561. return czm_getLambertDiffuse(lightDirectionEC, material.normal);
  2562. }
  2563. float czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material)
  2564. {
  2565. return czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess);
  2566. }
  2567. /**
  2568. * Computes a color using the Phong lighting model.
  2569. *
  2570. * @name czm_phong
  2571. * @glslFunction
  2572. *
  2573. * @param {vec3} toEye A normalized vector from the fragment to the eye in eye coordinates.
  2574. * @param {czm_material} material The fragment's material.
  2575. *
  2576. * @returns {vec4} The computed color.
  2577. *
  2578. * @example
  2579. * vec3 positionToEyeEC = // ...
  2580. * czm_material material = // ...
  2581. * vec3 lightDirectionEC = // ...
  2582. * out_FragColor = czm_phong(normalize(positionToEyeEC), material, lightDirectionEC);
  2583. *
  2584. * @see czm_getMaterial
  2585. */
  2586. vec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  2587. {
  2588. // Diffuse from directional light sources at eye (for top-down)
  2589. float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material);
  2590. if (czm_sceneMode == czm_sceneMode3D) {
  2591. // (and horizon views in 3D)
  2592. diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material);
  2593. }
  2594. float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);
  2595. // Temporary workaround for adding ambient.
  2596. vec3 materialDiffuse = material.diffuse * 0.5;
  2597. vec3 ambient = materialDiffuse;
  2598. vec3 color = ambient + material.emission;
  2599. color += materialDiffuse * diffuse * czm_lightColor;
  2600. color += material.specular * specular * czm_lightColor;
  2601. return vec4(color, material.alpha);
  2602. }
  2603. vec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  2604. {
  2605. float diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material);
  2606. float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material);
  2607. vec3 ambient = vec3(0.0);
  2608. vec3 color = ambient + material.emission;
  2609. color += material.diffuse * diffuse * czm_lightColor;
  2610. color += material.specular * specular * czm_lightColor;
  2611. return vec4(color, material.alpha);
  2612. }
  2613. `;var Xzt=y(x(),1),iL=`/**
  2614. * Computes distance from a point to a plane.
  2615. *
  2616. * @name czm_planeDistance
  2617. * @glslFunction
  2618. *
  2619. * param {vec4} plane A Plane in Hessian Normal Form. See Plane.js
  2620. * param {vec3} point A point in the same space as the plane.
  2621. * returns {float} The distance from the point to the plane.
  2622. */
  2623. float czm_planeDistance(vec4 plane, vec3 point) {
  2624. return (dot(plane.xyz, point) + plane.w);
  2625. }
  2626. /**
  2627. * Computes distance from a point to a plane.
  2628. *
  2629. * @name czm_planeDistance
  2630. * @glslFunction
  2631. *
  2632. * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js
  2633. * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js
  2634. * param {vec3} point A point in the same space as the plane.
  2635. * returns {float} The distance from the point to the plane.
  2636. */
  2637. float czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) {
  2638. return (dot(planeNormal, point) + planeDistance);
  2639. }
  2640. `;var Mzt=y(x(),1),oL=`/**
  2641. * Computes the point along a ray at the given time. <code>time</code> can be positive, negative, or zero.
  2642. *
  2643. * @name czm_pointAlongRay
  2644. * @glslFunction
  2645. *
  2646. * @param {czm_ray} ray The ray to compute the point along.
  2647. * @param {float} time The time along the ray.
  2648. *
  2649. * @returns {vec3} The point along the ray at the given time.
  2650. *
  2651. * @example
  2652. * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction
  2653. * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0)
  2654. */
  2655. vec3 czm_pointAlongRay(czm_ray ray, float time)
  2656. {
  2657. return ray.origin + (time * ray.direction);
  2658. }
  2659. `;var Uzt=y(x(),1),rL=`/**
  2660. * DOC_TBA
  2661. *
  2662. * @name czm_rayEllipsoidIntersectionInterval
  2663. * @glslFunction
  2664. */
  2665. czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)
  2666. {
  2667. // ray and ellipsoid center in eye coordinates. radii in model coordinates.
  2668. vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;
  2669. vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;
  2670. q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;
  2671. float q2 = dot(q, q);
  2672. float qw = dot(q, w);
  2673. if (q2 > 1.0) // Outside ellipsoid.
  2674. {
  2675. if (qw >= 0.0) // Looking outward or tangent (0 intersections).
  2676. {
  2677. return czm_emptyRaySegment;
  2678. }
  2679. else // qw < 0.0.
  2680. {
  2681. float qw2 = qw * qw;
  2682. float difference = q2 - 1.0; // Positively valued.
  2683. float w2 = dot(w, w);
  2684. float product = w2 * difference;
  2685. if (qw2 < product) // Imaginary roots (0 intersections).
  2686. {
  2687. return czm_emptyRaySegment;
  2688. }
  2689. else if (qw2 > product) // Distinct roots (2 intersections).
  2690. {
  2691. float discriminant = qw * qw - product;
  2692. float temp = -qw + sqrt(discriminant); // Avoid cancellation.
  2693. float root0 = temp / w2;
  2694. float root1 = difference / temp;
  2695. if (root0 < root1)
  2696. {
  2697. czm_raySegment i = czm_raySegment(root0, root1);
  2698. return i;
  2699. }
  2700. else
  2701. {
  2702. czm_raySegment i = czm_raySegment(root1, root0);
  2703. return i;
  2704. }
  2705. }
  2706. else // qw2 == product. Repeated roots (2 intersections).
  2707. {
  2708. float root = sqrt(difference / w2);
  2709. czm_raySegment i = czm_raySegment(root, root);
  2710. return i;
  2711. }
  2712. }
  2713. }
  2714. else if (q2 < 1.0) // Inside ellipsoid (2 intersections).
  2715. {
  2716. float difference = q2 - 1.0; // Negatively valued.
  2717. float w2 = dot(w, w);
  2718. float product = w2 * difference; // Negatively valued.
  2719. float discriminant = qw * qw - product;
  2720. float temp = -qw + sqrt(discriminant); // Positively valued.
  2721. czm_raySegment i = czm_raySegment(0.0, temp / w2);
  2722. return i;
  2723. }
  2724. else // q2 == 1.0. On ellipsoid.
  2725. {
  2726. if (qw < 0.0) // Looking inward.
  2727. {
  2728. float w2 = dot(w, w);
  2729. czm_raySegment i = czm_raySegment(0.0, -qw / w2);
  2730. return i;
  2731. }
  2732. else // qw >= 0.0. Looking outward or tangent.
  2733. {
  2734. return czm_emptyRaySegment;
  2735. }
  2736. }
  2737. }
  2738. `;var kzt=y(x(),1),sL=`/**
  2739. * Compute the intersection interval of a ray with a sphere.
  2740. *
  2741. * @name czm_raySphereIntersectionInterval
  2742. * @glslFunction
  2743. *
  2744. * @param {czm_ray} ray The ray.
  2745. * @param {vec3} center The center of the sphere.
  2746. * @param {float} radius The radius of the sphere.
  2747. * @return {czm_raySegment} The intersection interval of the ray with the sphere.
  2748. */
  2749. czm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius)
  2750. {
  2751. vec3 o = ray.origin;
  2752. vec3 d = ray.direction;
  2753. vec3 oc = o - center;
  2754. float a = dot(d, d);
  2755. float b = 2.0 * dot(d, oc);
  2756. float c = dot(oc, oc) - (radius * radius);
  2757. float det = (b * b) - (4.0 * a * c);
  2758. if (det < 0.0) {
  2759. return czm_emptyRaySegment;
  2760. }
  2761. float sqrtDet = sqrt(det);
  2762. float t0 = (-b - sqrtDet) / (2.0 * a);
  2763. float t1 = (-b + sqrtDet) / (2.0 * a);
  2764. czm_raySegment result = czm_raySegment(t0, t1);
  2765. return result;
  2766. }
  2767. `;var Ozt=y(x(),1),aL=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
  2768. {
  2769. return czm_reverseLogDepth(texture(depthTexture, texCoords).r);
  2770. }
  2771. `;var Hzt=y(x(),1),cL=`/**
  2772. * Reads a value previously transformed with {@link czm_writeNonPerspective}
  2773. * by dividing it by \`w\`, the value used in the perspective divide.
  2774. * This function is intended to be called in a fragment shader to access a
  2775. * \`varying\` that should not be subject to perspective interpolation.
  2776. * For example, screen-space texture coordinates. The value should have been
  2777. * previously written in the vertex shader with a call to
  2778. * {@link czm_writeNonPerspective}.
  2779. *
  2780. * @name czm_readNonPerspective
  2781. * @glslFunction
  2782. *
  2783. * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.
  2784. * @param {float} oneOverW One over the perspective divide value, \`w\`. Usually this is simply \`gl_FragCoord.w\`.
  2785. * @returns {float|vec2|vec3|vec4} The usable value.
  2786. */
  2787. float czm_readNonPerspective(float value, float oneOverW) {
  2788. return value * oneOverW;
  2789. }
  2790. vec2 czm_readNonPerspective(vec2 value, float oneOverW) {
  2791. return value * oneOverW;
  2792. }
  2793. vec3 czm_readNonPerspective(vec3 value, float oneOverW) {
  2794. return value * oneOverW;
  2795. }
  2796. vec4 czm_readNonPerspective(vec4 value, float oneOverW) {
  2797. return value * oneOverW;
  2798. }
  2799. `;var Kzt=y(x(),1),lL=`float czm_reverseLogDepth(float logZ)
  2800. {
  2801. #ifdef LOG_DEPTH
  2802. float near = czm_currentFrustum.x;
  2803. float far = czm_currentFrustum.y;
  2804. float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;
  2805. float depthFromNear = exp2(log2Depth) - 1.0;
  2806. return far * (1.0 - near / (depthFromNear + near)) / (far - near);
  2807. #endif
  2808. return logZ;
  2809. }
  2810. `;var qzt=y(x(),1),dL=`/**
  2811. * Converts an RGB color to HSB (hue, saturation, brightness)
  2812. * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
  2813. *
  2814. * @name czm_RGBToHSB
  2815. * @glslFunction
  2816. *
  2817. * @param {vec3} rgb The color in RGB.
  2818. *
  2819. * @returns {vec3} The color in HSB.
  2820. *
  2821. * @example
  2822. * vec3 hsb = czm_RGBToHSB(rgb);
  2823. * hsb.z *= 0.1;
  2824. * rgb = czm_HSBToRGB(hsb);
  2825. */
  2826. const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
  2827. vec3 czm_RGBToHSB(vec3 rgb)
  2828. {
  2829. vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g));
  2830. vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r));
  2831. float d = q.x - min(q.w, q.y);
  2832. return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x);
  2833. }
  2834. `;var e3t=y(x(),1),uL=`/**
  2835. * Converts an RGB color to HSL (hue, saturation, lightness)
  2836. * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html}
  2837. *
  2838. * @name czm_RGBToHSL
  2839. * @glslFunction
  2840. *
  2841. * @param {vec3} rgb The color in RGB.
  2842. *
  2843. * @returns {vec3} The color in HSL.
  2844. *
  2845. * @example
  2846. * vec3 hsl = czm_RGBToHSL(rgb);
  2847. * hsl.z *= 0.1;
  2848. * rgb = czm_HSLToRGB(hsl);
  2849. */
  2850. vec3 RGBtoHCV(vec3 rgb)
  2851. {
  2852. // Based on work by Sam Hocevar and Emil Persson
  2853. vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0);
  2854. vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx);
  2855. float c = q.x - min(q.w, q.y);
  2856. float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z);
  2857. return vec3(h, c, q.x);
  2858. }
  2859. vec3 czm_RGBToHSL(vec3 rgb)
  2860. {
  2861. vec3 hcv = RGBtoHCV(rgb);
  2862. float l = hcv.z - hcv.y * 0.5;
  2863. float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7);
  2864. return vec3(hcv.x, s, l);
  2865. }
  2866. `;var n3t=y(x(),1),mL=`/**
  2867. * Converts an RGB color to CIE Yxy.
  2868. * <p>The conversion is described in
  2869. * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
  2870. * </p>
  2871. *
  2872. * @name czm_RGBToXYZ
  2873. * @glslFunction
  2874. *
  2875. * @param {vec3} rgb The color in RGB.
  2876. *
  2877. * @returns {vec3} The color in CIE Yxy.
  2878. *
  2879. * @example
  2880. * vec3 xyz = czm_RGBToXYZ(rgb);
  2881. * xyz.x = max(xyz.x - luminanceThreshold, 0.0);
  2882. * rgb = czm_XYZToRGB(xyz);
  2883. */
  2884. vec3 czm_RGBToXYZ(vec3 rgb)
  2885. {
  2886. const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193,
  2887. 0.3576, 0.7152, 0.1192,
  2888. 0.1805, 0.0722, 0.9505);
  2889. vec3 xyz = RGB2XYZ * rgb;
  2890. vec3 Yxy;
  2891. Yxy.r = xyz.g;
  2892. float temp = dot(vec3(1.0), xyz);
  2893. Yxy.gb = xyz.rg / temp;
  2894. return Yxy;
  2895. }
  2896. `;var o3t=y(x(),1),hL=`/**
  2897. * Round a floating point value. This function exists because round() doesn't
  2898. * exist in GLSL 1.00.
  2899. *
  2900. * @param {float|vec2|vec3|vec4} value The value to round
  2901. * @param {float|vec2|vec3|vec3} The rounded value. The type matches the input.
  2902. */
  2903. float czm_round(float value) {
  2904. return floor(value + 0.5);
  2905. }
  2906. vec2 czm_round(vec2 value) {
  2907. return floor(value + 0.5);
  2908. }
  2909. vec3 czm_round(vec3 value) {
  2910. return floor(value + 0.5);
  2911. }
  2912. vec4 czm_round(vec4 value) {
  2913. return floor(value + 0.5);
  2914. }
  2915. `;var s3t=y(x(),1),fL=`/**
  2916. * Adjusts the saturation of a color.
  2917. *
  2918. * @name czm_saturation
  2919. * @glslFunction
  2920. *
  2921. * @param {vec3} rgb The color.
  2922. * @param {float} adjustment The amount to adjust the saturation of the color.
  2923. *
  2924. * @returns {float} The color with the saturation adjusted.
  2925. *
  2926. * @example
  2927. * vec3 greyScale = czm_saturation(color, 0.0);
  2928. * vec3 doubleSaturation = czm_saturation(color, 2.0);
  2929. */
  2930. vec3 czm_saturation(vec3 rgb, float adjustment)
  2931. {
  2932. // Algorithm from Chapter 16 of OpenGL Shading Language
  2933. const vec3 W = vec3(0.2125, 0.7154, 0.0721);
  2934. vec3 intensity = vec3(dot(rgb, W));
  2935. return mix(intensity, rgb, adjustment);
  2936. }
  2937. `;var c3t=y(x(),1),pL=`
  2938. float czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d)
  2939. {
  2940. return czm_unpackDepth(czm_textureCube(shadowMap, d));
  2941. }
  2942. float czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv)
  2943. {
  2944. #ifdef USE_SHADOW_DEPTH_TEXTURE
  2945. return texture(shadowMap, uv).r;
  2946. #else
  2947. return czm_unpackDepth(texture(shadowMap, uv));
  2948. #endif
  2949. }
  2950. float czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth)
  2951. {
  2952. return step(depth, czm_sampleShadowMap(shadowMap, uv));
  2953. }
  2954. float czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth)
  2955. {
  2956. return step(depth, czm_sampleShadowMap(shadowMap, uv));
  2957. }
  2958. `;var d3t=y(x(),1),AL=`
  2959. float czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness)
  2960. {
  2961. #ifdef USE_NORMAL_SHADING
  2962. #ifdef USE_NORMAL_SHADING_SMOOTH
  2963. float strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0);
  2964. #else
  2965. float strength = step(0.0, nDotL);
  2966. #endif
  2967. visibility *= strength;
  2968. #endif
  2969. visibility = max(visibility, darkness);
  2970. return visibility;
  2971. }
  2972. #ifdef USE_CUBE_MAP_SHADOW
  2973. float czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters)
  2974. {
  2975. float depthBias = shadowParameters.depthBias;
  2976. float depth = shadowParameters.depth;
  2977. float nDotL = shadowParameters.nDotL;
  2978. float normalShadingSmooth = shadowParameters.normalShadingSmooth;
  2979. float darkness = shadowParameters.darkness;
  2980. vec3 uvw = shadowParameters.texCoords;
  2981. depth -= depthBias;
  2982. float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);
  2983. return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
  2984. }
  2985. #else
  2986. float czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters)
  2987. {
  2988. float depthBias = shadowParameters.depthBias;
  2989. float depth = shadowParameters.depth;
  2990. float nDotL = shadowParameters.nDotL;
  2991. float normalShadingSmooth = shadowParameters.normalShadingSmooth;
  2992. float darkness = shadowParameters.darkness;
  2993. vec2 uv = shadowParameters.texCoords;
  2994. depth -= depthBias;
  2995. #ifdef USE_SOFT_SHADOWS
  2996. vec2 texelStepSize = shadowParameters.texelStepSize;
  2997. float radius = 1.0;
  2998. float dx0 = -texelStepSize.x * radius;
  2999. float dy0 = -texelStepSize.y * radius;
  3000. float dx1 = texelStepSize.x * radius;
  3001. float dy1 = texelStepSize.y * radius;
  3002. float visibility = (
  3003. czm_shadowDepthCompare(shadowMap, uv, depth) +
  3004. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +
  3005. czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +
  3006. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +
  3007. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +
  3008. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +
  3009. czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +
  3010. czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +
  3011. czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)
  3012. ) * (1.0 / 9.0);
  3013. #else
  3014. float visibility = czm_shadowDepthCompare(shadowMap, uv, depth);
  3015. #endif
  3016. return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
  3017. }
  3018. #endif
  3019. `;var m3t=y(x(),1),gL=`/**
  3020. * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL
  3021. * built-in function <code>sign</code> except that returns 1.0 instead of 0.0 when the input value is 0.0.
  3022. *
  3023. * @name czm_signNotZero
  3024. * @glslFunction
  3025. *
  3026. * @param {} value The value for which to determine the sign.
  3027. * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.
  3028. */
  3029. float czm_signNotZero(float value)
  3030. {
  3031. return value >= 0.0 ? 1.0 : -1.0;
  3032. }
  3033. vec2 czm_signNotZero(vec2 value)
  3034. {
  3035. return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));
  3036. }
  3037. vec3 czm_signNotZero(vec3 value)
  3038. {
  3039. return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));
  3040. }
  3041. vec4 czm_signNotZero(vec4 value)
  3042. {
  3043. return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));
  3044. }
  3045. `;var f3t=y(x(),1),bL=`/**
  3046. * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.
  3047. * <p>
  3048. * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22].
  3049. * </p>
  3050. *
  3051. * @name czm_sphericalHarmonics
  3052. * @glslFunction
  3053. *
  3054. * @param {vec3} normal The normalized direction.
  3055. * @param {vec3[9]} coefficients The third order spherical harmonic coefficients.
  3056. * @returns {vec3} The color at the direction.
  3057. *
  3058. * @see https://graphics.stanford.edu/papers/envmap/envmap.pdf
  3059. */
  3060. vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9])
  3061. {
  3062. vec3 L00 = coefficients[0];
  3063. vec3 L1_1 = coefficients[1];
  3064. vec3 L10 = coefficients[2];
  3065. vec3 L11 = coefficients[3];
  3066. vec3 L2_2 = coefficients[4];
  3067. vec3 L2_1 = coefficients[5];
  3068. vec3 L20 = coefficients[6];
  3069. vec3 L21 = coefficients[7];
  3070. vec3 L22 = coefficients[8];
  3071. float x = normal.x;
  3072. float y = normal.y;
  3073. float z = normal.z;
  3074. vec3 L =
  3075. L00
  3076. + L1_1 * y
  3077. + L10 * z
  3078. + L11 * x
  3079. + L2_2 * (y * x)
  3080. + L2_1 * (y * z)
  3081. + L20 * (3.0 * z * z - 1.0)
  3082. + L21 * (z * x)
  3083. + L22 * (x * x - y * y);
  3084. return max(L, vec3(0.0));
  3085. }
  3086. `;var A3t=y(x(),1),yL=`/**
  3087. * Converts an sRGB color to a linear RGB color.
  3088. *
  3089. * @param {vec3|vec4} srgbIn The color in sRGB space
  3090. * @returns {vec3|vec4} The color in linear color space. The vector type matches the input.
  3091. */
  3092. vec3 czm_srgbToLinear(vec3 srgbIn)
  3093. {
  3094. return pow(srgbIn, vec3(2.2));
  3095. }
  3096. vec4 czm_srgbToLinear(vec4 srgbIn)
  3097. {
  3098. vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));
  3099. return vec4(linearOut, srgbIn.a);
  3100. }
  3101. `;var b3t=y(x(),1),xL=`/**
  3102. * Creates a matrix that transforms vectors from tangent space to eye space.
  3103. *
  3104. * @name czm_tangentToEyeSpaceMatrix
  3105. * @glslFunction
  3106. *
  3107. * @param {vec3} normalEC The normal vector in eye coordinates.
  3108. * @param {vec3} tangentEC The tangent vector in eye coordinates.
  3109. * @param {vec3} bitangentEC The bitangent vector in eye coordinates.
  3110. *
  3111. * @returns {mat3} The matrix that transforms from tangent space to eye space.
  3112. *
  3113. * @example
  3114. * mat3 tangentToEye = czm_tangentToEyeSpaceMatrix(normalEC, tangentEC, bitangentEC);
  3115. * vec3 normal = tangentToEye * texture(normalMap, st).xyz;
  3116. */
  3117. mat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC)
  3118. {
  3119. vec3 normal = normalize(normalEC);
  3120. vec3 tangent = normalize(tangentEC);
  3121. vec3 bitangent = normalize(bitangentEC);
  3122. return mat3(tangent.x , tangent.y , tangent.z,
  3123. bitangent.x, bitangent.y, bitangent.z,
  3124. normal.x , normal.y , normal.z);
  3125. }
  3126. `;var x3t=y(x(),1),CL=`/**
  3127. * A wrapper around the texture (WebGL2) / textureCube (WebGL1)
  3128. * function to allow for WebGL 1 support.
  3129. *
  3130. * @name czm_textureCube
  3131. * @glslFunction
  3132. *
  3133. * @param {samplerCube} sampler The sampler.
  3134. * @param {vec3} p The coordinate at which to sample the texture.
  3135. */
  3136. vec4 czm_textureCube(samplerCube sampler, vec3 p) {
  3137. #if __VERSION__ == 300
  3138. return texture(sampler, p);
  3139. #else
  3140. return textureCube(sampler, p);
  3141. #endif
  3142. }
  3143. /**
  3144. * A wrapper around the textureLod (WebGL2) / textureCube (WebGL1)
  3145. * function to allow for WebGL 1 support in fragment shaders.
  3146. *
  3147. * @name czm_textureCubeLod
  3148. * @glslFunction
  3149. *
  3150. * @param {samplerCube} sampler The sampler.
  3151. * @param {vec3} p The coordinate at which to sample the texture.
  3152. * @param {float} lod The mipmap level from which to sample.
  3153. */
  3154. vec4 czm_textureCube(samplerCube sampler, vec3 p, float lod) {
  3155. #if __VERSION__ == 300
  3156. return textureLod(sampler, p, lod);
  3157. #elif defined(GL_EXT_shader_texture_lod)
  3158. return textureCubeLodEXT(sampler, p, lod);
  3159. #endif
  3160. }`;var T3t=y(x(),1),TL=`/**
  3161. * Transforms a plane.
  3162. *
  3163. * @name czm_transformPlane
  3164. * @glslFunction
  3165. *
  3166. * @param {vec4} plane The plane in Hessian Normal Form.
  3167. * @param {mat4} transform The inverse-transpose of a transformation matrix.
  3168. */
  3169. vec4 czm_transformPlane(vec4 plane, mat4 transform) {
  3170. vec4 transformedPlane = transform * plane;
  3171. // Convert the transformed plane to Hessian Normal Form
  3172. float normalMagnitude = length(transformedPlane.xyz);
  3173. return transformedPlane / normalMagnitude;
  3174. }
  3175. `;var S3t=y(x(),1),EL=`/**
  3176. * Translates a position (or any <code>vec3</code>) that was encoded with {@link EncodedCartesian3},
  3177. * and then provided to the shader as separate <code>high</code> and <code>low</code> bits to
  3178. * be relative to the eye. As shown in the example, the position can then be transformed in eye
  3179. * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},
  3180. * respectively.
  3181. * <p>
  3182. * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as
  3183. * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.
  3184. * </p>
  3185. *
  3186. * @name czm_translateRelativeToEye
  3187. * @glslFunction
  3188. *
  3189. * @param {vec3} high The position's high bits.
  3190. * @param {vec3} low The position's low bits.
  3191. * @returns {vec3} The position translated to be relative to the camera's position.
  3192. *
  3193. * @example
  3194. * in vec3 positionHigh;
  3195. * in vec3 positionLow;
  3196. *
  3197. * void main()
  3198. * {
  3199. * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  3200. * gl_Position = czm_modelViewProjectionRelativeToEye * p;
  3201. * }
  3202. *
  3203. * @see czm_modelViewRelativeToEye
  3204. * @see czm_modelViewProjectionRelativeToEye
  3205. * @see czm_computePosition
  3206. * @see EncodedCartesian3
  3207. */
  3208. vec4 czm_translateRelativeToEye(vec3 high, vec3 low)
  3209. {
  3210. vec3 highDifference = high - czm_encodedCameraPositionMCHigh;
  3211. // This check handles the case when NaN values have gotten into \`highDifference\`.
  3212. // Such a thing could happen on devices running iOS.
  3213. if (length(highDifference) == 0.0) {
  3214. highDifference = vec3(0);
  3215. }
  3216. vec3 lowDifference = low - czm_encodedCameraPositionMCLow;
  3217. return vec4(highDifference + lowDifference, 1.0);
  3218. }
  3219. `;var I3t=y(x(),1),SL=`/**
  3220. * @private
  3221. */
  3222. vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC)
  3223. {
  3224. // Diffuse from directional light sources at eye (for top-down and horizon views)
  3225. float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal);
  3226. if (czm_sceneMode == czm_sceneMode3D) {
  3227. // (and horizon views in 3D)
  3228. diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal);
  3229. }
  3230. diffuse = clamp(diffuse, 0.0, 1.0);
  3231. float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess);
  3232. // Temporary workaround for adding ambient.
  3233. vec3 materialDiffuse = material.diffuse * 0.5;
  3234. vec3 ambient = materialDiffuse;
  3235. vec3 color = ambient + material.emission;
  3236. color += materialDiffuse * diffuse * czm_lightColor;
  3237. color += material.specular * specular * czm_lightColor;
  3238. return vec4(color, material.alpha);
  3239. }
  3240. `;var R3t=y(x(),1),_L=`/**
  3241. * Returns the transpose of the matrix. The input <code>matrix</code> can be
  3242. * a <code>mat2</code>, <code>mat3</code>, or <code>mat4</code>.
  3243. *
  3244. * @name czm_transpose
  3245. * @glslFunction
  3246. *
  3247. * @param {} matrix The matrix to transpose.
  3248. *
  3249. * @returns {} The transposed matrix.
  3250. *
  3251. * @example
  3252. * // GLSL declarations
  3253. * mat2 czm_transpose(mat2 matrix);
  3254. * mat3 czm_transpose(mat3 matrix);
  3255. * mat4 czm_transpose(mat4 matrix);
  3256. *
  3257. * // Transpose a 3x3 rotation matrix to find its inverse.
  3258. * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates(
  3259. * positionMC, normalEC);
  3260. * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye);
  3261. */
  3262. mat2 czm_transpose(mat2 matrix)
  3263. {
  3264. return mat2(
  3265. matrix[0][0], matrix[1][0],
  3266. matrix[0][1], matrix[1][1]);
  3267. }
  3268. mat3 czm_transpose(mat3 matrix)
  3269. {
  3270. return mat3(
  3271. matrix[0][0], matrix[1][0], matrix[2][0],
  3272. matrix[0][1], matrix[1][1], matrix[2][1],
  3273. matrix[0][2], matrix[1][2], matrix[2][2]);
  3274. }
  3275. mat4 czm_transpose(mat4 matrix)
  3276. {
  3277. return mat4(
  3278. matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
  3279. matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
  3280. matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
  3281. matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
  3282. }
  3283. `;var G3t=y(x(),1),IL=`vec2 getLookupUv(vec2 dimensions, int i) {
  3284. int pixY = i / int(dimensions.x);
  3285. int pixX = i - (pixY * int(dimensions.x));
  3286. float pixelWidth = 1.0 / dimensions.x;
  3287. float pixelHeight = 1.0 / dimensions.y;
  3288. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  3289. float v = (float(pixY) + 0.5) * pixelHeight;
  3290. return vec2(u, v);
  3291. }
  3292. vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {
  3293. vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
  3294. return texture(extentsTexture, getLookupUv(textureDimensions, index));
  3295. }`;var W3t=y(x(),1),ZL=`/**
  3296. * Unpacks a vec4 depth value to a float in [0, 1) range.
  3297. *
  3298. * @name czm_unpackDepth
  3299. * @glslFunction
  3300. *
  3301. * @param {vec4} packedDepth The packed depth.
  3302. *
  3303. * @returns {float} The floating-point depth in [0, 1) range.
  3304. */
  3305. float czm_unpackDepth(vec4 packedDepth)
  3306. {
  3307. // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
  3308. // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
  3309. return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));
  3310. }
  3311. `;var B3t=y(x(),1),RL=`/**
  3312. * Unpack an IEEE 754 single-precision float that is packed as a little-endian unsigned normalized vec4.
  3313. *
  3314. * @name czm_unpackFloat
  3315. * @glslFunction
  3316. *
  3317. * @param {vec4} packedFloat The packed float.
  3318. *
  3319. * @returns {float} The floating-point depth in arbitrary range.
  3320. */
  3321. float czm_unpackFloat(vec4 packedFloat)
  3322. {
  3323. // Convert to [0.0, 255.0] and round to integer
  3324. packedFloat = floor(packedFloat * 255.0 + 0.5);
  3325. float sign = 1.0 - step(128.0, packedFloat[3]) * 2.0;
  3326. float exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0;
  3327. if (exponent == -127.0)
  3328. {
  3329. return 0.0;
  3330. }
  3331. float mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000);
  3332. float result = sign * exp2(exponent - 23.0) * mantissa;
  3333. return result;
  3334. }
  3335. `;var N3t=y(x(),1),VL=`/**
  3336. * Useful for reinterpreting texture data as higher-precision values.
  3337. * Only works correctly in WebGL 2, which supports the uint type and bitwise operations.
  3338. *
  3339. * @param {float|vec2|vec3|vec4} 1-4 values from a texture lookup (RGBA channels), normalized to [0.0, 1.0].
  3340. * @return {uint} Raw bits as an unsigned integer.
  3341. */
  3342. uint czm_unpackTexture(float packedValue) {
  3343. float rounded = czm_round(packedValue * 255.0);
  3344. return uint(rounded);
  3345. }
  3346. uint czm_unpackTexture(vec2 packedValue) {
  3347. vec2 rounded = czm_round(packedValue * 255.0);
  3348. uint byte0 = uint(rounded.x);
  3349. uint byte1 = uint(rounded.y);
  3350. return byte0 | (byte1 << 8);
  3351. }
  3352. uint czm_unpackTexture(vec3 packedValue) {
  3353. vec3 rounded = czm_round(packedValue * 255.0);
  3354. uint byte0 = uint(rounded.x);
  3355. uint byte1 = uint(rounded.y);
  3356. uint byte2 = uint(rounded.z);
  3357. return byte0 | (byte1 << 8) | (byte2 << 16);
  3358. }
  3359. uint czm_unpackTexture(vec4 packedValue) {
  3360. vec4 rounded = czm_round(packedValue * 255.0);
  3361. uint byte0 = uint(rounded.x);
  3362. uint byte1 = uint(rounded.y);
  3363. uint byte2 = uint(rounded.z);
  3364. uint byte3 = uint(rounded.w);
  3365. return byte0 | (byte1 << 8) | (byte2 << 16) | (byte3 << 24);
  3366. }
  3367. `;var X3t=y(x(),1),GL=`/**
  3368. * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,
  3369. * so the return value is an int.
  3370. * <p>
  3371. * There are also precision limitations in WebGL 1. highp int is still limited
  3372. * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur.
  3373. * </p>
  3374. *
  3375. * @param {float|vec2|vec3|vec4} packed The packed value. For vectors, the components are listed in little-endian order.
  3376. *
  3377. * @return {int} The unpacked value.
  3378. */
  3379. int czm_unpackUint(float packedValue) {
  3380. float rounded = czm_round(packedValue * 255.0);
  3381. return int(rounded);
  3382. }
  3383. int czm_unpackUint(vec2 packedValue) {
  3384. vec2 rounded = czm_round(packedValue * 255.0);
  3385. return int(dot(rounded, vec2(1.0, 256.0)));
  3386. }
  3387. int czm_unpackUint(vec3 packedValue) {
  3388. vec3 rounded = czm_round(packedValue * 255.0);
  3389. return int(dot(rounded, vec3(1.0, 256.0, 65536.0)));
  3390. }
  3391. int czm_unpackUint(vec4 packedValue) {
  3392. vec4 rounded = czm_round(packedValue * 255.0);
  3393. return int(dot(rounded, vec4(1.0, 256.0, 65536.0, 16777216.0)));
  3394. }
  3395. `;var M3t=y(x(),1),LL=`/**
  3396. * Transform metadata values following the EXT_structural_metadata spec
  3397. * by multiplying by scale and adding the offset. Operations are always
  3398. * performed component-wise, even for matrices.
  3399. *
  3400. * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} offset The offset to add
  3401. * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} scale The scale factor to multiply
  3402. * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} value The original value.
  3403. *
  3404. * @return {float|vec2|vec3|vec4|mat2|mat3|mat4} The transformed value of the same scalar/vector/matrix type as the input.
  3405. */
  3406. float czm_valueTransform(float offset, float scale, float value) {
  3407. return scale * value + offset;
  3408. }
  3409. vec2 czm_valueTransform(vec2 offset, vec2 scale, vec2 value) {
  3410. return scale * value + offset;
  3411. }
  3412. vec3 czm_valueTransform(vec3 offset, vec3 scale, vec3 value) {
  3413. return scale * value + offset;
  3414. }
  3415. vec4 czm_valueTransform(vec4 offset, vec4 scale, vec4 value) {
  3416. return scale * value + offset;
  3417. }
  3418. mat2 czm_valueTransform(mat2 offset, mat2 scale, mat2 value) {
  3419. return matrixCompMult(scale, value) + offset;
  3420. }
  3421. mat3 czm_valueTransform(mat3 offset, mat3 scale, mat3 value) {
  3422. return matrixCompMult(scale, value) + offset;
  3423. }
  3424. mat4 czm_valueTransform(mat4 offset, mat4 scale, mat4 value) {
  3425. return matrixCompMult(scale, value) + offset;
  3426. }
  3427. `;var U3t=y(x(),1),WL=`#ifdef LOG_DEPTH
  3428. // 1.0 at the near plane, increasing linearly from there.
  3429. out float v_depthFromNearPlusOne;
  3430. #ifdef SHADOW_MAP
  3431. out vec3 v_logPositionEC;
  3432. #endif
  3433. #endif
  3434. vec4 czm_updatePositionDepth(vec4 coords) {
  3435. #if defined(LOG_DEPTH)
  3436. #ifdef SHADOW_MAP
  3437. vec3 logPositionEC = (czm_inverseProjection * coords).xyz;
  3438. v_logPositionEC = logPositionEC;
  3439. #endif
  3440. // With the very high far/near ratios used with the logarithmic depth
  3441. // buffer, floating point rounding errors can cause linear depth values
  3442. // to end up on the wrong side of the far plane, even for vertices that
  3443. // are really nowhere near it. Since we always write a correct logarithmic
  3444. // depth value in the fragment shader anyway, we just need to make sure
  3445. // such errors don't cause the primitive to be clipped entirely before
  3446. // we even get to the fragment shader.
  3447. coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;
  3448. #endif
  3449. return coords;
  3450. }
  3451. /**
  3452. * Writes the logarithmic depth to gl_Position using the already computed gl_Position.
  3453. *
  3454. * @name czm_vertexLogDepth
  3455. * @glslFunction
  3456. */
  3457. void czm_vertexLogDepth()
  3458. {
  3459. #ifdef LOG_DEPTH
  3460. v_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0;
  3461. gl_Position = czm_updatePositionDepth(gl_Position);
  3462. #endif
  3463. }
  3464. /**
  3465. * Writes the logarithmic depth to gl_Position using the provided clip coordinates.
  3466. * <p>
  3467. * An example use case for this function would be moving the vertex in window coordinates
  3468. * before converting back to clip coordinates. Use the original vertex clip coordinates.
  3469. * </p>
  3470. * @name czm_vertexLogDepth
  3471. * @glslFunction
  3472. *
  3473. * @param {vec4} clipCoords The vertex in clip coordinates.
  3474. *
  3475. * @example
  3476. * czm_vertexLogDepth(czm_projection * vec4(positionEyeCoordinates, 1.0));
  3477. */
  3478. void czm_vertexLogDepth(vec4 clipCoords)
  3479. {
  3480. #ifdef LOG_DEPTH
  3481. v_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0;
  3482. czm_updatePositionDepth(clipCoords);
  3483. #endif
  3484. }
  3485. `;var k3t=y(x(),1),FL=`vec4 czm_screenToEyeCoordinates(vec4 screenCoordinate)
  3486. {
  3487. // Reconstruct NDC coordinates
  3488. float x = 2.0 * screenCoordinate.x - 1.0;
  3489. float y = 2.0 * screenCoordinate.y - 1.0;
  3490. float z = (screenCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2];
  3491. vec4 q = vec4(x, y, z, 1.0);
  3492. // Reverse the perspective division to obtain clip coordinates.
  3493. q /= screenCoordinate.w;
  3494. // Reverse the projection transformation to obtain eye coordinates.
  3495. if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s
  3496. {
  3497. q = czm_inverseProjection * q;
  3498. }
  3499. else
  3500. {
  3501. float top = czm_frustumPlanes.x;
  3502. float bottom = czm_frustumPlanes.y;
  3503. float left = czm_frustumPlanes.z;
  3504. float right = czm_frustumPlanes.w;
  3505. float near = czm_currentFrustum.x;
  3506. float far = czm_currentFrustum.y;
  3507. q.x = (q.x * (right - left) + left + right) * 0.5;
  3508. q.y = (q.y * (top - bottom) + bottom + top) * 0.5;
  3509. q.z = (q.z * (near - far) - near - far) * 0.5;
  3510. q.w = 1.0;
  3511. }
  3512. return q;
  3513. }
  3514. /**
  3515. * Transforms a position from window to eye coordinates.
  3516. * The transform from window to normalized device coordinates is done using components
  3517. * of (@link czm_viewport} and {@link czm_viewportTransformation} instead of calculating
  3518. * the inverse of <code>czm_viewportTransformation</code>. The transformation from
  3519. * normalized device coordinates to clip coordinates is done using <code>fragmentCoordinate.w</code>,
  3520. * which is expected to be the scalar used in the perspective divide. The transformation
  3521. * from clip to eye coordinates is done using {@link czm_inverseProjection}.
  3522. *
  3523. * @name czm_windowToEyeCoordinates
  3524. * @glslFunction
  3525. *
  3526. * @param {vec4} fragmentCoordinate The position in window coordinates to transform.
  3527. *
  3528. * @returns {vec4} The transformed position in eye coordinates.
  3529. *
  3530. * @see czm_modelToWindowCoordinates
  3531. * @see czm_eyeToWindowCoordinates
  3532. * @see czm_inverseProjection
  3533. * @see czm_viewport
  3534. * @see czm_viewportTransformation
  3535. *
  3536. * @example
  3537. * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord);
  3538. */
  3539. vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)
  3540. {
  3541. vec2 screenCoordXY = (fragmentCoordinate.xy - czm_viewport.xy) / czm_viewport.zw;
  3542. return czm_screenToEyeCoordinates(vec4(screenCoordXY, fragmentCoordinate.zw));
  3543. }
  3544. vec4 czm_screenToEyeCoordinates(vec2 screenCoordinateXY, float depthOrLogDepth)
  3545. {
  3546. // See reverseLogDepth.glsl. This is separate to re-use the pow.
  3547. #if defined(LOG_DEPTH) || defined(LOG_DEPTH_READ_ONLY)
  3548. float near = czm_currentFrustum.x;
  3549. float far = czm_currentFrustum.y;
  3550. float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;
  3551. float depthFromNear = exp2(log2Depth) - 1.0;
  3552. float depthFromCamera = depthFromNear + near;
  3553. vec4 screenCoord = vec4(screenCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);
  3554. vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
  3555. eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision
  3556. #else
  3557. vec4 screenCoord = vec4(screenCoordinateXY, depthOrLogDepth, 1.0);
  3558. vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
  3559. #endif
  3560. return eyeCoordinate;
  3561. }
  3562. /**
  3563. * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates.
  3564. * This function produces more accurate results for window positions with log depth than
  3565. * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version
  3566. * of czm_windowToEyeCoordinates.
  3567. *
  3568. * @name czm_windowToEyeCoordinates
  3569. * @glslFunction
  3570. *
  3571. * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform.
  3572. * @param {float} depthOrLogDepth A depth or log depth for the fragment.
  3573. *
  3574. * @see czm_modelToWindowCoordinates
  3575. * @see czm_eyeToWindowCoordinates
  3576. * @see czm_inverseProjection
  3577. * @see czm_viewport
  3578. * @see czm_viewportTransformation
  3579. *
  3580. * @returns {vec4} The transformed position in eye coordinates.
  3581. */
  3582. vec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)
  3583. {
  3584. vec2 screenCoordXY = (fragmentCoordinateXY.xy - czm_viewport.xy) / czm_viewport.zw;
  3585. return czm_screenToEyeCoordinates(screenCoordXY, depthOrLogDepth);
  3586. }
  3587. `;var O3t=y(x(),1),BL=`// emulated noperspective
  3588. #if !defined(LOG_DEPTH)
  3589. in float v_WindowZ;
  3590. #endif
  3591. /**
  3592. * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane
  3593. * by writing the fragment's depth. See czm_depthClamp for more details.
  3594. *
  3595. * @name czm_writeDepthClamp
  3596. * @glslFunction
  3597. *
  3598. * @example
  3599. * out_FragColor = color;
  3600. * czm_writeDepthClamp();
  3601. *
  3602. * @see czm_depthClamp
  3603. */
  3604. void czm_writeDepthClamp()
  3605. {
  3606. #if (!defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
  3607. gl_FragDepth = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0);
  3608. #endif
  3609. }
  3610. `;var H3t=y(x(),1),wL=`#ifdef LOG_DEPTH
  3611. in float v_depthFromNearPlusOne;
  3612. #ifdef POLYGON_OFFSET
  3613. uniform vec2 u_polygonOffset;
  3614. #endif
  3615. #endif
  3616. /**
  3617. * Writes the fragment depth to the logarithmic depth buffer.
  3618. * <p>
  3619. * Use this when the vertex shader does not call {@link czm_vertexLogDepth}, for example, when
  3620. * ray-casting geometry using a full screen quad.
  3621. * </p>
  3622. * @name czm_writeLogDepth
  3623. * @glslFunction
  3624. *
  3625. * @param {float} depth The depth coordinate, where 1.0 is on the near plane and
  3626. * depth increases in eye-space units from there
  3627. *
  3628. * @example
  3629. * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0);
  3630. */
  3631. void czm_writeLogDepth(float depth)
  3632. {
  3633. #if (defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
  3634. // Discard the vertex if it's not between the near and far planes.
  3635. // We allow a bit of epsilon on the near plane comparison because a 1.0
  3636. // from the vertex shader (indicating the vertex should be _on_ the near
  3637. // plane) will not necessarily come here as exactly 1.0.
  3638. if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) {
  3639. discard;
  3640. }
  3641. #ifdef POLYGON_OFFSET
  3642. // Polygon offset: m * factor + r * units
  3643. float factor = u_polygonOffset[0];
  3644. float units = u_polygonOffset[1];
  3645. #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
  3646. // This factor doesn't work in IE 10
  3647. if (factor != 0.0) {
  3648. // m = sqrt(dZdX^2 + dZdY^2);
  3649. float x = dFdx(depth);
  3650. float y = dFdy(depth);
  3651. float m = sqrt(x * x + y * y);
  3652. // Apply the factor before computing the log depth.
  3653. depth += m * factor;
  3654. }
  3655. #endif
  3656. #endif
  3657. gl_FragDepth = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne;
  3658. #ifdef POLYGON_OFFSET
  3659. // Apply the units after the log depth.
  3660. gl_FragDepth += czm_epsilon7 * units;
  3661. #endif
  3662. #endif
  3663. }
  3664. /**
  3665. * Writes the fragment depth to the logarithmic depth buffer.
  3666. * <p>
  3667. * Use this when the vertex shader calls {@link czm_vertexLogDepth}.
  3668. * </p>
  3669. *
  3670. * @name czm_writeLogDepth
  3671. * @glslFunction
  3672. */
  3673. void czm_writeLogDepth() {
  3674. #ifdef LOG_DEPTH
  3675. czm_writeLogDepth(v_depthFromNearPlusOne);
  3676. #endif
  3677. }
  3678. `;var K3t=y(x(),1),NL=`/**
  3679. * Transforms a value for non-perspective interpolation by multiplying
  3680. * it by w, the value used in the perspective divide. This function is
  3681. * intended to be called in a vertex shader to compute the value of a
  3682. * \`varying\` that should not be subject to perspective interpolation.
  3683. * For example, screen-space texture coordinates. The fragment shader
  3684. * must call {@link czm_readNonPerspective} to retrieve the final
  3685. * non-perspective value.
  3686. *
  3687. * @name czm_writeNonPerspective
  3688. * @glslFunction
  3689. *
  3690. * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective.
  3691. * @param {float} w The perspective divide value. Usually this is the computed \`gl_Position.w\`.
  3692. * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a \`varying\` and read in the
  3693. * fragment shader with {@link czm_readNonPerspective}.
  3694. */
  3695. float czm_writeNonPerspective(float value, float w) {
  3696. return value * w;
  3697. }
  3698. vec2 czm_writeNonPerspective(vec2 value, float w) {
  3699. return value * w;
  3700. }
  3701. vec3 czm_writeNonPerspective(vec3 value, float w) {
  3702. return value * w;
  3703. }
  3704. vec4 czm_writeNonPerspective(vec4 value, float w) {
  3705. return value * w;
  3706. }
  3707. `;var q3t=y(x(),1),PL=`/**
  3708. * Converts a CIE Yxy color to RGB.
  3709. * <p>The conversion is described in
  3710. * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
  3711. * </p>
  3712. *
  3713. * @name czm_XYZToRGB
  3714. * @glslFunction
  3715. *
  3716. * @param {vec3} Yxy The color in CIE Yxy.
  3717. *
  3718. * @returns {vec3} The color in RGB.
  3719. *
  3720. * @example
  3721. * vec3 xyz = czm_RGBToXYZ(rgb);
  3722. * xyz.x = max(xyz.x - luminanceThreshold, 0.0);
  3723. * rgb = czm_XYZToRGB(xyz);
  3724. */
  3725. vec3 czm_XYZToRGB(vec3 Yxy)
  3726. {
  3727. const mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556,
  3728. -1.5371, 1.8760, -0.2040,
  3729. -0.4985, 0.0416, 1.0572);
  3730. vec3 xyz;
  3731. xyz.r = Yxy.r * Yxy.g / Yxy.b;
  3732. xyz.g = Yxy.r;
  3733. xyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b;
  3734. return XYZ2RGB * xyz;
  3735. }
  3736. `;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,`
  3737. varying $2`),/out_FragData_(\d+)/.test(n)&&(n=`#extension GL_EXT_draw_buffers : enable
  3738. ${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
  3739. ${n}`,n=n.replaceAll(/gl_FragDepth/g,"gl_FragDepthEXT")),n=`#ifdef GL_EXT_shader_texture_lod
  3740. #extension GL_EXT_shader_texture_lod : enable
  3741. #endif
  3742. ${n}`,n=`#ifdef GL_OES_standard_derivatives
  3743. #extension GL_OES_standard_derivatives : enable
  3744. #endif
  3745. ${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
  3746. ${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+=`
  3747. `;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}
  3748. `;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+=`
  3749. #line 0
  3750. ${o[A]}`;i=dse(i);let r;i=i.replace(/#version\s+(.*?)\n/gm,function(A,f){return r=f,`
  3751. `});let s=[];i=i.replace(/#extension.*\n/gm,function(A){return s.push(A),`
  3752. `}),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+=`
  3753. #ifdef GL_FRAGMENT_PRECISION_HIGH
  3754. precision highp float;
  3755. precision highp int;
  3756. #else
  3757. precision mediump float;
  3758. precision mediump int;
  3759. #define highp mediump
  3760. #endif
  3761. `),n.webgl2&&(c+=`precision highp sampler3D;
  3762. `);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}
  3763. `)}n.textureFloatLinear&&(c+=`#define OES_texture_float_linear
  3764. `),n.floatingPointTexture&&(c+=`#define OES_texture_float
  3765. `);let h="";e.includeBuiltIns&&(h=M2e(i)),c+=`
  3766. #line 0
  3767. `;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;
  3768. `),c+=h,c+=i,n.webgl2?c=`#version 300 es
  3769. ${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(`
  3770. `);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")}
  3771. in vec4 pickColor;
  3772. out vec4 czm_pickColor;
  3773. void main()
  3774. {
  3775. czm_old_main();
  3776. czm_pickColor = pickColor;
  3777. }`};Ia.createPickFragmentShaderSource=function(e,t){let n=Ia.replaceMain(e,"czm_old_main"),i=`${t} vec4 czm_pickColor;
  3778. void main()
  3779. {
  3780. czm_old_main();
  3781. if (out_FragColor.a == 0.0) {
  3782. discard;
  3783. }
  3784. out_FragColor = czm_pickColor;
  3785. }`;return`${n}
  3786. ${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
  3787. `),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(`
  3788. `),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
  3789. in vec3 v_normalEC;
  3790. in vec3 v_tangentEC;
  3791. in vec3 v_bitangentEC;
  3792. in vec2 v_st;
  3793. void main()
  3794. {
  3795. vec3 positionToEyeEC = -v_positionEC;
  3796. mat3 tangentToEyeMatrix = czm_tangentToEyeSpaceMatrix(v_normalEC, v_tangentEC, v_bitangentEC);
  3797. vec3 normalEC = normalize(v_normalEC);
  3798. #ifdef FACE_FORWARD
  3799. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  3800. #endif
  3801. czm_materialInput materialInput;
  3802. materialInput.normalEC = normalEC;
  3803. materialInput.tangentToEyeMatrix = tangentToEyeMatrix;
  3804. materialInput.positionToEyeEC = positionToEyeEC;
  3805. materialInput.st = v_st;
  3806. czm_material material = czm_getMaterial(materialInput);
  3807. #ifdef FLAT
  3808. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  3809. #else
  3810. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  3811. #endif
  3812. }
  3813. `;var Xqt=y(x(),1),o1=`in vec3 position3DHigh;
  3814. in vec3 position3DLow;
  3815. in vec3 normal;
  3816. in vec3 tangent;
  3817. in vec3 bitangent;
  3818. in vec2 st;
  3819. in float batchId;
  3820. out vec3 v_positionEC;
  3821. out vec3 v_normalEC;
  3822. out vec3 v_tangentEC;
  3823. out vec3 v_bitangentEC;
  3824. out vec2 v_st;
  3825. void main()
  3826. {
  3827. vec4 p = czm_computePosition();
  3828. v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
  3829. v_normalEC = czm_normal * normal; // normal in eye coordinates
  3830. v_tangentEC = czm_normal * tangent; // tangent in eye coordinates
  3831. v_bitangentEC = czm_normal * bitangent; // bitangent in eye coordinates
  3832. v_st = st;
  3833. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  3834. }
  3835. `;var Mqt=y(x(),1),r1=`in vec3 v_positionEC;
  3836. in vec3 v_normalEC;
  3837. void main()
  3838. {
  3839. vec3 positionToEyeEC = -v_positionEC;
  3840. vec3 normalEC = normalize(v_normalEC);
  3841. #ifdef FACE_FORWARD
  3842. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  3843. #endif
  3844. czm_materialInput materialInput;
  3845. materialInput.normalEC = normalEC;
  3846. materialInput.positionToEyeEC = positionToEyeEC;
  3847. czm_material material = czm_getMaterial(materialInput);
  3848. #ifdef FLAT
  3849. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  3850. #else
  3851. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  3852. #endif
  3853. }
  3854. `;var Uqt=y(x(),1),s1=`in vec3 position3DHigh;
  3855. in vec3 position3DLow;
  3856. in vec3 normal;
  3857. in float batchId;
  3858. out vec3 v_positionEC;
  3859. out vec3 v_normalEC;
  3860. void main()
  3861. {
  3862. vec4 p = czm_computePosition();
  3863. v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
  3864. v_normalEC = czm_normal * normal; // normal in eye coordinates
  3865. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  3866. }
  3867. `;var kqt=y(x(),1),a1=`in vec3 v_positionEC;
  3868. in vec3 v_normalEC;
  3869. in vec2 v_st;
  3870. void main()
  3871. {
  3872. vec3 positionToEyeEC = -v_positionEC;
  3873. vec3 normalEC = normalize(v_normalEC);
  3874. #ifdef FACE_FORWARD
  3875. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  3876. #endif
  3877. czm_materialInput materialInput;
  3878. materialInput.normalEC = normalEC;
  3879. materialInput.positionToEyeEC = positionToEyeEC;
  3880. materialInput.st = v_st;
  3881. czm_material material = czm_getMaterial(materialInput);
  3882. #ifdef FLAT
  3883. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  3884. #else
  3885. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  3886. #endif
  3887. }
  3888. `;var Oqt=y(x(),1),c1=`in vec3 position3DHigh;
  3889. in vec3 position3DLow;
  3890. in vec3 normal;
  3891. in vec2 st;
  3892. in float batchId;
  3893. out vec3 v_positionEC;
  3894. out vec3 v_normalEC;
  3895. out vec2 v_st;
  3896. void main()
  3897. {
  3898. vec4 p = czm_computePosition();
  3899. v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
  3900. v_normalEC = czm_normal * normal; // normal in eye coordinates
  3901. v_st = st;
  3902. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  3903. }
  3904. `;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(`
  3905. `)};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;
  3906. czm_material czm_getMaterial(czm_materialInput materialInput)
  3907. {
  3908. czm_material material = czm_getDefaultMaterial(materialInput);
  3909. vec4 rampColor = texture(image, vec2(materialInput.aspect / (2.0 * czm_pi), 0.5));
  3910. rampColor = czm_gammaCorrect(rampColor);
  3911. material.diffuse = rampColor.rgb;
  3912. material.alpha = rampColor.a;
  3913. return material;
  3914. }
  3915. `;var g$t=y(x(),1),d1=`uniform sampler2D image;
  3916. uniform float strength;
  3917. uniform vec2 repeat;
  3918. czm_material czm_getMaterial(czm_materialInput materialInput)
  3919. {
  3920. czm_material material = czm_getDefaultMaterial(materialInput);
  3921. vec2 st = materialInput.st;
  3922. vec2 centerPixel = fract(repeat * st);
  3923. float centerBump = texture(image, centerPixel).channel;
  3924. float imageWidth = float(imageDimensions.x);
  3925. vec2 rightPixel = fract(repeat * (st + vec2(1.0 / imageWidth, 0.0)));
  3926. float rightBump = texture(image, rightPixel).channel;
  3927. float imageHeight = float(imageDimensions.y);
  3928. vec2 leftPixel = fract(repeat * (st + vec2(0.0, 1.0 / imageHeight)));
  3929. float topBump = texture(image, leftPixel).channel;
  3930. vec3 normalTangentSpace = normalize(vec3(centerBump - rightBump, centerBump - topBump, clamp(1.0 - strength, 0.1, 1.0)));
  3931. vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;
  3932. material.normal = normalEC;
  3933. material.diffuse = vec3(0.01);
  3934. return material;
  3935. }
  3936. `;var y$t=y(x(),1),u1=`uniform vec4 lightColor;
  3937. uniform vec4 darkColor;
  3938. uniform vec2 repeat;
  3939. czm_material czm_getMaterial(czm_materialInput materialInput)
  3940. {
  3941. czm_material material = czm_getDefaultMaterial(materialInput);
  3942. vec2 st = materialInput.st;
  3943. // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
  3944. float b = mod(floor(repeat.s * st.s) + floor(repeat.t * st.t), 2.0); // 0.0 or 1.0
  3945. // Find the distance from the closest separator (region between two colors)
  3946. float scaledWidth = fract(repeat.s * st.s);
  3947. scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));
  3948. float scaledHeight = fract(repeat.t * st.t);
  3949. scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));
  3950. float value = min(scaledWidth, scaledHeight);
  3951. vec4 currentColor = mix(lightColor, darkColor, b);
  3952. vec4 color = czm_antialias(lightColor, darkColor, currentColor, value, 0.03);
  3953. color = czm_gammaCorrect(color);
  3954. material.diffuse = color.rgb;
  3955. material.alpha = color.a;
  3956. return material;
  3957. }
  3958. `;var C$t=y(x(),1),m1=`uniform vec4 lightColor;
  3959. uniform vec4 darkColor;
  3960. uniform vec2 repeat;
  3961. czm_material czm_getMaterial(czm_materialInput materialInput)
  3962. {
  3963. czm_material material = czm_getDefaultMaterial(materialInput);
  3964. // From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
  3965. float b = smoothstep(0.3, 0.32, length(fract(repeat * materialInput.st) - 0.5)); // 0.0 or 1.0
  3966. vec4 color = mix(lightColor, darkColor, b);
  3967. color = czm_gammaCorrect(color);
  3968. material.diffuse = color.rgb;
  3969. material.alpha = color.a;
  3970. return material;
  3971. }
  3972. `;var E$t=y(x(),1),h1=`uniform sampler2D heights;
  3973. uniform sampler2D colors;
  3974. // This material expects heights to be sorted from lowest to highest.
  3975. float getHeight(int idx, float invTexSize)
  3976. {
  3977. vec2 uv = vec2((float(idx) + 0.5) * invTexSize, 0.5);
  3978. #ifdef OES_texture_float
  3979. return texture(heights, uv).x;
  3980. #else
  3981. return czm_unpackFloat(texture(heights, uv));
  3982. #endif
  3983. }
  3984. czm_material czm_getMaterial(czm_materialInput materialInput)
  3985. {
  3986. czm_material material = czm_getDefaultMaterial(materialInput);
  3987. float height = materialInput.height;
  3988. float invTexSize = 1.0 / float(heightsDimensions.x);
  3989. float minHeight = getHeight(0, invTexSize);
  3990. float maxHeight = getHeight(heightsDimensions.x - 1, invTexSize);
  3991. // early-out when outside the height range
  3992. if (height < minHeight || height > maxHeight) {
  3993. material.diffuse = vec3(0.0);
  3994. material.alpha = 0.0;
  3995. return material;
  3996. }
  3997. // Binary search to find heights above and below.
  3998. int idxBelow = 0;
  3999. int idxAbove = heightsDimensions.x;
  4000. float heightBelow = minHeight;
  4001. float heightAbove = maxHeight;
  4002. // while loop not allowed, so use for loop with max iterations.
  4003. // maxIterations of 16 supports a texture size up to 65536 (2^16).
  4004. const int maxIterations = 16;
  4005. for (int i = 0; i < maxIterations; i++) {
  4006. if (idxBelow >= idxAbove - 1) {
  4007. break;
  4008. }
  4009. int idxMid = (idxBelow + idxAbove) / 2;
  4010. float heightTex = getHeight(idxMid, invTexSize);
  4011. if (height > heightTex) {
  4012. idxBelow = idxMid;
  4013. heightBelow = heightTex;
  4014. } else {
  4015. idxAbove = idxMid;
  4016. heightAbove = heightTex;
  4017. }
  4018. }
  4019. float lerper = heightBelow == heightAbove ? 1.0 : (height - heightBelow) / (heightAbove - heightBelow);
  4020. vec2 colorUv = vec2(invTexSize * (float(idxBelow) + 0.5 + lerper), 0.5);
  4021. vec4 color = texture(colors, colorUv);
  4022. // undo preumultiplied alpha
  4023. if (color.a > 0.0)
  4024. {
  4025. color.rgb /= color.a;
  4026. }
  4027. color.rgb = czm_gammaCorrect(color.rgb);
  4028. material.diffuse = color.rgb;
  4029. material.alpha = color.a;
  4030. return material;
  4031. }
  4032. `;var _$t=y(x(),1),f1=`uniform vec4 color;
  4033. uniform float spacing;
  4034. uniform float width;
  4035. czm_material czm_getMaterial(czm_materialInput materialInput)
  4036. {
  4037. czm_material material = czm_getDefaultMaterial(materialInput);
  4038. float distanceToContour = mod(materialInput.height, spacing);
  4039. #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
  4040. float dxc = abs(dFdx(materialInput.height));
  4041. float dyc = abs(dFdy(materialInput.height));
  4042. float dF = max(dxc, dyc) * czm_pixelRatio * width;
  4043. float alpha = (distanceToContour < dF) ? 1.0 : 0.0;
  4044. #else
  4045. // If no derivatives available (IE 10?), use pixel ratio
  4046. float alpha = (distanceToContour < (czm_pixelRatio * width)) ? 1.0 : 0.0;
  4047. #endif
  4048. vec4 outColor = czm_gammaCorrect(vec4(color.rgb, alpha * color.a));
  4049. material.diffuse = outColor.rgb;
  4050. material.alpha = outColor.a;
  4051. return material;
  4052. }
  4053. `;var Z$t=y(x(),1),p1=`uniform sampler2D image;
  4054. uniform float minimumHeight;
  4055. uniform float maximumHeight;
  4056. czm_material czm_getMaterial(czm_materialInput materialInput)
  4057. {
  4058. czm_material material = czm_getDefaultMaterial(materialInput);
  4059. float scaledHeight = clamp((materialInput.height - minimumHeight) / (maximumHeight - minimumHeight), 0.0, 1.0);
  4060. vec4 rampColor = texture(image, vec2(scaledHeight, 0.5));
  4061. rampColor = czm_gammaCorrect(rampColor);
  4062. material.diffuse = rampColor.rgb;
  4063. material.alpha = rampColor.a;
  4064. return material;
  4065. }
  4066. `;var V$t=y(x(),1),A1=`uniform vec4 fadeInColor;
  4067. uniform vec4 fadeOutColor;
  4068. uniform float maximumDistance;
  4069. uniform bool repeat;
  4070. uniform vec2 fadeDirection;
  4071. uniform vec2 time;
  4072. float getTime(float t, float coord)
  4073. {
  4074. float scalar = 1.0 / maximumDistance;
  4075. float q = distance(t, coord) * scalar;
  4076. if (repeat)
  4077. {
  4078. float r = distance(t, coord + 1.0) * scalar;
  4079. float s = distance(t, coord - 1.0) * scalar;
  4080. q = min(min(r, s), q);
  4081. }
  4082. return clamp(q, 0.0, 1.0);
  4083. }
  4084. czm_material czm_getMaterial(czm_materialInput materialInput)
  4085. {
  4086. czm_material material = czm_getDefaultMaterial(materialInput);
  4087. vec2 st = materialInput.st;
  4088. float s = getTime(time.x, st.s) * fadeDirection.s;
  4089. float t = getTime(time.y, st.t) * fadeDirection.t;
  4090. float u = length(vec2(s, t));
  4091. vec4 color = mix(fadeInColor, fadeOutColor, u);
  4092. color = czm_gammaCorrect(color);
  4093. material.emission = color.rgb;
  4094. material.alpha = color.a;
  4095. return material;
  4096. }
  4097. `;var L$t=y(x(),1),g1=`uniform vec4 color;
  4098. uniform float cellAlpha;
  4099. uniform vec2 lineCount;
  4100. uniform vec2 lineThickness;
  4101. uniform vec2 lineOffset;
  4102. czm_material czm_getMaterial(czm_materialInput materialInput)
  4103. {
  4104. czm_material material = czm_getDefaultMaterial(materialInput);
  4105. vec2 st = materialInput.st;
  4106. float scaledWidth = fract(lineCount.s * st.s - lineOffset.s);
  4107. scaledWidth = abs(scaledWidth - floor(scaledWidth + 0.5));
  4108. float scaledHeight = fract(lineCount.t * st.t - lineOffset.t);
  4109. scaledHeight = abs(scaledHeight - floor(scaledHeight + 0.5));
  4110. float value;
  4111. // Fuzz Factor - Controls blurriness of lines
  4112. #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
  4113. const float fuzz = 1.2;
  4114. vec2 thickness = (lineThickness * czm_pixelRatio) - 1.0;
  4115. // From "3D Engine Design for Virtual Globes" by Cozzi and Ring, Listing 4.13.
  4116. vec2 dx = abs(dFdx(st));
  4117. vec2 dy = abs(dFdy(st));
  4118. vec2 dF = vec2(max(dx.s, dy.s), max(dx.t, dy.t)) * lineCount;
  4119. value = min(
  4120. smoothstep(dF.s * thickness.s, dF.s * (fuzz + thickness.s), scaledWidth),
  4121. smoothstep(dF.t * thickness.t, dF.t * (fuzz + thickness.t), scaledHeight));
  4122. #else
  4123. // If no derivatives available (IE 10?), revert to view-dependent fuzz
  4124. const float fuzz = 0.05;
  4125. vec2 range = 0.5 - (lineThickness * 0.05);
  4126. value = min(
  4127. 1.0 - smoothstep(range.s, range.s + fuzz, scaledWidth),
  4128. 1.0 - smoothstep(range.t, range.t + fuzz, scaledHeight));
  4129. #endif
  4130. // Edges taken from RimLightingMaterial.glsl
  4131. // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html
  4132. float dRim = 1.0 - abs(dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC)));
  4133. float sRim = smoothstep(0.8, 1.0, dRim);
  4134. value *= (1.0 - sRim);
  4135. vec4 halfColor;
  4136. halfColor.rgb = color.rgb * 0.5;
  4137. halfColor.a = color.a * (1.0 - ((1.0 - cellAlpha) * value));
  4138. halfColor = czm_gammaCorrect(halfColor);
  4139. material.diffuse = halfColor.rgb;
  4140. material.emission = halfColor.rgb;
  4141. material.alpha = halfColor.a;
  4142. return material;
  4143. }
  4144. `;var F$t=y(x(),1),b1=`uniform sampler2D image;
  4145. uniform float strength;
  4146. uniform vec2 repeat;
  4147. czm_material czm_getMaterial(czm_materialInput materialInput)
  4148. {
  4149. czm_material material = czm_getDefaultMaterial(materialInput);
  4150. vec4 textureValue = texture(image, fract(repeat * materialInput.st));
  4151. vec3 normalTangentSpace = textureValue.channels;
  4152. normalTangentSpace.xy = normalTangentSpace.xy * 2.0 - 1.0;
  4153. normalTangentSpace.z = clamp(1.0 - strength, 0.1, 1.0);
  4154. normalTangentSpace = normalize(normalTangentSpace);
  4155. vec3 normalEC = materialInput.tangentToEyeMatrix * normalTangentSpace;
  4156. material.normal = normalEC;
  4157. return material;
  4158. }
  4159. `;var w$t=y(x(),1),y1=`uniform vec4 color;
  4160. float getPointOnLine(vec2 p0, vec2 p1, float x)
  4161. {
  4162. float slope = (p0.y - p1.y) / (p0.x - p1.x);
  4163. return slope * (x - p0.x) + p0.y;
  4164. }
  4165. czm_material czm_getMaterial(czm_materialInput materialInput)
  4166. {
  4167. czm_material material = czm_getDefaultMaterial(materialInput);
  4168. vec2 st = materialInput.st;
  4169. #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
  4170. float base = 1.0 - abs(fwidth(st.s)) * 10.0 * czm_pixelRatio;
  4171. #else
  4172. // If no derivatives available (IE 10?), 2.5% of the line will be the arrow head
  4173. float base = 0.975;
  4174. #endif
  4175. vec2 center = vec2(1.0, 0.5);
  4176. float ptOnUpperLine = getPointOnLine(vec2(base, 1.0), center, st.s);
  4177. float ptOnLowerLine = getPointOnLine(vec2(base, 0.0), center, st.s);
  4178. float halfWidth = 0.15;
  4179. float s = step(0.5 - halfWidth, st.t);
  4180. s *= 1.0 - step(0.5 + halfWidth, st.t);
  4181. s *= 1.0 - step(base, st.s);
  4182. float t = step(base, materialInput.st.s);
  4183. t *= 1.0 - step(ptOnUpperLine, st.t);
  4184. t *= step(ptOnLowerLine, st.t);
  4185. // Find the distance from the closest separator (region between two colors)
  4186. float dist;
  4187. if (st.s < base)
  4188. {
  4189. float d1 = abs(st.t - (0.5 - halfWidth));
  4190. float d2 = abs(st.t - (0.5 + halfWidth));
  4191. dist = min(d1, d2);
  4192. }
  4193. else
  4194. {
  4195. float d1 = czm_infinity;
  4196. if (st.t < 0.5 - halfWidth && st.t > 0.5 + halfWidth)
  4197. {
  4198. d1 = abs(st.s - base);
  4199. }
  4200. float d2 = abs(st.t - ptOnUpperLine);
  4201. float d3 = abs(st.t - ptOnLowerLine);
  4202. dist = min(min(d1, d2), d3);
  4203. }
  4204. vec4 outsideColor = vec4(0.0);
  4205. vec4 currentColor = mix(outsideColor, color, clamp(s + t, 0.0, 1.0));
  4206. vec4 outColor = czm_antialias(outsideColor, color, currentColor, dist);
  4207. outColor = czm_gammaCorrect(outColor);
  4208. material.diffuse = outColor.rgb;
  4209. material.alpha = outColor.a;
  4210. return material;
  4211. }
  4212. `;var P$t=y(x(),1),x1=`uniform vec4 color;
  4213. uniform vec4 gapColor;
  4214. uniform float dashLength;
  4215. uniform float dashPattern;
  4216. in float v_polylineAngle;
  4217. const float maskLength = 16.0;
  4218. mat2 rotate(float rad) {
  4219. float c = cos(rad);
  4220. float s = sin(rad);
  4221. return mat2(
  4222. c, s,
  4223. -s, c
  4224. );
  4225. }
  4226. czm_material czm_getMaterial(czm_materialInput materialInput)
  4227. {
  4228. czm_material material = czm_getDefaultMaterial(materialInput);
  4229. vec2 pos = rotate(v_polylineAngle) * gl_FragCoord.xy;
  4230. // Get the relative position within the dash from 0 to 1
  4231. float dashPosition = fract(pos.x / (dashLength * czm_pixelRatio));
  4232. // Figure out the mask index.
  4233. float maskIndex = floor(dashPosition * maskLength);
  4234. // Test the bit mask.
  4235. float maskTest = floor(dashPattern / pow(2.0, maskIndex));
  4236. vec4 fragColor = (mod(maskTest, 2.0) < 1.0) ? gapColor : color;
  4237. if (fragColor.a < 0.005) { // matches 0/255 and 1/255
  4238. discard;
  4239. }
  4240. fragColor = czm_gammaCorrect(fragColor);
  4241. material.emission = fragColor.rgb;
  4242. material.alpha = fragColor.a;
  4243. return material;
  4244. }
  4245. `;var Y$t=y(x(),1),C1=`uniform vec4 color;
  4246. uniform float glowPower;
  4247. uniform float taperPower;
  4248. czm_material czm_getMaterial(czm_materialInput materialInput)
  4249. {
  4250. czm_material material = czm_getDefaultMaterial(materialInput);
  4251. vec2 st = materialInput.st;
  4252. float glow = glowPower / abs(st.t - 0.5) - (glowPower / 0.5);
  4253. if (taperPower <= 0.99999) {
  4254. glow *= min(1.0, taperPower / (0.5 - st.s * 0.5) - (taperPower / 0.5));
  4255. }
  4256. vec4 fragColor;
  4257. fragColor.rgb = max(vec3(glow - 1.0 + color.rgb), color.rgb);
  4258. fragColor.a = clamp(0.0, 1.0, glow) * color.a;
  4259. fragColor = czm_gammaCorrect(fragColor);
  4260. material.emission = fragColor.rgb;
  4261. material.alpha = fragColor.a;
  4262. return material;
  4263. }
  4264. `;var v$t=y(x(),1),T1=`uniform vec4 color;
  4265. uniform vec4 outlineColor;
  4266. uniform float outlineWidth;
  4267. in float v_width;
  4268. czm_material czm_getMaterial(czm_materialInput materialInput)
  4269. {
  4270. czm_material material = czm_getDefaultMaterial(materialInput);
  4271. vec2 st = materialInput.st;
  4272. float halfInteriorWidth = 0.5 * (v_width - outlineWidth) / v_width;
  4273. float b = step(0.5 - halfInteriorWidth, st.t);
  4274. b *= 1.0 - step(0.5 + halfInteriorWidth, st.t);
  4275. // Find the distance from the closest separator (region between two colors)
  4276. float d1 = abs(st.t - (0.5 - halfInteriorWidth));
  4277. float d2 = abs(st.t - (0.5 + halfInteriorWidth));
  4278. float dist = min(d1, d2);
  4279. vec4 currentColor = mix(outlineColor, color, b);
  4280. vec4 outColor = czm_antialias(outlineColor, color, currentColor, dist);
  4281. outColor = czm_gammaCorrect(outColor);
  4282. material.diffuse = outColor.rgb;
  4283. material.alpha = outColor.a;
  4284. return material;
  4285. }
  4286. `;var D$t=y(x(),1),E1=`uniform vec4 color;
  4287. uniform vec4 rimColor;
  4288. uniform float width;
  4289. czm_material czm_getMaterial(czm_materialInput materialInput)
  4290. {
  4291. czm_material material = czm_getDefaultMaterial(materialInput);
  4292. // See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html
  4293. float d = 1.0 - dot(materialInput.normalEC, normalize(materialInput.positionToEyeEC));
  4294. float s = smoothstep(1.0 - width, 1.0, d);
  4295. vec4 outColor = czm_gammaCorrect(color);
  4296. vec4 outRimColor = czm_gammaCorrect(rimColor);
  4297. material.diffuse = outColor.rgb;
  4298. material.emission = outRimColor.rgb * s;
  4299. material.alpha = mix(outColor.a, outRimColor.a, s);
  4300. return material;
  4301. }
  4302. `;var Q$t=y(x(),1),S1=`uniform sampler2D image;
  4303. czm_material czm_getMaterial(czm_materialInput materialInput)
  4304. {
  4305. czm_material material = czm_getDefaultMaterial(materialInput);
  4306. vec4 rampColor = texture(image, vec2(materialInput.slope / (czm_pi / 2.0), 0.5));
  4307. rampColor = czm_gammaCorrect(rampColor);
  4308. material.diffuse = rampColor.rgb;
  4309. material.alpha = rampColor.a;
  4310. return material;
  4311. }
  4312. `;var z$t=y(x(),1),_1=`uniform vec4 evenColor;
  4313. uniform vec4 oddColor;
  4314. uniform float offset;
  4315. uniform float repeat;
  4316. uniform bool horizontal;
  4317. czm_material czm_getMaterial(czm_materialInput materialInput)
  4318. {
  4319. czm_material material = czm_getDefaultMaterial(materialInput);
  4320. // Based on the Stripes Fragment Shader in the Orange Book (11.1.2)
  4321. float coord = mix(materialInput.st.s, materialInput.st.t, float(horizontal));
  4322. float value = fract((coord - offset) * (repeat * 0.5));
  4323. float dist = min(value, min(abs(value - 0.5), 1.0 - value));
  4324. vec4 currentColor = mix(evenColor, oddColor, step(0.5, value));
  4325. vec4 color = czm_antialias(evenColor, oddColor, currentColor, dist);
  4326. color = czm_gammaCorrect(color);
  4327. material.diffuse = color.rgb;
  4328. material.alpha = color.a;
  4329. return material;
  4330. }
  4331. `;var J$t=y(x(),1),I1=`uniform vec4 waterColor;
  4332. uniform vec4 landColor;
  4333. czm_material czm_getMaterial(czm_materialInput materialInput)
  4334. {
  4335. czm_material material = czm_getDefaultMaterial(materialInput);
  4336. vec4 outColor = mix(landColor, waterColor, materialInput.waterMask);
  4337. outColor = czm_gammaCorrect(outColor);
  4338. material.diffuse = outColor.rgb;
  4339. material.alpha = outColor.a;
  4340. return material;
  4341. }
  4342. `;var j$t=y(x(),1),Z1=`// Thanks for the contribution Jonas
  4343. // http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog
  4344. uniform sampler2D specularMap;
  4345. uniform sampler2D normalMap;
  4346. uniform vec4 baseWaterColor;
  4347. uniform vec4 blendColor;
  4348. uniform float frequency;
  4349. uniform float animationSpeed;
  4350. uniform float amplitude;
  4351. uniform float specularIntensity;
  4352. uniform float fadeFactor;
  4353. czm_material czm_getMaterial(czm_materialInput materialInput)
  4354. {
  4355. czm_material material = czm_getDefaultMaterial(materialInput);
  4356. float time = czm_frameNumber * animationSpeed;
  4357. // fade is a function of the distance from the fragment and the frequency of the waves
  4358. float fade = max(1.0, (length(materialInput.positionToEyeEC) / 10000000000.0) * frequency * fadeFactor);
  4359. float specularMapValue = texture(specularMap, materialInput.st).r;
  4360. // note: not using directional motion at this time, just set the angle to 0.0;
  4361. vec4 noise = czm_getWaterNoise(normalMap, materialInput.st * frequency, time, 0.0);
  4362. vec3 normalTangentSpace = noise.xyz * vec3(1.0, 1.0, (1.0 / amplitude));
  4363. // fade out the normal perturbation as we move further from the water surface
  4364. normalTangentSpace.xy /= fade;
  4365. // attempt to fade out the normal perturbation as we approach non water areas (low specular map value)
  4366. normalTangentSpace = mix(vec3(0.0, 0.0, 50.0), normalTangentSpace, specularMapValue);
  4367. normalTangentSpace = normalize(normalTangentSpace);
  4368. // get ratios for alignment of the new normal vector with a vector perpendicular to the tangent plane
  4369. float tsPerturbationRatio = clamp(dot(normalTangentSpace, vec3(0.0, 0.0, 1.0)), 0.0, 1.0);
  4370. // fade out water effect as specular map value decreases
  4371. material.alpha = mix(blendColor.a, baseWaterColor.a, specularMapValue) * specularMapValue;
  4372. // base color is a blend of the water and non-water color based on the value from the specular map
  4373. // may need a uniform blend factor to better control this
  4374. material.diffuse = mix(blendColor.rgb, baseWaterColor.rgb, specularMapValue);
  4375. // diffuse highlights are based on how perturbed the normal is
  4376. material.diffuse += (0.1 * tsPerturbationRatio);
  4377. material.diffuse = material.diffuse;
  4378. material.normal = normalize(materialInput.tangentToEyeMatrix * normalTangentSpace);
  4379. material.specular = specularIntensity;
  4380. material.shininess = 10.0;
  4381. return material;
  4382. }
  4383. `;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
  4384. `;else{if(e.shaderSource+=`czm_material czm_getMaterial(czm_materialInput materialInput)
  4385. {
  4386. `,e.shaderSource+=`czm_material material = czm_getDefaultMaterial(materialInput);
  4387. `,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};
  4388. `}else o==="alpha"?e.shaderSource+=`material.alpha = ${t.alpha};
  4389. `:e.shaderSource+=`material.${o} = ${t[o]};
  4390. `}e.shaderSource+=`return material;
  4391. }
  4392. `}}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===
  4393. in vec3 v_normalEC;
  4394. in vec4 v_color;
  4395. void main()
  4396. {
  4397. vec3 positionToEyeEC = -v_positionEC;
  4398. vec3 normalEC = normalize(v_normalEC);
  4399. #ifdef FACE_FORWARD
  4400. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  4401. #endif
  4402. vec4 color = czm_gammaCorrect(v_color);
  4403. czm_materialInput materialInput;
  4404. materialInput.normalEC = normalEC;
  4405. materialInput.positionToEyeEC = positionToEyeEC;
  4406. czm_material material = czm_getDefaultMaterial(materialInput);
  4407. material.diffuse = color.rgb;
  4408. material.alpha = color.a;
  4409. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  4410. }
  4411. `;var $en=y(x(),1),G1=`in vec3 position3DHigh;
  4412. in vec3 position3DLow;
  4413. in vec3 normal;
  4414. in vec4 color;
  4415. in float batchId;
  4416. out vec3 v_positionEC;
  4417. out vec3 v_normalEC;
  4418. out vec4 v_color;
  4419. void main()
  4420. {
  4421. vec4 p = czm_computePosition();
  4422. v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
  4423. v_normalEC = czm_normal * normal; // normal in eye coordinates
  4424. v_color = color;
  4425. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  4426. }
  4427. `;var ttn=y(x(),1),Bx=`in vec4 v_color;
  4428. void main()
  4429. {
  4430. out_FragColor = czm_gammaCorrect(v_color);
  4431. }
  4432. `;var itn=y(x(),1),L1=`in vec3 position3DHigh;
  4433. in vec3 position3DLow;
  4434. in vec4 color;
  4435. in float batchId;
  4436. out vec4 v_color;
  4437. void main()
  4438. {
  4439. vec4 p = czm_computePosition();
  4440. v_color = color;
  4441. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  4442. }
  4443. `;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
  4444. in vec3 position3DLow;
  4445. in float batchId;
  4446. #ifdef EXTRUDED_GEOMETRY
  4447. in vec3 extrudeDirection;
  4448. uniform float u_globeMinimumAltitude;
  4449. #endif // EXTRUDED_GEOMETRY
  4450. #ifdef PER_INSTANCE_COLOR
  4451. out vec4 v_color;
  4452. #endif // PER_INSTANCE_COLOR
  4453. #ifdef TEXTURE_COORDINATES
  4454. #ifdef SPHERICAL
  4455. out vec4 v_sphericalExtents;
  4456. #else // SPHERICAL
  4457. out vec2 v_inversePlaneExtents;
  4458. out vec4 v_westPlane;
  4459. out vec4 v_southPlane;
  4460. #endif // SPHERICAL
  4461. out vec3 v_uvMinAndSphericalLongitudeRotation;
  4462. out vec3 v_uMaxAndInverseDistance;
  4463. out vec3 v_vMaxAndInverseDistance;
  4464. #endif // TEXTURE_COORDINATES
  4465. void main()
  4466. {
  4467. vec4 position = czm_computePosition();
  4468. #ifdef EXTRUDED_GEOMETRY
  4469. float delta = min(u_globeMinimumAltitude, czm_geometricToleranceOverMeter * length(position.xyz));
  4470. delta *= czm_sceneMode == czm_sceneMode3D ? 1.0 : 0.0;
  4471. //extrudeDirection is zero for the top layer
  4472. position = position + vec4(extrudeDirection * delta, 0.0);
  4473. #endif
  4474. #ifdef TEXTURE_COORDINATES
  4475. #ifdef SPHERICAL
  4476. v_sphericalExtents = czm_batchTable_sphericalExtents(batchId);
  4477. v_uvMinAndSphericalLongitudeRotation.z = czm_batchTable_longitudeRotation(batchId);
  4478. #else // SPHERICAL
  4479. #ifdef COLUMBUS_VIEW_2D
  4480. vec4 planes2D_high = czm_batchTable_planes2D_HIGH(batchId);
  4481. vec4 planes2D_low = czm_batchTable_planes2D_LOW(batchId);
  4482. // If the primitive is split across the IDL (planes2D_high.x > planes2D_high.w):
  4483. // - If this vertex is on the east side of the IDL (position3DLow.y > 0.0, comparison with position3DHigh may produce artifacts)
  4484. // - existing "east" is on the wrong side of the world, far away (planes2D_high/low.w)
  4485. // - so set "east" as beyond the eastmost extent of the projection (idlSplitNewPlaneHiLow)
  4486. 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));
  4487. bool idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y > 0.0;
  4488. planes2D_high.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.w);
  4489. planes2D_low.w = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.w);
  4490. // - else, if this vertex is on the west side of the IDL (position3DLow.y < 0.0)
  4491. // - existing "west" is on the wrong side of the world, far away (planes2D_high/low.x)
  4492. // - so set "west" as beyond the westmost extent of the projection (idlSplitNewPlaneHiLow)
  4493. idlSplit = planes2D_high.x > planes2D_high.w && position3DLow.y < 0.0;
  4494. idlSplitNewPlaneHiLow = vec2(WEST_MOST_X_HIGH - (EAST_MOST_X_HIGH - planes2D_high.x), WEST_MOST_X_LOW - (EAST_MOST_X_LOW - planes2D_low.x));
  4495. planes2D_high.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.x, planes2D_high.x);
  4496. planes2D_low.x = czm_branchFreeTernary(idlSplit, idlSplitNewPlaneHiLow.y, planes2D_low.x);
  4497. vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, planes2D_high.xy), vec3(0.0, planes2D_low.xy))).xyz;
  4498. 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;
  4499. 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;
  4500. #else // COLUMBUS_VIEW_2D
  4501. // 3D case has smaller "plane extents," so planes encoded as a 64 bit position and 2 vec3s for distances/direction
  4502. vec3 southWestCorner = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(czm_batchTable_southWest_HIGH(batchId), czm_batchTable_southWest_LOW(batchId))).xyz;
  4503. vec3 northWestCorner = czm_normal * czm_batchTable_northward(batchId) + southWestCorner;
  4504. vec3 southEastCorner = czm_normal * czm_batchTable_eastward(batchId) + southWestCorner;
  4505. #endif // COLUMBUS_VIEW_2D
  4506. vec3 eastWard = southEastCorner - southWestCorner;
  4507. float eastExtent = length(eastWard);
  4508. eastWard /= eastExtent;
  4509. vec3 northWard = northWestCorner - southWestCorner;
  4510. float northExtent = length(northWard);
  4511. northWard /= northExtent;
  4512. v_westPlane = vec4(eastWard, -dot(eastWard, southWestCorner));
  4513. v_southPlane = vec4(northWard, -dot(northWard, southWestCorner));
  4514. v_inversePlaneExtents = vec2(1.0 / eastExtent, 1.0 / northExtent);
  4515. #endif // SPHERICAL
  4516. vec4 uvMinAndExtents = czm_batchTable_uvMinAndExtents(batchId);
  4517. vec4 uMaxVmax = czm_batchTable_uMaxVmax(batchId);
  4518. v_uMaxAndInverseDistance = vec3(uMaxVmax.xy, uvMinAndExtents.z);
  4519. v_vMaxAndInverseDistance = vec3(uMaxVmax.zw, uvMinAndExtents.w);
  4520. v_uvMinAndSphericalLongitudeRotation.xy = uvMinAndExtents.xy;
  4521. #endif // TEXTURE_COORDINATES
  4522. #ifdef PER_INSTANCE_COLOR
  4523. v_color = czm_batchTable_color(batchId);
  4524. #endif
  4525. gl_Position = czm_depthClamp(czm_modelViewProjectionRelativeToEye * position);
  4526. }
  4527. `;var Gnn=y(x(),1),i0=`#ifdef VECTOR_TILE
  4528. uniform vec4 u_highlightColor;
  4529. #endif
  4530. void main(void)
  4531. {
  4532. #ifdef VECTOR_TILE
  4533. out_FragColor = czm_gammaCorrect(u_highlightColor);
  4534. #else
  4535. out_FragColor = vec4(1.0);
  4536. #endif
  4537. czm_writeDepthClamp();
  4538. }
  4539. `;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;
  4540. vec2 computeSt(float batchId)
  4541. {
  4542. float stepX = batchTextureStep.x;
  4543. float centerX = batchTextureStep.y;
  4544. float numberOfAttributes = float(${t});
  4545. return vec2(centerX + (batchId * numberOfAttributes * stepX), 0.5);
  4546. }
  4547. `:`uniform vec4 batchTextureStep;
  4548. uniform vec2 batchTextureDimensions;
  4549. vec2 computeSt(float batchId)
  4550. {
  4551. float stepX = batchTextureStep.x;
  4552. float centerX = batchTextureStep.y;
  4553. float stepY = batchTextureStep.z;
  4554. float centerY = batchTextureStep.w;
  4555. float numberOfAttributes = float(${t});
  4556. float xId = mod(batchId * numberOfAttributes, batchTextureDimensions.x);
  4557. float yId = floor(batchId * numberOfAttributes / batchTextureDimensions.x);
  4558. return vec2(centerX + (xId * stepX), centerY + (yId * stepY));
  4559. }
  4560. `}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)
  4561. {
  4562. vec2 st = computeSt(batchId);
  4563. st.x += batchTextureStep.x * float(${c});
  4564. `;return e._packFloats&&i.componentDatatype!==Oe.UNSIGNED_BYTE?d+=`vec4 textureValue;
  4565. textureValue.x = czm_unpackFloat(texture(batchTexture, st));
  4566. textureValue.y = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x, 0.0)));
  4567. textureValue.z = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 2.0, 0.0)));
  4568. textureValue.w = czm_unpackFloat(texture(batchTexture, st + vec2(batchTextureStep.x * 3.0, 0.0)));
  4569. `:d+=` vec4 textureValue = texture(batchTexture, st);
  4570. `,d+=` ${s} value = textureValue${a};
  4571. `,e._pixelDatatype===Oe.UNSIGNED_BYTE&&i.componentDatatype===H.UNSIGNED_BYTE&&!i.normalize?d+=`value *= 255.0;
  4572. `:e._pixelDatatype===Oe.FLOAT&&i.componentDatatype===H.UNSIGNED_BYTE&&i.normalize&&(d+=`value /= 255.0;
  4573. `),d+=` return value;
  4574. }
  4575. `,d}FA.prototype.getVertexShaderCallback=function(){let e=this._attributes;if(e.length===0)return function(i){return i};let t=`uniform highp sampler2D batchTexture;
  4576. `;t+=`${HPe(this)}
  4577. `;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}
  4578. ${t}
  4579. ${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
  4580. `),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;
  4581. `,r+=`in vec4 position;
  4582. `,s+=`${c}
  4583. {
  4584. return u_modifiedModelView * position;
  4585. }
  4586. `,t=t.replace(/czm_modelViewRelativeToEye\s+\*\s+/g,""),t=t.replace(/czm_modelViewProjectionRelativeToEye/g,"czm_projection")):n?s+=`${c}
  4587. {
  4588. return czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow);
  4589. }
  4590. `:(r+=`in vec3 ${a}2DHigh;
  4591. in vec3 ${a}2DLow;
  4592. `,s+=`${c}
  4593. {
  4594. vec4 p;
  4595. if (czm_morphTime == 1.0)
  4596. {
  4597. p = czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow);
  4598. }
  4599. else if (czm_morphTime == 0.0)
  4600. {
  4601. p = czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy);
  4602. }
  4603. else
  4604. {
  4605. p = czm_columbusViewMorph(
  4606. czm_translateRelativeToEye(${a}2DHigh.zxy, ${a}2DLow.zxy),
  4607. czm_translateRelativeToEye(${a}3DHigh, ${a}3DLow),
  4608. czm_morphTime);
  4609. }
  4610. return p;
  4611. }
  4612. `)}return[o,r,t,s].join(`
  4613. `)};Jr._appendShowToShader=function(e,t){return l(e._batchTableAttributeIndices.show)?`${ze.replaceMain(t,"czm_non_show_main")}
  4614. void main()
  4615. {
  4616. czm_non_show_main();
  4617. gl_Position *= czm_batchTable_show(batchId);
  4618. }`: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")}
  4619. out vec4 v_pickColor;
  4620. void main()
  4621. {
  4622. czm_non_pick_main();
  4623. v_pickColor = czm_batchTable_pickColor(batchId);
  4624. }`}function wae(e){return`in vec4 v_pickColor;
  4625. ${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;
  4626. `;n+="in float applyOffset;";let i=t.replace(/in\s+float\s+batchId;/g,n),o=`vec4 $1 = czm_computePosition();
  4627. `;return o+=` if (czm_sceneMode == czm_sceneMode3D)
  4628. `,o+=` {
  4629. `,o+=" $1 = $1 + vec4(czm_batchTable_offset(batchId) * applyOffset, 0.0);",o+=` }
  4630. `,o+=` else
  4631. `,o+=` {
  4632. `,o+=" $1 = $1 + vec4(czm_batchTable_offset2D(batchId) * applyOffset, 0.0);",o+=` }
  4633. `,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()
  4634. {
  4635. czm_non_distanceDisplayCondition_main();
  4636. vec2 distanceDisplayCondition = czm_batchTable_distanceDisplayCondition(batchId);
  4637. vec3 boundingSphereCenter3DHigh = czm_batchTable_boundingSphereCenter3DHigh(batchId);
  4638. vec3 boundingSphereCenter3DLow = czm_batchTable_boundingSphereCenter3DLow(batchId);
  4639. float boundingSphereRadius = czm_batchTable_boundingSphereRadius(batchId);
  4640. `;return n?o+=` vec4 centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);
  4641. `:o+=` vec3 boundingSphereCenter2DHigh = czm_batchTable_boundingSphereCenter2DHigh(batchId);
  4642. vec3 boundingSphereCenter2DLow = czm_batchTable_boundingSphereCenter2DLow(batchId);
  4643. vec4 centerRTE;
  4644. if (czm_morphTime == 1.0)
  4645. {
  4646. centerRTE = czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow);
  4647. }
  4648. else if (czm_morphTime == 0.0)
  4649. {
  4650. centerRTE = czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy);
  4651. }
  4652. else
  4653. {
  4654. centerRTE = czm_columbusViewMorph(
  4655. czm_translateRelativeToEye(boundingSphereCenter2DHigh.zxy, boundingSphereCenter2DLow.zxy),
  4656. czm_translateRelativeToEye(boundingSphereCenter3DHigh, boundingSphereCenter3DLow),
  4657. czm_morphTime);
  4658. }
  4659. `,o+=` float radiusSq = boundingSphereRadius * boundingSphereRadius;
  4660. float distanceSq;
  4661. if (czm_sceneMode == czm_sceneMode2D)
  4662. {
  4663. distanceSq = czm_eyeHeight2D.y - radiusSq;
  4664. }
  4665. else
  4666. {
  4667. distanceSq = dot(centerRTE.xyz, centerRTE.xyz) - radiusSq;
  4668. }
  4669. distanceSq = max(distanceSq, 0.0);
  4670. float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;
  4671. float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;
  4672. float show = (distanceSq >= nearSq && distanceSq <= farSq) ? 1.0 : 0.0;
  4673. gl_Position *= show;
  4674. }`,`${i}
  4675. ${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;
  4676. `;let f=s>1?`${c}.x`:c;h+=` st = czm_decompressTextureCoordinates(${f});
  4677. `}n&&o&&r?(u+=`vec3 normal;
  4678. vec3 tangent;
  4679. vec3 bitangent;
  4680. `,h+=` czm_octDecode(${c}.${i?"yz":"xy"}, normal, tangent, bitangent);
  4681. `):(n&&(u+=`vec3 normal;
  4682. `,h+=` normal = czm_octDecode(${c}${s>1?`.${i?"y":"x"}`:""});
  4683. `),o&&(u+=`vec3 tangent;
  4684. `,h+=` tangent = czm_octDecode(${c}.${i&&n?"z":"y"});
  4685. `),r&&(u+=`vec3 bitangent;
  4686. `,h+=` bitangent = czm_octDecode(${c}.${i&&n?"z":"y"});
  4687. `));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()
  4688. {
  4689. ${h} czm_non_compressed_main();
  4690. }`;return[d,u,p,A].join(`
  4691. `)}function AXe(e){let t=ze.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() {
  4692. czm_non_depth_clamp_main();
  4693. gl_Position = czm_depthClamp(gl_Position);}
  4694. `,t}function gXe(e){let t=ze.replaceMain(e,"czm_non_depth_clamp_main");return t+=`void main() {
  4695. czm_non_depth_clamp_main();
  4696. #if defined(LOG_DEPTH)
  4697. czm_writeLogDepth();
  4698. #else
  4699. czm_writeDepthClamp();
  4700. #endif
  4701. }
  4702. `,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(
  4703. #ifdef SPHERICAL
  4704. in vec4 v_sphericalExtents;
  4705. #else // SPHERICAL
  4706. in vec2 v_inversePlaneExtents;
  4707. in vec4 v_westPlane;
  4708. in vec4 v_southPlane;
  4709. #endif // SPHERICAL
  4710. in vec3 v_uvMinAndSphericalLongitudeRotation;
  4711. in vec3 v_uMaxAndInverseDistance;
  4712. in vec3 v_vMaxAndInverseDistance;
  4713. #endif // TEXTURE_COORDINATES
  4714. #ifdef PER_INSTANCE_COLOR
  4715. in vec4 v_color;
  4716. #endif
  4717. #ifdef NORMAL_EC
  4718. vec3 getEyeCoordinate3FromWindowCoordinate(vec2 fragCoord, float logDepthOrDepth) {
  4719. vec4 eyeCoordinate = czm_windowToEyeCoordinates(fragCoord, logDepthOrDepth);
  4720. return eyeCoordinate.xyz / eyeCoordinate.w;
  4721. }
  4722. vec3 vectorFromOffset(vec4 eyeCoordinate, vec2 positiveOffset) {
  4723. vec2 glFragCoordXY = gl_FragCoord.xy;
  4724. // Sample depths at both offset and negative offset
  4725. float upOrRightLogDepth = czm_unpackDepth(texture(czm_globeDepthTexture, (glFragCoordXY + positiveOffset) / czm_viewport.zw));
  4726. float downOrLeftLogDepth = czm_unpackDepth(texture(czm_globeDepthTexture, (glFragCoordXY - positiveOffset) / czm_viewport.zw));
  4727. // Explicitly evaluate both paths
  4728. // Necessary for multifrustum and for edges of the screen
  4729. bvec2 upOrRightInBounds = lessThan(glFragCoordXY + positiveOffset, czm_viewport.zw);
  4730. float useUpOrRight = float(upOrRightLogDepth > 0.0 && upOrRightInBounds.x && upOrRightInBounds.y);
  4731. float useDownOrLeft = float(useUpOrRight == 0.0);
  4732. vec3 upOrRightEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY + positiveOffset, upOrRightLogDepth);
  4733. vec3 downOrLeftEC = getEyeCoordinate3FromWindowCoordinate(glFragCoordXY - positiveOffset, downOrLeftLogDepth);
  4734. return (upOrRightEC - (eyeCoordinate.xyz / eyeCoordinate.w)) * useUpOrRight + ((eyeCoordinate.xyz / eyeCoordinate.w) - downOrLeftEC) * useDownOrLeft;
  4735. }
  4736. #endif // NORMAL_EC
  4737. void main(void)
  4738. {
  4739. #ifdef REQUIRES_EC
  4740. float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw));
  4741. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
  4742. #endif
  4743. #ifdef REQUIRES_WC
  4744. vec4 worldCoordinate4 = czm_inverseView * eyeCoordinate;
  4745. vec3 worldCoordinate = worldCoordinate4.xyz / worldCoordinate4.w;
  4746. #endif
  4747. #ifdef TEXTURE_COORDINATES
  4748. vec2 uv;
  4749. #ifdef SPHERICAL
  4750. // Treat world coords as a sphere normal for spherical coordinates
  4751. vec2 sphericalLatLong = czm_approximateSphericalCoordinates(worldCoordinate);
  4752. sphericalLatLong.y += v_uvMinAndSphericalLongitudeRotation.z;
  4753. sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
  4754. uv.x = (sphericalLatLong.y - v_sphericalExtents.y) * v_sphericalExtents.w;
  4755. uv.y = (sphericalLatLong.x - v_sphericalExtents.x) * v_sphericalExtents.z;
  4756. #else // SPHERICAL
  4757. // Unpack planes and transform to eye space
  4758. uv.x = czm_planeDistance(v_westPlane, eyeCoordinate.xyz / eyeCoordinate.w) * v_inversePlaneExtents.x;
  4759. uv.y = czm_planeDistance(v_southPlane, eyeCoordinate.xyz / eyeCoordinate.w) * v_inversePlaneExtents.y;
  4760. #endif // SPHERICAL
  4761. #endif // TEXTURE_COORDINATES
  4762. #ifdef CULL_FRAGMENTS
  4763. // When classifying translucent geometry, logDepthOrDepth == 0.0
  4764. // indicates a region that should not be classified, possibly due to there
  4765. // being opaque pixels there in another buffer.
  4766. if (uv.x <= 0.0 || 1.0 <= uv.x || uv.y <= 0.0 || 1.0 <= uv.y || logDepthOrDepth == 0.0) {
  4767. discard;
  4768. }
  4769. #endif
  4770. #ifdef PICK
  4771. out_FragColor.a = 1.0; // Explicitly set the alpha, otherwise this may be discarded by ShaderSource.createPickFragmentShaderSource
  4772. #ifdef CULL_FRAGMENTS
  4773. czm_writeDepthClamp();
  4774. #endif // CULL_FRAGMENTS
  4775. #else // PICK
  4776. #ifdef NORMAL_EC
  4777. // Compute normal by sampling adjacent pixels in 2x2 block in screen space
  4778. vec3 downUp = vectorFromOffset(eyeCoordinate, vec2(0.0, 1.0));
  4779. vec3 leftRight = vectorFromOffset(eyeCoordinate, vec2(1.0, 0.0));
  4780. vec3 normalEC = normalize(cross(leftRight, downUp));
  4781. #endif
  4782. #ifdef PER_INSTANCE_COLOR
  4783. vec4 color = czm_gammaCorrect(v_color);
  4784. #ifdef FLAT
  4785. out_FragColor = color;
  4786. #else // FLAT
  4787. czm_materialInput materialInput;
  4788. materialInput.normalEC = normalEC;
  4789. materialInput.positionToEyeEC = -eyeCoordinate.xyz;
  4790. czm_material material = czm_getDefaultMaterial(materialInput);
  4791. material.diffuse = color.rgb;
  4792. material.alpha = color.a;
  4793. out_FragColor = czm_phong(normalize(-eyeCoordinate.xyz), material, czm_lightDirectionEC);
  4794. #endif // FLAT
  4795. // Premultiply alpha. Required for classification primitives on translucent globe.
  4796. out_FragColor.rgb *= out_FragColor.a;
  4797. #else // PER_INSTANCE_COLOR
  4798. // Material support.
  4799. // USES_ is distinct from REQUIRES_, because some things are dependencies of each other or
  4800. // dependencies for culling but might not actually be used by the material.
  4801. czm_materialInput materialInput;
  4802. #ifdef USES_NORMAL_EC
  4803. materialInput.normalEC = normalEC;
  4804. #endif
  4805. #ifdef USES_POSITION_TO_EYE_EC
  4806. materialInput.positionToEyeEC = -eyeCoordinate.xyz;
  4807. #endif
  4808. #ifdef USES_TANGENT_TO_EYE
  4809. materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(worldCoordinate, normalEC);
  4810. #endif
  4811. #ifdef USES_ST
  4812. // Remap texture coordinates from computed (approximately aligned with cartographic space) to the desired
  4813. // texture coordinate system, which typically forms a tight oriented bounding box around the geometry.
  4814. // Shader is provided a set of reference points for remapping.
  4815. materialInput.st.x = czm_lineDistance(v_uvMinAndSphericalLongitudeRotation.xy, v_uMaxAndInverseDistance.xy, uv) * v_uMaxAndInverseDistance.z;
  4816. materialInput.st.y = czm_lineDistance(v_uvMinAndSphericalLongitudeRotation.xy, v_vMaxAndInverseDistance.xy, uv) * v_vMaxAndInverseDistance.z;
  4817. #endif
  4818. czm_material material = czm_getMaterial(materialInput);
  4819. #ifdef FLAT
  4820. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  4821. #else // FLAT
  4822. out_FragColor = czm_phong(normalize(-eyeCoordinate.xyz), material, czm_lightDirectionEC);
  4823. #endif // FLAT
  4824. // Premultiply alpha. Required for classification primitives on translucent globe.
  4825. out_FragColor.rgb *= out_FragColor.a;
  4826. #endif // PER_INSTANCE_COLOR
  4827. czm_writeDepthClamp();
  4828. #endif // PICK
  4829. }
  4830. `;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}
  4831. ${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:
  4832. `,r=` extrudeDirection = czm_octDecode(${n}, 65535.0);
  4833. `,s=t;s=s.replace(/in\s+vec3\s+extrudeDirection;/g,""),s=ze.replaceMain(s,"czm_non_compressed_main");let a=`void main()
  4834. {
  4835. ${r} czm_non_compressed_main();
  4836. }`;return[i,o,s,a].join(`
  4837. `)}}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
  4838. in vec4 v_endPlaneNormalEcAndBatchId;
  4839. in vec4 v_rightPlaneEC; // Technically can compute distance for this here
  4840. in vec4 v_endEcAndStartEcX;
  4841. in vec4 v_texcoordNormalizationAndStartEcYZ;
  4842. #ifdef PER_INSTANCE_COLOR
  4843. in vec4 v_color;
  4844. #endif
  4845. void main(void)
  4846. {
  4847. float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));
  4848. vec3 ecStart = vec3(v_endEcAndStartEcX.w, v_texcoordNormalizationAndStartEcYZ.zw);
  4849. // Discard for sky
  4850. if (logDepthOrDepth == 0.0) {
  4851. #ifdef DEBUG_SHOW_VOLUME
  4852. out_FragColor = vec4(1.0, 0.0, 0.0, 0.5);
  4853. return;
  4854. #else // DEBUG_SHOW_VOLUME
  4855. discard;
  4856. #endif // DEBUG_SHOW_VOLUME
  4857. }
  4858. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
  4859. eyeCoordinate /= eyeCoordinate.w;
  4860. float halfMaxWidth = v_startPlaneNormalEcAndHalfWidth.w * czm_metersPerPixel(eyeCoordinate);
  4861. // Check distance of the eye coordinate against the right-facing plane
  4862. float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);
  4863. // Check eye coordinate against the mitering planes
  4864. float distanceFromStart = czm_planeDistance(v_startPlaneNormalEcAndHalfWidth.xyz, -dot(ecStart, v_startPlaneNormalEcAndHalfWidth.xyz), eyeCoordinate.xyz);
  4865. float distanceFromEnd = czm_planeDistance(v_endPlaneNormalEcAndBatchId.xyz, -dot(v_endEcAndStartEcX.xyz, v_endPlaneNormalEcAndBatchId.xyz), eyeCoordinate.xyz);
  4866. if (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) {
  4867. #ifdef DEBUG_SHOW_VOLUME
  4868. out_FragColor = vec4(1.0, 0.0, 0.0, 0.5);
  4869. return;
  4870. #else // DEBUG_SHOW_VOLUME
  4871. discard;
  4872. #endif // DEBUG_SHOW_VOLUME
  4873. }
  4874. // Check distance of the eye coordinate against start and end planes with normals in the right plane.
  4875. // For computing unskewed lengthwise texture coordinate.
  4876. // Can also be used for clipping extremely pointy miters, but in practice unnecessary because of miter breaking.
  4877. // aligned plane: cross the right plane normal with miter plane normal, then cross the result with right again to point it more "forward"
  4878. vec3 alignedPlaneNormal;
  4879. // start aligned plane
  4880. alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_startPlaneNormalEcAndHalfWidth.xyz);
  4881. alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz));
  4882. distanceFromStart = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, ecStart), eyeCoordinate.xyz);
  4883. // end aligned plane
  4884. alignedPlaneNormal = cross(v_rightPlaneEC.xyz, v_endPlaneNormalEcAndBatchId.xyz);
  4885. alignedPlaneNormal = normalize(cross(alignedPlaneNormal, v_rightPlaneEC.xyz));
  4886. distanceFromEnd = czm_planeDistance(alignedPlaneNormal, -dot(alignedPlaneNormal, v_endEcAndStartEcX.xyz), eyeCoordinate.xyz);
  4887. #ifdef PER_INSTANCE_COLOR
  4888. out_FragColor = czm_gammaCorrect(v_color);
  4889. #else // PER_INSTANCE_COLOR
  4890. // Clamp - distance to aligned planes may be negative due to mitering,
  4891. // so fragment texture coordinate might be out-of-bounds.
  4892. float s = clamp(distanceFromStart / (distanceFromStart + distanceFromEnd), 0.0, 1.0);
  4893. s = (s * v_texcoordNormalizationAndStartEcYZ.x) + v_texcoordNormalizationAndStartEcYZ.y;
  4894. float t = (widthwiseDistance + halfMaxWidth) / (2.0 * halfMaxWidth);
  4895. czm_materialInput materialInput;
  4896. materialInput.s = s;
  4897. materialInput.st = vec2(s, t);
  4898. materialInput.str = vec3(s, t, 0.0);
  4899. czm_material material = czm_getMaterial(materialInput);
  4900. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  4901. #endif // PER_INSTANCE_COLOR
  4902. // Premultiply alpha. Required for classification primitives on translucent globe.
  4903. out_FragColor.rgb *= out_FragColor.a;
  4904. czm_writeDepthClamp();
  4905. }
  4906. `;var qsn=y(x(),1),D1=`in vec3 v_forwardDirectionEC;
  4907. in vec3 v_texcoordNormalizationAndHalfWidth;
  4908. in float v_batchId;
  4909. #ifdef PER_INSTANCE_COLOR
  4910. in vec4 v_color;
  4911. #else
  4912. in vec2 v_alignedPlaneDistances;
  4913. in float v_texcoordT;
  4914. #endif
  4915. float rayPlaneDistanceUnsafe(vec3 origin, vec3 direction, vec3 planeNormal, float planeDistance) {
  4916. // We don't expect the ray to ever be parallel to the plane
  4917. return (-planeDistance - dot(planeNormal, origin)) / dot(planeNormal, direction);
  4918. }
  4919. void main(void)
  4920. {
  4921. vec4 eyeCoordinate = gl_FragCoord;
  4922. eyeCoordinate /= eyeCoordinate.w;
  4923. #ifdef PER_INSTANCE_COLOR
  4924. out_FragColor = czm_gammaCorrect(v_color);
  4925. #else // PER_INSTANCE_COLOR
  4926. // Use distances for planes aligned with segment to prevent skew in dashing
  4927. float distanceFromStart = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, -v_forwardDirectionEC, v_forwardDirectionEC.xyz, v_alignedPlaneDistances.x);
  4928. float distanceFromEnd = rayPlaneDistanceUnsafe(eyeCoordinate.xyz, v_forwardDirectionEC, -v_forwardDirectionEC.xyz, v_alignedPlaneDistances.y);
  4929. // Clamp - distance to aligned planes may be negative due to mitering
  4930. distanceFromStart = max(0.0, distanceFromStart);
  4931. distanceFromEnd = max(0.0, distanceFromEnd);
  4932. float s = distanceFromStart / (distanceFromStart + distanceFromEnd);
  4933. s = (s * v_texcoordNormalizationAndHalfWidth.x) + v_texcoordNormalizationAndHalfWidth.y;
  4934. czm_materialInput materialInput;
  4935. materialInput.s = s;
  4936. materialInput.st = vec2(s, v_texcoordT);
  4937. materialInput.str = vec3(s, v_texcoordT, 0.0);
  4938. czm_material material = czm_getMaterial(materialInput);
  4939. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  4940. #endif // PER_INSTANCE_COLOR
  4941. }
  4942. `;var ean=y(x(),1),k1=`in vec3 position3DHigh;
  4943. in vec3 position3DLow;
  4944. in vec4 startHiAndForwardOffsetX;
  4945. in vec4 startLoAndForwardOffsetY;
  4946. in vec4 startNormalAndForwardOffsetZ;
  4947. in vec4 endNormalAndTextureCoordinateNormalizationX;
  4948. in vec4 rightNormalAndTextureCoordinateNormalizationY;
  4949. in vec4 startHiLo2D;
  4950. in vec4 offsetAndRight2D;
  4951. in vec4 startEndNormals2D;
  4952. in vec2 texcoordNormalization2D;
  4953. in float batchId;
  4954. out vec3 v_forwardDirectionEC;
  4955. out vec3 v_texcoordNormalizationAndHalfWidth;
  4956. out float v_batchId;
  4957. // For materials
  4958. #ifdef WIDTH_VARYING
  4959. out float v_width;
  4960. #endif
  4961. #ifdef ANGLE_VARYING
  4962. out float v_polylineAngle;
  4963. #endif
  4964. #ifdef PER_INSTANCE_COLOR
  4965. out vec4 v_color;
  4966. #else
  4967. out vec2 v_alignedPlaneDistances;
  4968. out float v_texcoordT;
  4969. #endif
  4970. // Morphing planes using SLERP or NLERP doesn't seem to work, so instead draw the material directly on the shadow volume.
  4971. // Morph views are from very far away and aren't meant to be used precisely, so this should be sufficient.
  4972. void main()
  4973. {
  4974. v_batchId = batchId;
  4975. // Start position
  4976. vec4 posRelativeToEye2D = czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw));
  4977. vec4 posRelativeToEye3D = czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz);
  4978. vec4 posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime);
  4979. vec3 posEc2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz;
  4980. vec3 posEc3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz;
  4981. vec3 startEC = (czm_modelViewRelativeToEye * posRelativeToEye).xyz;
  4982. // Start plane
  4983. vec4 startPlane2D;
  4984. vec4 startPlane3D;
  4985. startPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy);
  4986. startPlane3D.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz;
  4987. startPlane2D.w = -dot(startPlane2D.xyz, posEc2D);
  4988. startPlane3D.w = -dot(startPlane3D.xyz, posEc3D);
  4989. // Right plane
  4990. vec4 rightPlane2D;
  4991. vec4 rightPlane3D;
  4992. rightPlane2D.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw);
  4993. rightPlane3D.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz;
  4994. rightPlane2D.w = -dot(rightPlane2D.xyz, posEc2D);
  4995. rightPlane3D.w = -dot(rightPlane3D.xyz, posEc3D);
  4996. // End position
  4997. posRelativeToEye2D = posRelativeToEye2D + vec4(0.0, offsetAndRight2D.xy, 0.0);
  4998. posRelativeToEye3D = posRelativeToEye3D + vec4(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w, 0.0);
  4999. posRelativeToEye = czm_columbusViewMorph(posRelativeToEye2D, posRelativeToEye3D, czm_morphTime);
  5000. posEc2D = (czm_modelViewRelativeToEye * posRelativeToEye2D).xyz;
  5001. posEc3D = (czm_modelViewRelativeToEye * posRelativeToEye3D).xyz;
  5002. vec3 endEC = (czm_modelViewRelativeToEye * posRelativeToEye).xyz;
  5003. vec3 forwardEc3D = czm_normal * normalize(vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w));
  5004. vec3 forwardEc2D = czm_normal * normalize(vec3(0.0, offsetAndRight2D.xy));
  5005. // End plane
  5006. vec4 endPlane2D;
  5007. vec4 endPlane3D;
  5008. endPlane2D.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw);
  5009. endPlane3D.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz;
  5010. endPlane2D.w = -dot(endPlane2D.xyz, posEc2D);
  5011. endPlane3D.w = -dot(endPlane3D.xyz, posEc3D);
  5012. // Forward direction
  5013. v_forwardDirectionEC = normalize(endEC - startEC);
  5014. vec2 cleanTexcoordNormalization2D;
  5015. cleanTexcoordNormalization2D.x = abs(texcoordNormalization2D.x);
  5016. cleanTexcoordNormalization2D.y = czm_branchFreeTernary(texcoordNormalization2D.y > 1.0, 0.0, abs(texcoordNormalization2D.y));
  5017. vec2 cleanTexcoordNormalization3D;
  5018. cleanTexcoordNormalization3D.x = abs(endNormalAndTextureCoordinateNormalizationX.w);
  5019. cleanTexcoordNormalization3D.y = rightNormalAndTextureCoordinateNormalizationY.w;
  5020. cleanTexcoordNormalization3D.y = czm_branchFreeTernary(cleanTexcoordNormalization3D.y > 1.0, 0.0, abs(cleanTexcoordNormalization3D.y));
  5021. v_texcoordNormalizationAndHalfWidth.xy = mix(cleanTexcoordNormalization2D, cleanTexcoordNormalization3D, czm_morphTime);
  5022. #ifdef PER_INSTANCE_COLOR
  5023. v_color = czm_batchTable_color(batchId);
  5024. #else // PER_INSTANCE_COLOR
  5025. // For computing texture coordinates
  5026. v_alignedPlaneDistances.x = -dot(v_forwardDirectionEC, startEC);
  5027. v_alignedPlaneDistances.y = -dot(-v_forwardDirectionEC, endEC);
  5028. #endif // PER_INSTANCE_COLOR
  5029. #ifdef WIDTH_VARYING
  5030. float width = czm_batchTable_width(batchId);
  5031. float halfWidth = width * 0.5;
  5032. v_width = width;
  5033. v_texcoordNormalizationAndHalfWidth.z = halfWidth;
  5034. #else
  5035. float halfWidth = 0.5 * czm_batchTable_width(batchId);
  5036. v_texcoordNormalizationAndHalfWidth.z = halfWidth;
  5037. #endif
  5038. // Compute a normal along which to "push" the position out, extending the miter depending on view distance.
  5039. // Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes.
  5040. // Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be.
  5041. // Since this is morphing, compute both 3D and 2D positions and then blend.
  5042. // ****** 3D ******
  5043. // Check distance to the end plane and start plane, pick the plane that is closer
  5044. vec4 positionEc3D = czm_modelViewRelativeToEye * czm_translateRelativeToEye(position3DHigh, position3DLow); // w = 1.0, see czm_computePosition
  5045. float absStartPlaneDistance = abs(czm_planeDistance(startPlane3D, positionEc3D.xyz));
  5046. float absEndPlaneDistance = abs(czm_planeDistance(endPlane3D, positionEc3D.xyz));
  5047. vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlane3D.xyz, endPlane3D.xyz);
  5048. vec3 upOrDown = normalize(cross(rightPlane3D.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane.
  5049. vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too.
  5050. // Nudge the top vertex upwards to prevent flickering
  5051. vec3 geodeticSurfaceNormal = normalize(cross(normalEC, forwardEc3D));
  5052. geodeticSurfaceNormal *= float(0.0 <= rightNormalAndTextureCoordinateNormalizationY.w && rightNormalAndTextureCoordinateNormalizationY.w <= 1.0);
  5053. geodeticSurfaceNormal *= MAX_TERRAIN_HEIGHT;
  5054. positionEc3D.xyz += geodeticSurfaceNormal;
  5055. // Determine if this vertex is on the "left" or "right"
  5056. normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w);
  5057. // A "perfect" implementation would push along normals according to the angle against forward.
  5058. // In practice, just pushing the normal out by halfWidth is sufficient for morph views.
  5059. positionEc3D.xyz += halfWidth * max(0.0, czm_metersPerPixel(positionEc3D)) * normalEC; // prevent artifacts when czm_metersPerPixel is negative (behind camera)
  5060. // ****** 2D ******
  5061. // Check distance to the end plane and start plane, pick the plane that is closer
  5062. vec4 positionEc2D = czm_modelViewRelativeToEye * czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy); // w = 1.0, see czm_computePosition
  5063. absStartPlaneDistance = abs(czm_planeDistance(startPlane2D, positionEc2D.xyz));
  5064. absEndPlaneDistance = abs(czm_planeDistance(endPlane2D, positionEc2D.xyz));
  5065. planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlane2D.xyz, endPlane2D.xyz);
  5066. upOrDown = normalize(cross(rightPlane2D.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane.
  5067. normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too.
  5068. // Nudge the top vertex upwards to prevent flickering
  5069. geodeticSurfaceNormal = normalize(cross(normalEC, forwardEc2D));
  5070. geodeticSurfaceNormal *= float(0.0 <= texcoordNormalization2D.y && texcoordNormalization2D.y <= 1.0);
  5071. geodeticSurfaceNormal *= MAX_TERRAIN_HEIGHT;
  5072. positionEc2D.xyz += geodeticSurfaceNormal;
  5073. // Determine if this vertex is on the "left" or "right"
  5074. normalEC *= sign(texcoordNormalization2D.x);
  5075. #ifndef PER_INSTANCE_COLOR
  5076. // Use vertex's sidedness to compute its texture coordinate.
  5077. v_texcoordT = clamp(sign(texcoordNormalization2D.x), 0.0, 1.0);
  5078. #endif
  5079. // A "perfect" implementation would push along normals according to the angle against forward.
  5080. // In practice, just pushing the normal out by halfWidth is sufficient for morph views.
  5081. positionEc2D.xyz += halfWidth * max(0.0, czm_metersPerPixel(positionEc2D)) * normalEC; // prevent artifacts when czm_metersPerPixel is negative (behind camera)
  5082. // Blend for actual position
  5083. gl_Position = czm_projection * mix(positionEc2D, positionEc3D, czm_morphTime);
  5084. #ifdef ANGLE_VARYING
  5085. // Approximate relative screen space direction of the line.
  5086. vec2 approxLineDirection = normalize(vec2(v_forwardDirectionEC.x, -v_forwardDirectionEC.y));
  5087. approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y);
  5088. v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y);
  5089. #endif
  5090. }
  5091. `;var nan=y(x(),1),Q1=`in vec3 position3DHigh;
  5092. in vec3 position3DLow;
  5093. // In 2D and in 3D, texture coordinate normalization component signs encodes:
  5094. // * X sign - sidedness relative to right plane
  5095. // * Y sign - is negative OR magnitude is greater than 1.0 if vertex is on bottom of volume
  5096. #ifndef COLUMBUS_VIEW_2D
  5097. in vec4 startHiAndForwardOffsetX;
  5098. in vec4 startLoAndForwardOffsetY;
  5099. in vec4 startNormalAndForwardOffsetZ;
  5100. in vec4 endNormalAndTextureCoordinateNormalizationX;
  5101. in vec4 rightNormalAndTextureCoordinateNormalizationY;
  5102. #else
  5103. in vec4 startHiLo2D;
  5104. in vec4 offsetAndRight2D;
  5105. in vec4 startEndNormals2D;
  5106. in vec2 texcoordNormalization2D;
  5107. #endif
  5108. in float batchId;
  5109. out vec4 v_startPlaneNormalEcAndHalfWidth;
  5110. out vec4 v_endPlaneNormalEcAndBatchId;
  5111. out vec4 v_rightPlaneEC;
  5112. out vec4 v_endEcAndStartEcX;
  5113. out vec4 v_texcoordNormalizationAndStartEcYZ;
  5114. // For materials
  5115. #ifdef WIDTH_VARYING
  5116. out float v_width;
  5117. #endif
  5118. #ifdef ANGLE_VARYING
  5119. out float v_polylineAngle;
  5120. #endif
  5121. #ifdef PER_INSTANCE_COLOR
  5122. out vec4 v_color;
  5123. #endif
  5124. void main()
  5125. {
  5126. #ifdef COLUMBUS_VIEW_2D
  5127. vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(vec3(0.0, startHiLo2D.xy), vec3(0.0, startHiLo2D.zw))).xyz;
  5128. vec3 forwardDirectionEC = czm_normal * vec3(0.0, offsetAndRight2D.xy);
  5129. vec3 ecEnd = forwardDirectionEC + ecStart;
  5130. forwardDirectionEC = normalize(forwardDirectionEC);
  5131. // Right plane
  5132. v_rightPlaneEC.xyz = czm_normal * vec3(0.0, offsetAndRight2D.zw);
  5133. v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);
  5134. // start plane
  5135. vec4 startPlaneEC;
  5136. startPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.xy);
  5137. startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);
  5138. // end plane
  5139. vec4 endPlaneEC;
  5140. endPlaneEC.xyz = czm_normal * vec3(0.0, startEndNormals2D.zw);
  5141. endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);
  5142. v_texcoordNormalizationAndStartEcYZ.x = abs(texcoordNormalization2D.x);
  5143. v_texcoordNormalizationAndStartEcYZ.y = texcoordNormalization2D.y;
  5144. #else // COLUMBUS_VIEW_2D
  5145. vec3 ecStart = (czm_modelViewRelativeToEye * czm_translateRelativeToEye(startHiAndForwardOffsetX.xyz, startLoAndForwardOffsetY.xyz)).xyz;
  5146. vec3 offset = czm_normal * vec3(startHiAndForwardOffsetX.w, startLoAndForwardOffsetY.w, startNormalAndForwardOffsetZ.w);
  5147. vec3 ecEnd = ecStart + offset;
  5148. vec3 forwardDirectionEC = normalize(offset);
  5149. // start plane
  5150. vec4 startPlaneEC;
  5151. startPlaneEC.xyz = czm_normal * startNormalAndForwardOffsetZ.xyz;
  5152. startPlaneEC.w = -dot(startPlaneEC.xyz, ecStart);
  5153. // end plane
  5154. vec4 endPlaneEC;
  5155. endPlaneEC.xyz = czm_normal * endNormalAndTextureCoordinateNormalizationX.xyz;
  5156. endPlaneEC.w = -dot(endPlaneEC.xyz, ecEnd);
  5157. // Right plane
  5158. v_rightPlaneEC.xyz = czm_normal * rightNormalAndTextureCoordinateNormalizationY.xyz;
  5159. v_rightPlaneEC.w = -dot(v_rightPlaneEC.xyz, ecStart);
  5160. v_texcoordNormalizationAndStartEcYZ.x = abs(endNormalAndTextureCoordinateNormalizationX.w);
  5161. v_texcoordNormalizationAndStartEcYZ.y = rightNormalAndTextureCoordinateNormalizationY.w;
  5162. #endif // COLUMBUS_VIEW_2D
  5163. v_endEcAndStartEcX.xyz = ecEnd;
  5164. v_endEcAndStartEcX.w = ecStart.x;
  5165. v_texcoordNormalizationAndStartEcYZ.zw = ecStart.yz;
  5166. #ifdef PER_INSTANCE_COLOR
  5167. v_color = czm_batchTable_color(batchId);
  5168. #endif // PER_INSTANCE_COLOR
  5169. // Compute a normal along which to "push" the position out, extending the miter depending on view distance.
  5170. // Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes.
  5171. // Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be.
  5172. vec4 positionRelativeToEye = czm_computePosition();
  5173. // Check distance to the end plane and start plane, pick the plane that is closer
  5174. vec4 positionEC = czm_modelViewRelativeToEye * positionRelativeToEye; // w = 1.0, see czm_computePosition
  5175. float absStartPlaneDistance = abs(czm_planeDistance(startPlaneEC, positionEC.xyz));
  5176. float absEndPlaneDistance = abs(czm_planeDistance(endPlaneEC, positionEC.xyz));
  5177. vec3 planeDirection = czm_branchFreeTernary(absStartPlaneDistance < absEndPlaneDistance, startPlaneEC.xyz, endPlaneEC.xyz);
  5178. vec3 upOrDown = normalize(cross(v_rightPlaneEC.xyz, planeDirection)); // Points "up" for start plane, "down" at end plane.
  5179. vec3 normalEC = normalize(cross(planeDirection, upOrDown)); // In practice, the opposite seems to work too.
  5180. // Extrude bottom vertices downward for far view distances, like for GroundPrimitives
  5181. upOrDown = cross(forwardDirectionEC, normalEC);
  5182. upOrDown = float(czm_sceneMode == czm_sceneMode3D) * upOrDown;
  5183. upOrDown = float(v_texcoordNormalizationAndStartEcYZ.y > 1.0 || v_texcoordNormalizationAndStartEcYZ.y < 0.0) * upOrDown;
  5184. upOrDown = min(GLOBE_MINIMUM_ALTITUDE, czm_geometricToleranceOverMeter * length(positionRelativeToEye.xyz)) * upOrDown;
  5185. positionEC.xyz += upOrDown;
  5186. v_texcoordNormalizationAndStartEcYZ.y = czm_branchFreeTernary(v_texcoordNormalizationAndStartEcYZ.y > 1.0, 0.0, abs(v_texcoordNormalizationAndStartEcYZ.y));
  5187. // Determine distance along normalEC to push for a volume of appropriate width.
  5188. // Make volumes about double pixel width for a conservative fit - in practice the
  5189. // extra cost here is minimal compared to the loose volume heights.
  5190. //
  5191. // N = normalEC (guaranteed "right-facing")
  5192. // R = rightEC
  5193. // p = angle between N and R
  5194. // w = distance to push along R if R == N
  5195. // d = distance to push along N
  5196. //
  5197. // N R
  5198. // { p| } * cos(p) = dot(N, R) = w / d
  5199. // d | |w * d = w / dot(N, R)
  5200. // { | }
  5201. // o---------- polyline segment ---->
  5202. //
  5203. float width = czm_batchTable_width(batchId);
  5204. #ifdef WIDTH_VARYING
  5205. v_width = width;
  5206. #endif
  5207. v_startPlaneNormalEcAndHalfWidth.xyz = startPlaneEC.xyz;
  5208. v_startPlaneNormalEcAndHalfWidth.w = width * 0.5;
  5209. v_endPlaneNormalEcAndBatchId.xyz = endPlaneEC.xyz;
  5210. v_endPlaneNormalEcAndBatchId.w = batchId;
  5211. width = width * max(0.0, czm_metersPerPixel(positionEC)); // width = distance to push along R
  5212. width = width / dot(normalEC, v_rightPlaneEC.xyz); // width = distance to push along N
  5213. // Determine if this vertex is on the "left" or "right"
  5214. #ifdef COLUMBUS_VIEW_2D
  5215. normalEC *= sign(texcoordNormalization2D.x);
  5216. #else
  5217. normalEC *= sign(endNormalAndTextureCoordinateNormalizationX.w);
  5218. #endif
  5219. positionEC.xyz += width * normalEC;
  5220. gl_Position = czm_depthClamp(czm_projection * positionEC);
  5221. #ifdef ANGLE_VARYING
  5222. // Approximate relative screen space direction of the line.
  5223. vec2 approxLineDirection = normalize(vec2(forwardDirectionEC.x, -forwardDirectionEC.y));
  5224. approxLineDirection.y = czm_branchFreeTernary(approxLineDirection.x == 0.0 && approxLineDirection.y == 0.0, -1.0, approxLineDirection.y);
  5225. v_polylineAngle = czm_fastApproximateAtan(approxLineDirection.x, approxLineDirection.y);
  5226. #endif
  5227. }
  5228. `;var fan=y(x(),1);var oan=y(x(),1),O1=`in vec3 position3DHigh;
  5229. in vec3 position3DLow;
  5230. in vec3 prevPosition3DHigh;
  5231. in vec3 prevPosition3DLow;
  5232. in vec3 nextPosition3DHigh;
  5233. in vec3 nextPosition3DLow;
  5234. in vec2 expandAndWidth;
  5235. in vec4 color;
  5236. in float batchId;
  5237. out vec4 v_color;
  5238. void main()
  5239. {
  5240. float expandDir = expandAndWidth.x;
  5241. float width = abs(expandAndWidth.y) + 0.5;
  5242. bool usePrev = expandAndWidth.y < 0.0;
  5243. vec4 p = czm_computePosition();
  5244. vec4 prev = czm_computePrevPosition();
  5245. vec4 next = czm_computeNextPosition();
  5246. float angle;
  5247. vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle);
  5248. gl_Position = czm_viewportOrthographic * positionWC;
  5249. v_color = color;
  5250. }
  5251. `;var san=y(x(),1),Zl=`void clipLineSegmentToNearPlane(
  5252. vec3 p0,
  5253. vec3 p1,
  5254. out vec4 positionWC,
  5255. out bool clipped,
  5256. out bool culledByNearPlane,
  5257. out vec4 clippedPositionEC)
  5258. {
  5259. culledByNearPlane = false;
  5260. clipped = false;
  5261. vec3 p0ToP1 = p1 - p0;
  5262. float magnitude = length(p0ToP1);
  5263. vec3 direction = normalize(p0ToP1);
  5264. // Distance that p0 is behind the near plane. Negative means p0 is
  5265. // in front of the near plane.
  5266. float endPoint0Distance = czm_currentFrustum.x + p0.z;
  5267. // Camera looks down -Z.
  5268. // When moving a point along +Z: LESS VISIBLE
  5269. // * Points in front of the camera move closer to the camera.
  5270. // * Points behind the camrea move farther away from the camera.
  5271. // When moving a point along -Z: MORE VISIBLE
  5272. // * Points in front of the camera move farther away from the camera.
  5273. // * Points behind the camera move closer to the camera.
  5274. // Positive denominator: -Z, becoming more visible
  5275. // Negative denominator: +Z, becoming less visible
  5276. // Nearly zero: parallel to near plane
  5277. float denominator = -direction.z;
  5278. if (endPoint0Distance > 0.0 && abs(denominator) < czm_epsilon7)
  5279. {
  5280. // p0 is behind the near plane and the line to p1 is nearly parallel to
  5281. // the near plane, so cull the segment completely.
  5282. culledByNearPlane = true;
  5283. }
  5284. else if (endPoint0Distance > 0.0)
  5285. {
  5286. // p0 is behind the near plane, and the line to p1 is moving distinctly
  5287. // toward or away from it.
  5288. // t = (-plane distance - dot(plane normal, ray origin)) / dot(plane normal, ray direction)
  5289. float t = endPoint0Distance / denominator;
  5290. if (t < 0.0 || t > magnitude)
  5291. {
  5292. // Near plane intersection is not between the two points.
  5293. // We already confirmed p0 is behind the naer plane, so now
  5294. // we know the entire segment is behind it.
  5295. culledByNearPlane = true;
  5296. }
  5297. else
  5298. {
  5299. // Segment crosses the near plane, update p0 to lie exactly on it.
  5300. p0 = p0 + t * direction;
  5301. // Numerical noise might put us a bit on the wrong side of the near plane.
  5302. // Don't let that happen.
  5303. p0.z = min(p0.z, -czm_currentFrustum.x);
  5304. clipped = true;
  5305. }
  5306. }
  5307. clippedPositionEC = vec4(p0, 1.0);
  5308. positionWC = czm_eyeToWindowCoordinates(clippedPositionEC);
  5309. }
  5310. vec4 getPolylineWindowCoordinatesEC(vec4 positionEC, vec4 prevEC, vec4 nextEC, float expandDirection, float width, bool usePrevious, out float angle)
  5311. {
  5312. // expandDirection +1 is to the _left_ when looking from positionEC toward nextEC.
  5313. #ifdef POLYLINE_DASH
  5314. // Compute the window coordinates of the points.
  5315. vec4 positionWindow = czm_eyeToWindowCoordinates(positionEC);
  5316. vec4 previousWindow = czm_eyeToWindowCoordinates(prevEC);
  5317. vec4 nextWindow = czm_eyeToWindowCoordinates(nextEC);
  5318. // Determine the relative screen space direction of the line.
  5319. vec2 lineDir;
  5320. if (usePrevious) {
  5321. lineDir = normalize(positionWindow.xy - previousWindow.xy);
  5322. }
  5323. else {
  5324. lineDir = normalize(nextWindow.xy - positionWindow.xy);
  5325. }
  5326. angle = atan(lineDir.x, lineDir.y) - 1.570796327; // precomputed atan(1,0)
  5327. // Quantize the angle so it doesn't change rapidly between segments.
  5328. angle = floor(angle / czm_piOverFour + 0.5) * czm_piOverFour;
  5329. #endif
  5330. vec4 clippedPrevWC, clippedPrevEC;
  5331. bool prevSegmentClipped, prevSegmentCulled;
  5332. clipLineSegmentToNearPlane(prevEC.xyz, positionEC.xyz, clippedPrevWC, prevSegmentClipped, prevSegmentCulled, clippedPrevEC);
  5333. vec4 clippedNextWC, clippedNextEC;
  5334. bool nextSegmentClipped, nextSegmentCulled;
  5335. clipLineSegmentToNearPlane(nextEC.xyz, positionEC.xyz, clippedNextWC, nextSegmentClipped, nextSegmentCulled, clippedNextEC);
  5336. bool segmentClipped, segmentCulled;
  5337. vec4 clippedPositionWC, clippedPositionEC;
  5338. clipLineSegmentToNearPlane(positionEC.xyz, usePrevious ? prevEC.xyz : nextEC.xyz, clippedPositionWC, segmentClipped, segmentCulled, clippedPositionEC);
  5339. if (segmentCulled)
  5340. {
  5341. return vec4(0.0, 0.0, 0.0, 1.0);
  5342. }
  5343. vec2 directionToPrevWC = normalize(clippedPrevWC.xy - clippedPositionWC.xy);
  5344. vec2 directionToNextWC = normalize(clippedNextWC.xy - clippedPositionWC.xy);
  5345. // If a segment was culled, we can't use the corresponding direction
  5346. // computed above. We should never see both of these be true without
  5347. // \`segmentCulled\` above also being true.
  5348. if (prevSegmentCulled)
  5349. {
  5350. directionToPrevWC = -directionToNextWC;
  5351. }
  5352. else if (nextSegmentCulled)
  5353. {
  5354. directionToNextWC = -directionToPrevWC;
  5355. }
  5356. vec2 thisSegmentForwardWC, otherSegmentForwardWC;
  5357. if (usePrevious)
  5358. {
  5359. thisSegmentForwardWC = -directionToPrevWC;
  5360. otherSegmentForwardWC = directionToNextWC;
  5361. }
  5362. else
  5363. {
  5364. thisSegmentForwardWC = directionToNextWC;
  5365. otherSegmentForwardWC = -directionToPrevWC;
  5366. }
  5367. vec2 thisSegmentLeftWC = vec2(-thisSegmentForwardWC.y, thisSegmentForwardWC.x);
  5368. vec2 leftWC = thisSegmentLeftWC;
  5369. float expandWidth = width * 0.5;
  5370. // When lines are split at the anti-meridian, the position may be at the
  5371. // same location as the next or previous position, and we need to handle
  5372. // that to avoid producing NaNs.
  5373. if (!czm_equalsEpsilon(prevEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1) && !czm_equalsEpsilon(nextEC.xyz - positionEC.xyz, vec3(0.0), czm_epsilon1))
  5374. {
  5375. vec2 otherSegmentLeftWC = vec2(-otherSegmentForwardWC.y, otherSegmentForwardWC.x);
  5376. vec2 leftSumWC = thisSegmentLeftWC + otherSegmentLeftWC;
  5377. float leftSumLength = length(leftSumWC);
  5378. leftWC = leftSumLength < czm_epsilon6 ? thisSegmentLeftWC : (leftSumWC / leftSumLength);
  5379. // The sine of the angle between the two vectors is given by the formula
  5380. // |a x b| = |a||b|sin(theta)
  5381. // which is
  5382. // float sinAngle = length(cross(vec3(leftWC, 0.0), vec3(-thisSegmentForwardWC, 0.0)));
  5383. // Because the z components of both vectors are zero, the x and y coordinate will be zero.
  5384. // Therefore, the sine of the angle is just the z component of the cross product.
  5385. vec2 u = -thisSegmentForwardWC;
  5386. vec2 v = leftWC;
  5387. float sinAngle = abs(u.x * v.y - u.y * v.x);
  5388. expandWidth = clamp(expandWidth / sinAngle, 0.0, width * 2.0);
  5389. }
  5390. vec2 offset = leftWC * expandDirection * expandWidth * czm_pixelRatio;
  5391. return vec4(clippedPositionWC.xy + offset, -clippedPositionWC.z, 1.0) * (czm_projection * clippedPositionEC).w;
  5392. }
  5393. vec4 getPolylineWindowCoordinates(vec4 position, vec4 previous, vec4 next, float expandDirection, float width, bool usePrevious, out float angle)
  5394. {
  5395. vec4 positionEC = czm_modelViewRelativeToEye * position;
  5396. vec4 prevEC = czm_modelViewRelativeToEye * previous;
  5397. vec4 nextEC = czm_modelViewRelativeToEye * next;
  5398. return getPolylineWindowCoordinatesEC(positionEC, prevEC, nextEC, expandDirection, width, usePrevious, angle);
  5399. }
  5400. `;var AMe=`#define CLIP_POLYLINE
  5401. ${Zl}
  5402. ${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;
  5403. in vec3 position3DLow;
  5404. in vec3 prevPosition3DHigh;
  5405. in vec3 prevPosition3DLow;
  5406. in vec3 nextPosition3DHigh;
  5407. in vec3 nextPosition3DLow;
  5408. in vec2 expandAndWidth;
  5409. in vec2 st;
  5410. in float batchId;
  5411. out float v_width;
  5412. out vec2 v_st;
  5413. out float v_polylineAngle;
  5414. void main()
  5415. {
  5416. float expandDir = expandAndWidth.x;
  5417. float width = abs(expandAndWidth.y) + 0.5;
  5418. bool usePrev = expandAndWidth.y < 0.0;
  5419. vec4 p = czm_computePosition();
  5420. vec4 prev = czm_computePrevPosition();
  5421. vec4 next = czm_computeNextPosition();
  5422. float angle;
  5423. vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, angle);
  5424. gl_Position = czm_viewportOrthographic * positionWC;
  5425. v_width = width;
  5426. v_st.s = st.s;
  5427. v_st.t = czm_writeNonPerspective(st.t, gl_Position.w);
  5428. v_polylineAngle = angle;
  5429. }
  5430. `;var ban=y(x(),1),vx=`#ifdef VECTOR_TILE
  5431. uniform vec4 u_highlightColor;
  5432. #endif
  5433. in vec2 v_st;
  5434. void main()
  5435. {
  5436. czm_materialInput materialInput;
  5437. vec2 st = v_st;
  5438. st.t = czm_readNonPerspective(st.t, gl_FragCoord.w);
  5439. materialInput.s = st.s;
  5440. materialInput.st = st;
  5441. materialInput.str = vec3(st, 0.0);
  5442. czm_material material = czm_getMaterial(materialInput);
  5443. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  5444. #ifdef VECTOR_TILE
  5445. out_FragColor *= u_highlightColor;
  5446. #endif
  5447. czm_writeLogDepth();
  5448. }
  5449. `;var bMe=`#define CLIP_POLYLINE
  5450. ${Zl}
  5451. ${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
  5452. ${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
  5453. `+_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
  5454. vec2 computeSt(float batchId)
  5455. {
  5456. float stepX = tile_textureStep.x;
  5457. float centerX = tile_textureStep.y;
  5458. return vec2(centerX + (batchId * stepX), 0.5);
  5459. }
  5460. `:`uniform vec4 tile_textureStep;
  5461. uniform vec2 tile_textureDimensions;
  5462. vec2 computeSt(float batchId)
  5463. {
  5464. float stepX = tile_textureStep.x;
  5465. float centerX = tile_textureStep.y;
  5466. float stepY = tile_textureStep.z;
  5467. float centerY = tile_textureStep.w;
  5468. float xId = mod(batchId, tile_textureDimensions.x);
  5469. float yId = floor(batchId / tile_textureDimensions.x);
  5470. return vec2(centerX + (xId * stepX), centerY + (yId * stepY));
  5471. }
  5472. `}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;
  5473. `),s+=`uniform sampler2D tile_batchTexture;
  5474. out vec4 tile_featureColor;
  5475. out vec2 tile_featureSt;
  5476. void main()
  5477. {
  5478. vec2 st = computeSt(${t});
  5479. vec4 featureProperties = texture(tile_batchTexture, st);
  5480. tile_color(featureProperties);
  5481. float show = ceil(featureProperties.a);
  5482. gl_Position *= show;
  5483. `,e&&(s+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
  5484. if (czm_pass == czm_passTranslucent)
  5485. {
  5486. if (!isStyleTranslucent && !tile_translucentCommand)
  5487. {
  5488. gl_Position *= 0.0;
  5489. }
  5490. }
  5491. else
  5492. {
  5493. if (isStyleTranslucent)
  5494. {
  5495. gl_Position *= 0.0;
  5496. }
  5497. }
  5498. `),s+=` tile_featureColor = featureProperties;
  5499. tile_featureSt = st;
  5500. }`):s=`out vec2 tile_featureSt;
  5501. void main()
  5502. {
  5503. tile_color(vec4(1.0));
  5504. tile_featureSt = computeSt(${t});
  5505. }`,`${r}
  5506. ${oUe(i)}${s}`}};function Cle(e,t){return e=ze.replaceMain(e,"tile_main"),t?`${e}uniform float tile_colorBlend;
  5507. void tile_color(vec4 tile_featureColor)
  5508. {
  5509. tile_main();
  5510. tile_featureColor = czm_gammaCorrect(tile_featureColor);
  5511. out_FragColor.a *= tile_featureColor.a;
  5512. float highlight = ceil(tile_colorBlend);
  5513. out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
  5514. }
  5515. `:`${e}void tile_color(vec4 tile_featureColor)
  5516. {
  5517. tile_main();
  5518. }
  5519. `}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)
  5520. {
  5521. return all(greaterThan(color, vec3(1.0 - czm_epsilon3)));
  5522. }
  5523. vec4 tile_diffuse_final(vec4 sourceDiffuse, vec4 tileDiffuse)
  5524. {
  5525. vec4 blendDiffuse = mix(sourceDiffuse, tileDiffuse, tile_colorBlend);
  5526. vec4 diffuse = isWhite(tileDiffuse.rgb) ? sourceDiffuse : blendDiffuse;
  5527. return vec4(diffuse.rgb, sourceDiffuse.a);
  5528. }
  5529. `,c=` tile_featureColor = czm_gammaCorrect(tile_featureColor);
  5530. out_FragColor.a *= tile_featureColor.a;
  5531. float highlight = ceil(tile_colorBlend);
  5532. out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
  5533. `,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};
  5534. tile_diffuse = tile_diffuse_final(source, tile_featureColor);
  5535. tile_main();
  5536. `}else s==="sampler2D"&&(e=rUe(e,t),d=` tile_diffuse = tile_featureColor;
  5537. tile_main();
  5538. `);return e=`uniform float tile_colorBlend;
  5539. vec4 tile_diffuse = vec4(1.0);
  5540. ${a}${r}
  5541. ${e}
  5542. void tile_color(vec4 tile_featureColor)
  5543. {
  5544. ${d}`,n&&(e+=c),e+=`}
  5545. `,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;
  5546. in vec2 tile_featureSt;
  5547. in vec4 tile_featureColor;
  5548. void main()
  5549. {
  5550. tile_color(tile_featureColor);
  5551. `,n&&(i+=` out_FragColor.rgb *= out_FragColor.a;
  5552. `),i+="}"):(e&&(i+=`uniform bool tile_translucentCommand;
  5553. `),i+=`uniform sampler2D tile_pickTexture;
  5554. uniform sampler2D tile_batchTexture;
  5555. in vec2 tile_featureSt;
  5556. void main()
  5557. {
  5558. vec4 featureProperties = texture(tile_batchTexture, tile_featureSt);
  5559. if (featureProperties.a == 0.0) {
  5560. discard;
  5561. }
  5562. `,e&&(i+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
  5563. if (czm_pass == czm_passTranslucent)
  5564. {
  5565. if (!isStyleTranslucent && !tile_translucentCommand)
  5566. {
  5567. discard;
  5568. }
  5569. }
  5570. else
  5571. {
  5572. if (isStyleTranslucent)
  5573. {
  5574. discard;
  5575. }
  5576. }
  5577. `),i+=` tile_color(featureProperties);
  5578. `,n&&(i+=` out_FragColor.rgb *= out_FragColor.a;
  5579. `),i+=`}
  5580. `),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
  5581. in float a_batchId;
  5582. uniform mat4 u_modifiedModelViewProjection;
  5583. void main()
  5584. {
  5585. gl_Position = czm_depthClamp(u_modifiedModelViewProjection * vec4(position, 1.0));
  5586. }
  5587. `;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
  5588. `;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
  5589. {
  5590. return ${o};
  5591. }
  5592. `,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
  5593. {
  5594. czm_non_pick_main();
  5595. out_FragColor = ${o};
  5596. }
  5597. `,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}
  5598. void main()
  5599. {
  5600. czm_non_pick_main();
  5601. out_FragColor = ${o};
  5602. }
  5603. `;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
  5604. ${n.message}`);let i=new me(t);return l(n)&&(i.stack=`Original stack:
  5605. ${n.stack}
  5606. Handler stack:
  5607. ${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
  5608. ${n.message}`);let o=new me(i);return l(n)&&(o.stack=`Original stack:
  5609. ${n.stack}
  5610. Handler stack:
  5611. ${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.
  5612. `,Ln&&(pn+=`var destructors = [];
  5613. `);var Is=Ln?"destructors":"null",Kd="humanName throwBindingError invoker fn runDestructors fromRetWire toClassParamWire".split(" ");for(Wt&&(pn+=`var thisWired = toClassParamWire(${Is}, this);
  5614. `),pt=0;pt<je;++pt){var Al=`toArg${pt}Wire`;pn+=`var arg${pt}Wired = ${Al}(${Is}, arg${pt});
  5615. `,Kd.push(Al)}if(pn+=(Se||Zt?"var rv = ":"")+`invoker(${Jn});
  5616. `,Ln)pn+=`runDestructors(destructors);
  5617. `;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});
  5618. `,Kd.push(`${Zt}_dtor`));return Se&&(pn+=`var ret = fromRetWire(rv);
  5619. return ret;
  5620. `),oe=new Function(Kd,pn+`}
  5621. `)(...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
  5622. ${Wt}
  5623. }`,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
  5624. uniform int u_polygonsLength;
  5625. uniform int u_extentsLength;
  5626. uniform highp sampler2D u_polygonTexture;
  5627. uniform highp sampler2D u_extentsTexture;
  5628. int getPolygonIndex(float dimension, vec2 coord) {
  5629. vec2 uv = coord.xy * dimension;
  5630. return int(floor(uv.y) * dimension + floor(uv.x));
  5631. }
  5632. vec2 getLookupUv(ivec2 dimensions, int i) {
  5633. int pixY = i / dimensions.x;
  5634. int pixX = i - (pixY * dimensions.x);
  5635. float pixelWidth = 1.0 / float(dimensions.x);
  5636. float pixelHeight = 1.0 / float(dimensions.y);
  5637. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  5638. float v = (float(pixY) + 0.5) * pixelHeight;
  5639. return vec2(u, v);
  5640. }
  5641. vec4 getExtents(int i) {
  5642. return texture(u_extentsTexture, getLookupUv(textureSize(u_extentsTexture, 0), i));
  5643. }
  5644. ivec2 getPositionsLengthAndExtentsIndex(int i) {
  5645. vec2 uv = getLookupUv(textureSize(u_polygonTexture, 0), i);
  5646. vec4 value = texture(u_polygonTexture, uv);
  5647. return ivec2(int(value.x), int(value.y));
  5648. }
  5649. vec2 getPolygonPosition(int i) {
  5650. vec2 uv = getLookupUv(textureSize(u_polygonTexture, 0), i);
  5651. return texture(u_polygonTexture, uv).xy;
  5652. }
  5653. vec2 getCoordinates(vec2 textureCoordinates, vec4 extents) {
  5654. float latitude = mix(extents.x, extents.x + 1.0 / extents.z, textureCoordinates.y);
  5655. float longitude = mix(extents.y, extents.y + 1.0 / extents.w, textureCoordinates.x);
  5656. return vec2(latitude, longitude);
  5657. }
  5658. void main() {
  5659. int lastPolygonIndex = 0;
  5660. out_FragColor = vec4(1.0);
  5661. // Get the relevant region of the texture
  5662. float dimension = float(u_extentsLength);
  5663. if (u_extentsLength > 2) {
  5664. dimension = ceil(log2(float(u_extentsLength)));
  5665. }
  5666. int regionIndex = getPolygonIndex(dimension, v_textureCoordinates);
  5667. if (regionIndex >= u_extentsLength) {
  5668. return; // done (no polygons in this region)
  5669. }
  5670. for (int polygonIndex = 0; polygonIndex < u_polygonsLength; polygonIndex++) {
  5671. ivec2 positionsLengthAndExtents = getPositionsLengthAndExtentsIndex(lastPolygonIndex);
  5672. int positionsLength = positionsLengthAndExtents.x;
  5673. int polygonExtentsIndex = positionsLengthAndExtents.y;
  5674. lastPolygonIndex += 1;
  5675. // Read the individual polygon extent (2 pixels: south/west, latRange/lonRange)
  5676. vec2 extentsSouthWest = getPolygonPosition(lastPolygonIndex);
  5677. vec2 extentsRange = getPolygonPosition(lastPolygonIndex + 1);
  5678. vec4 polygonExtent = vec4(extentsSouthWest, extentsRange);
  5679. lastPolygonIndex += 2;
  5680. if (polygonExtentsIndex < regionIndex) {
  5681. lastPolygonIndex += positionsLength;
  5682. continue; // skip to next (TODO: could optimize further if we knew how many polygons to skip)
  5683. } else if (polygonExtentsIndex > regionIndex) {
  5684. break; // done (we know polygons are sorted by regionIndex)
  5685. }
  5686. // Only compute signed distance for the relevant part of the atlas
  5687. float clipAmount = czm_infinity;
  5688. vec4 extents = getExtents(polygonExtentsIndex);
  5689. vec2 textureOffset = vec2(mod(float(polygonExtentsIndex), dimension), floor(float(polygonExtentsIndex) / dimension)) / dimension;
  5690. vec2 p = getCoordinates((v_textureCoordinates - textureOffset) * dimension, extents); // current pixel position
  5691. // Only consider polygons whos boundingbox includes current pixel (with a slight padding)
  5692. float padding = 0.05; // 5% of polygon extents
  5693. float polygonNorth = polygonExtent.x + polygonExtent.z;
  5694. float polygonEast = polygonExtent.y + polygonExtent.w;
  5695. float latPadding = padding * polygonExtent.z; // padding as fraction of latitude range
  5696. float lonPadding = padding * polygonExtent.w; // padding as fraction of longitude range
  5697. if (p.x < polygonExtent.x - latPadding || p.x > polygonNorth + latPadding ||
  5698. p.y < polygonExtent.y - lonPadding || p.y > polygonEast + lonPadding) {
  5699. lastPolygonIndex += positionsLength;
  5700. continue; // skip to next
  5701. }
  5702. float s = 1.0;
  5703. // Check each edge for absolute distance.
  5704. // Cache the previous vertex to halve the texture reads per iteration.
  5705. vec2 prev = getPolygonPosition(lastPolygonIndex + positionsLength - 1);
  5706. for (int i = 0; i < positionsLength; i++) {
  5707. vec2 a = getPolygonPosition(lastPolygonIndex + i);
  5708. vec2 b = prev;
  5709. prev = a;
  5710. vec2 ab = b - a;
  5711. vec2 pa = p - a;
  5712. float t = dot(pa, ab) / dot(ab, ab);
  5713. t = clamp(t, 0.0, 1.0);
  5714. vec2 pq = pa - t * ab;
  5715. float d = length(pq);
  5716. // Inside / outside computation to determine sign
  5717. bvec3 cond = bvec3(p.y >= a.y,
  5718. p.y < b.y,
  5719. ab.x * pa.y > ab.y * pa.x);
  5720. if (all(cond) || all(not(cond))) s = -s;
  5721. if (abs(d) < abs(clipAmount)) {
  5722. clipAmount = d;
  5723. }
  5724. }
  5725. // Normalize the range to [0,1]
  5726. vec4 result = (s * vec4(clipAmount * length(extents.zw))) / 2.0 + 0.5;
  5727. // In the case where we've iterated through multiple polygons, take the minimum
  5728. out_FragColor = min(out_FragColor, result);
  5729. lastPolygonIndex += positionsLength;
  5730. }
  5731. }`;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
  5732. in vec2 v_textureCoordinates;
  5733. float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {
  5734. float signedDistance = texture(clippingDistance, uv).r;
  5735. return (signedDistance - 0.5) * 2.0;
  5736. }
  5737. void main()
  5738. {
  5739. float dist = texture(billboard_texture, v_textureCoordinates).r;
  5740. if (dist > 0.5) {
  5741. out_FragColor = vec4(dist, 0.0, 0.0, 1.0);
  5742. } else {
  5743. out_FragColor = vec4(0.0, dist, 0.0, 1.0);
  5744. }
  5745. }
  5746. `,{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;
  5747. uniform float u_atmosphereLightIntensity;
  5748. uniform float u_atmosphereRayleighScaleHeight;
  5749. uniform float u_atmosphereMieScaleHeight;
  5750. uniform float u_atmosphereMieAnisotropy;
  5751. uniform vec3 u_atmosphereRayleighCoefficient;
  5752. uniform vec3 u_atmosphereMieCoefficient;
  5753. const float ATMOSPHERE_THICKNESS = 111e3; // The thickness of the atmosphere in meters.
  5754. const int PRIMARY_STEPS_MAX = 16; // Maximum number of times the ray from the camera to the world position (primary ray) is sampled.
  5755. 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.
  5756. /**
  5757. * This function computes the colors contributed by Rayliegh and Mie scattering on a given ray, as well as
  5758. * the transmittance value for the ray.
  5759. *
  5760. * @param {czm_ray} primaryRay The ray from the camera to the position.
  5761. * @param {float} primaryRayLength The length of the primary ray.
  5762. * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
  5763. * @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
  5764. * @param {vec3} mieColor The variable the Mie scattering will be written to.
  5765. * @param {float} opacity The variable the transmittance will be written to.
  5766. * @glslFunction
  5767. */
  5768. void computeScattering(
  5769. czm_ray primaryRay,
  5770. float primaryRayLength,
  5771. vec3 lightDirection,
  5772. float atmosphereInnerRadius,
  5773. out vec3 rayleighColor,
  5774. out vec3 mieColor,
  5775. out float opacity
  5776. ) {
  5777. // Initialize the default scattering amounts to 0.
  5778. rayleighColor = vec3(0.0);
  5779. mieColor = vec3(0.0);
  5780. opacity = 0.0;
  5781. float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
  5782. vec3 origin = vec3(0.0);
  5783. // Calculate intersection from the camera to the outer ring of the atmosphere.
  5784. czm_raySegment primaryRayAtmosphereIntersect = czm_raySphereIntersectionInterval(primaryRay, origin, atmosphereOuterRadius);
  5785. // Return empty colors if no intersection with the atmosphere geometry.
  5786. if (primaryRayAtmosphereIntersect == czm_emptyRaySegment) {
  5787. return;
  5788. }
  5789. // To deal with smaller values of PRIMARY_STEPS (e.g. 4)
  5790. // we implement a split strategy: sky or horizon.
  5791. // For performance reasons, instead of a if/else branch
  5792. // a soft choice is implemented through a weight 0.0 <= w_stop_gt_lprl <= 1.0
  5793. float x = 1e-7 * primaryRayAtmosphereIntersect.stop / length(primaryRayLength);
  5794. // Value close to 0.0: close to the horizon
  5795. // Value close to 1.0: above in the sky
  5796. float w_stop_gt_lprl = 0.5 * (1.0 + czm_approximateTanh(x));
  5797. // The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
  5798. float start_0 = primaryRayAtmosphereIntersect.start;
  5799. primaryRayAtmosphereIntersect.start = max(primaryRayAtmosphereIntersect.start, 0.0);
  5800. // The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
  5801. primaryRayAtmosphereIntersect.stop = min(primaryRayAtmosphereIntersect.stop, length(primaryRayLength));
  5802. // For the number of ray steps, distinguish inside or outside atmosphere (outer space)
  5803. // (1) from outer space we have to use more ray steps to get a realistic rendering
  5804. // (2) within atmosphere we need fewer steps for faster rendering
  5805. 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
  5806. float w_inside_atmosphere = 1.0 - 0.5 * (1.0 + czm_approximateTanh(x_o_a));
  5807. 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.
  5808. 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.
  5809. // Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
  5810. float rayPositionLength = primaryRayAtmosphereIntersect.start;
  5811. // (1) Outside the atmosphere: constant rayStepLength
  5812. // (2) Inside atmosphere: variable rayStepLength to compensate the rough rendering of the smaller number of ray steps
  5813. float totalRayLength = primaryRayAtmosphereIntersect.stop - rayPositionLength;
  5814. float rayStepLengthIncrease = w_inside_atmosphere * ((1.0 - w_stop_gt_lprl) * totalRayLength / (float(PRIMARY_STEPS * (PRIMARY_STEPS + 1)) / 2.0));
  5815. float rayStepLength = max(1.0 - w_inside_atmosphere, w_stop_gt_lprl) * totalRayLength / max(7.0 * w_inside_atmosphere, float(PRIMARY_STEPS));
  5816. vec3 rayleighAccumulation = vec3(0.0);
  5817. vec3 mieAccumulation = vec3(0.0);
  5818. vec2 opticalDepth = vec2(0.0);
  5819. vec2 heightScale = vec2(u_atmosphereRayleighScaleHeight, u_atmosphereMieScaleHeight);
  5820. // Sample positions on the primary ray.
  5821. for (int i = 0; i < PRIMARY_STEPS_MAX; ++i) {
  5822. // The loop should be: for (int i = 0; i < PRIMARY_STEPS; ++i) {...} but WebGL1 cannot
  5823. // loop with non-constant condition, so it has to break early instead
  5824. if (i >= PRIMARY_STEPS) {
  5825. break;
  5826. }
  5827. // Calculate sample position along viewpoint ray.
  5828. vec3 samplePosition = primaryRay.origin + primaryRay.direction * (rayPositionLength + rayStepLength);
  5829. // Calculate height of sample position above ellipsoid.
  5830. float sampleHeight = length(samplePosition) - atmosphereInnerRadius;
  5831. // Calculate and accumulate density of particles at the sample position.
  5832. vec2 sampleDensity = exp(-sampleHeight / heightScale) * rayStepLength;
  5833. opticalDepth += sampleDensity;
  5834. // Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
  5835. czm_ray lightRay = czm_ray(samplePosition, lightDirection);
  5836. czm_raySegment lightRayAtmosphereIntersect = czm_raySphereIntersectionInterval(lightRay, origin, atmosphereOuterRadius);
  5837. float lightStepLength = lightRayAtmosphereIntersect.stop / float(LIGHT_STEPS);
  5838. float lightPositionLength = 0.0;
  5839. vec2 lightOpticalDepth = vec2(0.0);
  5840. // Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
  5841. for (int j = 0; j < LIGHT_STEPS_MAX; ++j) {
  5842. // The loop should be: for (int j = 0; i < LIGHT_STEPS; ++j) {...} but WebGL1 cannot
  5843. // loop with non-constant condition, so it has to break early instead
  5844. if (j >= LIGHT_STEPS) {
  5845. break;
  5846. }
  5847. // Calculate sample position along light ray.
  5848. vec3 lightPosition = samplePosition + lightDirection * (lightPositionLength + lightStepLength * 0.5);
  5849. // Calculate height of the light sample position above ellipsoid.
  5850. float lightHeight = length(lightPosition) - atmosphereInnerRadius;
  5851. // Calculate density of photons at the light sample position.
  5852. lightOpticalDepth += exp(-lightHeight / heightScale) * lightStepLength;
  5853. // Increment distance on light ray.
  5854. lightPositionLength += lightStepLength;
  5855. }
  5856. // Compute attenuation via the primary ray and the light ray.
  5857. vec3 attenuation = exp(-((u_atmosphereMieCoefficient * (opticalDepth.y + lightOpticalDepth.y)) + (u_atmosphereRayleighCoefficient * (opticalDepth.x + lightOpticalDepth.x))));
  5858. // Accumulate the scattering.
  5859. rayleighAccumulation += sampleDensity.x * attenuation;
  5860. mieAccumulation += sampleDensity.y * attenuation;
  5861. // Increment distance on primary ray.
  5862. rayPositionLength += (rayStepLength += rayStepLengthIncrease);
  5863. }
  5864. // Compute the scattering amount.
  5865. rayleighColor = u_atmosphereRayleighCoefficient * rayleighAccumulation;
  5866. mieColor = u_atmosphereMieCoefficient * mieAccumulation;
  5867. // Compute the transmittance i.e. how much light is passing through the atmosphere.
  5868. opacity = length(exp(-((u_atmosphereMieCoefficient * opticalDepth.y) + (u_atmosphereRayleighCoefficient * opticalDepth.x))));
  5869. }
  5870. vec4 computeAtmosphereColor(
  5871. vec3 positionWC,
  5872. vec3 lightDirection,
  5873. vec3 rayleighColor,
  5874. vec3 mieColor,
  5875. float opacity
  5876. ) {
  5877. // Setup the primary ray: from the camera position to the vertex position.
  5878. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
  5879. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
  5880. float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
  5881. float cosAngleSq = cosAngle * cosAngle;
  5882. float G = u_atmosphereMieAnisotropy;
  5883. float GSq = G * G;
  5884. // The Rayleigh phase function.
  5885. float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
  5886. // The Mie phase function.
  5887. 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));
  5888. // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
  5889. vec3 rayleigh = rayleighPhase * rayleighColor;
  5890. vec3 mie = miePhase * mieColor;
  5891. vec3 color = (rayleigh + mie) * u_atmosphereLightIntensity;
  5892. return vec4(color, opacity);
  5893. }
  5894. `;var XZn=y(x(),1),$W=`uniform samplerCube u_radianceMap;
  5895. in vec2 v_textureCoordinates;
  5896. const float twoSqrtPi = 2.0 * sqrt(czm_pi);
  5897. // Coutesy of https://www.ppsloan.org/publications/StupidSH36.pdf
  5898. float computeShBasis(int index, vec3 s) {
  5899. if (index == 0) { // l = 0, m = 0
  5900. return 1.0 / twoSqrtPi;
  5901. }
  5902. if (index == 1) { // l = 1, m = -1
  5903. return -sqrt(3.0) * s.y / twoSqrtPi;
  5904. }
  5905. if (index == 2) { // l = 1, m = 0
  5906. return sqrt(3.0) * s.z / twoSqrtPi;
  5907. }
  5908. if (index == 3) { // l = 1, m = 1
  5909. return -sqrt(3.0) * s.x / twoSqrtPi;
  5910. }
  5911. if (index == 4) { // l = 2, m = -2
  5912. return sqrt(15.0) * s.y * s.x / twoSqrtPi;
  5913. }
  5914. if (index == 5) { // l = 2, m = -1
  5915. return -sqrt(15.0) * s.y * s.z / twoSqrtPi;
  5916. }
  5917. if (index == 6) { // l = 2, m = 0
  5918. return sqrt(5.0) * (3.0 * s.z * s.z - 1.0) / 2.0 / twoSqrtPi;
  5919. }
  5920. if (index == 7) { // l = 2, m = 1
  5921. return -sqrt(15.0) * s.x * s.z / twoSqrtPi;
  5922. }
  5923. if (index == 8) { // l = 2, m = 2
  5924. return sqrt(15.0) * (s.x * s.x - s.y * s.y) / 2.0 / twoSqrtPi;
  5925. }
  5926. return 0.0;
  5927. }
  5928. float vdcRadicalInverse(int i)
  5929. {
  5930. float r;
  5931. float base = 2.0;
  5932. float value = 0.0;
  5933. float invBase = 1.0 / base;
  5934. float invBi = invBase;
  5935. for (int x = 0; x < 100; x++)
  5936. {
  5937. if (i <= 0)
  5938. {
  5939. break;
  5940. }
  5941. r = mod(float(i), base);
  5942. value += r * invBi;
  5943. invBi *= invBase;
  5944. i = int(float(i) * invBase);
  5945. }
  5946. return value;
  5947. }
  5948. vec2 hammersley2D(int i, int N)
  5949. {
  5950. return vec2(float(i) / float(N), vdcRadicalInverse(i));
  5951. }
  5952. // Sample count is relatively low for the sake of performance, but should still be enough to capture directionality needed for third-order harmonics
  5953. const int samples = 256;
  5954. const float solidAngle = 1.0 / float(samples);
  5955. void main() {
  5956. // Get the current coefficient based on the uv
  5957. vec2 uv = v_textureCoordinates.xy * 3.0;
  5958. int coefficientIndex = int(floor(uv.y) * 3.0 + floor(uv.x));
  5959. for (int i = 0; i < samples; ++i) {
  5960. vec2 xi = hammersley2D(i, samples);
  5961. float phi = czm_twoPi * xi.x;
  5962. float cosTheta = 1.0 - 2.0 * sqrt(1.0 - xi.y * xi.y);
  5963. float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
  5964. vec3 direction = normalize(vec3(sinTheta * cos(phi), cosTheta, sinTheta * sin(phi)));
  5965. // Generate the spherical harmonics basis from the direction
  5966. float Ylm = computeShBasis(coefficientIndex, direction);
  5967. vec3 lookupDirection = -direction.xyz;
  5968. lookupDirection.z = -lookupDirection.z;
  5969. vec4 color = czm_textureCube(u_radianceMap, lookupDirection, 0.0);
  5970. // Use the relevant function for this coefficient
  5971. out_FragColor += Ylm * color * solidAngle * sinTheta;
  5972. }
  5973. }
  5974. `;var MZn=y(x(),1),eF=`precision highp float;
  5975. in vec2 v_textureCoordinates;
  5976. uniform vec3 u_faceDirection; // Current cubemap face
  5977. uniform vec3 u_positionWC;
  5978. uniform mat4 u_enuToFixedFrame;
  5979. uniform vec4 u_brightnessSaturationGammaIntensity;
  5980. uniform vec4 u_groundColor; // alpha component represent albedo
  5981. vec4 getCubeMapDirection(vec2 uv, vec3 faceDir) {
  5982. vec2 scaledUV = uv * 2.0 - 1.0;
  5983. if (faceDir.x != 0.0) {
  5984. return vec4(faceDir.x, scaledUV.x * faceDir.x, -scaledUV.y, 0.0);
  5985. } else if (faceDir.y != 0.0) {
  5986. return vec4(scaledUV.x, -scaledUV.y * faceDir.y, faceDir.y, 0.0);
  5987. } else {
  5988. return vec4(scaledUV.x * faceDir.z, -faceDir.z, -scaledUV.y, 0.0);
  5989. }
  5990. }
  5991. void main() {
  5992. float height = length(u_positionWC);
  5993. float atmosphereInnerRadius = u_radiiAndDynamicAtmosphereColor.y;
  5994. float ellipsoidHeight = max(height - atmosphereInnerRadius, 0.0);
  5995. // Scale the position to ensure the sky color is present, even when underground.
  5996. vec3 positionWC = u_positionWC / height * (ellipsoidHeight + atmosphereInnerRadius);
  5997. float atmosphereOuterRadius = u_radiiAndDynamicAtmosphereColor.x;
  5998. float atmosphereHeight = atmosphereOuterRadius - atmosphereInnerRadius;
  5999. vec3 direction = (u_enuToFixedFrame * getCubeMapDirection(v_textureCoordinates, u_faceDirection)).xyz;
  6000. vec3 normalizedDirection = normalize(direction);
  6001. czm_ray ray = czm_ray(positionWC, normalizedDirection);
  6002. czm_raySegment intersection = czm_raySphereIntersectionInterval(ray, vec3(0.0), atmosphereInnerRadius);
  6003. if (!czm_isEmpty(intersection)) {
  6004. intersection = czm_rayEllipsoidIntersectionInterval(ray, vec3(0.0), czm_ellipsoidInverseRadii);
  6005. }
  6006. bool onEllipsoid = intersection.start >= 0.0;
  6007. float rayLength = czm_branchFreeTernary(onEllipsoid, intersection.start, atmosphereOuterRadius);
  6008. // Compute sky color for each position on a sphere at radius centered around the provided position's origin
  6009. vec3 skyPositionWC = positionWC + normalizedDirection * rayLength;
  6010. float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
  6011. vec3 lightDirectionWC = normalize(czm_getDynamicAtmosphereLightDirection(skyPositionWC, lightEnum));
  6012. vec3 mieColor;
  6013. vec3 rayleighColor;
  6014. float opacity;
  6015. czm_computeScattering(
  6016. ray,
  6017. rayLength,
  6018. lightDirectionWC,
  6019. atmosphereInnerRadius,
  6020. rayleighColor,
  6021. mieColor,
  6022. opacity
  6023. );
  6024. vec4 atmopshereColor = czm_computeAtmosphereColor(ray, lightDirectionWC, rayleighColor, mieColor, opacity);
  6025. #ifdef ATMOSPHERE_COLOR_CORRECT
  6026. const bool ignoreBlackPixels = true;
  6027. atmopshereColor.rgb = czm_applyHSBShift(atmopshereColor.rgb, czm_atmosphereHsbShift, ignoreBlackPixels);
  6028. #endif
  6029. vec3 lookupDirection = -normalizedDirection;
  6030. // Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
  6031. lookupDirection.x = -lookupDirection.x;
  6032. lookupDirection = -normalize(czm_temeToPseudoFixed * lookupDirection);
  6033. lookupDirection.x = -lookupDirection.x;
  6034. // Values outside the atmopshere are rendered as black, when they should be treated as transparent
  6035. float skyAlpha = clamp((1.0 - ellipsoidHeight / atmosphereHeight) * atmopshereColor.a, 0.0, 1.0);
  6036. skyAlpha = czm_branchFreeTernary(length(atmopshereColor.rgb) <= czm_epsilon7, 0.0, skyAlpha); // Treat black as transparent
  6037. // Blend starmap with atmopshere scattering
  6038. float intensity = u_brightnessSaturationGammaIntensity.w;
  6039. vec4 sceneSkyBoxColor = czm_textureCube(czm_environmentMap, lookupDirection);
  6040. vec3 skyBackgroundColor = mix(czm_backgroundColor.rgb, sceneSkyBoxColor.rgb, sceneSkyBoxColor.a);
  6041. vec4 combinedSkyColor = vec4(mix(skyBackgroundColor, atmopshereColor.rgb * intensity, skyAlpha), 1.0);
  6042. // Compute ground color based on amount of reflected light, then blend it with ground atmosphere based on height
  6043. vec3 up = normalize(positionWC);
  6044. float occlusion = max(dot(lightDirectionWC, up), 0.05);
  6045. vec4 groundColor = vec4(u_groundColor.rgb * u_groundColor.a * (vec3(intensity * occlusion) + atmopshereColor.rgb), 1.0);
  6046. vec4 blendedGroundColor = mix(groundColor, atmopshereColor, clamp(ellipsoidHeight / atmosphereHeight, 0.0, 1.0));
  6047. vec4 color = czm_branchFreeTernary(onEllipsoid, blendedGroundColor, combinedSkyColor);
  6048. float brightness = u_brightnessSaturationGammaIntensity.x;
  6049. float saturation = u_brightnessSaturationGammaIntensity.y;
  6050. float gamma = u_brightnessSaturationGammaIntensity.z;
  6051. #ifdef ENVIRONMENT_COLOR_CORRECT
  6052. color.rgb = mix(vec3(0.0), color.rgb, brightness);
  6053. color.rgb = czm_saturation(color.rgb, saturation);
  6054. #endif
  6055. 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.
  6056. color.rgb = czm_gammaCorrect(color.rgb);
  6057. out_FragColor = color;
  6058. }
  6059. `;var UZn=y(x(),1),tF=`precision highp float;
  6060. in vec3 v_textureCoordinates;
  6061. uniform float u_roughness;
  6062. uniform samplerCube u_radianceTexture;
  6063. uniform vec3 u_faceDirection;
  6064. float vdcRadicalInverse(int i)
  6065. {
  6066. float r;
  6067. float base = 2.0;
  6068. float value = 0.0;
  6069. float invBase = 1.0 / base;
  6070. float invBi = invBase;
  6071. for (int x = 0; x < 100; x++)
  6072. {
  6073. if (i <= 0)
  6074. {
  6075. break;
  6076. }
  6077. r = mod(float(i), base);
  6078. value += r * invBi;
  6079. invBi *= invBase;
  6080. i = int(float(i) * invBase);
  6081. }
  6082. return value;
  6083. }
  6084. vec2 hammersley2D(int i, int N)
  6085. {
  6086. return vec2(float(i) / float(N), vdcRadicalInverse(i));
  6087. }
  6088. vec3 importanceSampleGGX(vec2 xi, float alphaRoughness, vec3 N)
  6089. {
  6090. float alphaRoughnessSquared = alphaRoughness * alphaRoughness;
  6091. float phi = czm_twoPi * xi.x;
  6092. float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 1.0) * xi.y));
  6093. float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
  6094. vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
  6095. vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  6096. vec3 tangentX = normalize(cross(upVector, N));
  6097. vec3 tangentY = cross(N, tangentX);
  6098. return tangentX * H.x + tangentY * H.y + N * H.z;
  6099. }
  6100. // Sample count is relatively low for the sake of performance, but should still be enough to prevent artifacting in lower roughnesses
  6101. const int samples = 128;
  6102. void main() {
  6103. vec3 normal = u_faceDirection;
  6104. vec3 V = normalize(v_textureCoordinates);
  6105. float roughness = u_roughness;
  6106. vec4 color = vec4(0.0);
  6107. float weight = 0.0;
  6108. for (int i = 0; i < samples; ++i) {
  6109. vec2 xi = hammersley2D(i, samples);
  6110. vec3 H = importanceSampleGGX(xi, roughness, V);
  6111. vec3 L = 2.0 * dot(V, H) * H - V; // reflected vector
  6112. float NdotL = max(dot(V, L), 0.0);
  6113. if (NdotL > 0.0) {
  6114. color += vec4(czm_textureCube(u_radianceTexture, L).rgb, 1.0) * NdotL;
  6115. weight += NdotL;
  6116. }
  6117. }
  6118. out_FragColor = color / weight;
  6119. }
  6120. `;var kZn=y(x(),1),nF=`in vec3 position;
  6121. out vec3 v_textureCoordinates;
  6122. uniform vec3 u_faceDirection;
  6123. vec3 getCubeMapDirection(vec2 uv, vec3 faceDir) {
  6124. vec2 scaledUV = uv;
  6125. if (faceDir.x != 0.0) {
  6126. return vec3(faceDir.x, scaledUV.y, scaledUV.x * faceDir.x);
  6127. } else if (faceDir.y != 0.0) {
  6128. return vec3(scaledUV.x, -faceDir.y, -scaledUV.y * faceDir.y);
  6129. } else {
  6130. return vec3(scaledUV.x * faceDir.z, scaledUV.y, -faceDir.z);
  6131. }
  6132. }
  6133. void main()
  6134. {
  6135. v_textureCoordinates = getCubeMapDirection(position.xy, u_faceDirection);
  6136. v_textureCoordinates.y = -v_textureCoordinates.y;
  6137. v_textureCoordinates.z = -v_textureCoordinates.z;
  6138. gl_Position = vec4(position, 1.0);
  6139. }
  6140. `;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.
  6141. uniform sampler2D u_pointCloud_depthGBuffer;
  6142. uniform vec2 u_distanceAndEdlStrength;
  6143. in vec2 v_textureCoordinates;
  6144. vec2 neighborContribution(float log2Depth, vec2 offset)
  6145. {
  6146. float dist = u_distanceAndEdlStrength.x;
  6147. vec2 texCoordOrig = v_textureCoordinates + offset * dist;
  6148. vec2 texCoord0 = v_textureCoordinates + offset * floor(dist);
  6149. vec2 texCoord1 = v_textureCoordinates + offset * ceil(dist);
  6150. float depthOrLogDepth0 = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, texCoord0));
  6151. float depthOrLogDepth1 = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, texCoord1));
  6152. // ignore depth values that are the clear depth
  6153. if (depthOrLogDepth0 == 0.0 || depthOrLogDepth1 == 0.0) {
  6154. return vec2(0.0);
  6155. }
  6156. // interpolate the two adjacent depth values
  6157. float depthMix = mix(depthOrLogDepth0, depthOrLogDepth1, fract(dist));
  6158. vec4 eyeCoordinate = czm_windowToEyeCoordinates(texCoordOrig, depthMix);
  6159. return vec2(max(0.0, log2Depth - log2(-eyeCoordinate.z / eyeCoordinate.w)), 1.0);
  6160. }
  6161. void main()
  6162. {
  6163. float depthOrLogDepth = czm_unpackDepth(texture(u_pointCloud_depthGBuffer, v_textureCoordinates));
  6164. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, depthOrLogDepth);
  6165. eyeCoordinate /= eyeCoordinate.w;
  6166. float log2Depth = log2(-eyeCoordinate.z);
  6167. if (depthOrLogDepth == 0.0) // 0.0 is the clear value for the gbuffer
  6168. {
  6169. discard;
  6170. }
  6171. vec4 color = texture(u_pointCloud_colorGBuffer, v_textureCoordinates);
  6172. // sample from neighbors left, right, down, up
  6173. vec2 texelSize = 1.0 / czm_viewport.zw;
  6174. vec2 responseAndCount = vec2(0.0);
  6175. responseAndCount += neighborContribution(log2Depth, vec2(-texelSize.x, 0.0));
  6176. responseAndCount += neighborContribution(log2Depth, vec2(+texelSize.x, 0.0));
  6177. responseAndCount += neighborContribution(log2Depth, vec2(0.0, -texelSize.y));
  6178. responseAndCount += neighborContribution(log2Depth, vec2(0.0, +texelSize.y));
  6179. float response = responseAndCount.x / responseAndCount.y;
  6180. float strength = u_distanceAndEdlStrength.y;
  6181. float shade = exp(-response * 300.0 * strength);
  6182. color.rgb *= shade;
  6183. out_FragColor = vec4(color);
  6184. // Input and output depth are the same.
  6185. gl_FragDepth = depthOrLogDepth;
  6186. }
  6187. `;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;
  6188. 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()
  6189. {
  6190. czm_point_cloud_post_process_main();
  6191. #ifdef LOG_DEPTH
  6192. czm_writeLogDepth();
  6193. out_FragData_1 = czm_packDepth(gl_FragDepth);
  6194. #else
  6195. out_FragData_1 = czm_packDepth(gl_FragCoord.z);
  6196. #endif
  6197. }`),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
  6198. // https://github.com/0xfaded/ellipse_demo/issues/1
  6199. // https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
  6200. //
  6201. // This version uses only a single iteration for best performance. For fog
  6202. // rendering, the difference is negligible.
  6203. vec2 nearestPointOnEllipseFast(vec2 pos, vec2 radii) {
  6204. vec2 p = abs(pos);
  6205. vec2 inverseRadii = 1.0 / radii;
  6206. vec2 evoluteScale = (radii.x * radii.x - radii.y * radii.y) * vec2(1.0, -1.0) * inverseRadii;
  6207. // We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
  6208. // but store the cos and sin of t in a vec2 for efficiency.
  6209. // Initial guess: t = cos(pi/4)
  6210. vec2 tTrigs = vec2(0.70710678118);
  6211. vec2 v = radii * tTrigs;
  6212. // Find the evolute of the ellipse (center of curvature) at v.
  6213. vec2 evolute = evoluteScale * tTrigs * tTrigs * tTrigs;
  6214. // Find the (approximate) intersection of p - evolute with the ellipsoid.
  6215. vec2 q = normalize(p - evolute) * length(v - evolute);
  6216. // Update the estimate of t.
  6217. tTrigs = (q + evolute) * inverseRadii;
  6218. tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));
  6219. v = radii * tTrigs;
  6220. return v * sign(pos);
  6221. }
  6222. vec3 computeEllipsoidPositionWC(vec3 positionMC) {
  6223. // Get the world-space position and project onto a meridian plane of
  6224. // the ellipsoid
  6225. vec3 positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
  6226. vec2 positionEllipse = vec2(length(positionWC.xy), positionWC.z);
  6227. vec2 nearestPoint = nearestPointOnEllipseFast(positionEllipse, czm_ellipsoidRadii.xz);
  6228. // Reconstruct a 3D point in world space
  6229. return vec3(nearestPoint.x * normalize(positionWC.xy), nearestPoint.y);
  6230. }
  6231. void applyFog(inout vec4 color, vec4 groundAtmosphereColor, vec3 lightDirection, float distanceToCamera) {
  6232. vec3 fogColor = groundAtmosphereColor.rgb;
  6233. // If there is dynamic lighting, apply that to the fog.
  6234. const float NONE = 0.0;
  6235. if (czm_atmosphereDynamicLighting != NONE) {
  6236. float darken = clamp(dot(normalize(czm_viewerPositionWC), lightDirection), czm_fogMinimumBrightness, 1.0);
  6237. fogColor *= darken;
  6238. }
  6239. // Tonemap if HDR rendering is disabled
  6240. #ifndef HDR
  6241. fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);
  6242. fogColor.rgb = czm_inverseGamma(fogColor.rgb);
  6243. #endif
  6244. vec3 withFog = czm_fog(distanceToCamera, color.rgb, fogColor, czm_fogVisualDensityScalar);
  6245. color = vec4(withFog, color.a);
  6246. }
  6247. void atmosphereStage(inout vec4 color, in ProcessedAttributes attributes) {
  6248. vec3 rayleighColor;
  6249. vec3 mieColor;
  6250. float opacity;
  6251. vec3 positionWC;
  6252. vec3 lightDirection;
  6253. // When the camera is in space, compute the position per-fragment for
  6254. // more accurate ground atmosphere. All other cases will use
  6255. //
  6256. // The if condition will be added in https://github.com/CesiumGS/cesium/issues/11717
  6257. if (false) {
  6258. positionWC = computeEllipsoidPositionWC(attributes.positionMC);
  6259. lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);
  6260. // The fog color is derived from the ground atmosphere color
  6261. czm_computeGroundAtmosphereScattering(
  6262. positionWC,
  6263. lightDirection,
  6264. rayleighColor,
  6265. mieColor,
  6266. opacity
  6267. );
  6268. } else {
  6269. positionWC = attributes.positionWC;
  6270. lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC, czm_atmosphereDynamicLighting);
  6271. rayleighColor = v_atmosphereRayleighColor;
  6272. mieColor = v_atmosphereMieColor;
  6273. opacity = v_atmosphereOpacity;
  6274. }
  6275. //color correct rayleigh and mie colors
  6276. const bool ignoreBlackPixels = true;
  6277. rayleighColor = czm_applyHSBShift(rayleighColor, czm_atmosphereHsbShift, ignoreBlackPixels);
  6278. mieColor = czm_applyHSBShift(mieColor, czm_atmosphereHsbShift, ignoreBlackPixels);
  6279. vec4 groundAtmosphereColor = czm_computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
  6280. if (u_isInFog) {
  6281. float distanceToCamera = length(attributes.positionEC);
  6282. applyFog(color, groundAtmosphereColor, lightDirection, distanceToCamera);
  6283. } else {
  6284. // Ground atmosphere
  6285. }
  6286. }
  6287. `;var CBn=y(x(),1),UF=`void atmosphereStage(ProcessedAttributes attributes) {
  6288. vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_positionWC, czm_atmosphereDynamicLighting);
  6289. czm_computeGroundAtmosphereScattering(
  6290. // This assumes the geometry stage came before this.
  6291. v_positionWC,
  6292. lightDirection,
  6293. v_atmosphereRayleighColor,
  6294. v_atmosphereMieColor,
  6295. v_atmosphereOpacity
  6296. );
  6297. }
  6298. `;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_IBL
  6299. vec3 sampleDiffuseEnvironment(vec3 cubeDir)
  6300. {
  6301. #ifdef CUSTOM_SPHERICAL_HARMONICS
  6302. return czm_sphericalHarmonics(cubeDir, model_sphericalHarmonicCoefficients);
  6303. #else
  6304. return czm_sphericalHarmonics(cubeDir, czm_sphericalHarmonicCoefficients);
  6305. #endif
  6306. }
  6307. #endif
  6308. #ifdef SPECULAR_IBL
  6309. vec3 sampleSpecularEnvironment(vec3 cubeDir, float roughness)
  6310. {
  6311. #ifdef CUSTOM_SPECULAR_IBL
  6312. float lod = roughness * model_specularEnvironmentMapsMaximumLOD;
  6313. return czm_textureCube(model_specularEnvironmentMaps, cubeDir, lod).rgb;
  6314. #else
  6315. float lod = roughness * czm_specularEnvironmentMapsMaximumLOD;
  6316. return czm_textureCube(czm_specularEnvironmentMaps, cubeDir, lod).rgb;
  6317. #endif
  6318. }
  6319. vec3 computeSpecularIBL(vec3 cubeDir, float NdotV, vec3 f0, float roughness)
  6320. {
  6321. // see https://bruop.github.io/ibl/ at Single Scattering Results
  6322. // Roughness dependent fresnel, from Fdez-Aguera
  6323. vec3 f90 = max(vec3(1.0 - roughness), f0);
  6324. vec3 F = fresnelSchlick2(f0, f90, NdotV);
  6325. vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
  6326. vec3 specularSample = sampleSpecularEnvironment(cubeDir, roughness);
  6327. return specularSample * (F * brdfLut.x + brdfLut.y);
  6328. }
  6329. #endif
  6330. #if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
  6331. /**
  6332. * Compute the light contributions from environment maps and spherical harmonic coefficients.
  6333. * See Fdez-Aguera, https://www.jcgt.org/published/0008/01/03/paper.pdf, for explanation
  6334. * of the single- and multi-scattering terms.
  6335. *
  6336. * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position.
  6337. * @param {vec3} normalEC The surface normal in eye coordinates.
  6338. * @param {czm_modelMaterial} The material properties.
  6339. * @return {vec3} The computed HDR color.
  6340. */
  6341. vec3 textureIBL(vec3 viewDirectionEC, vec3 normalEC, czm_modelMaterial material) {
  6342. vec3 f0 = material.specular;
  6343. float roughness = material.roughness;
  6344. float specularWeight = 1.0;
  6345. #ifdef USE_SPECULAR
  6346. specularWeight = material.specularWeight;
  6347. #endif
  6348. float NdotV = clamp(dot(normalEC, viewDirectionEC), 0.0, 1.0);
  6349. // see https://bruop.github.io/ibl/ at Single Scattering Results
  6350. // Roughness dependent fresnel, from Fdez-Aguera
  6351. vec3 f90 = max(vec3(1.0 - roughness), f0);
  6352. vec3 singleScatterFresnel = fresnelSchlick2(f0, f90, NdotV);
  6353. vec2 brdfLut = texture(czm_brdfLut, vec2(NdotV, roughness)).rg;
  6354. vec3 FssEss = specularWeight * (singleScatterFresnel * brdfLut.x + brdfLut.y);
  6355. #ifdef DIFFUSE_IBL
  6356. vec3 normalMC = normalize(model_iblReferenceFrameMatrix * normalEC);
  6357. vec3 irradiance = sampleDiffuseEnvironment(normalMC);
  6358. vec3 averageFresnel = f0 + (1.0 - f0) / 21.0;
  6359. float Ems = specularWeight * (1.0 - brdfLut.x - brdfLut.y);
  6360. vec3 FmsEms = FssEss * averageFresnel * Ems / (1.0 - averageFresnel * Ems);
  6361. vec3 dielectricScattering = (1.0 - FssEss - FmsEms) * material.diffuse;
  6362. vec3 diffuseContribution = irradiance * (FmsEms + dielectricScattering) * model_iblFactor.x;
  6363. #else
  6364. vec3 diffuseContribution = vec3(0.0);
  6365. #endif
  6366. #ifdef USE_ANISOTROPY
  6367. // Bend normal to account for anisotropic distortion of specular reflection
  6368. vec3 anisotropyDirection = material.anisotropicB;
  6369. vec3 anisotropicTangent = cross(anisotropyDirection, viewDirectionEC);
  6370. vec3 anisotropicNormal = cross(anisotropicTangent, anisotropyDirection);
  6371. float bendFactor = 1.0 - material.anisotropyStrength * (1.0 - roughness);
  6372. float bendFactorPow4 = bendFactor * bendFactor * bendFactor * bendFactor;
  6373. vec3 bentNormal = normalize(mix(anisotropicNormal, normalEC, bendFactorPow4));
  6374. vec3 reflectEC = reflect(-viewDirectionEC, bentNormal);
  6375. #else
  6376. vec3 reflectEC = reflect(-viewDirectionEC, normalEC);
  6377. #endif
  6378. #ifdef SPECULAR_IBL
  6379. vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflectEC);
  6380. vec3 radiance = sampleSpecularEnvironment(reflectMC, roughness);
  6381. vec3 specularContribution = radiance * FssEss * model_iblFactor.y;
  6382. #else
  6383. vec3 specularContribution = vec3(0.0);
  6384. #endif
  6385. return diffuseContribution + specularContribution;
  6386. }
  6387. #endif
  6388. `;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
  6389. {
  6390. material.diffuse = mix(material.diffuse, model_color.rgb, model_colorBlend);
  6391. float highlight = ceil(model_colorBlend);
  6392. material.diffuse *= mix(model_color.rgb, vec3(1.0), highlight);
  6393. material.alpha *= model_color.a;
  6394. }
  6395. `;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_TEXTURE
  6396. vec4 getClippingPlane(
  6397. highp sampler2D packedClippingPlanes,
  6398. int clippingPlaneNumber,
  6399. mat4 transform
  6400. ) {
  6401. int pixY = clippingPlaneNumber / CLIPPING_PLANES_TEXTURE_WIDTH;
  6402. int pixX = clippingPlaneNumber - (pixY * CLIPPING_PLANES_TEXTURE_WIDTH);
  6403. float pixelWidth = 1.0 / float(CLIPPING_PLANES_TEXTURE_WIDTH);
  6404. float pixelHeight = 1.0 / float(CLIPPING_PLANES_TEXTURE_HEIGHT);
  6405. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  6406. float v = (float(pixY) + 0.5) * pixelHeight;
  6407. vec4 plane = texture(packedClippingPlanes, vec2(u, v));
  6408. return czm_transformPlane(plane, transform);
  6409. }
  6410. #else
  6411. // Handle uint8 clipping texture instead
  6412. vec4 getClippingPlane(
  6413. highp sampler2D packedClippingPlanes,
  6414. int clippingPlaneNumber,
  6415. mat4 transform
  6416. ) {
  6417. int clippingPlaneStartIndex = clippingPlaneNumber * 2; // clipping planes are two pixels each
  6418. int pixY = clippingPlaneStartIndex / CLIPPING_PLANES_TEXTURE_WIDTH;
  6419. int pixX = clippingPlaneStartIndex - (pixY * CLIPPING_PLANES_TEXTURE_WIDTH);
  6420. float pixelWidth = 1.0 / float(CLIPPING_PLANES_TEXTURE_WIDTH);
  6421. float pixelHeight = 1.0 / float(CLIPPING_PLANES_TEXTURE_HEIGHT);
  6422. float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
  6423. float v = (float(pixY) + 0.5) * pixelHeight;
  6424. vec4 oct32 = texture(packedClippingPlanes, vec2(u, v)) * 255.0;
  6425. vec2 oct = vec2(oct32.x * 256.0 + oct32.y, oct32.z * 256.0 + oct32.w);
  6426. vec4 plane;
  6427. plane.xyz = czm_octDecode(oct, 65535.0);
  6428. plane.w = czm_unpackFloat(texture(packedClippingPlanes, vec2(u + pixelWidth, v)));
  6429. return czm_transformPlane(plane, transform);
  6430. }
  6431. #endif
  6432. float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix) {
  6433. vec4 position = czm_windowToEyeCoordinates(fragCoord);
  6434. vec3 clipNormal = vec3(0.0);
  6435. vec3 clipPosition = vec3(0.0);
  6436. float pixelWidth = czm_metersPerPixel(position);
  6437. #ifdef UNION_CLIPPING_REGIONS
  6438. 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.
  6439. #else
  6440. float clipAmount = 0.0;
  6441. bool clipped = true;
  6442. #endif
  6443. for (int i = 0; i < CLIPPING_PLANES_LENGTH; ++i) {
  6444. vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
  6445. clipNormal = clippingPlane.xyz;
  6446. clipPosition = -clippingPlane.w * clipNormal;
  6447. float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
  6448. #ifdef UNION_CLIPPING_REGIONS
  6449. clipAmount = czm_branchFreeTernary(i == 0, amount, min(amount, clipAmount));
  6450. if (amount <= 0.0) {
  6451. discard;
  6452. }
  6453. #else
  6454. clipAmount = max(amount, clipAmount);
  6455. clipped = clipped && (amount <= 0.0);
  6456. #endif
  6457. }
  6458. #ifndef UNION_CLIPPING_REGIONS
  6459. if (clipped) {
  6460. discard;
  6461. }
  6462. #endif
  6463. return clipAmount;
  6464. }
  6465. void modelClippingPlanesStage(inout vec4 color)
  6466. {
  6467. float clipDistance = clip(gl_FragCoord, model_clippingPlanes, model_clippingPlanesMatrix);
  6468. vec4 clippingPlanesEdgeColor = vec4(1.0);
  6469. clippingPlanesEdgeColor.rgb = model_clippingPlanesEdgeStyle.rgb;
  6470. float clippingPlanesEdgeWidth = model_clippingPlanesEdgeStyle.a;
  6471. if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth) {
  6472. color = clippingPlanesEdgeColor;
  6473. }
  6474. }
  6475. `;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)
  6476. {
  6477. vec2 sphericalLatLong = czm_approximateSphericalCoordinates(v_positionWC);
  6478. sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
  6479. vec2 minDistance = vec2(czm_infinity);
  6480. v_regionIndex = -1;
  6481. v_clippingPosition = vec2(czm_infinity);
  6482. for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
  6483. vec4 extents = czm_unpackClippingExtents(model_clippingExtents, regionIndex);
  6484. vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
  6485. vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
  6486. vec2 distance = abs(rectUv - clamped) * extents.wz;
  6487. if (minDistance.x > distance.x || minDistance.y > distance.y) {
  6488. minDistance = distance;
  6489. v_clippingPosition = rectUv;
  6490. }
  6491. float threshold = 0.01;
  6492. if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
  6493. v_regionIndex = regionIndex;
  6494. }
  6495. }
  6496. }
  6497. `;var Cwn=y(x(),1),qF=`void modelClippingPolygonsStage()
  6498. {
  6499. vec2 clippingPosition = v_clippingPosition;
  6500. int regionIndex = v_regionIndex;
  6501. czm_clipPolygons(model_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
  6502. }
  6503. `;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()
  6504. {
  6505. mat4 instancingTransform;
  6506. #ifdef HAS_INSTANCE_MATRICES
  6507. instancingTransform = mat4(
  6508. a_instancingTransformRow0.x, a_instancingTransformRow1.x, a_instancingTransformRow2.x, 0.0, // Column 1
  6509. a_instancingTransformRow0.y, a_instancingTransformRow1.y, a_instancingTransformRow2.y, 0.0, // Column 2
  6510. a_instancingTransformRow0.z, a_instancingTransformRow1.z, a_instancingTransformRow2.z, 0.0, // Column 3
  6511. a_instancingTransformRow0.w, a_instancingTransformRow1.w, a_instancingTransformRow2.w, 1.0 // Column 4
  6512. );
  6513. #else
  6514. vec3 translation = vec3(0.0, 0.0, 0.0);
  6515. vec3 scale = vec3(1.0, 1.0, 1.0);
  6516. #ifdef HAS_INSTANCE_TRANSLATION
  6517. translation = a_instanceTranslation;
  6518. #endif
  6519. #ifdef HAS_INSTANCE_SCALE
  6520. scale = a_instanceScale;
  6521. #endif
  6522. instancingTransform = mat4(
  6523. scale.x, 0.0, 0.0, 0.0,
  6524. 0.0, scale.y, 0.0, 0.0,
  6525. 0.0, 0.0, scale.z, 0.0,
  6526. translation.x, translation.y, translation.z, 1.0
  6527. );
  6528. #endif
  6529. return instancingTransform;
  6530. }
  6531. #ifdef USE_2D_INSTANCING
  6532. mat4 getInstancingTransform2D()
  6533. {
  6534. mat4 instancingTransform2D;
  6535. #ifdef HAS_INSTANCE_MATRICES
  6536. instancingTransform2D = mat4(
  6537. a_instancingTransform2DRow0.x, a_instancingTransform2DRow1.x, a_instancingTransform2DRow2.x, 0.0, // Column 1
  6538. a_instancingTransform2DRow0.y, a_instancingTransform2DRow1.y, a_instancingTransform2DRow2.y, 0.0, // Column 2
  6539. a_instancingTransform2DRow0.z, a_instancingTransform2DRow1.z, a_instancingTransform2DRow2.z, 0.0, // Column 3
  6540. a_instancingTransform2DRow0.w, a_instancingTransform2DRow1.w, a_instancingTransform2DRow2.w, 1.0 // Column 4
  6541. );
  6542. #else
  6543. vec3 translation2D = vec3(0.0, 0.0, 0.0);
  6544. vec3 scale = vec3(1.0, 1.0, 1.0);
  6545. #ifdef HAS_INSTANCE_TRANSLATION
  6546. translation2D = a_instanceTranslation2D;
  6547. #endif
  6548. #ifdef HAS_INSTANCE_SCALE
  6549. scale = a_instanceScale;
  6550. #endif
  6551. instancingTransform2D = mat4(
  6552. scale.x, 0.0, 0.0, 0.0,
  6553. 0.0, scale.y, 0.0, 0.0,
  6554. 0.0, 0.0, scale.z, 0.0,
  6555. translation2D.x, translation2D.y, translation2D.z, 1.0
  6556. );
  6557. #endif
  6558. return instancingTransform2D;
  6559. }
  6560. #endif
  6561. `;var Bwn=y(x(),1),n2=`void instancingStage(inout ProcessedAttributes attributes)
  6562. {
  6563. vec3 positionMC = attributes.positionMC;
  6564. mat4 instancingTransform = getInstancingTransform();
  6565. attributes.positionMC = (instancingTransform * vec4(positionMC, 1.0)).xyz;
  6566. #ifdef HAS_NORMALS
  6567. vec3 normalMC = attributes.normalMC;
  6568. attributes.normalMC = (instancingTransform * vec4(normalMC, 0.0)).xyz;
  6569. #endif
  6570. #ifdef USE_2D_INSTANCING
  6571. mat4 instancingTransform2D = getInstancingTransform2D();
  6572. attributes.position2D = (instancingTransform2D * vec4(positionMC, 1.0)).xyz;
  6573. #endif
  6574. }
  6575. `;var Nwn=y(x(),1),i2=`void legacyInstancingStage(
  6576. inout ProcessedAttributes attributes,
  6577. out mat4 instanceModelView,
  6578. out mat3 instanceModelViewInverseTranspose)
  6579. {
  6580. vec3 positionMC = attributes.positionMC;
  6581. mat4 instancingTransform = getInstancingTransform();
  6582. mat4 instanceModel = instancingTransform * u_instance_nodeTransform;
  6583. instanceModelView = u_instance_modifiedModelView;
  6584. instanceModelViewInverseTranspose = mat3(u_instance_modifiedModelView * instanceModel);
  6585. attributes.positionMC = (instanceModel * vec4(positionMC, 1.0)).xyz;
  6586. #ifdef USE_2D_INSTANCING
  6587. mat4 instancingTransform2D = getInstancingTransform2D();
  6588. attributes.position2D = (instancingTransform2D * vec4(positionMC, 1.0)).xyz;
  6589. #endif
  6590. }
  6591. `;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
  6592. {
  6593. bool styleTranslucent = (featureColor.a != 1.0);
  6594. // Only render translucent features in the translucent pass (if the style or the original command has translucency).
  6595. if (czm_pass == czm_passTranslucent && !styleTranslucent && !model_commandTranslucent)
  6596. {
  6597. // If the model has a translucent silhouette, it needs to render during the silhouette color command,
  6598. // (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
  6599. #ifdef HAS_SILHOUETTE
  6600. positionMC *= float(model_silhouettePass);
  6601. #else
  6602. positionMC *= 0.0;
  6603. #endif
  6604. }
  6605. // If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
  6606. else if (czm_pass != czm_passTranslucent && styleTranslucent)
  6607. {
  6608. positionMC *= 0.0;
  6609. }
  6610. }
  6611. void cpuStylingStage(inout vec3 positionMC, inout SelectedFeature feature)
  6612. {
  6613. float show = ceil(feature.color.a);
  6614. positionMC *= show;
  6615. #if defined(HAS_SELECTED_FEATURE_ID_ATTRIBUTE) && !defined(HAS_CLASSIFICATION)
  6616. filterByPassType(positionMC, feature.color);
  6617. #endif
  6618. }
  6619. `;var kNn=y(x(),1),h2=`void filterByPassType(vec4 featureColor)
  6620. {
  6621. bool styleTranslucent = (featureColor.a != 1.0);
  6622. // Only render translucent features in the translucent pass (if the style or the original command has translucency).
  6623. if (czm_pass == czm_passTranslucent && !styleTranslucent && !model_commandTranslucent)
  6624. {
  6625. // If the model has a translucent silhouette, it needs to render during the silhouette color command,
  6626. // (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
  6627. #ifdef HAS_SILHOUETTE
  6628. if(!model_silhouettePass) {
  6629. discard;
  6630. }
  6631. #else
  6632. discard;
  6633. #endif
  6634. }
  6635. // If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
  6636. else if (czm_pass != czm_passTranslucent && styleTranslucent)
  6637. {
  6638. discard;
  6639. }
  6640. }
  6641. void cpuStylingStage(inout czm_modelMaterial material, SelectedFeature feature)
  6642. {
  6643. vec4 featureColor = feature.color;
  6644. if (featureColor.a == 0.0)
  6645. {
  6646. discard;
  6647. }
  6648. // If a feature ID vertex attribute is used, the pass type filter is applied in the vertex shader.
  6649. // So, we only apply in in the fragment shader if the feature ID texture is used.
  6650. #if defined(HAS_SELECTED_FEATURE_ID_TEXTURE) && !defined(HAS_CLASSIFICATION)
  6651. filterByPassType(featureColor);
  6652. #endif
  6653. featureColor = czm_gammaCorrect(featureColor);
  6654. // Classification models compute the diffuse differently.
  6655. #ifdef HAS_CLASSIFICATION
  6656. material.diffuse = featureColor.rgb * featureColor.a;
  6657. #else
  6658. float highlight = ceil(model_colorBlend);
  6659. material.diffuse *= mix(featureColor.rgb, vec3(1.0), highlight);
  6660. #endif
  6661. material.alpha *= featureColor.a;
  6662. }
  6663. `;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(
  6664. inout czm_modelVertexOutput vsOutput,
  6665. inout ProcessedAttributes attributes,
  6666. FeatureIds featureIds,
  6667. Metadata metadata,
  6668. MetadataClass metadataClass,
  6669. MetadataStatistics metadataStatistics
  6670. ) {
  6671. // VertexInput and initializeInputStruct() are dynamically generated in JS,
  6672. // see CustomShaderPipelineStage.js
  6673. VertexInput vsInput;
  6674. initializeInputStruct(vsInput, attributes);
  6675. vsInput.featureIds = featureIds;
  6676. vsInput.metadata = metadata;
  6677. vsInput.metadataClass = metadataClass;
  6678. vsInput.metadataStatistics = metadataStatistics;
  6679. vertexMain(vsInput, vsOutput);
  6680. attributes.positionMC = vsOutput.positionMC;
  6681. }
  6682. `;var rPn=y(x(),1),A2=`void customShaderStage(
  6683. inout czm_modelMaterial material,
  6684. ProcessedAttributes attributes,
  6685. FeatureIds featureIds,
  6686. Metadata metadata,
  6687. MetadataClass metadataClass,
  6688. MetadataStatistics metadataStatistics
  6689. ) {
  6690. // FragmentInput and initializeInputStruct() are dynamically generated in JS,
  6691. // see CustomShaderPipelineStage.js
  6692. FragmentInput fsInput;
  6693. initializeInputStruct(fsInput, attributes);
  6694. fsInput.featureIds = featureIds;
  6695. fsInput.metadata = metadata;
  6696. fsInput.metadataClass = metadataClass;
  6697. fsInput.metadataStatistics = metadataStatistics;
  6698. fragmentMain(fsInput, material);
  6699. }
  6700. `;var TPn=y(x(),1);var aPn=y(x(),1),g2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes) {
  6701. initializeFeatureIds(featureIds, attributes);
  6702. initializeFeatureIdAliases(featureIds);
  6703. }
  6704. `;var lPn=y(x(),1),b2=`void featureIdStage(out FeatureIds featureIds, ProcessedAttributes attributes)
  6705. {
  6706. initializeFeatureIds(featureIds, attributes);
  6707. initializeFeatureIdAliases(featureIds);
  6708. setFeatureIdVaryings();
  6709. }
  6710. `;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)&&
  6711. FeatureIds featureIds,
  6712. out Metadata metadata,
  6713. out MetadataClass metadataClass,
  6714. out MetadataStatistics metadataStatistics,
  6715. ProcessedAttributes attributes
  6716. )
  6717. {
  6718. initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);
  6719. }
  6720. `;var IPn=y(x(),1),x2=`void metadataStage(
  6721. FeatureIds featureIds,
  6722. out Metadata metadata,
  6723. out MetadataClass metadataClass,
  6724. out MetadataStatistics metadataStatistics,
  6725. ProcessedAttributes attributes
  6726. )
  6727. {
  6728. initializeMetadata(featureIds, metadata, metadataClass, metadataStatistics, attributes);
  6729. setMetadataVaryings();
  6730. }
  6731. `;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
  6732. if (u_isEdgePass) {
  6733. return;
  6734. }
  6735. vec2 screenCoord = gl_FragCoord.xy / czm_viewport.zw;
  6736. vec4 edgeColor = texture(czm_edgeColorTexture, screenCoord);
  6737. vec4 edgeId = texture(czm_edgeIdTexture, screenCoord);
  6738. // Packed window-space depth from edge pass (0..1)
  6739. float edgeDepthWin = czm_unpackDepth(texture(czm_edgeDepthTexture, screenCoord));
  6740. // Near / far for current frustum
  6741. float n = czm_currentFrustum.x;
  6742. float f = czm_currentFrustum.y;
  6743. // geometry depth in eye coordinate
  6744. vec4 geomEC = czm_windowToEyeCoordinates(gl_FragCoord);
  6745. float geomDepthLinear = -geomEC.z;
  6746. // Convert edge depth to linear depth
  6747. float z_ndc_edge = edgeDepthWin * 2.0 - 1.0;
  6748. float edgeDepthLinear = (2.0 * n * f) / (f + n - z_ndc_edge * (f - n));
  6749. float d = abs(edgeDepthLinear - geomDepthLinear);
  6750. // Adaptive epsilon using linear depth fwidth for robustness
  6751. float pixelStepLinear = fwidth(geomDepthLinear);
  6752. float rel = geomDepthLinear * 0.0005;
  6753. float eps = max(n * 1e-4, max(pixelStepLinear * 1.5, rel));
  6754. // If Edge isn't behind any geometry and the pixel has edge data
  6755. if (d < eps && edgeId.r > 0.0) {
  6756. #ifdef HAS_EDGE_FEATURE_ID
  6757. float edgeFeatureId = edgeId.g;
  6758. float currentFeatureId = float(featureIds.featureId_0);
  6759. #endif
  6760. float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));
  6761. // Background / sky / globe: always show edge
  6762. bool isBackground = geomDepthLinear > globeDepth;
  6763. bool drawEdge = isBackground;
  6764. #ifdef HAS_EDGE_FEATURE_ID
  6765. bool hasEdgeFeature = edgeFeatureId > 0.0;
  6766. bool hasCurrentFeature = currentFeatureId > 0.0;
  6767. bool featuresMatch = edgeFeatureId == currentFeatureId;
  6768. drawEdge = drawEdge || !hasEdgeFeature || !hasCurrentFeature || featuresMatch;
  6769. #else
  6770. drawEdge = true;
  6771. #endif
  6772. if (drawEdge) {
  6773. color = edgeColor;
  6774. }
  6775. }
  6776. }
  6777. `;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
  6778. // when shaders are processed by different rendering pipelines (e.g., OIT).
  6779. // Only declare MRT outputs when not in a derived shader context.
  6780. #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)
  6781. layout(location = 1) out vec4 out_id; // edge id / metadata
  6782. layout(location = 2) out vec4 out_edgeDepth; // packed depth
  6783. #endif
  6784. void edgeVisibilityStage(inout vec4 color, inout FeatureIds featureIds)
  6785. {
  6786. #ifdef HAS_EDGE_VISIBILITY
  6787. if (!u_isEdgePass) {
  6788. return;
  6789. }
  6790. float edgeTypeInt = v_edgeType * 255.0;
  6791. if (edgeTypeInt < 0.5) {
  6792. discard;
  6793. }
  6794. if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) { // silhouette candidate
  6795. // Silhouette check done in vertex shader
  6796. // v_shouldDiscard will be > 0.5 if this edge should be discarded
  6797. if (v_shouldDiscard > 0.5) {
  6798. discard;
  6799. }
  6800. }
  6801. vec4 finalColor = color;
  6802. #ifdef HAS_EDGE_COLOR_ATTRIBUTE
  6803. if (v_edgeColor.a >= 0.0) {
  6804. finalColor = v_edgeColor;
  6805. }
  6806. #endif
  6807. #ifdef HAS_LINE_PATTERN
  6808. // Pattern is 16-bit, each bit represents visibility at that position
  6809. const float maskLength = 16.0;
  6810. // Get the relative position within the dash from 0 to 1
  6811. float dashPosition = fract(v_lineCoord / maskLength);
  6812. // Figure out the mask index
  6813. float maskIndex = floor(dashPosition * maskLength);
  6814. // Test the bit mask
  6815. float maskTest = floor(u_linePattern / pow(2.0, maskIndex));
  6816. // If bit is 0 (gap), discard the fragment (use < 1.0 for better numerical stability)
  6817. if (mod(maskTest, 2.0) < 1.0) {
  6818. discard;
  6819. }
  6820. #endif
  6821. color = finalColor;
  6822. #if defined(HAS_EDGE_VISIBILITY_MRT) && !defined(CESIUM_REDIRECTED_COLOR_OUTPUT)
  6823. // Write edge metadata
  6824. out_id = vec4(0.0);
  6825. out_id.r = edgeTypeInt; // Edge type (0-3)
  6826. #ifdef HAS_EDGE_FEATURE_ID
  6827. out_id.g = float(featureIds.featureId_0); // Feature ID if available
  6828. #else
  6829. out_id.g = 0.0;
  6830. #endif
  6831. // Pack depth into separate MRT attachment
  6832. out_edgeDepth = czm_packDepth(gl_FragCoord.z);
  6833. #endif
  6834. #endif
  6835. }`;var AXn=y(x(),1),Z2=`#ifdef HAS_EDGE_VISIBILITY
  6836. void edgeVisibilityStageVS() {
  6837. if (!u_isEdgePass) {
  6838. return;
  6839. }
  6840. v_edgeType = a_edgeType;
  6841. v_silhouetteNormalView = czm_normal * a_silhouetteNormal;
  6842. v_faceNormalAView = czm_normal * a_faceNormalA;
  6843. v_faceNormalBView = czm_normal * a_faceNormalB;
  6844. v_edgeOffset = a_edgeOffset;
  6845. // Silhouette detection: check both endpoints of the edge
  6846. v_shouldDiscard = 0.0;
  6847. float edgeTypeInt = a_edgeType * 255.0;
  6848. if (edgeTypeInt > 0.5 && edgeTypeInt < 1.5) {
  6849. vec3 normalA = normalize(v_faceNormalAView);
  6850. vec3 normalB = normalize(v_faceNormalBView);
  6851. const float perpTol = 2.5e-4;
  6852. // Check at current vertex (first endpoint)
  6853. vec4 currentPosEC = czm_modelView * vec4(v_positionMC, 1.0);
  6854. vec3 toEye1 = normalize(-currentPosEC.xyz);
  6855. float dotA1 = dot(normalA, toEye1);
  6856. float dotB1 = dot(normalB, toEye1);
  6857. // Check at other vertex (second endpoint)
  6858. vec4 otherPosEC = czm_modelView * vec4(a_edgeOtherPos, 1.0);
  6859. vec3 toEye2 = normalize(-otherPosEC.xyz);
  6860. float dotA2 = dot(normalA, toEye2);
  6861. float dotB2 = dot(normalB, toEye2);
  6862. // Discard if EITHER endpoint is non-silhouette
  6863. if (dotA1 * dotB1 > perpTol || dotA2 * dotB2 > perpTol) {
  6864. v_shouldDiscard = 1.0;
  6865. }
  6866. }
  6867. #ifdef HAS_EDGE_FEATURE_ID
  6868. v_featureId_0 = a_edgeFeatureId;
  6869. #endif
  6870. #ifdef HAS_EDGE_COLOR_ATTRIBUTE
  6871. v_edgeColor = a_edgeColor;
  6872. #endif
  6873. #ifdef HAS_LINE_PATTERN
  6874. #ifdef HAS_EDGE_CUMULATIVE_DISTANCE
  6875. v_lineCoord = a_edgeCumulativeDistance * u_pixelsPerWorld;
  6876. #else
  6877. vec4 currentClip = czm_modelViewProjection * vec4(v_positionMC, 1.0);
  6878. vec2 currentScreen = ((currentClip.xy / currentClip.w) * 0.5 + 0.5) * czm_viewport.zw;
  6879. vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0);
  6880. vec2 otherScreen = ((otherClip.xy / otherClip.w) * 0.5 + 0.5) * czm_viewport.zw;
  6881. vec2 windowDir = otherScreen - currentScreen;
  6882. const float textureCoordinateBase = 8192.0;
  6883. if (abs(windowDir.x) > abs(windowDir.y)) {
  6884. v_lineCoord = textureCoordinateBase + currentScreen.x;
  6885. } else {
  6886. v_lineCoord = textureCoordinateBase + currentScreen.y;
  6887. }
  6888. #endif
  6889. #endif
  6890. // Expand vertex to form quad
  6891. vec4 posClip = gl_Position;
  6892. if (length(a_edgeOtherPos) > 0.0 && abs(a_edgeOffset) > 0.0) {
  6893. vec4 currentClip = posClip;
  6894. vec4 otherClip = czm_modelViewProjection * vec4(a_edgeOtherPos, 1.0);
  6895. vec2 currentNDC = currentClip.xy / currentClip.w;
  6896. vec2 otherNDC = otherClip.xy / otherClip.w;
  6897. vec2 edgeDirNDC = otherNDC - currentNDC;
  6898. // Ensure consistent edge direction
  6899. if (edgeDirNDC.x < 0.0 || (abs(edgeDirNDC.x) < 0.001 && edgeDirNDC.y < 0.0)) {
  6900. edgeDirNDC = -edgeDirNDC;
  6901. }
  6902. edgeDirNDC = normalize(edgeDirNDC);
  6903. vec2 perpNDC = vec2(-edgeDirNDC.y, edgeDirNDC.x);
  6904. // Convert line width from pixels to clip space
  6905. float lineWidthPixels = u_lineWidth;
  6906. vec2 viewportSize = czm_viewport.zw;
  6907. vec2 clipPerPixel = (2.0 / viewportSize) * currentClip.w;
  6908. vec2 offsetClip = perpNDC * lineWidthPixels * clipPerPixel * 0.5 * a_edgeOffset;
  6909. posClip.xy += offsetClip;
  6910. }
  6911. gl_Position = posClip;
  6912. }
  6913. #endif
  6914. `;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
  6915. {
  6916. attributes.positionMC = v_positionMC;
  6917. attributes.positionEC = v_positionEC;
  6918. #if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE)
  6919. attributes.positionWC = v_positionWC;
  6920. #endif
  6921. #ifdef HAS_NORMALS
  6922. // renormalize after interpolation
  6923. attributes.normalEC = normalize(v_normalEC);
  6924. #endif
  6925. #ifdef HAS_TANGENTS
  6926. attributes.tangentEC = normalize(v_tangentEC);
  6927. #endif
  6928. #ifdef HAS_BITANGENTS
  6929. attributes.bitangentEC = normalize(v_bitangentEC);
  6930. #endif
  6931. // Everything else is dynamically generated in GeometryPipelineStage
  6932. setDynamicVaryings(attributes);
  6933. }
  6934. `;var $Xn=y(x(),1),G2=`vec4 geometryStage(inout ProcessedAttributes attributes, mat4 modelView, mat3 normal)
  6935. {
  6936. vec4 computedPosition;
  6937. // Compute positions in different coordinate systems
  6938. vec3 positionMC = attributes.positionMC;
  6939. v_positionMC = positionMC;
  6940. v_positionEC = (modelView * vec4(positionMC, 1.0)).xyz;
  6941. #if defined(USE_2D_POSITIONS) || defined(USE_2D_INSTANCING)
  6942. vec3 position2D = attributes.position2D;
  6943. vec3 positionEC = (u_modelView2D * vec4(position2D, 1.0)).xyz;
  6944. computedPosition = czm_projection * vec4(positionEC, 1.0);
  6945. #else
  6946. computedPosition = czm_projection * vec4(v_positionEC, 1.0);
  6947. #endif
  6948. // Sometimes the custom shader and/or style needs this
  6949. #if defined(COMPUTE_POSITION_WC_CUSTOM_SHADER) || defined(COMPUTE_POSITION_WC_STYLE) || defined(COMPUTE_POSITION_WC_ATMOSPHERE) || defined(ENABLE_CLIPPING_POLYGONS)
  6950. // Note that this is a 32-bit position which may result in jitter on small
  6951. // scales.
  6952. v_positionWC = (czm_model * vec4(positionMC, 1.0)).xyz;
  6953. #endif
  6954. #ifdef HAS_NORMALS
  6955. v_normalEC = normalize(normal * attributes.normalMC);
  6956. #endif
  6957. #ifdef HAS_TANGENTS
  6958. v_tangentEC = normalize(normal * attributes.tangentMC);
  6959. #endif
  6960. #ifdef HAS_BITANGENTS
  6961. v_bitangentEC = normalize(normal * attributes.bitangentMC);
  6962. #endif
  6963. // All other varyings need to be dynamically generated in
  6964. // GeometryPipelineStage
  6965. setDynamicVaryings(attributes);
  6966. return computedPosition;
  6967. }
  6968. `;var cYn=y(x(),1);var tYn=y(x(),1),S_=`vec2 computeSt(float featureId)
  6969. {
  6970. float stepX = model_textureStep.x;
  6971. float centerX = model_textureStep.y;
  6972. #ifdef MULTILINE_BATCH_TEXTURE
  6973. float stepY = model_textureStep.z;
  6974. float centerY = model_textureStep.w;
  6975. float xId = mod(featureId, model_textureDimensions.x);
  6976. float yId = floor(featureId / model_textureDimensions.x);
  6977. return vec2(centerX + (xId * stepX), centerY + (yId * stepY));
  6978. #else
  6979. return vec2(centerX + (featureId * stepX), 0.5);
  6980. #endif
  6981. }
  6982. void selectedFeatureIdStage(out SelectedFeature feature, FeatureIds featureIds)
  6983. {
  6984. int featureId = featureIds.SELECTED_FEATURE_ID;
  6985. if (featureId < model_featuresLength)
  6986. {
  6987. vec2 featureSt = computeSt(float(featureId));
  6988. feature.id = featureId;
  6989. feature.st = featureSt;
  6990. feature.color = texture(model_batchTexture, featureSt);
  6991. }
  6992. // Floating point comparisons can be unreliable in GLSL, so we
  6993. // increment the feature ID to make sure it's always greater
  6994. // then the model_featuresLength - a condition we check for in the
  6995. // pick ID, to avoid sampling the pick texture if the feature ID is
  6996. // greater than the number of features.
  6997. else
  6998. {
  6999. feature.id = model_featuresLength + 1;
  7000. feature.st = vec2(0.0);
  7001. feature.color = vec4(1.0);
  7002. }
  7003. #ifdef HAS_NULL_FEATURE_ID
  7004. if (featureId == model_nullFeatureId) {
  7005. feature.id = featureId;
  7006. feature.st = vec2(0.0);
  7007. feature.color = vec4(1.0);
  7008. }
  7009. #endif
  7010. }
  7011. `;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
  7012. ${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
  7013. in vec2 v_textureCoordinates;
  7014. void main()
  7015. {
  7016. out_FragColor = texture(u_texture, v_textureCoordinates);
  7017. }
  7018. `;var ODn=y(x(),1),z2=`in vec4 position;
  7019. in float webMercatorT;
  7020. uniform vec2 u_textureDimensions;
  7021. out vec2 v_textureCoordinates;
  7022. void main()
  7023. {
  7024. v_textureCoordinates = vec2(position.x, webMercatorT);
  7025. gl_Position = czm_viewportOrthographic * (position * vec4(u_textureDimensions, 1.0, 1.0));
  7026. }
  7027. `;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
  7028. vec3 computeIBL(vec3 position, vec3 normal, vec3 lightDirection, vec3 lightColorHdr, czm_modelMaterial material)
  7029. {
  7030. #if defined(DIFFUSE_IBL) || defined(SPECULAR_IBL)
  7031. // Environment maps were provided, use them for IBL
  7032. vec3 viewDirection = -normalize(position);
  7033. vec3 iblColor = textureIBL(viewDirection, normal, material);
  7034. return iblColor;
  7035. #endif
  7036. return vec3(0.0);
  7037. }
  7038. #endif
  7039. #ifdef USE_CLEARCOAT
  7040. vec3 addClearcoatReflection(vec3 baseLayerColor, vec3 position, vec3 lightDirection, vec3 lightColorHdr, czm_modelMaterial material)
  7041. {
  7042. vec3 viewDirection = -normalize(position);
  7043. vec3 halfwayDirection = normalize(viewDirection + lightDirection);
  7044. vec3 normal = material.clearcoatNormal;
  7045. float NdotL = clamp(dot(normal, lightDirection), 0.001, 1.0);
  7046. // clearcoatF0 = vec3(pow((ior - 1.0) / (ior + 1.0), 2.0)), but without KHR_materials_ior, ior is a constant 1.5.
  7047. vec3 f0 = vec3(0.04);
  7048. vec3 f90 = vec3(1.0);
  7049. // Note: clearcoat Fresnel computed with dot(n, v) instead of dot(v, h).
  7050. // This is to make it energy conserving with a simple layering function.
  7051. float NdotV = clamp(dot(normal, viewDirection), 0.0, 1.0);
  7052. vec3 F = fresnelSchlick2(f0, f90, NdotV);
  7053. // compute specular reflection from direct lighting
  7054. float roughness = material.clearcoatRoughness;
  7055. float alphaRoughness = roughness * roughness;
  7056. float directStrength = computeDirectSpecularStrength(normal, lightDirection, viewDirection, halfwayDirection, alphaRoughness);
  7057. vec3 directReflection = F * directStrength * NdotL;
  7058. vec3 color = lightColorHdr * directReflection;
  7059. #ifdef SPECULAR_IBL
  7060. // Find the direction in which to sample the environment map
  7061. vec3 reflectMC = normalize(model_iblReferenceFrameMatrix * reflect(-viewDirection, normal));
  7062. vec3 iblColor = computeSpecularIBL(reflectMC, NdotV, f0, roughness);
  7063. color += iblColor * material.occlusion;
  7064. #endif
  7065. float clearcoatFactor = material.clearcoatFactor;
  7066. vec3 clearcoatColor = color * clearcoatFactor;
  7067. // Dim base layer based on transmission loss through clearcoat
  7068. return baseLayerColor * (1.0 - clearcoatFactor * F) + clearcoatColor;
  7069. }
  7070. #endif
  7071. #if defined(LIGHTING_PBR) && defined(HAS_NORMALS)
  7072. vec3 computePbrLighting(in czm_modelMaterial material, in vec3 position)
  7073. {
  7074. #ifdef USE_CUSTOM_LIGHT_COLOR
  7075. vec3 lightColorHdr = model_lightColorHdr;
  7076. #else
  7077. vec3 lightColorHdr = czm_lightColorHdr;
  7078. #endif
  7079. vec3 viewDirection = -normalize(position);
  7080. vec3 normal = material.normalEC;
  7081. vec3 lightDirection = normalize(czm_lightDirectionEC);
  7082. vec3 directLighting = czm_pbrLighting(viewDirection, normal, lightDirection, material);
  7083. vec3 directColor = lightColorHdr * directLighting;
  7084. // Accumulate colors from base layer
  7085. vec3 color = directColor + material.emissive;
  7086. #ifdef USE_IBL_LIGHTING
  7087. color += computeIBL(position, normal, lightDirection, lightColorHdr, material);
  7088. #endif
  7089. #ifdef USE_CLEARCOAT
  7090. color = addClearcoatReflection(color, position, lightDirection, lightColorHdr, material);
  7091. #endif
  7092. return color;
  7093. }
  7094. #endif
  7095. /**
  7096. * Compute the material color under the current lighting conditions.
  7097. * All other material properties are passed through so further stages
  7098. * have access to them.
  7099. *
  7100. * @param {czm_modelMaterial} material The material properties from {@MaterialStageFS}
  7101. * @param {ProcessedAttributes} attributes
  7102. */
  7103. void lightingStage(inout czm_modelMaterial material, ProcessedAttributes attributes)
  7104. {
  7105. #ifdef LIGHTING_PBR
  7106. #ifdef HAS_NORMALS
  7107. vec3 color = computePbrLighting(material, attributes.positionEC);
  7108. #else
  7109. vec3 color = material.diffuse * material.occlusion + material.emissive;
  7110. #endif
  7111. // In HDR mode, the frame buffer is in linear color space. The
  7112. // post-processing stages (see PostProcessStageCollection) will handle
  7113. // tonemapping. However, if HDR is not enabled, we must tonemap else large
  7114. // values may be clamped to 1.0
  7115. #ifndef HDR
  7116. color = czm_pbrNeutralTonemapping(color);
  7117. #endif
  7118. #else // unlit
  7119. vec3 color = material.diffuse;
  7120. #endif
  7121. #ifdef HAS_POINT_CLOUD_COLOR_STYLE
  7122. // The colors resulting from point cloud styles are adjusted differently.
  7123. color = czm_gammaCorrect(color);
  7124. #elif !defined(HDR)
  7125. // If HDR is not enabled, the frame buffer stores sRGB colors rather than
  7126. // linear colors so the linear value must be converted.
  7127. color = czm_linearToSrgb(color);
  7128. #endif
  7129. material.diffuse = color;
  7130. }
  7131. `;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.
  7132. bool isDefaultStyleColor(vec3 color)
  7133. {
  7134. return all(greaterThan(color, vec3(1.0 - czm_epsilon3)));
  7135. }
  7136. vec3 blend(vec3 sourceColor, vec3 styleColor, float styleColorBlend)
  7137. {
  7138. vec3 blendColor = mix(sourceColor, styleColor, styleColorBlend);
  7139. vec3 color = isDefaultStyleColor(styleColor.rgb) ? sourceColor : blendColor;
  7140. return color;
  7141. }
  7142. #ifdef HAS_NORMAL_TEXTURE
  7143. vec2 getNormalTexCoords()
  7144. {
  7145. vec2 texCoord = TEXCOORD_NORMAL;
  7146. #ifdef HAS_NORMAL_TEXTURE_TRANSFORM
  7147. texCoord = czm_computeTextureTransform(texCoord, u_normalTextureTransform);
  7148. #endif
  7149. return texCoord;
  7150. }
  7151. #endif
  7152. #if defined(HAS_NORMAL_TEXTURE) || defined(HAS_CLEARCOAT_NORMAL_TEXTURE)
  7153. vec3 computeTangent(in vec3 position, in vec2 normalTexCoords)
  7154. {
  7155. vec2 tex_dx = dFdx(normalTexCoords);
  7156. vec2 tex_dy = dFdy(normalTexCoords);
  7157. float determinant = tex_dx.x * tex_dy.y - tex_dy.x * tex_dx.y;
  7158. vec3 tangent = tex_dy.t * dFdx(position) - tex_dx.t * dFdy(position);
  7159. return tangent / determinant;
  7160. }
  7161. #endif
  7162. #ifdef USE_ANISOTROPY
  7163. struct NormalInfo {
  7164. vec3 tangent;
  7165. vec3 bitangent;
  7166. vec3 normal;
  7167. vec3 geometryNormal;
  7168. };
  7169. NormalInfo getNormalInfo(ProcessedAttributes attributes)
  7170. {
  7171. vec3 geometryNormal = attributes.normalEC;
  7172. #ifdef HAS_NORMAL_TEXTURE
  7173. vec2 normalTexCoords = getNormalTexCoords();
  7174. #endif
  7175. #ifdef HAS_BITANGENTS
  7176. vec3 tangent = attributes.tangentEC;
  7177. vec3 bitangent = attributes.bitangentEC;
  7178. #else // Assume HAS_NORMAL_TEXTURE
  7179. vec3 tangent = computeTangent(attributes.positionEC, normalTexCoords);
  7180. tangent = normalize(tangent - geometryNormal * dot(geometryNormal, tangent));
  7181. vec3 bitangent = normalize(cross(geometryNormal, tangent));
  7182. #endif
  7183. #ifdef HAS_NORMAL_TEXTURE
  7184. mat3 tbn = mat3(tangent, bitangent, geometryNormal);
  7185. vec3 normalSample;
  7186. #if defined(HAS_NORMAL_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD)
  7187. #ifdef HAS_NORMAL_TEXTURE_TRANSFORM
  7188. normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams, u_normalTextureTransform).rgb;
  7189. #else
  7190. normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams).rgb;
  7191. #endif
  7192. #else
  7193. normalSample = texture(u_normalTexture, normalTexCoords).rgb;
  7194. #endif
  7195. normalSample = 2.0 * normalSample - 1.0;
  7196. #ifdef HAS_NORMAL_TEXTURE_SCALE
  7197. normalSample.xy *= u_normalTextureScale;
  7198. #endif
  7199. vec3 normal = normalize(tbn * normalSample);
  7200. #else
  7201. vec3 normal = geometryNormal;
  7202. #endif
  7203. #ifdef HAS_DOUBLE_SIDED_MATERIAL
  7204. if (czm_backFacing()) {
  7205. tangent *= -1.0;
  7206. bitangent *= -1.0;
  7207. normal *= -1.0;
  7208. geometryNormal *= -1.0;
  7209. }
  7210. #endif
  7211. NormalInfo normalInfo;
  7212. normalInfo.tangent = tangent;
  7213. normalInfo.bitangent = bitangent;
  7214. normalInfo.normal = normal;
  7215. normalInfo.geometryNormal = geometryNormal;
  7216. return normalInfo;
  7217. }
  7218. #endif
  7219. #if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)
  7220. vec3 getNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)
  7221. {
  7222. vec2 normalTexCoords = getNormalTexCoords();
  7223. // If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
  7224. #ifdef HAS_BITANGENTS
  7225. vec3 t = attributes.tangentEC;
  7226. vec3 b = attributes.bitangentEC;
  7227. #else
  7228. vec3 t = computeTangent(attributes.positionEC, normalTexCoords);
  7229. t = normalize(t - geometryNormal * dot(geometryNormal, t));
  7230. vec3 b = normalize(cross(geometryNormal, t));
  7231. #endif
  7232. mat3 tbn = mat3(t, b, geometryNormal);
  7233. vec3 normalSample;
  7234. #if defined(HAS_NORMAL_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD)
  7235. #ifdef HAS_NORMAL_TEXTURE_TRANSFORM
  7236. normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams, u_normalTextureTransform).rgb;
  7237. #else
  7238. normalSample = constantLodTextureLookup(u_normalTexture, u_normalTextureConstantLodParams).rgb;
  7239. #endif
  7240. #else
  7241. normalSample = texture(u_normalTexture, normalTexCoords).rgb;
  7242. #endif
  7243. normalSample = 2.0 * normalSample - 1.0;
  7244. #ifdef HAS_NORMAL_TEXTURE_SCALE
  7245. normalSample.xy *= u_normalTextureScale;
  7246. #endif
  7247. return normalize(tbn * normalSample);
  7248. }
  7249. #endif
  7250. #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE
  7251. vec3 getClearcoatNormalFromTexture(ProcessedAttributes attributes, vec3 geometryNormal)
  7252. {
  7253. vec2 normalTexCoords = TEXCOORD_CLEARCOAT_NORMAL;
  7254. #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_TRANSFORM
  7255. normalTexCoords = vec2(u_clearcoatNormalTextureTransform * vec3(normalTexCoords, 1.0));
  7256. #endif
  7257. // If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
  7258. #ifdef HAS_BITANGENTS
  7259. vec3 t = attributes.tangentEC;
  7260. vec3 b = attributes.bitangentEC;
  7261. #else
  7262. vec3 t = computeTangent(attributes.positionEC, normalTexCoords);
  7263. t = normalize(t - geometryNormal * dot(geometryNormal, t));
  7264. vec3 b = normalize(cross(geometryNormal, t));
  7265. #endif
  7266. mat3 tbn = mat3(t, b, geometryNormal);
  7267. vec3 normalSample = texture(u_clearcoatNormalTexture, normalTexCoords).rgb;
  7268. normalSample = 2.0 * normalSample - 1.0;
  7269. #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE_SCALE
  7270. normalSample.xy *= u_clearcoatNormalTextureScale;
  7271. #endif
  7272. return normalize(tbn * normalSample);
  7273. }
  7274. #endif
  7275. #ifdef HAS_NORMALS
  7276. vec3 computeNormal(ProcessedAttributes attributes)
  7277. {
  7278. // Geometry normal. This is already normalized
  7279. vec3 normal = attributes.normalEC;
  7280. #if defined(HAS_NORMAL_TEXTURE) && !defined(HAS_WIREFRAME)
  7281. normal = getNormalFromTexture(attributes, normal);
  7282. #endif
  7283. #ifdef HAS_DOUBLE_SIDED_MATERIAL
  7284. if (czm_backFacing()) {
  7285. normal = -normal;
  7286. }
  7287. #endif
  7288. return normal;
  7289. }
  7290. #endif
  7291. #ifdef HAS_BASE_COLOR_TEXTURE
  7292. vec4 getBaseColorFromTexture()
  7293. {
  7294. vec2 baseColorTexCoords = TEXCOORD_BASE_COLOR;
  7295. #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM
  7296. baseColorTexCoords = czm_computeTextureTransform(baseColorTexCoords, u_baseColorTextureTransform);
  7297. #endif
  7298. vec4 baseColorWithAlpha;
  7299. #if defined(HAS_BASE_COLOR_CONSTANT_LOD) && defined(HAS_CONSTANT_LOD)
  7300. #ifdef HAS_BASE_COLOR_TEXTURE_TRANSFORM
  7301. baseColorWithAlpha = czm_srgbToLinear(constantLodTextureLookup(u_baseColorTexture, u_baseColorTextureConstantLodParams, u_baseColorTextureTransform));
  7302. #else
  7303. baseColorWithAlpha = czm_srgbToLinear(constantLodTextureLookup(u_baseColorTexture, u_baseColorTextureConstantLodParams));
  7304. #endif
  7305. #else
  7306. baseColorWithAlpha = czm_srgbToLinear(texture(u_baseColorTexture, baseColorTexCoords));
  7307. #endif
  7308. #ifdef HAS_BASE_COLOR_FACTOR
  7309. baseColorWithAlpha *= u_baseColorFactor;
  7310. #endif
  7311. return baseColorWithAlpha;
  7312. }
  7313. #endif
  7314. #ifdef HAS_EMISSIVE_TEXTURE
  7315. vec3 getEmissiveFromTexture()
  7316. {
  7317. vec2 emissiveTexCoords = TEXCOORD_EMISSIVE;
  7318. #ifdef HAS_EMISSIVE_TEXTURE_TRANSFORM
  7319. emissiveTexCoords = czm_computeTextureTransform(emissiveTexCoords, u_emissiveTextureTransform);
  7320. #endif
  7321. vec3 emissive = czm_srgbToLinear(texture(u_emissiveTexture, emissiveTexCoords).rgb);
  7322. #ifdef HAS_EMISSIVE_FACTOR
  7323. emissive *= u_emissiveFactor;
  7324. #endif
  7325. return emissive;
  7326. }
  7327. #endif
  7328. #if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)
  7329. void setSpecularGlossiness(inout czm_modelMaterial material)
  7330. {
  7331. #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE
  7332. vec2 specularGlossinessTexCoords = TEXCOORD_SPECULAR_GLOSSINESS;
  7333. #ifdef HAS_SPECULAR_GLOSSINESS_TEXTURE_TRANSFORM
  7334. specularGlossinessTexCoords = czm_computeTextureTransform(specularGlossinessTexCoords, u_specularGlossinessTextureTransform);
  7335. #endif
  7336. vec4 specularGlossiness = czm_srgbToLinear(texture(u_specularGlossinessTexture, specularGlossinessTexCoords));
  7337. vec3 specular = specularGlossiness.rgb;
  7338. float glossiness = specularGlossiness.a;
  7339. #ifdef HAS_LEGACY_SPECULAR_FACTOR
  7340. specular *= u_legacySpecularFactor;
  7341. #endif
  7342. #ifdef HAS_GLOSSINESS_FACTOR
  7343. glossiness *= u_glossinessFactor;
  7344. #endif
  7345. #else
  7346. #ifdef HAS_LEGACY_SPECULAR_FACTOR
  7347. vec3 specular = clamp(u_legacySpecularFactor, vec3(0.0), vec3(1.0));
  7348. #else
  7349. vec3 specular = vec3(1.0);
  7350. #endif
  7351. #ifdef HAS_GLOSSINESS_FACTOR
  7352. float glossiness = clamp(u_glossinessFactor, 0.0, 1.0);
  7353. #else
  7354. float glossiness = 1.0;
  7355. #endif
  7356. #endif
  7357. #ifdef HAS_DIFFUSE_TEXTURE
  7358. vec2 diffuseTexCoords = TEXCOORD_DIFFUSE;
  7359. #ifdef HAS_DIFFUSE_TEXTURE_TRANSFORM
  7360. diffuseTexCoords = czm_computeTextureTransform(diffuseTexCoords, u_diffuseTextureTransform);
  7361. #endif
  7362. vec4 diffuse = czm_srgbToLinear(texture(u_diffuseTexture, diffuseTexCoords));
  7363. #ifdef HAS_DIFFUSE_FACTOR
  7364. diffuse *= u_diffuseFactor;
  7365. #endif
  7366. #elif defined(HAS_DIFFUSE_FACTOR)
  7367. vec4 diffuse = clamp(u_diffuseFactor, vec4(0.0), vec4(1.0));
  7368. #else
  7369. vec4 diffuse = vec4(1.0);
  7370. #endif
  7371. material.diffuse = diffuse.rgb * (1.0 - czm_maximumComponent(specular));
  7372. // the specular glossiness extension's alpha overrides anything set
  7373. // by the base material.
  7374. material.alpha = diffuse.a;
  7375. material.specular = specular;
  7376. // glossiness is the opposite of roughness, but easier for artists to use.
  7377. material.roughness = 1.0 - glossiness;
  7378. }
  7379. #elif defined(LIGHTING_PBR)
  7380. float setMetallicRoughness(inout czm_modelMaterial material)
  7381. {
  7382. #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE
  7383. vec2 metallicRoughnessTexCoords = TEXCOORD_METALLIC_ROUGHNESS;
  7384. #ifdef HAS_METALLIC_ROUGHNESS_TEXTURE_TRANSFORM
  7385. metallicRoughnessTexCoords = czm_computeTextureTransform(metallicRoughnessTexCoords, u_metallicRoughnessTextureTransform);
  7386. #endif
  7387. vec3 metallicRoughness = texture(u_metallicRoughnessTexture, metallicRoughnessTexCoords).rgb;
  7388. float metalness = clamp(metallicRoughness.b, 0.0, 1.0);
  7389. float roughness = clamp(metallicRoughness.g, 0.0, 1.0);
  7390. #ifdef HAS_METALLIC_FACTOR
  7391. metalness = clamp(metalness * u_metallicFactor, 0.0, 1.0);
  7392. #endif
  7393. #ifdef HAS_ROUGHNESS_FACTOR
  7394. roughness = clamp(roughness * u_roughnessFactor, 0.0, 1.0);
  7395. #endif
  7396. #else
  7397. #ifdef HAS_METALLIC_FACTOR
  7398. float metalness = clamp(u_metallicFactor, 0.0, 1.0);
  7399. #else
  7400. float metalness = 1.0;
  7401. #endif
  7402. #ifdef HAS_ROUGHNESS_FACTOR
  7403. float roughness = clamp(u_roughnessFactor, 0.0, 1.0);
  7404. #else
  7405. float roughness = 1.0;
  7406. #endif
  7407. #endif
  7408. // dielectrics use f0 = 0.04, metals use albedo as f0
  7409. const vec3 REFLECTANCE_DIELECTRIC = vec3(0.04);
  7410. vec3 f0 = mix(REFLECTANCE_DIELECTRIC, material.baseColor.rgb, metalness);
  7411. material.specular = f0;
  7412. // diffuse only applies to dielectrics.
  7413. material.diffuse = mix(material.baseColor.rgb, vec3(0.0), metalness);
  7414. // This is perceptual roughness. The square of this value is used for direct lighting
  7415. material.roughness = roughness;
  7416. return metalness;
  7417. }
  7418. #ifdef USE_SPECULAR
  7419. void setSpecular(inout czm_modelMaterial material, in float metalness)
  7420. {
  7421. #ifdef HAS_SPECULAR_TEXTURE
  7422. vec2 specularTexCoords = TEXCOORD_SPECULAR;
  7423. #ifdef HAS_SPECULAR_TEXTURE_TRANSFORM
  7424. specularTexCoords = czm_computeTextureTransform(specularTexCoords, u_specularTextureTransform);
  7425. #endif
  7426. float specularWeight = texture(u_specularTexture, specularTexCoords).a;
  7427. #ifdef HAS_SPECULAR_FACTOR
  7428. specularWeight *= u_specularFactor;
  7429. #endif
  7430. #else
  7431. #ifdef HAS_SPECULAR_FACTOR
  7432. float specularWeight = u_specularFactor;
  7433. #else
  7434. float specularWeight = 1.0;
  7435. #endif
  7436. #endif
  7437. #ifdef HAS_SPECULAR_COLOR_TEXTURE
  7438. vec2 specularColorTexCoords = TEXCOORD_SPECULAR_COLOR;
  7439. #ifdef HAS_SPECULAR_COLOR_TEXTURE_TRANSFORM
  7440. specularColorTexCoords = czm_computeTextureTransform(specularColorTexCoords, u_specularColorTextureTransform);
  7441. #endif
  7442. vec3 specularColorSample = texture(u_specularColorTexture, specularColorTexCoords).rgb;
  7443. vec3 specularColorFactor = czm_srgbToLinear(specularColorSample);
  7444. #ifdef HAS_SPECULAR_COLOR_FACTOR
  7445. specularColorFactor *= u_specularColorFactor;
  7446. #endif
  7447. #else
  7448. #ifdef HAS_SPECULAR_COLOR_FACTOR
  7449. vec3 specularColorFactor = u_specularColorFactor;
  7450. #else
  7451. vec3 specularColorFactor = vec3(1.0);
  7452. #endif
  7453. #endif
  7454. material.specularWeight = specularWeight;
  7455. vec3 f0 = material.specular;
  7456. vec3 dielectricSpecularF0 = min(f0 * specularColorFactor, vec3(1.0));
  7457. material.specular = mix(dielectricSpecularF0, material.baseColor.rgb, metalness);
  7458. }
  7459. #endif
  7460. #ifdef USE_ANISOTROPY
  7461. void setAnisotropy(inout czm_modelMaterial material, in NormalInfo normalInfo)
  7462. {
  7463. mat2 rotation = mat2(u_anisotropy.xy, -u_anisotropy.y, u_anisotropy.x);
  7464. float anisotropyStrength = u_anisotropy.z;
  7465. vec2 direction = vec2(1.0, 0.0);
  7466. #ifdef HAS_ANISOTROPY_TEXTURE
  7467. vec2 anisotropyTexCoords = TEXCOORD_ANISOTROPY;
  7468. #ifdef HAS_ANISOTROPY_TEXTURE_TRANSFORM
  7469. anisotropyTexCoords = czm_computeTextureTransform(anisotropyTexCoords, u_anisotropyTextureTransform);
  7470. #endif
  7471. vec3 anisotropySample = texture(u_anisotropyTexture, anisotropyTexCoords).rgb;
  7472. direction = anisotropySample.rg * 2.0 - vec2(1.0);
  7473. anisotropyStrength *= anisotropySample.b;
  7474. #endif
  7475. direction = rotation * direction;
  7476. mat3 tbn = mat3(normalInfo.tangent, normalInfo.bitangent, normalInfo.normal);
  7477. vec3 anisotropicT = tbn * normalize(vec3(direction, 0.0));
  7478. vec3 anisotropicB = cross(normalInfo.geometryNormal, anisotropicT);
  7479. material.anisotropicT = anisotropicT;
  7480. material.anisotropicB = anisotropicB;
  7481. material.anisotropyStrength = anisotropyStrength;
  7482. }
  7483. #endif
  7484. #ifdef USE_CLEARCOAT
  7485. void setClearcoat(inout czm_modelMaterial material, in ProcessedAttributes attributes)
  7486. {
  7487. #ifdef HAS_CLEARCOAT_TEXTURE
  7488. vec2 clearcoatTexCoords = TEXCOORD_CLEARCOAT;
  7489. #ifdef HAS_CLEARCOAT_TEXTURE_TRANSFORM
  7490. clearcoatTexCoords = czm_computeTextureTransform(clearcoatTexCoords, u_clearcoatTextureTransform);
  7491. #endif
  7492. float clearcoatFactor = texture(u_clearcoatTexture, clearcoatTexCoords).r;
  7493. #ifdef HAS_CLEARCOAT_FACTOR
  7494. clearcoatFactor *= u_clearcoatFactor;
  7495. #endif
  7496. #else
  7497. #ifdef HAS_CLEARCOAT_FACTOR
  7498. float clearcoatFactor = u_clearcoatFactor;
  7499. #else
  7500. // PERFORMANCE_IDEA: this case should turn the whole extension off
  7501. float clearcoatFactor = 0.0;
  7502. #endif
  7503. #endif
  7504. #ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE
  7505. vec2 clearcoatRoughnessTexCoords = TEXCOORD_CLEARCOAT_ROUGHNESS;
  7506. #ifdef HAS_CLEARCOAT_ROUGHNESS_TEXTURE_TRANSFORM
  7507. clearcoatRoughnessTexCoords = czm_computeTextureTransform(clearcoatRoughnessTexCoords, u_clearcoatRoughnessTextureTransform);
  7508. #endif
  7509. float clearcoatRoughness = texture(u_clearcoatRoughnessTexture, clearcoatRoughnessTexCoords).g;
  7510. #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR
  7511. clearcoatRoughness *= u_clearcoatRoughnessFactor;
  7512. #endif
  7513. #else
  7514. #ifdef HAS_CLEARCOAT_ROUGHNESS_FACTOR
  7515. float clearcoatRoughness = u_clearcoatRoughnessFactor;
  7516. #else
  7517. float clearcoatRoughness = 0.0;
  7518. #endif
  7519. #endif
  7520. material.clearcoatFactor = clearcoatFactor;
  7521. // This is perceptual roughness. The square of this value is used for direct lighting
  7522. material.clearcoatRoughness = clearcoatRoughness;
  7523. #ifdef HAS_CLEARCOAT_NORMAL_TEXTURE
  7524. material.clearcoatNormal = getClearcoatNormalFromTexture(attributes, attributes.normalEC);
  7525. #else
  7526. material.clearcoatNormal = attributes.normalEC;
  7527. #endif
  7528. }
  7529. #endif
  7530. #endif
  7531. void materialStage(inout czm_modelMaterial material, ProcessedAttributes attributes, SelectedFeature feature)
  7532. {
  7533. #ifdef USE_ANISOTROPY
  7534. NormalInfo normalInfo = getNormalInfo(attributes);
  7535. material.normalEC = normalInfo.normal;
  7536. #elif defined(HAS_NORMALS)
  7537. material.normalEC = computeNormal(attributes);
  7538. #endif
  7539. vec4 baseColorWithAlpha = vec4(1.0);
  7540. // Regardless of whether we use PBR, set a base color
  7541. #ifdef HAS_BASE_COLOR_TEXTURE
  7542. baseColorWithAlpha = getBaseColorFromTexture();
  7543. #elif defined(HAS_BASE_COLOR_FACTOR)
  7544. baseColorWithAlpha = u_baseColorFactor;
  7545. #endif
  7546. #ifdef HAS_IMAGERY
  7547. baseColorWithAlpha = blendBaseColorWithImagery(baseColorWithAlpha);
  7548. #endif // HAS_IMAGERY
  7549. #ifdef HAS_POINT_CLOUD_COLOR_STYLE
  7550. baseColorWithAlpha = v_pointCloudColor;
  7551. #elif defined(HAS_COLOR_0)
  7552. vec4 color = attributes.color_0;
  7553. // .pnts files store colors in the sRGB color space
  7554. #ifdef HAS_SRGB_COLOR
  7555. color = czm_srgbToLinear(color);
  7556. #endif
  7557. baseColorWithAlpha *= color;
  7558. #endif
  7559. #ifdef USE_CPU_STYLING
  7560. baseColorWithAlpha.rgb = blend(baseColorWithAlpha.rgb, feature.color.rgb, model_colorBlend);
  7561. #endif
  7562. material.baseColor = baseColorWithAlpha;
  7563. material.diffuse = baseColorWithAlpha.rgb;
  7564. material.alpha = baseColorWithAlpha.a;
  7565. #ifdef HAS_OCCLUSION_TEXTURE
  7566. vec2 occlusionTexCoords = TEXCOORD_OCCLUSION;
  7567. #ifdef HAS_OCCLUSION_TEXTURE_TRANSFORM
  7568. occlusionTexCoords = czm_computeTextureTransform(occlusionTexCoords, u_occlusionTextureTransform);
  7569. #endif
  7570. material.occlusion = texture(u_occlusionTexture, occlusionTexCoords).r;
  7571. #endif
  7572. #ifdef HAS_EMISSIVE_TEXTURE
  7573. material.emissive = getEmissiveFromTexture();
  7574. #elif defined(HAS_EMISSIVE_FACTOR)
  7575. material.emissive = u_emissiveFactor;
  7576. #endif
  7577. #if defined(LIGHTING_PBR) && defined(USE_SPECULAR_GLOSSINESS)
  7578. setSpecularGlossiness(material);
  7579. #elif defined(LIGHTING_PBR)
  7580. float metalness = setMetallicRoughness(material);
  7581. #ifdef USE_SPECULAR
  7582. setSpecular(material, metalness);
  7583. #endif
  7584. #ifdef USE_ANISOTROPY
  7585. setAnisotropy(material, normalInfo);
  7586. #endif
  7587. #ifdef USE_CLEARCOAT
  7588. setClearcoat(material, attributes);
  7589. #endif
  7590. #endif
  7591. }
  7592. `;var t5n=y(x(),1),tB=`#ifdef HAS_CONSTANT_LOD
  7593. // Extract model scale to compensate for minimumPixelSize scaling
  7594. float modelScaleX = length(czm_model[0].xyz);
  7595. float modelScaleY = length(czm_model[1].xyz);
  7596. float modelScaleZ = length(czm_model[2].xyz);
  7597. float modelScale = (modelScaleX + modelScaleY + modelScaleZ) / 3.0;
  7598. // Transform model position through ENU but as direction only (w=0) to avoid position-dependent rotation
  7599. vec3 enuDir = (u_constantLodWorldToEnu * czm_model * vec4(v_positionMC, 0.0)).xyz;
  7600. v_constantLodUvCustom.xy = (enuDir.yx + u_constantLodOffset) / modelScale;
  7601. v_constantLodUvCustom.z = u_constantLodDistance / modelScale;
  7602. #endif`;var i5n=y(x(),1),nB=`#ifdef HAS_CONSTANT_LOD
  7603. vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams) {
  7604. bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y;
  7605. bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x;
  7606. bool atClampBoundary = atMaxClamp || atMinClamp;
  7607. float effectiveDistance = atMaxClamp ? constantLodParams.y :
  7608. (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z);
  7609. float logDepth = log2(effectiveDistance);
  7610. logDepth = clamp(logDepth, -10.0, 20.0);
  7611. float f = fract(logDepth);
  7612. float p = floor(logDepth);
  7613. if (atClampBoundary) {
  7614. float clampedP = ceil(logDepth);
  7615. vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z;
  7616. return texture(textureSampler, tc);
  7617. }
  7618. vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z;
  7619. vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z;
  7620. return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);
  7621. }
  7622. vec4 constantLodTextureLookup(sampler2D textureSampler, vec3 constantLodParams, mat3 textureTransform) {
  7623. bool atMaxClamp = v_constantLodUvCustom.z >= constantLodParams.y;
  7624. bool atMinClamp = v_constantLodUvCustom.z <= constantLodParams.x;
  7625. bool atClampBoundary = atMaxClamp || atMinClamp;
  7626. float effectiveDistance = atMaxClamp ? constantLodParams.y :
  7627. (atMinClamp ? constantLodParams.x : v_constantLodUvCustom.z);
  7628. float logDepth = log2(effectiveDistance);
  7629. logDepth = clamp(logDepth, -10.0, 20.0);
  7630. float f = fract(logDepth);
  7631. float p = floor(logDepth);
  7632. if (atClampBoundary) {
  7633. float clampedP = ceil(logDepth);
  7634. vec2 tc = v_constantLodUvCustom.xy / pow(2.0, clampedP) * constantLodParams.z;
  7635. // Apply texture transform to the final texture coordinates
  7636. tc = czm_computeTextureTransform(tc, textureTransform);
  7637. return texture(textureSampler, tc);
  7638. }
  7639. vec2 tc1 = v_constantLodUvCustom.xy / pow(2.0, p) * constantLodParams.z;
  7640. vec2 tc2 = v_constantLodUvCustom.xy / pow(2.0, p + 1.0) * constantLodParams.z;
  7641. // Apply texture transform to both LOD texture coordinates before mixing
  7642. tc1 = czm_computeTextureTransform(tc1, textureTransform);
  7643. tc2 = czm_computeTextureTransform(tc2, textureTransform);
  7644. return mix(texture(textureSampler, tc1), texture(textureSampler, tc2), f);
  7645. }
  7646. #endif
  7647. `;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(`
  7648. `).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(`
  7649. #ifdef HAS_LINE_CUMULATIVE_DISTANCE
  7650. void lineStyleStageVS(in ProcessedAttributes attributes)
  7651. {
  7652. float cumDist = attributes.${d};
  7653. #ifdef LINE_CUM_DIST_NORMALIZED
  7654. cumDist *= u_cumulativeDistanceMax;
  7655. #endif
  7656. const float textureCoordinateBase = 8192.0;
  7657. v_lineCoord = textureCoordinateBase + cumDist * u_pixelsPerWorld;
  7658. }
  7659. #endif
  7660. `)}else l(s)&&o.addVertexLines(`
  7661. #ifdef HAS_LINE_PATTERN
  7662. void lineStyleStageVS(in ProcessedAttributes attributes)
  7663. {
  7664. vec4 posClip = gl_Position;
  7665. vec2 screenPos = ((posClip.xy / posClip.w) * 0.5 + 0.5) * czm_viewport.zw;
  7666. const float textureCoordinateBase = 8192.0;
  7667. if (czm_viewport.z > czm_viewport.w) {
  7668. v_lineCoord = textureCoordinateBase + screenPos.x;
  7669. } else {
  7670. v_lineCoord = textureCoordinateBase + screenPos.y;
  7671. }
  7672. }
  7673. #endif
  7674. `)}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
  7675. {
  7676. vec3 positionMC = attributes.positionMC;
  7677. attributes.positionMC = getMorphedPosition(positionMC);
  7678. #ifdef HAS_NORMALS
  7679. vec3 normalMC = attributes.normalMC;
  7680. attributes.normalMC = getMorphedNormal(normalMC);
  7681. #endif
  7682. #ifdef HAS_TANGENTS
  7683. vec3 tangentMC = attributes.tangentMC;
  7684. attributes.tangentMC = getMorphedTangent(tangentMC);
  7685. #endif
  7686. }`;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
  7687. // Variables are packed into a single vector to minimize gl.uniformXXX() calls
  7688. float pointSize = model_pointCloudParameters.x;
  7689. float geometricError = model_pointCloudParameters.y;
  7690. float depthMultiplier = model_pointCloudParameters.z;
  7691. float depth = -positionEC.z;
  7692. return min((geometricError / depth) * depthMultiplier, pointSize);
  7693. }
  7694. #ifdef HAS_POINT_CLOUD_SHOW_STYLE
  7695. float pointCloudShowStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
  7696. float tiles3d_tileset_time = model_pointCloudParameters.w;
  7697. return float(getShowFromStyle(attributes, metadata, tiles3d_tileset_time));
  7698. }
  7699. #endif
  7700. #ifdef HAS_POINT_CLOUD_COLOR_STYLE
  7701. vec4 pointCloudColorStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
  7702. float tiles3d_tileset_time = model_pointCloudParameters.w;
  7703. return getColorFromStyle(attributes, metadata, tiles3d_tileset_time);
  7704. }
  7705. #endif
  7706. #ifdef HAS_POINT_CLOUD_POINT_SIZE_STYLE
  7707. float pointCloudPointSizeStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
  7708. float tiles3d_tileset_time = model_pointCloudParameters.w;
  7709. return float(getPointSizeFromStyle(attributes, metadata, tiles3d_tileset_time));
  7710. }
  7711. #elif defined(HAS_POINT_CLOUD_ATTENUATION)
  7712. float pointCloudPointSizeStylingStage(in ProcessedAttributes attributes, in Metadata metadata) {
  7713. return getPointSizeFromAttenuation(v_positionEC);
  7714. }
  7715. #endif
  7716. #ifdef HAS_POINT_CLOUD_BACK_FACE_CULLING
  7717. float pointCloudBackFaceCullingStage() {
  7718. #if defined(HAS_NORMALS) && !defined(HAS_DOUBLE_SIDED_MATERIAL)
  7719. // This needs to be computed in eye coordinates so we can't use attributes.normalMC
  7720. return step(-v_normalEC.z, 0.0);
  7721. #else
  7722. return 1.0;
  7723. #endif
  7724. }
  7725. #endif
  7726. `;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() {
  7727. v_outlineCoordinates = a_outlineCoordinates;
  7728. }
  7729. `;var gQn=y(x(),1),dB=`void primitiveOutlineStage(inout czm_modelMaterial material) {
  7730. if (!model_showOutline) {
  7731. return;
  7732. }
  7733. float outlineX =
  7734. texture(model_outlineTexture, vec2(v_outlineCoordinates.x, 0.5)).r;
  7735. float outlineY =
  7736. texture(model_outlineTexture, vec2(v_outlineCoordinates.y, 0.5)).r;
  7737. float outlineZ =
  7738. texture(model_outlineTexture, vec2(v_outlineCoordinates.z, 0.5)).r;
  7739. float outlineness = max(outlineX, max(outlineY, outlineZ));
  7740. material.diffuse = mix(material.diffuse, model_outlineColor.rgb, model_outlineColor.a * outlineness);
  7741. }
  7742. `;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
  7743. {
  7744. mat4 skinningMatrix = getSkinningMatrix();
  7745. mat3 skinningMatrixMat3 = mat3(skinningMatrix);
  7746. vec4 positionMC = vec4(attributes.positionMC, 1.0);
  7747. attributes.positionMC = vec3(skinningMatrix * positionMC);
  7748. #ifdef HAS_NORMALS
  7749. vec3 normalMC = attributes.normalMC;
  7750. attributes.normalMC = skinningMatrixMat3 * normalMC;
  7751. #endif
  7752. #ifdef HAS_TANGENTS
  7753. vec3 tangentMC = attributes.tangentMC;
  7754. attributes.tangentMC = skinningMatrixMat3 * tangentMC;
  7755. #endif
  7756. }`;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(
  7757. inout ProcessedAttributes attributes
  7758. ) {
  7759. // Compute the distance from the camera to the local center of curvature.
  7760. vec4 vertexPositionENU = czm_modelToEnu * vec4(attributes.positionMC, 1.0);
  7761. vec2 vertexAzimuth = normalize(vertexPositionENU.xy);
  7762. // Curvature = 1 / radius of curvature.
  7763. float azimuthalCurvature = dot(vertexAzimuth * vertexAzimuth, czm_eyeEllipsoidCurvature);
  7764. float eyeToCenter = 1.0 / azimuthalCurvature + czm_eyeHeight;
  7765. // Compute the approximate ellipsoid normal at the vertex position.
  7766. // Uses a circular approximation for the Earth curvature along the geodesic.
  7767. vec3 vertexPositionEC = (czm_modelView * vec4(attributes.positionMC, 1.0)).xyz;
  7768. vec3 centerToVertex = eyeToCenter * czm_eyeEllipsoidNormalEC + vertexPositionEC;
  7769. vec3 vertexNormal = normalize(centerToVertex);
  7770. // Estimate the (sine of the) angle between the camera direction and the vertex normal
  7771. float verticalDistance = dot(vertexPositionEC, czm_eyeEllipsoidNormalEC);
  7772. float horizontalDistance = length(vertexPositionEC - verticalDistance * czm_eyeEllipsoidNormalEC);
  7773. float sinTheta = horizontalDistance / (eyeToCenter + verticalDistance);
  7774. bool isSmallAngle = clamp(sinTheta, 0.0, 0.05) == sinTheta;
  7775. // Approximate the change in height above the ellipsoid, from camera to vertex position.
  7776. float exactVersine = 1.0 - dot(czm_eyeEllipsoidNormalEC, vertexNormal);
  7777. float smallAngleVersine = 0.5 * sinTheta * sinTheta;
  7778. float versine = isSmallAngle ? smallAngleVersine : exactVersine;
  7779. float dHeight = dot(vertexPositionEC, vertexNormal) - eyeToCenter * versine;
  7780. float vertexHeight = czm_eyeHeight + dHeight;
  7781. // Transform the approximate vertex normal to model coordinates.
  7782. vec3 vertexNormalMC = (czm_inverseModelView * vec4(vertexNormal, 0.0)).xyz;
  7783. vertexNormalMC = normalize(vertexNormalMC);
  7784. // Compute the exaggeration and apply it along the approximate vertex normal.
  7785. float stretch = u_verticalExaggerationAndRelativeHeight.x;
  7786. float shift = u_verticalExaggerationAndRelativeHeight.y;
  7787. float exaggeration = (vertexHeight - shift) * (stretch - 1.0);
  7788. attributes.positionMC += exaggeration * vertexNormalMC;
  7789. }
  7790. `;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))
  7791. if(model_silhouettePass) {
  7792. color = czm_gammaCorrect(model_silhouetteColor);
  7793. }
  7794. }`;var yzn=y(x(),1),EB=`void silhouetteStage(in ProcessedAttributes attributes, inout vec4 positionClip) {
  7795. #ifdef HAS_NORMALS
  7796. if(model_silhouettePass) {
  7797. vec3 normal = normalize(czm_normal3D * attributes.normalMC);
  7798. normal.x *= czm_projection[0][0];
  7799. normal.y *= czm_projection[1][1];
  7800. positionClip.xy += normal.xy * positionClip.w * model_silhouetteSize * czm_pixelRatio / czm_viewport.z;
  7801. }
  7802. #endif
  7803. }
  7804. `;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()
  7805. {
  7806. // Don't split when rendering the shadow map, because it is rendered from
  7807. // the perspective of a totally different camera.
  7808. #ifndef SHADOW_MAP
  7809. if (model_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
  7810. if (model_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
  7811. #endif
  7812. }
  7813. `;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
  7814. czm_modelVertexOutput defaultVertexOutput(vec3 positionMC) {
  7815. czm_modelVertexOutput vsOutput;
  7816. vsOutput.positionMC = positionMC;
  7817. vsOutput.pointSize = 1.0;
  7818. return vsOutput;
  7819. }
  7820. void main()
  7821. {
  7822. // Initialize the attributes struct with all
  7823. // attributes except quantized ones.
  7824. ProcessedAttributes attributes;
  7825. initializeAttributes(attributes);
  7826. #ifdef HAS_IMAGERY
  7827. initializeImageryAttributes();
  7828. #endif
  7829. // Dequantize the quantized ones and add them to the
  7830. // attributes struct.
  7831. #ifdef USE_DEQUANTIZATION
  7832. dequantizationStage(attributes);
  7833. #endif
  7834. #ifdef HAS_MORPH_TARGETS
  7835. morphTargetsStage(attributes);
  7836. #endif
  7837. #ifdef HAS_SKINNING
  7838. skinningStage(attributes);
  7839. #endif
  7840. #ifdef HAS_PRIMITIVE_OUTLINE
  7841. primitiveOutlineStage();
  7842. #endif
  7843. // Compute the bitangent according to the formula in the glTF spec.
  7844. // Normal and tangents can be affected by morphing and skinning, so
  7845. // the bitangent should not be computed until their values are finalized.
  7846. #ifdef HAS_BITANGENTS
  7847. attributes.bitangentMC = normalize(cross(attributes.normalMC, attributes.tangentMC) * attributes.tangentSignMC);
  7848. #endif
  7849. FeatureIds featureIds;
  7850. featureIdStage(featureIds, attributes);
  7851. #ifdef HAS_SELECTED_FEATURE_ID
  7852. SelectedFeature feature;
  7853. selectedFeatureIdStage(feature, featureIds);
  7854. // Handle any show properties that come from the style.
  7855. cpuStylingStage(attributes.positionMC, feature);
  7856. #endif
  7857. #if defined(USE_2D_POSITIONS) || defined(USE_2D_INSTANCING)
  7858. // The scene mode 2D pipeline stage and instancing stage add a different
  7859. // model view matrix to accurately project the model to 2D. However, the
  7860. // output positions and normals should be transformed by the 3D matrices
  7861. // to keep the data the same for the fragment shader.
  7862. mat4 modelView = czm_modelView3D;
  7863. mat3 normal = czm_normal3D;
  7864. #else
  7865. // These are used for individual model projection because they will
  7866. // automatically change based on the scene mode.
  7867. mat4 modelView = czm_modelView;
  7868. mat3 normal = czm_normal;
  7869. #endif
  7870. // Update the position for this instance in place
  7871. #ifdef HAS_INSTANCING
  7872. // The legacy instance stage is used when rendering i3dm models that
  7873. // encode instances transforms in world space, as opposed to glTF models
  7874. // that use EXT_mesh_gpu_instancing, where instance transforms are encoded
  7875. // in object space.
  7876. #ifdef USE_LEGACY_INSTANCING
  7877. mat4 instanceModelView;
  7878. mat3 instanceModelViewInverseTranspose;
  7879. legacyInstancingStage(attributes, instanceModelView, instanceModelViewInverseTranspose);
  7880. modelView = instanceModelView;
  7881. normal = instanceModelViewInverseTranspose;
  7882. #else
  7883. instancingStage(attributes);
  7884. #endif
  7885. #ifdef USE_PICKING
  7886. v_pickColor = a_pickColor;
  7887. #endif
  7888. #endif
  7889. Metadata metadata;
  7890. MetadataClass metadataClass;
  7891. MetadataStatistics metadataStatistics;
  7892. metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);
  7893. #ifdef HAS_VERTICAL_EXAGGERATION
  7894. verticalExaggerationStage(attributes);
  7895. #endif
  7896. #ifdef HAS_CUSTOM_VERTEX_SHADER
  7897. czm_modelVertexOutput vsOutput = defaultVertexOutput(attributes.positionMC);
  7898. customShaderStage(vsOutput, attributes, featureIds, metadata, metadataClass, metadataStatistics);
  7899. #endif
  7900. // Compute the final position in each coordinate system needed.
  7901. // This returns the value that will be assigned to gl_Position.
  7902. vec4 positionClip = geometryStage(attributes, modelView, normal);
  7903. #if defined(HAS_LINE_CUMULATIVE_DISTANCE) || defined(HAS_LINE_PATTERN)
  7904. lineStyleStageVS(attributes);
  7905. #endif
  7906. // This must go after the geometry stage as it needs v_positionWC
  7907. #ifdef HAS_ATMOSPHERE
  7908. atmosphereStage(attributes);
  7909. #endif
  7910. #ifdef ENABLE_CLIPPING_POLYGONS
  7911. modelClippingPolygonsStage(attributes);
  7912. #endif
  7913. #ifdef HAS_SILHOUETTE
  7914. silhouetteStage(attributes, positionClip);
  7915. #endif
  7916. #ifdef HAS_POINT_CLOUD_SHOW_STYLE
  7917. float show = pointCloudShowStylingStage(attributes, metadata);
  7918. #else
  7919. float show = 1.0;
  7920. #endif
  7921. #ifdef HAS_POINT_CLOUD_BACK_FACE_CULLING
  7922. show *= pointCloudBackFaceCullingStage();
  7923. #endif
  7924. #ifdef HAS_POINT_CLOUD_COLOR_STYLE
  7925. v_pointCloudColor = pointCloudColorStylingStage(attributes, metadata);
  7926. #endif
  7927. #ifdef PRIMITIVE_TYPE_POINTS
  7928. #ifdef HAS_CUSTOM_VERTEX_SHADER
  7929. gl_PointSize = vsOutput.pointSize;
  7930. #elif defined(HAS_POINT_CLOUD_POINT_SIZE_STYLE) || defined(HAS_POINT_CLOUD_ATTENUATION)
  7931. gl_PointSize = pointCloudPointSizeStylingStage(attributes, metadata);
  7932. #elif defined(HAS_POINT_DIAMETER)
  7933. gl_PointSize = u_pointDiameter;
  7934. #else
  7935. gl_PointSize = 1.0;
  7936. #endif
  7937. gl_PointSize *= show;
  7938. #endif
  7939. // Important NOT to compute gl_Position = show * positionClip or we hit:
  7940. // https://github.com/CesiumGS/cesium/issues/11270
  7941. //
  7942. // We will discard points with v_pointCloudShow == 0 in the fragment shader.
  7943. gl_Position = positionClip;
  7944. #ifdef HAS_EDGE_VISIBILITY
  7945. edgeVisibilityStageVS();
  7946. #endif
  7947. #ifdef HAS_POINT_CLOUD_SHOW_STYLE
  7948. v_pointCloudShow = show;
  7949. #endif
  7950. }
  7951. `;var B3n=y(x(),1),wB=`
  7952. precision highp float;
  7953. czm_modelMaterial defaultModelMaterial()
  7954. {
  7955. czm_modelMaterial material;
  7956. material.diffuse = vec3(0.0);
  7957. material.specular = vec3(1.0);
  7958. material.roughness = 1.0;
  7959. material.occlusion = 1.0;
  7960. material.normalEC = vec3(0.0, 0.0, 1.0);
  7961. material.emissive = vec3(0.0);
  7962. material.alpha = 1.0;
  7963. return material;
  7964. }
  7965. vec4 handleAlpha(vec3 color, float alpha)
  7966. {
  7967. #ifdef ALPHA_MODE_MASK
  7968. if (alpha < u_alphaCutoff) {
  7969. discard;
  7970. }
  7971. #endif
  7972. return vec4(color, alpha);
  7973. }
  7974. void lineStyleStage()
  7975. {
  7976. #if defined(HAS_LINE_PATTERN) && !defined(HAS_EDGE_VISIBILITY)
  7977. const float maskLength = 16.0;
  7978. float dashPosition = fract(v_lineCoord / maskLength);
  7979. float maskIndex = floor(dashPosition * maskLength);
  7980. float maskTest = floor(u_linePattern / pow(2.0, maskIndex));
  7981. if (mod(maskTest, 2.0) < 1.0) {
  7982. discard;
  7983. }
  7984. #endif
  7985. }
  7986. SelectedFeature selectedFeature;
  7987. void main()
  7988. {
  7989. #if defined(PRIMITIVE_TYPE_POINTS) && defined(HAS_POINT_DIAMETER)
  7990. // Render points as circles
  7991. float distanceToCenter = length(gl_PointCoord - vec2(0.5));
  7992. if (distanceToCenter > 0.5) {
  7993. discard;
  7994. }
  7995. #endif
  7996. #ifdef HAS_POINT_CLOUD_SHOW_STYLE
  7997. if (v_pointCloudShow == 0.0)
  7998. {
  7999. discard;
  8000. }
  8001. #endif
  8002. #ifdef HAS_MODEL_SPLITTER
  8003. modelSplitterStage();
  8004. #endif
  8005. czm_modelMaterial material = defaultModelMaterial();
  8006. ProcessedAttributes attributes;
  8007. geometryStage(attributes);
  8008. FeatureIds featureIds;
  8009. featureIdStage(featureIds, attributes);
  8010. Metadata metadata;
  8011. MetadataClass metadataClass;
  8012. MetadataStatistics metadataStatistics;
  8013. metadataStage(featureIds, metadata, metadataClass, metadataStatistics, attributes);
  8014. //========================================================================
  8015. // When not picking metadata START
  8016. #ifndef METADATA_PICKING_ENABLED
  8017. #ifdef HAS_SELECTED_FEATURE_ID
  8018. selectedFeatureIdStage(selectedFeature, featureIds);
  8019. #endif
  8020. #ifndef CUSTOM_SHADER_REPLACE_MATERIAL
  8021. materialStage(material, attributes, selectedFeature);
  8022. #endif
  8023. #ifdef HAS_CUSTOM_FRAGMENT_SHADER
  8024. customShaderStage(material, attributes, featureIds, metadata, metadataClass, metadataStatistics);
  8025. #endif
  8026. lightingStage(material, attributes);
  8027. #ifdef HAS_SELECTED_FEATURE_ID
  8028. cpuStylingStage(material, selectedFeature);
  8029. #endif
  8030. #ifdef HAS_MODEL_COLOR
  8031. modelColorStage(material);
  8032. #endif
  8033. #ifdef HAS_PRIMITIVE_OUTLINE
  8034. primitiveOutlineStage(material);
  8035. #endif
  8036. vec4 color = handleAlpha(material.diffuse, material.alpha);
  8037. // When not picking metadata END
  8038. //========================================================================
  8039. #else
  8040. //========================================================================
  8041. // When picking metadata START
  8042. vec4 metadataValues = vec4(0.0, 0.0, 0.0, 0.0);
  8043. metadataPickingStage(metadata, metadataClass, metadataValues);
  8044. vec4 color = metadataValues;
  8045. #endif
  8046. // When picking metadata END
  8047. //========================================================================
  8048. lineStyleStage();
  8049. #ifdef HAS_CLIPPING_PLANES
  8050. modelClippingPlanesStage(color);
  8051. #endif
  8052. #ifdef ENABLE_CLIPPING_POLYGONS
  8053. modelClippingPolygonsStage();
  8054. #endif
  8055. //========================================================================
  8056. // When not picking metadata START
  8057. #ifndef METADATA_PICKING_ENABLED
  8058. #if defined(HAS_SILHOUETTE) && defined(HAS_NORMALS)
  8059. silhouetteStage(color);
  8060. #endif
  8061. #ifdef HAS_ATMOSPHERE
  8062. atmosphereStage(color, attributes);
  8063. #endif
  8064. #ifdef HAS_EDGE_VISIBILITY
  8065. edgeVisibilityStage(color, featureIds);
  8066. edgeDetectionStage(color, featureIds);
  8067. #endif
  8068. #endif
  8069. // When not picking metadata END
  8070. //========================================================================
  8071. out_FragColor = color;
  8072. }
  8073. `;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
  8074. uniform float u_coarseDepthTestDistance;
  8075. uniform float u_threePointDepthTestDistance;
  8076. #ifdef VECTOR_TILE
  8077. uniform vec4 u_highlightColor;
  8078. #endif
  8079. in vec2 v_textureCoordinates;
  8080. in vec4 v_pickColor;
  8081. in vec4 v_color;
  8082. flat in vec2 v_splitDirectionAndEllipsoidDepthEC;
  8083. #ifdef SDF
  8084. in vec4 v_outlineColor;
  8085. in float v_outlineWidth;
  8086. #endif
  8087. in vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
  8088. const float SHIFT_LEFT1 = 2.0;
  8089. const float SHIFT_RIGHT1 = 1.0 / 2.0;
  8090. float getGlobeDepthAtCoords(vec2 st)
  8091. {
  8092. float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, st));
  8093. if (logDepthOrDepth == 0.0)
  8094. {
  8095. return 0.0; // not on the globe
  8096. }
  8097. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
  8098. return eyeCoordinate.z / eyeCoordinate.w;
  8099. }
  8100. #ifdef SDF
  8101. // Get the distance from the edge of a glyph at a given position sampling an SDF texture.
  8102. float getDistance(vec2 position)
  8103. {
  8104. return texture(u_atlas, position).r;
  8105. }
  8106. // Samples the sdf texture at the given position and produces a color based on the fill color and the outline.
  8107. vec4 getSDFColor(vec2 position, float outlineWidth, vec4 outlineColor, float smoothing)
  8108. {
  8109. float distance = getDistance(position);
  8110. if (outlineWidth > 0.0)
  8111. {
  8112. // Don't get the outline edge exceed the SDF_EDGE
  8113. float outlineEdge = clamp(SDF_EDGE - outlineWidth, 0.0, SDF_EDGE);
  8114. float outlineFactor = smoothstep(SDF_EDGE - smoothing, SDF_EDGE + smoothing, distance);
  8115. vec4 sdfColor = mix(outlineColor, v_color, outlineFactor);
  8116. float alpha = smoothstep(outlineEdge - smoothing, outlineEdge + smoothing, distance);
  8117. return vec4(sdfColor.rgb, sdfColor.a * alpha);
  8118. }
  8119. else
  8120. {
  8121. float alpha = smoothstep(SDF_EDGE - smoothing, SDF_EDGE + smoothing, distance);
  8122. return vec4(v_color.rgb, v_color.a * alpha);
  8123. }
  8124. }
  8125. #endif
  8126. bool getDepthTestEnabled() {
  8127. float temp = v_compressed.y;
  8128. temp = temp * SHIFT_RIGHT1;
  8129. float temp2 = (temp - floor(temp)) * SHIFT_LEFT1;
  8130. return temp2 != 0.0;
  8131. }
  8132. float getRelativeEyeDepth(float eyeDepth, float distanceToEllipsoid, float epsilon) {
  8133. float depthDifferential = eyeDepth - distanceToEllipsoid;
  8134. float depthRatio = abs(depthDifferential / distanceToEllipsoid);
  8135. if (depthRatio < epsilon) {
  8136. // The approximations are imprecise, so use an epsilon check for small value differences and assume a value of 0.0
  8137. return 0.0;
  8138. }
  8139. return depthDifferential;
  8140. }
  8141. // Extra manual depth testing is done to allow more control over how a billboard is occluded
  8142. // by the globe when near and far from the camera.
  8143. void doDepthTest(float eyeDepth, float globeDepth) {
  8144. #ifdef VS_THREE_POINT_DEPTH_CHECK
  8145. // Since discarding vertices is not possible, the vertex shader sets eyeDepth to 0 to indicate the depth test failed. Apply the discard here.
  8146. if (eyeDepth > -u_threePointDepthTestDistance) {
  8147. if (eyeDepth == 0.0) {
  8148. discard;
  8149. }
  8150. return;
  8151. }
  8152. #endif
  8153. bool useGlobeDepth = eyeDepth > -u_coarseDepthTestDistance;
  8154. if (useGlobeDepth && globeDepth == 0.0) {
  8155. // Pixel is not on the globe, so there is no distance to compare against. Pass.
  8156. return;
  8157. }
  8158. // If the camera is close, compare against the globe depth texture that includes depth from the 3D tile pass.
  8159. if (useGlobeDepth && getRelativeEyeDepth(eyeDepth, globeDepth, czm_epsilon1) < 0.0) {
  8160. discard;
  8161. }
  8162. }
  8163. #ifdef LOG_DEPTH
  8164. void writeDepth(float eyeDepth, float globeDepth, float distanceToEllipsoid) {
  8165. // If we've made it here, the manual depth test above determined that this fragment should be visible.
  8166. // But the automatic depth test must still run in order to write the result to the depth buffer, and its results may
  8167. // 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.
  8168. float depthArg = v_depthFromNearPlusOne;
  8169. if (globeDepth != 0.0 && getRelativeEyeDepth(eyeDepth, distanceToEllipsoid, czm_epsilon3) > 0.0) {
  8170. float globeDepthFromNearPlusOne = (-globeDepth - czm_currentFrustum.x) + 1.0;
  8171. float nudge = max(globeDepthFromNearPlusOne * 5e-6, czm_epsilon7);
  8172. float globeOnTop = max(1.0, globeDepthFromNearPlusOne - nudge);
  8173. depthArg = min(depthArg, globeOnTop);
  8174. }
  8175. czm_writeLogDepth(depthArg);
  8176. }
  8177. #endif
  8178. void main()
  8179. {
  8180. if (v_splitDirectionAndEllipsoidDepthEC.x < 0.0 && gl_FragCoord.x > czm_splitPosition) {
  8181. discard;
  8182. }
  8183. if (v_splitDirectionAndEllipsoidDepthEC.x > 0.0 && gl_FragCoord.x < czm_splitPosition) {
  8184. discard;
  8185. }
  8186. if (getDepthTestEnabled()) {
  8187. vec2 fragSt = gl_FragCoord.xy / czm_viewport.zw;
  8188. float eyeDepth = v_compressed.x;
  8189. float globeDepth = getGlobeDepthAtCoords(fragSt);
  8190. float distanceToEllipsoid = -v_splitDirectionAndEllipsoidDepthEC.y;
  8191. doDepthTest(eyeDepth, globeDepth);
  8192. #ifdef LOG_DEPTH
  8193. writeDepth(eyeDepth, globeDepth, distanceToEllipsoid);
  8194. #endif
  8195. }
  8196. vec4 color = texture(u_atlas, v_textureCoordinates);
  8197. #ifdef SDF
  8198. float outlineWidth = v_outlineWidth;
  8199. vec4 outlineColor = v_outlineColor;
  8200. // Get the current distance
  8201. float distance = getDistance(v_textureCoordinates);
  8202. #if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives))
  8203. float smoothing = fwidth(distance);
  8204. // Get an offset that is approximately half the distance to the neighbor pixels
  8205. // 0.354 is approximately half of 1/sqrt(2)
  8206. vec2 sampleOffset = 0.354 * vec2(dFdx(v_textureCoordinates) + dFdy(v_textureCoordinates));
  8207. // Sample the center point
  8208. vec4 center = getSDFColor(v_textureCoordinates, outlineWidth, outlineColor, smoothing);
  8209. // Sample the 4 neighbors
  8210. vec4 color1 = getSDFColor(v_textureCoordinates + vec2(sampleOffset.x, sampleOffset.y), outlineWidth, outlineColor, smoothing);
  8211. vec4 color2 = getSDFColor(v_textureCoordinates + vec2(-sampleOffset.x, sampleOffset.y), outlineWidth, outlineColor, smoothing);
  8212. vec4 color3 = getSDFColor(v_textureCoordinates + vec2(-sampleOffset.x, -sampleOffset.y), outlineWidth, outlineColor, smoothing);
  8213. vec4 color4 = getSDFColor(v_textureCoordinates + vec2(sampleOffset.x, -sampleOffset.y), outlineWidth, outlineColor, smoothing);
  8214. // Equally weight the center sample and the 4 neighboring samples
  8215. color = (center + color1 + color2 + color3 + color4)/5.0;
  8216. #else
  8217. // If no derivatives available (IE 10?), just do a single sample
  8218. float smoothing = 1.0/32.0;
  8219. color = getSDFColor(v_textureCoordinates, outlineWidth, outlineColor, smoothing);
  8220. #endif
  8221. color = czm_gammaCorrect(color);
  8222. #else
  8223. color = czm_gammaCorrect(color);
  8224. color *= czm_gammaCorrect(v_color);
  8225. #endif
  8226. // Fully transparent parts of the billboard are not pickable.
  8227. #if !defined(OPAQUE) && !defined(TRANSLUCENT)
  8228. if (color.a < 0.005) // matches 0/255 and 1/255
  8229. {
  8230. discard;
  8231. }
  8232. #else
  8233. // The billboard is rendered twice. The opaque pass discards translucent fragments
  8234. // and the translucent pass discards opaque fragments.
  8235. #ifdef OPAQUE
  8236. if (color.a < 0.995) // matches < 254/255
  8237. {
  8238. discard;
  8239. }
  8240. #else
  8241. if (color.a >= 0.995) // matches 254/255 and 255/255
  8242. {
  8243. discard;
  8244. }
  8245. #endif
  8246. #endif
  8247. #ifdef VECTOR_TILE
  8248. color *= u_highlightColor;
  8249. #endif
  8250. out_FragColor = color;
  8251. }
  8252. `;var HKn=y(x(),1),zB=`uniform float u_threePointDepthTestDistance;
  8253. in vec2 direction;
  8254. in vec4 positionHighAndScale;
  8255. in vec4 positionLowAndRotation;
  8256. in vec4 compressedAttribute0; // pixel offset, translate, horizontal origin, vertical origin, show, direction, texture coordinates (texture offset)
  8257. in vec4 compressedAttribute1; // aligned axis, translucency by distance, image width
  8258. in vec4 compressedAttribute2; // label horizontal origin, image height, color, pick color, size in meters, valid aligned axis, 13 bits free
  8259. in vec4 eyeOffset; // eye offset in meters, 4 bytes free (texture range)
  8260. in vec4 scaleByDistance; // near, nearScale, far, farScale
  8261. in vec4 pixelOffsetScaleByDistance; // near, nearScale, far, farScale
  8262. in vec4 compressedAttribute3; // distance display condition near, far, disableDepthTestDistanceSq, dimensions
  8263. in vec2 sdf; // sdf outline color (rgb) and width (w)
  8264. in float splitDirection; // splitDirection
  8265. #ifdef VS_THREE_POINT_DEPTH_CHECK
  8266. in vec4 textureCoordinateBoundsOrLabelTranslate; // the min and max x and y values for the texture coordinates
  8267. #endif
  8268. #ifdef VECTOR_TILE
  8269. in float a_batchId;
  8270. #endif
  8271. out vec2 v_textureCoordinates;
  8272. out vec4 v_compressed; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
  8273. out vec4 v_pickColor;
  8274. out vec4 v_color;
  8275. flat out vec2 v_splitDirectionAndEllipsoidDepthEC; // x: splitDirection, y: ellipsoid depth in eye coordinates
  8276. #ifdef SDF
  8277. out vec4 v_outlineColor;
  8278. out float v_outlineWidth;
  8279. #endif
  8280. const float UPPER_BOUND = 32768.0;
  8281. const float SHIFT_LEFT16 = 65536.0;
  8282. const float SHIFT_LEFT12 = 4096.0;
  8283. const float SHIFT_LEFT8 = 256.0;
  8284. const float SHIFT_LEFT7 = 128.0;
  8285. const float SHIFT_LEFT5 = 32.0;
  8286. const float SHIFT_LEFT3 = 8.0;
  8287. const float SHIFT_LEFT2 = 4.0;
  8288. const float SHIFT_LEFT1 = 2.0;
  8289. const float SHIFT_RIGHT12 = 1.0 / 4096.0;
  8290. const float SHIFT_RIGHT8 = 1.0 / 256.0;
  8291. const float SHIFT_RIGHT7 = 1.0 / 128.0;
  8292. const float SHIFT_RIGHT5 = 1.0 / 32.0;
  8293. const float SHIFT_RIGHT3 = 1.0 / 8.0;
  8294. const float SHIFT_RIGHT2 = 1.0 / 4.0;
  8295. const float SHIFT_RIGHT1 = 1.0 / 2.0;
  8296. 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)
  8297. {
  8298. // Note the halfSize cannot be computed in JavaScript because it is sent via
  8299. // compressed vertex attributes that coerce it to an integer.
  8300. vec2 halfSize = imageSize * scale * 0.5;
  8301. halfSize *= ((direction * 2.0) - 1.0);
  8302. vec2 originTranslate = origin * abs(halfSize);
  8303. #if defined(ROTATION) || defined(ALIGNED_AXIS)
  8304. if (validAlignedAxis || rotation != 0.0)
  8305. {
  8306. float angle = rotation;
  8307. if (validAlignedAxis)
  8308. {
  8309. vec4 projectedAlignedAxis = czm_modelView3D * vec4(alignedAxis, 0.0);
  8310. angle += sign(-projectedAlignedAxis.x) * acos(sign(projectedAlignedAxis.y) * (projectedAlignedAxis.y * projectedAlignedAxis.y) /
  8311. (projectedAlignedAxis.x * projectedAlignedAxis.x + projectedAlignedAxis.y * projectedAlignedAxis.y));
  8312. }
  8313. float cosTheta = cos(angle);
  8314. float sinTheta = sin(angle);
  8315. rotationMatrix = mat2(cosTheta, sinTheta, -sinTheta, cosTheta);
  8316. halfSize = rotationMatrix * halfSize;
  8317. }
  8318. else
  8319. {
  8320. rotationMatrix = mat2(1.0, 0.0, 0.0, 1.0);
  8321. }
  8322. #endif
  8323. mpp = czm_metersPerPixel(positionEC);
  8324. positionEC.xy += (originTranslate + halfSize) * czm_branchFreeTernary(sizeInMeters, 1.0, mpp);
  8325. positionEC.xy += (translate + pixelOffset) * mpp;
  8326. return positionEC;
  8327. }
  8328. #ifdef VS_THREE_POINT_DEPTH_CHECK
  8329. float getGlobeDepth(vec4 positionEC)
  8330. {
  8331. vec4 posWC = czm_eyeToWindowCoordinates(positionEC);
  8332. float globeDepth = czm_unpackDepth(texture(czm_globeDepthTexture, posWC.xy / czm_viewport.zw));
  8333. if (globeDepth == 0.0)
  8334. {
  8335. return 0.0; // not on the globe
  8336. }
  8337. vec4 eyeCoordinate = czm_windowToEyeCoordinates(posWC.xy, globeDepth);
  8338. return eyeCoordinate.z / eyeCoordinate.w;
  8339. }
  8340. #endif
  8341. void main()
  8342. {
  8343. // Modifying this shader may also require modifications to Billboard._computeScreenSpacePosition
  8344. // unpack attributes
  8345. vec3 positionHigh = positionHighAndScale.xyz;
  8346. vec3 positionLow = positionLowAndRotation.xyz;
  8347. float scale = positionHighAndScale.w;
  8348. #if defined(ROTATION) || defined(ALIGNED_AXIS)
  8349. float rotation = positionLowAndRotation.w;
  8350. #else
  8351. float rotation = 0.0;
  8352. #endif
  8353. float compressed = compressedAttribute0.x;
  8354. vec2 pixelOffset;
  8355. pixelOffset.x = floor(compressed * SHIFT_RIGHT7);
  8356. compressed -= pixelOffset.x * SHIFT_LEFT7;
  8357. pixelOffset.x -= UPPER_BOUND;
  8358. vec2 origin;
  8359. origin.x = floor(compressed * SHIFT_RIGHT5);
  8360. compressed -= origin.x * SHIFT_LEFT5;
  8361. origin.y = floor(compressed * SHIFT_RIGHT3);
  8362. compressed -= origin.y * SHIFT_LEFT3;
  8363. origin -= vec2(1.0);
  8364. float show = floor(compressed * SHIFT_RIGHT2);
  8365. compressed -= show * SHIFT_LEFT2;
  8366. vec2 textureCoordinatesBottomLeft = czm_decompressTextureCoordinates(compressedAttribute0.w);
  8367. vec2 textureCoordinatesRange = czm_decompressTextureCoordinates(eyeOffset.w);
  8368. vec2 textureCoordinates = textureCoordinatesBottomLeft + direction * textureCoordinatesRange;
  8369. float temp = compressedAttribute0.y * SHIFT_RIGHT8;
  8370. pixelOffset.y = -(floor(temp) - UPPER_BOUND);
  8371. vec2 translate;
  8372. translate.y = (temp - floor(temp)) * SHIFT_LEFT16;
  8373. temp = compressedAttribute0.z * SHIFT_RIGHT8;
  8374. translate.x = floor(temp) - UPPER_BOUND;
  8375. translate.x *= SHIFT_RIGHT2; // undo translateX scaling (helps preserve subpixel precision, see BillboardCollection.js attribute writer for more info)
  8376. translate.y += (temp - floor(temp)) * SHIFT_LEFT8;
  8377. translate.y -= UPPER_BOUND;
  8378. translate.y *= SHIFT_RIGHT2;
  8379. temp = compressedAttribute1.x * SHIFT_RIGHT8;
  8380. float temp2 = floor(compressedAttribute2.w * SHIFT_RIGHT2);
  8381. vec2 imageSize = vec2(floor(temp), temp2);
  8382. #ifdef EYE_DISTANCE_TRANSLUCENCY
  8383. vec4 translucencyByDistance;
  8384. translucencyByDistance.x = compressedAttribute1.z;
  8385. translucencyByDistance.z = compressedAttribute1.w;
  8386. translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
  8387. temp = compressedAttribute1.y * SHIFT_RIGHT8;
  8388. translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
  8389. #endif
  8390. #ifdef VS_THREE_POINT_DEPTH_CHECK
  8391. temp = compressedAttribute3.w;
  8392. temp = temp * SHIFT_RIGHT12;
  8393. vec2 dimensions;
  8394. dimensions.y = (temp - floor(temp)) * SHIFT_LEFT12;
  8395. dimensions.x = floor(temp);
  8396. #endif
  8397. #ifdef ALIGNED_AXIS
  8398. vec3 alignedAxis = czm_octDecode(floor(compressedAttribute1.y * SHIFT_RIGHT8));
  8399. temp = compressedAttribute2.z * SHIFT_RIGHT5;
  8400. bool validAlignedAxis = (temp - floor(temp)) * SHIFT_LEFT1 > 0.0;
  8401. #else
  8402. vec3 alignedAxis = vec3(0.0);
  8403. bool validAlignedAxis = false;
  8404. #endif
  8405. vec4 color = czm_decodeRGB8(compressedAttribute2.x);
  8406. vec4 pickColor = czm_decodeRGB8(compressedAttribute2.y);
  8407. temp = compressedAttribute2.z * SHIFT_RIGHT8;
  8408. bool sizeInMeters = floor((temp - floor(temp)) * SHIFT_LEFT7) > 0.0;
  8409. temp = floor(temp) * SHIFT_RIGHT8;
  8410. pickColor.a = (temp - floor(temp)) * SHIFT_LEFT8;
  8411. pickColor.a /= 255.0;
  8412. color.a = floor(temp);
  8413. color.a /= 255.0;
  8414. ///////////////////////////////////////////////////////////////////////////
  8415. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  8416. vec4 positionEC = czm_modelViewRelativeToEye * p;
  8417. positionEC = czm_eyeOffset(positionEC, eyeOffset.xyz);
  8418. positionEC.xyz *= show;
  8419. ///////////////////////////////////////////////////////////////////////////
  8420. #if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(EYE_DISTANCE_PIXEL_OFFSET) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)
  8421. float lengthSq;
  8422. if (czm_sceneMode == czm_sceneMode2D)
  8423. {
  8424. // 2D camera distance is a special case
  8425. // treat all billboards as flattened to the z=0.0 plane
  8426. lengthSq = czm_eyeHeight2D.y;
  8427. }
  8428. else
  8429. {
  8430. lengthSq = dot(positionEC.xyz, positionEC.xyz);
  8431. }
  8432. #endif
  8433. #ifdef EYE_DISTANCE_SCALING
  8434. float distanceScale = czm_nearFarScalar(scaleByDistance, lengthSq);
  8435. scale *= distanceScale;
  8436. translate *= distanceScale;
  8437. // push vertex behind near plane for clipping
  8438. if (scale == 0.0)
  8439. {
  8440. positionEC.xyz = vec3(0.0);
  8441. }
  8442. #endif
  8443. float translucency = 1.0;
  8444. #ifdef EYE_DISTANCE_TRANSLUCENCY
  8445. translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);
  8446. // push vertex behind near plane for clipping
  8447. if (translucency == 0.0)
  8448. {
  8449. positionEC.xyz = vec3(0.0);
  8450. }
  8451. #endif
  8452. #ifdef EYE_DISTANCE_PIXEL_OFFSET
  8453. float pixelOffsetScale = czm_nearFarScalar(pixelOffsetScaleByDistance, lengthSq);
  8454. pixelOffset *= pixelOffsetScale;
  8455. #endif
  8456. #ifdef DISTANCE_DISPLAY_CONDITION
  8457. float nearSq = compressedAttribute3.x;
  8458. float farSq = compressedAttribute3.y;
  8459. if (lengthSq < nearSq || lengthSq > farSq)
  8460. {
  8461. positionEC.xyz = vec3(0.0);
  8462. }
  8463. #endif
  8464. mat2 rotationMatrix;
  8465. float mpp;
  8466. float enableDepthCheck = 1.0;
  8467. #ifdef DISABLE_DEPTH_DISTANCE
  8468. float disableDepthTestDistanceSq = compressedAttribute3.z;
  8469. if (disableDepthTestDistanceSq == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)
  8470. {
  8471. disableDepthTestDistanceSq = czm_minimumDisableDepthTestDistance;
  8472. }
  8473. if (lengthSq < disableDepthTestDistanceSq || disableDepthTestDistanceSq < 0.0)
  8474. {
  8475. enableDepthCheck = 0.0;
  8476. }
  8477. #endif
  8478. v_splitDirectionAndEllipsoidDepthEC.y = czm_infinity;
  8479. vec3 ellipsoidCenter = czm_view[3].xyz;
  8480. vec3 rayDirection = normalize(positionEC.xyz);
  8481. czm_ray ray = czm_ray(vec3(0.0), rayDirection);
  8482. vec3 ellipsoid_inverseRadii = czm_ellipsoidInverseRadii;
  8483. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii);
  8484. if (!czm_isEmpty(intersection))
  8485. {
  8486. v_splitDirectionAndEllipsoidDepthEC.y = intersection.start;
  8487. }
  8488. v_compressed.y = enableDepthCheck;
  8489. #ifdef VS_THREE_POINT_DEPTH_CHECK
  8490. if (lengthSq < (u_threePointDepthTestDistance * u_threePointDepthTestDistance) && (enableDepthCheck == 1.0)) {
  8491. float depthsilon = 10.0;
  8492. vec2 depthOrigin;
  8493. // Horizontal origin for labels comes from a special attribute. If that value is 0, this is a billboard - use the regular origin.
  8494. // Otherwise, transform the label origin to -1, 0, 1 (right, center, left).
  8495. depthOrigin.x = floor(compressedAttribute2.w - (temp2 * SHIFT_LEFT2));
  8496. depthOrigin.x = czm_branchFreeTernary(depthOrigin.x == 0.0, origin.x, depthOrigin.x - 2.0);
  8497. depthOrigin.y = origin.y;
  8498. vec4 pEC1 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
  8499. float globeDepth1 = getGlobeDepth(pEC1);
  8500. if (globeDepth1 != 0.0 && pEC1.z + depthsilon < globeDepth1)
  8501. {
  8502. vec4 pEC2 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(0.0, 1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
  8503. float globeDepth2 = getGlobeDepth(pEC2);
  8504. if (globeDepth2 != 0.0 && pEC2.z + depthsilon < globeDepth2)
  8505. {
  8506. vec4 pEC3 = addScreenSpaceOffset(positionEC, dimensions, scale, vec2(1.0), depthOrigin, vec2(0.0), pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
  8507. float globeDepth3 = getGlobeDepth(pEC3);
  8508. if (globeDepth3 != 0.0 && pEC3.z + depthsilon < globeDepth3)
  8509. {
  8510. // "Discard" this vertex, as three key points fail depth test.
  8511. positionEC.xyz = vec3(0.0);
  8512. }
  8513. }
  8514. }
  8515. }
  8516. #endif
  8517. // Write out the eyespace depth before applying the screen space offset, but after potentially "discarding" the vertex
  8518. // by setting its eyespace position to zero, via the three-point depth test above.
  8519. v_compressed.x = positionEC.z;
  8520. positionEC = addScreenSpaceOffset(positionEC, imageSize, scale, direction, origin, translate, pixelOffset, alignedAxis, validAlignedAxis, rotation, sizeInMeters, rotationMatrix, mpp);
  8521. gl_Position = czm_projection * positionEC;
  8522. v_textureCoordinates = textureCoordinates;
  8523. #ifdef LOG_DEPTH
  8524. czm_vertexLogDepth();
  8525. #endif
  8526. #ifdef DISABLE_DEPTH_DISTANCE
  8527. if (disableDepthTestDistanceSq != 0.0)
  8528. {
  8529. // Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
  8530. float zclip = gl_Position.z / gl_Position.w;
  8531. bool clipped = (zclip < -1.0 || zclip > 1.0);
  8532. // disableDepthTestDistanceSq can be less than zero if it's explicitly set to -1 in JS (as a sentinel value equivalent to infinity)
  8533. if (!clipped && (disableDepthTestDistanceSq < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistanceSq)))
  8534. {
  8535. // Position z on the near plane.
  8536. gl_Position.z = -gl_Position.w;
  8537. #ifdef LOG_DEPTH
  8538. v_depthFromNearPlusOne = 1.0;
  8539. #endif
  8540. }
  8541. }
  8542. #endif
  8543. #ifdef SDF
  8544. vec4 outlineColor = czm_decodeRGB8(sdf.x);
  8545. float outlineWidth;
  8546. temp = sdf.y;
  8547. temp = temp * SHIFT_RIGHT8;
  8548. float temp3 = (temp - floor(temp)) * SHIFT_LEFT8;
  8549. temp = floor(temp) * SHIFT_RIGHT8;
  8550. outlineWidth = (temp - floor(temp)) * SHIFT_LEFT8;
  8551. outlineColor.a = floor(temp);
  8552. outlineColor.a /= 255.0;
  8553. v_outlineWidth = outlineWidth / 255.0;
  8554. v_outlineColor = outlineColor;
  8555. v_outlineColor.a *= translucency;
  8556. #endif
  8557. v_pickColor = pickColor;
  8558. v_color = color;
  8559. v_color.a *= translucency;
  8560. v_splitDirectionAndEllipsoidDepthEC.x = splitDirection;
  8561. }
  8562. `;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??!
  8563. in vec2 v_textureCoordinates;
  8564. void main()
  8565. {
  8566. out_FragColor = texture(billboard_texture, v_textureCoordinates);
  8567. }
  8568. `,{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(
  8569. `),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+=`
  8570. `)}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(`
  8571. `).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)===`
  8572. `){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)===`
  8573. `){++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(`
  8574. `).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;
  8575. in vec3 position3DLow;
  8576. in vec3 position2DHigh;
  8577. in vec3 position2DLow;
  8578. in vec3 prevPosition3DHigh;
  8579. in vec3 prevPosition3DLow;
  8580. in vec3 prevPosition2DHigh;
  8581. in vec3 prevPosition2DLow;
  8582. in vec3 nextPosition3DHigh;
  8583. in vec3 nextPosition3DLow;
  8584. in vec3 nextPosition2DHigh;
  8585. in vec3 nextPosition2DLow;
  8586. in vec4 texCoordExpandAndBatchIndex;
  8587. out vec2 v_st;
  8588. out float v_width;
  8589. out vec4 v_pickColor;
  8590. out float v_polylineAngle;
  8591. void main()
  8592. {
  8593. float texCoord = texCoordExpandAndBatchIndex.x;
  8594. float expandDir = texCoordExpandAndBatchIndex.y;
  8595. bool usePrev = texCoordExpandAndBatchIndex.z < 0.0;
  8596. float batchTableIndex = texCoordExpandAndBatchIndex.w;
  8597. vec2 widthAndShow = batchTable_getWidthAndShow(batchTableIndex);
  8598. float width = widthAndShow.x + 0.5;
  8599. float show = widthAndShow.y;
  8600. if (width < 1.0)
  8601. {
  8602. show = 0.0;
  8603. }
  8604. vec4 pickColor = batchTable_getPickColor(batchTableIndex);
  8605. vec4 p, prev, next;
  8606. if (czm_morphTime == 1.0)
  8607. {
  8608. p = czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz);
  8609. prev = czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz);
  8610. next = czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz);
  8611. }
  8612. else if (czm_morphTime == 0.0)
  8613. {
  8614. p = czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy);
  8615. prev = czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy);
  8616. next = czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy);
  8617. }
  8618. else
  8619. {
  8620. p = czm_columbusViewMorph(
  8621. czm_translateRelativeToEye(position2DHigh.zxy, position2DLow.zxy),
  8622. czm_translateRelativeToEye(position3DHigh.xyz, position3DLow.xyz),
  8623. czm_morphTime);
  8624. prev = czm_columbusViewMorph(
  8625. czm_translateRelativeToEye(prevPosition2DHigh.zxy, prevPosition2DLow.zxy),
  8626. czm_translateRelativeToEye(prevPosition3DHigh.xyz, prevPosition3DLow.xyz),
  8627. czm_morphTime);
  8628. next = czm_columbusViewMorph(
  8629. czm_translateRelativeToEye(nextPosition2DHigh.zxy, nextPosition2DLow.zxy),
  8630. czm_translateRelativeToEye(nextPosition3DHigh.xyz, nextPosition3DLow.xyz),
  8631. czm_morphTime);
  8632. }
  8633. #ifdef DISTANCE_DISPLAY_CONDITION
  8634. vec3 centerHigh = batchTable_getCenterHigh(batchTableIndex);
  8635. vec4 centerLowAndRadius = batchTable_getCenterLowAndRadius(batchTableIndex);
  8636. vec3 centerLow = centerLowAndRadius.xyz;
  8637. float radius = centerLowAndRadius.w;
  8638. vec2 distanceDisplayCondition = batchTable_getDistanceDisplayCondition(batchTableIndex);
  8639. float lengthSq;
  8640. if (czm_sceneMode == czm_sceneMode2D)
  8641. {
  8642. lengthSq = czm_eyeHeight2D.y;
  8643. }
  8644. else
  8645. {
  8646. vec4 center = czm_translateRelativeToEye(centerHigh.xyz, centerLow.xyz);
  8647. lengthSq = max(0.0, dot(center.xyz, center.xyz) - radius * radius);
  8648. }
  8649. float nearSq = distanceDisplayCondition.x * distanceDisplayCondition.x;
  8650. float farSq = distanceDisplayCondition.y * distanceDisplayCondition.y;
  8651. if (lengthSq < nearSq || lengthSq > farSq)
  8652. {
  8653. show = 0.0;
  8654. }
  8655. #endif
  8656. float polylineAngle;
  8657. vec4 positionWC = getPolylineWindowCoordinates(p, prev, next, expandDir, width, usePrev, polylineAngle);
  8658. gl_Position = czm_viewportOrthographic * positionWC * show;
  8659. v_st.s = texCoord;
  8660. v_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);
  8661. v_width = width;
  8662. v_pickColor = pickColor;
  8663. v_polylineAngle = polylineAngle;
  8664. }
  8665. `;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(
  8666. `,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
  8667. in vec4 previousPosition;
  8668. in vec4 nextPosition;
  8669. in vec2 expandAndWidth;
  8670. in float a_batchId;
  8671. uniform mat4 u_modifiedModelView;
  8672. void main()
  8673. {
  8674. float expandDir = expandAndWidth.x;
  8675. float width = abs(expandAndWidth.y) + 0.5;
  8676. bool usePrev = expandAndWidth.y < 0.0;
  8677. vec4 p = u_modifiedModelView * currentPosition;
  8678. vec4 prev = u_modifiedModelView * previousPosition;
  8679. vec4 next = u_modifiedModelView * nextPosition;
  8680. float angle;
  8681. vec4 positionWC = getPolylineWindowCoordinatesEC(p, prev, next, expandDir, width, usePrev, angle);
  8682. gl_Position = czm_viewportOrthographic * positionWC;
  8683. }
  8684. `;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
  8685. void main()
  8686. {
  8687. out_FragColor = u_highlightColor;
  8688. }
  8689. `;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;
  8690. in vec3 endEllipsoidNormal;
  8691. in vec4 startPositionAndHeight;
  8692. in vec4 endPositionAndHeight;
  8693. in vec4 startFaceNormalAndVertexCorner;
  8694. in vec4 endFaceNormalAndHalfWidth;
  8695. in float a_batchId;
  8696. uniform mat4 u_modifiedModelView;
  8697. uniform vec2 u_minimumMaximumVectorHeights;
  8698. out vec4 v_startPlaneEC;
  8699. out vec4 v_endPlaneEC;
  8700. out vec4 v_rightPlaneEC;
  8701. out float v_halfWidth;
  8702. out vec3 v_volumeUpEC;
  8703. void main()
  8704. {
  8705. // vertex corner IDs
  8706. // 3-----------7
  8707. // /| left /|
  8708. // / | 1 / |
  8709. // 2-----------6 5 end
  8710. // | / | /
  8711. // start |/ right |/
  8712. // 0-----------4
  8713. //
  8714. float isEnd = floor(startFaceNormalAndVertexCorner.w * 0.251); // 0 for front, 1 for end
  8715. float isTop = floor(startFaceNormalAndVertexCorner.w * mix(0.51, 0.19, isEnd)); // 0 for bottom, 1 for top
  8716. vec3 forward = endPositionAndHeight.xyz - startPositionAndHeight.xyz;
  8717. vec3 right = normalize(cross(forward, startEllipsoidNormal));
  8718. vec4 position = vec4(startPositionAndHeight.xyz, 1.0);
  8719. position.xyz += forward * isEnd;
  8720. v_volumeUpEC = czm_normal * normalize(cross(right, forward));
  8721. // Push for volume height
  8722. float offset;
  8723. vec3 ellipsoidNormal = mix(startEllipsoidNormal, endEllipsoidNormal, isEnd);
  8724. // offset height to create volume
  8725. offset = mix(startPositionAndHeight.w, endPositionAndHeight.w, isEnd);
  8726. offset = mix(u_minimumMaximumVectorHeights.y, u_minimumMaximumVectorHeights.x, isTop) - offset;
  8727. position.xyz += offset * ellipsoidNormal;
  8728. // move from RTC to EC
  8729. position = u_modifiedModelView * position;
  8730. right = czm_normal * right;
  8731. // Push for width in a direction that is in the start or end plane and in a plane with right
  8732. // N = normalEC ("right-facing" direction for push)
  8733. // R = right
  8734. // p = angle between N and R
  8735. // w = distance to push along R if R == N
  8736. // d = distance to push along N
  8737. //
  8738. // N R
  8739. // { p| } * cos(p) = dot(N, R) = w / d
  8740. // d | |w * d = w / dot(N, R)
  8741. // { | }
  8742. // o---------- polyline segment ---->
  8743. //
  8744. vec3 scratchNormal = mix(-startFaceNormalAndVertexCorner.xyz, endFaceNormalAndHalfWidth.xyz, isEnd);
  8745. scratchNormal = cross(scratchNormal, mix(startEllipsoidNormal, endEllipsoidNormal, isEnd));
  8746. vec3 miterPushNormal = czm_normal * normalize(scratchNormal);
  8747. offset = 2.0 * endFaceNormalAndHalfWidth.w * max(0.0, czm_metersPerPixel(position)); // offset = widthEC
  8748. offset = offset / dot(miterPushNormal, right);
  8749. position.xyz += miterPushNormal * (offset * sign(0.5 - mod(startFaceNormalAndVertexCorner.w, 2.0)));
  8750. gl_Position = czm_depthClamp(czm_projection * position);
  8751. position = u_modifiedModelView * vec4(startPositionAndHeight.xyz, 1.0);
  8752. vec3 startNormalEC = czm_normal * startFaceNormalAndVertexCorner.xyz;
  8753. v_startPlaneEC = vec4(startNormalEC, -dot(startNormalEC, position.xyz));
  8754. v_rightPlaneEC = vec4(right, -dot(right, position.xyz));
  8755. position = u_modifiedModelView * vec4(endPositionAndHeight.xyz, 1.0);
  8756. vec3 endNormalEC = czm_normal * endFaceNormalAndHalfWidth.xyz;
  8757. v_endPlaneEC = vec4(endNormalEC, -dot(endNormalEC, position.xyz));
  8758. v_halfWidth = endFaceNormalAndHalfWidth.w;
  8759. }
  8760. `;var P6n=y(x(),1),dw=`in vec4 v_startPlaneEC;
  8761. in vec4 v_endPlaneEC;
  8762. in vec4 v_rightPlaneEC;
  8763. in float v_halfWidth;
  8764. in vec3 v_volumeUpEC;
  8765. uniform vec4 u_highlightColor;
  8766. void main()
  8767. {
  8768. float logDepthOrDepth = czm_branchFreeTernary(czm_sceneMode == czm_sceneMode2D, gl_FragCoord.z, czm_unpackDepth(texture(czm_globeDepthTexture, gl_FragCoord.xy / czm_viewport.zw)));
  8769. // Discard for sky
  8770. if (logDepthOrDepth == 0.0) {
  8771. #ifdef DEBUG_SHOW_VOLUME
  8772. out_FragColor = vec4(0.0, 0.0, 1.0, 0.5);
  8773. return;
  8774. #else // DEBUG_SHOW_VOLUME
  8775. discard;
  8776. #endif // DEBUG_SHOW_VOLUME
  8777. }
  8778. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
  8779. eyeCoordinate /= eyeCoordinate.w;
  8780. float halfMaxWidth = v_halfWidth * czm_metersPerPixel(eyeCoordinate);
  8781. // Expand halfMaxWidth if direction to camera is almost perpendicular with the volume's up direction
  8782. halfMaxWidth += halfMaxWidth * (1.0 - dot(-normalize(eyeCoordinate.xyz), v_volumeUpEC));
  8783. // Check distance of the eye coordinate against the right-facing plane
  8784. float widthwiseDistance = czm_planeDistance(v_rightPlaneEC, eyeCoordinate.xyz);
  8785. // Check eye coordinate against the mitering planes
  8786. float distanceFromStart = czm_planeDistance(v_startPlaneEC, eyeCoordinate.xyz);
  8787. float distanceFromEnd = czm_planeDistance(v_endPlaneEC, eyeCoordinate.xyz);
  8788. if (abs(widthwiseDistance) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0) {
  8789. #ifdef DEBUG_SHOW_VOLUME
  8790. out_FragColor = vec4(logDepthOrDepth, 0.0, 0.0, 0.5);
  8791. return;
  8792. #else // DEBUG_SHOW_VOLUME
  8793. discard;
  8794. #endif // DEBUG_SHOW_VOLUME
  8795. }
  8796. out_FragColor = u_highlightColor;
  8797. czm_writeDepthClamp();
  8798. }
  8799. `;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
  8800. in vec3 positionLow;
  8801. in vec4 pickColor;
  8802. in vec3 showPixelSizeAndColor;
  8803. in vec2 outlineWidthAndOutlineColor;
  8804. out vec4 v_pickColor;
  8805. out vec4 v_color;
  8806. out vec4 v_outlineColor;
  8807. out float v_innerRadiusFrac;
  8808. void main()
  8809. {
  8810. // Unpack attributes.
  8811. float show = showPixelSizeAndColor.x;
  8812. float pixelSize = showPixelSizeAndColor.y;
  8813. vec4 color = czm_decodeRGB8(showPixelSizeAndColor.z);
  8814. float outlineWidth = outlineWidthAndOutlineColor.x;
  8815. vec4 outlineColor = czm_decodeRGB8(outlineWidthAndOutlineColor.y);
  8816. ///////////////////////////////////////////////////////////////////////////
  8817. float innerRadius = 0.5 * pixelSize * czm_pixelRatio;
  8818. float outerRadius = (0.5 * pixelSize + outlineWidth) * czm_pixelRatio;
  8819. ///////////////////////////////////////////////////////////////////////////
  8820. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  8821. vec4 positionEC = czm_modelViewRelativeToEye * p;
  8822. ///////////////////////////////////////////////////////////////////////////
  8823. gl_Position = czm_projection * positionEC;
  8824. czm_vertexLogDepth();
  8825. v_pickColor = pickColor / 255.0;
  8826. v_color = color;
  8827. v_color.a *= show;
  8828. v_outlineColor = outlineColor;
  8829. v_outlineColor.a *= show;
  8830. v_innerRadiusFrac = innerRadius / outerRadius;
  8831. gl_PointSize = 2.0 * outerRadius * show;
  8832. gl_Position *= show;
  8833. }
  8834. `;var f$n=y(x(),1),Aw=`in vec4 v_pickColor;
  8835. in vec4 v_color;
  8836. in vec4 v_outlineColor;
  8837. in float v_innerRadiusFrac;
  8838. void main()
  8839. {
  8840. // Distance between fragment and point center, 0 to 0.5.
  8841. float distanceToCenter = length(gl_PointCoord - vec2(0.5));
  8842. float delta = fwidth(distanceToCenter);
  8843. float outerLimit = 0.5;
  8844. float innerLimit = 0.5 * v_innerRadiusFrac;
  8845. float outerAlpha = 1.0 - smoothstep(max(0.0, outerLimit - delta), outerLimit, distanceToCenter);
  8846. float innerAlpha = 1.0 - smoothstep(innerLimit - delta, innerLimit, distanceToCenter);
  8847. vec4 color = vec4(mix(v_outlineColor.rgb, v_color.rgb, innerAlpha), outerAlpha);
  8848. if (color.a < 0.005) // matches 0/255 and 1/255
  8849. {
  8850. discard;
  8851. }
  8852. out_FragColor = czm_gammaCorrect(color);
  8853. czm_writeLogDepth();
  8854. }
  8855. `;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,
  8856. in vec3 positionLow;
  8857. in vec4 pickColor;
  8858. in vec2 showAndColor;
  8859. out vec4 v_pickColor;
  8860. out vec4 v_color;
  8861. void main()
  8862. {
  8863. float show = showAndColor.x;
  8864. vec4 color = czm_decodeRGB8(showAndColor.y);
  8865. ///////////////////////////////////////////////////////////////////////////
  8866. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  8867. vec4 positionEC = czm_modelViewRelativeToEye * p;
  8868. ///////////////////////////////////////////////////////////////////////////
  8869. gl_Position = czm_projection * positionEC;
  8870. czm_vertexLogDepth();
  8871. v_pickColor = pickColor / 255.0;
  8872. v_color = color;
  8873. v_color.a *= show;
  8874. gl_Position *= show;
  8875. }
  8876. `;var pei=y(x(),1),Ew=`in vec4 v_pickColor;
  8877. in vec4 v_color;
  8878. void main()
  8879. {
  8880. if (v_color.a < 0.005) // matches 0/255 and 1/255
  8881. {
  8882. discard;
  8883. }
  8884. out_FragColor = czm_gammaCorrect(v_color);
  8885. czm_writeLogDepth();
  8886. }
  8887. `;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(),
  8888. in vec3 positionLow;
  8889. in vec3 prevPositionHigh;
  8890. in vec3 prevPositionLow;
  8891. in vec3 nextPositionHigh;
  8892. in vec3 nextPositionLow;
  8893. in vec4 pickColor;
  8894. in vec4 showColorWidthAndTexCoord;
  8895. out vec4 v_pickColor;
  8896. out vec4 v_color;
  8897. out vec2 v_st;
  8898. out float v_width;
  8899. out float v_polylineAngle;
  8900. void main()
  8901. {
  8902. float show = showColorWidthAndTexCoord.x;
  8903. vec4 color = czm_decodeRGB8(showColorWidthAndTexCoord.y);
  8904. float width = showColorWidthAndTexCoord.z;
  8905. float texCoord = showColorWidthAndTexCoord.w;
  8906. ///////////////////////////////////////////////////////////////////////////
  8907. bool usePrevious = texCoord == 1.0;
  8908. float expandDir = gl_VertexID % 2 == 1 ? 1.0 : -1.0;
  8909. float polylineAngle;
  8910. vec4 positionEC = czm_translateRelativeToEye(positionHigh, positionLow);
  8911. vec4 prevPositionEC = czm_translateRelativeToEye(prevPositionHigh, prevPositionLow);
  8912. vec4 nextPositionEC = czm_translateRelativeToEye(nextPositionHigh, nextPositionLow);
  8913. vec4 positionWC = getPolylineWindowCoordinates(positionEC, prevPositionEC, nextPositionEC, expandDir, width, usePrevious, polylineAngle);
  8914. ///////////////////////////////////////////////////////////////////////////
  8915. gl_Position = czm_viewportOrthographic * positionWC * show;
  8916. v_pickColor = pickColor / 255.0;
  8917. v_color = color;
  8918. v_color.a *= show;
  8919. v_st.s = texCoord;
  8920. v_st.t = czm_writeNonPerspective(clamp(expandDir, 0.0, 1.0), gl_Position.w);
  8921. v_width = width;
  8922. v_polylineAngle = polylineAngle;
  8923. }
  8924. `;var hti=y(x(),1),Zw=`in vec4 v_pickColor;
  8925. in vec4 v_color;
  8926. void main()
  8927. {
  8928. if (v_color.a < 0.005) // matches 0/255 and 1/255
  8929. {
  8930. discard;
  8931. }
  8932. out_FragColor = czm_gammaCorrect(v_color);
  8933. czm_writeLogDepth();
  8934. }
  8935. `;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
  8936. {
  8937. return ${u};
  8938. }
  8939. `}return r=`${i} ${e}
  8940. {
  8941. ${r} return ${i}(1.0);
  8942. }
  8943. `,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)}
  8944. // Vertex shader for Gaussian splats.
  8945. // The splats are rendered as quads in view space. Splat attributes are loaded from a texture with precomputed 3D covariance.
  8946. // Passes local quad coordinates and color to the fragment shader for Gaussian evaluation.
  8947. //
  8948. // Discards splats outside the view frustum or with negligible screen size.
  8949. //
  8950. #if defined(HAS_SPHERICAL_HARMONICS)
  8951. const uint coefficientCount[3] = uint[3](3u,8u,15u);
  8952. const float SH_C1 = 0.48860251;
  8953. const float SH_C2[5] = float[5](
  8954. 1.092548430,
  8955. -1.09254843,
  8956. 0.315391565,
  8957. -1.09254843,
  8958. 0.546274215
  8959. );
  8960. const float SH_C3[7] = float[7](
  8961. -0.59004358,
  8962. 2.890611442,
  8963. -0.45704579,
  8964. 0.373176332,
  8965. -0.45704579,
  8966. 1.445305721,
  8967. -0.59004358
  8968. );
  8969. //Retrieve SH coefficient. Currently RG32UI format
  8970. uvec2 loadSHCoeff(uint splatID, int index) {
  8971. ivec2 shTexSize = textureSize(u_sphericalHarmonicsTexture, 0);
  8972. uint dims = coefficientCount[uint(u_sphericalHarmonicsDegree)-1u];
  8973. uint splatsPerRow = uint(shTexSize.x) / dims;
  8974. uint shIndex = (splatID%splatsPerRow) * dims + uint(index);
  8975. ivec2 shPosCoord = ivec2(shIndex, splatID / splatsPerRow);
  8976. return texelFetch(u_sphericalHarmonicsTexture, shPosCoord, 0).rg;
  8977. }
  8978. //Unpack RG32UI half float coefficients to vec3
  8979. vec3 halfToVec3(uvec2 packed) {
  8980. return vec3(unpackHalf2x16(packed.x), unpackHalf2x16(packed.y).x);
  8981. }
  8982. vec3 loadAndExpandSHCoeff(uint splatID, int index) {
  8983. uvec2 coeff = loadSHCoeff(splatID, index);
  8984. return halfToVec3(coeff);
  8985. }
  8986. vec3 evaluateSH(uint splatID, vec3 viewDir) {
  8987. vec3 result = vec3(0.0);
  8988. int coeffIndex = 0;
  8989. float x = viewDir.x, y = viewDir.y, z = viewDir.z;
  8990. if (u_sphericalHarmonicsDegree >= 1.) {
  8991. vec3 sh1 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  8992. vec3 sh2 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  8993. vec3 sh3 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  8994. result += -SH_C1 * y * sh1 + SH_C1 * z * sh2 - SH_C1 * x * sh3;
  8995. if (u_sphericalHarmonicsDegree >= 2.) {
  8996. float xx = x * x;
  8997. float yy = y * y;
  8998. float zz = z * z;
  8999. float xy = x * y;
  9000. float yz = y * z;
  9001. float xz = x * z;
  9002. vec3 sh4 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9003. vec3 sh5 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9004. vec3 sh6 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9005. vec3 sh7 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9006. vec3 sh8 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9007. result += SH_C2[0] * xy * sh4 +
  9008. SH_C2[1] * yz * sh5 +
  9009. SH_C2[2] * (2.0f * zz - xx - yy) * sh6 +
  9010. SH_C2[3] * xz * sh7 +
  9011. SH_C2[4] * (xx - yy) * sh8;
  9012. if (u_sphericalHarmonicsDegree >= 3.) {
  9013. vec3 sh9 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9014. vec3 sh10 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9015. vec3 sh11 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9016. vec3 sh12 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9017. vec3 sh13 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9018. vec3 sh14 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9019. vec3 sh15 = loadAndExpandSHCoeff(splatID, coeffIndex++);
  9020. result += SH_C3[0] * y * (3.0f * xx - yy) * sh9 +
  9021. SH_C3[1] * xy * z * sh10 +
  9022. SH_C3[2] * y * (4.0f * zz - xx - yy) * sh11 +
  9023. SH_C3[3] * z * (2.0f * zz - 3.0f * xx - 3.0f * yy) * sh12 +
  9024. SH_C3[4] * x * (4.0f * zz - xx - yy) * sh13 +
  9025. SH_C3[5] * z * (xx - yy) * sh14 +
  9026. SH_C3[6] * x * (xx - 3.0f * yy) * sh15;
  9027. }
  9028. }
  9029. }
  9030. return result;
  9031. }
  9032. #endif
  9033. // Transforms and projects splat covariance into screen space and extracts the major and minor axes of the Gaussian ellipsoid
  9034. // which is used to calculate the vertex position in clip space.
  9035. vec4 calcCovVectors(vec3 viewPos, mat3 Vrk) {
  9036. vec4 t = vec4(viewPos, 1.0);
  9037. vec2 focal = vec2(czm_projection[0][0] * czm_viewport.z, czm_projection[1][1] * czm_viewport.w);
  9038. vec2 J1 = focal / t.z;
  9039. vec2 J2 = -focal * vec2(t.x, t.y) / (t.z * t.z);
  9040. mat3 J = mat3(
  9041. J1.x, 0.0, J2.x,
  9042. 0.0, J1.y, J2.y,
  9043. 0.0, 0.0, 0.0
  9044. );
  9045. mat3 R = mat3(czm_modelView);
  9046. //transform our covariance into view space
  9047. //ensures orientation is correct
  9048. mat3 Vrk_view = R * Vrk * transpose(R);
  9049. mat3 cov = transpose(J) * Vrk_view * J;
  9050. float diagonal1 = cov[0][0] + .3;
  9051. float offDiagonal = cov[0][1];
  9052. float diagonal2 = cov[1][1] + .3;
  9053. float mid = 0.5 * (diagonal1 + diagonal2);
  9054. float radius = length(vec2((diagonal1 - diagonal2) * 0.5, offDiagonal));
  9055. float lambda1 = mid + radius;
  9056. float lambda2 = max(mid - radius, 0.1);
  9057. vec2 diagonalVector = normalize(vec2(offDiagonal, lambda1 - diagonal1));
  9058. return vec4(
  9059. min(sqrt(2.0 * lambda1), 1024.0) * diagonalVector,
  9060. min(sqrt(2.0 * lambda2), 1024.0) * vec2(diagonalVector.y, -diagonalVector.x)
  9061. );
  9062. }
  9063. highp vec4 discardVec = vec4(0.0, 0.0, 2.0, 1.0);
  9064. void main() {
  9065. uint texIdx = uint(a_splatIndex);
  9066. // u_splatRowMask and u_splatRowShift encode the row width of the splat
  9067. // attribute texture. The texture width is always maximumTextureSize, which
  9068. // varies by GPU, so these are passed as uniforms rather than constants.
  9069. // rowMask = maximumTextureSize/2 - 1
  9070. // rowShift = log2(maximumTextureSize/2)
  9071. uint rowMask = uint(u_splatRowMask);
  9072. uint rowShift = uint(u_splatRowShift);
  9073. ivec2 posCoord = ivec2(int((texIdx & rowMask) << 1), int(texIdx >> rowShift));
  9074. vec4 splatPosition = vec4( uintBitsToFloat(uvec4(texelFetch(u_splatAttributeTexture, posCoord, 0))) );
  9075. vec4 splatViewPos = czm_modelView * vec4(splatPosition.xyz, 1.0);
  9076. vec4 clipPosition = czm_projection * splatViewPos;
  9077. float clip = 1.2 * clipPosition.w;
  9078. if (clipPosition.z < -clip || clipPosition.x < -clip || clipPosition.x > clip ||
  9079. clipPosition.y < -clip || clipPosition.y > clip) {
  9080. gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
  9081. return;
  9082. }
  9083. ivec2 covCoord = ivec2(int(((texIdx & rowMask) << 1) | 1u), int(texIdx >> rowShift));
  9084. uvec4 covariance = uvec4(texelFetch(u_splatAttributeTexture, covCoord, 0));
  9085. gl_Position = clipPosition;
  9086. vec2 u1 = unpackHalf2x16(covariance.x) ;
  9087. vec2 u2 = unpackHalf2x16(covariance.y);
  9088. vec2 u3 = unpackHalf2x16(covariance.z);
  9089. mat3 Vrk = mat3(u1.x, u1.y, u2.x, u1.y, u2.y, u3.x, u2.x, u3.x, u3.y);
  9090. vec4 covVectors = calcCovVectors(splatViewPos.xyz, Vrk);
  9091. if (dot(covVectors.xy, covVectors.xy) < 4.0 && dot(covVectors.zw, covVectors.zw) < 4.0) {
  9092. gl_Position = discardVec;
  9093. return;
  9094. }
  9095. vec2 corner = vec2((gl_VertexID << 1) & 2, gl_VertexID & 2) - 1.;
  9096. gl_Position += vec4((corner.x * covVectors.xy + corner.y * covVectors.zw) / czm_viewport.zw * gl_Position.w, 0, 0);
  9097. gl_Position.z = clamp(gl_Position.z, -abs(gl_Position.w), abs(gl_Position.w));
  9098. v_vertPos = corner ;
  9099. v_splatColor = vec4(covariance.w & 0xffu, (covariance.w >> 8) & 0xffu, (covariance.w >> 16) & 0xffu, (covariance.w >> 24) & 0xffu) / 255.0;
  9100. #if defined(HAS_SPHERICAL_HARMONICS)
  9101. vec4 splatWC = czm_inverseView * splatViewPos;
  9102. vec3 viewDirModel = normalize(u_inverseModelRotation * (splatWC.xyz - u_cameraPositionWC.xyz));
  9103. v_splatColor.rgb += evaluateSH(texIdx, viewDirModel).rgb;
  9104. #endif
  9105. v_splitDirection = u_splitDirection;
  9106. }`;var bii=y(x(),1),Pw=`//
  9107. // Fragment shader for Gaussian splats.
  9108. // Renders a Gaussian splat within a quad, discarding fragments outside the unit circle.
  9109. // Applies an approximate Gaussian falloff based on distance from the center and outputs
  9110. // a color modulated by the alpha and Gaussian weight.
  9111. //
  9112. void main() {
  9113. if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
  9114. if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
  9115. float A = -dot(v_vertPos, v_vertPos);
  9116. if (A < -4.) {
  9117. discard;
  9118. }
  9119. float B = exp(A * 4.) * v_splatColor.a ;
  9120. out_FragColor = vec4(v_splatColor.rgb * B , B);
  9121. }
  9122. `;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
  9123. 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
  9124. Geometric error: ${e.geometricError}`,o++),t.debugShowRenderingStatistics&&(i+=`
  9125. Commands: ${e.commandsLength}`,o++,e.content.pointsLength>0&&(i+=`
  9126. Points: ${e.content.pointsLength}`,o++),e.content.trianglesLength>0&&(i+=`
  9127. Triangles: ${e.content.trianglesLength}`,o++),i+=`
  9128. Features: ${e.content.featuresLength}`,o++),t.debugShowMemoryUsage&&(i+=`
  9129. Texture Memory: ${FAe(e.content.texturesByteLength)}`,i+=`
  9130. Geometry Memory: ${FAe(e.content.geometryByteLength)}`,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+=`
  9131. Urls:`;let s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+=`
  9132. - ${s[a]}`;o+=s.length}else i+=`
  9133. 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
  9134. in vec4 v_outlineColor;
  9135. in float v_innerPercent;
  9136. in float v_pixelDistance;
  9137. in vec4 v_pickColor;
  9138. in float v_splitDirection;
  9139. void main()
  9140. {
  9141. if (v_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
  9142. if (v_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
  9143. // The distance in UV space from this fragment to the center of the point, at most 0.5.
  9144. float distanceToCenter = length(gl_PointCoord - vec2(0.5));
  9145. // The max distance stops one pixel shy of the edge to leave space for anti-aliasing.
  9146. float maxDistance = max(0.0, 0.5 - v_pixelDistance);
  9147. float wholeAlpha = 1.0 - smoothstep(maxDistance, 0.5, distanceToCenter);
  9148. float innerAlpha = 1.0 - smoothstep(maxDistance * v_innerPercent, 0.5 * v_innerPercent, distanceToCenter);
  9149. vec4 color = mix(v_outlineColor, v_color, innerAlpha);
  9150. color.a *= wholeAlpha;
  9151. // Fully transparent parts of the billboard are not pickable.
  9152. #if !defined(OPAQUE) && !defined(TRANSLUCENT)
  9153. if (color.a < 0.005) // matches 0/255 and 1/255
  9154. {
  9155. discard;
  9156. }
  9157. #else
  9158. // The billboard is rendered twice. The opaque pass discards translucent fragments
  9159. // and the translucent pass discards opaque fragments.
  9160. #ifdef OPAQUE
  9161. if (color.a < 0.995) // matches < 254/255
  9162. {
  9163. discard;
  9164. }
  9165. #else
  9166. if (color.a >= 0.995) // matches 254/255 and 255/255
  9167. {
  9168. discard;
  9169. }
  9170. #endif
  9171. #endif
  9172. out_FragColor = czm_gammaCorrect(color);
  9173. czm_writeLogDepth();
  9174. }
  9175. `;var Bpi=y(x(),1),TN=`uniform float u_maxTotalPointSize;
  9176. in vec4 positionHighAndSize;
  9177. in vec4 positionLowAndOutline;
  9178. in vec4 compressedAttribute0; // color, outlineColor, pick color
  9179. in vec4 compressedAttribute1; // show, translucency by distance, some free space
  9180. in vec4 scaleByDistance; // near, nearScale, far, farScale
  9181. in vec4 distanceDisplayConditionAndDisableDepthAndSplitDirection; // near, far, disableDepthTestDistance, splitDirection
  9182. out vec4 v_color;
  9183. out vec4 v_outlineColor;
  9184. out float v_innerPercent;
  9185. out float v_pixelDistance;
  9186. out vec4 v_pickColor;
  9187. out float v_splitDirection;
  9188. const float SHIFT_LEFT8 = 256.0;
  9189. const float SHIFT_RIGHT8 = 1.0 / 256.0;
  9190. void main()
  9191. {
  9192. // Modifying this shader may also require modifications to PointPrimitive._computeScreenSpacePosition
  9193. // unpack attributes
  9194. vec3 positionHigh = positionHighAndSize.xyz;
  9195. vec3 positionLow = positionLowAndOutline.xyz;
  9196. float outlineWidthBothSides = 2.0 * positionLowAndOutline.w;
  9197. float totalSize = positionHighAndSize.w + outlineWidthBothSides;
  9198. float outlinePercent = outlineWidthBothSides / totalSize;
  9199. // Scale in response to browser-zoom.
  9200. totalSize *= czm_pixelRatio;
  9201. float temp = compressedAttribute1.x * SHIFT_RIGHT8;
  9202. float show = floor(temp);
  9203. #ifdef EYE_DISTANCE_TRANSLUCENCY
  9204. vec4 translucencyByDistance;
  9205. translucencyByDistance.x = compressedAttribute1.z;
  9206. translucencyByDistance.z = compressedAttribute1.w;
  9207. translucencyByDistance.y = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
  9208. temp = compressedAttribute1.y * SHIFT_RIGHT8;
  9209. translucencyByDistance.w = ((temp - floor(temp)) * SHIFT_LEFT8) / 255.0;
  9210. #endif
  9211. ///////////////////////////////////////////////////////////////////////////
  9212. vec4 color = czm_decodeRGB8(compressedAttribute0.x);
  9213. vec4 outlineColor = czm_decodeRGB8(compressedAttribute0.y);
  9214. vec4 pickColor = czm_decodeRGB8(compressedAttribute0.z);
  9215. vec4 alphaPacked = czm_decodeRGB8(compressedAttribute0.w);
  9216. color.a = alphaPacked.x;
  9217. outlineColor.a = alphaPacked.y;
  9218. pickColor.a = alphaPacked.z;
  9219. ///////////////////////////////////////////////////////////////////////////
  9220. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  9221. vec4 positionEC = czm_modelViewRelativeToEye * p;
  9222. ///////////////////////////////////////////////////////////////////////////
  9223. #if defined(EYE_DISTANCE_SCALING) || defined(EYE_DISTANCE_TRANSLUCENCY) || defined(DISTANCE_DISPLAY_CONDITION) || defined(DISABLE_DEPTH_DISTANCE)
  9224. float lengthSq;
  9225. if (czm_sceneMode == czm_sceneMode2D)
  9226. {
  9227. // 2D camera distance is a special case
  9228. // treat all billboards as flattened to the z=0.0 plane
  9229. lengthSq = czm_eyeHeight2D.y;
  9230. }
  9231. else
  9232. {
  9233. lengthSq = dot(positionEC.xyz, positionEC.xyz);
  9234. }
  9235. #endif
  9236. #ifdef EYE_DISTANCE_SCALING
  9237. totalSize *= czm_nearFarScalar(scaleByDistance, lengthSq);
  9238. #endif
  9239. if (totalSize > 0.0) {
  9240. // Add padding for anti-aliasing on both sides.
  9241. totalSize += 3.0;
  9242. }
  9243. // Clamp to max point size.
  9244. totalSize = min(totalSize, u_maxTotalPointSize);
  9245. // If size is too small, push vertex behind near plane for clipping.
  9246. // Note that context.minimumAliasedPointSize "will be at most 1.0".
  9247. if (totalSize < 1.0)
  9248. {
  9249. positionEC.xyz = vec3(0.0);
  9250. totalSize = 1.0;
  9251. }
  9252. float translucency = 1.0;
  9253. #ifdef EYE_DISTANCE_TRANSLUCENCY
  9254. translucency = czm_nearFarScalar(translucencyByDistance, lengthSq);
  9255. // push vertex behind near plane for clipping
  9256. if (translucency < 0.004)
  9257. {
  9258. positionEC.xyz = vec3(0.0);
  9259. }
  9260. #endif
  9261. #ifdef DISTANCE_DISPLAY_CONDITION
  9262. float nearSq = distanceDisplayConditionAndDisableDepthAndSplitDirection.x;
  9263. float farSq = distanceDisplayConditionAndDisableDepthAndSplitDirection.y;
  9264. if (lengthSq < nearSq || lengthSq > farSq) {
  9265. // push vertex behind camera to force it to be clipped
  9266. positionEC.xyz = vec3(0.0, 0.0, 1.0);
  9267. }
  9268. #endif
  9269. gl_Position = czm_projection * positionEC;
  9270. czm_vertexLogDepth();
  9271. #ifdef DISABLE_DEPTH_DISTANCE
  9272. float disableDepthTestDistance = distanceDisplayConditionAndDisableDepthAndSplitDirection.z;
  9273. if (disableDepthTestDistance == 0.0 && czm_minimumDisableDepthTestDistance != 0.0)
  9274. {
  9275. disableDepthTestDistance = czm_minimumDisableDepthTestDistance;
  9276. }
  9277. if (disableDepthTestDistance != 0.0)
  9278. {
  9279. // Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
  9280. float zclip = gl_Position.z / gl_Position.w;
  9281. bool clipped = (zclip < -1.0 || zclip > 1.0);
  9282. if (!clipped && (disableDepthTestDistance < 0.0 || (lengthSq > 0.0 && lengthSq < disableDepthTestDistance)))
  9283. {
  9284. // Position z on the near plane.
  9285. gl_Position.z = -gl_Position.w;
  9286. #ifdef LOG_DEPTH
  9287. czm_vertexLogDepth(vec4(czm_currentFrustum.x));
  9288. #endif
  9289. }
  9290. }
  9291. #endif
  9292. v_color = color;
  9293. v_color.a *= translucency * show;
  9294. v_outlineColor = outlineColor;
  9295. v_outlineColor.a *= translucency * show;
  9296. v_innerPercent = 1.0 - outlinePercent;
  9297. v_pixelDistance = 2.0 / totalSize;
  9298. gl_PointSize = totalSize * show;
  9299. gl_Position *= show;
  9300. v_pickColor = pickColor;
  9301. v_splitDirection = distanceDisplayConditionAndDisableDepthAndSplitDirection.w;
  9302. }
  9303. `;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
  9304. ${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.getNumberOfYTilesAtLev
  9305. wmi\xD6\xF0\x9Ck\x93\xA1\xBDNu\xE0A[\xDF@V\f\xD9\xBBr\x9B\x81|3S\xEEOl\xD4q\xB0{\xC0\x7FEVZ\xADwUe\v3\x92*\xACl5\xC50s\xF83>mF8J\xB4\xDD\xF0.\xDDu\xDA\x8CDt"\xFAa"\f3"So\xAF9D\v\x8C9\xD99L\xB9\xBF\x7F\xAB\\\x8CP_\x9F"ux\xE9\x07q\x91h;\xC1\xC4\x9B\x7F\xF0<VqH\x82'UfYNe\x98u\xA3aF}a?A\0\x9F\xD7\xB44M\xCE\x87F\xB0\xD5\xB8\x8A'{\x8B\xDC+\xBBMg0\xC8\xD1\xF6\\\x8FP\xFA[/F\x9Bn5/'C.\xEB
  9306. \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
  9307. \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
  9308. ZGM&30x\xDA\xC0\x9CFG\xE2[y\`In7gS
  9309. >\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
  9310. \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:"DbR
  9311. layout (location = 0) out vec4 out_FragData_0;
  9312. layout (location = 1) out vec4 out_FragData_1;
  9313. #else
  9314. layout (location = 0) out vec4 out_FragColor;
  9315. #endif
  9316. uniform vec4 u_bgColor;
  9317. uniform sampler2D u_depthTexture;
  9318. in vec2 v_textureCoordinates;
  9319. void main()
  9320. {
  9321. if (texture(u_depthTexture, v_textureCoordinates).r < 1.0)
  9322. {
  9323. #ifdef MRT
  9324. out_FragData_0 = u_bgColor;
  9325. out_FragData_1 = vec4(u_bgColor.a);
  9326. #else
  9327. out_FragColor = u_bgColor;
  9328. #endif
  9329. return;
  9330. }
  9331. discard;
  9332. }
  9333. `;var fKi=y(x(),1),UX=`in vec2 v_textureCoordinates;
  9334. const float M_PI = 3.141592653589793;
  9335. float vdcRadicalInverse(int i)
  9336. {
  9337. float r;
  9338. float base = 2.0;
  9339. float value = 0.0;
  9340. float invBase = 1.0 / base;
  9341. float invBi = invBase;
  9342. for (int x = 0; x < 100; x++)
  9343. {
  9344. if (i <= 0)
  9345. {
  9346. break;
  9347. }
  9348. r = mod(float(i), base);
  9349. value += r * invBi;
  9350. invBi *= invBase;
  9351. i = int(float(i) * invBase);
  9352. }
  9353. return value;
  9354. }
  9355. vec2 hammersley2D(int i, int N)
  9356. {
  9357. return vec2(float(i) / float(N), vdcRadicalInverse(i));
  9358. }
  9359. vec3 importanceSampleGGX(vec2 xi, float alphaRoughness, vec3 N)
  9360. {
  9361. float alphaRoughnessSquared = alphaRoughness * alphaRoughness;
  9362. float phi = 2.0 * M_PI * xi.x;
  9363. float cosTheta = sqrt((1.0 - xi.y) / (1.0 + (alphaRoughnessSquared - 1.0) * xi.y));
  9364. float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
  9365. vec3 H = vec3(sinTheta * cos(phi), sinTheta * sin(phi), cosTheta);
  9366. vec3 upVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
  9367. vec3 tangentX = normalize(cross(upVector, N));
  9368. vec3 tangentY = cross(N, tangentX);
  9369. return tangentX * H.x + tangentY * H.y + N * H.z;
  9370. }
  9371. /**
  9372. * Estimate the geometric self-shadowing of the microfacets in a surface,
  9373. * using the Smith Joint GGX visibility function.
  9374. * Note: Vis = G / (4 * NdotL * NdotV)
  9375. * see Eric Heitz. 2014. Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs. Journal of Computer Graphics Techniques, 3
  9376. * see Real-Time Rendering. Page 331 to 336.
  9377. * see https://google.github.io/filament/Filament.md.html#materialsystem/specularbrdf/geometricshadowing(specularg)
  9378. *
  9379. * @param {float} alphaRoughness The roughness of the material, expressed as the square of perceptual roughness.
  9380. * @param {float} NdotL The cosine of the angle between the surface normal and the direction to the light source.
  9381. * @param {float} NdotV The cosine of the angle between the surface normal and the direction to the camera.
  9382. */
  9383. float smithVisibilityGGX(float alphaRoughness, float NdotL, float NdotV)
  9384. {
  9385. float alphaRoughnessSq = alphaRoughness * alphaRoughness;
  9386. float GGXV = NdotL * sqrt(NdotV * NdotV * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
  9387. float GGXL = NdotV * sqrt(NdotL * NdotL * (1.0 - alphaRoughnessSq) + alphaRoughnessSq);
  9388. float GGX = GGXV + GGXL; // 2.0 if NdotL = NdotV = 1.0
  9389. if (GGX > 0.0)
  9390. {
  9391. return 0.5 / GGX; // 1/4 if NdotL = NdotV = 1.0
  9392. }
  9393. return 0.0;
  9394. }
  9395. vec2 integrateBrdf(float roughness, float NdotV)
  9396. {
  9397. vec3 V = vec3(sqrt(1.0 - NdotV * NdotV), 0.0, NdotV);
  9398. float A = 0.0;
  9399. float B = 0.0;
  9400. const int NumSamples = 1024;
  9401. float alphaRoughness = roughness * roughness;
  9402. for (int i = 0; i < NumSamples; i++)
  9403. {
  9404. vec2 xi = hammersley2D(i, NumSamples);
  9405. vec3 H = importanceSampleGGX(xi, alphaRoughness, vec3(0.0, 0.0, 1.0));
  9406. vec3 L = 2.0 * dot(V, H) * H - V;
  9407. float NdotL = clamp(L.z, 0.0, 1.0);
  9408. float NdotH = clamp(H.z, 0.0, 1.0);
  9409. float VdotH = clamp(dot(V, H), 0.0, 1.0);
  9410. if (NdotL > 0.0)
  9411. {
  9412. float G = smithVisibilityGGX(alphaRoughness, NdotL, NdotV);
  9413. float G_Vis = 4.0 * G * VdotH * NdotL / NdotH;
  9414. float Fc = pow(1.0 - VdotH, 5.0);
  9415. A += (1.0 - Fc) * G_Vis;
  9416. B += Fc * G_Vis;
  9417. }
  9418. }
  9419. return vec2(A, B) / float(NumSamples);
  9420. }
  9421. void main()
  9422. {
  9423. out_FragColor = vec4(integrateBrdf(v_textureCoordinates.y, v_textureCoordinates.x), 0.0, 1.0);
  9424. }
  9425. `;var AKi=y(x(),1),DX=`uniform sampler2D u_noiseTexture;
  9426. uniform vec3 u_noiseTextureDimensions;
  9427. uniform float u_noiseDetail;
  9428. in vec2 v_offset;
  9429. in vec3 v_maximumSize;
  9430. in vec4 v_color;
  9431. in float v_slice;
  9432. in float v_brightness;
  9433. float wrap(float value, float rangeLength) {
  9434. if(value < 0.0) {
  9435. float absValue = abs(value);
  9436. float modValue = mod(absValue, rangeLength);
  9437. return mod(rangeLength - modValue, rangeLength);
  9438. }
  9439. return mod(value, rangeLength);
  9440. }
  9441. vec3 wrapVec(vec3 value, float rangeLength) {
  9442. return vec3(wrap(value.x, rangeLength),
  9443. wrap(value.y, rangeLength),
  9444. wrap(value.z, rangeLength));
  9445. }
  9446. vec2 voxelToUV(vec3 voxelIndex) {
  9447. float textureSliceWidth = u_noiseTextureDimensions.x;
  9448. float noiseTextureRows = u_noiseTextureDimensions.y;
  9449. float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
  9450. float textureSliceWidthSquared = textureSliceWidth * textureSliceWidth;
  9451. vec2 inverseNoiseTextureDimensions = vec2(noiseTextureRows / textureSliceWidthSquared,
  9452. inverseNoiseTextureRows / textureSliceWidth);
  9453. vec3 wrappedIndex = wrapVec(voxelIndex, textureSliceWidth);
  9454. float column = mod(wrappedIndex.z, textureSliceWidth * inverseNoiseTextureRows);
  9455. float row = floor(wrappedIndex.z / textureSliceWidth * noiseTextureRows);
  9456. float xPixelCoord = wrappedIndex.x + column * textureSliceWidth;
  9457. float yPixelCoord = wrappedIndex.y + row * textureSliceWidth;
  9458. return vec2(xPixelCoord, yPixelCoord) * inverseNoiseTextureDimensions;
  9459. }
  9460. // Interpolate a voxel with its neighbor (along the positive X-axis)
  9461. vec4 lerpSamplesX(vec3 voxelIndex, float x) {
  9462. vec2 uv0 = voxelToUV(voxelIndex);
  9463. vec2 uv1 = voxelToUV(voxelIndex + vec3(1.0, 0.0, 0.0));
  9464. vec4 sample0 = texture(u_noiseTexture, uv0);
  9465. vec4 sample1 = texture(u_noiseTexture, uv1);
  9466. return mix(sample0, sample1, x);
  9467. }
  9468. vec4 sampleNoiseTexture(vec3 position) {
  9469. float textureSliceWidth = u_noiseTextureDimensions.x;
  9470. vec3 recenteredPos = position + vec3(textureSliceWidth / 2.0);
  9471. vec3 lerpValue = fract(recenteredPos);
  9472. vec3 voxelIndex = floor(recenteredPos);
  9473. vec4 xLerp00 = lerpSamplesX(voxelIndex, lerpValue.x);
  9474. vec4 xLerp01 = lerpSamplesX(voxelIndex + vec3(0.0, 0.0, 1.0), lerpValue.x);
  9475. vec4 xLerp10 = lerpSamplesX(voxelIndex + vec3(0.0, 1.0, 0.0), lerpValue.x);
  9476. vec4 xLerp11 = lerpSamplesX(voxelIndex + vec3(0.0, 1.0, 1.0), lerpValue.x);
  9477. vec4 yLerp0 = mix(xLerp00, xLerp10, lerpValue.y);
  9478. vec4 yLerp1 = mix(xLerp01, xLerp11, lerpValue.y);
  9479. return mix(yLerp0, yLerp1, lerpValue.z);
  9480. }
  9481. // Intersection with a unit sphere with radius 0.5 at center (0, 0, 0).
  9482. bool intersectSphere(vec3 origin, vec3 dir, float slice,
  9483. out vec3 point, out vec3 normal) {
  9484. float A = dot(dir, dir);
  9485. float B = dot(origin, dir);
  9486. float C = dot(origin, origin) - 0.25;
  9487. float discriminant = (B * B) - (A * C);
  9488. if(discriminant < 0.0) {
  9489. return false;
  9490. }
  9491. float root = sqrt(discriminant);
  9492. float t = (-B - root) / A;
  9493. if(t < 0.0) {
  9494. t = (-B + root) / A;
  9495. }
  9496. point = origin + t * dir;
  9497. if(slice >= 0.0) {
  9498. point.z = (slice / 2.0) - 0.5;
  9499. if(length(point) > 0.5) {
  9500. return false;
  9501. }
  9502. }
  9503. normal = normalize(point);
  9504. point -= czm_epsilon2 * normal;
  9505. return true;
  9506. }
  9507. // Transforms the ray origin and direction into unit sphere space,
  9508. // then transforms the result back into the ellipsoid's space.
  9509. bool intersectEllipsoid(vec3 origin, vec3 dir, vec3 center, vec3 scale, float slice,
  9510. out vec3 point, out vec3 normal) {
  9511. if(scale.x <= 0.01 || scale.y < 0.01 || scale.z < 0.01) {
  9512. return false;
  9513. }
  9514. vec3 o = (origin - center) / scale;
  9515. vec3 d = dir / scale;
  9516. vec3 p, n;
  9517. bool intersected = intersectSphere(o, d, slice, p, n);
  9518. if(intersected) {
  9519. point = (p * scale) + center;
  9520. normal = n;
  9521. }
  9522. return intersected;
  9523. }
  9524. // Assume that if phase shift is being called for octave i,
  9525. // the frequency is of i - 1. This saves us from doing extra
  9526. // division / multiplication operations.
  9527. vec2 phaseShift2D(vec2 p, vec2 freq) {
  9528. return (czm_pi / 2.0) * sin(freq.yx * p.yx);
  9529. }
  9530. vec2 phaseShift3D(vec3 p, vec2 freq) {
  9531. return phaseShift2D(p.xy, freq) + czm_pi * vec2(sin(freq.x * p.z));
  9532. }
  9533. // The cloud texture function derived from Gardner's 1985 paper,
  9534. // "Visual Simulation of Clouds."
  9535. // https://www.cs.drexel.edu/~david/Classes/Papers/p297-gardner.pdf
  9536. const float T0 = 0.6; // contrast of the texture pattern
  9537. const float k = 0.1; // computed to produce a maximum value of 1
  9538. const float C0 = 0.8; // coefficient
  9539. const float FX0 = 0.6; // frequency X
  9540. const float FY0 = 0.6; // frequency Y
  9541. const int octaves = 5;
  9542. float T(vec3 point) {
  9543. vec2 sum = vec2(0.0);
  9544. float Ci = C0;
  9545. vec2 FXY = vec2(FX0, FY0);
  9546. vec2 PXY = vec2(0.0);
  9547. for(int i = 1; i <= octaves; i++) {
  9548. PXY = phaseShift3D(point, FXY);
  9549. Ci *= 0.707;
  9550. FXY *= 2.0;
  9551. vec2 sinTerm = sin(FXY * point.xy + PXY);
  9552. sum += Ci * sinTerm + vec2(T0);
  9553. }
  9554. return k * sum.x * sum.y;
  9555. }
  9556. const float a = 0.5; // fraction of surface reflection due to ambient or scattered light,
  9557. const float t = 0.4; // fraction of texture shading
  9558. const float s = 0.25; // fraction of specular reflection
  9559. float I(float Id, float Is, float It) {
  9560. return (1.0 - a) * ((1.0 - t) * ((1.0 - s) * Id + s * Is) + t * It) + a;
  9561. }
  9562. const vec3 lightDir = normalize(vec3(0.2, -1.0, 0.7));
  9563. vec4 drawCloud(vec3 rayOrigin, vec3 rayDir, vec3 cloudCenter, vec3 cloudScale, float cloudSlice,
  9564. float brightness) {
  9565. vec3 cloudPoint, cloudNormal;
  9566. if(!intersectEllipsoid(rayOrigin, rayDir, cloudCenter, cloudScale, cloudSlice,
  9567. cloudPoint, cloudNormal)) {
  9568. return vec4(0.0);
  9569. }
  9570. float Id = clamp(dot(cloudNormal, -lightDir), 0.0, 1.0); // diffuse reflection
  9571. float Is = max(pow(dot(-lightDir, -rayDir), 2.0), 0.0); // specular reflection
  9572. float It = T(cloudPoint); // texture function
  9573. float intensity = I(Id, Is, It);
  9574. vec3 color = vec3(intensity * clamp(brightness, 0.1, 1.0));
  9575. vec4 noise = sampleNoiseTexture(u_noiseDetail * cloudPoint);
  9576. float W = noise.x;
  9577. float W2 = noise.y;
  9578. float W3 = noise.z;
  9579. // The dot product between the cloud's normal and the ray's direction is greatest
  9580. // in the center of the ellipsoid's surface. It decreases towards the edge.
  9581. // Thus, it is used to blur the areas leading to the edges of the ellipsoid,
  9582. // so that no harsh lines appear.
  9583. // The first (and biggest) layer of worley noise is then subtracted from this.
  9584. // The final result is scaled up so that the base cloud is not too translucent.
  9585. float ndDot = clamp(dot(cloudNormal, -rayDir), 0.0, 1.0);
  9586. float TR = pow(ndDot, 3.0) - W; // translucency
  9587. TR *= 1.3;
  9588. // Subtracting the second and third layers of worley noise is more complicated.
  9589. // If these layers of noise were simply subtracted from the current translucency,
  9590. // the shape derived from the first layer of noise would be completely deleted.
  9591. // The erosion of this noise should thus be constricted to the edges of the cloud.
  9592. // However, because the edges of the ellipsoid were already blurred away, mapping
  9593. // the noise to (1.0 - ndDot) will have no impact on most of the cloud's appearance.
  9594. // The value of (0.5 - ndDot) provides the best compromise.
  9595. float minusDot = 0.5 - ndDot;
  9596. // Even with the previous calculation, subtracting the second layer of wnoise
  9597. // erode too much of the cloud. The addition of it, however, will detailed
  9598. // volume to the cloud. As long as the noise is only added and not subtracted,
  9599. // the results are aesthetically pleasing.
  9600. // The minusDot product is mapped in a way that it is larger at the edges of
  9601. // the ellipsoid, so a subtraction and min operation are used instead of
  9602. // an addition and max one.
  9603. TR -= min(minusDot * W2, 0.0);
  9604. // The third level of worley noise is subtracted from the result, with some
  9605. // modifications. First, a scalar is added to minusDot so that the noise
  9606. // starts affecting the shape farther away from the center of the ellipsoid's
  9607. // surface. Then, it is scaled down so its impact is not too intense.
  9608. TR -= 0.8 * (minusDot + 0.25) * W3;
  9609. // The texture function's shading does not correlate with the shape of the cloud
  9610. // produced by the layers of noise, so an extra shading scalar is calculated.
  9611. // The darkest areas of the cloud are assigned to be where the noise erodes
  9612. // the cloud the most. This is then interpolated based on the translucency
  9613. // and the diffuse shading term of that point in the cloud.
  9614. float shading = mix(1.0 - 0.8 * W * W, 1.0, Id * TR);
  9615. // To avoid values that are too dark, this scalar is increased by a small amount
  9616. // and clamped so it never goes to zero.
  9617. shading = clamp(shading + 0.2, 0.3, 1.0);
  9618. // Finally, the contrast of the cloud's color is increased.
  9619. vec3 finalColor = mix(vec3(0.5), shading * color, 1.15);
  9620. return vec4(finalColor, clamp(TR, 0.0, 1.0)) * v_color;
  9621. }
  9622. void main() {
  9623. #ifdef DEBUG_BILLBOARDS
  9624. out_FragColor = vec4(0.0, 0.5, 0.5, 1.0);
  9625. #endif
  9626. // To avoid calculations with high values,
  9627. // we raycast from an arbitrarily smaller space.
  9628. vec2 coordinate = v_maximumSize.xy * v_offset;
  9629. vec3 ellipsoidScale = 0.82 * v_maximumSize;
  9630. vec3 ellipsoidCenter = vec3(0.0);
  9631. float zOffset = max(ellipsoidScale.z - 10.0, 0.0);
  9632. vec3 eye = vec3(0, 0, -10.0 - zOffset);
  9633. vec3 rayDir = normalize(vec3(coordinate, 1.0) - eye);
  9634. vec3 rayOrigin = eye;
  9635. #ifdef DEBUG_ELLIPSOIDS
  9636. vec3 point, normal;
  9637. if(intersectEllipsoid(rayOrigin, rayDir, ellipsoidCenter, ellipsoidScale, v_slice,
  9638. point, normal)) {
  9639. out_FragColor = v_brightness * v_color;
  9640. }
  9641. #else
  9642. #ifndef DEBUG_BILLBOARDS
  9643. vec4 cloud = drawCloud(rayOrigin, rayDir,
  9644. ellipsoidCenter, ellipsoidScale, v_slice, v_brightness);
  9645. if(cloud.w < 0.01) {
  9646. discard;
  9647. }
  9648. out_FragColor = cloud;
  9649. #endif
  9650. #endif
  9651. }
  9652. `;var bKi=y(x(),1),kX=`#ifdef INSTANCED
  9653. in vec2 direction;
  9654. #endif
  9655. in vec4 positionHighAndScaleX;
  9656. in vec4 positionLowAndScaleY;
  9657. in vec4 packedAttribute0;
  9658. in vec4 packedAttribute1;
  9659. in vec4 color;
  9660. out vec2 v_offset;
  9661. out vec3 v_maximumSize;
  9662. out vec4 v_color;
  9663. out float v_slice;
  9664. out float v_brightness;
  9665. void main() {
  9666. // Unpack attributes.
  9667. vec3 positionHigh = positionHighAndScaleX.xyz;
  9668. vec3 positionLow = positionLowAndScaleY.xyz;
  9669. vec2 scale = vec2(positionHighAndScaleX.w, positionLowAndScaleY.w);
  9670. float show = packedAttribute0.x;
  9671. float brightness = packedAttribute0.y;
  9672. vec2 coordinates = packedAttribute0.wz;
  9673. vec3 maximumSize = packedAttribute1.xyz;
  9674. float slice = packedAttribute1.w;
  9675. #ifdef INSTANCED
  9676. vec2 dir = direction;
  9677. #else
  9678. vec2 dir = coordinates;
  9679. #endif
  9680. vec2 offset = dir - vec2(0.5, 0.5);
  9681. vec2 scaledOffset = scale * offset;
  9682. vec4 p = czm_translateRelativeToEye(positionHigh, positionLow);
  9683. vec4 positionEC = czm_modelViewRelativeToEye * p;
  9684. positionEC.xy += scaledOffset;
  9685. positionEC.xyz *= show;
  9686. gl_Position = czm_projection * positionEC;
  9687. v_offset = offset;
  9688. v_maximumSize = maximumSize;
  9689. v_color = color;
  9690. v_slice = slice;
  9691. v_brightness = brightness;
  9692. }
  9693. `;var xKi=y(x(),1),QX=`uniform vec3 u_noiseTextureDimensions;
  9694. uniform float u_noiseDetail;
  9695. uniform vec3 u_noiseOffset;
  9696. in vec2 v_position;
  9697. float wrap(float value, float rangeLength) {
  9698. if(value < 0.0) {
  9699. float absValue = abs(value);
  9700. float modValue = mod(absValue, rangeLength);
  9701. return mod(rangeLength - modValue, rangeLength);
  9702. }
  9703. return mod(value, rangeLength);
  9704. }
  9705. vec3 wrapVec(vec3 value, float rangeLength) {
  9706. return vec3(wrap(value.x, rangeLength),
  9707. wrap(value.y, rangeLength),
  9708. wrap(value.z, rangeLength));
  9709. }
  9710. vec3 random3(vec3 p) {
  9711. float dot1 = dot(p, vec3(127.1, 311.7, 932.8));
  9712. float dot2 = dot(p, vec3(269.5, 183.3, 421.4));
  9713. return fract(vec3(sin(dot1 - dot2), cos(dot1 * dot2), dot1 * dot2));
  9714. }
  9715. // Frequency corresponds to cell size.
  9716. // The higher the frequency, the smaller the cell size.
  9717. vec3 getWorleyCellPoint(vec3 centerCell, vec3 offset, float freq) {
  9718. float textureSliceWidth = u_noiseTextureDimensions.x;
  9719. vec3 cell = centerCell + offset;
  9720. cell = wrapVec(cell, textureSliceWidth / u_noiseDetail);
  9721. cell += floor(u_noiseOffset / u_noiseDetail);
  9722. vec3 p = offset + random3(cell);
  9723. return p;
  9724. }
  9725. float worleyNoise(vec3 p, float freq) {
  9726. vec3 centerCell = floor(p * freq);
  9727. vec3 pointInCell = fract(p * freq);
  9728. float shortestDistance = 1000.0;
  9729. for(float z = -1.0; z <= 1.0; z++) {
  9730. for(float y = -1.0; y <= 1.0; y++) {
  9731. for(float x = -1.0; x <= 1.0; x++) {
  9732. vec3 offset = vec3(x, y, z);
  9733. vec3 point = getWorleyCellPoint(centerCell, offset, freq);
  9734. float distance = length(pointInCell - point);
  9735. if(distance < shortestDistance) {
  9736. shortestDistance = distance;
  9737. }
  9738. }
  9739. }
  9740. }
  9741. return shortestDistance;
  9742. }
  9743. const float MAX_FBM_ITERATIONS = 10.0;
  9744. float worleyFBMNoise(vec3 p, float octaves, float scale) {
  9745. float noise = 0.0;
  9746. float freq = 1.0;
  9747. float persistence = 0.625;
  9748. for(float i = 0.0; i < MAX_FBM_ITERATIONS; i++) {
  9749. if(i >= octaves) {
  9750. break;
  9751. }
  9752. noise += worleyNoise(p * scale, freq * scale) * persistence;
  9753. persistence *= 0.5;
  9754. freq *= 2.0;
  9755. }
  9756. return noise;
  9757. }
  9758. void main() {
  9759. float textureSliceWidth = u_noiseTextureDimensions.x;
  9760. float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
  9761. float x = mod(v_position.x, textureSliceWidth);
  9762. float y = mod(v_position.y, textureSliceWidth);
  9763. float sliceRow = floor(v_position.y / textureSliceWidth);
  9764. float z = floor(v_position.x / textureSliceWidth) + sliceRow * inverseNoiseTextureRows * textureSliceWidth;
  9765. vec3 position = vec3(x, y, z);
  9766. position /= u_noiseDetail;
  9767. float worley0 = clamp(worleyFBMNoise(position, 3.0, 1.0), 0.0, 1.0);
  9768. float worley1 = clamp(worleyFBMNoise(position, 3.0, 2.0), 0.0, 1.0);
  9769. float worley2 = clamp(worleyFBMNoise(position, 3.0, 3.0), 0.0, 1.0);
  9770. out_FragColor = vec4(worley0, worley1, worley2, 1.0);
  9771. }
  9772. `;var TKi=y(x(),1),OX=`uniform vec3 u_noiseTextureDimensions;
  9773. in vec2 position;
  9774. out vec2 v_position;
  9775. void main()
  9776. {
  9777. gl_Position = vec4(position, 0.1, 1.0);
  9778. float textureSliceWidth = u_noiseTextureDimensions.x;
  9779. float noiseTextureRows = u_noiseTextureDimensions.y;
  9780. float inverseNoiseTextureRows = u_noiseTextureDimensions.z;
  9781. vec2 transformedPos = (position * 0.5) + vec2(0.5);
  9782. transformedPos *= textureSliceWidth;
  9783. transformedPos.x *= textureSliceWidth * inverseNoiseTextureRows;
  9784. transformedPos.y *= noiseTextureRows;
  9785. v_position = transformedPos;
  9786. }
  9787. `;var SKi=y(x(),1),zX=`uniform sampler2D u_opaqueDepthTexture;
  9788. uniform sampler2D u_translucentDepthTexture;
  9789. in vec2 v_textureCoordinates;
  9790. void main()
  9791. {
  9792. float opaqueDepth = texture(u_opaqueDepthTexture, v_textureCoordinates).r;
  9793. float translucentDepth = texture(u_translucentDepthTexture, v_textureCoordinates).r;
  9794. translucentDepth = czm_branchFreeTernary(translucentDepth > opaqueDepth, 1.0, translucentDepth);
  9795. out_FragColor = czm_packDepth(translucentDepth);
  9796. }
  9797. `;var IKi=y(x(),1),HX=`/**
  9798. * Compositing for Weighted Blended Order-Independent Transparency. See:
  9799. * - http://jcgt.org/published/0002/02/09/
  9800. * - http://casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html
  9801. */
  9802. uniform sampler2D u_opaque;
  9803. uniform sampler2D u_accumulation;
  9804. uniform sampler2D u_revealage;
  9805. in vec2 v_textureCoordinates;
  9806. void main()
  9807. {
  9808. vec4 opaque = texture(u_opaque, v_textureCoordinates);
  9809. vec4 accum = texture(u_accumulation, v_textureCoordinates);
  9810. float r = texture(u_revealage, v_textureCoordinates).r;
  9811. #ifdef MRT
  9812. vec4 transparent = vec4(accum.rgb / clamp(r, 1e-4, 5e4), accum.a);
  9813. #else
  9814. vec4 transparent = vec4(accum.rgb / clamp(accum.a, 1e-4, 5e4), r);
  9815. #endif
  9816. out_FragColor = (1.0 - transparent.a) * transparent + transparent.a * opaque;
  9817. if (opaque != czm_backgroundColor)
  9818. {
  9819. out_FragColor.a = 1.0;
  9820. }
  9821. }
  9822. `;var RKi=y(x(),1),JX=`uniform mat3 u_cubeMapPanoramaTransform;
  9823. in vec3 position;
  9824. out vec3 v_texCoord;
  9825. void main()
  9826. {
  9827. vec3 p = czm_viewRotation * (u_cubeMapPanoramaTransform * (czm_entireFrustum.y * position));
  9828. gl_Position = czm_projection * vec4(p, 1.0);
  9829. v_texCoord = position.xyz;
  9830. }
  9831. `;var GKi=y(x(),1),KX=`in vec4 positionEC;
  9832. void main()
  9833. {
  9834. vec3 position;
  9835. vec3 direction;
  9836. if (czm_orthographicIn3D == 1.0)
  9837. {
  9838. vec2 uv = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw;
  9839. vec2 minPlane = vec2(czm_frustumPlanes.z, czm_frustumPlanes.y); // left, bottom
  9840. vec2 maxPlane = vec2(czm_frustumPlanes.w, czm_frustumPlanes.x); // right, top
  9841. position = vec3(mix(minPlane, maxPlane, uv), 0.0);
  9842. direction = vec3(0.0, 0.0, -1.0);
  9843. }
  9844. else
  9845. {
  9846. position = vec3(0.0);
  9847. direction = normalize(positionEC.xyz);
  9848. }
  9849. czm_ray ray = czm_ray(position, direction);
  9850. vec3 ellipsoid_center = czm_view[3].xyz;
  9851. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);
  9852. if (!czm_isEmpty(intersection))
  9853. {
  9854. out_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
  9855. }
  9856. else
  9857. {
  9858. discard;
  9859. }
  9860. czm_writeLogDepth();
  9861. }
  9862. `;var WKi=y(x(),1),jX=`in vec4 position;
  9863. out vec4 positionEC;
  9864. void main()
  9865. {
  9866. positionEC = czm_modelView * position;
  9867. gl_Position = czm_projection * positionEC;
  9868. czm_vertexLogDepth();
  9869. }
  9870. `;var BKi=y(x(),1),XZ=`uniform vec3 u_radii;
  9871. uniform vec3 u_oneOverEllipsoidRadiiSquared;
  9872. in vec3 v_positionEC;
  9873. vec4 computeEllipsoidColor(czm_ray ray, float intersection, float side)
  9874. {
  9875. vec3 positionEC = czm_pointAlongRay(ray, intersection);
  9876. vec3 positionMC = (czm_inverseModelView * vec4(positionEC, 1.0)).xyz;
  9877. vec3 geodeticNormal = normalize(czm_geodeticSurfaceNormal(positionMC, vec3(0.0), u_oneOverEllipsoidRadiiSquared));
  9878. vec3 sphericalNormal = normalize(positionMC / u_radii);
  9879. vec3 normalMC = geodeticNormal * side; // normalized surface normal (always facing the viewer) in model coordinates
  9880. vec3 normalEC = normalize(czm_normal * normalMC); // normalized surface normal in eye coordinates
  9881. vec2 st = czm_ellipsoidTextureCoordinates(sphericalNormal);
  9882. vec3 positionToEyeEC = -positionEC;
  9883. czm_materialInput materialInput;
  9884. materialInput.s = st.s;
  9885. materialInput.st = st;
  9886. materialInput.str = (positionMC + u_radii) / u_radii;
  9887. materialInput.normalEC = normalEC;
  9888. materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
  9889. materialInput.positionToEyeEC = positionToEyeEC;
  9890. czm_material material = czm_getMaterial(materialInput);
  9891. #ifdef ONLY_SUN_LIGHTING
  9892. return czm_private_phong(normalize(positionToEyeEC), material, czm_sunDirectionEC);
  9893. #else
  9894. return czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  9895. #endif
  9896. }
  9897. void main()
  9898. {
  9899. // PERFORMANCE_TODO: When dynamic branching is available, compute ratio of maximum and minimum radii
  9900. // in the vertex shader. Only when it is larger than some constant, march along the ray.
  9901. // Otherwise perform one intersection test which will be the common case.
  9902. // Test if the ray intersects a sphere with the ellipsoid's maximum radius.
  9903. // For very oblate ellipsoids, using the ellipsoid's radii for an intersection test
  9904. // may cause false negatives. This will discard fragments before marching the ray forward.
  9905. float maxRadius = max(u_radii.x, max(u_radii.y, u_radii.z)) * 1.5;
  9906. vec3 direction = normalize(v_positionEC);
  9907. vec3 ellipsoidCenter = czm_modelView[3].xyz;
  9908. float t1 = -1.0;
  9909. float t2 = -1.0;
  9910. float b = -2.0 * dot(direction, ellipsoidCenter);
  9911. float c = dot(ellipsoidCenter, ellipsoidCenter) - maxRadius * maxRadius;
  9912. float discriminant = b * b - 4.0 * c;
  9913. if (discriminant >= 0.0) {
  9914. t1 = (-b - sqrt(discriminant)) * 0.5;
  9915. t2 = (-b + sqrt(discriminant)) * 0.5;
  9916. }
  9917. if (t1 < 0.0 && t2 < 0.0) {
  9918. discard;
  9919. }
  9920. float t = min(t1, t2);
  9921. if (t < 0.0) {
  9922. t = 0.0;
  9923. }
  9924. // March ray forward to intersection with larger sphere and find
  9925. czm_ray ray = czm_ray(t * direction, direction);
  9926. vec3 ellipsoid_inverseRadii = vec3(1.0 / u_radii.x, 1.0 / u_radii.y, 1.0 / u_radii.z);
  9927. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoidCenter, ellipsoid_inverseRadii);
  9928. if (czm_isEmpty(intersection))
  9929. {
  9930. discard;
  9931. }
  9932. // If the viewer is outside, compute outsideFaceColor, with normals facing outward.
  9933. vec4 outsideFaceColor = (intersection.start != 0.0) ? computeEllipsoidColor(ray, intersection.start, 1.0) : vec4(0.0);
  9934. // If the viewer either is inside or can see inside, compute insideFaceColor, with normals facing inward.
  9935. vec4 insideFaceColor = (outsideFaceColor.a < 1.0) ? computeEllipsoidColor(ray, intersection.stop, -1.0) : vec4(0.0);
  9936. out_FragColor = mix(insideFaceColor, outsideFaceColor, outsideFaceColor.a);
  9937. out_FragColor.a = 1.0 - (1.0 - insideFaceColor.a) * (1.0 - outsideFaceColor.a);
  9938. #if (defined(WRITE_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
  9939. t = (intersection.start != 0.0) ? intersection.start : intersection.stop;
  9940. vec3 positionEC = czm_pointAlongRay(ray, t);
  9941. vec4 positionCC = czm_projection * vec4(positionEC, 1.0);
  9942. #ifdef LOG_DEPTH
  9943. czm_writeLogDepth(1.0 + positionCC.w);
  9944. #else
  9945. float z = positionCC.z / positionCC.w;
  9946. float n = czm_depthRange.near;
  9947. float f = czm_depthRange.far;
  9948. gl_FragDepth = (z * (f - n) + f + n) * 0.5;
  9949. #endif
  9950. #endif
  9951. }
  9952. `;var NKi=y(x(),1),YZ=`in vec3 position;
  9953. uniform vec3 u_radii;
  9954. out vec3 v_positionEC;
  9955. void main()
  9956. {
  9957. // In the vertex data, the cube goes from (-1.0, -1.0, -1.0) to (1.0, 1.0, 1.0) in model coordinates.
  9958. // Scale to consider the radii. We could also do this once on the CPU when using the BoxGeometry,
  9959. // but doing it here allows us to change the radii without rewriting the vertex data, and
  9960. // allows all ellipsoids to reuse the same vertex data.
  9961. vec4 p = vec4(u_radii * position, 1.0);
  9962. vec4 pEC = czm_modelView * p;
  9963. v_positionEC = pEC.xyz; // position in eye coordinates
  9964. gl_Position = czm_projection * pEC;
  9965. // With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums
  9966. // and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the
  9967. // ellipsoid (does not write depth) that was rendered in the farther frustum.
  9968. //
  9969. // Here, we clamp the depth in the vertex shader to avoid being overwritten; however, this creates
  9970. // artifacts since some fragments can be alpha blended twice. This is solved by only rendering
  9971. // the ellipsoid in the closest frustum to the viewer.
  9972. gl_Position.z = clamp(gl_Position.z, czm_depthRange.near, czm_depthRange.far);
  9973. czm_vertexLogDepth();
  9974. }
  9975. `;var XKi=y(x(),1);/**
  9976. * @license
  9977. * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
  9978. *
  9979. * Redistribution and use in source and binary forms, with or without
  9980. * modification, are permitted provided that the following conditions
  9981. * are met:
  9982. * * Redistributions of source code must retain the above copyright
  9983. * notice, this list of conditions and the following disclaimer.
  9984. * * Redistributions in binary form must reproduce the above copyright
  9985. * notice, this list of conditions and the following disclaimer in the
  9986. * documentation and/or other materials provided with the distribution.
  9987. * * Neither the name of NVIDIA CORPORATION nor the names of its
  9988. * contributors may be used to endorse or promote products derived
  9989. * from this software without specific prior written permission.
  9990. *
  9991. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
  9992. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  9993. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  9994. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  9995. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  9996. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  9997. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  9998. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  9999. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10000. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  10001. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10002. */var qX=`/**
  10003. * @license
  10004. * Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved.
  10005. *
  10006. * Redistribution and use in source and binary forms, with or without
  10007. * modification, are permitted provided that the following conditions
  10008. * are met:
  10009. * * Redistributions of source code must retain the above copyright
  10010. * notice, this list of conditions and the following disclaimer.
  10011. * * Redistributions in binary form must reproduce the above copyright
  10012. * notice, this list of conditions and the following disclaimer in the
  10013. * documentation and/or other materials provided with the distribution.
  10014. * * Neither the name of NVIDIA CORPORATION nor the names of its
  10015. * contributors may be used to endorse or promote products derived
  10016. * from this software without specific prior written permission.
  10017. *
  10018. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS \`\`AS IS'' AND ANY
  10019. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  10020. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  10021. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  10022. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  10023. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  10024. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  10025. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  10026. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  10027. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  10028. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  10029. */
  10030. // NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples
  10031. // Original source (archived): https://archive.org/details/nvidiagame-works-graphics-samples-master
  10032. // Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
  10033. // Shader link in fork: https://github.com/lyntel/GraphicsSamples/blob/3d30817ebeeade64fe6a4fc3aa1fe4265c29b6fd/samples/es3-kepler/FXAA/FXAA3_11.h
  10034. // Steps used to integrate into Cesium:
  10035. // * The following defines are set:
  10036. // #define FXAA_PC 1
  10037. // #define FXAA_WEBGL_1 1
  10038. // #define FXAA_GREEN_AS_LUMA 1
  10039. // #define FXAA_EARLY_EXIT 1
  10040. // #define FXAA_GLSL_120 1
  10041. // * All other preprocessor directives besides the FXAA_QUALITY__P* directives were removed.
  10042. // * Double underscores are invalid for preprocessor directives so replace them with a single underscore. Replace
  10043. // /FXAA_QUALITY__P(.*)/g with /FXAA_QUALITY__P$1/.
  10044. // * There are no implicit conversions from ivec* to vec* so replace:
  10045. // #define FxaaInt2 ivec2
  10046. // with
  10047. // #define FxaaInt2 vec2
  10048. // * The texture2DLod function is only available in vertex shaders so replace:
  10049. // #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)
  10050. // #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)
  10051. // with
  10052. // #define FxaaTexTop(t, p) texture(t, p)
  10053. // #define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
  10054. // * FXAA_QUALITY_PRESET is prepended in the javascript code. We may want to expose that setting in the future.
  10055. // * The following parameters to FxaaPixelShader are unused and can be removed:
  10056. // fxaaConsolePosPos
  10057. // fxaaConsoleRcpFrameOpt
  10058. // fxaaConsoleRcpFrameOpt2
  10059. // fxaaConsole360RcpFrameOpt2
  10060. // fxaaConsoleEdgeSharpness
  10061. // fxaaConsoleEdgeThreshold
  10062. // fxaaConsoleEdgeThresholdMi
  10063. // fxaaConsole360ConstDir
  10064. //
  10065. // Choose the quality preset.
  10066. // This needs to be compiled into the shader as it effects code.
  10067. // Best option to include multiple presets is to
  10068. // in each shader define the preset, then include this file.
  10069. //
  10070. // OPTIONS
  10071. // -----------------------------------------------------------------------
  10072. // 10 to 15 - default medium dither (10=fastest, 15=highest quality)
  10073. // 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
  10074. // 39 - no dither, very expensive
  10075. //
  10076. // NOTES
  10077. // -----------------------------------------------------------------------
  10078. // 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
  10079. // 13 = about same speed as FXAA 3.9 and better than 12
  10080. // 23 = closest to FXAA 3.9 visually and performance wise
  10081. // _ = the lowest digit is directly related to performance
  10082. // _ = the highest digit is directly related to style
  10083. //
  10084. //#define FXAA_QUALITY_PRESET 12
  10085. #if (FXAA_QUALITY_PRESET == 10)
  10086. #define FXAA_QUALITY_PS 3
  10087. #define FXAA_QUALITY_P0 1.5
  10088. #define FXAA_QUALITY_P1 3.0
  10089. #define FXAA_QUALITY_P2 12.0
  10090. #endif
  10091. #if (FXAA_QUALITY_PRESET == 11)
  10092. #define FXAA_QUALITY_PS 4
  10093. #define FXAA_QUALITY_P0 1.0
  10094. #define FXAA_QUALITY_P1 1.5
  10095. #define FXAA_QUALITY_P2 3.0
  10096. #define FXAA_QUALITY_P3 12.0
  10097. #endif
  10098. #if (FXAA_QUALITY_PRESET == 12)
  10099. #define FXAA_QUALITY_PS 5
  10100. #define FXAA_QUALITY_P0 1.0
  10101. #define FXAA_QUALITY_P1 1.5
  10102. #define FXAA_QUALITY_P2 2.0
  10103. #define FXAA_QUALITY_P3 4.0
  10104. #define FXAA_QUALITY_P4 12.0
  10105. #endif
  10106. #if (FXAA_QUALITY_PRESET == 13)
  10107. #define FXAA_QUALITY_PS 6
  10108. #define FXAA_QUALITY_P0 1.0
  10109. #define FXAA_QUALITY_P1 1.5
  10110. #define FXAA_QUALITY_P2 2.0
  10111. #define FXAA_QUALITY_P3 2.0
  10112. #define FXAA_QUALITY_P4 4.0
  10113. #define FXAA_QUALITY_P5 12.0
  10114. #endif
  10115. #if (FXAA_QUALITY_PRESET == 14)
  10116. #define FXAA_QUALITY_PS 7
  10117. #define FXAA_QUALITY_P0 1.0
  10118. #define FXAA_QUALITY_P1 1.5
  10119. #define FXAA_QUALITY_P2 2.0
  10120. #define FXAA_QUALITY_P3 2.0
  10121. #define FXAA_QUALITY_P4 2.0
  10122. #define FXAA_QUALITY_P5 4.0
  10123. #define FXAA_QUALITY_P6 12.0
  10124. #endif
  10125. #if (FXAA_QUALITY_PRESET == 15)
  10126. #define FXAA_QUALITY_PS 8
  10127. #define FXAA_QUALITY_P0 1.0
  10128. #define FXAA_QUALITY_P1 1.5
  10129. #define FXAA_QUALITY_P2 2.0
  10130. #define FXAA_QUALITY_P3 2.0
  10131. #define FXAA_QUALITY_P4 2.0
  10132. #define FXAA_QUALITY_P5 2.0
  10133. #define FXAA_QUALITY_P6 4.0
  10134. #define FXAA_QUALITY_P7 12.0
  10135. #endif
  10136. #if (FXAA_QUALITY_PRESET == 20)
  10137. #define FXAA_QUALITY_PS 3
  10138. #define FXAA_QUALITY_P0 1.5
  10139. #define FXAA_QUALITY_P1 2.0
  10140. #define FXAA_QUALITY_P2 8.0
  10141. #endif
  10142. #if (FXAA_QUALITY_PRESET == 21)
  10143. #define FXAA_QUALITY_PS 4
  10144. #define FXAA_QUALITY_P0 1.0
  10145. #define FXAA_QUALITY_P1 1.5
  10146. #define FXAA_QUALITY_P2 2.0
  10147. #define FXAA_QUALITY_P3 8.0
  10148. #endif
  10149. #if (FXAA_QUALITY_PRESET == 22)
  10150. #define FXAA_QUALITY_PS 5
  10151. #define FXAA_QUALITY_P0 1.0
  10152. #define FXAA_QUALITY_P1 1.5
  10153. #define FXAA_QUALITY_P2 2.0
  10154. #define FXAA_QUALITY_P3 2.0
  10155. #define FXAA_QUALITY_P4 8.0
  10156. #endif
  10157. #if (FXAA_QUALITY_PRESET == 23)
  10158. #define FXAA_QUALITY_PS 6
  10159. #define FXAA_QUALITY_P0 1.0
  10160. #define FXAA_QUALITY_P1 1.5
  10161. #define FXAA_QUALITY_P2 2.0
  10162. #define FXAA_QUALITY_P3 2.0
  10163. #define FXAA_QUALITY_P4 2.0
  10164. #define FXAA_QUALITY_P5 8.0
  10165. #endif
  10166. #if (FXAA_QUALITY_PRESET == 24)
  10167. #define FXAA_QUALITY_PS 7
  10168. #define FXAA_QUALITY_P0 1.0
  10169. #define FXAA_QUALITY_P1 1.5
  10170. #define FXAA_QUALITY_P2 2.0
  10171. #define FXAA_QUALITY_P3 2.0
  10172. #define FXAA_QUALITY_P4 2.0
  10173. #define FXAA_QUALITY_P5 3.0
  10174. #define FXAA_QUALITY_P6 8.0
  10175. #endif
  10176. #if (FXAA_QUALITY_PRESET == 25)
  10177. #define FXAA_QUALITY_PS 8
  10178. #define FXAA_QUALITY_P0 1.0
  10179. #define FXAA_QUALITY_P1 1.5
  10180. #define FXAA_QUALITY_P2 2.0
  10181. #define FXAA_QUALITY_P3 2.0
  10182. #define FXAA_QUALITY_P4 2.0
  10183. #define FXAA_QUALITY_P5 2.0
  10184. #define FXAA_QUALITY_P6 4.0
  10185. #define FXAA_QUALITY_P7 8.0
  10186. #endif
  10187. #if (FXAA_QUALITY_PRESET == 26)
  10188. #define FXAA_QUALITY_PS 9
  10189. #define FXAA_QUALITY_P0 1.0
  10190. #define FXAA_QUALITY_P1 1.5
  10191. #define FXAA_QUALITY_P2 2.0
  10192. #define FXAA_QUALITY_P3 2.0
  10193. #define FXAA_QUALITY_P4 2.0
  10194. #define FXAA_QUALITY_P5 2.0
  10195. #define FXAA_QUALITY_P6 2.0
  10196. #define FXAA_QUALITY_P7 4.0
  10197. #define FXAA_QUALITY_P8 8.0
  10198. #endif
  10199. #if (FXAA_QUALITY_PRESET == 27)
  10200. #define FXAA_QUALITY_PS 10
  10201. #define FXAA_QUALITY_P0 1.0
  10202. #define FXAA_QUALITY_P1 1.5
  10203. #define FXAA_QUALITY_P2 2.0
  10204. #define FXAA_QUALITY_P3 2.0
  10205. #define FXAA_QUALITY_P4 2.0
  10206. #define FXAA_QUALITY_P5 2.0
  10207. #define FXAA_QUALITY_P6 2.0
  10208. #define FXAA_QUALITY_P7 2.0
  10209. #define FXAA_QUALITY_P8 4.0
  10210. #define FXAA_QUALITY_P9 8.0
  10211. #endif
  10212. #if (FXAA_QUALITY_PRESET == 28)
  10213. #define FXAA_QUALITY_PS 11
  10214. #define FXAA_QUALITY_P0 1.0
  10215. #define FXAA_QUALITY_P1 1.5
  10216. #define FXAA_QUALITY_P2 2.0
  10217. #define FXAA_QUALITY_P3 2.0
  10218. #define FXAA_QUALITY_P4 2.0
  10219. #define FXAA_QUALITY_P5 2.0
  10220. #define FXAA_QUALITY_P6 2.0
  10221. #define FXAA_QUALITY_P7 2.0
  10222. #define FXAA_QUALITY_P8 2.0
  10223. #define FXAA_QUALITY_P9 4.0
  10224. #define FXAA_QUALITY_P10 8.0
  10225. #endif
  10226. #if (FXAA_QUALITY_PRESET == 29)
  10227. #define FXAA_QUALITY_PS 12
  10228. #define FXAA_QUALITY_P0 1.0
  10229. #define FXAA_QUALITY_P1 1.5
  10230. #define FXAA_QUALITY_P2 2.0
  10231. #define FXAA_QUALITY_P3 2.0
  10232. #define FXAA_QUALITY_P4 2.0
  10233. #define FXAA_QUALITY_P5 2.0
  10234. #define FXAA_QUALITY_P6 2.0
  10235. #define FXAA_QUALITY_P7 2.0
  10236. #define FXAA_QUALITY_P8 2.0
  10237. #define FXAA_QUALITY_P9 2.0
  10238. #define FXAA_QUALITY_P10 4.0
  10239. #define FXAA_QUALITY_P11 8.0
  10240. #endif
  10241. #if (FXAA_QUALITY_PRESET == 39)
  10242. #define FXAA_QUALITY_PS 12
  10243. #define FXAA_QUALITY_P0 1.0
  10244. #define FXAA_QUALITY_P1 1.0
  10245. #define FXAA_QUALITY_P2 1.0
  10246. #define FXAA_QUALITY_P3 1.0
  10247. #define FXAA_QUALITY_P4 1.0
  10248. #define FXAA_QUALITY_P5 1.5
  10249. #define FXAA_QUALITY_P6 2.0
  10250. #define FXAA_QUALITY_P7 2.0
  10251. #define FXAA_QUALITY_P8 2.0
  10252. #define FXAA_QUALITY_P9 2.0
  10253. #define FXAA_QUALITY_P10 4.0
  10254. #define FXAA_QUALITY_P11 8.0
  10255. #endif
  10256. #define FxaaBool bool
  10257. #define FxaaFloat float
  10258. #define FxaaFloat2 vec2
  10259. #define FxaaFloat3 vec3
  10260. #define FxaaFloat4 vec4
  10261. #define FxaaHalf float
  10262. #define FxaaHalf2 vec2
  10263. #define FxaaHalf3 vec3
  10264. #define FxaaHalf4 vec4
  10265. #define FxaaInt2 vec2
  10266. #define FxaaTex sampler2D
  10267. #define FxaaSat(x) clamp(x, 0.0, 1.0)
  10268. #define FxaaTexTop(t, p) texture(t, p)
  10269. #define FxaaTexOff(t, p, o, r) texture(t, p + (o * r))
  10270. FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
  10271. FxaaFloat4 FxaaPixelShader(
  10272. //
  10273. // Use noperspective interpolation here (turn off perspective interpolation).
  10274. // {xy} = center of pixel
  10275. FxaaFloat2 pos,
  10276. //
  10277. // Input color texture.
  10278. // {rgb_} = color in linear or perceptual color space
  10279. // if (FXAA_GREEN_AS_LUMA == 0)
  10280. // {___a} = luma in perceptual color space (not linear)
  10281. FxaaTex tex,
  10282. //
  10283. // Only used on FXAA Quality.
  10284. // This must be from a constant/uniform.
  10285. // {x_} = 1.0/screenWidthInPixels
  10286. // {_y} = 1.0/screenHeightInPixels
  10287. FxaaFloat2 fxaaQualityRcpFrame,
  10288. //
  10289. // Only used on FXAA Quality.
  10290. // This used to be the FXAA_QUALITY_SUBPIX define.
  10291. // It is here now to allow easier tuning.
  10292. // Choose the amount of sub-pixel aliasing removal.
  10293. // This can effect sharpness.
  10294. // 1.00 - upper limit (softer)
  10295. // 0.75 - default amount of filtering
  10296. // 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
  10297. // 0.25 - almost off
  10298. // 0.00 - completely off
  10299. FxaaFloat fxaaQualitySubpix,
  10300. //
  10301. // Only used on FXAA Quality.
  10302. // This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
  10303. // It is here now to allow easier tuning.
  10304. // The minimum amount of local contrast required to apply algorithm.
  10305. // 0.333 - too little (faster)
  10306. // 0.250 - low quality
  10307. // 0.166 - default
  10308. // 0.125 - high quality
  10309. // 0.063 - overkill (slower)
  10310. FxaaFloat fxaaQualityEdgeThreshold,
  10311. //
  10312. // Only used on FXAA Quality.
  10313. // This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
  10314. // It is here now to allow easier tuning.
  10315. // Trims the algorithm from processing darks.
  10316. // 0.0833 - upper limit (default, the start of visible unfiltered edges)
  10317. // 0.0625 - high quality (faster)
  10318. // 0.0312 - visible limit (slower)
  10319. // Special notes when using FXAA_GREEN_AS_LUMA,
  10320. // Likely want to set this to zero.
  10321. // As colors that are mostly not-green
  10322. // will appear very dark in the green channel!
  10323. // Tune by looking at mostly non-green content,
  10324. // then start at zero and increase until aliasing is a problem.
  10325. FxaaFloat fxaaQualityEdgeThresholdMin
  10326. ) {
  10327. /*--------------------------------------------------------------------------*/
  10328. FxaaFloat2 posM;
  10329. posM.x = pos.x;
  10330. posM.y = pos.y;
  10331. FxaaFloat4 rgbyM = FxaaTexTop(tex, posM);
  10332. #define lumaM rgbyM.y
  10333. FxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0, 1), fxaaQualityRcpFrame.xy));
  10334. FxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 0), fxaaQualityRcpFrame.xy));
  10335. FxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 0,-1), fxaaQualityRcpFrame.xy));
  10336. FxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));
  10337. /*--------------------------------------------------------------------------*/
  10338. FxaaFloat maxSM = max(lumaS, lumaM);
  10339. FxaaFloat minSM = min(lumaS, lumaM);
  10340. FxaaFloat maxESM = max(lumaE, maxSM);
  10341. FxaaFloat minESM = min(lumaE, minSM);
  10342. FxaaFloat maxWN = max(lumaN, lumaW);
  10343. FxaaFloat minWN = min(lumaN, lumaW);
  10344. FxaaFloat rangeMax = max(maxWN, maxESM);
  10345. FxaaFloat rangeMin = min(minWN, minESM);
  10346. FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;
  10347. FxaaFloat range = rangeMax - rangeMin;
  10348. FxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);
  10349. FxaaBool earlyExit = range < rangeMaxClamped;
  10350. /*--------------------------------------------------------------------------*/
  10351. if(earlyExit)
  10352. return rgbyM;
  10353. /*--------------------------------------------------------------------------*/
  10354. FxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));
  10355. FxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1, 1), fxaaQualityRcpFrame.xy));
  10356. FxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2( 1,-1), fxaaQualityRcpFrame.xy));
  10357. FxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));
  10358. /*--------------------------------------------------------------------------*/
  10359. FxaaFloat lumaNS = lumaN + lumaS;
  10360. FxaaFloat lumaWE = lumaW + lumaE;
  10361. FxaaFloat subpixRcpRange = 1.0/range;
  10362. FxaaFloat subpixNSWE = lumaNS + lumaWE;
  10363. FxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;
  10364. FxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;
  10365. /*--------------------------------------------------------------------------*/
  10366. FxaaFloat lumaNESE = lumaNE + lumaSE;
  10367. FxaaFloat lumaNWNE = lumaNW + lumaNE;
  10368. FxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;
  10369. FxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;
  10370. /*--------------------------------------------------------------------------*/
  10371. FxaaFloat lumaNWSW = lumaNW + lumaSW;
  10372. FxaaFloat lumaSWSE = lumaSW + lumaSE;
  10373. FxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);
  10374. FxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);
  10375. FxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;
  10376. FxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;
  10377. FxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;
  10378. FxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;
  10379. /*--------------------------------------------------------------------------*/
  10380. FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;
  10381. FxaaFloat lengthSign = fxaaQualityRcpFrame.x;
  10382. FxaaBool horzSpan = edgeHorz >= edgeVert;
  10383. FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;
  10384. /*--------------------------------------------------------------------------*/
  10385. if(!horzSpan) lumaN = lumaW;
  10386. if(!horzSpan) lumaS = lumaE;
  10387. if(horzSpan) lengthSign = fxaaQualityRcpFrame.y;
  10388. FxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;
  10389. /*--------------------------------------------------------------------------*/
  10390. FxaaFloat gradientN = lumaN - lumaM;
  10391. FxaaFloat gradientS = lumaS - lumaM;
  10392. FxaaFloat lumaNN = lumaN + lumaM;
  10393. FxaaFloat lumaSS = lumaS + lumaM;
  10394. FxaaBool pairN = abs(gradientN) >= abs(gradientS);
  10395. FxaaFloat gradient = max(abs(gradientN), abs(gradientS));
  10396. if(pairN) lengthSign = -lengthSign;
  10397. FxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);
  10398. /*--------------------------------------------------------------------------*/
  10399. FxaaFloat2 posB;
  10400. posB.x = posM.x;
  10401. posB.y = posM.y;
  10402. FxaaFloat2 offNP;
  10403. offNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;
  10404. offNP.y = ( horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;
  10405. if(!horzSpan) posB.x += lengthSign * 0.5;
  10406. if( horzSpan) posB.y += lengthSign * 0.5;
  10407. /*--------------------------------------------------------------------------*/
  10408. FxaaFloat2 posN;
  10409. posN.x = posB.x - offNP.x * FXAA_QUALITY_P0;
  10410. posN.y = posB.y - offNP.y * FXAA_QUALITY_P0;
  10411. FxaaFloat2 posP;
  10412. posP.x = posB.x + offNP.x * FXAA_QUALITY_P0;
  10413. posP.y = posB.y + offNP.y * FXAA_QUALITY_P0;
  10414. FxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;
  10415. FxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));
  10416. FxaaFloat subpixE = subpixC * subpixC;
  10417. FxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));
  10418. /*--------------------------------------------------------------------------*/
  10419. if(!pairN) lumaNN = lumaSS;
  10420. FxaaFloat gradientScaled = gradient * 1.0/4.0;
  10421. FxaaFloat lumaMM = lumaM - lumaNN * 0.5;
  10422. FxaaFloat subpixF = subpixD * subpixE;
  10423. FxaaBool lumaMLTZero = lumaMM < 0.0;
  10424. /*--------------------------------------------------------------------------*/
  10425. lumaEndN -= lumaNN * 0.5;
  10426. lumaEndP -= lumaNN * 0.5;
  10427. FxaaBool doneN = abs(lumaEndN) >= gradientScaled;
  10428. FxaaBool doneP = abs(lumaEndP) >= gradientScaled;
  10429. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;
  10430. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;
  10431. FxaaBool doneNP = (!doneN) || (!doneP);
  10432. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;
  10433. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;
  10434. /*--------------------------------------------------------------------------*/
  10435. if(doneNP) {
  10436. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10437. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10438. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10439. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10440. doneN = abs(lumaEndN) >= gradientScaled;
  10441. doneP = abs(lumaEndP) >= gradientScaled;
  10442. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;
  10443. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;
  10444. doneNP = (!doneN) || (!doneP);
  10445. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;
  10446. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;
  10447. /*--------------------------------------------------------------------------*/
  10448. #if (FXAA_QUALITY_PS > 3)
  10449. if(doneNP) {
  10450. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10451. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10452. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10453. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10454. doneN = abs(lumaEndN) >= gradientScaled;
  10455. doneP = abs(lumaEndP) >= gradientScaled;
  10456. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;
  10457. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;
  10458. doneNP = (!doneN) || (!doneP);
  10459. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;
  10460. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;
  10461. /*--------------------------------------------------------------------------*/
  10462. #if (FXAA_QUALITY_PS > 4)
  10463. if(doneNP) {
  10464. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10465. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10466. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10467. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10468. doneN = abs(lumaEndN) >= gradientScaled;
  10469. doneP = abs(lumaEndP) >= gradientScaled;
  10470. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;
  10471. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;
  10472. doneNP = (!doneN) || (!doneP);
  10473. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;
  10474. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;
  10475. /*--------------------------------------------------------------------------*/
  10476. #if (FXAA_QUALITY_PS > 5)
  10477. if(doneNP) {
  10478. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10479. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10480. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10481. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10482. doneN = abs(lumaEndN) >= gradientScaled;
  10483. doneP = abs(lumaEndP) >= gradientScaled;
  10484. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;
  10485. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;
  10486. doneNP = (!doneN) || (!doneP);
  10487. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;
  10488. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;
  10489. /*--------------------------------------------------------------------------*/
  10490. #if (FXAA_QUALITY_PS > 6)
  10491. if(doneNP) {
  10492. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10493. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10494. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10495. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10496. doneN = abs(lumaEndN) >= gradientScaled;
  10497. doneP = abs(lumaEndP) >= gradientScaled;
  10498. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;
  10499. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;
  10500. doneNP = (!doneN) || (!doneP);
  10501. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;
  10502. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;
  10503. /*--------------------------------------------------------------------------*/
  10504. #if (FXAA_QUALITY_PS > 7)
  10505. if(doneNP) {
  10506. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10507. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10508. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10509. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10510. doneN = abs(lumaEndN) >= gradientScaled;
  10511. doneP = abs(lumaEndP) >= gradientScaled;
  10512. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;
  10513. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;
  10514. doneNP = (!doneN) || (!doneP);
  10515. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;
  10516. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;
  10517. /*--------------------------------------------------------------------------*/
  10518. #if (FXAA_QUALITY_PS > 8)
  10519. if(doneNP) {
  10520. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10521. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10522. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10523. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10524. doneN = abs(lumaEndN) >= gradientScaled;
  10525. doneP = abs(lumaEndP) >= gradientScaled;
  10526. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;
  10527. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;
  10528. doneNP = (!doneN) || (!doneP);
  10529. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;
  10530. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;
  10531. /*--------------------------------------------------------------------------*/
  10532. #if (FXAA_QUALITY_PS > 9)
  10533. if(doneNP) {
  10534. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10535. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10536. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10537. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10538. doneN = abs(lumaEndN) >= gradientScaled;
  10539. doneP = abs(lumaEndP) >= gradientScaled;
  10540. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;
  10541. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;
  10542. doneNP = (!doneN) || (!doneP);
  10543. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;
  10544. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;
  10545. /*--------------------------------------------------------------------------*/
  10546. #if (FXAA_QUALITY_PS > 10)
  10547. if(doneNP) {
  10548. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10549. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10550. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10551. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10552. doneN = abs(lumaEndN) >= gradientScaled;
  10553. doneP = abs(lumaEndP) >= gradientScaled;
  10554. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;
  10555. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;
  10556. doneNP = (!doneN) || (!doneP);
  10557. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;
  10558. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;
  10559. /*--------------------------------------------------------------------------*/
  10560. #if (FXAA_QUALITY_PS > 11)
  10561. if(doneNP) {
  10562. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10563. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10564. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10565. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10566. doneN = abs(lumaEndN) >= gradientScaled;
  10567. doneP = abs(lumaEndP) >= gradientScaled;
  10568. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;
  10569. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;
  10570. doneNP = (!doneN) || (!doneP);
  10571. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;
  10572. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;
  10573. /*--------------------------------------------------------------------------*/
  10574. #if (FXAA_QUALITY_PS > 12)
  10575. if(doneNP) {
  10576. if(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));
  10577. if(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));
  10578. if(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;
  10579. if(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;
  10580. doneN = abs(lumaEndN) >= gradientScaled;
  10581. doneP = abs(lumaEndP) >= gradientScaled;
  10582. if(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;
  10583. if(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;
  10584. doneNP = (!doneN) || (!doneP);
  10585. if(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;
  10586. if(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;
  10587. /*--------------------------------------------------------------------------*/
  10588. }
  10589. #endif
  10590. /*--------------------------------------------------------------------------*/
  10591. }
  10592. #endif
  10593. /*--------------------------------------------------------------------------*/
  10594. }
  10595. #endif
  10596. /*--------------------------------------------------------------------------*/
  10597. }
  10598. #endif
  10599. /*--------------------------------------------------------------------------*/
  10600. }
  10601. #endif
  10602. /*--------------------------------------------------------------------------*/
  10603. }
  10604. #endif
  10605. /*--------------------------------------------------------------------------*/
  10606. }
  10607. #endif
  10608. /*--------------------------------------------------------------------------*/
  10609. }
  10610. #endif
  10611. /*--------------------------------------------------------------------------*/
  10612. }
  10613. #endif
  10614. /*--------------------------------------------------------------------------*/
  10615. }
  10616. #endif
  10617. /*--------------------------------------------------------------------------*/
  10618. }
  10619. /*--------------------------------------------------------------------------*/
  10620. FxaaFloat dstN = posM.x - posN.x;
  10621. FxaaFloat dstP = posP.x - posM.x;
  10622. if(!horzSpan) dstN = posM.y - posN.y;
  10623. if(!horzSpan) dstP = posP.y - posM.y;
  10624. /*--------------------------------------------------------------------------*/
  10625. FxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;
  10626. FxaaFloat spanLength = (dstP + dstN);
  10627. FxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;
  10628. FxaaFloat spanLengthRcp = 1.0/spanLength;
  10629. /*--------------------------------------------------------------------------*/
  10630. FxaaBool directionN = dstN < dstP;
  10631. FxaaFloat dst = min(dstN, dstP);
  10632. FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;
  10633. FxaaFloat subpixG = subpixF * subpixF;
  10634. FxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;
  10635. FxaaFloat subpixH = subpixG * fxaaQualitySubpix;
  10636. /*--------------------------------------------------------------------------*/
  10637. FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;
  10638. FxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);
  10639. if(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;
  10640. if( horzSpan) posM.y += pixelOffsetSubpix * lengthSign;
  10641. return FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);
  10642. }
  10643. `;var MKi=y(x(),1),$X=`uniform vec4 u_initialColor;
  10644. #if TEXTURE_UNITS > 0
  10645. uniform sampler2D u_dayTextures[TEXTURE_UNITS];
  10646. uniform vec4 u_dayTextureTranslationAndScale[TEXTURE_UNITS];
  10647. uniform bool u_dayTextureUseWebMercatorT[TEXTURE_UNITS];
  10648. #ifdef APPLY_ALPHA
  10649. uniform float u_dayTextureAlpha[TEXTURE_UNITS];
  10650. #endif
  10651. #ifdef APPLY_DAY_NIGHT_ALPHA
  10652. uniform float u_dayTextureNightAlpha[TEXTURE_UNITS];
  10653. uniform float u_dayTextureDayAlpha[TEXTURE_UNITS];
  10654. #endif
  10655. #ifdef APPLY_SPLIT
  10656. uniform float u_dayTextureSplit[TEXTURE_UNITS];
  10657. #endif
  10658. #ifdef APPLY_BRIGHTNESS
  10659. uniform float u_dayTextureBrightness[TEXTURE_UNITS];
  10660. #endif
  10661. #ifdef APPLY_CONTRAST
  10662. uniform float u_dayTextureContrast[TEXTURE_UNITS];
  10663. #endif
  10664. #ifdef APPLY_HUE
  10665. uniform float u_dayTextureHue[TEXTURE_UNITS];
  10666. #endif
  10667. #ifdef APPLY_SATURATION
  10668. uniform float u_dayTextureSaturation[TEXTURE_UNITS];
  10669. #endif
  10670. #ifdef APPLY_GAMMA
  10671. uniform float u_dayTextureOneOverGamma[TEXTURE_UNITS];
  10672. #endif
  10673. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10674. #ifdef APPLY_INVERT_COLOR_MARS3D
  10675. uniform bool u_mars3dTextureInvertColor[TEXTURE_UNITS];
  10676. #endif
  10677. #ifdef APPLY_FILTER_COLOR_MARS3D
  10678. uniform vec3 u_mars3dTextureFilterColor[TEXTURE_UNITS];
  10679. #endif
  10680. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10681. #ifdef APPLY_IMAGERY_CUTOUT
  10682. uniform vec4 u_dayTextureCutoutRectangles[TEXTURE_UNITS];
  10683. #endif
  10684. #ifdef APPLY_COLOR_TO_ALPHA
  10685. uniform vec4 u_colorsToAlpha[TEXTURE_UNITS];
  10686. #endif
  10687. uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];
  10688. #endif
  10689. #if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))
  10690. uniform sampler2D u_waterMask;
  10691. uniform vec4 u_waterMaskTranslationAndScale;
  10692. uniform float u_zoomedOutOceanSpecularIntensity;
  10693. #endif
  10694. #ifdef SHOW_OCEAN_WAVES
  10695. uniform sampler2D u_oceanNormalMap;
  10696. #endif
  10697. #if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)
  10698. uniform vec2 u_lightingFadeDistance;
  10699. #endif
  10700. #ifdef TILE_LIMIT_RECTANGLE
  10701. uniform vec4 u_cartographicLimitRectangle;
  10702. #endif
  10703. #ifdef GROUND_ATMOSPHERE
  10704. uniform vec2 u_nightFadeDistance;
  10705. #endif
  10706. #ifdef ENABLE_CLIPPING_PLANES
  10707. uniform highp sampler2D u_clippingPlanes;
  10708. uniform mat4 u_clippingPlanesMatrix;
  10709. uniform vec4 u_clippingPlanesEdgeStyle;
  10710. #endif
  10711. #ifdef ENABLE_CLIPPING_POLYGONS
  10712. uniform highp sampler2D u_clippingDistance;
  10713. in vec2 v_clippingPosition;
  10714. flat in int v_regionIndex;
  10715. #endif
  10716. #if defined(GROUND_ATMOSPHERE) || defined(FOG) && defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
  10717. uniform float u_minimumBrightness;
  10718. #endif
  10719. // Based on colorCorrect
  10720. // The colorCorrect flag can only be true when tileProvider.hue/saturation/brightnessShift
  10721. // are nonzero AND when (applyFog || showGroundAtmosphere) in the tile provider
  10722. // - The tileProvider.hue/saturation/brightnessShift are just passed through
  10723. // from the Globe hue/saturation/brightness, like atmosphereBrightnessShift
  10724. // - The applyFog depends on enableFog, and some tile distance from the viewer
  10725. // - The showGroundAtmosphere is a flag that is passed through from the Globe,
  10726. // and is true by default when the ellipsoid is WGS84
  10727. #ifdef COLOR_CORRECT
  10728. uniform vec3 u_hsbShift; // Hue, saturation, brightness
  10729. #endif
  10730. // Based on highlightFillTile
  10731. // This is set for terrain tiles when they are "fill" tiles, and
  10732. // the terrainProvider.fillHighlightColor was set to a value with
  10733. // nonzero alpha
  10734. #ifdef HIGHLIGHT_FILL_TILE
  10735. uniform vec4 u_fillHighlightColor;
  10736. #endif
  10737. // Based on translucent
  10738. // This is set depending on the GlobeTranslucencyState
  10739. #ifdef TRANSLUCENT
  10740. uniform vec4 u_frontFaceAlphaByDistance;
  10741. uniform vec4 u_backFaceAlphaByDistance;
  10742. uniform vec4 u_translucencyRectangle;
  10743. #endif
  10744. // Based on showUndergroundColor
  10745. // This is set when GlobeSurfaceTileProvider.isUndergroundVisible
  10746. // returns true, AND the tileProvider.undergroundColor had a value with
  10747. // nonzero alpha, and the tileProvider.undergroundColorAlphaByDistance
  10748. // was in the right range
  10749. #ifdef UNDERGROUND_COLOR
  10750. uniform vec4 u_undergroundColor;
  10751. uniform vec4 u_undergroundColorAlphaByDistance;
  10752. #endif
  10753. // Based on enableLighting && hasVertexNormals
  10754. // The enableLighting flag is passed in directly from the Globe.
  10755. // The hasVertexNormals flag is from the tileProvider
  10756. #ifdef ENABLE_VERTEX_LIGHTING
  10757. uniform float u_lambertDiffuseMultiplier;
  10758. uniform float u_vertexShadowDarkness;
  10759. #endif
  10760. in vec3 v_positionMC;
  10761. in vec3 v_positionEC;
  10762. in vec3 v_textureCoordinates;
  10763. in vec3 v_normalMC;
  10764. in vec3 v_normalEC;
  10765. #ifdef APPLY_MATERIAL
  10766. in float v_height;
  10767. in float v_slope;
  10768. in float v_aspect;
  10769. #endif
  10770. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
  10771. #ifdef APPLY_MARS3D_FLOOD
  10772. uniform bool u_mars_flood_enabled;
  10773. uniform bool u_mars_flood_only;
  10774. uniform vec4 u_mars_flood_rectangle;
  10775. uniform highp sampler2D u_mars_flood_texture;
  10776. #endif
  10777. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
  10778. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
  10779. #ifdef APPLY_MARS3D_CLIP
  10780. uniform bool u_mars_clip_enabled;
  10781. uniform bool u_mars_clip_only;
  10782. uniform vec4 u_mars_clip_rectangle;
  10783. uniform highp sampler2D u_mars_clip_texture;
  10784. #endif
  10785. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
  10786. //\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
  10787. uniform highp float u_mars_inverseTileWidth;
  10788. uniform highp vec2 u_mars_cartographicTileRectangle;
  10789. bool inAreaMars3DRange(vec4 rectangle, sampler2D rangeTexture) {
  10790. float lo = v_textureCoordinates.x / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.x;
  10791. float la = v_textureCoordinates.y / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.y;
  10792. float newX = (lo - rectangle.x) / rectangle.z;
  10793. float newY = (la - rectangle.y) / rectangle.w;
  10794. if(newX >= 0.0 && newX <= 1.0 && newY >= 0.0 && newY <= 1.0){
  10795. vec4 point = texture(rangeTexture, vec2(newX, newY));
  10796. return point.r > 0.0;
  10797. }
  10798. return false;
  10799. }
  10800. //\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
  10801. #if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
  10802. in float v_distance;
  10803. #endif
  10804. #if defined(GROUND_ATMOSPHERE) || defined(FOG)
  10805. in vec3 v_atmosphereRayleighColor;
  10806. in vec3 v_atmosphereMieColor;
  10807. in float v_atmosphereOpacity;
  10808. #endif
  10809. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
  10810. #ifdef APPLY_MARS3D_UPLIFT
  10811. uniform vec4 u_mars_uplift_rectangle;
  10812. uniform highp sampler2D u_mars_uplift_texture;
  10813. uniform bool u_mars_uplift_enabled;
  10814. uniform bool u_mars_uplift_hideInsideOrOutside;
  10815. #endif
  10816. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
  10817. #if defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
  10818. float interpolateByDistance(vec4 nearFarScalar, float distance)
  10819. {
  10820. float startDistance = nearFarScalar.x;
  10821. float startValue = nearFarScalar.y;
  10822. float endDistance = nearFarScalar.z;
  10823. float endValue = nearFarScalar.w;
  10824. float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
  10825. return mix(startValue, endValue, t);
  10826. }
  10827. #endif
  10828. #if defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT) || defined(APPLY_MATERIAL)
  10829. vec4 alphaBlend(vec4 sourceColor, vec4 destinationColor)
  10830. {
  10831. return sourceColor * vec4(sourceColor.aaa, 1.0) + destinationColor * (1.0 - sourceColor.a);
  10832. }
  10833. #endif
  10834. #ifdef TRANSLUCENT
  10835. bool inTranslucencyRectangle()
  10836. {
  10837. return
  10838. v_textureCoordinates.x > u_translucencyRectangle.x &&
  10839. v_textureCoordinates.x < u_translucencyRectangle.z &&
  10840. v_textureCoordinates.y > u_translucencyRectangle.y &&
  10841. v_textureCoordinates.y < u_translucencyRectangle.w;
  10842. }
  10843. #endif
  10844. vec4 sampleAndBlend(
  10845. vec4 previousColor,
  10846. sampler2D textureToSample,
  10847. vec2 tileTextureCoordinates,
  10848. vec4 textureCoordinateRectangle,
  10849. vec4 textureCoordinateTranslationAndScale,
  10850. float textureAlpha,
  10851. float textureNightAlpha,
  10852. float textureDayAlpha,
  10853. float textureBrightness,
  10854. float textureContrast,
  10855. float textureHue,
  10856. float textureSaturation,
  10857. float textureOneOverGamma,
  10858. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10859. bool textureInvertColor,
  10860. vec3 texturefilterColor,
  10861. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10862. float split,
  10863. vec4 colorToAlpha,
  10864. float nightBlend)
  10865. {
  10866. // This crazy step stuff sets the alpha to 0.0 if this following condition is true:
  10867. // tileTextureCoordinates.s < textureCoordinateRectangle.s ||
  10868. // tileTextureCoordinates.s > textureCoordinateRectangle.p ||
  10869. // tileTextureCoordinates.t < textureCoordinateRectangle.t ||
  10870. // tileTextureCoordinates.t > textureCoordinateRectangle.q
  10871. // In other words, the alpha is zero if the fragment is outside the rectangle
  10872. // covered by this texture. Would an actual 'if' yield better performance?
  10873. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);
  10874. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  10875. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);
  10876. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;
  10877. #if defined(APPLY_DAY_NIGHT_ALPHA) && defined(ENABLE_DAYNIGHT_SHADING)
  10878. textureAlpha *= mix(textureDayAlpha, textureNightAlpha, nightBlend);
  10879. #endif
  10880. vec2 translation = textureCoordinateTranslationAndScale.xy;
  10881. vec2 scale = textureCoordinateTranslationAndScale.zw;
  10882. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;
  10883. vec4 value = texture(textureToSample, textureCoordinates);
  10884. vec3 color = value.rgb;
  10885. float alpha = value.a;
  10886. #ifdef APPLY_COLOR_TO_ALPHA
  10887. vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);
  10888. colorDiff.r = czm_maximumComponent(colorDiff);
  10889. alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);
  10890. #endif
  10891. #if !defined(APPLY_GAMMA)
  10892. vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));
  10893. color = tempColor.rgb;
  10894. alpha = tempColor.a;
  10895. #else
  10896. color = pow(color, vec3(textureOneOverGamma));
  10897. #endif
  10898. #ifdef APPLY_SPLIT
  10899. float splitPosition = czm_splitPosition;
  10900. // Split to the left
  10901. if (split < 0.0 && gl_FragCoord.x > splitPosition) {
  10902. alpha = 0.0;
  10903. }
  10904. // Split to the right
  10905. else if (split > 0.0 && gl_FragCoord.x < splitPosition) {
  10906. alpha = 0.0;
  10907. }
  10908. #endif
  10909. #ifdef APPLY_BRIGHTNESS
  10910. color = mix(vec3(0.0), color, textureBrightness);
  10911. #endif
  10912. #ifdef APPLY_CONTRAST
  10913. color = mix(vec3(0.5), color, textureContrast);
  10914. #endif
  10915. #ifdef APPLY_HUE
  10916. color = czm_hue(color, textureHue);
  10917. #endif
  10918. #ifdef APPLY_SATURATION
  10919. color = czm_saturation(color, textureSaturation);
  10920. #endif
  10921. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10922. #ifdef APPLY_INVERT_COLOR_MARS3D
  10923. if(textureInvertColor) {
  10924. color = vec3(1.0 - color.r, 1.0 - color.g, 1.0 - color.b);
  10925. }
  10926. #endif
  10927. #ifdef APPLY_FILTER_COLOR_MARS3D
  10928. if(texturefilterColor.x != 1.0 || texturefilterColor.y != 1.0 || texturefilterColor.z != 1.0) {
  10929. color = vec3(color.r * texturefilterColor.x, color.g * texturefilterColor.y, color.b * texturefilterColor.z);
  10930. }
  10931. #endif
  10932. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  10933. float sourceAlpha = alpha * textureAlpha;
  10934. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);
  10935. outAlpha += sign(outAlpha) - 1.0;
  10936. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;
  10937. // When rendering imagery for a tile in multiple passes,
  10938. // some GPU/WebGL implementation combinations will not blend fragments in
  10939. // additional passes correctly if their computation includes an unmasked
  10940. // divide-by-zero operation,
  10941. // even if it's not in the output or if the output has alpha zero.
  10942. //
  10943. // For example, without sanitization for outAlpha,
  10944. // this renders without artifacts:
  10945. // if (outAlpha == 0.0) { outColor = vec3(0.0); }
  10946. //
  10947. // but using czm_branchFreeTernary will cause portions of the tile that are
  10948. // alpha-zero in the additional pass to render as black instead of blending
  10949. // with the previous pass:
  10950. // outColor = czm_branchFreeTernary(outAlpha == 0.0, vec3(0.0), outColor);
  10951. //
  10952. // So instead, sanitize against divide-by-zero,
  10953. // store this state on the sign of outAlpha, and correct on return.
  10954. return vec4(outColor, max(outAlpha, 0.0));
  10955. }
  10956. vec3 colorCorrect(vec3 rgb) {
  10957. #ifdef COLOR_CORRECT
  10958. // Convert rgb color to hsb
  10959. vec3 hsb = czm_RGBToHSB(rgb);
  10960. // Perform hsb shift
  10961. hsb.x += u_hsbShift.x; // hue
  10962. hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation
  10963. hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness
  10964. // Convert shifted hsb back to rgb
  10965. rgb = czm_HSBToRGB(hsb);
  10966. #endif
  10967. return rgb;
  10968. }
  10969. vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates, float nightBlend);
  10970. vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float specularMapValue, float fade);
  10971. const float fExposure = 2.0;
  10972. vec3 computeEllipsoidPosition()
  10973. {
  10974. float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0), 1.0);
  10975. vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0);
  10976. xy *= czm_viewport.zw * mpp * 0.5;
  10977. vec3 direction;
  10978. if (czm_orthographicIn3D == 1.0)
  10979. {
  10980. direction = vec3(0.0, 0.0, -1.0);
  10981. }
  10982. else
  10983. {
  10984. direction = normalize(vec3(xy, -czm_currentFrustum.x));
  10985. }
  10986. czm_ray ray = czm_ray(vec3(0.0), direction);
  10987. vec3 ellipsoid_center = czm_view[3].xyz;
  10988. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);
  10989. vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start);
  10990. return (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz;
  10991. }
  10992. void main()
  10993. {
  10994. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
  10995. #ifdef APPLY_MARS3D_CLIP
  10996. if(u_mars_clip_enabled) {
  10997. if(u_mars_clip_only) {
  10998. if(!inAreaMars3DRange(u_mars_clip_rectangle, u_mars_clip_texture)) {
  10999. discard;
  11000. }
  11001. } else {
  11002. if(inAreaMars3DRange(u_mars_clip_rectangle, u_mars_clip_texture)) {
  11003. discard;
  11004. }
  11005. }
  11006. }
  11007. #endif
  11008. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u5F00\u6316
  11009. #ifdef TILE_LIMIT_RECTANGLE
  11010. if (v_textureCoordinates.x < u_cartographicLimitRectangle.x || u_cartographicLimitRectangle.z < v_textureCoordinates.x ||
  11011. v_textureCoordinates.y < u_cartographicLimitRectangle.y || u_cartographicLimitRectangle.w < v_textureCoordinates.y)
  11012. {
  11013. discard;
  11014. }
  11015. #endif
  11016. #ifdef ENABLE_CLIPPING_PLANES
  11017. float clipDistance = clip(gl_FragCoord, u_clippingPlanes, u_clippingPlanesMatrix);
  11018. #endif
  11019. #if defined(SHOW_REFLECTIVE_OCEAN) || defined(ENABLE_DAYNIGHT_SHADING) || defined(HDR)
  11020. vec3 normalMC = czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)); // normalized surface normal in model coordinates
  11021. vec3 normalEC = czm_normal3D * normalMC; // normalized surface normal in eye coordinates
  11022. #endif
  11023. #if defined(APPLY_DAY_NIGHT_ALPHA) && defined(ENABLE_DAYNIGHT_SHADING)
  11024. float nightBlend = 1.0 - clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * 5.0, 0.0, 1.0);
  11025. #else
  11026. float nightBlend = 0.0;
  11027. #endif
  11028. // The clamp below works around an apparent bug in Chrome Canary v23.0.1241.0
  11029. // where the fragment shader sees textures coordinates < 0.0 and > 1.0 for the
  11030. // fragments on the edges of tiles even though the vertex shader is outputting
  11031. // coordinates strictly in the 0-1 range.
  11032. vec4 color = computeDayColor(u_initialColor, clamp(v_textureCoordinates, 0.0, 1.0), nightBlend);
  11033. #ifdef SHOW_TILE_BOUNDARIES
  11034. if (v_textureCoordinates.x < (1.0/256.0) || v_textureCoordinates.x > (255.0/256.0) ||
  11035. v_textureCoordinates.y < (1.0/256.0) || v_textureCoordinates.y > (255.0/256.0))
  11036. {
  11037. color = vec4(1.0, 0.0, 0.0, 1.0);
  11038. }
  11039. #endif
  11040. #if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)
  11041. float cameraDist;
  11042. if (czm_sceneMode == czm_sceneMode2D)
  11043. {
  11044. cameraDist = max(czm_frustumPlanes.x - czm_frustumPlanes.y, czm_frustumPlanes.w - czm_frustumPlanes.z) * 0.5;
  11045. }
  11046. else if (czm_sceneMode == czm_sceneModeColumbusView)
  11047. {
  11048. cameraDist = -czm_view[3].z;
  11049. }
  11050. else
  11051. {
  11052. cameraDist = length(czm_view[3]);
  11053. }
  11054. float fadeOutDist = u_lightingFadeDistance.x;
  11055. float fadeInDist = u_lightingFadeDistance.y;
  11056. if (czm_sceneMode != czm_sceneMode3D) {
  11057. vec3 radii = czm_ellipsoidRadii;
  11058. float maxRadii = max(radii.x, max(radii.y, radii.z));
  11059. fadeOutDist -= maxRadii;
  11060. fadeInDist -= maxRadii;
  11061. }
  11062. float fade = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.0, 1.0);
  11063. #else
  11064. float fade = 0.0;
  11065. #endif
  11066. #if defined(HAS_WATER_MASK) && (defined(SHOW_REFLECTIVE_OCEAN) || defined(APPLY_MATERIAL))
  11067. vec2 waterMaskTranslation = u_waterMaskTranslationAndScale.xy;
  11068. vec2 waterMaskScale = u_waterMaskTranslationAndScale.zw;
  11069. vec2 waterMaskTextureCoordinates = v_textureCoordinates.xy * waterMaskScale + waterMaskTranslation;
  11070. waterMaskTextureCoordinates.y = 1.0 - waterMaskTextureCoordinates.y;
  11071. float mask = texture(u_waterMask, waterMaskTextureCoordinates).r;
  11072. #ifdef SHOW_REFLECTIVE_OCEAN
  11073. if (mask > 0.0)
  11074. {
  11075. mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);
  11076. vec2 ellipsoidTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC);
  11077. vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidTextureCoordinates(normalMC.zyx);
  11078. vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));
  11079. color = computeWaterColor(v_positionEC, textureCoordinates, enuToEye, color, mask, fade);
  11080. }
  11081. #endif
  11082. #endif
  11083. #ifdef APPLY_MATERIAL
  11084. czm_materialInput materialInput;
  11085. materialInput.st = v_textureCoordinates.st;
  11086. materialInput.normalEC = normalize(v_normalEC);
  11087. materialInput.positionToEyeEC = -v_positionEC;
  11088. materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalize(v_normalEC));
  11089. materialInput.slope = v_slope;
  11090. materialInput.height = v_height;
  11091. materialInput.aspect = v_aspect;
  11092. #ifdef HAS_WATER_MASK
  11093. materialInput.waterMask = mask;
  11094. #endif
  11095. czm_material material = czm_getMaterial(materialInput);
  11096. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
  11097. bool hasAlphaBlend = true;
  11098. #ifdef APPLY_MARS3D_FLOOD
  11099. hasAlphaBlend = !u_mars_flood_enabled || (u_mars_flood_enabled && inAreaMars3DRange(u_mars_flood_rectangle, u_mars_flood_texture));
  11100. if(u_mars_flood_enabled) {
  11101. if(u_mars_flood_only) {
  11102. if(! inAreaMars3DRange(u_mars_flood_rectangle, u_mars_flood_texture)) {
  11103. discard;
  11104. }
  11105. }
  11106. }
  11107. #endif
  11108. //\u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-07-19 \u5730\u5F62\u533A\u57DF\u6750\u8D28(\u6DF9\u6CA1\uFF0C\u7B49\u9AD8\u7EBF)
  11109. if(hasAlphaBlend) {
  11110. vec4 materialColor = vec4(material.diffuse, material.alpha);
  11111. color = alphaBlend(materialColor, color);
  11112. }
  11113. #endif
  11114. #ifdef ENABLE_VERTEX_LIGHTING
  11115. float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalize(v_normalEC)) * u_lambertDiffuseMultiplier + u_vertexShadowDarkness, 0.0, 1.0);
  11116. vec4 finalColor = vec4(color.rgb * czm_lightColor * diffuseIntensity, color.a);
  11117. #elif defined(ENABLE_DAYNIGHT_SHADING)
  11118. float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * 5.0 + 0.3, 0.0, 1.0);
  11119. diffuseIntensity = mix(1.0, diffuseIntensity, fade);
  11120. vec4 finalColor = vec4(color.rgb * czm_lightColor * diffuseIntensity, color.a);
  11121. #else
  11122. vec4 finalColor = color;
  11123. #endif
  11124. #ifdef ENABLE_CLIPPING_PLANES
  11125. vec4 clippingPlanesEdgeColor = vec4(1.0);
  11126. clippingPlanesEdgeColor.rgb = u_clippingPlanesEdgeStyle.rgb;
  11127. float clippingPlanesEdgeWidth = u_clippingPlanesEdgeStyle.a;
  11128. if (clipDistance < clippingPlanesEdgeWidth)
  11129. {
  11130. finalColor = clippingPlanesEdgeColor;
  11131. }
  11132. #endif
  11133. #ifdef ENABLE_CLIPPING_POLYGONS
  11134. vec2 clippingPosition = v_clippingPosition;
  11135. int regionIndex = v_regionIndex;
  11136. clipPolygons(u_clippingDistance, CLIPPING_POLYGON_REGIONS_LENGTH, clippingPosition, regionIndex);
  11137. #endif
  11138. #ifdef HIGHLIGHT_FILL_TILE
  11139. finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);
  11140. #endif
  11141. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN)
  11142. vec3 atmosphereLightDirection = czm_sunDirectionWC;
  11143. #else
  11144. vec3 atmosphereLightDirection = czm_lightDirectionWC;
  11145. #endif
  11146. #if defined(GROUND_ATMOSPHERE) || defined(FOG)
  11147. if (!czm_backFacing())
  11148. {
  11149. bool dynamicLighting = false;
  11150. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))
  11151. dynamicLighting = true;
  11152. #endif
  11153. vec3 rayleighColor;
  11154. vec3 mieColor;
  11155. float opacity;
  11156. vec3 positionWC;
  11157. vec3 lightDirection;
  11158. // When the camera is far away (camera distance > nightFadeOutDistance), the scattering is computed in the fragment shader.
  11159. // Otherwise, the scattering is computed in the vertex shader.
  11160. #ifdef PER_FRAGMENT_GROUND_ATMOSPHERE
  11161. positionWC = computeEllipsoidPosition();
  11162. lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(positionWC));
  11163. computeAtmosphereScattering(
  11164. positionWC,
  11165. lightDirection,
  11166. rayleighColor,
  11167. mieColor,
  11168. opacity
  11169. );
  11170. #else
  11171. positionWC = v_positionMC;
  11172. lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(positionWC));
  11173. rayleighColor = v_atmosphereRayleighColor;
  11174. mieColor = v_atmosphereMieColor;
  11175. opacity = v_atmosphereOpacity;
  11176. #endif
  11177. #ifdef COLOR_CORRECT
  11178. const bool ignoreBlackPixels = true;
  11179. rayleighColor = czm_applyHSBShift(rayleighColor, u_hsbShift, ignoreBlackPixels);
  11180. mieColor = czm_applyHSBShift(mieColor, u_hsbShift, ignoreBlackPixels);
  11181. #endif
  11182. vec4 groundAtmosphereColor = computeAtmosphereColor(positionWC, lightDirection, rayleighColor, mieColor, opacity);
  11183. // Fog is applied to tiles selected for fog, close to the Earth.
  11184. #ifdef FOG
  11185. vec3 fogColor = groundAtmosphereColor.rgb;
  11186. // If there is lighting, apply that to the fog.
  11187. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
  11188. float darken = clamp(dot(normalize(czm_viewerPositionWC), atmosphereLightDirection), u_minimumBrightness, 1.0);
  11189. fogColor *= darken;
  11190. #endif
  11191. #ifndef HDR
  11192. fogColor.rgb = czm_pbrNeutralTonemapping(fogColor.rgb);
  11193. fogColor.rgb = czm_inverseGamma(fogColor.rgb);
  11194. #endif
  11195. finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor.rgb, czm_fogVisualDensityScalar), finalColor.a);
  11196. #else
  11197. // Apply ground atmosphere. This happens when the camera is far away from the earth.
  11198. // The transmittance is based on optical depth i.e. the length of segment of the ray inside the atmosphere.
  11199. // This value is larger near the "circumference", as it is further away from the camera. We use it to
  11200. // brighten up that area of the ground atmosphere.
  11201. const float transmittanceModifier = 0.5;
  11202. float transmittance = transmittanceModifier + clamp(1.0 - groundAtmosphereColor.a, 0.0, 1.0);
  11203. vec3 finalAtmosphereColor = finalColor.rgb + groundAtmosphereColor.rgb * transmittance;
  11204. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING))
  11205. float fadeInDist = u_nightFadeDistance.x;
  11206. float fadeOutDist = u_nightFadeDistance.y;
  11207. float sunlitAtmosphereIntensity = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.05, 1.0);
  11208. float darken = clamp(dot(normalize(positionWC), atmosphereLightDirection), 0.0, 1.0);
  11209. vec3 darkenendGroundAtmosphereColor = mix(groundAtmosphereColor.rgb, finalAtmosphereColor.rgb, darken);
  11210. finalAtmosphereColor = mix(darkenendGroundAtmosphereColor, finalAtmosphereColor, sunlitAtmosphereIntensity);
  11211. #endif
  11212. #ifndef HDR
  11213. finalAtmosphereColor.rgb = vec3(1.0) - exp(-fExposure * finalAtmosphereColor.rgb);
  11214. #else
  11215. finalAtmosphereColor.rgb = czm_saturation(finalAtmosphereColor.rgb, 1.6);
  11216. #endif
  11217. finalColor.rgb = mix(finalColor.rgb, finalAtmosphereColor.rgb, fade);
  11218. #endif
  11219. }
  11220. #endif
  11221. #ifdef UNDERGROUND_COLOR
  11222. if (czm_backFacing())
  11223. {
  11224. float distanceFromEllipsoid = max(czm_eyeHeight, 0.0);
  11225. float distance = max(v_distance - distanceFromEllipsoid, 0.0);
  11226. float blendAmount = interpolateByDistance(u_undergroundColorAlphaByDistance, distance);
  11227. vec4 undergroundColor = vec4(u_undergroundColor.rgb, u_undergroundColor.a * blendAmount);
  11228. finalColor = alphaBlend(undergroundColor, finalColor);
  11229. }
  11230. #endif
  11231. #ifdef TRANSLUCENT
  11232. if (inTranslucencyRectangle())
  11233. {
  11234. vec4 alphaByDistance = gl_FrontFacing ? u_frontFaceAlphaByDistance : u_backFaceAlphaByDistance;
  11235. finalColor.a *= interpolateByDistance(alphaByDistance, v_distance);
  11236. }
  11237. #endif
  11238. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u62AC\u5347
  11239. #ifdef APPLY_MARS3D_UPLIFT
  11240. if(u_mars_uplift_enabled) {
  11241. bool isInSlopeRampRectangle = inAreaMars3DRange(u_mars_uplift_rectangle, u_mars_uplift_texture);
  11242. if(isInSlopeRampRectangle == u_mars_uplift_hideInsideOrOutside) {
  11243. discard;
  11244. }
  11245. }
  11246. #endif
  11247. out_FragColor = finalColor;
  11248. }
  11249. #ifdef SHOW_REFLECTIVE_OCEAN
  11250. float waveFade(float edge0, float edge1, float x)
  11251. {
  11252. float y = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
  11253. return pow(1.0 - y, 5.0);
  11254. }
  11255. float linearFade(float edge0, float edge1, float x)
  11256. {
  11257. return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);
  11258. }
  11259. // Based on water rendering by Jonas Wagner:
  11260. // http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog
  11261. // low altitude wave settings
  11262. const float oceanFrequencyLowAltitude = 825000.0;
  11263. const float oceanAnimationSpeedLowAltitude = 0.004;
  11264. const float oceanOneOverAmplitudeLowAltitude = 1.0 / 2.0;
  11265. const float oceanSpecularIntensity = 0.5;
  11266. // high altitude wave settings
  11267. const float oceanFrequencyHighAltitude = 125000.0;
  11268. const float oceanAnimationSpeedHighAltitude = 0.008;
  11269. const float oceanOneOverAmplitudeHighAltitude = 1.0 / 2.0;
  11270. vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float maskValue, float fade)
  11271. {
  11272. vec3 positionToEyeEC = -positionEyeCoordinates;
  11273. float positionToEyeECLength = length(positionToEyeEC);
  11274. // The double normalize below works around a bug in Firefox on Android devices.
  11275. vec3 normalizedPositionToEyeEC = normalize(normalize(positionToEyeEC));
  11276. // Fade out the waves as the camera moves far from the surface.
  11277. float waveIntensity = waveFade(70000.0, 1000000.0, positionToEyeECLength);
  11278. #ifdef SHOW_OCEAN_WAVES
  11279. // high altitude waves
  11280. float time = czm_frameNumber * oceanAnimationSpeedHighAltitude;
  11281. vec4 noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyHighAltitude, time, 0.0);
  11282. vec3 normalTangentSpaceHighAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeHighAltitude);
  11283. // low altitude waves
  11284. time = czm_frameNumber * oceanAnimationSpeedLowAltitude;
  11285. noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyLowAltitude, time, 0.0);
  11286. vec3 normalTangentSpaceLowAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeLowAltitude);
  11287. // blend the 2 wave layers based on distance to surface
  11288. float highAltitudeFade = linearFade(0.0, 60000.0, positionToEyeECLength);
  11289. float lowAltitudeFade = 1.0 - linearFade(20000.0, 60000.0, positionToEyeECLength);
  11290. vec3 normalTangentSpace =
  11291. (highAltitudeFade * normalTangentSpaceHighAltitude) +
  11292. (lowAltitudeFade * normalTangentSpaceLowAltitude);
  11293. normalTangentSpace = normalize(normalTangentSpace);
  11294. // fade out the normal perturbation as we move farther from the water surface
  11295. normalTangentSpace.xy *= waveIntensity;
  11296. normalTangentSpace = normalize(normalTangentSpace);
  11297. #else
  11298. vec3 normalTangentSpace = vec3(0.0, 0.0, 1.0);
  11299. #endif
  11300. vec3 normalEC = enuToEye * normalTangentSpace;
  11301. const vec3 waveHighlightColor = vec3(0.3, 0.45, 0.6);
  11302. // Use diffuse light to highlight the waves
  11303. float diffuseIntensity = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC) * maskValue;
  11304. vec3 diffuseHighlight = waveHighlightColor * diffuseIntensity * (1.0 - fade);
  11305. #ifdef SHOW_OCEAN_WAVES
  11306. // Where diffuse light is low or non-existent, use wave highlights based solely on
  11307. // the wave bumpiness and no particular light direction.
  11308. float tsPerturbationRatio = normalTangentSpace.z;
  11309. vec3 nonDiffuseHighlight = mix(waveHighlightColor * 5.0 * (1.0 - tsPerturbationRatio), vec3(0.0), diffuseIntensity);
  11310. #else
  11311. vec3 nonDiffuseHighlight = vec3(0.0);
  11312. #endif
  11313. // Add specular highlights in 3D, and in all modes when zoomed in.
  11314. float specularIntensity = czm_getSpecular(czm_lightDirectionEC, normalizedPositionToEyeEC, normalEC, 10.0);
  11315. float surfaceReflectance = mix(0.0, mix(u_zoomedOutOceanSpecularIntensity, oceanSpecularIntensity, waveIntensity), maskValue);
  11316. float specular = specularIntensity * surfaceReflectance;
  11317. #ifdef HDR
  11318. specular *= 1.4;
  11319. float e = 0.2;
  11320. float d = 3.3;
  11321. float c = 1.7;
  11322. vec3 color = imageryColor.rgb + (c * (vec3(e) + imageryColor.rgb * d) * (diffuseHighlight + nonDiffuseHighlight + specular));
  11323. #else
  11324. vec3 color = imageryColor.rgb + diffuseHighlight + nonDiffuseHighlight + specular;
  11325. #endif
  11326. return vec4(color, imageryColor.a);
  11327. }
  11328. #endif // #ifdef SHOW_REFLECTIVE_OCEAN
  11329. `;var UKi=y(x(),1),eY=`#ifdef QUANTIZATION_BITS12
  11330. in vec4 compressed0;
  11331. in float compressed1;
  11332. #else
  11333. in vec4 position3DAndHeight;
  11334. in vec4 textureCoordAndEncodedNormals;
  11335. #endif
  11336. #ifdef GEODETIC_SURFACE_NORMALS
  11337. in vec3 geodeticSurfaceNormal;
  11338. #endif
  11339. #ifdef EXAGGERATION
  11340. uniform vec2 u_verticalExaggerationAndRelativeHeight;
  11341. #endif
  11342. uniform vec3 u_center3D;
  11343. uniform mat4 u_modifiedModelView;
  11344. uniform mat4 u_modifiedModelViewProjection;
  11345. uniform vec4 u_tileRectangle;
  11346. // Uniforms for 2D Mercator projection
  11347. uniform vec2 u_southAndNorthLatitude;
  11348. uniform vec2 u_southMercatorYAndOneOverHeight;
  11349. out vec3 v_positionMC;
  11350. out vec3 v_positionEC;
  11351. out vec3 v_textureCoordinates;
  11352. out vec3 v_normalMC;
  11353. out vec3 v_normalEC;
  11354. #ifdef APPLY_MATERIAL
  11355. out float v_slope;
  11356. out float v_aspect;
  11357. out float v_height;
  11358. #endif
  11359. #if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
  11360. out float v_distance;
  11361. #endif
  11362. #if defined(FOG) || defined(GROUND_ATMOSPHERE)
  11363. out vec3 v_atmosphereRayleighColor;
  11364. out vec3 v_atmosphereMieColor;
  11365. out float v_atmosphereOpacity;
  11366. #endif
  11367. #ifdef ENABLE_CLIPPING_POLYGONS
  11368. uniform highp sampler2D u_clippingExtents;
  11369. out vec2 v_clippingPosition;
  11370. flat out int v_regionIndex;
  11371. #endif
  11372. // These functions are generated at runtime.
  11373. vec4 getPosition(vec3 position, float height, vec2 textureCoordinates);
  11374. float get2DYPositionFraction(vec2 textureCoordinates);
  11375. vec4 getPosition3DMode(vec3 position, float height, vec2 textureCoordinates)
  11376. {
  11377. return u_modifiedModelViewProjection * vec4(position, 1.0);
  11378. }
  11379. float get2DMercatorYPositionFraction(vec2 textureCoordinates)
  11380. {
  11381. // The width of a tile at level 11, in radians and assuming a single root tile, is
  11382. // 2.0 * czm_pi / pow(2.0, 11.0)
  11383. // We want to just linearly interpolate the 2D position from the texture coordinates
  11384. // when we're at this level or higher. The constant below is the expression
  11385. // above evaluated and then rounded up at the 4th significant digit.
  11386. const float maxTileWidth = 0.003068;
  11387. float positionFraction = textureCoordinates.y;
  11388. float southLatitude = u_southAndNorthLatitude.x;
  11389. float northLatitude = u_southAndNorthLatitude.y;
  11390. if (northLatitude - southLatitude > maxTileWidth)
  11391. {
  11392. float southMercatorY = u_southMercatorYAndOneOverHeight.x;
  11393. float oneOverMercatorHeight = u_southMercatorYAndOneOverHeight.y;
  11394. float currentLatitude = mix(southLatitude, northLatitude, textureCoordinates.y);
  11395. currentLatitude = clamp(currentLatitude, -czm_webMercatorMaxLatitude, czm_webMercatorMaxLatitude);
  11396. positionFraction = czm_latitudeToWebMercatorFraction(currentLatitude, southMercatorY, oneOverMercatorHeight);
  11397. }
  11398. return positionFraction;
  11399. }
  11400. float get2DGeographicYPositionFraction(vec2 textureCoordinates)
  11401. {
  11402. return textureCoordinates.y;
  11403. }
  11404. vec4 getPositionPlanarEarth(vec3 position, float height, vec2 textureCoordinates)
  11405. {
  11406. float yPositionFraction = get2DYPositionFraction(textureCoordinates);
  11407. vec4 rtcPosition2D = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
  11408. return u_modifiedModelViewProjection * rtcPosition2D;
  11409. }
  11410. vec4 getPosition2DMode(vec3 position, float height, vec2 textureCoordinates)
  11411. {
  11412. return getPositionPlanarEarth(position, 0.0, textureCoordinates);
  11413. }
  11414. vec4 getPositionColumbusViewMode(vec3 position, float height, vec2 textureCoordinates)
  11415. {
  11416. return getPositionPlanarEarth(position, height, textureCoordinates);
  11417. }
  11418. vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinates)
  11419. {
  11420. // We do not do RTC while morphing, so there is potential for jitter.
  11421. // This is unlikely to be noticeable, though.
  11422. vec3 position3DWC = position + u_center3D;
  11423. float yPositionFraction = get2DYPositionFraction(textureCoordinates);
  11424. vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
  11425. vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime);
  11426. vec4 morphPositionEC = czm_modelView * morphPosition;
  11427. return czm_projection * morphPositionEC;
  11428. }
  11429. #ifdef QUANTIZATION_BITS12
  11430. uniform vec2 u_minMaxHeight;
  11431. uniform mat4 u_scaleAndBias;
  11432. #endif
  11433. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
  11434. #ifdef APPLY_MARS3D_FLAT
  11435. uniform bool u_mars_flat_enabled;
  11436. uniform vec4 u_mars_flat_rectangle;
  11437. uniform highp sampler2D u_mars_flat_texture;
  11438. uniform highp float u_mars_inverseTileWidth;
  11439. uniform highp vec2 u_mars_cartographicTileRectangle;
  11440. vec4 getAreaMars3DRange(vec4 rectangle, sampler2D rangeTexture, vec2 textureCoordinates) {
  11441. float lo = textureCoordinates.x / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.x;
  11442. float la = textureCoordinates.y / u_mars_inverseTileWidth + u_mars_cartographicTileRectangle.y;
  11443. float newX = (lo - rectangle.x) / rectangle.z;
  11444. float newY = (la - rectangle.y) / rectangle.w;
  11445. vec4 point;
  11446. if(newX >= 0.0 && newX <= 1.0 && newY >= 0.0 && newY <= 1.0){
  11447. vec4 point = texture(rangeTexture, vec2(newX, newY));
  11448. return point;
  11449. }else{
  11450. return vec4(0.0);
  11451. }
  11452. }
  11453. #endif
  11454. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
  11455. void main()
  11456. {
  11457. #ifdef QUANTIZATION_BITS12
  11458. vec2 xy = czm_decompressTextureCoordinates(compressed0.x);
  11459. vec2 zh = czm_decompressTextureCoordinates(compressed0.y);
  11460. vec3 position = vec3(xy, zh.x);
  11461. float height = zh.y;
  11462. vec2 textureCoordinates = czm_decompressTextureCoordinates(compressed0.z);
  11463. height = height * (u_minMaxHeight.y - u_minMaxHeight.x) + u_minMaxHeight.x;
  11464. position = (u_scaleAndBias * vec4(position, 1.0)).xyz;
  11465. #if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL)) && defined(INCLUDE_WEB_MERCATOR_Y) || defined(APPLY_MATERIAL)
  11466. float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
  11467. float encodedNormal = compressed1;
  11468. #elif defined(INCLUDE_WEB_MERCATOR_Y)
  11469. float webMercatorT = czm_decompressTextureCoordinates(compressed0.w).x;
  11470. float encodedNormal = 0.0;
  11471. #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
  11472. float webMercatorT = textureCoordinates.y;
  11473. float encodedNormal = compressed0.w;
  11474. #else
  11475. float webMercatorT = textureCoordinates.y;
  11476. float encodedNormal = 0.0;
  11477. #endif
  11478. #else
  11479. // A single float per element
  11480. vec3 position = position3DAndHeight.xyz;
  11481. float height = position3DAndHeight.w;
  11482. vec2 textureCoordinates = textureCoordAndEncodedNormals.xy;
  11483. #if (defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)) && defined(INCLUDE_WEB_MERCATOR_Y)
  11484. float webMercatorT = textureCoordAndEncodedNormals.z;
  11485. float encodedNormal = textureCoordAndEncodedNormals.w;
  11486. #elif defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
  11487. float webMercatorT = textureCoordinates.y;
  11488. float encodedNormal = textureCoordAndEncodedNormals.z;
  11489. #elif defined(INCLUDE_WEB_MERCATOR_Y)
  11490. float webMercatorT = textureCoordAndEncodedNormals.z;
  11491. float encodedNormal = 0.0;
  11492. #else
  11493. float webMercatorT = textureCoordinates.y;
  11494. float encodedNormal = 0.0;
  11495. #endif
  11496. #endif
  11497. vec3 position3DWC = position + u_center3D;
  11498. #ifdef GEODETIC_SURFACE_NORMALS
  11499. vec3 ellipsoidNormal = geodeticSurfaceNormal;
  11500. #else
  11501. vec3 ellipsoidNormal = normalize(position3DWC);
  11502. #endif
  11503. #if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)
  11504. float exaggeration = u_verticalExaggerationAndRelativeHeight.x;
  11505. float relativeHeight = u_verticalExaggerationAndRelativeHeight.y;
  11506. float newHeight = (height - relativeHeight) * exaggeration + relativeHeight;
  11507. // stop from going through center of earth
  11508. float minRadius = min(min(czm_ellipsoidRadii.x, czm_ellipsoidRadii.y), czm_ellipsoidRadii.z);
  11509. newHeight = max(newHeight, -minRadius);
  11510. vec3 offset = ellipsoidNormal * (newHeight - height);
  11511. position += offset;
  11512. position3DWC += offset;
  11513. height = newHeight;
  11514. #endif
  11515. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
  11516. #ifdef APPLY_MARS3D_FLAT
  11517. if(u_mars_flat_enabled) {
  11518. vec4 isInside = getAreaMars3DRange(u_mars_flat_rectangle,u_mars_flat_texture,textureCoordinates);
  11519. if(isInside.r>0.0 || isInside.g>0.0 || isInside.b>0.0 || isInside.a>0.0){
  11520. float newHeight = czm_unpackFloat(isInside);
  11521. if(newHeight>-9999.0 && newHeight<9999.0){
  11522. vec3 offset = (newHeight - height) * ellipsoidNormal;
  11523. position += offset;
  11524. position3DWC += offset;
  11525. height = newHeight;
  11526. // vec3 newPosition = (position3DWC + offset) - u_center3D;
  11527. }
  11528. }
  11529. }
  11530. #endif
  11531. // \u3010mars3d.cn\u4FEE\u6539\u3011 Muyao 2023-02-20 \u5730\u5F62\u538B\u5E73
  11532. gl_Position = getPosition(position, height, textureCoordinates);
  11533. v_positionEC = (u_modifiedModelView * vec4(position, 1.0)).xyz;
  11534. v_positionMC = position3DWC; // position in model coordinates
  11535. v_textureCoordinates = vec3(textureCoordinates, webMercatorT);
  11536. #if defined(ENABLE_VERTEX_LIGHTING) || defined(GENERATE_POSITION_AND_NORMAL) || defined(APPLY_MATERIAL)
  11537. vec3 normalMC = czm_octDecode(encodedNormal);
  11538. #if defined(EXAGGERATION) && defined(GEODETIC_SURFACE_NORMALS)
  11539. vec3 projection = dot(normalMC, ellipsoidNormal) * ellipsoidNormal;
  11540. vec3 rejection = normalMC - projection;
  11541. normalMC = normalize(projection + rejection * exaggeration);
  11542. #endif
  11543. v_normalMC = normalMC;
  11544. v_normalEC = czm_normal3D * v_normalMC;
  11545. #endif
  11546. #ifdef ENABLE_CLIPPING_POLYGONS
  11547. vec2 sphericalLatLong = czm_approximateSphericalCoordinates(position3DWC);
  11548. sphericalLatLong.y = czm_branchFreeTernary(sphericalLatLong.y < czm_pi, sphericalLatLong.y, sphericalLatLong.y - czm_twoPi);
  11549. vec2 minDistance = vec2(czm_infinity);
  11550. v_clippingPosition = vec2(czm_infinity);
  11551. v_regionIndex = -1;
  11552. for (int regionIndex = 0; regionIndex < CLIPPING_POLYGON_REGIONS_LENGTH; regionIndex++) {
  11553. vec4 extents = unpackClippingExtents(u_clippingExtents, regionIndex);
  11554. vec2 rectUv = (sphericalLatLong.yx - extents.yx) * extents.wz;
  11555. vec2 clamped = clamp(rectUv, vec2(0.0), vec2(1.0));
  11556. vec2 distance = abs(rectUv - clamped) * extents.wz;
  11557. float threshold = 0.01;
  11558. if (minDistance.x > distance.x || minDistance.y > distance.y) {
  11559. minDistance = distance;
  11560. v_clippingPosition = rectUv;
  11561. if (rectUv.x > threshold && rectUv.y > threshold && rectUv.x < 1.0 - threshold && rectUv.y < 1.0 - threshold) {
  11562. v_regionIndex = regionIndex;
  11563. }
  11564. }
  11565. }
  11566. #endif
  11567. #if defined(FOG) || (defined(GROUND_ATMOSPHERE) && !defined(PER_FRAGMENT_GROUND_ATMOSPHERE))
  11568. bool dynamicLighting = false;
  11569. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))
  11570. dynamicLighting = true;
  11571. #endif
  11572. #if defined(DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN)
  11573. vec3 atmosphereLightDirection = czm_sunDirectionWC;
  11574. #else
  11575. vec3 atmosphereLightDirection = czm_lightDirectionWC;
  11576. #endif
  11577. vec3 lightDirection = czm_branchFreeTernary(dynamicLighting, atmosphereLightDirection, normalize(position3DWC));
  11578. computeAtmosphereScattering(
  11579. position3DWC,
  11580. lightDirection,
  11581. v_atmosphereRayleighColor,
  11582. v_atmosphereMieColor,
  11583. v_atmosphereOpacity
  11584. );
  11585. #endif
  11586. #if defined(FOG) || defined(GROUND_ATMOSPHERE) || defined(UNDERGROUND_COLOR) || defined(TRANSLUCENT)
  11587. v_distance = length((czm_modelView3D * vec4(position3DWC, 1.0)).xyz);
  11588. #endif
  11589. #ifdef APPLY_MATERIAL
  11590. float northPoleZ = czm_ellipsoidRadii.z;
  11591. vec3 northPolePositionMC = vec3(0.0, 0.0, northPoleZ);
  11592. vec3 vectorEastMC = normalize(cross(northPolePositionMC - v_positionMC, ellipsoidNormal));
  11593. float dotProd = abs(dot(ellipsoidNormal, v_normalMC));
  11594. v_slope = acos(dotProd);
  11595. vec3 normalRejected = ellipsoidNormal * dotProd;
  11596. vec3 normalProjected = v_normalMC - normalRejected;
  11597. vec3 aspectVector = normalize(normalProjected);
  11598. v_aspect = acos(dot(aspectVector, vectorEastMC));
  11599. float determ = dot(cross(vectorEastMC, aspectVector), ellipsoidNormal);
  11600. v_aspect = czm_branchFreeTernary(determ < 0.0, 2.0 * czm_pi - v_aspect, v_aspect);
  11601. v_height = height;
  11602. #endif
  11603. }
  11604. `;var kKi=y(x(),1),MZ=`void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
  11605. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
  11606. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
  11607. czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
  11608. float atmosphereInnerRadius = length(positionWC);
  11609. computeScattering(
  11610. primaryRay,
  11611. length(cameraToPositionWC),
  11612. lightDirection,
  11613. atmosphereInnerRadius,
  11614. rayleighColor,
  11615. mieColor,
  11616. opacity
  11617. );
  11618. }
  11619. `;var OKi=y(x(),1),vZ=`float interpolateByDistance(vec4 nearFarScalar, float distance)
  11620. {
  11621. float startDistance = nearFarScalar.x;
  11622. float startValue = nearFarScalar.y;
  11623. float endDistance = nearFarScalar.z;
  11624. float endValue = nearFarScalar.w;
  11625. float t = clamp((distance - startDistance) / (endDistance - startDistance), 0.0, 1.0);
  11626. return mix(startValue, endValue, t);
  11627. }
  11628. void computeAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity, out float underTranslucentGlobe)
  11629. {
  11630. float ellipsoidRadiiDifference = czm_ellipsoidRadii.x - czm_ellipsoidRadii.z;
  11631. // Adjustment to the atmosphere radius applied based on the camera height.
  11632. float distanceAdjustMin = czm_ellipsoidRadii.x / 4.0;
  11633. float distanceAdjustMax = czm_ellipsoidRadii.x;
  11634. float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0;
  11635. float distanceAdjust = distanceAdjustModifier * clamp((czm_eyeHeight - distanceAdjustMin) / (distanceAdjustMax - distanceAdjustMin), 0.0, 1.0);
  11636. // Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
  11637. // for the position on the ellipsoid.
  11638. float radiusAdjust = (ellipsoidRadiiDifference / 4.0) + distanceAdjust;
  11639. float atmosphereInnerRadius = (length(czm_viewerPositionWC) - czm_eyeHeight) - radiusAdjust;
  11640. // Setup the primary ray: from the camera position to the vertex position.
  11641. vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
  11642. vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
  11643. czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
  11644. underTranslucentGlobe = 0.0;
  11645. // Brighten the sky atmosphere under the Earth's atmosphere when translucency is enabled.
  11646. #if defined(GLOBE_TRANSLUCENT)
  11647. // Check for intersection with the inner radius of the atmopshere.
  11648. czm_raySegment primaryRayEarthIntersect = czm_raySphereIntersectionInterval(primaryRay, vec3(0.0), atmosphereInnerRadius + radiusAdjust);
  11649. if (primaryRayEarthIntersect.start > 0.0 && primaryRayEarthIntersect.stop > 0.0) {
  11650. // Compute position on globe.
  11651. vec3 direction = normalize(positionWC);
  11652. czm_ray ellipsoidRay = czm_ray(positionWC, -direction);
  11653. czm_raySegment ellipsoidIntersection = czm_rayEllipsoidIntersectionInterval(ellipsoidRay, vec3(0.0), czm_ellipsoidInverseRadii);
  11654. vec3 onEarth = positionWC - (direction * ellipsoidIntersection.start);
  11655. // Control the color using the camera angle.
  11656. float angle = dot(normalize(czm_viewerPositionWC), normalize(onEarth));
  11657. // Control the opacity using the distance from Earth.
  11658. opacity = interpolateByDistance(vec4(0.0, 1.0, czm_ellipsoidRadii.x, 0.0), length(czm_viewerPositionWC - onEarth));
  11659. vec3 horizonColor = vec3(0.1, 0.2, 0.3);
  11660. vec3 nearColor = vec3(0.0);
  11661. rayleighColor = mix(nearColor, horizonColor, exp(-angle) * opacity);
  11662. // Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.
  11663. underTranslucentGlobe = 1.0;
  11664. return;
  11665. }
  11666. #endif
  11667. computeScattering(
  11668. primaryRay,
  11669. length(cameraToPositionWC),
  11670. lightDirection,
  11671. atmosphereInnerRadius,
  11672. rayleighColor,
  11673. mieColor,
  11674. opacity
  11675. );
  11676. // Alter the opacity based on how close the viewer is to the ground.
  11677. // (0.0 = At edge of atmosphere, 1.0 = On ground)
  11678. float cameraHeight = czm_eyeHeight + atmosphereInnerRadius;
  11679. float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE_THICKNESS;
  11680. opacity = clamp((atmosphereOuterRadius - cameraHeight) / (atmosphereOuterRadius - atmosphereInnerRadius), 0.0, 1.0);
  11681. // Alter alpha based on time of day (0.0 = night , 1.0 = day)
  11682. float nightAlpha = (u_radiiAndDynamicAtmosphereColor.z != 0.0) ? clamp(dot(normalize(positionWC), lightDirection), 0.0, 1.0) : 1.0;
  11683. opacity *= pow(nightAlpha, 0.5);
  11684. }
  11685. `;var HKi=y(x(),1),tY=`in vec3 v_outerPositionWC;
  11686. uniform vec3 u_hsbShift;
  11687. #ifndef PER_FRAGMENT_ATMOSPHERE
  11688. in vec3 v_mieColor;
  11689. in vec3 v_rayleighColor;
  11690. in float v_opacity;
  11691. in float v_translucent;
  11692. #endif
  11693. void main (void)
  11694. {
  11695. float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
  11696. vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_outerPositionWC, lightEnum);
  11697. vec3 mieColor;
  11698. vec3 rayleighColor;
  11699. float opacity;
  11700. float translucent;
  11701. #ifdef PER_FRAGMENT_ATMOSPHERE
  11702. computeAtmosphereScattering(
  11703. v_outerPositionWC,
  11704. lightDirection,
  11705. rayleighColor,
  11706. mieColor,
  11707. opacity,
  11708. translucent
  11709. );
  11710. #else
  11711. mieColor = v_mieColor;
  11712. rayleighColor = v_rayleighColor;
  11713. opacity = v_opacity;
  11714. translucent = v_translucent;
  11715. #endif
  11716. vec4 color = computeAtmosphereColor(v_outerPositionWC, lightDirection, rayleighColor, mieColor, opacity);
  11717. #ifndef HDR
  11718. color.rgb = czm_pbrNeutralTonemapping(color.rgb);
  11719. color.rgb = czm_inverseGamma(color.rgb);
  11720. #endif
  11721. #ifdef COLOR_CORRECT
  11722. const bool ignoreBlackPixels = true;
  11723. color.rgb = czm_applyHSBShift(color.rgb, u_hsbShift, ignoreBlackPixels);
  11724. #endif
  11725. // For the parts of the sky atmosphere that are not behind a translucent globe,
  11726. // we mix in the default opacity so that the sky atmosphere still appears at distance.
  11727. // This is needed because the opacity in the sky atmosphere is initially adjusted based
  11728. // on the camera height.
  11729. if (translucent == 0.0) {
  11730. color.a = mix(color.b, 1.0, color.a) * smoothstep(0.0, 1.0, czm_morphTime);
  11731. }
  11732. out_FragColor = color;
  11733. }
  11734. `;var KKi=y(x(),1),nY=`in vec4 position;
  11735. out vec3 v_outerPositionWC;
  11736. #ifndef PER_FRAGMENT_ATMOSPHERE
  11737. out vec3 v_mieColor;
  11738. out vec3 v_rayleighColor;
  11739. out float v_opacity;
  11740. out float v_translucent;
  11741. #endif
  11742. void main(void)
  11743. {
  11744. vec4 positionWC = czm_model * position;
  11745. float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
  11746. vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(positionWC.xyz, lightEnum);
  11747. #ifndef PER_FRAGMENT_ATMOSPHERE
  11748. computeAtmosphereScattering(
  11749. positionWC.xyz,
  11750. lightDirection,
  11751. v_rayleighColor,
  11752. v_mieColor,
  11753. v_opacity,
  11754. v_translucent
  11755. );
  11756. #endif
  11757. v_outerPositionWC = positionWC.xyz;
  11758. vec4 positionEC = czm_modelView * position;
  11759. gl_Position = czm_projection * positionEC;
  11760. }
  11761. `;var qKi=y(x(),1),iY=`uniform samplerCube u_cubeMap;
  11762. in vec3 v_texCoord;
  11763. void main()
  11764. {
  11765. vec4 color = czm_textureCube(u_cubeMap, normalize(v_texCoord));
  11766. out_FragColor = vec4(czm_gammaCorrect(color).rgb, czm_morphTime);
  11767. }
  11768. `;var eji=y(x(),1),oY=`in vec3 position;
  11769. out vec3 v_texCoord;
  11770. void main()
  11771. {
  11772. vec3 p = czm_viewRotation * (czm_temeToPseudoFixed * (czm_entireFrustum.y * position));
  11773. gl_Position = czm_projection * vec4(p, 1.0);
  11774. v_texCoord = position.xyz;
  11775. }
  11776. `;var nji=y(x(),1),rY=`uniform sampler2D u_texture;
  11777. in vec2 v_textureCoordinates;
  11778. void main()
  11779. {
  11780. vec4 color = texture(u_texture, v_textureCoordinates);
  11781. out_FragColor = czm_gammaCorrect(color);
  11782. }
  11783. `;var oji=y(x(),1),sY=`uniform float u_radiusTS;
  11784. in vec2 v_textureCoordinates;
  11785. vec2 rotate(vec2 p, vec2 direction)
  11786. {
  11787. return vec2(p.x * direction.x - p.y * direction.y, p.x * direction.y + p.y * direction.x);
  11788. }
  11789. vec4 addBurst(vec2 position, vec2 direction, float lengthScalar)
  11790. {
  11791. vec2 rotatedPosition = rotate(position, direction) * vec2(25.0, 0.75);
  11792. float radius = length(rotatedPosition) * lengthScalar;
  11793. float burst = 1.0 - smoothstep(0.0, 0.55, radius);
  11794. return vec4(burst);
  11795. }
  11796. void main()
  11797. {
  11798. float lengthScalar = 2.0 / sqrt(2.0);
  11799. vec2 position = v_textureCoordinates - vec2(0.5);
  11800. float radius = length(position) * lengthScalar;
  11801. float surface = step(radius, u_radiusTS);
  11802. vec4 color = vec4(vec2(1.0), surface + 0.2, surface);
  11803. float glow = 1.0 - smoothstep(0.0, 0.55, radius);
  11804. color.ba += mix(vec2(0.0), vec2(1.0), glow) * 0.75;
  11805. vec4 burst = vec4(0.0);
  11806. // The following loop has been manually unrolled for speed, to
  11807. // avoid sin() and cos().
  11808. //
  11809. //for (float i = 0.4; i < 3.2; i += 1.047) {
  11810. // vec2 direction = vec2(sin(i), cos(i));
  11811. // burst += 0.4 * addBurst(position, direction, lengthScalar);
  11812. //
  11813. // direction = vec2(sin(i - 0.08), cos(i - 0.08));
  11814. // burst += 0.3 * addBurst(position, direction, lengthScalar);
  11815. //}
  11816. burst += 0.4 * addBurst(position, vec2(0.38942, 0.92106), lengthScalar); // angle == 0.4
  11817. burst += 0.4 * addBurst(position, vec2(0.99235, 0.12348), lengthScalar); // angle == 0.4 + 1.047
  11818. burst += 0.4 * addBurst(position, vec2(0.60327, -0.79754), lengthScalar); // angle == 0.4 + 1.047 * 2.0
  11819. burst += 0.3 * addBurst(position, vec2(0.31457, 0.94924), lengthScalar); // angle == 0.4 - 0.08
  11820. burst += 0.3 * addBurst(position, vec2(0.97931, 0.20239), lengthScalar); // angle == 0.4 + 1.047 - 0.08
  11821. burst += 0.3 * addBurst(position, vec2(0.66507, -0.74678), lengthScalar); // angle == 0.4 + 1.047 * 2.0 - 0.08
  11822. // End of manual loop unrolling.
  11823. color += clamp(burst, vec4(0.0), vec4(1.0)) * 0.15;
  11824. out_FragColor = clamp(color, vec4(0.0), vec4(1.0));
  11825. }
  11826. `;var sji=y(x(),1),aY=`in vec2 direction;
  11827. uniform float u_size;
  11828. out vec2 v_textureCoordinates;
  11829. void main()
  11830. {
  11831. vec4 position;
  11832. if (czm_morphTime == 1.0)
  11833. {
  11834. position = vec4(czm_sunPositionWC, 1.0);
  11835. }
  11836. else
  11837. {
  11838. position = vec4(czm_sunPositionColumbusView.zxy, 1.0);
  11839. }
  11840. vec4 positionEC = czm_view * position;
  11841. vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
  11842. vec2 halfSize = vec2(u_size * 0.5);
  11843. halfSize *= ((direction * 2.0) - 1.0);
  11844. gl_Position = czm_viewportOrthographic * vec4(positionWC.xy + halfSize, -positionWC.z, 1.0);
  11845. v_textureCoordinates = direction;
  11846. }
  11847. `;var cji=y(x(),1),cY=`
  11848. in vec2 v_textureCoordinates;
  11849. void main()
  11850. {
  11851. czm_materialInput materialInput;
  11852. materialInput.s = v_textureCoordinates.s;
  11853. materialInput.st = v_textureCoordinates;
  11854. materialInput.str = vec3(v_textureCoordinates, 0.0);
  11855. materialInput.normalEC = vec3(0.0, 0.0, -1.0);
  11856. czm_material material = czm_getMaterial(materialInput);
  11857. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  11858. }
  11859. `;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+=`
  11860. `,c+=n?b0t(i):y0t(i),c}function b0t(e){return`float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix)
  11861. {
  11862. vec4 position = czm_windowToEyeCoordinates(fragCoord);
  11863. vec3 clipNormal = vec3(0.0);
  11864. vec3 clipPosition = vec3(0.0);
  11865. float clipAmount;
  11866. float pixelWidth = czm_metersPerPixel(position);
  11867. bool breakAndDiscard = false;
  11868. for (int i = 0; i < ${e}; ++i)
  11869. {
  11870. vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
  11871. clipNormal = clippingPlane.xyz;
  11872. clipPosition = -clippingPlane.w * clipNormal;
  11873. float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
  11874. clipAmount = czm_branchFreeTernary(i == 0, amount, min(amount, clipAmount));
  11875. if (amount <= 0.0)
  11876. {
  11877. breakAndDiscard = true;
  11878. // HLSL compiler bug if we discard here: https://bugs.chromium.org/p/angleproject/issues/detail?id=1945#c6
  11879. break;
  11880. }
  11881. }
  11882. if (breakAndDiscard) {
  11883. discard;
  11884. }
  11885. return clipAmount;
  11886. }
  11887. `}function y0t(e){return`float clip(vec4 fragCoord, sampler2D clippingPlanes, mat4 clippingPlanesMatrix)
  11888. {
  11889. bool clipped = true;
  11890. vec4 position = czm_windowToEyeCoordinates(fragCoord);
  11891. vec3 clipNormal = vec3(0.0);
  11892. vec3 clipPosition = vec3(0.0);
  11893. float clipAmount = 0.0;
  11894. float pixelWidth = czm_metersPerPixel(position);
  11895. for (int i = 0; i < ${e}; ++i)
  11896. {
  11897. vec4 clippingPlane = getClippingPlane(clippingPlanes, i, clippingPlanesMatrix);
  11898. clipNormal = clippingPlane.xyz;
  11899. clipPosition = -clippingPlane.w * clipNormal;
  11900. float amount = dot(clipNormal, (position.xyz - clipPosition)) / pixelWidth;
  11901. clipAmount = max(amount, clipAmount);
  11902. clipped = clipped && (amount <= 0.0);
  11903. }
  11904. if (clipped)
  11905. {
  11906. discard;
  11907. }
  11908. return clipAmount;
  11909. }
  11910. `}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)
  11911. {
  11912. int pixY = clippingPlaneNumber / ${e};
  11913. int pixX = clippingPlaneNumber - (pixY * ${e});
  11914. // Sample from center of pixel
  11915. float u = (float(pixX) + 0.5) * ${o};
  11916. float v = (float(pixY) + 0.5) * ${r};
  11917. vec4 plane = texture(packedClippingPlanes, vec2(u, v));
  11918. return czm_transformPlane(plane, transform);
  11919. }
  11920. `}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)
  11921. {
  11922. int clippingPlaneStartIndex = clippingPlaneNumber * 2;
  11923. int pixY = clippingPlaneStartIndex / ${e};
  11924. int pixX = clippingPlaneStartIndex - (pixY * ${e});
  11925. // Sample from center of pixel
  11926. float u = (float(pixX) + 0.5) * ${o};
  11927. float v = (float(pixY) + 0.5) * ${r};
  11928. vec4 oct32 = texture(packedClippingPlanes, vec2(u, v)) * 255.0;
  11929. vec2 oct = vec2(oct32.x * 256.0 + oct32.y, oct32.z * 256.0 + oct32.w);
  11930. vec4 plane;
  11931. plane.xyz = czm_octDecode(oct, 65535.0);
  11932. plane.w = czm_unpackFloat(texture(packedClippingPlanes, vec2(u + ${o}, v)));
  11933. return czm_transformPlane(plane, transform);
  11934. }
  11935. `}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) {
  11936. czm_clipPolygons(clippingDistance, regionsLength, clippingPosition, regionIndex);
  11937. }`:`void clipPolygons(highp sampler2D clippingDistance, int regionsLength, vec2 clippingPosition, int regionIndex) {
  11938. }`}function _0t(e){return e.webgl2?`vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
  11939. return czm_unpackClippingExtents(extentsTexture, index);
  11940. }`:`vec4 unpackClippingExtents(highp sampler2D extentsTexture, int index) {
  11941. return vec4();
  11942. }`}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
  11943. {
  11944. vec4 color = initialColor;
  11945. `;_&&(xt+=` vec4 cutoutAndColorResult;
  11946. bool texelUnclipped;
  11947. `);for(let Je=0;Je<i;++Je)_?xt+=` cutoutAndColorResult = u_dayTextureCutoutRectangles[${Je}];
  11948. texelUnclipped = v_textureCoordinates.x < cutoutAndColorResult.x || cutoutAndColorResult.z < v_textureCoordinates.x || v_textureCoordinates.y < cutoutAndColorResult.y || cutoutAndColorResult.w < v_textureCoordinates.y;
  11949. cutoutAndColorResult = sampleAndBlend(
  11950. `:xt+=` color = sampleAndBlend(
  11951. `,xt+=` color,
  11952. u_dayTextures[${Je}],
  11953. u_dayTextureUseWebMercatorT[${Je}] ? textureCoordinates.xz : textureCoordinates.xy,
  11954. u_dayTextureTexCoordsRectangle[${Je}],
  11955. u_dayTextureTranslationAndScale[${Je}],
  11956. ${d?`u_dayTextureAlpha[${Je}]`:"1.0"},
  11957. ${u?`u_dayTextureNightAlpha[${Je}]`:"1.0"},
  11958. ${u?`u_dayTextureDayAlpha[${Je}]`:"1.0"},
  11959. ${o?`u_dayTextureBrightness[${Je}]`:"0.0"},
  11960. ${r?`u_dayTextureContrast[${Je}]`:"0.0"},
  11961. ${s?`u_dayTextureHue[${Je}]`:"0.0"},
  11962. ${a?`u_dayTextureSaturation[${Je}]`:"0.0"},
  11963. ${c?`u_dayTextureOneOverGamma[${Je}]`:"0.0"},
  11964. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  11965. ${Y.invertColor?`u_mars3dTextureInvertColor[${Je}]`:"false"},
  11966. ${Y.filterColor?`u_mars3dTextureFilterColor[${Je}]`:"vec3(1.0)"},
  11967. //\u3010mars3d.cn\u4FEE\u6539\u3011 Hao 2022-1-5 \u74E6\u7247\u6EE4\u955C\u6548\u679C
  11968. ${h?`u_dayTextureSplit[${Je}]`:"0.0"},
  11969. ${w?`u_colorsToAlpha[${Je}]`:"vec4(0.0)"},
  11970. nightBlend);
  11971. `,_&&(xt+=` color = czm_branchFreeTernary(texelUnclipped, cutoutAndColorResult, color);
  11972. `);xt+=` return color;
  11973. }`,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
  11974. .cesium-credit-lightbox-overlay {
  11975. display: none;
  11976. z-index: 1;
  11977. position: absolute;
  11978. top: 0;
  11979. left: 0;
  11980. width: 100%;
  11981. height: 100%;
  11982. background-color: rgba(80, 80, 80, 0.8);
  11983. }
  11984. .cesium-credit-lightbox {
  11985. background-color: #303336;
  11986. color: ${GY};
  11987. position: relative;
  11988. min-height: ${QCt}px;
  11989. margin: auto;
  11990. }
  11991. .cesium-credit-lightbox > ul > li a,
  11992. .cesium-credit-lightbox > ul > li a:visited,
  11993. .cesium-credit-wrapper a,
  11994. .cesium-credit-wrapper a:visited {
  11995. color: ${GY};
  11996. }
  11997. .cesium-credit-lightbox > ul > li a:hover {
  11998. color: ${VO};
  11999. }
  12000. .cesium-credit-lightbox.cesium-credit-lightbox-expanded {
  12001. border: 1px solid #444;
  12002. border-radius: 5px;
  12003. max-width: 470px;
  12004. }
  12005. .cesium-credit-lightbox.cesium-credit-lightbox-mobile {
  12006. height: 100%;
  12007. width: 100%;
  12008. }
  12009. .cesium-credit-lightbox-title {
  12010. padding: 20px 20px 0 20px;
  12011. }
  12012. .cesium-credit-lightbox-close {
  12013. font-size: 18pt;
  12014. cursor: pointer;
  12015. position: absolute;
  12016. top: 0;
  12017. right: 6px;
  12018. color: ${GY};
  12019. }
  12020. .cesium-credit-lightbox-close:hover {
  12021. color: ${VO};
  12022. }
  12023. .cesium-credit-lightbox > ul {
  12024. margin: 0;
  12025. padding: 12px 20px 12px 40px;
  12026. font-size: 13px;
  12027. }
  12028. .cesium-credit-lightbox > ul > li {
  12029. padding-bottom: 6px;
  12030. }
  12031. .cesium-credit-lightbox > ul > li * {
  12032. padding: 0;
  12033. margin: 0;
  12034. }
  12035. .cesium-credit-expand-link {
  12036. padding-left: 5px;
  12037. cursor: pointer;
  12038. text-decoration: underline;
  12039. color: ${GY};
  12040. }
  12041. .cesium-credit-expand-link:hover {
  12042. color: ${VO};
  12043. }
  12044. .cesium-credit-text {
  12045. color: ${GY};
  12046. }
  12047. .cesium-credit-delimiter {
  12048. padding: 0 5px;
  12049. }
  12050. .cesium-credit-textContainer *,
  12051. .cesium-credit-logoContainer * {
  12052. display: inline;
  12053. }
  12054. .cesium-credit-textContainer a:hover {
  12055. color: ${VO}
  12056. }
  12057. .cesium-credit-textContainer .cesium-credit-wrapper:first-of-type {
  12058. padding-left: 5px;
  12059. }
  12060. `;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="&times;",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
  12061. {
  12062. out_FragColor = vec4(1.0);
  12063. }
  12064. `;i=new ze({sources:[a]})}else if(!o&&s){let a=`void main()
  12065. {
  12066. out_FragColor = vec4(1.0);
  12067. czm_writeLogDepth();
  12068. }
  12069. `;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(`
  12070. void main()
  12071. {
  12072. czm_log_depth_main();
  12073. czm_vertexLogDepth();
  12074. }
  12075. `)}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=`
  12076. void main()
  12077. {
  12078. czm_log_depth_main();
  12079. czm_writeLogDepth();
  12080. }
  12081. `}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 ()
  12082. {
  12083. czm_non_pick_main();
  12084. if (${c}.a == 0.0) {
  12085. discard;
  12086. }
  12087. ${c} = ${n};
  12088. } `,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
  12089. {
  12090. out_FragColor = vec4(1.0);
  12091. }
  12092. `;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(`
  12093. uniform sampler2D u_classificationTexture;
  12094. void main()
  12095. {
  12096. vec2 st = gl_FragCoord.xy / czm_viewport.zw;
  12097. #ifdef MANUAL_DEPTH_TEST
  12098. float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, st));
  12099. if (logDepthOrDepth != 0.0)
  12100. {
  12101. vec4 eyeCoordinate = czm_windowToEyeCoordinates(gl_FragCoord.xy, logDepthOrDepth);
  12102. float depthEC = eyeCoordinate.z / eyeCoordinate.w;
  12103. if (v_positionEC.z < depthEC)
  12104. {
  12105. discard;
  12106. }
  12107. }
  12108. #endif
  12109. czm_globe_translucency_main();
  12110. vec4 classificationColor = texture(u_classificationTexture, st);
  12111. if (classificationColor.a > 0.0)
  12112. {
  12113. // Reverse premultiplication process to get the correct composited result of the classification primitives
  12114. classificationColor.rgb /= classificationColor.a;
  12115. }
  12116. out_FragColor = classificationColor * vec4(classificationColor.aaa, 1.0) + out_FragColor * (1.0 - classificationColor.a);
  12117. }
  12118. `)}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;
  12119. void main()
  12120. {
  12121. vec2 st = gl_FragCoord.xy / czm_viewport.zw;
  12122. vec4 pickColor = texture(u_classificationTexture, st);
  12123. if (pickColor == vec4(0.0))
  12124. {
  12125. discard;
  12126. }
  12127. out_FragColor = pickColor;
  12128. }
  12129. `;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
  12130. in vec2 v_textureCoordinates;
  12131. void main()
  12132. {
  12133. out_FragColor = texture(colorTexture, v_textureCoordinates);
  12134. }
  12135. `;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;
  12136. uniform sampler2D depthTexture;
  12137. uniform sampler2D classifiedTexture;
  12138. in vec2 v_textureCoordinates;
  12139. void main()
  12140. {
  12141. vec4 color = texture(colorTexture, v_textureCoordinates);
  12142. if (color.a == 0.0)
  12143. {
  12144. discard;
  12145. }
  12146. bool isClassified = all(equal(texture(classifiedTexture, v_textureCoordinates), vec4(0.0)));
  12147. #ifdef UNCLASSIFIED
  12148. vec4 highlightColor = czm_invertClassificationColor;
  12149. if (isClassified)
  12150. {
  12151. discard;
  12152. }
  12153. #else
  12154. vec4 highlightColor = vec4(1.0);
  12155. if (!isClassified)
  12156. {
  12157. discard;
  12158. }
  12159. #endif
  12160. out_FragColor = color * highlightColor;
  12161. gl_FragDepth = texture(depthTexture, v_textureCoordinates).r;
  12162. }
  12163. `,qTt=`uniform sampler2D colorTexture;
  12164. in vec2 v_textureCoordinates;
  12165. void main()
  12166. {
  12167. vec4 color = texture(colorTexture, v_textureCoordinates);
  12168. if (color.a == 0.0)
  12169. {
  12170. discard;
  12171. }
  12172. #ifdef UNCLASSIFIED
  12173. out_FragColor = color * czm_invertClassificationColor;
  12174. #else
  12175. out_FragColor = color;
  12176. #endif
  12177. }
  12178. `;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
  12179. in vec2 v_textureCoordinates;
  12180. void main()
  12181. {
  12182. vec4 globeDepthPacked = texture(czm_globeDepthTexture, v_textureCoordinates);
  12183. float globeDepth = czm_unpackDepth(globeDepthPacked);
  12184. float depth = texture(colorTexture, v_textureCoordinates).r;
  12185. out_FragColor = czm_branchFreeTernary(globeDepth <= 0.0 || globeDepth >= 1.0 || depth < globeDepth && depth > 0.0 && depth < 1.0,
  12186. czm_packDepth(depth), globeDepthPacked);
  12187. }
  12188. `,{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;
  12189. in vec2 v_textureCoordinates;
  12190. void main()
  12191. {
  12192. out_FragColor = czm_packDepth(texture(u_depthTexture, v_textureCoordinates).r);
  12193. }
  12194. `;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
  12195. float ai = czm_out_FragColor.a;
  12196. float wzi = czm_alphaWeight(ai);
  12197. out_FragData_0 = vec4(Ci * wzi, ai);
  12198. out_FragData_1 = vec4(ai * wzi);
  12199. `,AEt=` vec3 Ci = czm_out_FragColor.rgb * czm_out_FragColor.a;
  12200. float ai = czm_out_FragColor.a;
  12201. float wzi = czm_alphaWeight(ai);
  12202. out_FragColor = vec4(Ci, ai) * wzi;
  12203. `,gEt=` float ai = czm_out_FragColor.a;
  12204. out_FragColor = vec4(ai);
  12205. `;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_OUTPUT
  12206. vec4 czm_out_FragColor;
  12207. bool czm_discard = false;
  12208. `);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]};
  12209. ${d}`}return a.sources.push(d),a.sources.push(`void main()
  12210. {
  12211. czm_translucent_main();
  12212. if (czm_discard)
  12213. {
  12214. discard;
  12215. }
  12216. ${i}}
  12217. `),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
  12218. void main()
  12219. {
  12220. czm_shadow_cast_main();
  12221. v_positionEC = (czm_inverseProjection * gl_Position).xyz;
  12222. }`)}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;
  12223. `),d+=`uniform vec4 shadowMap_lightPositionEC;
  12224. `),i?d+=`void main()
  12225. {
  12226. `:d+=`void main()
  12227. {
  12228. czm_shadow_cast_main();
  12229. if (out_FragColor.a == 0.0)
  12230. {
  12231. discard;
  12232. }
  12233. `,t?d+=` float distance = length(${s});
  12234. if (distance >= shadowMap_lightPositionEC.w)
  12235. {
  12236. discard;
  12237. }
  12238. distance /= shadowMap_lightPositionEC.w; // radius
  12239. out_FragColor = czm_packDepth(distance);
  12240. `:n?d+=` out_FragColor = vec4(1.0);
  12241. `:d+=` out_FragColor = czm_packDepth(gl_FragCoord.z);
  12242. `,d+=`}
  12243. `,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;
  12244. `:I+=`uniform sampler2D shadowMap_texture;
  12245. `;let R;return c?R=` return vec4(${a}, 1.0);
  12246. `:R=`#ifndef LOG_DEPTH
  12247. return czm_windowToEyeCoordinates(gl_FragCoord);
  12248. #else
  12249. return vec4(v_logPositionEC, 1.0);
  12250. #endif
  12251. `,I+=`uniform mat4 shadowMap_matrix;
  12252. uniform vec3 shadowMap_lightDirectionEC;
  12253. uniform vec4 shadowMap_lightPositionEC;
  12254. uniform vec4 shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness;
  12255. uniform vec4 shadowMap_texelSizeDepthBiasAndNormalShadingSmooth;
  12256. #ifdef LOG_DEPTH
  12257. in vec3 v_logPositionEC;
  12258. #endif
  12259. vec4 getPositionEC()
  12260. {
  12261. ${R}}
  12262. vec3 getNormalEC()
  12263. {
  12264. ${s?` return normalize(${r});
  12265. `:` return vec3(1.0);
  12266. `}}
  12267. void applyNormalOffset(inout vec4 positionEC, vec3 normalEC, float nDotL)
  12268. {
  12269. ${C.normalOffset&&s?` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
  12270. float normalOffsetScale = 1.0 - nDotL;
  12271. vec3 offset = normalOffset * normalOffsetScale * normalEC;
  12272. positionEC.xyz += offset;
  12273. `:""}}
  12274. `,I+=`void main()
  12275. {
  12276. czm_shadow_receive_main();
  12277. vec4 positionEC = getPositionEC();
  12278. vec3 normalEC = getNormalEC();
  12279. float depth = -positionEC.z;
  12280. `,I+=` czm_shadowParameters shadowParameters;
  12281. shadowParameters.texelStepSize = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.xy;
  12282. shadowParameters.depthBias = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.z;
  12283. shadowParameters.normalShadingSmooth = shadowMap_texelSizeDepthBiasAndNormalShadingSmooth.w;
  12284. shadowParameters.darkness = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.w;
  12285. `,i?I+=` shadowParameters.depthBias *= max(depth * 0.01, 1.0);
  12286. `:u||(I+=` shadowParameters.depthBias *= mix(1.0, 100.0, depth * 0.0015);
  12287. `),h?I+=` vec3 directionEC = positionEC.xyz - shadowMap_lightPositionEC.xyz;
  12288. float distance = length(directionEC);
  12289. directionEC = normalize(directionEC);
  12290. float radius = shadowMap_lightPositionEC.w;
  12291. // Stop early if the fragment is beyond the point light radius
  12292. if (distance > radius)
  12293. {
  12294. return;
  12295. }
  12296. vec3 directionWC = czm_inverseViewRotation * directionEC;
  12297. shadowParameters.depth = distance / radius;
  12298. shadowParameters.nDotL = clamp(dot(normalEC, -directionEC), 0.0, 1.0);
  12299. shadowParameters.texCoords = directionWC;
  12300. float visibility = czm_shadowVisibility(shadowMap_textureCube, shadowParameters);
  12301. `:p?I+=` vec3 directionEC = normalize(positionEC.xyz - shadowMap_lightPositionEC.xyz);
  12302. float nDotL = clamp(dot(normalEC, -directionEC), 0.0, 1.0);
  12303. applyNormalOffset(positionEC, normalEC, nDotL);
  12304. vec4 shadowPosition = shadowMap_matrix * positionEC;
  12305. // Spot light uses a perspective projection, so perform the perspective divide
  12306. shadowPosition /= shadowPosition.w;
  12307. // Stop early if the fragment is not in the shadow bounds
  12308. if (any(lessThan(shadowPosition.xyz, vec3(0.0))) || any(greaterThan(shadowPosition.xyz, vec3(1.0))))
  12309. {
  12310. return;
  12311. }
  12312. shadowParameters.texCoords = shadowPosition.xy;
  12313. shadowParameters.depth = shadowPosition.z;
  12314. shadowParameters.nDotL = nDotL;
  12315. float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
  12316. `:A?I+=` float maxDepth = shadowMap_cascadeSplits[1].w;
  12317. // Stop early if the eye depth exceeds the last cascade
  12318. if (depth > maxDepth)
  12319. {
  12320. return;
  12321. }
  12322. // Get the cascade based on the eye-space depth
  12323. vec4 weights = czm_cascadeWeights(depth);
  12324. // Apply normal offset
  12325. float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
  12326. applyNormalOffset(positionEC, normalEC, nDotL);
  12327. // Transform position into the cascade
  12328. vec4 shadowPosition = czm_cascadeMatrix(weights) * positionEC;
  12329. // Get visibility
  12330. shadowParameters.texCoords = shadowPosition.xy;
  12331. shadowParameters.depth = shadowPosition.z;
  12332. shadowParameters.nDotL = nDotL;
  12333. float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
  12334. // Fade out shadows that are far away
  12335. float shadowMapMaximumDistance = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.z;
  12336. float fade = max((depth - shadowMapMaximumDistance * 0.8) / (shadowMapMaximumDistance * 0.2), 0.0);
  12337. visibility = mix(visibility, 1.0, fade);
  12338. ${f?` // Draw cascade colors for debugging
  12339. out_FragColor *= czm_cascadeColor(weights);
  12340. `:""}`:I+=` float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
  12341. applyNormalOffset(positionEC, normalEC, nDotL);
  12342. vec4 shadowPosition = shadowMap_matrix * positionEC;
  12343. // Stop early if the fragment is not in the shadow bounds
  12344. if (any(lessThan(shadowPosition.xyz, vec3(0.0))) || any(greaterThan(shadowPosition.xyz, vec3(1.0))))
  12345. {
  12346. return;
  12347. }
  12348. shadowParameters.texCoords = shadowPosition.xy;
  12349. shadowParameters.depth = shadowPosition.z;
  12350. shadowParameters.nDotL = nDotL;
  12351. float visibility = czm_shadowVisibility(shadowMap_texture, shadowParameters);
  12352. `,I+=` out_FragColor.rgb *= visibility;
  12353. }
  12354. `,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(
  12355. in vec2 v_textureCoordinates;
  12356. void main()
  12357. {
  12358. vec2 uv = v_textureCoordinates;
  12359. vec3 dir;
  12360. if (uv.y < 0.5)
  12361. {
  12362. if (uv.x < 0.333)
  12363. {
  12364. dir.x = -1.0;
  12365. dir.y = uv.x * 6.0 - 1.0;
  12366. dir.z = uv.y * 4.0 - 1.0;
  12367. }
  12368. else if (uv.x < 0.666)
  12369. {
  12370. dir.y = -1.0;
  12371. dir.x = uv.x * 6.0 - 3.0;
  12372. dir.z = uv.y * 4.0 - 1.0;
  12373. }
  12374. else
  12375. {
  12376. dir.z = -1.0;
  12377. dir.x = uv.x * 6.0 - 5.0;
  12378. dir.y = uv.y * 4.0 - 1.0;
  12379. }
  12380. }
  12381. else
  12382. {
  12383. if (uv.x < 0.333)
  12384. {
  12385. dir.x = 1.0;
  12386. dir.y = uv.x * 6.0 - 1.0;
  12387. dir.z = uv.y * 4.0 - 3.0;
  12388. }
  12389. else if (uv.x < 0.666)
  12390. {
  12391. dir.y = 1.0;
  12392. dir.x = uv.x * 6.0 - 3.0;
  12393. dir.z = uv.y * 4.0 - 3.0;
  12394. }
  12395. else
  12396. {
  12397. dir.z = 1.0;
  12398. dir.x = uv.x * 6.0 - 5.0;
  12399. dir.y = uv.y * 4.0 - 3.0;
  12400. }
  12401. }
  12402. float shadow = czm_unpackDepth(czm_textureCube(shadowMap_textureCube, dir));
  12403. out_FragColor = vec4(vec3(shadow), 1.0);
  12404. }
  12405. `:n=`uniform sampler2D shadowMap_texture;
  12406. in vec2 v_textureCoordinates;
  12407. void main()
  12408. {
  12409. ${e._usesDepthTexture?` float shadow = texture(shadowMap_texture, v_textureCoordinates).r;
  12410. `:` float shadow = czm_unpackDepth(texture(shadowMap_texture, v_textureCoordinates));
  12411. `} out_FragColor = vec4(vec3(shadow), 1.0);
  12412. }
  12413. `;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(
  12414. #ifdef DEBUG_SHOW_DEPTH
  12415. uniform sampler2D u_packedTranslucentDepth;
  12416. #endif
  12417. in vec2 v_textureCoordinates;
  12418. void main()
  12419. {
  12420. #ifdef DEBUG_SHOW_DEPTH
  12421. if (v_textureCoordinates.x < 0.5)
  12422. {
  12423. out_FragColor.rgb = vec3(czm_unpackDepth(texture(u_packedTranslucentDepth, v_textureCoordinates)));
  12424. out_FragColor.a = 1.0;
  12425. }
  12426. #else
  12427. vec4 color = texture(colorTexture, v_textureCoordinates);
  12428. #ifdef PICK
  12429. if (color == vec4(0.0))
  12430. {
  12431. discard;
  12432. }
  12433. #else
  12434. // Reverse premultiplication process to get the correct composited result of the classification primitives
  12435. color.rgb /= color.a;
  12436. #endif
  12437. out_FragColor = color;
  12438. #endif
  12439. }
  12440. `;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
  12441. in vec2 v_textureCoordinates;
  12442. #ifdef AUTO_EXPOSURE
  12443. uniform sampler2D autoExposure;
  12444. #else
  12445. uniform float exposure;
  12446. #endif
  12447. void main()
  12448. {
  12449. vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
  12450. vec3 color = fragmentColor.rgb;
  12451. #ifdef AUTO_EXPOSURE
  12452. color /= texture(autoExposure, vec2(0.5)).r;
  12453. #else
  12454. color *= vec3(exposure);
  12455. #endif
  12456. color = czm_acesTonemapping(color);
  12457. color = czm_inverseGamma(color);
  12458. out_FragColor = vec4(color, fragmentColor.a);
  12459. }
  12460. `;var sro=y(x(),1),nM=`precision highp float;
  12461. uniform sampler2D randomTexture;
  12462. uniform sampler2D depthTexture;
  12463. uniform float intensity;
  12464. uniform float bias;
  12465. uniform float lengthCap;
  12466. uniform int stepCount;
  12467. uniform int directionCount;
  12468. vec4 pixelToEye(vec2 screenCoordinate)
  12469. {
  12470. vec2 uv = screenCoordinate / czm_viewport.zw;
  12471. float depth = czm_readDepth(depthTexture, uv);
  12472. vec2 xy = 2.0 * uv - vec2(1.0);
  12473. vec4 posEC = czm_inverseProjection * vec4(xy, depth, 1.0);
  12474. posEC = posEC / posEC.w;
  12475. // Avoid numerical error at far plane
  12476. if (depth >= 1.0) {
  12477. posEC.z = czm_currentFrustum.y;
  12478. }
  12479. return posEC;
  12480. }
  12481. // Reconstruct surface normal in eye coordinates, avoiding edges
  12482. vec3 getNormalXEdge(vec3 positionEC)
  12483. {
  12484. // Find the 3D surface positions at adjacent screen pixels
  12485. vec2 centerCoord = gl_FragCoord.xy;
  12486. vec3 positionLeft = pixelToEye(centerCoord + vec2(-1.0, 0.0)).xyz;
  12487. vec3 positionRight = pixelToEye(centerCoord + vec2(1.0, 0.0)).xyz;
  12488. vec3 positionUp = pixelToEye(centerCoord + vec2(0.0, 1.0)).xyz;
  12489. vec3 positionDown = pixelToEye(centerCoord + vec2(0.0, -1.0)).xyz;
  12490. // Compute potential tangent vectors
  12491. vec3 dx0 = positionEC - positionLeft;
  12492. vec3 dx1 = positionRight - positionEC;
  12493. vec3 dy0 = positionEC - positionDown;
  12494. vec3 dy1 = positionUp - positionEC;
  12495. // The shorter tangent is more likely to be on the same surface
  12496. vec3 dx = length(dx0) < length(dx1) ? dx0 : dx1;
  12497. vec3 dy = length(dy0) < length(dy1) ? dy0 : dy1;
  12498. return normalize(cross(dx, dy));
  12499. }
  12500. const float sqrtTwoPi = sqrt(czm_twoPi);
  12501. float gaussian(float x, float standardDeviation) {
  12502. float argument = x / standardDeviation;
  12503. return exp(-0.5 * argument * argument) / (sqrtTwoPi * standardDeviation);
  12504. }
  12505. void main(void)
  12506. {
  12507. vec4 positionEC = pixelToEye(gl_FragCoord.xy);
  12508. // Exit if we are too close to the back of the frustum, where the depth value is invalid.
  12509. float maxValidDepth = czm_currentFrustum.y - lengthCap;
  12510. if (-positionEC.z > maxValidDepth)
  12511. {
  12512. out_FragColor = vec4(1.0);
  12513. return;
  12514. }
  12515. vec3 normalEC = getNormalXEdge(positionEC.xyz);
  12516. float gaussianVariance = lengthCap * sqrt(-positionEC.z);
  12517. // Choose a step length such that the marching stops just before 3 * variance.
  12518. float stepLength = 3.0 * gaussianVariance / (float(stepCount) + 1.0);
  12519. float metersPerPixel = czm_metersPerPixel(positionEC, 1.0);
  12520. // Minimum step is 1 pixel to avoid double sampling
  12521. float pixelsPerStep = max(stepLength / metersPerPixel, 1.0);
  12522. stepLength = pixelsPerStep * metersPerPixel;
  12523. float angleStepScale = 1.0 / float(directionCount);
  12524. float angleStep = angleStepScale * czm_twoPi;
  12525. float cosStep = cos(angleStep);
  12526. float sinStep = sin(angleStep);
  12527. mat2 rotateStep = mat2(cosStep, sinStep, -sinStep, cosStep);
  12528. // Initial sampling direction (different for each pixel)
  12529. const float randomTextureSize = 255.0;
  12530. vec2 randomTexCoord = fract(gl_FragCoord.xy / randomTextureSize);
  12531. float randomVal = texture(randomTexture, randomTexCoord).x;
  12532. vec2 sampleDirection = vec2(cos(angleStep * randomVal), sin(angleStep * randomVal));
  12533. float ao = 0.0;
  12534. // Loop over sampling directions
  12535. #if __VERSION__ == 300
  12536. for (int i = 0; i < directionCount; i++)
  12537. {
  12538. #else
  12539. for (int i = 0; i < 16; i++)
  12540. {
  12541. if (i >= directionCount) {
  12542. break;
  12543. }
  12544. #endif
  12545. sampleDirection = rotateStep * sampleDirection;
  12546. float localAO = 0.0;
  12547. vec2 radialStep = pixelsPerStep * sampleDirection;
  12548. #if __VERSION__ == 300
  12549. for (int j = 0; j < stepCount; j++)
  12550. {
  12551. #else
  12552. for (int j = 0; j < 64; j++)
  12553. {
  12554. if (j >= stepCount) {
  12555. break;
  12556. }
  12557. #endif
  12558. // Step along sampling direction, away from output pixel
  12559. vec2 samplePixel = floor(gl_FragCoord.xy + float(j + 1) * radialStep) + vec2(0.5);
  12560. // Exit if we stepped off the screen
  12561. if (clamp(samplePixel, vec2(0.0), czm_viewport.zw) != samplePixel) {
  12562. break;
  12563. }
  12564. // Compute step vector from output point to sampled point
  12565. vec4 samplePositionEC = pixelToEye(samplePixel);
  12566. vec3 stepVector = samplePositionEC.xyz - positionEC.xyz;
  12567. // Estimate the angle from the surface normal.
  12568. float dotVal = clamp(dot(normalEC, normalize(stepVector)), 0.0, 1.0);
  12569. dotVal = czm_branchFreeTernary(dotVal > bias, dotVal, 0.0);
  12570. dotVal = czm_branchFreeTernary(-samplePositionEC.z <= maxValidDepth, dotVal, 0.0);
  12571. // Weight contribution based on the distance from the output point
  12572. float sampleDistance = length(stepVector);
  12573. float weight = gaussian(sampleDistance, gaussianVariance);
  12574. localAO += weight * dotVal;
  12575. }
  12576. ao += localAO;
  12577. }
  12578. ao *= angleStepScale * stepLength;
  12579. ao = 1.0 - clamp(ao, 0.0, 1.0);
  12580. ao = pow(ao, intensity);
  12581. out_FragColor = vec4(vec3(ao), 1.0);
  12582. }
  12583. `;var cro=y(x(),1),iM=`uniform sampler2D colorTexture;
  12584. uniform sampler2D ambientOcclusionTexture;
  12585. uniform bool ambientOcclusionOnly;
  12586. in vec2 v_textureCoordinates;
  12587. void main(void)
  12588. {
  12589. vec4 color = texture(colorTexture, v_textureCoordinates);
  12590. vec4 ao = texture(ambientOcclusionTexture, v_textureCoordinates);
  12591. out_FragColor = ambientOcclusionOnly ? ao : ao * color;
  12592. }
  12593. `;var dro=y(x(),1),oM=`uniform sampler2D colorTexture;
  12594. uniform float gradations;
  12595. in vec2 v_textureCoordinates;
  12596. void main(void)
  12597. {
  12598. vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
  12599. #ifdef CZM_SELECTED_FEATURE
  12600. if (czm_selected()) {
  12601. out_FragColor = vec4(rgb, 1.0);
  12602. return;
  12603. }
  12604. #endif
  12605. float luminance = czm_luminance(rgb);
  12606. float darkness = luminance * gradations;
  12607. darkness = (darkness - fract(darkness)) / gradations;
  12608. out_FragColor = vec4(vec3(darkness), 1.0);
  12609. }
  12610. `;var mro=y(x(),1),rM=`uniform sampler2D colorTexture;
  12611. uniform sampler2D bloomTexture;
  12612. uniform bool glowOnly;
  12613. in vec2 v_textureCoordinates;
  12614. void main(void)
  12615. {
  12616. vec4 color = texture(colorTexture, v_textureCoordinates);
  12617. #ifdef CZM_SELECTED_FEATURE
  12618. if (czm_selected()) {
  12619. out_FragColor = color;
  12620. return;
  12621. }
  12622. #endif
  12623. vec4 bloom = texture(bloomTexture, v_textureCoordinates);
  12624. out_FragColor = glowOnly ? bloom : bloom + color;
  12625. }
  12626. `;var fro=y(x(),1),sM=`uniform sampler2D colorTexture;
  12627. uniform float brightness;
  12628. in vec2 v_textureCoordinates;
  12629. void main(void)
  12630. {
  12631. vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
  12632. vec3 target = vec3(0.0);
  12633. out_FragColor = vec4(mix(target, rgb, brightness), 1.0);
  12634. }
  12635. `;var Aro=y(x(),1),aM=`uniform sampler2D colorTexture;
  12636. uniform float contrast;
  12637. uniform float brightness;
  12638. in vec2 v_textureCoordinates;
  12639. void main(void)
  12640. {
  12641. vec3 sceneColor = texture(colorTexture, v_textureCoordinates).xyz;
  12642. sceneColor = czm_RGBToHSB(sceneColor);
  12643. sceneColor.z += brightness;
  12644. sceneColor = czm_HSBToRGB(sceneColor);
  12645. float factor = (259.0 * (contrast + 255.0)) / (255.0 * (259.0 - contrast));
  12646. sceneColor = factor * (sceneColor - vec3(0.5)) + vec3(0.5);
  12647. out_FragColor = vec4(sceneColor, 1.0);
  12648. }
  12649. `;var bro=y(x(),1),cM=`uniform sampler2D colorTexture;
  12650. uniform sampler2D blurTexture;
  12651. uniform sampler2D depthTexture;
  12652. uniform float focalDistance;
  12653. in vec2 v_textureCoordinates;
  12654. vec4 toEye(vec2 uv, float depth)
  12655. {
  12656. vec2 xy = vec2((uv.x * 2.0 - 1.0), ((1.0 - uv.y) * 2.0 - 1.0));
  12657. vec4 posInCamera = czm_inverseProjection * vec4(xy, depth, 1.0);
  12658. posInCamera = posInCamera / posInCamera.w;
  12659. return posInCamera;
  12660. }
  12661. float computeDepthBlur(float depth)
  12662. {
  12663. float f;
  12664. if (depth < focalDistance)
  12665. {
  12666. f = (focalDistance - depth) / (focalDistance - czm_currentFrustum.x);
  12667. }
  12668. else
  12669. {
  12670. f = (depth - focalDistance) / (czm_currentFrustum.y - focalDistance);
  12671. f = pow(f, 0.1);
  12672. }
  12673. f *= f;
  12674. f = clamp(f, 0.0, 1.0);
  12675. return pow(f, 0.5);
  12676. }
  12677. void main(void)
  12678. {
  12679. float depth = czm_readDepth(depthTexture, v_textureCoordinates);
  12680. vec4 posInCamera = toEye(v_textureCoordinates, depth);
  12681. float d = computeDepthBlur(-posInCamera.z);
  12682. out_FragColor = mix(texture(colorTexture, v_textureCoordinates), texture(blurTexture, v_textureCoordinates), d);
  12683. }
  12684. `;var xro=y(x(),1),lM=`uniform sampler2D depthTexture;
  12685. in vec2 v_textureCoordinates;
  12686. void main(void)
  12687. {
  12688. float depth = czm_readDepth(depthTexture, v_textureCoordinates);
  12689. out_FragColor = vec4(vec3(depth), 1.0);
  12690. }
  12691. `;var Tro=y(x(),1),dM=`uniform sampler2D depthTexture;
  12692. uniform float length;
  12693. uniform vec4 color;
  12694. in vec2 v_textureCoordinates;
  12695. void main(void)
  12696. {
  12697. float directions[3];
  12698. directions[0] = -1.0;
  12699. directions[1] = 0.0;
  12700. directions[2] = 1.0;
  12701. float scalars[3];
  12702. scalars[0] = 3.0;
  12703. scalars[1] = 10.0;
  12704. scalars[2] = 3.0;
  12705. float padx = czm_pixelRatio / czm_viewport.z;
  12706. float pady = czm_pixelRatio / czm_viewport.w;
  12707. #ifdef CZM_SELECTED_FEATURE
  12708. bool selected = false;
  12709. for (int i = 0; i < 3; ++i)
  12710. {
  12711. float dir = directions[i];
  12712. selected = selected || czm_selected(vec2(-padx, dir * pady));
  12713. selected = selected || czm_selected(vec2(padx, dir * pady));
  12714. selected = selected || czm_selected(vec2(dir * padx, -pady));
  12715. selected = selected || czm_selected(vec2(dir * padx, pady));
  12716. if (selected)
  12717. {
  12718. break;
  12719. }
  12720. }
  12721. if (!selected)
  12722. {
  12723. out_FragColor = vec4(color.rgb, 0.0);
  12724. return;
  12725. }
  12726. #endif
  12727. float horizEdge = 0.0;
  12728. float vertEdge = 0.0;
  12729. for (int i = 0; i < 3; ++i)
  12730. {
  12731. float dir = directions[i];
  12732. float scale = scalars[i];
  12733. horizEdge -= texture(depthTexture, v_textureCoordinates + vec2(-padx, dir * pady)).x * scale;
  12734. horizEdge += texture(depthTexture, v_textureCoordinates + vec2(padx, dir * pady)).x * scale;
  12735. vertEdge -= texture(depthTexture, v_textureCoordinates + vec2(dir * padx, -pady)).x * scale;
  12736. vertEdge += texture(depthTexture, v_textureCoordinates + vec2(dir * padx, pady)).x * scale;
  12737. }
  12738. float len = sqrt(horizEdge * horizEdge + vertEdge * vertEdge);
  12739. out_FragColor = vec4(color.rgb, len > length ? color.a : 0.0);
  12740. }
  12741. `;var Sro=y(x(),1),uM=`uniform sampler2D colorTexture;
  12742. in vec2 v_textureCoordinates;
  12743. #ifdef AUTO_EXPOSURE
  12744. uniform sampler2D autoExposure;
  12745. #else
  12746. uniform float exposure;
  12747. #endif
  12748. // See slides 142 and 143:
  12749. // http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting
  12750. void main()
  12751. {
  12752. vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
  12753. vec3 color = fragmentColor.rgb;
  12754. #ifdef AUTO_EXPOSURE
  12755. float exposure = texture(autoExposure, vec2(0.5)).r;
  12756. color /= exposure;
  12757. #else
  12758. color *= vec3(exposure);
  12759. #endif
  12760. const float A = 0.22; // shoulder strength
  12761. const float B = 0.30; // linear strength
  12762. const float C = 0.10; // linear angle
  12763. const float D = 0.20; // toe strength
  12764. const float E = 0.01; // toe numerator
  12765. const float F = 0.30; // toe denominator
  12766. const float white = 11.2; // linear white point value
  12767. vec3 c = ((color * (A * color + C * B) + D * E) / (color * ( A * color + B) + D * F)) - E / F;
  12768. float w = ((white * (A * white + C * B) + D * E) / (white * ( A * white + B) + D * F)) - E / F;
  12769. c = czm_inverseGamma(c / w);
  12770. out_FragColor = vec4(c, fragmentColor.a);
  12771. }
  12772. `;var Iro=y(x(),1),mM=`uniform sampler2D colorTexture;
  12773. in vec2 v_textureCoordinates;
  12774. #ifdef AUTO_EXPOSURE
  12775. uniform sampler2D autoExposure;
  12776. #else
  12777. uniform float exposure;
  12778. #endif
  12779. void main()
  12780. {
  12781. vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
  12782. vec3 color = fragmentColor.rgb;
  12783. #ifdef AUTO_EXPOSURE
  12784. color /= texture(autoExposure, vec2(0.5)).r;
  12785. #else
  12786. color *= vec3(exposure);
  12787. #endif
  12788. color = czm_pbrNeutralTonemapping(color);
  12789. color = czm_inverseGamma(color);
  12790. out_FragColor = vec4(color, fragmentColor.a);
  12791. }
  12792. `;var Rro=y(x(),1),hM=`in vec2 v_textureCoordinates;
  12793. uniform sampler2D colorTexture;
  12794. const float fxaaQualitySubpix = 0.5;
  12795. const float fxaaQualityEdgeThreshold = 0.125;
  12796. const float fxaaQualityEdgeThresholdMin = 0.0833;
  12797. void main()
  12798. {
  12799. vec2 fxaaQualityRcpFrame = vec2(1.0) / czm_viewport.zw;
  12800. vec4 color = FxaaPixelShader(
  12801. v_textureCoordinates,
  12802. colorTexture,
  12803. fxaaQualityRcpFrame,
  12804. fxaaQualitySubpix,
  12805. fxaaQualityEdgeThreshold,
  12806. fxaaQualityEdgeThresholdMin);
  12807. float alpha = texture(colorTexture, v_textureCoordinates).a;
  12808. out_FragColor = vec4(color.rgb, alpha);
  12809. }
  12810. `;var Gro=y(x(),1),Ky=`#define SAMPLES 8
  12811. uniform float delta;
  12812. uniform float sigma;
  12813. uniform float direction; // 0.0 for x direction, 1.0 for y direction
  12814. uniform sampler2D colorTexture;
  12815. #ifdef USE_STEP_SIZE
  12816. uniform float stepSize;
  12817. #else
  12818. uniform vec2 step;
  12819. #endif
  12820. in vec2 v_textureCoordinates;
  12821. // Incremental Computation of the Gaussian:
  12822. // https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch40.html
  12823. void main()
  12824. {
  12825. vec2 st = v_textureCoordinates;
  12826. vec2 dir = vec2(1.0 - direction, direction);
  12827. #ifdef USE_STEP_SIZE
  12828. vec2 step = vec2(stepSize * (czm_pixelRatio / czm_viewport.zw));
  12829. #else
  12830. vec2 step = step;
  12831. #endif
  12832. vec3 g;
  12833. g.x = 1.0 / (sqrt(czm_twoPi) * sigma);
  12834. g.y = exp((-0.5 * delta * delta) / (sigma * sigma));
  12835. g.z = g.y * g.y;
  12836. vec4 result = texture(colorTexture, st) * g.x;
  12837. for (int i = 1; i < SAMPLES; ++i)
  12838. {
  12839. g.xy *= g.yz;
  12840. vec2 offset = float(i) * dir * step;
  12841. result += texture(colorTexture, st - offset) * g.x;
  12842. result += texture(colorTexture, st + offset) * g.x;
  12843. }
  12844. out_FragColor = result;
  12845. }
  12846. `;var Wro=y(x(),1),fM=`uniform sampler2D colorTexture;
  12847. uniform sampler2D dirtTexture;
  12848. uniform sampler2D starTexture;
  12849. uniform vec2 dirtTextureDimensions;
  12850. uniform float distortion;
  12851. uniform float ghostDispersal;
  12852. uniform float haloWidth;
  12853. uniform float dirtAmount;
  12854. uniform float earthRadius;
  12855. uniform float intensity;
  12856. in vec2 v_textureCoordinates;
  12857. // whether it is in space or not
  12858. // 6500000.0 is empirical value
  12859. #define DISTANCE_TO_SPACE 6500000.0
  12860. // return ndc from world coordinate biased earthRadius
  12861. vec4 getNDCFromWC(vec3 WC, float earthRadius)
  12862. {
  12863. vec4 positionEC = czm_view * vec4(WC, 1.0);
  12864. positionEC = vec4(positionEC.x + earthRadius, positionEC.y, positionEC.z, 1.0);
  12865. vec4 positionWC = czm_eyeToWindowCoordinates(positionEC);
  12866. return czm_viewportOrthographic * vec4(positionWC.xy, -positionWC.z, 1.0);
  12867. }
  12868. // Check if current pixel is included Earth
  12869. // if then mask it gradually
  12870. float isInEarth(vec2 texcoord, vec2 sceneSize)
  12871. {
  12872. vec2 NDC = texcoord * 2.0 - 1.0;
  12873. vec4 earthPosSC = getNDCFromWC(vec3(0.0), 0.0);
  12874. vec4 earthPosSCEdge = getNDCFromWC(vec3(0.0), earthRadius * 1.5);
  12875. NDC.xy -= earthPosSC.xy;
  12876. float X = abs(NDC.x) * sceneSize.x;
  12877. float Y = abs(NDC.y) * sceneSize.y;
  12878. return clamp(0.0, 1.0, max(sqrt(X * X + Y * Y) / max(abs(earthPosSCEdge.x * sceneSize.x), 1.0) - 0.8 , 0.0));
  12879. }
  12880. // For Chromatic effect
  12881. vec4 textureDistorted(sampler2D tex, vec2 texcoord, vec2 direction, vec3 distortion, bool isSpace)
  12882. {
  12883. vec2 sceneSize = czm_viewport.zw;
  12884. vec3 color;
  12885. if(isSpace)
  12886. {
  12887. color.r = isInEarth(texcoord + direction * distortion.r, sceneSize) * texture(tex, texcoord + direction * distortion.r).r;
  12888. color.g = isInEarth(texcoord + direction * distortion.g, sceneSize) * texture(tex, texcoord + direction * distortion.g).g;
  12889. color.b = isInEarth(texcoord + direction * distortion.b, sceneSize) * texture(tex, texcoord + direction * distortion.b).b;
  12890. }
  12891. else
  12892. {
  12893. color.r = texture(tex, texcoord + direction * distortion.r).r;
  12894. color.g = texture(tex, texcoord + direction * distortion.g).g;
  12895. color.b = texture(tex, texcoord + direction * distortion.b).b;
  12896. }
  12897. return vec4(clamp(color, 0.0, 1.0), 0.0);
  12898. }
  12899. void main(void)
  12900. {
  12901. vec4 originalColor = texture(colorTexture, v_textureCoordinates);
  12902. vec3 rgb = originalColor.rgb;
  12903. bool isSpace = length(czm_viewerPositionWC.xyz) > DISTANCE_TO_SPACE;
  12904. // Sun position
  12905. vec4 sunPos = czm_morphTime == 1.0 ? vec4(czm_sunPositionWC, 1.0) : vec4(czm_sunPositionColumbusView.zxy, 1.0);
  12906. vec4 sunPositionEC = czm_view * sunPos;
  12907. vec4 sunPositionWC = czm_eyeToWindowCoordinates(sunPositionEC);
  12908. sunPos = czm_viewportOrthographic * vec4(sunPositionWC.xy, -sunPositionWC.z, 1.0);
  12909. // If sun is not in the screen space, use original color.
  12910. if(!isSpace || !((sunPos.x >= -1.1 && sunPos.x <= 1.1) && (sunPos.y >= -1.1 && sunPos.y <= 1.1)))
  12911. {
  12912. // Lens flare is disabled when not in space until #5932 is fixed.
  12913. // https://github.com/CesiumGS/cesium/issues/5932
  12914. out_FragColor = originalColor;
  12915. return;
  12916. }
  12917. vec2 texcoord = vec2(1.0) - v_textureCoordinates;
  12918. vec2 pixelSize = czm_pixelRatio / czm_viewport.zw;
  12919. vec2 invPixelSize = 1.0 / pixelSize;
  12920. vec3 distortionVec = pixelSize.x * vec3(-distortion, 0.0, distortion);
  12921. // ghost vector to image centre:
  12922. vec2 ghostVec = (vec2(0.5) - texcoord) * ghostDispersal;
  12923. vec3 direction = normalize(vec3(ghostVec, 0.0));
  12924. // sample ghosts:
  12925. vec4 result = vec4(0.0);
  12926. vec4 ghost = vec4(0.0);
  12927. for (int i = 0; i < 4; ++i)
  12928. {
  12929. vec2 offset = fract(texcoord + ghostVec * float(i));
  12930. // Only bright spots from the centre of the source image
  12931. ghost += textureDistorted(colorTexture, offset, direction.xy, distortionVec, isSpace);
  12932. }
  12933. result += ghost;
  12934. // sample halo
  12935. vec2 haloVec = normalize(ghostVec) * haloWidth;
  12936. float weightForHalo = length(vec2(0.5) - fract(texcoord + haloVec)) / length(vec2(0.5));
  12937. weightForHalo = pow(1.0 - weightForHalo, 5.0);
  12938. result += textureDistorted(colorTexture, texcoord + haloVec, direction.xy, distortionVec, isSpace) * weightForHalo * 1.5;
  12939. // dirt on lens
  12940. vec2 dirtTexCoords = (v_textureCoordinates * invPixelSize) / dirtTextureDimensions;
  12941. if (dirtTexCoords.x > 1.0)
  12942. {
  12943. dirtTexCoords.x = mod(floor(dirtTexCoords.x), 2.0) == 1.0 ? 1.0 - fract(dirtTexCoords.x) : fract(dirtTexCoords.x);
  12944. }
  12945. if (dirtTexCoords.y > 1.0)
  12946. {
  12947. dirtTexCoords.y = mod(floor(dirtTexCoords.y), 2.0) == 1.0 ? 1.0 - fract(dirtTexCoords.y) : fract(dirtTexCoords.y);
  12948. }
  12949. result += dirtAmount * texture(dirtTexture, dirtTexCoords);
  12950. // Rotating starburst texture's coordinate
  12951. // dot(czm_view[0].xyz, vec3(0.0, 0.0, 1.0)) + dot(czm_view[1].xyz, vec3(0.0, 1.0, 0.0))
  12952. float camrot = czm_view[0].z + czm_view[1].y;
  12953. float cosValue = cos(camrot);
  12954. float sinValue = sin(camrot);
  12955. mat3 rotation = mat3(
  12956. cosValue, -sinValue, 0.0,
  12957. sinValue, cosValue, 0.0,
  12958. 0.0, 0.0, 1.0
  12959. );
  12960. vec3 st1 = vec3(v_textureCoordinates * 2.0 - vec2(1.0), 1.0);
  12961. vec3 st2 = vec3((rotation * st1).xy, 1.0);
  12962. vec3 st3 = st2 * 0.5 + vec3(0.5);
  12963. vec2 lensStarTexcoord = st3.xy;
  12964. float weightForLensFlare = length(vec3(sunPos.xy, 0.0));
  12965. float oneMinusWeightForLensFlare = max(1.0 - weightForLensFlare, 0.0);
  12966. if (!isSpace)
  12967. {
  12968. result *= oneMinusWeightForLensFlare * intensity * 0.2;
  12969. }
  12970. else
  12971. {
  12972. result *= oneMinusWeightForLensFlare * intensity;
  12973. result *= texture(starTexture, lensStarTexcoord) * pow(weightForLensFlare, 1.0) * max((1.0 - length(vec3(st1.xy, 0.0))), 0.0) * 2.0;
  12974. }
  12975. result += texture(colorTexture, v_textureCoordinates);
  12976. out_FragColor = result;
  12977. }
  12978. `;var Bro=y(x(),1),pM=`uniform sampler2D colorTexture;
  12979. uniform vec3 white;
  12980. in vec2 v_textureCoordinates;
  12981. #ifdef AUTO_EXPOSURE
  12982. uniform sampler2D autoExposure;
  12983. #else
  12984. uniform float exposure;
  12985. #endif
  12986. // See equation 4:
  12987. // http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
  12988. void main()
  12989. {
  12990. vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
  12991. vec3 color = fragmentColor.rgb;
  12992. #ifdef AUTO_EXPOSURE
  12993. float exposure = texture(autoExposure, vec2(0.5)).r;
  12994. color /= exposure;
  12995. #else
  12996. color *= vec3(exposure);
  12997. #endif
  12998. color = (color * (1.0 + color / white)) / (1.0 + color);
  12999. color = czm_inverseGamma(color);
  13000. out_FragColor = vec4(color, fragmentColor.a);
  13001. }
  13002. `;var Nro=y(x(),1),AM=`uniform sampler2D colorTexture;
  13003. in vec2 v_textureCoordinates;
  13004. float rand(vec2 co)
  13005. {
  13006. return fract(sin(dot(co.xy ,vec2(12.9898, 78.233))) * 43758.5453);
  13007. }
  13008. void main(void)
  13009. {
  13010. float noiseValue = rand(v_textureCoordinates + sin(czm_frameNumber)) * 0.1;
  13011. vec3 rgb = texture(colorTexture, v_textureCoordinates).rgb;
  13012. vec3 green = vec3(0.0, 1.0, 0.0);
  13013. out_FragColor = vec4((noiseValue + rgb) * green, 1.0);
  13014. }
  13015. `;var Xro=y(x(),1),gM=`uniform sampler2D colorTexture;
  13016. in vec2 v_textureCoordinates;
  13017. #ifdef AUTO_EXPOSURE
  13018. uniform sampler2D autoExposure;
  13019. #else
  13020. uniform float exposure;
  13021. #endif
  13022. // See equation 3:
  13023. // http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
  13024. void main()
  13025. {
  13026. vec4 fragmentColor = texture(colorTexture, v_textureCoordinates);
  13027. vec3 color = fragmentColor.rgb;
  13028. #ifdef AUTO_EXPOSURE
  13029. float exposure = texture(autoExposure, vec2(0.5)).r;
  13030. color /= exposure;
  13031. #else
  13032. color *= vec3(exposure);
  13033. #endif
  13034. color = color / (1.0 + color);
  13035. color = czm_inverseGamma(color);
  13036. out_FragColor = vec4(color, fragmentColor.a);
  13037. }
  13038. `;var Mro=y(x(),1),bM=`uniform sampler2D colorTexture;
  13039. uniform sampler2D silhouetteTexture;
  13040. in vec2 v_textureCoordinates;
  13041. void main(void)
  13042. {
  13043. vec4 silhouetteColor = texture(silhouetteTexture, v_textureCoordinates);
  13044. vec4 color = texture(colorTexture, v_textureCoordinates);
  13045. out_FragColor = mix(color, silhouetteColor, silhouetteColor.a);
  13046. }
  13047. `;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;
  13048. in vec2 v_textureCoordinates;
  13049. float sampleTexture(vec2 offset) {
  13050. `;return e===0?n+=` vec4 color = texture(colorTexture, v_textureCoordinates + offset);
  13051. return czm_luminance(color.rgb);
  13052. `:n+=` return texture(colorTexture, v_textureCoordinates + offset).r;
  13053. `,n+=`}
  13054. `,n+=`uniform vec2 colorTextureDimensions;
  13055. uniform vec2 minMaxLuminance;
  13056. uniform sampler2D previousLuminance;
  13057. void main() {
  13058. float color = 0.0;
  13059. float xStep = 1.0 / colorTextureDimensions.x;
  13060. float yStep = 1.0 / colorTextureDimensions.y;
  13061. int count = 0;
  13062. for (int i = 0; i < 3; ++i) {
  13063. for (int j = 0; j < 3; ++j) {
  13064. vec2 offset;
  13065. offset.x = -xStep + float(i) * xStep;
  13066. offset.y = -yStep + float(j) * yStep;
  13067. if (offset.x < 0.0 || offset.x > 1.0 || offset.y < 0.0 || offset.y > 1.0) {
  13068. continue;
  13069. }
  13070. color += sampleTexture(offset);
  13071. ++count;
  13072. }
  13073. }
  13074. if (count > 0) {
  13075. color /= float(count);
  13076. }
  13077. `,e===t-1&&(n+=` float previous = texture(previousLuminance, vec2(0.5)).r;
  13078. color = clamp(color, minMaxLuminance.x, minMaxLuminance.y);
  13079. color = previous + (color - previous) / (60.0 * 1.5);
  13080. color = clamp(color, minMaxLuminance.x, minMaxLuminance.y);
  13081. `),n+=` out_FragColor = vec4(color);
  13082. }
  13083. `,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
  13084. uniform sampler2D czm_idTexture;
  13085. uniform sampler2D czm_selectedIdTexture;
  13086. uniform float czm_selectedIdTextureStep;
  13087. in vec2 v_textureCoordinates;
  13088. bool czm_selected(vec2 offset)
  13089. {
  13090. bool selected = false;
  13091. vec4 id = texture(czm_idTexture, v_textureCoordinates + offset);
  13092. for (int i = 0; i < ${t}; ++i)
  13093. {
  13094. vec4 selectedId = texture(czm_selectedIdTexture, vec2((float(i) + 0.5) * czm_selectedIdTextureStep, 0.5));
  13095. if (all(equal(id, selectedId)))
  13096. {
  13097. return true;
  13098. }
  13099. }
  13100. return false;
  13101. }
  13102. bool czm_selected()
  13103. {
  13104. return czm_selected(vec2(0.0));
  13105. }
  13106. ${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
  13107. ${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};
  13108. `,o+=` vec4 edge${a} = texture(edgeTexture${a}, v_textureCoordinates);
  13109. if (edge${a}.a > 0.0)
  13110. {
  13111. color = edge${a};
  13112. break;
  13113. }
  13114. `,n[`edgeTexture${a}`]=e[a].name;let r=`${i}in vec2 v_textureCoordinates;
  13115. void main() {
  13116. vec4 color = vec4(0.0);
  13117. for (int i = 0; i < ${e.length}; i++)
  13118. {
  13119. ${o} }
  13120. out_FragColor = color;
  13121. }
  13122. `,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
  13123. ${qX}
  13124. ${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
  13125. `:"";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
  13126. `:"";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
  13127. `:"";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
  13128. `:"";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
  13129. `:"";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
  13130. uniform sampler2D colorTexture2;
  13131. uniform vec2 center;
  13132. uniform float radius;
  13133. in vec2 v_textureCoordinates;
  13134. void main()
  13135. {
  13136. vec4 color0 = texture(colorTexture, v_textureCoordinates);
  13137. vec4 color1 = texture(colorTexture2, v_textureCoordinates);
  13138. float x = length(gl_FragCoord.xy - center) / radius;
  13139. float t = smoothstep(0.5, 0.8, x);
  13140. out_FragColor = mix(color0 + color1, color1, t);
  13141. }
  13142. `;var Dco=y(x(),1),VM=`uniform sampler2D colorTexture;
  13143. uniform float avgLuminance;
  13144. uniform float threshold;
  13145. uniform float offset;
  13146. in vec2 v_textureCoordinates;
  13147. float key(float avg)
  13148. {
  13149. float guess = 1.5 - (1.5 / (avg * 0.1 + 1.0));
  13150. return max(0.0, guess) + 0.1;
  13151. }
  13152. // See section 9. "The bright-pass filter" of Realtime HDR Rendering
  13153. // http://www.cg.tuwien.ac.at/research/publications/2007/Luksch_2007_RHR/Luksch_2007_RHR-RealtimeHDR%20.pdf
  13154. void main()
  13155. {
  13156. vec4 color = texture(colorTexture, v_textureCoordinates);
  13157. vec3 xyz = czm_RGBToXYZ(color.rgb);
  13158. float luminance = xyz.r;
  13159. float scaledLum = key(avgLuminance) * luminance / avgLuminance;
  13160. float brightLum = max(scaledLum - threshold, 0.0);
  13161. float brightness = brightLum / (offset + brightLum);
  13162. xyz.r = brightness;
  13163. out_FragColor = vec4(czm_XYZToRGB(xyz), 1.0);
  13164. }
  13165. `;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;
  13166. `,a+=`uniform vec3 debugShowFrustumsColor;
  13167. `,a+=`void main()
  13168. {
  13169. czm_Debug_main();
  13170. `;let c;if(s>0)for(c=0;c<s;++c)a+=` out_FragData_${r[c]}.rgb *= debugShowCommandsColor;
  13171. `,a+=` out_FragData_${r[c]}.rgb *= debugShowFrustumsColor;
  13172. `;else a+=` out_FragColor.rgb *= debugShowCommandsColor;
  13173. `,a+=` out_FragColor.rgb *= debugShowFrustumsColor;
  13174. `;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[_]} =
  13175. vec3 pos;
  13176. vec3 dir;
  13177. };
  13178. float minComponent(in vec3 v) {
  13179. return min(min(v.x, v.y), v.z);
  13180. }
  13181. float maxComponent(in vec3 v) {
  13182. return max(max(v.x, v.y), v.z);
  13183. }
  13184. `;var Hlo=y(x(),1),NM=`// See Intersection.glsl for the definition of intersectScene
  13185. // See IntersectionUtils.glsl for the definition of nextIntersection
  13186. // See convertLocalToBoxUv.glsl, convertLocalToCylinderUv.glsl, or convertLocalToEllipsoidUv.glsl
  13187. // for the definitions of convertLocalToShapeSpaceDerivative and getTileAndUvCoordinate.
  13188. // The appropriate functions are selected based on the VoxelPrimitive shape type,
  13189. // and added to the shader in Scene/VoxelRenderResources.js.
  13190. // See Octree.glsl for the definitions of TraversalData, SampleData,
  13191. // traverseOctreeFromBeginning, and traverseOctreeFromExisting
  13192. // See Megatexture.glsl for the definition of accumulatePropertiesFromMegatexture
  13193. #define STEP_COUNT_MAX 1000 // Harcoded value because GLSL doesn't like variable length loops
  13194. #if defined(PICKING_VOXEL)
  13195. #define ALPHA_ACCUM_MAX 0.1
  13196. #else
  13197. #define ALPHA_ACCUM_MAX 0.98 // Must be > 0.0 and <= 1.0
  13198. #endif
  13199. uniform mat4 u_transformPositionViewToLocal;
  13200. uniform mat3 u_transformDirectionViewToLocal;
  13201. uniform vec3 u_cameraPositionLocal;
  13202. uniform vec3 u_cameraDirectionLocal;
  13203. uniform float u_stepSize;
  13204. #if defined(PICKING)
  13205. uniform vec4 u_pickColor;
  13206. #endif
  13207. vec3 getSampleSize(in int level) {
  13208. vec3 sampleCount = exp2(float(level)) * vec3(u_dimensions);
  13209. vec3 sampleSizeUv = 1.0 / sampleCount;
  13210. return scaleShapeUvToShapeSpace(sampleSizeUv);
  13211. }
  13212. #define MINIMUM_STEP_SCALAR (0.02)
  13213. #define SHIFT_FRACTION (0.001)
  13214. /**
  13215. * Given a coordinate within a tile, and sample spacings along a ray through
  13216. * the coordinate, find the distance to the points where the ray entered and
  13217. * exited the voxel cell, along with the surface normals at those points.
  13218. * The surface normals are returned in shape space coordinates.
  13219. */
  13220. RayShapeIntersection getVoxelIntersection(in vec3 tileUv, in vec3 sampleSizeAlongRay) {
  13221. vec3 voxelCoord = tileUv * vec3(u_dimensions);
  13222. vec3 directions = sign(sampleSizeAlongRay);
  13223. vec3 positiveDirections = max(directions, 0.0);
  13224. vec3 entryCoord = mix(ceil(voxelCoord), floor(voxelCoord), positiveDirections);
  13225. vec3 exitCoord = entryCoord + directions;
  13226. vec3 distanceFromEntry = -abs((entryCoord - voxelCoord) * sampleSizeAlongRay);
  13227. float lastEntry = maxComponent(distanceFromEntry);
  13228. bvec3 isLastEntry = equal(distanceFromEntry, vec3(lastEntry));
  13229. vec3 entryNormal = -1.0 * vec3(isLastEntry) * directions;
  13230. vec4 entry = vec4(entryNormal, lastEntry);
  13231. vec3 distanceToExit = abs((exitCoord - voxelCoord) * sampleSizeAlongRay);
  13232. float firstExit = minComponent(distanceToExit);
  13233. bvec3 isFirstExit = equal(distanceToExit, vec3(firstExit));
  13234. vec3 exitNormal = vec3(isFirstExit) * directions;
  13235. vec4 exit = vec4(exitNormal, firstExit);
  13236. return RayShapeIntersection(entry, exit);
  13237. }
  13238. vec4 getStepSize(in SampleData sampleData, in Ray viewRay, in RayShapeIntersection shapeIntersection, in mat3 jacobianT, in float currentT) {
  13239. vec3 gradient = viewRay.dir * jacobianT;
  13240. vec3 sampleSizeAlongRay = getSampleSize(sampleData.tileCoords.w) / gradient;
  13241. RayShapeIntersection voxelIntersection = getVoxelIntersection(sampleData.tileUv, sampleSizeAlongRay);
  13242. // Transform normal from shape space to Cartesian space to eye space
  13243. vec3 voxelNormal = jacobianT * voxelIntersection.entry.xyz;
  13244. voxelNormal = normalize(czm_normal * voxelNormal);
  13245. // Compare with the shape intersection, to choose the appropriate normal
  13246. vec4 voxelEntry = vec4(voxelNormal, currentT + voxelIntersection.entry.w);
  13247. vec4 entry = intersectionMax(shapeIntersection.entry, voxelEntry);
  13248. float fixedStep = minComponent(abs(sampleSizeAlongRay)) * u_stepSize;
  13249. float shift = fixedStep * SHIFT_FRACTION;
  13250. float dt = voxelIntersection.exit.w + shift;
  13251. if ((currentT + dt) > shapeIntersection.exit.w) {
  13252. // Stop at end of shape
  13253. dt = shapeIntersection.exit.w - currentT + shift;
  13254. }
  13255. float stepSize = clamp(dt, fixedStep * MINIMUM_STEP_SCALAR, fixedStep + shift);
  13256. return vec4(entry.xyz, stepSize);
  13257. }
  13258. vec2 packIntToVec2(int value) {
  13259. float shifted = float(value) / 255.0;
  13260. float lowBits = fract(shifted);
  13261. float highBits = floor(shifted) / 255.0;
  13262. return vec2(highBits, lowBits);
  13263. }
  13264. vec2 packFloatToVec2(float value) {
  13265. float lowBits = fract(value);
  13266. float highBits = floor(value) / 255.0;
  13267. return vec2(highBits, lowBits);
  13268. }
  13269. int getSampleIndex(in SampleData sampleData) {
  13270. // tileUv = 1.0 is a valid coordinate but sampleIndex = u_inputDimensions is not.
  13271. // (tileUv = 1.0 corresponds to the far edge of the last sample, at index = u_inputDimensions - 1).
  13272. // Clamp to [0, voxelDimensions - 0.5) to avoid numerical error before flooring
  13273. vec3 maxCoordinate = vec3(u_inputDimensions) - vec3(0.5);
  13274. vec3 inputCoordinate = clamp(sampleData.inputCoordinate, vec3(0.0), maxCoordinate);
  13275. ivec3 sampleIndex = ivec3(floor(inputCoordinate));
  13276. // Convert to a 1D index for lookup in a 1D data array
  13277. return sampleIndex.x + u_inputDimensions.x * (sampleIndex.y + u_inputDimensions.y * sampleIndex.z);
  13278. }
  13279. /**
  13280. * Compute the view ray at the current fragment, in the local coordinates of the shape.
  13281. */
  13282. Ray getViewRayLocal() {
  13283. vec4 eyeCoordinates = czm_windowToEyeCoordinates(gl_FragCoord);
  13284. vec3 origin;
  13285. vec3 direction;
  13286. if (czm_orthographicIn3D == 1.0) {
  13287. eyeCoordinates.z = 0.0;
  13288. origin = (u_transformPositionViewToLocal * eyeCoordinates).xyz;
  13289. direction = u_cameraDirectionLocal;
  13290. } else {
  13291. origin = u_cameraPositionLocal;
  13292. direction = u_transformDirectionViewToLocal * normalize(eyeCoordinates.xyz);
  13293. }
  13294. return Ray(origin, direction);
  13295. }
  13296. Ray getViewRayEC() {
  13297. vec4 eyeCoordinates = czm_windowToEyeCoordinates(gl_FragCoord);
  13298. vec3 viewPosEC = (czm_orthographicIn3D == 1.0)
  13299. ? vec3(eyeCoordinates.xy, 0.0)
  13300. : vec3(0.0);
  13301. vec3 viewDirEC = normalize(eyeCoordinates.xyz);
  13302. return Ray(viewPosEC, viewDirEC);
  13303. }
  13304. void main()
  13305. {
  13306. Ray viewRayLocal = getViewRayLocal();
  13307. Ray viewRayEC = getViewRayEC();
  13308. Intersections ix;
  13309. vec2 screenCoord = (gl_FragCoord.xy - czm_viewport.xy) / czm_viewport.zw; // [0,1]
  13310. RayShapeIntersection shapeIntersection = intersectScene(screenCoord, viewRayLocal, viewRayEC, ix);
  13311. // Exit early if the scene was completely missed.
  13312. if (shapeIntersection.entry.w == NO_HIT) {
  13313. discard;
  13314. }
  13315. float currentT = shapeIntersection.entry.w;
  13316. float endT = shapeIntersection.exit.w;
  13317. vec3 positionEC = viewRayEC.pos + currentT * viewRayEC.dir;
  13318. TileAndUvCoordinate tileAndUv = getTileAndUvCoordinate(positionEC);
  13319. vec3 positionLocal = viewRayLocal.pos + currentT * viewRayLocal.dir;
  13320. mat3 jacobianT = convertLocalToShapeSpaceDerivative(positionLocal);
  13321. // Traverse the tree from the start position
  13322. TraversalData traversalData;
  13323. SampleData sampleDatas[SAMPLE_COUNT];
  13324. traverseOctreeFromBeginning(tileAndUv, traversalData, sampleDatas);
  13325. vec4 step = getStepSize(sampleDatas[0], viewRayLocal, shapeIntersection, jacobianT, currentT);
  13326. FragmentInput fragmentInput;
  13327. #if defined(STATISTICS)
  13328. setStatistics(fragmentInput.metadataStatistics);
  13329. #endif
  13330. czm_modelMaterial materialOutput;
  13331. vec4 colorAccum = vec4(0.0);
  13332. for (int stepCount = 0; stepCount < STEP_COUNT_MAX; ++stepCount) {
  13333. // Read properties from the megatexture based on the traversal state
  13334. Properties properties = accumulatePropertiesFromMegatexture(sampleDatas);
  13335. // Prepare the custom shader inputs
  13336. copyPropertiesToMetadata(properties, fragmentInput.metadata);
  13337. fragmentInput.attributes.positionEC = positionEC;
  13338. // Re-normalize normals: some shape intersections may have been scaled to encode positive/negative shapes
  13339. fragmentInput.attributes.normalEC = normalize(step.xyz);
  13340. fragmentInput.voxel.viewDirUv = viewRayLocal.dir;
  13341. fragmentInput.voxel.travelDistance = step.w;
  13342. fragmentInput.voxel.stepCount = stepCount;
  13343. fragmentInput.voxel.tileIndex = sampleDatas[0].megatextureIndex;
  13344. fragmentInput.voxel.sampleIndex = getSampleIndex(sampleDatas[0]);
  13345. fragmentInput.voxel.distanceToDepthBuffer = ix.distanceToDepthBuffer - currentT;
  13346. // Run the custom shader
  13347. fragmentMain(fragmentInput, materialOutput);
  13348. // Sanitize the custom shader output
  13349. vec4 color = vec4(materialOutput.diffuse, materialOutput.alpha);
  13350. color.rgb = max(color.rgb, vec3(0.0));
  13351. color.a = clamp(color.a, 0.0, 1.0);
  13352. // Pre-multiplied alpha blend
  13353. colorAccum += (1.0 - colorAccum.a) * vec4(color.rgb * color.a, color.a);
  13354. // Stop traversing if the alpha has been fully saturated
  13355. if (colorAccum.a > ALPHA_ACCUM_MAX) {
  13356. colorAccum.a = ALPHA_ACCUM_MAX;
  13357. break;
  13358. }
  13359. if (step.w == 0.0) {
  13360. // Shape is infinitely thin. The ray may have hit the edge of a
  13361. // foreground voxel. Step ahead slightly to check for more voxels
  13362. step.w = 0.001;
  13363. }
  13364. // Keep raymarching
  13365. currentT += step.w;
  13366. // Check if there's more intersections.
  13367. if (currentT > endT) {
  13368. #if (INTERSECTION_COUNT == 1)
  13369. break;
  13370. #else
  13371. shapeIntersection = nextIntersection(ix);
  13372. if (shapeIntersection.entry.w == NO_HIT) {
  13373. break;
  13374. } else {
  13375. // Found another intersection. Resume raymarching there
  13376. currentT = shapeIntersection.entry.w;
  13377. endT = shapeIntersection.exit.w;
  13378. }
  13379. #endif
  13380. }
  13381. positionEC = viewRayEC.pos + currentT * viewRayEC.dir;
  13382. tileAndUv = getTileAndUvCoordinate(positionEC);
  13383. positionLocal = viewRayLocal.pos + currentT * viewRayLocal.dir;
  13384. jacobianT = convertLocalToShapeSpaceDerivative(positionLocal);
  13385. // Traverse the tree from the current ray position.
  13386. // This is similar to traverseOctreeFromBeginning but is faster when the ray is in the same tile as the previous step.
  13387. traverseOctreeFromExisting(tileAndUv, traversalData, sampleDatas);
  13388. step = getStepSize(sampleDatas[0], viewRayLocal, shapeIntersection, jacobianT, currentT);
  13389. }
  13390. // Convert the alpha from [0,ALPHA_ACCUM_MAX] to [0,1]
  13391. colorAccum.a /= ALPHA_ACCUM_MAX;
  13392. #if defined(PICKING)
  13393. // If alpha is 0.0 there is nothing to pick
  13394. if (colorAccum.a == 0.0) {
  13395. discard;
  13396. }
  13397. out_FragColor = u_pickColor;
  13398. #elif defined(PICKING_VOXEL)
  13399. // If alpha is 0.0 there is nothing to pick
  13400. if (colorAccum.a == 0.0) {
  13401. discard;
  13402. }
  13403. vec2 megatextureId = packIntToVec2(sampleDatas[0].megatextureIndex);
  13404. vec2 sampleIndex = packIntToVec2(getSampleIndex(sampleDatas[0]));
  13405. out_FragColor = vec4(megatextureId, sampleIndex);
  13406. #else
  13407. out_FragColor = colorAccum;
  13408. #endif
  13409. }
  13410. `;var Klo=y(x(),1),PM=`in vec2 position;
  13411. uniform vec4 u_ndcSpaceAxisAlignedBoundingBox;
  13412. void main() {
  13413. vec2 aabbMin = u_ndcSpaceAxisAlignedBoundingBox.xy;
  13414. vec2 aabbMax = u_ndcSpaceAxisAlignedBoundingBox.zw;
  13415. vec2 translation = 0.5 * (aabbMax + aabbMin);
  13416. vec2 scale = 0.5 * (aabbMax - aabbMin);
  13417. gl_Position = vec4(position * scale + translation, 0.0, 1.0);
  13418. }
  13419. `;var qlo=y(x(),1),XM=`/* Intersection defines
  13420. #define INTERSECTION_COUNT ###
  13421. */
  13422. #define NO_HIT (-czm_infinity)
  13423. #define INF_HIT (czm_infinity * 0.5)
  13424. struct RayShapeIntersection {
  13425. vec4 entry;
  13426. vec4 exit;
  13427. };
  13428. vec4 intersectionMin(in vec4 intersect0, in vec4 intersect1)
  13429. {
  13430. if (intersect0.w == NO_HIT) {
  13431. return intersect1;
  13432. } else if (intersect1.w == NO_HIT) {
  13433. return intersect0;
  13434. }
  13435. return (intersect0.w <= intersect1.w) ? intersect0 : intersect1;
  13436. }
  13437. vec4 intersectionMax(in vec4 intersect0, in vec4 intersect1)
  13438. {
  13439. return (intersect0.w >= intersect1.w) ? intersect0 : intersect1;
  13440. }
  13441. RayShapeIntersection intersectIntersections(in Ray ray, in RayShapeIntersection intersect0, in RayShapeIntersection intersect1)
  13442. {
  13443. bool missed = (intersect0.entry.w == NO_HIT) ||
  13444. (intersect1.entry.w == NO_HIT) ||
  13445. (intersect0.exit.w < intersect1.entry.w) ||
  13446. (intersect0.entry.w > intersect1.exit.w);
  13447. if (missed) {
  13448. vec4 miss = vec4(normalize(ray.dir), NO_HIT);
  13449. return RayShapeIntersection(miss, miss);
  13450. }
  13451. vec4 entry = intersectionMax(intersect0.entry, intersect1.entry);
  13452. vec4 exit = intersectionMin(intersect0.exit, intersect1.exit);
  13453. return RayShapeIntersection(entry, exit);
  13454. }
  13455. struct Intersections {
  13456. // Don't access these member variables directly - call the functions instead.
  13457. // Store an array of ray-surface intersections. Each intersection is composed of:
  13458. // .xyz for the surface normal at the intersection point
  13459. // .w for the T value
  13460. // The scale of the normal encodes the shape intersection type:
  13461. // length(intersection.xyz) = 1: positive shape entry
  13462. // length(intersection.xyz) = 2: positive shape exit
  13463. // length(intersection.xyz) = 3: negative shape entry
  13464. // length(intersection.xyz) = 4: negative shape exit
  13465. // INTERSECTION_COUNT is the number of ray-*shape* (volume) intersections,
  13466. // so we need twice as many to track ray-*surface* intersections
  13467. vec4 intersections[INTERSECTION_COUNT * 2];
  13468. float distanceToDepthBuffer;
  13469. #if (INTERSECTION_COUNT > 1)
  13470. // Maintain state for future nextIntersection calls
  13471. int index;
  13472. int surroundCount;
  13473. bool surroundIsPositive;
  13474. #endif
  13475. };
  13476. RayShapeIntersection getFirstIntersection(in Intersections ix)
  13477. {
  13478. return RayShapeIntersection(ix.intersections[0], ix.intersections[1]);
  13479. }
  13480. vec4 encodeIntersectionType(vec4 intersection, int index, bool entry)
  13481. {
  13482. float scale = float(index > 0) * 2.0 + float(!entry) + 1.0;
  13483. return vec4(intersection.xyz * scale, intersection.w);
  13484. }
  13485. // Use defines instead of real functions because WebGL1 cannot access array with non-constant index.
  13486. #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))
  13487. #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)
  13488. #define setSurfaceIntersection(/*inout Intersections*/ ix, /*int*/ index, /*vec4*/ intersection, /*bool*/ positive, /*bool*/ enter) (ix).intersections[(index)] = encodeIntersectionType((intersection), int(!positive), (enter))
  13489. #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)
  13490. #if (INTERSECTION_COUNT > 1)
  13491. void initializeIntersections(inout Intersections ix) {
  13492. // Sort the intersections from min T to max T with bubble sort.
  13493. // Note: If this sorting function changes, some of the intersection test may
  13494. // need to be updated. Search for "bubble sort" to find those areas.
  13495. const int sortPasses = INTERSECTION_COUNT * 2 - 1;
  13496. for (int n = sortPasses; n > 0; --n) {
  13497. for (int i = 0; i < sortPasses; ++i) {
  13498. // The loop should be: for (i = 0; i < n; ++i) {...} but WebGL1 cannot
  13499. // loop with non-constant condition, so it has to break early instead
  13500. if (i >= n) { break; }
  13501. vec4 intersect0 = ix.intersections[i + 0];
  13502. vec4 intersect1 = ix.intersections[i + 1];
  13503. bool inOrder = intersect0.w <= intersect1.w;
  13504. ix.intersections[i + 0] = inOrder ? intersect0 : intersect1;
  13505. ix.intersections[i + 1] = inOrder ? intersect1 : intersect0;
  13506. }
  13507. }
  13508. // Prepare initial state for nextIntersection
  13509. ix.index = 0;
  13510. ix.surroundCount = 0;
  13511. ix.surroundIsPositive = false;
  13512. }
  13513. #endif
  13514. #if (INTERSECTION_COUNT > 1)
  13515. RayShapeIntersection nextIntersection(inout Intersections ix) {
  13516. vec4 surfaceIntersection = vec4(0.0, 0.0, 0.0, NO_HIT);
  13517. RayShapeIntersection shapeIntersection = RayShapeIntersection(surfaceIntersection, surfaceIntersection);
  13518. const int passCount = INTERSECTION_COUNT * 2;
  13519. if (ix.index == passCount) {
  13520. return shapeIntersection;
  13521. }
  13522. for (int i = 0; i < passCount; ++i) {
  13523. // The loop should be: for (i = ix.index; i < passCount; ++i) {...} but WebGL1 cannot
  13524. // loop with non-constant condition, so it has to continue instead.
  13525. if (i < ix.index) {
  13526. continue;
  13527. }
  13528. ix.index = i + 1;
  13529. surfaceIntersection = ix.intersections[i];
  13530. int intersectionType = int(length(surfaceIntersection.xyz) - 0.5);
  13531. bool currShapeIsPositive = intersectionType < 2;
  13532. bool enter = intersectionType % 2 == 0;
  13533. ix.surroundCount += enter ? +1 : -1;
  13534. ix.surroundIsPositive = currShapeIsPositive ? enter : ix.surroundIsPositive;
  13535. // entering positive or exiting negative
  13536. if (ix.surroundCount == 1 && ix.surroundIsPositive && enter == currShapeIsPositive) {
  13537. shapeIntersection.entry = surfaceIntersection;
  13538. }
  13539. // exiting positive or entering negative after being inside positive
  13540. bool exitPositive = !enter && currShapeIsPositive && ix.surroundCount == 0;
  13541. bool enterNegativeFromPositive = enter && !currShapeIsPositive && ix.surroundCount == 2 && ix.surroundIsPositive;
  13542. if (exitPositive || enterNegativeFromPositive) {
  13543. shapeIntersection.exit = surfaceIntersection;
  13544. // entry and exit have been found, so the loop can stop
  13545. if (exitPositive) {
  13546. // After exiting positive shape there is nothing left to intersect, so jump to the end index.
  13547. ix.index = passCount;
  13548. }
  13549. break;
  13550. }
  13551. }
  13552. return shapeIntersection;
  13553. }
  13554. #endif
  13555. // NOTE: initializeIntersections, nextIntersection aren't even declared unless INTERSECTION_COUNT > 1
  13556. `;var edo=y(x(),1),YM=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections,
  13557. // setIntersectionPair, INF_HIT, NO_HIT
  13558. /* intersectDepth defines (set in Scene/VoxelRenderResources.js)
  13559. #define DEPTH_INTERSECTION_INDEX ###
  13560. */
  13561. void intersectDepth(in vec2 screenCoord, in Ray ray, inout Intersections ix) {
  13562. float logDepthOrDepth = czm_unpackDepth(texture(czm_globeDepthTexture, screenCoord));
  13563. float entry;
  13564. float exit;
  13565. if (logDepthOrDepth != 0.0) {
  13566. // Calculate how far the ray must travel before it hits the depth buffer.
  13567. vec4 eyeCoordinateDepth = czm_screenToEyeCoordinates(screenCoord, logDepthOrDepth);
  13568. eyeCoordinateDepth /= eyeCoordinateDepth.w;
  13569. entry = dot(eyeCoordinateDepth.xyz - ray.pos, ray.dir);
  13570. exit = +INF_HIT;
  13571. } else {
  13572. // There's no depth at this location.
  13573. entry = NO_HIT;
  13574. exit = NO_HIT;
  13575. }
  13576. ix.distanceToDepthBuffer = entry;
  13577. #if defined(DEPTH_TEST)
  13578. setIntersectionPair(ix, DEPTH_INTERSECTION_INDEX, vec2(entry, exit));
  13579. #endif
  13580. }
  13581. `;var ndo=y(x(),1),MM=`// See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,
  13582. // NO_HIT, setShapeIntersection
  13583. /* Clipping plane defines (set in Scene/VoxelRenderResources.js)
  13584. #define CLIPPING_PLANES_UNION
  13585. #define CLIPPING_PLANES_COUNT
  13586. #define CLIPPING_PLANES_INTERSECTION_INDEX
  13587. */
  13588. uniform sampler2D u_clippingPlanesTexture;
  13589. uniform mat4 u_clippingPlanesMatrix;
  13590. // Plane is in Hessian Normal Form
  13591. vec4 intersectPlane(in Ray ray, in vec4 plane) {
  13592. vec3 n = plane.xyz; // normal
  13593. float w = plane.w; // -dot(pointOnPlane, normal)
  13594. float a = dot(ray.pos, n);
  13595. float b = dot(ray.dir, n);
  13596. float t = -(w + a) / b;
  13597. return vec4(n, t);
  13598. }
  13599. #ifdef CLIPPING_PLANES
  13600. void intersectClippingPlanes(in Ray ray, inout Intersections ix) {
  13601. vec4 backSide = vec4(-ray.dir, -INF_HIT);
  13602. vec4 farSide = vec4(ray.dir, +INF_HIT);
  13603. RayShapeIntersection clippingVolume;
  13604. #if (CLIPPING_PLANES_COUNT == 1)
  13605. // Union and intersection are the same when there's one clipping plane, and the code
  13606. // is more simplified.
  13607. vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, 0);
  13608. vec4 intersection = intersectPlane(ray, planeUv);
  13609. bool reflects = dot(ray.dir, intersection.xyz) < 0.0;
  13610. clippingVolume.entry = reflects ? backSide : intersection;
  13611. clippingVolume.exit = reflects ? intersection : farSide;
  13612. setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX, clippingVolume);
  13613. #elif defined(CLIPPING_PLANES_UNION)
  13614. vec4 firstTransmission = vec4(ray.dir, +INF_HIT);
  13615. vec4 lastReflection = vec4(-ray.dir, -INF_HIT);
  13616. for (int i = 0; i < CLIPPING_PLANES_COUNT; i++) {
  13617. vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, i);
  13618. vec4 intersection = intersectPlane(ray, planeUv);
  13619. if (dot(ray.dir, planeUv.xyz) > 0.0) {
  13620. firstTransmission = intersection.w <= firstTransmission.w ? intersection : firstTransmission;
  13621. } else {
  13622. lastReflection = intersection.w >= lastReflection.w ? intersection : lastReflection;
  13623. }
  13624. }
  13625. clippingVolume.entry = backSide;
  13626. clippingVolume.exit = lastReflection;
  13627. setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX + 0, clippingVolume);
  13628. clippingVolume.entry = firstTransmission;
  13629. clippingVolume.exit = farSide;
  13630. setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX + 1, clippingVolume);
  13631. #else // intersection
  13632. vec4 lastTransmission = vec4(ray.dir, -INF_HIT);
  13633. vec4 firstReflection = vec4(-ray.dir, +INF_HIT);
  13634. for (int i = 0; i < CLIPPING_PLANES_COUNT; i++) {
  13635. vec4 planeUv = getClippingPlane(u_clippingPlanesTexture, i);
  13636. vec4 intersection = intersectPlane(ray, planeUv);
  13637. if (dot(ray.dir, planeUv.xyz) > 0.0) {
  13638. lastTransmission = intersection.w > lastTransmission.w ? intersection : lastTransmission;
  13639. } else {
  13640. firstReflection = intersection.w < firstReflection.w ? intersection: firstReflection;
  13641. }
  13642. }
  13643. if (lastTransmission.w < firstReflection.w) {
  13644. clippingVolume.entry = lastTransmission;
  13645. clippingVolume.exit = firstReflection;
  13646. } else {
  13647. clippingVolume.entry = vec4(-ray.dir, NO_HIT);
  13648. clippingVolume.exit = vec4(ray.dir, NO_HIT);
  13649. }
  13650. setShapeIntersection(ix, CLIPPING_PLANES_INTERSECTION_INDEX, clippingVolume);
  13651. #endif
  13652. }
  13653. #endif
  13654. `;var odo=y(x(),1),eR=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, INF_HIT,
  13655. // RayShapeIntersection
  13656. vec4 transformNormalToEC(in vec4 intersection) {
  13657. return vec4(normalize(czm_normal * intersection.xyz), intersection.w);
  13658. }
  13659. RayShapeIntersection transformNormalsToEC(in RayShapeIntersection ix) {
  13660. return RayShapeIntersection(transformNormalToEC(ix.entry), transformNormalToEC(ix.exit));
  13661. }
  13662. vec4 intersectLongitude(in Ray ray, in float angle, in bool positiveNormal) {
  13663. float normalSign = positiveNormal ? 1.0 : -1.0;
  13664. vec2 planeNormal = vec2(-sin(angle), cos(angle)) * normalSign;
  13665. vec2 position = ray.pos.xy;
  13666. vec2 direction = ray.dir.xy;
  13667. float approachRate = dot(direction, planeNormal);
  13668. float distance = -dot(position, planeNormal);
  13669. float t = (approachRate == 0.0)
  13670. ? NO_HIT
  13671. : distance / approachRate;
  13672. return vec4(planeNormal, 0.0, t);
  13673. }
  13674. RayShapeIntersection intersectHalfSpace(in Ray ray, in float angle, in bool positiveNormal)
  13675. {
  13676. vec4 intersection = intersectLongitude(ray, angle, positiveNormal);
  13677. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  13678. bool hitFront = (intersection.w > 0.0) == (dot(ray.pos.xy, intersection.xy) > 0.0);
  13679. if (!hitFront) {
  13680. return RayShapeIntersection(intersection, farSide);
  13681. } else {
  13682. return RayShapeIntersection(-1.0 * farSide, intersection);
  13683. }
  13684. }
  13685. void intersectFlippedWedge(in Ray ray, in vec2 minMaxAngle, out RayShapeIntersection intersections[2])
  13686. {
  13687. intersections[0] = transformNormalsToEC(intersectHalfSpace(ray, minMaxAngle.x, false));
  13688. intersections[1] = transformNormalsToEC(intersectHalfSpace(ray, minMaxAngle.y, true));
  13689. }
  13690. bool hitPositiveHalfPlane(in Ray ray, in vec4 intersection, in bool positiveNormal) {
  13691. float normalSign = positiveNormal ? 1.0 : -1.0;
  13692. vec2 planeDirection = vec2(intersection.y, -intersection.x) * normalSign;
  13693. vec2 hit = ray.pos.xy + intersection.w * ray.dir.xy;
  13694. return dot(hit, planeDirection) > 0.0;
  13695. }
  13696. void intersectHalfPlane(in Ray ray, in float angle, out RayShapeIntersection intersections[2]) {
  13697. vec4 intersection = intersectLongitude(ray, angle, true);
  13698. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  13699. bool hitPositiveSide = hitPositiveHalfPlane(ray, intersection, true);
  13700. farSide = transformNormalToEC(farSide);
  13701. if (hitPositiveSide) {
  13702. intersection = transformNormalToEC(intersection);
  13703. intersections[0].entry = -1.0 * farSide;
  13704. intersections[0].exit = vec4(-1.0 * intersection.xyz, intersection.w);
  13705. intersections[1].entry = intersection;
  13706. intersections[1].exit = farSide;
  13707. } else {
  13708. vec4 miss = vec4(normalize(czm_normal * ray.dir), NO_HIT);
  13709. intersections[0].entry = -1.0 * farSide;
  13710. intersections[0].exit = farSide;
  13711. intersections[1].entry = miss;
  13712. intersections[1].exit = miss;
  13713. }
  13714. }
  13715. RayShapeIntersection intersectRegularWedge(in Ray ray, in vec2 minMaxAngle)
  13716. {
  13717. // Note: works for maxAngle > minAngle + pi, where the "regular wedge"
  13718. // is actually a negative volume.
  13719. // Compute intersections with the two planes.
  13720. // Normals will point toward the "outside" (negative space)
  13721. vec4 intersect1 = intersectLongitude(ray, minMaxAngle.x, false);
  13722. vec4 intersect2 = intersectLongitude(ray, minMaxAngle.y, true);
  13723. // Choose intersection with smallest T as the "first", the other as "last"
  13724. // Note: first or last could be in the "shadow" wedge, beyond the tip
  13725. bool inOrder = intersect1.w <= intersect2.w;
  13726. vec4 first = inOrder ? intersect1 : intersect2;
  13727. vec4 last = inOrder ? intersect2 : intersect1;
  13728. bool firstIsAhead = first.w >= 0.0;
  13729. bool startedInsideFirst = dot(ray.pos.xy, first.xy) < 0.0;
  13730. bool exitFromInside = firstIsAhead == startedInsideFirst;
  13731. bool lastIsAhead = last.w > 0.0;
  13732. bool startedOutsideLast = dot(ray.pos.xy, last.xy) >= 0.0;
  13733. bool enterFromOutside = lastIsAhead == startedOutsideLast;
  13734. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  13735. vec4 miss = vec4(normalize(ray.dir), NO_HIT);
  13736. if (exitFromInside && enterFromOutside) {
  13737. // Ray crosses both faces of negative wedge, exiting then entering the positive shape
  13738. return transformNormalsToEC(RayShapeIntersection(first, last));
  13739. } else if (!exitFromInside && enterFromOutside) {
  13740. // Ray starts inside wedge. last is in shadow wedge, and first is actually the entry
  13741. return transformNormalsToEC(RayShapeIntersection(-1.0 * farSide, first));
  13742. } else if (exitFromInside && !enterFromOutside) {
  13743. // First intersection was in the shadow wedge, so last is actually the exit
  13744. return transformNormalsToEC(RayShapeIntersection(last, farSide));
  13745. } else { // !exitFromInside && !enterFromOutside
  13746. // Both intersections were in the shadow wedge
  13747. return transformNormalsToEC(RayShapeIntersection(miss, miss));
  13748. }
  13749. }
  13750. `;var sdo=y(x(),1),vM=`// See IntersectionUtils.glsl for the definitions of Ray, RayShapeIntersection,
  13751. // NO_HIT, Intersections
  13752. /* Box defines (set in Scene/VoxelBoxShape.js)
  13753. #define BOX_INTERSECTION_INDEX ### // always 0
  13754. */
  13755. uniform sampler2D u_renderBoundPlanesTexture;
  13756. RayShapeIntersection intersectBoundPlanes(in Ray ray) {
  13757. vec4 lastEntry = vec4(ray.dir, -INF_HIT);
  13758. vec4 firstExit = vec4(-ray.dir, +INF_HIT);
  13759. for (int i = 0; i < 6; i++) {
  13760. vec4 boundPlane = getBoundPlane(u_renderBoundPlanesTexture, i);
  13761. vec4 intersection = intersectPlane(ray, boundPlane);
  13762. if (dot(ray.dir, boundPlane.xyz) < 0.0) {
  13763. lastEntry = intersection.w > lastEntry.w ? intersection : lastEntry;
  13764. } else {
  13765. firstExit = intersection.w < firstExit.w ? intersection: firstExit;
  13766. }
  13767. }
  13768. if (lastEntry.w < firstExit.w) {
  13769. return RayShapeIntersection(lastEntry, firstExit);
  13770. } else {
  13771. return RayShapeIntersection(vec4(-ray.dir, NO_HIT), vec4(ray.dir, NO_HIT));
  13772. }
  13773. }
  13774. void intersectShape(in Ray rayUV, in Ray rayEC, inout Intersections ix)
  13775. {
  13776. RayShapeIntersection intersection = intersectBoundPlanes(rayEC);
  13777. setShapeIntersection(ix, BOX_INTERSECTION_INDEX, intersection);
  13778. }
  13779. `;var cdo=y(x(),1),UM=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, Intersections,
  13780. // RayShapeIntersection, setSurfaceIntersection, setShapeIntersection,
  13781. // intersectIntersections
  13782. // See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
  13783. // intersectFlippedWedge, intersectRegularWedge
  13784. /* Cylinder defines (set in Scene/VoxelCylinderShape.js)
  13785. #define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN
  13786. #define CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT
  13787. #define CYLINDER_HAS_RENDER_BOUNDS_ANGLE
  13788. #define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF
  13789. #define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF
  13790. #define CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO
  13791. #define CYLINDER_INTERSECTION_INDEX_RADIUS_MAX
  13792. #define CYLINDER_INTERSECTION_INDEX_RADIUS_MIN
  13793. #define CYLINDER_INTERSECTION_INDEX_ANGLE
  13794. */
  13795. // Cylinder uniforms
  13796. uniform vec2 u_cylinderRenderRadiusMinMax;
  13797. #if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE)
  13798. uniform vec2 u_cylinderRenderAngleMinMax;
  13799. #endif
  13800. uniform sampler2D u_renderBoundPlanesTexture;
  13801. RayShapeIntersection intersectBoundPlanes(in Ray ray) {
  13802. vec4 lastEntry = vec4(ray.dir, -INF_HIT);
  13803. vec4 firstExit = vec4(-ray.dir, +INF_HIT);
  13804. for (int i = 0; i < 2; i++) {
  13805. vec4 boundPlane = getBoundPlane(u_renderBoundPlanesTexture, i);
  13806. vec4 intersection = intersectPlane(ray, boundPlane);
  13807. if (dot(ray.dir, boundPlane.xyz) < 0.0) {
  13808. lastEntry = intersection.w > lastEntry.w ? intersection : lastEntry;
  13809. } else {
  13810. firstExit = intersection.w < firstExit.w ? intersection: firstExit;
  13811. }
  13812. }
  13813. if (lastEntry.w < firstExit.w) {
  13814. return RayShapeIntersection(lastEntry, firstExit);
  13815. } else {
  13816. return RayShapeIntersection(vec4(-ray.dir, NO_HIT), vec4(ray.dir, NO_HIT));
  13817. }
  13818. }
  13819. /**
  13820. * Find the intersection of a ray with a right cylindrical surface of a given radius
  13821. * about the z-axis.
  13822. */
  13823. RayShapeIntersection intersectCylinder(in Ray ray, in float radius, in bool convex)
  13824. {
  13825. vec2 position = ray.pos.xy;
  13826. vec2 direction = ray.dir.xy;
  13827. float a = dot(direction, direction);
  13828. float b = dot(position, direction);
  13829. float c = dot(position, position) - radius * radius;
  13830. float determinant = b * b - a * c;
  13831. if (determinant < 0.0) {
  13832. vec4 miss = vec4(normalize(ray.dir), NO_HIT);
  13833. return RayShapeIntersection(miss, miss);
  13834. }
  13835. determinant = sqrt(determinant);
  13836. float t1 = (-b - determinant) / a;
  13837. float t2 = (-b + determinant) / a;
  13838. float signFlip = convex ? 1.0 : -1.0;
  13839. vec3 normal1 = vec3((position + t1 * direction) * signFlip, 0.0);
  13840. vec3 normal2 = vec3((position + t2 * direction) * signFlip, 0.0);
  13841. // Return normals in eye coordinates
  13842. vec4 intersect1 = vec4(normalize(czm_normal * normal1), t1);
  13843. vec4 intersect2 = vec4(normalize(czm_normal * normal2), t2);
  13844. return RayShapeIntersection(intersect1, intersect2);
  13845. }
  13846. /**
  13847. * Find the intersection of a ray with a right cylindrical solid of given
  13848. * radius and height bounds. NOTE: The shape is assumed to be convex.
  13849. */
  13850. RayShapeIntersection intersectBoundedCylinder(in Ray ray, in Ray rayEC, in float radius)
  13851. {
  13852. RayShapeIntersection cylinderIntersection = intersectCylinder(ray, radius, true);
  13853. RayShapeIntersection heightBoundsIntersection = intersectBoundPlanes(rayEC);
  13854. return intersectIntersections(ray, cylinderIntersection, heightBoundsIntersection);
  13855. }
  13856. void intersectShape(in Ray ray, in Ray rayEC, inout Intersections ix)
  13857. {
  13858. RayShapeIntersection outerIntersect = intersectBoundedCylinder(ray, rayEC, u_cylinderRenderRadiusMinMax.y);
  13859. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MAX, outerIntersect);
  13860. if (outerIntersect.entry.w == NO_HIT) {
  13861. return;
  13862. }
  13863. #if defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_FLAT)
  13864. // When the cylinder is perfectly thin it's necessary to sandwich the
  13865. // inner cylinder intersection inside the outer cylinder intersection.
  13866. // Without this special case,
  13867. // [outerMin, outerMax, innerMin, innerMax] will bubble sort to
  13868. // [outerMin, innerMin, outerMax, innerMax] which will cause the back
  13869. // side of the cylinder to be invisible because it will think the ray
  13870. // is still inside the inner (negative) cylinder after exiting the
  13871. // outer (positive) cylinder.
  13872. // With this special case,
  13873. // [outerMin, innerMin, innerMax, outerMax] will bubble sort to
  13874. // [outerMin, innerMin, innerMax, outerMax] which will work correctly.
  13875. // Note: If initializeIntersections() changes its sorting function
  13876. // from bubble sort to something else, this code may need to change.
  13877. RayShapeIntersection innerIntersect = intersectCylinder(ray, 1.0, false);
  13878. setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter
  13879. setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter
  13880. setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit
  13881. setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit
  13882. #elif defined(CYLINDER_HAS_RENDER_BOUNDS_RADIUS_MIN)
  13883. RayShapeIntersection innerIntersect = intersectCylinder(ray, u_cylinderRenderRadiusMinMax.x, false);
  13884. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_RADIUS_MIN, innerIntersect);
  13885. #endif
  13886. #if defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_UNDER_HALF)
  13887. RayShapeIntersection wedgeIntersect = intersectRegularWedge(ray, u_cylinderRenderAngleMinMax);
  13888. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE, wedgeIntersect);
  13889. #elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_OVER_HALF)
  13890. RayShapeIntersection wedgeIntersects[2];
  13891. intersectFlippedWedge(ray, u_cylinderRenderAngleMinMax, wedgeIntersects);
  13892. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]);
  13893. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]);
  13894. #elif defined(CYLINDER_HAS_RENDER_BOUNDS_ANGLE_RANGE_EQUAL_ZERO)
  13895. RayShapeIntersection wedgeIntersects[2];
  13896. intersectHalfPlane(ray, u_cylinderRenderAngleMinMax.x, wedgeIntersects);
  13897. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 0, wedgeIntersects[0]);
  13898. setShapeIntersection(ix, CYLINDER_INTERSECTION_INDEX_ANGLE + 1, wedgeIntersects[1]);
  13899. #endif
  13900. }
  13901. `;var ddo=y(x(),1),DM=`// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT, INF_HIT, Intersections,
  13902. // RayShapeIntersection, setSurfaceIntersection, setShapeIntersection
  13903. // See IntersectLongitude.glsl for the definitions of intersectHalfPlane,
  13904. // intersectFlippedWedge, intersectRegularWedge
  13905. /* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)
  13906. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE
  13907. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO
  13908. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF
  13909. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF
  13910. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF
  13911. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF
  13912. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF
  13913. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF
  13914. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF
  13915. #define ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF
  13916. #define ELLIPSOID_INTERSECTION_INDEX_LONGITUDE
  13917. #define ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX
  13918. #define ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN
  13919. #define ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX
  13920. #define ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN
  13921. */
  13922. #if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE)
  13923. uniform vec2 u_ellipsoidRenderLongitudeMinMax;
  13924. #endif
  13925. uniform float u_eccentricitySquared;
  13926. uniform vec2 u_ellipsoidRenderLatitudeSinMinMax;
  13927. uniform vec2 u_clipMinMaxHeight; // Values are negative: clipHeight - maxShapeHeight
  13928. RayShapeIntersection intersectZPlane(in Ray ray, in float z) {
  13929. float t = -ray.pos.z / ray.dir.z;
  13930. bool startsOutside = sign(ray.pos.z) == sign(z);
  13931. bool entry = (t >= 0.0) != startsOutside;
  13932. vec4 intersect = vec4(0.0, 0.0, z, t);
  13933. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  13934. if (entry) {
  13935. return RayShapeIntersection(intersect, farSide);
  13936. } else {
  13937. return RayShapeIntersection(-1.0 * farSide, intersect);
  13938. }
  13939. }
  13940. RayShapeIntersection intersectHeight(in Ray ray, in float height, in bool convex)
  13941. {
  13942. // Scale the ray by the ellipsoid axes to make it a unit sphere
  13943. // Note: approximating ellipsoid + height as an ellipsoid
  13944. vec3 radiiCorrection = vec3(1.0) / (u_ellipsoidRadii + height);
  13945. vec3 position = ray.pos * radiiCorrection;
  13946. vec3 direction = ray.dir * radiiCorrection;
  13947. float a = dot(direction, direction); // ~ 1.0 (or maybe 4.0 if ray is scaled)
  13948. float b = dot(direction, position); // roughly inside [-1.0, 1.0] when zoomed in
  13949. float c = dot(position, position) - 1.0; // ~ 0.0 when zoomed in.
  13950. float determinant = b * b - a * c; // ~ b * b when zoomed in
  13951. if (determinant < 0.0) {
  13952. vec4 miss = vec4(normalize(direction), NO_HIT);
  13953. return RayShapeIntersection(miss, miss);
  13954. }
  13955. determinant = sqrt(determinant);
  13956. // Compute larger root using standard formula
  13957. float signB = b < 0.0 ? -1.0 : 1.0;
  13958. // The other root may suffer from subtractive cancellation in the standard formula.
  13959. // Compute it from the first root instead.
  13960. float t1 = (-b - signB * determinant) / a;
  13961. float t2 = c / (a * t1);
  13962. float tmin = min(t1, t2);
  13963. float tmax = max(t1, t2);
  13964. float directionScale = convex ? 1.0 : -1.0;
  13965. vec3 d1 = directionScale * (position + tmin * direction);
  13966. vec3 d2 = directionScale * (position + tmax * direction);
  13967. // Return normals in eye coordinates. Use spherical approximation for the normal.
  13968. vec3 normal1 = normalize(czm_normal * d1);
  13969. vec3 normal2 = normalize(czm_normal * d2);
  13970. return RayShapeIntersection(vec4(normal1, tmin), vec4(normal2, tmax));
  13971. }
  13972. /**
  13973. * Given a circular cone around the z-axis, with apex at the origin,
  13974. * find the parametric distance(s) along a ray where that ray intersects
  13975. * the cone.
  13976. * The cone opening angle is described by the squared cosine of
  13977. * its half-angle (the angle between the Z-axis and the surface)
  13978. */
  13979. vec2 intersectDoubleEndedCone(in Ray ray, in float cosSqrHalfAngle)
  13980. {
  13981. vec3 o = ray.pos;
  13982. vec3 d = ray.dir;
  13983. float sinSqrHalfAngle = 1.0 - cosSqrHalfAngle;
  13984. float aSin = d.z * d.z * sinSqrHalfAngle;
  13985. float aCos = -dot(d.xy, d.xy) * cosSqrHalfAngle;
  13986. float a = aSin + aCos;
  13987. float bSin = d.z * o.z * sinSqrHalfAngle;
  13988. float bCos = -dot(o.xy, d.xy) * cosSqrHalfAngle;
  13989. float b = bSin + bCos;
  13990. float cSin = o.z * o.z * sinSqrHalfAngle;
  13991. float cCos = -dot(o.xy, o.xy) * cosSqrHalfAngle;
  13992. float c = cSin + cCos;
  13993. // determinant = b * b - a * c. But bSin * bSin = aSin * cSin.
  13994. // Avoid subtractive cancellation by expanding to eliminate these terms
  13995. float determinant = 2.0 * bSin * bCos + bCos * bCos - aSin * cCos - aCos * cSin - aCos * cCos;
  13996. if (determinant < 0.0) {
  13997. return vec2(NO_HIT);
  13998. } else if (a == 0.0) {
  13999. // Ray is parallel to cone surface
  14000. return (b == 0.0)
  14001. ? vec2(NO_HIT) // Ray is on cone surface
  14002. : vec2(-0.5 * c / b, NO_HIT);
  14003. }
  14004. determinant = sqrt(determinant);
  14005. // Compute larger root using standard formula
  14006. float signB = b < 0.0 ? -1.0 : 1.0;
  14007. float t1 = (-b - signB * determinant) / a;
  14008. // The other root may suffer from subtractive cancellation in the standard formula.
  14009. // Compute it from the first root instead.
  14010. float t2 = c / (a * t1);
  14011. float tmin = min(t1, t2);
  14012. float tmax = max(t1, t2);
  14013. return vec2(tmin, tmax);
  14014. }
  14015. /**
  14016. * Given a point on a conical surface, find the surface normal at that point.
  14017. */
  14018. vec3 getConeNormal(in vec3 p, in bool convex) {
  14019. // Start with radial component pointing toward z-axis
  14020. vec2 radial = -abs(p.z) * normalize(p.xy);
  14021. // Z component points toward opening of cone
  14022. float zSign = (p.z < 0.0) ? -1.0 : 1.0;
  14023. float z = length(p.xy) * zSign;
  14024. // Flip normal if shape is convex
  14025. float flip = (convex) ? -1.0 : 1.0;
  14026. return normalize(vec3(radial, z) * flip);
  14027. }
  14028. /**
  14029. * Compute the shift between the ellipsoid origin and the apex of a cone of latitude
  14030. */
  14031. float getLatitudeConeShift(in float sinLatitude) {
  14032. // Find prime vertical radius of curvature:
  14033. // the distance along the ellipsoid normal to the intersection with the z-axis
  14034. float x2 = u_eccentricitySquared * sinLatitude * sinLatitude;
  14035. float primeVerticalRadius = u_ellipsoidRadii.x * inversesqrt(1.0 - x2);
  14036. // Compute a shift from the origin to the intersection of the cone with the z-axis
  14037. return primeVerticalRadius * u_eccentricitySquared * sinLatitude;
  14038. }
  14039. void intersectFlippedCone(in Ray ray, in float cosHalfAngle, out RayShapeIntersection intersections[2]) {
  14040. // Shift the ray to account for the latitude cone not being centered at the Earth center
  14041. ray.pos.z += getLatitudeConeShift(cosHalfAngle);
  14042. float cosSqrHalfAngle = cosHalfAngle * cosHalfAngle;
  14043. vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
  14044. vec4 miss = vec4(normalize(ray.dir), NO_HIT);
  14045. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  14046. // Initialize output with no intersections
  14047. intersections[0].entry = -1.0 * farSide;
  14048. intersections[0].exit = farSide;
  14049. intersections[1].entry = miss;
  14050. intersections[1].exit = miss;
  14051. if (intersect.x == NO_HIT) {
  14052. return;
  14053. }
  14054. // Find the points of intersection
  14055. float tmin = intersect.x;
  14056. float tmax = intersect.y;
  14057. vec3 p0 = ray.pos + tmin * ray.dir;
  14058. vec3 p1 = ray.pos + tmax * ray.dir;
  14059. vec4 intersect0 = vec4(getConeNormal(p0, true), tmin);
  14060. vec4 intersect1 = vec4(getConeNormal(p1, true), tmax);
  14061. bool p0InShadowCone = sign(p0.z) != sign(cosHalfAngle);
  14062. bool p1InShadowCone = sign(p1.z) != sign(cosHalfAngle);
  14063. if (p0InShadowCone && p1InShadowCone) {
  14064. // no valid intersections
  14065. } else if (p0InShadowCone) {
  14066. intersections[0].exit = intersect1;
  14067. } else if (p1InShadowCone) {
  14068. intersections[0].entry = intersect0;
  14069. } else {
  14070. intersections[0].exit = intersect0;
  14071. intersections[1].entry = intersect1;
  14072. intersections[1].exit = farSide;
  14073. }
  14074. }
  14075. RayShapeIntersection intersectRegularCone(in Ray ray, in float cosHalfAngle, in bool convex) {
  14076. // Shift the ray to account for the latitude cone not being centered at the Earth center
  14077. ray.pos.z += getLatitudeConeShift(cosHalfAngle);
  14078. float cosSqrHalfAngle = cosHalfAngle * cosHalfAngle;
  14079. vec2 intersect = intersectDoubleEndedCone(ray, cosSqrHalfAngle);
  14080. vec4 miss = vec4(normalize(ray.dir), NO_HIT);
  14081. vec4 farSide = vec4(normalize(ray.dir), INF_HIT);
  14082. if (intersect.x == NO_HIT) {
  14083. return RayShapeIntersection(miss, miss);
  14084. }
  14085. // Find the points of intersection
  14086. float tmin = intersect.x;
  14087. float tmax = intersect.y;
  14088. vec3 p0 = ray.pos + tmin * ray.dir;
  14089. vec3 p1 = ray.pos + tmax * ray.dir;
  14090. vec4 intersect0 = vec4(getConeNormal(p0, convex), tmin);
  14091. vec4 intersect1 = vec4(getConeNormal(p1, convex), tmax);
  14092. bool p0InShadowCone = sign(p0.z) != sign(cosHalfAngle);
  14093. bool p1InShadowCone = sign(p1.z) != sign(cosHalfAngle);
  14094. if (p0InShadowCone && p1InShadowCone) {
  14095. return RayShapeIntersection(miss, miss);
  14096. } else if (p0InShadowCone) {
  14097. return RayShapeIntersection(intersect1, farSide);
  14098. } else if (p1InShadowCone) {
  14099. return RayShapeIntersection(-1.0 * farSide, intersect0);
  14100. } else {
  14101. return RayShapeIntersection(intersect0, intersect1);
  14102. }
  14103. }
  14104. void intersectShape(in Ray ray, in Ray rayEC, inout Intersections ix) { // Outer ellipsoid
  14105. RayShapeIntersection outerIntersect = intersectHeight(ray, u_clipMinMaxHeight.y, true);
  14106. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MAX, outerIntersect);
  14107. // Exit early if the outer ellipsoid was missed.
  14108. if (outerIntersect.entry.w == NO_HIT) {
  14109. return;
  14110. }
  14111. // Inner ellipsoid
  14112. RayShapeIntersection innerIntersect = intersectHeight(ray, u_clipMinMaxHeight.x, false);
  14113. if (innerIntersect.entry.w == NO_HIT) {
  14114. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_HEIGHT_MIN, innerIntersect);
  14115. } else {
  14116. // When the ellipsoid is large and thin it's possible for floating point math
  14117. // to cause the ray to intersect the inner ellipsoid before the outer ellipsoid.
  14118. // To prevent this from happening, clamp innerIntersect to outerIntersect and
  14119. // sandwich the inner ellipsoid intersection inside the outer ellipsoid intersection.
  14120. // Without this special case,
  14121. // [outerMin, outerMax, innerMin, innerMax] will bubble sort to
  14122. // [outerMin, innerMin, outerMax, innerMax] which will cause the back
  14123. // side of the ellipsoid to be invisible because it will think the ray
  14124. // is still inside the inner (negative) ellipsoid after exiting the
  14125. // outer (positive) ellipsoid.
  14126. // With this special case,
  14127. // [outerMin, innerMin, innerMax, outerMax] will bubble sort to
  14128. // [outerMin, innerMin, innerMax, outerMax] which will work correctly.
  14129. // Note: If initializeIntersections() changes its sorting function
  14130. // from bubble sort to something else, this code may need to change.
  14131. innerIntersect.entry.w = max(innerIntersect.entry.w, outerIntersect.entry.w);
  14132. innerIntersect.exit.w = min(innerIntersect.exit.w, outerIntersect.exit.w);
  14133. setSurfaceIntersection(ix, 0, outerIntersect.entry, true, true); // positive, enter
  14134. setSurfaceIntersection(ix, 1, innerIntersect.entry, false, true); // negative, enter
  14135. setSurfaceIntersection(ix, 2, innerIntersect.exit, false, false); // negative, exit
  14136. setSurfaceIntersection(ix, 3, outerIntersect.exit, true, false); // positive, exit
  14137. }
  14138. // Bottom cone
  14139. #if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_UNDER_HALF)
  14140. RayShapeIntersection bottomConeIntersection = intersectRegularCone(ray, u_ellipsoidRenderLatitudeSinMinMax.x, false);
  14141. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection);
  14142. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_EQUAL_HALF)
  14143. RayShapeIntersection bottomConeIntersection = intersectZPlane(ray, -1.0);
  14144. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN, bottomConeIntersection);
  14145. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MIN_OVER_HALF)
  14146. RayShapeIntersection bottomConeIntersections[2];
  14147. intersectFlippedCone(ray, u_ellipsoidRenderLatitudeSinMinMax.x, bottomConeIntersections);
  14148. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 0, bottomConeIntersections[0]);
  14149. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MIN + 1, bottomConeIntersections[1]);
  14150. #endif
  14151. // Top cone
  14152. #if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_UNDER_HALF)
  14153. RayShapeIntersection topConeIntersections[2];
  14154. intersectFlippedCone(ray, u_ellipsoidRenderLatitudeSinMinMax.y, topConeIntersections);
  14155. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 0, topConeIntersections[0]);
  14156. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX + 1, topConeIntersections[1]);
  14157. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_EQUAL_HALF)
  14158. RayShapeIntersection topConeIntersection = intersectZPlane(ray, 1.0);
  14159. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection);
  14160. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LATITUDE_MAX_OVER_HALF)
  14161. RayShapeIntersection topConeIntersection = intersectRegularCone(ray, u_ellipsoidRenderLatitudeSinMinMax.y, false);
  14162. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LATITUDE_MAX, topConeIntersection);
  14163. #endif
  14164. // Wedge
  14165. #if defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_EQUAL_ZERO)
  14166. RayShapeIntersection wedgeIntersects[2];
  14167. intersectHalfPlane(ray, u_ellipsoidRenderLongitudeMinMax.x, wedgeIntersects);
  14168. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersects[0]);
  14169. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersects[1]);
  14170. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_UNDER_HALF)
  14171. RayShapeIntersection wedgeIntersect = intersectRegularWedge(ray, u_ellipsoidRenderLongitudeMinMax);
  14172. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE, wedgeIntersect);
  14173. #elif defined(ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_RANGE_OVER_HALF)
  14174. RayShapeIntersection wedgeIntersects[2];
  14175. intersectFlippedWedge(ray, u_ellipsoidRenderLongitudeMinMax, wedgeIntersects);
  14176. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 0, wedgeIntersects[0]);
  14177. setShapeIntersection(ix, ELLIPSOID_INTERSECTION_INDEX_LONGITUDE + 1, wedgeIntersects[1]);
  14178. #endif
  14179. }
  14180. `;var mdo=y(x(),1),RE=`// Main intersection function for Voxel scenes.
  14181. // See IntersectBox.glsl, IntersectCylinder.glsl, or IntersectEllipsoid.glsl
  14182. // for the definition of intersectShape. The appropriate function is selected
  14183. // based on the VoxelPrimitive shape type, and added to the shader in
  14184. // Scene/VoxelRenderResources.js.
  14185. // See also IntersectClippingPlane.glsl and IntersectDepth.glsl.
  14186. // See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,
  14187. // getFirstIntersection, initializeIntersections, nextIntersection.
  14188. /* Intersection defines (set in Scene/VoxelRenderResources.js)
  14189. #define INTERSECTION_COUNT ###
  14190. */
  14191. RayShapeIntersection intersectScene(in vec2 screenCoord, in Ray ray, in Ray rayEC, out Intersections ix) {
  14192. // Do a ray-shape intersection to find the exact starting and ending points.
  14193. intersectShape(ray, rayEC, ix);
  14194. // Exit early if the positive shape was completely missed or behind the ray.
  14195. RayShapeIntersection intersection = getFirstIntersection(ix);
  14196. if (intersection.entry.w == NO_HIT) {
  14197. // Positive shape was completely missed - so exit early.
  14198. return intersection;
  14199. }
  14200. // Clipping planes
  14201. #if defined(CLIPPING_PLANES)
  14202. intersectClippingPlanes(ray, ix);
  14203. #endif
  14204. // Depth
  14205. intersectDepth(screenCoord, rayEC, ix);
  14206. // Find the first intersection that's in front of the ray
  14207. #if (INTERSECTION_COUNT > 1)
  14208. initializeIntersections(ix);
  14209. for (int i = 0; i < INTERSECTION_COUNT; ++i) {
  14210. intersection = nextIntersection(ix);
  14211. if (intersection.exit.w > 0.0) {
  14212. // Set start to 0.0 when ray is inside the shape.
  14213. intersection.entry.w = max(intersection.entry.w, 0.0);
  14214. break;
  14215. }
  14216. }
  14217. #else
  14218. // Set start to 0.0 when ray is inside the shape.
  14219. intersection.entry.w = max(intersection.entry.w, 0.0);
  14220. #endif
  14221. return intersection;
  14222. }
  14223. `;var fdo=y(x(),1),kM=`uniform vec3 u_boxLocalToShapeUvScale;
  14224. uniform vec3 u_boxLocalToShapeUvTranslate;
  14225. uniform ivec4 u_cameraTileCoordinates;
  14226. uniform vec3 u_cameraTileUv;
  14227. uniform mat3 u_boxEcToXyz;
  14228. mat3 convertLocalToShapeSpaceDerivative(in vec3 positionLocal) {
  14229. // For BOX, local space = shape space, so the Jacobian is the identity matrix.
  14230. return mat3(1.0);
  14231. }
  14232. vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {
  14233. return shapeUv / u_boxLocalToShapeUvScale;
  14234. }
  14235. vec3 convertEcToDeltaTile(in vec3 positionEC) {
  14236. vec3 dPosition = u_boxEcToXyz * positionEC;
  14237. return u_boxLocalToShapeUvScale * dPosition * float(1 << u_cameraTileCoordinates.w);
  14238. }
  14239. TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {
  14240. vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);
  14241. vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;
  14242. ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));
  14243. tileCoordinate = min(max(ivec3(0), tileCoordinate), ivec3((1 << u_cameraTileCoordinates.w) - 1));
  14244. ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
  14245. vec3 tileUv = clamp(tileUvSum - vec3(tileCoordinateChange), 0.0, 1.0);
  14246. return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);
  14247. }
  14248. `;var Ado=y(x(),1),QM=`uniform vec2 u_cylinderLocalToShapeUvRadius; // x = scale, y = offset
  14249. uniform vec2 u_cylinderLocalToShapeUvHeight; // x = scale, y = offset
  14250. uniform vec2 u_cylinderLocalToShapeUvAngle; // x = scale, y = offset
  14251. uniform float u_cylinderShapeUvAngleRangeOrigin;
  14252. uniform mat3 u_cylinderEcToRadialTangentUp;
  14253. uniform ivec4 u_cameraTileCoordinates;
  14254. uniform vec3 u_cameraTileUv;
  14255. uniform vec3 u_cameraShapePosition; // (radial distance, angle, height) of camera in shape space
  14256. mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {
  14257. vec3 radial = normalize(vec3(position.xy, 0.0));
  14258. vec3 z = vec3(0.0, 0.0, 1.0);
  14259. vec3 east = normalize(vec3(-position.y, position.x, 0.0));
  14260. return mat3(radial, east / length(position.xy), z);
  14261. }
  14262. vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {
  14263. float radius = shapeUv.x / u_cylinderLocalToShapeUvRadius.x;
  14264. float angle = shapeUv.y * czm_twoPi / u_cylinderLocalToShapeUvAngle.x;
  14265. float height = shapeUv.z / u_cylinderLocalToShapeUvHeight.x;
  14266. return vec3(radius, angle, height);
  14267. }
  14268. /**
  14269. * Computes the change in polar coordinates given a change in position.
  14270. * @param {vec2} dPosition The change in position in Cartesian coordinates.
  14271. * @param {float} cameraRadialDistance The radial distance of the camera from the origin.
  14272. * @return {vec2} The change in polar coordinates (radial distance, angle).
  14273. */
  14274. vec2 computePolarChange(in vec2 dPosition, in float cameraRadialDistance) {
  14275. float dAngle = atan(dPosition.y, cameraRadialDistance + dPosition.x);
  14276. // Find the direction of the radial axis at the output angle, in Cartesian coordinates
  14277. vec2 outputRadialAxis = vec2(cos(dAngle), sin(dAngle));
  14278. float sinHalfAngle = sin(dAngle / 2.0);
  14279. float versine = 2.0 * sinHalfAngle * sinHalfAngle;
  14280. float dRadial = dot(dPosition, outputRadialAxis) - cameraRadialDistance * versine;
  14281. return vec2(dRadial, dAngle);
  14282. }
  14283. vec3 convertEcToDeltaShape(in vec3 positionEC) {
  14284. // 1. Rotate to radial, tangent, and up coordinates
  14285. vec3 rtu = u_cylinderEcToRadialTangentUp * positionEC;
  14286. // 2. Compute change in angular and radial coordinates.
  14287. vec2 dPolar = computePolarChange(rtu.xy, u_cameraShapePosition.x);
  14288. return vec3(dPolar.xy, rtu.z);
  14289. }
  14290. vec3 convertEcToDeltaTile(in vec3 positionEC) {
  14291. vec3 deltaShape = convertEcToDeltaShape(positionEC);
  14292. // Convert to tileset coordinates in [0, 1]
  14293. float dx = u_cylinderLocalToShapeUvRadius.x * deltaShape.x;
  14294. float dy = deltaShape.y / czm_twoPi;
  14295. #if defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE)
  14296. // Wrap to ensure dy is not crossing through the unoccupied angle range, where
  14297. // angle to tile coordinate conversions would be more complicated
  14298. float cameraUvAngle = (u_cameraShapePosition.y + czm_pi) / czm_twoPi;
  14299. float cameraUvAngleShift = fract(cameraUvAngle - u_cylinderShapeUvAngleRangeOrigin);
  14300. float rawOutputUvAngle = cameraUvAngleShift + dy;
  14301. float rotation = floor(rawOutputUvAngle);
  14302. dy -= rotation;
  14303. #endif
  14304. dy *= u_cylinderLocalToShapeUvAngle.x;
  14305. float dz = u_cylinderLocalToShapeUvHeight.x * deltaShape.z;
  14306. // Convert to tile coordinate changes
  14307. return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);
  14308. }
  14309. TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {
  14310. vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);
  14311. vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;
  14312. ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));
  14313. int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;
  14314. tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);
  14315. tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);
  14316. #if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))
  14317. ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
  14318. if (tileCoordinate.y < 0) {
  14319. tileCoordinate.y += (maxTileCoordinate + 1);
  14320. } else if (tileCoordinate.y > maxTileCoordinate) {
  14321. tileCoordinate.y -= (maxTileCoordinate + 1);
  14322. }
  14323. #else
  14324. tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);
  14325. ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
  14326. #endif
  14327. vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);
  14328. tileUv.x = clamp(tileUv.x, 0.0, 1.0);
  14329. #if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))
  14330. // If there is only one tile spanning 2*PI angle, the coordinate wraps around
  14331. tileUv.y = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.y) : clamp(tileUv.y, 0.0, 1.0);
  14332. #else
  14333. tileUv.y = clamp(tileUv.y, 0.0, 1.0);
  14334. #endif
  14335. tileUv.z = clamp(tileUv.z, 0.0, 1.0);
  14336. return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);
  14337. }
  14338. `;var bdo=y(x(),1),OM=`/* Ellipsoid defines (set in Scene/VoxelEllipsoidShape.js)
  14339. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MIN_DISCONTINUITY
  14340. #define ELLIPSOID_HAS_RENDER_BOUNDS_LONGITUDE_MAX_DISCONTINUITY
  14341. #define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE
  14342. #define ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE_MIN_MAX_REVERSED
  14343. #define ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE
  14344. */
  14345. uniform vec3 u_cameraPositionCartographic; // (longitude, latitude, height) in radians and meters
  14346. uniform vec2 u_ellipsoidCurvatureAtLatitude;
  14347. uniform mat3 u_ellipsoidEcToEastNorthUp;
  14348. uniform vec3 u_ellipsoidRadii;
  14349. uniform vec2 u_evoluteScale; // (radii.x ^ 2 - radii.z ^ 2) * vec2(1.0, -1.0) / radii;
  14350. uniform vec3 u_ellipsoidInverseRadiiSquared;
  14351. #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)
  14352. uniform vec3 u_ellipsoidShapeUvLongitudeMinMaxMid;
  14353. #endif
  14354. #if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
  14355. uniform vec2 u_ellipsoidLocalToShapeUvLongitude; // x = scale, y = offset
  14356. uniform float u_ellipsoidShapeUvLongitudeRangeOrigin;
  14357. #endif
  14358. #if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
  14359. uniform vec2 u_ellipsoidLocalToShapeUvLatitude; // x = scale, y = offset
  14360. #endif
  14361. uniform float u_ellipsoidInverseHeightDifference;
  14362. uniform ivec4 u_cameraTileCoordinates;
  14363. uniform vec3 u_cameraTileUv;
  14364. // robust iterative solution without trig functions
  14365. // https://github.com/0xfaded/ellipse_demo/issues/1
  14366. // https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
  14367. // Extended to return radius of curvature along with the point
  14368. vec3 nearestPointAndRadiusOnEllipse(vec2 pos, vec2 radii) {
  14369. vec2 p = abs(pos);
  14370. vec2 inverseRadii = 1.0 / radii;
  14371. // We describe the ellipse parametrically: v = radii * vec2(cos(t), sin(t))
  14372. // but store the cos and sin of t in a vec2 for efficiency.
  14373. // Initial guess: t = pi/4
  14374. vec2 tTrigs = vec2(0.7071067811865476);
  14375. // Initial guess of point on ellipsoid
  14376. vec2 v = radii * tTrigs;
  14377. // Center of curvature of the ellipse at v
  14378. vec2 evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;
  14379. const int iterations = 3;
  14380. for (int i = 0; i < iterations; ++i) {
  14381. // Find the (approximate) intersection of p - evolute with the ellipsoid.
  14382. vec2 q = normalize(p - evolute) * length(v - evolute);
  14383. // Update the estimate of t.
  14384. tTrigs = (q + evolute) * inverseRadii;
  14385. tTrigs = normalize(clamp(tTrigs, 0.0, 1.0));
  14386. v = radii * tTrigs;
  14387. evolute = u_evoluteScale * tTrigs * tTrigs * tTrigs;
  14388. }
  14389. return vec3(v * sign(pos), length(v - evolute));
  14390. }
  14391. mat3 convertLocalToShapeSpaceDerivative(in vec3 position) {
  14392. vec3 east = normalize(vec3(-position.y, position.x, 0.0));
  14393. // Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z)
  14394. // (assume radii.y == radii.x) and find the nearest point on the ellipse and its normal
  14395. float distanceFromZAxis = length(position.xy);
  14396. vec2 posEllipse = vec2(distanceFromZAxis, position.z);
  14397. vec3 surfacePointAndRadius = nearestPointAndRadiusOnEllipse(posEllipse, u_ellipsoidRadii.xz);
  14398. vec2 surfacePoint = surfacePointAndRadius.xy;
  14399. vec2 normal2d = normalize(surfacePoint * u_ellipsoidInverseRadiiSquared.xz);
  14400. vec3 north = vec3(-normal2d.y * normalize(position.xy), abs(normal2d.x));
  14401. float heightSign = length(posEllipse) < length(surfacePoint) ? -1.0 : 1.0;
  14402. float height = heightSign * length(posEllipse - surfacePoint);
  14403. vec3 up = normalize(cross(east, north));
  14404. return mat3(east / distanceFromZAxis, north / (surfacePointAndRadius.z + height), up);
  14405. }
  14406. vec3 scaleShapeUvToShapeSpace(in vec3 shapeUv) {
  14407. // Convert from [0, 1] to radians [-pi, pi]
  14408. float longitude = shapeUv.x * czm_twoPi;
  14409. #if defined (ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE)
  14410. longitude /= u_ellipsoidLocalToShapeUvLongitude.x;
  14411. #endif
  14412. // Convert from [0, 1] to radians [-pi/2, pi/2]
  14413. float latitude = shapeUv.y * czm_pi;
  14414. #if defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE)
  14415. latitude /= u_ellipsoidLocalToShapeUvLatitude.x;
  14416. #endif
  14417. float height = shapeUv.z / u_ellipsoidInverseHeightDifference;
  14418. return vec3(longitude, latitude, height);
  14419. }
  14420. vec3 convertEcToDeltaShape(in vec3 positionEC) {
  14421. vec3 enu = u_ellipsoidEcToEastNorthUp * positionEC;
  14422. // 1. Compute the change in longitude from the camera to the ENU point
  14423. // First project the camera and ENU positions to the equatorial XY plane,
  14424. // positioning the camera on the +x axis, so that enu.x projects along the +y axis
  14425. float cosLatitude = cos(u_cameraPositionCartographic.y);
  14426. float sinLatitude = sin(u_cameraPositionCartographic.y);
  14427. float primeVerticalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.x;
  14428. vec2 cameraXY = vec2((primeVerticalRadius + u_cameraPositionCartographic.z) * cosLatitude, 0.0);
  14429. // Note precision loss in positionXY.x if length(enu) << length(cameraXY)
  14430. vec2 positionXY = cameraXY + vec2(-enu.y * sinLatitude + enu.z * cosLatitude, enu.x);
  14431. float dLongitude = atan(positionXY.y, positionXY.x);
  14432. // 2. Find the longitude component of positionXY, by rotating about Z until the y component is zero.
  14433. // Use the versine to compute the change in x directly from the change in angle:
  14434. // versine(angle) = 2 * sin^2(angle/2)
  14435. float sinHalfLongitude = sin(dLongitude / 2.0);
  14436. float dx = length(positionXY) * 2.0 * sinHalfLongitude * sinHalfLongitude;
  14437. // Rotate longitude component back to ENU North and Up, and remove from enu
  14438. enu += vec3(-enu.x, -dx * sinLatitude, dx * cosLatitude);
  14439. // 3. Compute the change in latitude from the camera to the ENU point.
  14440. // First project the camera and ENU positions to the meridional ZX plane,
  14441. // positioning the camera on the +Z axis, so that enu.y maps to the +X axis.
  14442. float meridionalRadius = 1.0 / u_ellipsoidCurvatureAtLatitude.y;
  14443. vec2 cameraZX = vec2(meridionalRadius + u_cameraPositionCartographic.z, 0.0);
  14444. vec2 positionZX = cameraZX + vec2(enu.z, enu.y);
  14445. float dLatitude = atan(positionZX.y, positionZX.x);
  14446. // 4. Compute the change in height above the ellipsoid
  14447. // Find the change in enu.z associated with rotating the point to the latitude of the camera
  14448. float sinHalfLatitude = sin(dLatitude / 2.0);
  14449. float dz = length(positionZX) * 2.0 * sinHalfLatitude * sinHalfLatitude;
  14450. // The remaining change in enu.z is the change in height above the ellipsoid
  14451. float dHeight = enu.z + dz;
  14452. return vec3(dLongitude, dLatitude, dHeight);
  14453. }
  14454. vec3 convertEcToDeltaTile(in vec3 positionEC) {
  14455. vec3 deltaShape = convertEcToDeltaShape(positionEC);
  14456. // Convert to tileset coordinates in [0, 1]
  14457. float dx = deltaShape.x / czm_twoPi;
  14458. #if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
  14459. // Wrap to ensure dx is not crossing through the unoccupied angle range, where
  14460. // angle to tile coordinate conversions would be more complicated
  14461. float cameraUvLongitude = (u_cameraPositionCartographic.x + czm_pi) / czm_twoPi;
  14462. float cameraUvLongitudeShift = fract(cameraUvLongitude - u_ellipsoidShapeUvLongitudeRangeOrigin);
  14463. float rawOutputUvLongitude = cameraUvLongitudeShift + dx;
  14464. float rotation = floor(rawOutputUvLongitude);
  14465. dx -= rotation;
  14466. dx *= u_ellipsoidLocalToShapeUvLongitude.x;
  14467. #endif
  14468. float dy = deltaShape.y / czm_pi;
  14469. #if (defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LATITUDE))
  14470. dy *= u_ellipsoidLocalToShapeUvLatitude.x;
  14471. #endif
  14472. float dz = u_ellipsoidInverseHeightDifference * deltaShape.z;
  14473. // Convert to tile coordinate changes
  14474. return vec3(dx, dy, dz) * float(1 << u_cameraTileCoordinates.w);
  14475. }
  14476. TileAndUvCoordinate getTileAndUvCoordinate(in vec3 positionEC) {
  14477. vec3 deltaTileCoordinate = convertEcToDeltaTile(positionEC);
  14478. vec3 tileUvSum = u_cameraTileUv + deltaTileCoordinate;
  14479. ivec3 tileCoordinate = u_cameraTileCoordinates.xyz + ivec3(floor(tileUvSum));
  14480. int maxTileCoordinate = (1 << u_cameraTileCoordinates.w) - 1;
  14481. tileCoordinate.y = min(max(0, tileCoordinate.y), maxTileCoordinate);
  14482. tileCoordinate.z = min(max(0, tileCoordinate.z), maxTileCoordinate);
  14483. #if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
  14484. ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
  14485. if (tileCoordinate.x < 0) {
  14486. tileCoordinate.x += (maxTileCoordinate + 1);
  14487. } else if (tileCoordinate.x > maxTileCoordinate) {
  14488. tileCoordinate.x -= (maxTileCoordinate + 1);
  14489. }
  14490. #else
  14491. tileCoordinate.x = min(max(0, tileCoordinate.x), maxTileCoordinate);
  14492. ivec3 tileCoordinateChange = tileCoordinate - u_cameraTileCoordinates.xyz;
  14493. #endif
  14494. vec3 tileUv = tileUvSum - vec3(tileCoordinateChange);
  14495. #if (!defined(ELLIPSOID_HAS_SHAPE_BOUNDS_LONGITUDE))
  14496. // If there is only one tile spanning 2*PI angle, the coordinate wraps around
  14497. tileUv.x = (u_cameraTileCoordinates.w == 0) ? fract(tileUv.x) : clamp(tileUv.x, 0.0, 1.0);
  14498. #else
  14499. tileUv.x = clamp(tileUv.x, 0.0, 1.0);
  14500. #endif
  14501. tileUv.y = clamp(tileUv.y, 0.0, 1.0);
  14502. tileUv.z = clamp(tileUv.z, 0.0, 1.0);
  14503. return TileAndUvCoordinate(ivec4(tileCoordinate, u_cameraTileCoordinates.w), tileUv);
  14504. }
  14505. `;var xdo=y(x(),1),zM=`// These octree flags must be in sync with GpuOctreeFlag in VoxelTraversal.js
  14506. #define OCTREE_FLAG_INTERNAL 0
  14507. #define OCTREE_FLAG_LEAF 1
  14508. #define OCTREE_FLAG_PACKED_LEAF_FROM_PARENT 2
  14509. #define OCTREE_MAX_LEVELS 32 // Harcoded value because GLSL doesn't like variable length loops
  14510. uniform sampler2D u_octreeInternalNodeTexture;
  14511. uniform vec2 u_octreeInternalNodeTexelSizeUv;
  14512. uniform int u_octreeInternalNodeTilesPerRow;
  14513. #if (SAMPLE_COUNT > 1)
  14514. uniform sampler2D u_octreeLeafNodeTexture;
  14515. uniform vec2 u_octreeLeafNodeTexelSizeUv;
  14516. uniform int u_octreeLeafNodeTilesPerRow;
  14517. #endif
  14518. uniform ivec3 u_dimensions; // does not include padding, and is in the z-up orientation
  14519. uniform ivec3 u_inputDimensions; // includes padding, and is in the orientation of the input data
  14520. #if defined(PADDING)
  14521. uniform ivec3 u_paddingBefore;
  14522. #endif
  14523. struct OctreeNodeData {
  14524. int data;
  14525. int flag;
  14526. };
  14527. struct TraversalData {
  14528. ivec4 octreeCoords;
  14529. int parentOctreeIndex;
  14530. };
  14531. struct TileAndUvCoordinate {
  14532. ivec4 tileCoords;
  14533. vec3 tileUv;
  14534. };
  14535. struct SampleData {
  14536. int megatextureIndex;
  14537. ivec4 tileCoords;
  14538. vec3 tileUv;
  14539. vec3 inputCoordinate;
  14540. #if (SAMPLE_COUNT > 1)
  14541. float weight;
  14542. #endif
  14543. };
  14544. int normU8_toInt(in float value) {
  14545. return int(value * 255.0);
  14546. }
  14547. int normU8x2_toInt(in vec2 value) {
  14548. return int(value.x * 255.0) + 256 * int(value.y * 255.0);
  14549. }
  14550. float normU8x2_toFloat(in vec2 value) {
  14551. return float(normU8x2_toInt(value)) / 65535.0;
  14552. }
  14553. OctreeNodeData getOctreeNodeData(in vec2 octreeUv) {
  14554. vec4 texData = texture(u_octreeInternalNodeTexture, octreeUv);
  14555. OctreeNodeData data;
  14556. data.data = normU8x2_toInt(texData.xy);
  14557. data.flag = normU8x2_toInt(texData.zw);
  14558. return data;
  14559. }
  14560. OctreeNodeData getOctreeChildData(in int parentOctreeIndex, in ivec3 childCoord) {
  14561. int childIndex = childCoord.z * 4 + childCoord.y * 2 + childCoord.x;
  14562. int octreeCoordX = (parentOctreeIndex % u_octreeInternalNodeTilesPerRow) * 9 + 1 + childIndex;
  14563. int octreeCoordY = parentOctreeIndex / u_octreeInternalNodeTilesPerRow;
  14564. vec2 octreeUv = u_octreeInternalNodeTexelSizeUv * vec2(float(octreeCoordX) + 0.5, float(octreeCoordY) + 0.5);
  14565. return getOctreeNodeData(octreeUv);
  14566. }
  14567. int getOctreeParentIndex(in int octreeIndex) {
  14568. int octreeCoordX = (octreeIndex % u_octreeInternalNodeTilesPerRow) * 9;
  14569. int octreeCoordY = octreeIndex / u_octreeInternalNodeTilesPerRow;
  14570. vec2 octreeUv = u_octreeInternalNodeTexelSizeUv * vec2(float(octreeCoordX) + 0.5, float(octreeCoordY) + 0.5);
  14571. vec4 parentData = texture(u_octreeInternalNodeTexture, octreeUv);
  14572. int parentOctreeIndex = normU8x2_toInt(parentData.xy);
  14573. return parentOctreeIndex;
  14574. }
  14575. vec3 getTileUv(in TileAndUvCoordinate tileAndUv, in ivec4 octreeCoords) {
  14576. int levelDifference = tileAndUv.tileCoords.w - octreeCoords.w;
  14577. float scalar = exp2(-1.0 * float(levelDifference));
  14578. vec3 originShift = vec3(tileAndUv.tileCoords.xyz - (octreeCoords.xyz << levelDifference)) * scalar;
  14579. return tileAndUv.tileUv * scalar + originShift;
  14580. }
  14581. vec3 getClampedTileUv(in TileAndUvCoordinate tileAndUv, in ivec4 octreeCoords) {
  14582. vec3 tileUv = getTileUv(tileAndUv, octreeCoords);
  14583. return clamp(tileUv, vec3(0.0), vec3(1.0));
  14584. }
  14585. void addSampleCoordinates(in TileAndUvCoordinate tileAndUv, inout SampleData sampleData) {
  14586. vec3 tileUv = getClampedTileUv(tileAndUv, sampleData.tileCoords);
  14587. vec3 inputCoordinate = tileUv * vec3(u_dimensions);
  14588. #if defined(PADDING)
  14589. inputCoordinate += vec3(u_paddingBefore);
  14590. #endif
  14591. #if defined(Y_UP_METADATA_ORDER)
  14592. #if defined(SHAPE_BOX)
  14593. float inputY = inputCoordinate.y;
  14594. inputCoordinate.y = inputCoordinate.z;
  14595. // u_inputDimensions.z is the y-up dimension along the 3D Tiles y-axis.
  14596. inputCoordinate.z = float(u_inputDimensions.z) - inputY;
  14597. #elif defined(SHAPE_CYLINDER)
  14598. float angle = inputCoordinate.y;
  14599. float height = inputCoordinate.z;
  14600. #if (!defined(CYLINDER_HAS_SHAPE_BOUNDS_ANGLE))
  14601. // Account for the different 0-angle convention in glTF vs 3DTiles
  14602. if (sampleData.tileCoords.w == 0) {
  14603. float angleCount = float(u_inputDimensions.z);
  14604. angle = mod(angle + angleCount / 2.0, angleCount);
  14605. }
  14606. #endif
  14607. inputCoordinate.y = height;
  14608. inputCoordinate.z = angle;
  14609. #endif
  14610. #endif
  14611. sampleData.tileUv = tileUv;
  14612. sampleData.inputCoordinate = inputCoordinate;
  14613. }
  14614. void getOctreeLeafSampleData(in OctreeNodeData data, in ivec4 octreeCoords, out SampleData sampleData) {
  14615. sampleData.megatextureIndex = data.data;
  14616. sampleData.tileCoords = (data.flag == OCTREE_FLAG_PACKED_LEAF_FROM_PARENT)
  14617. ? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
  14618. : octreeCoords;
  14619. }
  14620. #if (SAMPLE_COUNT > 1)
  14621. void getOctreeLeafSampleDatas(in OctreeNodeData data, in ivec4 octreeCoords, out SampleData sampleDatas[SAMPLE_COUNT]) {
  14622. int leafIndex = data.data;
  14623. int leafNodeTexelCount = 2;
  14624. // Adding 0.5 moves to the center of the texel
  14625. float leafCoordXStart = float((leafIndex % u_octreeLeafNodeTilesPerRow) * leafNodeTexelCount) + 0.5;
  14626. float leafCoordY = float(leafIndex / u_octreeLeafNodeTilesPerRow) + 0.5;
  14627. // Get an interpolation weight and a flag to determine whether to read the parent texture
  14628. vec2 leafUv0 = u_octreeLeafNodeTexelSizeUv * vec2(leafCoordXStart + 0.0, leafCoordY);
  14629. vec4 leafData0 = texture(u_octreeLeafNodeTexture, leafUv0);
  14630. float lerp = normU8x2_toFloat(leafData0.xy);
  14631. sampleDatas[0].weight = 1.0 - lerp;
  14632. sampleDatas[1].weight = lerp;
  14633. // TODO: this looks wrong? Should be comparing to OCTREE_FLAG_PACKED_LEAF_FROM_PARENT
  14634. sampleDatas[0].tileCoords = (normU8_toInt(leafData0.z) == 1)
  14635. ? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
  14636. : octreeCoords;
  14637. sampleDatas[1].tileCoords = (normU8_toInt(leafData0.w) == 1)
  14638. ? ivec4(octreeCoords.xyz / 2, octreeCoords.w - 1)
  14639. : octreeCoords;
  14640. // Get megatexture indices for both samples
  14641. vec2 leafUv1 = u_octreeLeafNodeTexelSizeUv * vec2(leafCoordXStart + 1.0, leafCoordY);
  14642. vec4 leafData1 = texture(u_octreeLeafNodeTexture, leafUv1);
  14643. sampleDatas[0].megatextureIndex = normU8x2_toInt(leafData1.xy);
  14644. sampleDatas[1].megatextureIndex = normU8x2_toInt(leafData1.zw);
  14645. }
  14646. #endif
  14647. OctreeNodeData traverseOctreeDownwards(in ivec4 tileCoordinate, inout TraversalData traversalData) {
  14648. OctreeNodeData childData;
  14649. for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) {
  14650. // tileCoordinate.xyz is defined at the level of detail tileCoordinate.w.
  14651. // Find the corresponding coordinate at the level traversalData.octreeCoords.w
  14652. int level = traversalData.octreeCoords.w + 1;
  14653. int levelDifference = tileCoordinate.w - level;
  14654. ivec3 coordinateAtLevel = tileCoordinate.xyz >> levelDifference;
  14655. traversalData.octreeCoords = ivec4(coordinateAtLevel, level);
  14656. ivec3 childCoordinate = coordinateAtLevel & 1;
  14657. childData = getOctreeChildData(traversalData.parentOctreeIndex, childCoordinate);
  14658. if (childData.flag != OCTREE_FLAG_INTERNAL) {
  14659. // leaf tile - stop traversing
  14660. break;
  14661. }
  14662. traversalData.parentOctreeIndex = childData.data;
  14663. }
  14664. return childData;
  14665. }
  14666. /**
  14667. * Transform a given position to an octree tile coordinate and a position within that tile,
  14668. * and find the corresponding megatexture index and texture coordinates
  14669. */
  14670. void traverseOctreeFromBeginning(in TileAndUvCoordinate tileAndUv, out TraversalData traversalData, out SampleData sampleDatas[SAMPLE_COUNT]) {
  14671. traversalData.octreeCoords = ivec4(0);
  14672. traversalData.parentOctreeIndex = 0;
  14673. OctreeNodeData nodeData = getOctreeNodeData(vec2(0.0));
  14674. if (nodeData.flag != OCTREE_FLAG_LEAF) {
  14675. nodeData = traverseOctreeDownwards(tileAndUv.tileCoords, traversalData);
  14676. }
  14677. #if (SAMPLE_COUNT == 1)
  14678. getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]);
  14679. addSampleCoordinates(tileAndUv, sampleDatas[0]);
  14680. #else
  14681. getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas);
  14682. addSampleCoordinates(tileAndUv, sampleDatas[0]);
  14683. addSampleCoordinates(tileAndUv, sampleDatas[1]);
  14684. #endif
  14685. }
  14686. bool insideTile(in ivec4 tileCoordinate, in ivec4 octreeCoords) {
  14687. int levelDifference = tileCoordinate.w - octreeCoords.w;
  14688. if (levelDifference < 0) {
  14689. return false;
  14690. }
  14691. ivec3 coordinateAtLevel = tileCoordinate.xyz >> levelDifference;
  14692. return coordinateAtLevel == octreeCoords.xyz;
  14693. }
  14694. void traverseOctreeFromExisting(in TileAndUvCoordinate tileAndUv, inout TraversalData traversalData, inout SampleData sampleDatas[SAMPLE_COUNT]) {
  14695. ivec4 tileCoords = tileAndUv.tileCoords;
  14696. if (insideTile(tileCoords, traversalData.octreeCoords)) {
  14697. for (int i = 0; i < SAMPLE_COUNT; i++) {
  14698. addSampleCoordinates(tileAndUv, sampleDatas[i]);
  14699. }
  14700. return;
  14701. }
  14702. // Go up tree until we find a parent tile containing tileCoords.
  14703. // Assumes all parents are available all they way up to the root.
  14704. for (int i = 0; i < OCTREE_MAX_LEVELS; ++i) {
  14705. traversalData.octreeCoords.xyz /= 2;
  14706. traversalData.octreeCoords.w -= 1;
  14707. if (insideTile(tileCoords, traversalData.octreeCoords)) {
  14708. break;
  14709. }
  14710. traversalData.parentOctreeIndex = getOctreeParentIndex(traversalData.parentOctreeIndex);
  14711. }
  14712. // Go down tree
  14713. OctreeNodeData nodeData = traverseOctreeDownwards(tileCoords, traversalData);
  14714. #if (SAMPLE_COUNT == 1)
  14715. getOctreeLeafSampleData(nodeData, traversalData.octreeCoords, sampleDatas[0]);
  14716. addSampleCoordinates(tileAndUv, sampleDatas[0]);
  14717. #else
  14718. getOctreeLeafSampleDatas(nodeData, traversalData.octreeCoords, sampleDatas);
  14719. addSampleCoordinates(tileAndUv, sampleDatas[0]);
  14720. addSampleCoordinates(tileAndUv, sampleDatas[1]);
  14721. #endif
  14722. }
  14723. `;var Tdo=y(x(),1),HM=`// See Octree.glsl for the definitions of SampleData
  14724. /* Megatexture defines (set in Scene/VoxelRenderResources.js)
  14725. #define SAMPLE_COUNT ###
  14726. #define PADDING
  14727. */
  14728. uniform ivec3 u_megatextureTileCounts; // number of tiles in the megatexture, along each axis
  14729. vec3 index1DTo3DTexCoord(int index)
  14730. {
  14731. int tilesPerZ = u_megatextureTileCounts.x * u_megatextureTileCounts.y;
  14732. int iz = index / tilesPerZ;
  14733. int remainder = index - iz * tilesPerZ;
  14734. int iy = remainder / u_megatextureTileCounts.x;
  14735. int ix = remainder - iy * u_megatextureTileCounts.x;
  14736. return vec3(ix, iy, iz) / vec3(u_megatextureTileCounts);
  14737. }
  14738. Properties getPropertiesFromMegatexture(in SampleData sampleData) {
  14739. int tileIndex = sampleData.megatextureIndex;
  14740. vec3 voxelCoord = sampleData.inputCoordinate;
  14741. // UV coordinate of the lower corner of the tile in the megatexture
  14742. vec3 tileUvOffset = index1DTo3DTexCoord(tileIndex);
  14743. // Voxel location
  14744. vec3 tileDimensions = vec3(u_inputDimensions);
  14745. vec3 clampedVoxelCoord = clamp(voxelCoord, vec3(0.5), tileDimensions - vec3(0.5));
  14746. vec3 voxelUv = clampedVoxelCoord / tileDimensions / vec3(u_megatextureTileCounts);
  14747. return getPropertiesFromMegatextureAtUv(tileUvOffset + voxelUv);
  14748. }
  14749. // Convert an array of sample datas to a final weighted properties.
  14750. Properties accumulatePropertiesFromMegatexture(in SampleData sampleDatas[SAMPLE_COUNT]) {
  14751. #if (SAMPLE_COUNT == 1)
  14752. return getPropertiesFromMegatexture(sampleDatas[0]);
  14753. #else
  14754. // When more than one sample is taken the accumulator needs to start at 0
  14755. Properties properties = clearProperties();
  14756. for (int i = 0; i < SAMPLE_COUNT; ++i) {
  14757. float weight = sampleDatas[i].weight;
  14758. // Avoid reading the megatexture when the weight is 0 as it can be costly.
  14759. if (weight > 0.0) {
  14760. Properties tempProperties = getPropertiesFromMegatexture(sampleDatas[i]);
  14761. tempProperties = scaleProperties(tempProperties, weight);
  14762. properties = sumProperties(properties, tempProperties);
  14763. }
  14764. }
  14765. return properties;
  14766. #endif
  14767. }
  14768. `;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};
  14769. int pixX = planeNumber - (pixY * ${t});
  14770. // Sample from center of pixel
  14771. float u = (float(pixX) + 0.5) * ${r};
  14772. float v = (float(pixY) + 0.5) * ${s};
  14773. 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
  14774. {
  14775. material.diffuse = vec3(1.0);
  14776. material.alpha = 1.0;
  14777. }`});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
  14778. vec4 clippingPlanesEdgeColor = vec4(1.0);
  14779. clippingPlanesEdgeColor.rgb = ${n}.rgb;
  14780. float clippingPlanesEdgeWidth = ${n}.a;
  14781. if (clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth)
  14782. {
  14783. out_FragColor = clippingPlanesEdgeColor;
  14784. }
  14785. `}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;
  14786. void main()
  14787. {
  14788. #ifndef SHADOW_MAP
  14789. if (czm_splitDirection < 0.0 && gl_FragCoord.x > czm_splitPosition) discard;
  14790. if (czm_splitDirection > 0.0 && gl_FragCoord.x < czm_splitPosition) discard;
  14791. #endif
  14792. czm_splitter_main();
  14793. }
  14794. `,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
  14795. `));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};
  14796. `,te[Te]=r.location}TLt(e,t);let ee=`in vec3 a_position;
  14797. out vec4 v_color;
  14798. uniform vec4 u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier;
  14799. uniform vec4 u_constantColor;
  14800. uniform vec4 u_highlightColor;
  14801. `;ee+=`float u_pointSize;
  14802. float tiles3d_tileset_time;
  14803. `,R&&(ee+=`float u_geometricError;
  14804. float u_depthMultiplier;
  14805. `),ee+=z,O&&(A?ee+=`in vec4 a_color;
  14806. `:p?ee+=`in float a_color;
  14807. const float SHIFT_RIGHT_11 = 1.0 / 2048.0;
  14808. const float SHIFT_RIGHT_5 = 1.0 / 32.0;
  14809. const float SHIFT_LEFT_11 = 2048.0;
  14810. const float SHIFT_LEFT_5 = 32.0;
  14811. const float NORMALIZE_6 = 1.0 / 64.0;
  14812. const float NORMALIZE_5 = 1.0 / 32.0;
  14813. `:ee+=`in vec3 a_color;
  14814. `),J&&(u||h?ee+=`in vec2 a_normal;
  14815. `:ee+=`in vec3 a_normal;
  14816. `),C&&(ee+=`in float a_batchId;
  14817. `),(c||d||h)&&(ee+=`uniform vec4 u_quantizedVolumeScaleAndOctEncodedRange;
  14818. `),Z&&(ee+=V),G&&(ee+=W),w&&(ee+=B),ee+=`void main()
  14819. {
  14820. u_pointSize = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.x;
  14821. tiles3d_tileset_time = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.y;
  14822. `,R&&(ee+=` u_geometricError = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.z;
  14823. u_depthMultiplier = u_pointSizeAndTimeAndGeometricErrorAndDepthMultiplier.w;
  14824. `),O?A?ee+=` vec4 color = a_color;
  14825. `:p?ee+=` float compressed = a_color;
  14826. float r = floor(compressed * SHIFT_RIGHT_11);
  14827. compressed -= r * SHIFT_LEFT_11;
  14828. float g = floor(compressed * SHIFT_RIGHT_5);
  14829. compressed -= g * SHIFT_LEFT_5;
  14830. float b = compressed;
  14831. vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);
  14832. vec4 color = vec4(rgb, 1.0);
  14833. `:ee+=` vec4 color = vec4(a_color, 1.0);
  14834. `:ee+=` vec4 color = u_constantColor;
  14835. `,c||d?ee+=` vec3 position = a_position * u_quantizedVolumeScaleAndOctEncodedRange.xyz;
  14836. `:ee+=` vec3 position = a_position;
  14837. `,ee+=` vec3 position_absolute = vec3(czm_model * vec4(position, 1.0));
  14838. `,J?(u?ee+=` vec3 normal = czm_octDecode(a_normal);
  14839. `:h?ee+=` vec3 normal = czm_octDecode(a_normal, u_quantizedVolumeScaleAndOctEncodedRange.w).zxy;
  14840. `:ee+=` vec3 normal = a_normal;
  14841. `,ee+=` vec3 normalEC = czm_normal * normal;
  14842. `):ee+=` vec3 normal = vec3(1.0);
  14843. `,Z&&(ee+=` color = getColorFromStyle(position, position_absolute, color, normal);
  14844. `),G&&(ee+=` float show = float(getShowFromStyle(position, position_absolute, color, normal));
  14845. `),w?ee+=` gl_PointSize = getPointSizeFromStyle(position, position_absolute, color, normal) * czm_pixelRatio;
  14846. `:R?ee+=` vec4 positionEC = czm_modelView * vec4(position, 1.0);
  14847. float depth = -positionEC.z;
  14848. gl_PointSize = min((u_geometricError / depth) * u_depthMultiplier, u_pointSize);
  14849. `:ee+=` gl_PointSize = u_pointSize;
  14850. `,ee+=` color = color * u_highlightColor;
  14851. `,J&&E&&(ee+=` float diffuseStrength = czm_getLambertDiffuse(czm_lightDirectionEC, normalEC);
  14852. diffuseStrength = max(diffuseStrength, 0.4);
  14853. color.xyz *= diffuseStrength * czm_lightColor;
  14854. `),ee+=` v_color = color;
  14855. gl_Position = czm_modelViewProjection * vec4(position, 1.0);
  14856. `,J&&T&&(ee+=` float visible = step(-normalEC.z, 0.0);
  14857. gl_Position *= visible;
  14858. gl_PointSize *= visible;
  14859. `),G&&(ee+=` gl_Position.w *= float(show);
  14860. gl_PointSize *= float(show);
  14861. `),ee+=`}
  14862. `;let ge=`in vec4 v_color;
  14863. `;X&&(ge+=`uniform highp sampler2D u_clippingPlanes;
  14864. uniform mat4 u_clippingPlanesMatrix;
  14865. uniform vec4 u_clippingPlanesEdgeStyle;
  14866. `,ge+=`
  14867. `,ge+=cE(I,s),ge+=`
  14868. `),ge+=`void main()
  14869. {
  14870. out_FragColor = czm_gammaCorrect(v_color);
  14871. `,X&&(ge+=gv("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),ge+=`}
  14872. `,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
  14873. ${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
  14874. ${t}
  14875. ${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
  14876. `;else switch(t==="st"&&(i="vec2"),i){case"float":r=`vec4 getColor() { return vec4(vec3(${o}), 1.0); }
  14877. `;break;case"vec2":r=`vec4 getColor() { return vec4(${o}, 0.0, 1.0); }
  14878. `;break;case"vec3":r=`vec4 getColor() { return vec4(${o}, 1.0); }
  14879. `;break;case"vec4":r=`vec4 getColor() { return ${o}; }
  14880. `;break}let s=`in vec3 position3DHigh;
  14881. in vec3 position3DLow;
  14882. in float batchId;
  14883. ${n?"":`in ${i} ${t};
  14884. `}out ${i} ${o};
  14885. void main()
  14886. {
  14887. vec4 p = czm_translateRelativeToEye(position3DHigh, position3DLow);
  14888. ${n?`${o} = czm_batchTable_${t}(batchId);
  14889. `:`${o} = ${t};
  14890. `}gl_Position = czm_modelViewProjectionRelativeToEye * p;
  14891. }`,a=`in ${i} ${o};
  14892. ${r}
  14893. void main()
  14894. {
  14895. out_FragColor = getColor();
  14896. }`;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;
  14897. in vec3 v_positionEC;
  14898. in vec2 v_st;
  14899. void main()
  14900. {
  14901. czm_materialInput materialInput;
  14902. vec3 normalEC = normalize(czm_normal3D * czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0)));
  14903. #ifdef FACE_FORWARD
  14904. normalEC = faceforward(normalEC, vec3(0.0, 0.0, 1.0), -normalEC);
  14905. #endif
  14906. materialInput.s = v_st.s;
  14907. materialInput.st = v_st;
  14908. materialInput.str = vec3(v_st, 0.0);
  14909. // Convert tangent space material normal to eye space
  14910. materialInput.normalEC = normalEC;
  14911. materialInput.tangentToEyeMatrix = czm_eastNorthUpToEyeCoordinates(v_positionMC, materialInput.normalEC);
  14912. // Convert view vector to world space
  14913. vec3 positionToEyeEC = -v_positionEC;
  14914. materialInput.positionToEyeEC = positionToEyeEC;
  14915. czm_material material = czm_getMaterial(materialInput);
  14916. #ifdef FLAT
  14917. out_FragColor = vec4(material.diffuse + material.emission, material.alpha);
  14918. #else
  14919. out_FragColor = czm_phong(normalize(positionToEyeEC), material, czm_lightDirectionEC);
  14920. #endif
  14921. }
  14922. `;var Oxo=y(x(),1),Gv=`in vec3 position3DHigh;
  14923. in vec3 position3DLow;
  14924. in vec2 st;
  14925. in float batchId;
  14926. out vec3 v_positionMC;
  14927. out vec3 v_positionEC;
  14928. out vec2 v_st;
  14929. void main()
  14930. {
  14931. vec4 p = czm_computePosition();
  14932. v_positionMC = position3DHigh + position3DLow; // position in model coordinates
  14933. v_positionEC = (czm_modelViewRelativeToEye * p).xyz; // position in eye coordinates
  14934. v_st = st;
  14935. gl_Position = czm_modelViewProjectionRelativeToEye * p;
  14936. }
  14937. `;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
  14938. in vec2 v_textureCoordinates;
  14939. void main()
  14940. {
  14941. float z_window = czm_unpackDepth(texture(u_depthTexture, v_textureCoordinates));
  14942. z_window = czm_reverseLogDepth(z_window);
  14943. float n_range = czm_depthRange.near;
  14944. float f_range = czm_depthRange.far;
  14945. float z_ndc = (2.0 * z_window - n_range - f_range) / (f_range - n_range);
  14946. float scale = pow(z_ndc * 0.5 + 0.5, 8.0);
  14947. out_FragColor = vec4(mix(vec3(0.0), vec3(1.0), scale), 1.0);
  14948. }
  14949. `;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)}
  14950. 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(){/*!
  14951. * Knockout JavaScript library v3.5.1
  14952. * (c) The Knockout.js team - http://knockoutjs.com/
  14953. * License: MIT (http://www.opensource.org/licenses/mit-license.php)
  14954. */(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
  14955. ,`;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(`"(?:\\\\.|[^"])*"|'(?:\\\\.|[^'])*'|\`(?:\\\\.|[^\`])*\`|/\\*(?:[^*]|\\*+[^*/])*\\*+/|//.*
  14956. |/(?:\\\\.|[^/])+/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?
  14957. Bindings value: `+g+`
  14958. 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]+`"
  14959. 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
  14960. * @license
  14961. * Knockout ES5 plugin - https://github.com/SteveSanderson/knockout-es5
  14962. * Copyright (c) Steve Sanderson
  14963. * MIT license
  14964. */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
  14965. <ul class="cesium-cesiumInspector-statistics">
  14966. <li><strong>Geometry Memory (MB): </strong>${nU(e.geometryByteLength)}</li>
  14967. <li><strong>Texture Memory (MB): </strong>${nU(e.texturesByteLength)}</li>
  14968. </ul>
  14969. `}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())}}),
  14970. `),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(`
  14971. `);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
  14972. ${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
  14973. 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
  14974. 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
  14975. 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.
  14976. 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.
  14977. 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:`&copy; <a href="https://stamen.com/" target="_blank">Stamen Design</a>
  14978. &copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
  14979. &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
  14980. &copy; <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.
  14981. 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:`&copy; <a href="https://stamen.com/" target="_blank">Stamen Design</a>
  14982. &copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
  14983. &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
  14984. &copy; <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.
  14985. 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:`&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
  14986. &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
  14987. &copy; <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.
  14988. 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:`&copy; <a href="https://www.stadiamaps.com/" target="_blank">Stadia Maps</a>
  14989. &copy; <a href="https://openmaptiles.org/" target="_blank">OpenMapTiles</a>
  14990. &copy; <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.
  14991. 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>&nbsp;&nbsp;&nbsp;&nbsp;${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"
  14992. <h3>Building explorer</h3>
  14993. <select
  14994. data-bind="options: topLayers, optionsText: 'name', optionsAfterRender: setOptionDisable, value: currentLayer"
  14995. ></select>
  14996. <div id="bsl-wrapper">
  14997. <h3>Select Level</h3>
  14998. <select data-bind="options: levels, value: currentLevel"></select>
  14999. <h3>Disciplines & Categories</h3>
  15000. <ul class="layersList" data-bind="foreach: sublayers">
  15001. <ul class="layersList" data-bind="foreach: sublayers.sort(function (l, r) { return l.name.localeCompare(r.name) })">
  15002. <li>
  15003. <div class="li-wrapper">
  15004. <span
  15005. class="expandItem"
  15006. data-bind="click: $root.expandClickHandler"
  15007. >+</span
  15008. >
  15009. <input
  15010. type="checkbox"
  15011. data-bind="checked: visibility, valueUpdate: 'input', attr: { id: name}"
  15012. />
  15013. <label data-bind="attr: { for: name}">
  15014. <span data-bind="text: name"></span>
  15015. </label>
  15016. </div>
  15017. <ul class="nested" data-bind="attr: { id: name + '-expander'}">
  15018. <li data-bind="foreach: sublayers.sort(function (l, r) { return l.name.localeCompare(r.name) })">
  15019. <div class="li-wrapper">
  15020. <input
  15021. type="checkbox"
  15022. data-bind="checked: visibility, valueUpdate: 'input', attr: { id: name}"
  15023. />
  15024. <label data-bind="attr: { for: name}">
  15025. <span data-bind="text: name"></span>
  15026. </label>
  15027. </div>
  15028. </li>
  15029. </ul>
  15030. </li>
  15031. </ul>
  15032. </ul>
  15033. </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="&times;",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
  15034. `),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}
  15035. `}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
  15036. `),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(`
  15037. `);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