2023-02-01 01:46:39 +00:00
( function ( ) { const t = document . createElement ( "link" ) . relList ; if ( t && t . supports && t . supports ( "modulepreload" ) ) return ; for ( const o of document . querySelectorAll ( 'link[rel="modulepreload"]' ) ) i ( o ) ; new MutationObserver ( o => { for ( const r of o ) if ( r . type === "childList" ) for ( const s of r . addedNodes ) s . tagName === "LINK" && s . rel === "modulepreload" && i ( s ) } ) . observe ( document , { childList : ! 0 , subtree : ! 0 } ) ; function n ( o ) { const r = { } ; return o . integrity && ( r . integrity = o . integrity ) , o . referrerpolicy && ( r . referrerPolicy = o . referrerpolicy ) , o . crossorigin === "use-credentials" ? r . credentials = "include" : o . crossorigin === "anonymous" ? r . credentials = "omit" : r . credentials = "same-origin" , r } function i ( o ) { if ( o . ep ) return ; o . ep = ! 0 ; const r = n ( o ) ; fetch ( o . href , r ) } } ) ( ) ; function tB ( e , t ) { const n = Object . create ( null ) , i = e . split ( "," ) ; for ( let o = 0 ; o < i . length ; o ++ ) n [ i [ o ] ] = ! 0 ; return t ? o => ! ! n [ o . toLowerCase ( ) ] : o => ! ! n [ o ] } function Kw ( e ) { if ( Tn ( e ) ) { const t = { } ; for ( let n = 0 ; n < e . length ; n ++ ) { const i = e [ n ] , o = No ( i ) ? VQ ( i ) : Kw ( i ) ; if ( o ) for ( const r in o ) t [ r ] = o [ r ] } return t } else { if ( No ( e ) ) return e ; if ( eo ( e ) ) return e } } const zQ = /;(?![^(]*\))/g , UQ = /:([^]+)/ , HQ = / \ / \ * . * ? \ * \ / / g s ; f u n c t i o n V Q ( e ) { c o n s t t = { } ; r e t u r n e . r e p l a c e ( H Q , " " ) . s p l i t ( z Q ) . f o r E a c h ( n = > { i f ( n ) { c o n s t i = n . s p l i t ( U Q ) ; i . l e n g t h > 1 & & ( t [ i [ 0 ] . t r i m ( ) ] = i [ 1 ] . t r i m ( ) ) } } ) , t } f u n c t i o n m l ( e ) { l e t t = " " ; i f ( N o ( e ) ) t = e ; e l s e i f ( T n ( e ) ) f o r ( l e t n = 0 ; n < e . l e n g t h ; n + + ) { c o n s t i = m l ( e [ n ] ) ; i & & ( t + = i + " " ) } e l s e i f ( e o ( e ) ) f o r ( c o n s t n i n e ) e [ n ] & & ( t + = n + " " ) ; r e t u r n t . t r i m ( ) } c o n s t k Q = " i t e m s c o p e , a l l o w f u l l s c r e e n , f o r m n o v a l i d a t e , i s m a p , n o m o d u l e , n o v a l i d a t e , r e a d o n l y " , G Q = t B ( k Q ) ; f u n c t i o n l G ( e ) { r e t u r n ! ! e | | e = = = " " } c o n s t u G = e = > N o ( e ) ? e : e = = n u l l ? " " : T n ( e ) | | e o ( e ) & & ( e . t o S t r i n g = = = p G | | ! A n ( e . t o S t r i n g ) ) ? J S O N . s t r i n g i f y ( e , f G , 2 ) : S t r i n g ( e ) , f G = ( e , t ) = > t & & t . _ _ v _ i s R e f ? f G ( e , t . v a l u e ) : v g ( t ) ? { [ ` M a p ( $ { t . s i z e } ) ` ] : [ . . . t . e n t r i e s ( ) ] . r e d u c e ( ( n , [ i , o ] ) = > ( n [ ` $ { i } = > ` ] = o , n ) , { } ) } : d G ( t ) ? { [ ` S e t ( $ { t . s i z e } ) ` ] : [ . . . t . v a l u e s ( ) ] } : e o ( t ) & & ! T n ( t ) & & ! m G ( t ) ? S t r i n g ( t ) : t , r o = { } , S g = [ ] , E l = ( ) = > { } , W Q = ( ) = > ! 1 , j Q = / ^ o n [ ^ a - z ] / , J w = e = > j Q . t e s t ( e ) , n B = e = > e . s t a r t s W i t h ( " o n U p d a t e : " ) , c s = O b j e c t . a s s i g n , i B = ( e , t ) = > { c o n s t n = e . i n d e x O f ( t ) ; n > - 1 & & e . s p l i c e ( n , 1 ) } , q Q = O b j e c t . p r o t o t y p e . h a s O w n P r o p e r t y , t i = ( e , t ) = > q Q . c a l l ( e , t ) , T n = A r r a y . i s A r r a y , v g = e = > Q w ( e ) = = = " [ o b j e c t M a p ] " , d G = e = > Q w ( e ) = = = " [ o b j e c t S e t ] " , A n = e = > t y p e o f e = = " f u n c t i o n " , N o = e = > t y p e o f e = = " s t r i n g " , o B = e = > t y p e o f e = = " s y m b o l " , e o = e = > e ! = = n u l l & & t y p e o f e = = " o b j e c t " , h G = e = > e o ( e ) & & A n ( e . t h e n ) & & A n ( e . c a t c h ) , p G = O b j e c t . p r o t o t y p e . t o S t r i n g , Q w = e = > p G . c a l l ( e ) , Y Q = e = > Q w ( e ) . s l i c e ( 8 , - 1 ) , m G = e = > Q w ( e ) = = = " [ o b j e c t O b j e c t ] " , r B = e = > N o ( e ) & & e ! = = " N a N " & & e [ 0 ] ! = = " - " & & " " + p a r s e I n t ( e , 1 0 ) = = = e , X E = t B ( " , k e y , r e f , r e f _ f o r , r e f _ k e y , o n V n o d e B e f o r e M o u n t , o n V n o d e M o u n t e d , o n V n o d e B e f o r e U p d a t e , o n V n o d e U p d a t e d , o n V n o d e B e f o r e U n m o u n t , o n V n o d e U n m o u n t e d " ) , Z w = e = > { c o n s t t = O b j e c t . c r e a t e ( n u l l ) ; r e t u r n n = > t [ n ] | | ( t [ n ] = e ( n ) ) } , X Q = / - ( \ w ) / g , P u = Z w ( e = > e . r e p l a c e ( X Q , ( t , n ) = > n ? n . t o U p p e r C a s e ( ) : " " ) ) , $ Q = / \ B ( [ A - Z ] ) / g , A y = Z w ( e = > e . r e p l a c e ( $ Q , " - $ 1 " ) . t o L o w e r C a s e ( ) ) , e S = Z w ( e = > e . c h a r A t ( 0 ) . t o U p p e r C a s e ( ) + e . s l i c e ( 1 ) ) , k v = Z w ( e = > e ? ` o n $ { e S ( e ) } ` : " " ) , G A = ( e , t ) = > ! O b j e c t . i s ( e , t ) , G v = ( e , t ) = > { f o r ( l e t n = 0 ; n < e . l e n g t h ; n + + ) e [ n ] ( t ) } , k x = ( e , t , n ) = > { O b j e c t . d e f i n e P r o p e r t y ( e , t , { c o n f i g u r a b l e : ! 0 , e n u m e r a b l e : ! 1 , v a l u e : n } ) } , s B = e = > { c o n s t t = p a r s e F l o a t ( e ) ; r e t u r n i s N a N ( t ) ? e : t } ; l e t b M ; c o n s t K Q = ( ) = > b M | | ( b M = t y p e o f g l o b a l T h i s < " u " ? g l o b a l T h i s : t y p e o f s e l f < " u " ? s e l f : t y p e o f w i n d o w < " u " ? w i n d o w : t y p e o f g l o b a l < " u " ? g l o b a l : { } ) ; l e t D a ; c l a s s _ G { c o n s t r u c t o r ( t = ! 1 ) { t h i s . d e t a c h e d = t , t h i s . a c t i v e = ! 0 , t h i s . e f f e c t s = [ ] , t h i s . c l e a n u p s = [ ] , t h i s . p a r e n t = D a , ! t & & D a & & ( t h i s . i n d e x = ( D a . s c o p e s | | ( D a . s c o p e s = [ ] ) ) . p u s h ( t h i s ) - 1 ) } r u n ( t ) { i f ( t h i s . a c t i v e ) { c o n s t n = D a ; t r y { r e t u r n D a = t h i s , t ( ) } f i n a l l y { D a = n } } } o n ( ) { D a = t h i s } o f f ( ) { D a = t h i s . p a r e n t } s t o p ( t ) { i f ( t h i s . a c t i v e ) { l e t n , i ; f o r ( n = 0 , i = t h i s . e f f e c t s . l e n g t h ; n < i ; n + + ) t h i s . e f f e c t s [ n ] . s t o p ( ) ; f o r ( n = 0 , i = t h i s . c l e a n u p s . l e n g t h ; n < i ; n + + ) t h i s . c l e a n u p s [ n ] ( ) ; i f ( t h i s . s c o p e s ) f o r ( n = 0 , i = t h i s . s c o p e s . l e n g t h ; n < i ; n + + ) t h i s . s c o p e s [ n ] . s t o p ( ! 0 ) ; i f ( ! t h i s . d e t a c h e d & & t h i s . p a r e n t & & ! t ) { c o n s t o = t h i s . p a r e n t . s c o p e s . p o p ( ) ; o & & o ! = = t h i s & & ( t h i s . p a r e n t . s c o p e s [ t h i s . i n d e x ] = o , o . i n d e x = t h i s . i n d e x ) } t h i s . p a r e n t = v o i d 0 , t h i s . a c t i v e = ! 1 } } } f u n c t i o n J Q ( e ) { r e t u r n n e w _ G ( e ) } f u n c t i o n Q Q ( e , t = D a ) { t & & t . a c t i v e & & t . e f f e c t s . p u s h ( e ) } f u n c t i o n Z Q ( ) { r e t u r n D a } f u n c t i o n e Z ( e ) { D a & & D a . c l e a n u p s . p u s h ( e ) } c o n s t a B = e = > { c o n s t t = n e w S e t ( e ) ; r e t u r n t . w = 0 , t . n = 0 , t } , g G = e = > ( e . w & R h
* pinia v2 . 0.28
* ( c ) 2022 Eduardo San Martin Morote
* @ license MIT
* /const hte=Symbol();var nF;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(nF||(nF={}));function pte(){const e=JQ(!0),t=e.run(()=>Bf({}));let n=[],i=[];const o=hB({install(r){o._a=r,r.provide(hte,o),r.config.globalProperties.$pinia=o,i.forEach(s=>n.push(s)),i=[]},use(r){return!this._a&&!dte?i.push(r):n.push(r),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return o}/ * !
* vue - router v4 . 1.6
* ( c ) 2022 Eduardo San Martin Morote
* @ license MIT
* /const ng=typeof window<"u";function mte(e){return e.__esModule||e[Symbol.toStringTag]==="Module"}const Fi=Object.assign;function Jv(e,t){const n={};for(const i in t){const o=t[i];n[i]=Ll(o)?o.map(e):e(o)}return n}const CA=()=>{},Ll=Array.isArray,_te=/ \ / $ / , gte = e => e . replace ( _te , "" ) ; function Qv ( e , t , n = "/" ) { let i , o = { } , r = "" , s = "" ; const a = t . indexOf ( "#" ) ; let c = t . indexOf ( "?" ) ; return a < c && a >= 0 && ( c = - 1 ) , c > - 1 && ( i = t . slice ( 0 , c ) , r = t . slice ( c + 1 , a > - 1 ? a : t . length ) , o = e ( r ) ) , a > - 1 && ( i = i || t . slice ( 0 , a ) , s = t . slice ( a , t . length ) ) , i = Tte ( i ? ? t , n ) , { fullPath : i + ( r && "?" ) + r + s , path : i , query : o , hash : s } } function yte ( e , t ) { const n = t . query ? e ( t . query ) : "" ; return t . path + ( n && "?" ) + n + ( t . hash || "" ) } function iF ( e , t ) { return ! t || ! e . toLowerCase ( ) . startsWith ( t . toLowerCase ( ) ) ? e : e . slice ( t . length ) || "/" } function Ate ( e , t , n ) { const i = t . matched . length - 1 , o = n . matched . length - 1 ; return i > - 1 && i === o && Zg ( t . matched [ i ] , n . matched [ o ] ) && m5 ( t . params , n . params ) && e ( t . query ) === e ( n . query ) && t . hash === n . hash } function Zg ( e , t ) { return ( e . aliasOf || e ) === ( t . aliasOf || t ) } function m5 ( e , t ) { if ( Object . keys ( e ) . length !== Object . keys ( t ) . length ) return ! 1 ; for ( const n in e ) if ( ! Cte ( e [ n ] , t [ n ] ) ) return ! 1 ; return ! 0 } function Cte ( e , t ) { return Ll ( e ) ? oF ( e , t ) : Ll ( t ) ? oF ( t , e ) : e === t } function oF ( e , t ) { return Ll ( t ) ? e . length === t . length && e . every ( ( n , i ) => n === t [ i ] ) : e . length === 1 && e [ 0 ] === t } function Tte ( e , t ) { if ( e . startsWith ( "/" ) ) return e ; if ( ! e ) return t ; const n = t . split ( "/" ) , i = e . split ( "/" ) ; let o = n . length - 1 , r , s ; for ( r = 0 ; r < i . length ; r ++ ) if ( s = i [ r ] , s !== "." ) if ( s === ".." ) o > 1 && o -- ; else break ; return n . slice ( 0 , o ) . join ( "/" ) + "/" + i . slice ( r - ( r === i . length ? 1 : 0 ) ) . join ( "/" ) } var $A ; ( function ( e ) { e . pop = "pop" , e . push = "push" } ) ( $A || ( $A = { } ) ) ; var TA ; ( function ( e ) { e . back = "back" , e . forward = "forward" , e . unknown = "" } ) ( TA || ( TA = { } ) ) ; function bte ( e ) { if ( ! e ) if ( ng ) { const t = document . querySelector ( "base" ) ; e = t && t . getAttribute ( "href" ) || "/" , e = e . replace ( /^\w+:\/\/[^\/]+/ , "" ) } else e = "/" ; return e [ 0 ] !== "/" && e [ 0 ] !== "#" && ( e = "/" + e ) , gte ( e ) } const Ete = /^[^#]+#/ ; function xte ( e , t ) { return e . replace ( Ete , "#" ) + t } function wte ( e , t ) { const n = document . documentElement . getBoundingClientRect ( ) , i = e . getBoundingClientRect ( ) ; return { behavior : t . behavior , left : i . left - n . left - ( t . left || 0 ) , top : i . top - n . top - ( t . top || 0 ) } } const dS = ( ) => ( { left : window . pageXOffset , top : window . pageYOffset } ) ; function Ste ( e ) { let t ; if ( "el" in e ) { const n = e . el , i = typeof n == "string" && n . startsWith ( "#" ) , o = typeof n == "string" ? i ? document . getElementById ( n . slice ( 1 ) ) : document . querySelector ( n ) : n ; if ( ! o ) return ; t = wte ( o , e ) } else t = e ; "scrollBehavior" in document . documentElement . style ? window . scrollTo ( t ) : window . scrollTo ( t . left != null ? t . left : window . pageXOffset , t . top != null ? t . top : window . pageYOffset ) } function rF ( e , t ) { return ( history . state ? history . state . position - t : - 1 ) + e } const WO = new Map ; function vte ( e , t ) { WO . set ( e , t ) } function Dte ( e ) { const t = WO . get ( e ) ; return WO . delete ( e ) , t } let Ite = ( ) => location . protocol + "//" + location . host ; function _5 ( e , t ) { const { pathname : n , search : i , hash : o } = t , r = e . indexOf ( "#" ) ; if ( r > - 1 ) { let a = o . includes ( e . slice ( r ) ) ? e . slice ( r ) . length : 1 , c = o . slice ( a ) ; return c [ 0 ] !== "/" && ( c = "/" + c ) , iF ( c , "" ) } return iF ( n , e ) + i + o } function Pte ( e , t , n , i ) { let o = [ ] , r = [ ] , s = null ; const a = ( { state : _ } ) => { const g = _5 ( e , location ) , p = n . value , A = t . value ; let C = 0 ; if ( _ ) { if ( n . value = g , t . value = _ , s && s === p ) { s = null ; return } C = A ? _ . position - A . position : 0 } else i ( g ) ; o . forEach ( b => { b ( n . value , p , { delta : C , type : $A . pop , direction : C ? C > 0 ? TA . forward : TA . back : TA . unknown } ) } ) } ; function c ( ) { s = n . value } function u ( _ ) { o . push ( _ ) ; const g = ( ) => { const p = o . indexOf ( _ ) ; p > - 1 && o . splice ( p , 1 ) } ; return r . push ( g ) , g } function f ( ) { const { history : _ } = window ; _ . state && _ . replaceState ( Fi ( { } , _ . state , { scroll : dS ( ) } ) , "" ) } function h ( ) { for ( const _ of r ) _ ( ) ; r = [ ] , window . removeEventListener ( "popstate" , a ) , window . removeEventListener ( "beforeunload" , f ) } return window . addEventListener ( "popstate" , a ) , window . addEventListener ( "beforeunload" , f ) , { pauseListeners : c , listen : u , destroy : h } } function sF ( e , t , n , i = ! 1 , o = ! 1 ) { return { back : e , current : t , forward : n , replaced : i , position : window . history . length , scroll : o ? dS ( ) : null } } function Ote ( e ) { const { history : t , location : n } = window , i = { value : _5 ( e , n ) } , o = { value : t . state } ; o . value || r ( i . value , { back : null , current : i . value , forward : null , position : t . length - 1 , replaced : ! 0 , scroll : null } , ! 0 ) ; function r ( c , u , f
$ { this . stack . toString ( ) } ` ),e};E.throwInstantiationError=function(){throw new E("This function defines an interface and should not be called directly.")};const hr={};hr.typeOf={};function Cne(e){return ` $ { e } is required , actual value was undefined ` }function by(e,t,n){return ` Expected $ { n } to be typeof $ { t } , actual typeof was $ { e } ` }hr.defined=function(e,t){if(!l(t))throw new E(Cne(e))};hr.typeOf.func=function(e,t){if(typeof t!="function")throw new E(by(typeof t,"function",e))};hr.typeOf.string=function(e,t){if(typeof t!="string")throw new E(by(typeof t,"string",e))};hr.typeOf.number=function(e,t){if(typeof t!="number")throw new E(by(typeof t,"number",e))};hr.typeOf.number.lessThan=function(e,t,n){if(hr.typeOf.number(e,t),t>=n)throw new E( ` Expected $ { e } to be less than $ { n } , actual value was $ { t } ` )};hr.typeOf.number.lessThanOrEquals=function(e,t,n){if(hr.typeOf.number(e,t),t>n)throw new E( ` Expected $ { e } to be less than or equal to $ { n } , actual value was $ { t } ` )};hr.typeOf.number.greaterThan=function(e,t,n){if(hr.typeOf.number(e,t),t<=n)throw new E( ` Expected $ { e } to be greater than $ { n } , actual value was $ { t } ` )};hr.typeOf.number.greaterThanOrEquals=function(e,t,n){if(hr.typeOf.number(e,t),t<n)throw new E( ` Expected $ { e } to be greater than or equal to $ { n } , actual value was $ { t } ` )};hr.typeOf.object=function(e,t){if(typeof t!="object")throw new E(by(typeof t,"object",e))};hr.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new E(by(typeof t,"boolean",e))};hr.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new E(by(typeof t,"bigint",e))};hr.typeOf.number.equals=function(e,t,n,i){if(hr.typeOf.number(e,n),hr.typeOf.number(t,i),n!==i)throw new E( ` $ { e } must be equal to $ { t } , the actual values are $ { n } and $ { i } ` )};const T=hr;function y(e,t){return e??t}y.EMPTY_OBJECT=Object.freeze({});var Pg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},sd=function(e){e==null&&(e=new Date().getTime()),this.N=624,this.M=397,this.MATRIX_A=2567483615,this.UPPER_MASK=2147483648,this.LOWER_MASK=2147483647,this.mt=new Array(this.N),this.mti=this.N+1,e.constructor==Array?this.init_by_array(e,e.length):this.init_seed(e)};sd.prototype.init_seed=function(e){for(this.mt[0]=e>>>0,this.mti=1;this.mti<this.N;this.mti++){var e=this.mt[this.mti-1]^this.mt[this.mti-1]>>>30;this.mt[this.mti]=(((e&4294901760)>>>16)*1812433253<<16)+(e&65535)*1812433253+this.mti,this.mt[this.mti]>>>=0}};sd.prototype.init_by_array=function(e,t){var n,i,o;for(this.init_seed(19650218),n=1,i=0,o=this.N>t?this.N:t;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1664525<<16)+(r&65535)*1664525)+e[i]+i,this.mt[n]>>>=0,n++,i++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1),i>=t&&(i=0)}for(o=this.N-1;o;o--){var r=this.mt[n-1]^this.mt[n-1]>>>30;this.mt[n]=(this.mt[n]^(((r&4294901760)>>>16)*1566083941<<16)+(r&65535)*1566083941)-n,this.mt[n]>>>=0,n++,n>=this.N&&(this.mt[0]=this.mt[this.N-1],n=1)}this.mt[0]=2147483648};sd.prototype.random_int=function(){var e,t=new Array(0,this.MATRIX_A);if(this.mti>=this.N){var n;for(this.mti==this.N+1&&this.init_seed(5489),n=0;n<this.N-this.M;n++)e=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+this.M]^e>>>1^t[e&1];for(;n<this.N-1;n++)e=this.mt[n]&this.UPPER_MASK|this.mt[n+1]&this.LOWER_MASK,this.mt[n]=this.mt[n+(this.M-this.N)]^e>>>1^t[e&1];e=this.mt[this.N-1]&this.UPPER_MASK|this.mt[0]&this.LOWER_MASK,this.mt[this.N-1]=this.mt[this.M-1]^e>>>1^t[e&1],this.mti=0}return e=this.mt[this.mti++],e^=e>>>11,e^=e<<7&2636928640,e^=e<<15&4022730752,e^=e>>>18,e>>>0};sd.prototype.random_int31=function(){return this.random_int()>>>1};sd.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};sd.prototype.random=function(){return this.random_int()*(1/4294967296)};sd.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};sd.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};var hS=sd;const Ye={};Ye.EPSILON1=.1;Ye.EPSILON2=.
( $ { this [ 1 ] } , $ { this [ 4 ] } , $ { this [ 7 ] } )
( $ { this [ 2 ] } , $ { this [ 5 ] } , $ { this [ 8 ] } ) ` };function Se(e){this.name="RuntimeError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}l(Object.create)&&(Se.prototype=Object.create(Error.prototype),Se.prototype.constructor=Se);Se.prototype.toString=function(){let e= ` $ { this . name } : $ { this . message } ` ;return l(this.stack)&&(e+= `
$ { this . stack . toString ( ) } ` ),e};function B(e,t,n,i,o,r,s,a,c,u,f,h,_,g,p,A){this[0]=y(e,0),this[1]=y(o,0),this[2]=y(c,0),this[3]=y(_,0),this[4]=y(t,0),this[5]=y(r,0),this[6]=y(u,0),this[7]=y(g,0),this[8]=y(n,0),this[9]=y(s,0),this[10]=y(f,0),this[11]=y(p,0),this[12]=y(i,0),this[13]=y(a,0),this[14]=y(h,0),this[15]=y(A,0)}B.packedLength=16;B.pack=function(e,t,n){return T.typeOf.object("value",e),T.defined("array",t),n=y(n,0),t[n++]=e[0],t[n++]=e[1],t[n++]=e[2],t[n++]=e[3],t[n++]=e[4],t[n++]=e[5],t[n++]=e[6],t[n++]=e[7],t[n++]=e[8],t[n++]=e[9],t[n++]=e[10],t[n++]=e[11],t[n++]=e[12],t[n++]=e[13],t[n++]=e[14],t[n]=e[15],t};B.unpack=function(e,t,n){return T.defined("array",e),t=y(t,0),l(n)||(n=new B),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};B.packArray=function(e,t){T.defined("array",e);const n=e.length,i=n*16;if(!l(t))t=new Array(i);else{if(!Array.isArray(t)&&t.length!==i)throw new E("If result is a typed array, it must have exactly array.length * 16 elements");t.length!==i&&(t.length=i)}for(let o=0;o<n;++o)B.pack(e[o],t,o*16);return t};B.unpackArray=function(e,t){if(T.defined("array",e),T.typeOf.number.greaterThanOrEquals("array.length",e.length,16),e.length%16!==0)throw new E("array length must be a multiple of 16.");const n=e.length;l(t)?t.length=n/16:t=new Array(n/16);for(let i=0;i<n;i+=16){const o=i/16;t[o]=B.unpack(e,i,t[o])}return t};B.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 B(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])};B.fromArray=B.unpack;B.fromColumnMajorArray=function(e,t){return T.defined("values",e),B.clone(e,t)};B.fromRowMajorArray=function(e,t){return T.defined("values",e),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 B(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])};B.fromRotationTranslation=function(e,t,n){return T.typeOf.object("rotation",e),t=y(t,d.ZERO),l(n)?(n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=0,n[4]=e[3],n[5]=e[4],n[6]=e[5],n[7]=0,n[8]=e[6],n[9]=e[7],n[10]=e[8],n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,n):new B(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)};B.fromTranslationQuaternionRotationScale=function(e,t,n,i){T.typeOf.object("translation",e),T.typeOf.object("rotation",t),T.typeOf.object("scale",n),l(i)||(i=new B);const o=n.x,r=n.y,s=n.z,a=t.x*t.x,c=t.x*t.y,u=t.x*t.z,f=t.x*t.w,h=t.y*t.y,_=t.y*t.z,g=t.y*t.w,p=t.z*t.z,A=t.z*t.w,C=t.w*t.w,b=a-h-p+C,x=2*(c-A),w=2*(u+g),S=2*(c+A),P=-a+h-p+C,L=2*(_-f),H=2*(u-g),R=2*(_+f),z=-a-h+p+C;return i[0]=b*o,i[1]=S*o,i[2]=H*o,i[3]=0,i[4]=x*r,i[5]=P*r,i[6]=R*r,i[7]=0,i[8]=w*s,i[9]=L*s,i[10]=z*s,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,i};B.fromTranslationRotationScale=function(e,t){return T.typeOf.object("translationRotationScale",e),B.fromTranslationQuaternionRotationScale(e.translation,e.rotation,e.scale,t)};B.fromTranslation=function(e,t){return T.typeOf.object("translation",e),B.fromRotationTranslation(J.IDENTITY,e,t)};B.fromScale=function(e,t){return T.typeOf.object("scale",e),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 B(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1)};B.fromUniformScale=function(e,t){return T.typeOf.number("scale",e),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 B(e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1)};B.fromRotation=function(e,t){return T.typeOf.object("rotation",e),l(t)||(t=new B),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
( $ { this [ 1 ] } , $ { this [ 5 ] } , $ { this [ 9 ] } , $ { this [ 13 ] } )
( $ { this [ 2 ] } , $ { this [ 6 ] } , $ { this [ 10 ] } , $ { this [ 14 ] } )
( $ { this [ 3 ] } , $ { this [ 7 ] } , $ { this [ 11 ] } , $ { this [ 15 ] } ) ` };const Gne={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXT
attribute vec2 textureCoordinates ;
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _Position = position ;
v _textureCoordinates = textureCoordinates ;
}
` ,_o={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 ft(e){e=y(e,y.EMPTY_OBJECT),this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._modelMatrix=e.modelMatrix,this._primitiveType=y(e.primitiveType,Je.TRIANGLES),this._vertexArray=e.vertexArray,this._count=e.count,this._offset=y(e.offset,0),this._instanceCount=y(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._flags=0,this.cull=y(e.cull,!0),this.occlude=y(e.occlude,!0),this.executeInClosestFrustum=y(e.executeInClosestFrustum,!1),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.castShadows=y(e.castShadows,!1),this.receiveShadows=y(e.receiveShadows,!1),this.pickOnly=y(e.pickOnly,!1),this.depthForTranslucentClassification=y(e.depthForTranslucentClassification,!1),this.dirty=!0,this.lastDirtyTime=0,this.derivedCommands={}}function ms(e,t){return(e._flags&t)===t}function Od(e,t,n){n?e._flags|=t:e._flags&=~t}Object.defineProperties(ft.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 ms(this,_o.CULL)},set:function(e){ms(this,_o.CULL)!==e&&(Od(this,_o.CULL,e),this.dirty=!0)}},occlude:{get:function(){return ms(this,_o.OCCLUDE)},set:function(e){ms(this,_o.OCCLUDE)!==e&&(Od(this,_o.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 ms(this,_o.CAST_SHADOWS)},set:function(e){ms(this,_o.CAST_SHADOWS)!==e&&(Od(this,_o.CAST_SHADOWS,e),this.dirty=!0)}},receiveShadows:{get:function(){return ms(this,_o.RECEIVE_SHADOWS)},set:function(e){ms(this,_o.RECEIVE_SHADOWS)!==e&&(Od(this,_o.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 ms(this,_o.EXECUTE_IN_CLOSEST_FRUSTUM)},set:function(e){ms(this,_o.EXECUTE_IN_CLOSEST_FRUSTUM)!==e&&(Od(this,_o.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 ms(this,_o.DEBUG_SHOW_BOUNDING_VOLUME)},set:function(e){ms(this,_o.DEBUG_SHOW_BOUNDING_VOLUME)!==e&&(Od(this,_o.DEBUG_SHOW_BOUNDING_VOLUME,e),this.dirty=!0)}},debugOverlappingFrustums:{g
( $ { this [ 1 ] } , $ { this [ 3 ] } ) ` };function Uie(e,t,n,i){switch(t.type){case e.FLOAT:return new n8(e,t,n,i);case e.FLOAT_VEC2:return new i8(e,t,n,i);case e.FLOAT_VEC3:return new o8(e,t,n,i);case e.FLOAT_VEC4:return new r8(e,t,n,i);case e.SAMPLER_2D:case e.SAMPLER_CUBE:return new DB(e,t,n,i);case e.INT:case e.BOOL:return new s8(e,t,n,i);case e.INT_VEC2:case e.BOOL_VEC2:return new a8(e,t,n,i);case e.INT_VEC3:case e.BOOL_VEC3:return new c8(e,t,n,i);case e.INT_VEC4:case e.BOOL_VEC4:return new l8(e,t,n,i);case e.FLOAT_MAT2:return new u8(e,t,n,i);case e.FLOAT_MAT3:return new f8(e,t,n,i);case e.FLOAT_MAT4:return new d8(e,t,n,i);default:throw new Se( ` Unrecognized uniform type : $ { t . type } for uniform "${n}" . ` )}}function n8(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}n8.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1f(this._location,this.value))};function i8(e,t,n,i){this.name=n,this.value=void 0,this._value=new j,this._gl=e,this._location=i}i8.prototype.set=function(){const e=this.value;j.equals(e,this._value)||(j.clone(e,this._value),this._gl.uniform2f(this._location,e.x,e.y))};function o8(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}o8.prototype.set=function(){const e=this.value;if(l(e.red))F.equals(e,this._value)||(this._value=F.clone(e,this._value),this._gl.uniform3f(this._location,e.red,e.green,e.blue));else if(l(e.x))d.equals(e,this._value)||(this._value=d.clone(e,this._value),this._gl.uniform3f(this._location,e.x,e.y,e.z));else throw new E( ` Invalid vec3 value for uniform "${this.name}" . ` )};function r8(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}r8.prototype.set=function(){const e=this.value;if(l(e.red))F.equals(e,this._value)||(this._value=F.clone(e,this._value),this._gl.uniform4f(this._location,e.red,e.green,e.blue,e.alpha));else if(l(e.x))oe.equals(e,this._value)||(this._value=oe.clone(e,this._value),this._gl.uniform4f(this._location,e.x,e.y,e.z,e.w));else throw new E( ` Invalid vec4 value for uniform "${this.name}" . ` )};function DB(e,t,n,i){this.name=n,this.value=void 0,this._gl=e,this._location=i,this.textureUnitIndex=void 0}DB.prototype.set=function(){const e=this._gl;e.activeTexture(e.TEXTURE0+this.textureUnitIndex);const t=this.value;e.bindTexture(t._target,t._texture)};DB.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function s8(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}s8.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1i(this._location,this.value))};function a8(e,t,n,i){this.name=n,this.value=void 0,this._value=new j,this._gl=e,this._location=i}a8.prototype.set=function(){const e=this.value;j.equals(e,this._value)||(j.clone(e,this._value),this._gl.uniform2i(this._location,e.x,e.y))};function c8(e,t,n,i){this.name=n,this.value=void 0,this._value=new d,this._gl=e,this._location=i}c8.prototype.set=function(){const e=this.value;d.equals(e,this._value)||(d.clone(e,this._value),this._gl.uniform3i(this._location,e.x,e.y,e.z))};function l8(e,t,n,i){this.name=n,this.value=void 0,this._value=new oe,this._gl=e,this._location=i}l8.prototype.set=function(){const e=this.value;oe.equals(e,this._value)||(oe.clone(e,this._value),this._gl.uniform4i(this._location,e.x,e.y,e.z,e.w))};const Hie=new Float32Array(4);function u8(e,t,n,i){this.name=n,this.value=void 0,this._value=new at,this._gl=e,this._location=i}u8.prototype.set=function(){if(!at.equalsArray(this.value,this._value,0)){at.clone(this.value,this._value);const e=at.toArray(this.value,Hie);this._gl.uniformMatrix2fv(this._location,!1,e)}};const Vie=new Float32Array(9);function f8(e,t,n,i){this.name=n,this.value=void 0,this._value=new J,this._gl=e,this._location=i}f8.prototype.set=function(){if(!J.equalsArray(this.value,this._value,0)){J.clone(this.value,this._value);const e=J.toArray(this.value,Vie);this._gl.uniformMatrix3fv(this._location,!1,e)}};const kie=new Float32Array(16);funct
$ { n } ` ),u= ` Vertex shader failed to compile . Compile log : $ { c } ` ):(c=e.getShaderInfoLog(r),console.error( ` $ { ou } Fragment shader compile log : $ { c } ` ),console.error( ` $ { ou } Fragment shader source :
$ { i } ` ),u= ` Fragment shader failed to compile . Compile log : $ { c } ` ),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(s),new Se(u);function h(_,g){if(!l(f))return;const p=f.getTranslatedShaderSource(_);if(p===""){console.error( ` $ { ou } $ { g } shader translation failed . ` );return}console.error( ` $ { ou } Translated $ { g } shaderSource :
2023-02-01 02:29:19 +00:00
$ { p } ` )}}function Yie(e,t,n){const i={};for(let o=0;o<n;++o){const 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 Xie(e,t){const n={},i=[],o=[],r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){const a=e.getActiveUniform(t,s),c="[0]",u=a.name.indexOf(c,a.name.length-c.length)!==-1?a.name.slice(0,a.name.length-3):a.name;if(u.indexOf("gl_")!==0)if(a.name.indexOf("[")<0){const f=e.getUniformLocation(t,u);if(f!==null){const h=Uie(e,a,u,f);n[u]=h,i.push(h),h._setSampler&&o.push(h)}}else{let f,h,_,g;const p=u.indexOf("[");if(p>=0){if(f=n[u.slice(0,p)],!l(f))continue;h=f._locations,h.length<=1&&(_=f.value,g=e.getUniformLocation(t,u),g!==null&&(h.push(g),_.push(e.getUniform(t,g))))}else{h=[];for(let A=0;A<a.size;++A)g=e.getUniformLocation(t, ` $ { u } [ $ { A } ] ` ),g!==null&&h.push(g);f=Gie(e,a,u,h),n[u]=f,i.push(f),f._setSampler&&o.push(f)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:o}}function $ ie(e,t){const n=[],i=[];for(const o in t)if(t.hasOwnProperty(o)){const r=t[o];let s=o;const a=e._duplicateUniformNames[s];l(a)&&(r.name=a,s=a);const c=KE[s];l(c)?n.push({uniform:r,automaticUniform:c}):i.push(r)}return{automaticUniforms:n,manualUniforms:i}}function Kie(e,t,n){e.useProgram(t);let i=0;const o=n.length;for(let r=0;r<o;++r)i=n[r]._setSampler(i);return e.useProgram(null),i}function ZE(e){l(e._program)||x8(e)}function x8(e){const t=e._program,n=e._gl,i=qie(n,e,e._debugShaders),o=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),r=Xie(n,i),s= $ ie(e,r.uniformsByName);e._program=i,e._numberOfVertexAttributes=o,e._vertexAttributes=Yie(n,i,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=s.automaticUniforms,e._manualUniforms=s.manualUniforms,e.maximumTextureUnitIndex=Kie(n,i,r.samplerUniforms),t&&e._gl.deleteProgram(t),typeof spector<"u"&&(e._program.__SPECTOR_rebuildProgram=function(a,c,u,f){const h=e._vertexShaderText,_=e._fragmentShaderText,g=/ ! = /g;e._vertexShaderText=a.replace(g," != "),e._fragmentShaderText=c.replace(g," != ");try{x8(e),u(e._program)}catch(p){e._vertexShaderText=h,e._fragmentShaderText=_;const C=/(?:Compile|Link) error: ([^]*)/.exec(p.message);f(C?C[1]:p.message)}})}un.prototype._bind=function(){ZE(this),this._gl.useProgram(this._program)};un.prototype._setUniforms=function(e,t,n){let i,o;if(l(e)){const a=this._manualUniforms;for(i=a.length,o=0;o<i;++o){const c=a[o];c.value=e[c.name]()}}const r=this._automaticUniforms;for(i=r.length,o=0;o<i;++o){const a=r[o];a.uniform.value=a.automaticUniform.getValue(t)}const s=this._uniforms;for(i=s.length,o=0;o<i;++o)s[o].set();if(n){const a=this._gl,c=this._program;if(a.validateProgram(c),!a.getProgramParameter(c,a.VALIDATE_STATUS))throw new E( ` Program validation failed . Program info log : $ { a . getProgramInfoLog ( c ) } ` )}};un.prototype.isDestroyed=function(){return!1};un.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};un.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),Ue(this)};function mS(e){this._context=e}let Ky;const Jie=new ft({primitiveType:Je.TRIANGLES}),Qie=new ji({color:new F(0,0,0,0)});function Zie(e,t){return new Dr({context:e,colorTextures:[t],destroyAttachments:!1})}function eoe(e,t){return un.fromCache({context:e,vertexShaderSource:H5,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function toe(e,t){return(!l(Ky)||Ky.viewport.width!==e||Ky.viewport.height!==t)&&(Ky=Qe.fromCache({viewport:new qe(0,0,e,t)})),Ky}mS.prototype.execute=function(e){if(T.defined("computeCommand",e),l(e.preExecute)&&e.preExecute(e),!l(e.fragmentShaderSource)&&!l(e.shaderProgram))throw new E("computeCommand.fragmentShaderSource or computeCommand.shaderProgram is required.");T.defined("computeCommand.outputTexture",e.outputTexture);const 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:eoe(o,e.fragmentShaderSource),a=Zie(o,t),c=toe(n,i),u=e.uniformMap,f=Qie;f.framebuffer=a,f.ren
2023-02-01 01:46:39 +00:00
* URI . js - Mutating URLs
* IPv6 Support
*
* Version : 1.19 . 11
*
* Author : Rodney Rehm
* Web : http : //medialize.github.io/URI.js/
*
* Licensed under
* MIT License http : //www.opensource.org/licenses/mit-license
*
* /var kF;function xoe(){return kF||(kF=1,function(e){(function(t,n){e.exports?e.exports=n():t.IPv6=n(t)})(Pg,function(t){var n=t&&t.IPv6;function i(r){var s=r.toLowerCase(),a=s.split(":"),c=a.length,u=8;a[0]===""&&a[1]===""&&a[2]===""?(a.shift(),a.shift()):a[0]===""&&a[1]===""?a.shift():a[c-1]===""&&a[c-2]===""&&a.pop(),c=a.length,a[c-1].indexOf(".")!==-1&&(u=7);var f;for(f=0;f<c&&a[f]!=="";f++);if(f<u)for(a.splice(f,1,"0000");a.length<u;)a.splice(f,0,"0000");for(var h,_=0;_<u;_++){h=a[_].split("");for(var g=0;g<3&&(h[0]==="0"&&h.length>1);g++)h.splice(0,1);a[_]=h.join("")}var p=-1,A=0,C=0,b=-1,x=!1;for(_=0;_<u;_++)x?a[_]==="0"?C+=1:(x=!1,C>A&&(p=b,A=C)):a[_]==="0"&&(x=!0,b=_,C=1);C>A&&(p=b,A=C),A>1&&a.splice(p,A,""),c=a.length;var w="";for(a[0]===""&&(w=":"),_=0;_<c&&(w+=a[_],_!==c-1);_++)w+=":";return a[c-1]===""&&(w+=":"),w}function o(){return t.IPv6===this&&(t.IPv6=n),this}return{best:i,noConflict:o}})}(Eoe)),Zx}var ew={},woe={get exports(){return ew},set exports(e){ew=e}};/ * !
* URI . js - Mutating URLs
* Second Level Domain ( SLD ) Support
*
* Version : 1.19 . 11
*
* Author : Rodney Rehm
* Web : http : //medialize.github.io/URI.js/
*
* Licensed under
* MIT License http : //www.opensource.org/licenses/mit-license
*
* / v a r G F ; f u n c t i o n S o e ( ) { r e t u r n G F | | ( G F = 1 , f u n c t i o n ( e ) { ( f u n c t i o n ( t , n ) { e . e x p o r t s ? e . e x p o r t s = n ( ) : t . S e c o n d L e v e l D o m a i n s = n ( t ) } ) ( P g , f u n c t i o n ( t ) { v a r n = t & & t . S e c o n d L e v e l D o m a i n s , i = { l i s t : { a c : " c o m g o v m i l n e t o r g " , a e : " a c c o g o v m i l n a m e n e t o r g p r o s c h " , a f : " c o m e d u g o v n e t o r g " , a l : " c o m e d u g o v m i l n e t o r g " , a o : " c o e d g v i t o g p b " , a r : " c o m e d u g o b g o v i n t m i l n e t o r g t u r " , a t : " a c c o g v o r " , a u : " a s n c o m c s i r o e d u g o v i d n e t o r g " , b a : " c o c o m e d u g o v m i l n e t o r g r s u n b i u n m o u n s a u n t z u n z e " , b b : " b i z c o c o m e d u g o v i n f o n e t o r g s t o r e t v " , b h : " b i z c c c o m e d u g o v i n f o n e t o r g " , b n : " c o m e d u g o v n e t o r g " , b o : " c o m e d u g o b g o v i n t m i l n e t o r g t v " , b r : " a d m a d v a g r a m a r q a r t a t o b b i o b l o g b m d c i m c n g c n t c o m c o o p e c n e d u e n g e s p e t c e t i f a r f l o g f m f n d f o t f s t g 1 2 g g f g o v i m b i n d i n f j o r j u s l e l m a t m e d m i l m u s n e t n o m n o t n t r o d o o r g p p g p r o p s c p s i q s l r e c s l g s r v t m p t r d t u r t v v e t v l o g w i k i z l g " , b s : " c o m e d u g o v n e t o r g " , b z : " d u e t o m o v r g " , c a : " a b b c m b n b n f n l n s n t n u o n p e q c s k y k " , c k : " b i z c o e d u g e n g o v i n f o n e t o r g " , c n : " a c a h b j c o m c q e d u f j g d g o v g s g x g z h a h b h e h i h l h n j l j s j x l n m i l n e t n m n x o r g q h s c s d s h s n s x t j t w x j x z y n z j " , c o : " c o m e d u g o v m i l n e t n o m o r g " , c r : " a c c c o e d f i g o o r s a " , c y : " a c b i z c o m e k l o g e s g o v l t d n a m e n e t o r g p a r l i a m e n t p r e s s p r o t m " , d o : " a r t c o m e d u g o b g o v m i l n e t o r g s l d w e b " , d z : " a r t a s s o c o m e d u g o v n e t o r g p o l " , e c : " c o m e d u f i n g o v i n f o m e d m i l n e t o r g p r o " , e g : " c o m e d u e u n g o v m i l n a m e n e t o r g s c i " , e r : " c o m e d u g o v i n d m i l n e t o r g r o c h e s t w " , e s : " c o m e d u g o b n o m o r g " , e t : " b i z c o m e d u g o v i n f o n a m e n e t o r g " , f j : " a c b i z c o m i n f o m i l n a m e n e t o r g p r o " , f k : " a c c o g o v n e t n o m o r g " , f r : " a s s o c o m f g o u v n o m p r d p r e s s e t m " , g g : " c o n e t o r g " , g h : " c o m e d u g o v m i l o r g " , g n : " a c c o m g o v n e t o r g " , g r : " c o m e d u g o v m i l n e t o r g " , g t : " c o m e d u g o b i n d m i l n e t o r g " , g u : " c o m e d u g o v n e t o r g " , h k : " c o m e d u g o v i d v n e t o r g " , h u : " 2 0 0 0 a g r a r b o l t c a s i n o c i t y c o e r o t i c a e r o t i k a f i l m f o r u m g a m e s h o t e l i n f o i n g a t l a n j o g a s z k o n y v e l o l a k a s m e d i a n e w s o r g p r i v r e k l a m s e x s h o p s p o r t s u l i s z e x t m t o z s d e u t a z a s v i d e o " , i d : " a c c o g o m i l n e t o r s c h w e b " , i l : " a c c o g o v i d f k 1 2 m u n i n e t o r g " , i n : " a c c o e d u e r n e t f i r m g e n g o v i i n d m i l n e t n i c o r g r e s " , i q : " c o m e d u g o v i m i l n e t o r g " , i r : " a c c o d n s s e c g o v i i d n e t o r g s c h " , i t : " e d u g o v " , j e : " c o n e t o r g " , j o : " c o m e d u g o v m i l n a m e n e t o r g s c h " , j p : " a c a d c o e d g o g r l g n e o r " , k e : " a c c o g o i n f o m e m o b i n e o r s c " , k h : " c o m e d u g o v m i l n e t o r g p e r " , k i : " b i z c o m d e e d u g o v i n f o m o b n e t o r g t e l " , k m : " a s s o c o m c o o p e d u g o u v k m e d e c i n m i l n o m n o t a i r e s p h a r m a c i e n s p r e s s e t m v e t e r i n a i r e " , k n : " e d u g o v n e t o r g " , k r : " a c b u s a n c h u n g b u k c h u n g n a m c o d a e g u d a e j e o n e s g a n g w o n g o g w a n g j u g y e o n g b u k g y e o n g g i g y e o n g n a m h s i n c h e o n j e j u j e o n b u k j e o n n a m k k g m i l m s n e o r p e r e s c s e o u l u l s a n " , k w : " c o m e d u g o v n e t o r g " , k y : " c o m e d u g o v n e t o r g " , k z : " c o m e d u g o v m i l n e t o r g " , l b : " c o m e d u g o v n e t o r g " , l k : " a s s n c o m e d u g o v g r p h o t e l i n t l t d n e t n g o o r g s c h s o c w e b " , l r : " c o m e d u g o v n e t o r g " , l v : " a s n c o m c o n f e d u g o v i d m i l n e t o r g " , l y : " c o m e d u g o v i d m e d n e t o r g p l c s c h " , m a : " a c c o g o v m n e t o r g p r e s s " , m c : " a s s o t m " , m e : " a c c o e d u g o v i t s n e t o r g p r i v " , m g : " c o m e d u g o v m i l n o m o r g p r d t m " , m k : " c o m e d u g o v i n f n a m e n e t o r g p r o " , m l : " c o m e d u g o v n e t o r g p r e s s e " , m n : " e d u g o v o r g " , m o : " c o m e d u g o v n e t o r g " , m t : " c o m e d u g o v n e t o r g " , m v : " a e r o b i z c o m c o o p e d u g o v i n f o i n t m i l m u s e u m n a m e n e t o r g p r o " , m w : " a c c o c o m c o o p e d u g o v i n t m u s e u m n e t o r g " , m x : " c o m e d u g o b n e t o r g " , m y : " c o m e d u g o v m i l n a m e n e t o r g s c h " , n f : " a r t s c o m f i r m i n f o n e t o t h e r p e r r e c s t o r e w e b " , n g : " b i z c o m e d u g o v m i l m o b i n a m e n e t o r g s c h " , n i : " a c c o c o m e d u g o b m i l n e t n o m o r g " , n p : " c o m e d u g o v m i l n e t o r g " , n r : " b i z c o m e d u g o v i n f o n e t o r g " , o m : " a c b i z c o c o m e d u g o v m e d m i l m u s e u m n e t o r g p r o s c h " , p e : " c o m e d u g o b m i l n e t n o m o r g s l d " , p h : " c o m e d u g o v i m i l n e t n g o o r g " , p k : " b i z c o m e d u f a m g o b g o k g o n g o p g o s g o v n e t o r g w e b " , p l : " a r t b i a l y s t o k b i z c o m e d u g d a g d a n s k g o r z o w g o v i n f o k a t o w i c e k r a k o w l o d z l u b l i n m i l n e t n g o o l s z t y n o r g p o z n a n p w r
* URI . js - Mutating URLs
*
* Version : 1.19 . 11
*
* Author : Rodney Rehm
* Web : http : //medialize.github.io/URI.js/
*
* Licensed under
* MIT License http : //www.opensource.org/licenses/mit-license
*
* /(function(e){(function(t,n){e.exports?e.exports=n(boe(),xoe(),Soe()):t.URI=n(t.punycode,t.IPv6,t.SecondLevelDomains,t)})(Pg,function(t,n,i,o){var r=o&&o.URI;function s(m,D){var O=arguments.length>=1,M=arguments.length>=2;if(!(this instanceof s))return O?M?new s(m,D):new s(m):new s;if(m===void 0){if(O)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?m=location.href+"":m=""}if(m===null&&O)throw new TypeError("null is not a valid argument for URI");return this.href(m),D!==void 0?this.absoluteTo(D):this}function a(m){return/ ^ [ 0 - 9 ] + $ / . test ( m ) } s . version = "1.19.11" ; var c = s . prototype , u = Object . prototype . hasOwnProperty ; function f ( m ) { return m . replace ( /([.*+?^=!:${}()|[\]\/\\])/g , "\\$1" ) } function h ( m ) { return m === void 0 ? "Undefined" : String ( Object . prototype . toString . call ( m ) ) . slice ( 8 , - 1 ) } function _ ( m ) { return h ( m ) === "Array" } function g ( m , D ) { var O = { } , M , V ; if ( h ( D ) === "RegExp" ) O = null ; else if ( _ ( D ) ) for ( M = 0 , V = D . length ; M < V ; M ++ ) O [ D [ M ] ] = ! 0 ; else O [ D ] = ! 0 ; for ( M = 0 , V = m . length ; M < V ; M ++ ) { var k = O && O [ m [ M ] ] !== void 0 || ! O && D . test ( m [ M ] ) ; k && ( m . splice ( M , 1 ) , V -- , M -- ) } return m } function p ( m , D ) { var O , M ; if ( _ ( D ) ) { for ( O = 0 , M = D . length ; O < M ; O ++ ) if ( ! p ( m , D [ O ] ) ) return ! 1 ; return ! 0 } var V = h ( D ) ; for ( O = 0 , M = m . length ; O < M ; O ++ ) if ( V === "RegExp" ) { if ( typeof m [ O ] == "string" && m [ O ] . match ( D ) ) return ! 0 } else if ( m [ O ] === D ) return ! 0 ; return ! 1 } function A ( m , D ) { if ( ! _ ( m ) || ! _ ( D ) || m . length !== D . length ) return ! 1 ; m . sort ( ) , D . sort ( ) ; for ( var O = 0 , M = m . length ; O < M ; O ++ ) if ( m [ O ] !== D [ O ] ) return ! 1 ; return ! 0 } function C ( m ) { var D = /^\/+|\/+$/g ; return m . replace ( D , "" ) } s . _parts = function ( ) { return { protocol : null , username : null , password : null , hostname : null , urn : null , port : null , path : null , query : null , fragment : null , preventInvalidHostname : s . preventInvalidHostname , duplicateQueryParameters : s . duplicateQueryParameters , escapeQuerySpace : s . escapeQuerySpace } } , s . preventInvalidHostname = ! 1 , s . duplicateQueryParameters = ! 1 , s . escapeQuerySpace = ! 0 , s . protocol _expression = /^[a-z][a-z0-9.+-]*$/i , s . idn _expression = /[^a-z0-9\._-]/i , s . punycode _expression = /(xn--)/i , s . ip4 _expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/ , s . 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*$/ , s . 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 , s . findUri = { start : /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi , end : /[\s\r\n]|$/ , trim : /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/ , parens : /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g } , s . leading _whitespace _expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/ , s . ascii _tab _whitespace = /[\u0009\u000A\u000D]+/g , s . defaultPorts = { http : "80" , https : "443" , ftp : "21" , gopher : "70" , ws : "80" , wss : "443" } , s . hostProtocols = [ "http" , "https" ] , s . invalid _hostname _characters = /[^a-zA-Z0-9\.\-:_]/ , s . domAttributes = { a : "href" , blockquote : "cite" , link : "href" , base : "href" , script : "src" , form : "action" , img : "src" , area : "href" , iframe : "src" , embed : "src" , source : "src" , track : "src" , input : "src" , audio : "src" , video : "src" } , s . getDomAttribute = f
` );for(let i=0;i<n.length;++i){const o=n[i],r=o.indexOf(": ");if(r>0){const s=o.substring(0,r),a=o.substring(r+2);t[s]=a}}return t}function ny(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=Foe(this.responseHeaders))}ny.prototype.toString=function(){let e="Request has failed.";return l(this.statusCode)&&(e+= ` Status Code : $ { this . statusCode } ` ),e};function Xe(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}Object.defineProperties(Xe.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}});Xe.prototype.addEventListener=function(e,t){T.typeOf.func("listener",e),this._listeners.push(e),this._scopes.push(t);const n=this;return function(){n.removeEventListener(e,t)}};Xe.prototype.removeEventListener=function(e,t){T.typeOf.func("listener",e);const n=this._listeners,i=this._scopes;let o=-1;for(let r=0;r<n.length;r++)if(n[r]===e&&i[r]===t){o=r;break}return o!==-1?(this._insideRaiseEvent?(this._toRemove.push(o),n[o]=void 0,i[o]=void 0):(n.splice(o,1),i.splice(o,1)),!0):!1};function zoe(e,t){return t-e}Xe.prototype.raiseEvent=function(){this._insideRaiseEvent=!0;let e;const t=this._listeners,n=this._scopes;let i=t.length;for(e=0;e<i;e++){const r=t[e];l(r)&&t[e].apply(n[e],arguments)}const o=this._toRemove;if(i=o.length,i>0){for(o.sort(zoe),e=0;e<i;e++){const r=o[e];t.splice(r,1),n.splice(r,1)}o.length=0}this._insideRaiseEvent=!1};function Ym(e){T.typeOf.object("options",e),T.defined("options.comparator",e.comparator),this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}Object.defineProperties(Ym.prototype,{length:{get:function(){return this._length}},internalArray:{get:function(){return this._array}},maximumLength:{get:function(){return this._maximumLength},set:function(e){T.typeOf.number.greaterThanOrEquals("maximumLength",e,0);const t=this._length;if(e<t){const 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 NB(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}Ym.prototype.reserve=function(e){e=y(e,this._length),this._array.length=e};Ym.prototype.heapify=function(e){e=y(e,0);const t=this._length,n=this._comparator,i=this._array;let o=-1,r=!0;for(;r;){const 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?(NB(i,o,e),e=o):r=!1}};Ym.prototype.resort=function(){const e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};Ym.prototype.insert=function(e){T.defined("element",e);const t=this._array,n=this._comparator,i=this._maximumLength;let o=this._length++;for(o<t.length?t[o]=e:t.push(e);o!==0;){const s=Math.floor((o-1)/2);if(n(t[o],t[s])<0)NB(t,o,s),o=s;else break}let r;return l(i)&&this._length>i&&(r=t[i],this._length=i),r};Ym.prototype.pop=function(e){if(e=y(e,0),this._length===0)return;T.typeOf.number.lessThan("index",e,this._length);const t=this._array,n=t[e];return NB(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};function Uoe(e,t){return e.priority-t.priority}const ui={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0};let Og=20;const Is=new Ym({comparator:Uoe});Is.maximumLength=Og;Is.reserve(Og);const yu=[];let Xf={};const Hoe=typeof document<"u"?new us(document.location.href):new us,gS=new Xe;function si(){}si.maximumRequests=50;si.maximumRequestsPerServer=6;si.requestsByServer={"api.cesium.com:443":18,"assets.cesium.com:443":18};si.throttleRequests=!0;si.debugShowStatistics=!1;si.requestCompletedEvent=gS;Object.defineProperties(si,{statistics:{get:function(){return ui}},priorityHeapLength:{get:function(){return Og},set:function(e){if(e<Og)for(;Is.length>e;){const t=Is.pop();pm(t)}Og=e,Is.maximumLength=e,Is.reserve(e)}}});function I8(e){l(e.priorityFunction)&&(e.priority=e.priorityFunction())}si.serverHasOpenSlots=function(e,t){t=y(t,1);const n=
` );if(/#version 300 es/g.test(e))return e;let o=-1,r,s;for(r=0;r<i.length;++r)if(s=i[r],n.test(s)){o=r;break}if(o===-1)throw new E("Could not find a #define OUTPUT_DECLARATION!");const a=[];for(r=0;r<10;r++){const A= ` gl _FragData \ \ [ $ { r } \ \ ] ` ,C= ` czm _out$ { r } ` ;new RegExp(A,"g").test(e)&&(QF(C,a),lu(A,C,i),i.splice(o,0, ` layout ( location = $ { r } ) out vec4 $ { C } ; ` ),o+=1)}const c="czm_fragColor";Vre("gl_FragColor",i)&&(QF(c,a),lu("gl_FragColor",c,i),i.splice(o,0,"layout(location = 0) out vec4 czm_fragColor;"),o+=1);const u=Gre(a,i),f={};for(r=0;r<i.length;r++){s=i[r];for(const A in u)u.hasOwnProperty(A)&&new RegExp( ` ( layout ) [ ^ ] + ( out ) [ ^ ] + ( $ { A } ) [ ^ ] + ` ,"g").test(s)&&(f[s]=A)}for(const A in f)if(f.hasOwnProperty(A)){const C=f[A];let b=i.indexOf(A);const x=u[C],w=x.length;for(let S=0;S<w;S++)i.splice(b,0,x[S]);b+=w+1;for(let S=w-1;S>=0;S--)i.splice(b,0, ` # endif //${x[S]}`)}const h="WEBGL_2",_=`#define ${h}`,g="#version 300 es";let p=!1;for(r=0;r<i.length;r++)if(/#version/.test(i[r])){i[r]=g,p=!0;break}return p||i.splice(0,0,g),i.splice(1,0,_),AD("EXT_draw_buffers",h,i),AD("EXT_frag_depth",h,i),AD("OES_standard_derivatives",h,i),lu("texture2D","texture",i),lu("texture3D","texture",i),lu("textureCube","texture",i),lu("gl_FragDepthEXT","gl_FragDepth",i),t?lu("varying","in",i):(lu("attribute","in",i),lu("varying","out",i)),kre(i)}function lu(e,t,n){const i=`(^|[^\\w])(${e})($|[^\\w])`,o=new RegExp(i,"g"),r=n.length;for(let s=0;s<r;++s){const a=n[s];n[s]=a.replace(o,`$1${t}$3`)}}function Hre(e,t,n){const i=n.length;for(let o=0;o<i;++o){const r=n[o];n[o]=r.replace(e,t)}}function Vre(e,t){const n=`(^|[^\\w])(${e})($|[^\\w])`,i=new RegExp(n,"g"),o=t.length;for(let r=0;r<o;++r){const s=t[r];if(i.test(s))return!0}return!1}function kre(e){let t="";const n=e.length;for(let i=0;i<n;++i)t+=`${e[i]}
` ;return t}function QF(e,t){t.indexOf(e)===-1&&t.push(e)}function Gre(e,t){const n={},i=e.length,o=[];for(let r=0;r<t.length;++r){const s=t[r],a=/(#ifdef|#if)/g.test(s),c=/#else/g.test(s),u=/#endif/g.test(s);if(a)o.push(s);else if(c){let h=o[o.length-1].replace("ifdef","ifndef");/if/g.test(h)&&(h=h.replace(/(#if \s +)( \S *)([^]*)/," $ 1!( $ 2) $ 3")),o.pop(),o.push(h)}else if(u)o.pop();else if(!/layout/g.test(s))for(let f=0;f<i;++f){const h=e[f];s.indexOf(h)!==-1&&(l(n[h])?n[h]=n[h].filter(function(_){return o.indexOf(_)>=0}):n[h]=o.slice())}}return n}function AD(e,t,n){const i= ` # extension \ \ s + GL _$ { e } \ \ s + : \ \ s + [ a - zA - Z0 - 9 ] + \ \ s * $ ` ;Hre(new RegExp(i,"g"),"",n),lu( ` GL _$ { e } ` ,t,n)}const Wre= ` / * *
* A built - in GLSL floating - point constant for converting radians to degrees .
*
* @ alias czm _degreesPerRadian
* @ glslConstant
*
* @ see CesiumMath . DEGREES _PER _RADIAN
*
* @ example
* // GLSL declaration
* const float czm _degreesPerRadian = ... ;
*
* // Example
* float deg = czm _degreesPerRadian * rad ;
* /
const float czm _degreesPerRadian = 57.29577951308232 ;
` ,jre= ` / * *
* A built - in GLSL vec2 constant for defining the depth range .
* This is a workaround to a bug where IE11 does not implement gl _DepthRange .
*
* @ alias czm _depthRange
* @ glslConstant
*
* @ example
* // GLSL declaration
* float depthRangeNear = czm _depthRange . near ;
* float depthRangeFar = czm _depthRange . far ;
*
* /
const czm _depthRangeStruct czm _depthRange = czm _depthRangeStruct ( 0.0 , 1.0 ) ;
` ,qre= ` / * *
* 0.1
*
* @ name czm _epsilon1
* @ glslConstant
* /
const float czm _epsilon1 = 0.1 ;
` ,Yre= ` / * *
* 0.01
*
* @ name czm _epsilon2
* @ glslConstant
* /
const float czm _epsilon2 = 0.01 ;
` ,Xre= ` / * *
* 0.001
*
* @ name czm _epsilon3
* @ glslConstant
* /
const float czm _epsilon3 = 0.001 ;
` , $ re= ` / * *
* 0.0001
*
* @ name czm _epsilon4
* @ glslConstant
* /
const float czm _epsilon4 = 0.0001 ;
` ,Kre= ` / * *
* 0.00001
*
* @ name czm _epsilon5
* @ glslConstant
* /
const float czm _epsilon5 = 0.00001 ;
` ,Jre= ` / * *
* 0.000001
*
* @ name czm _epsilon6
* @ glslConstant
* /
const float czm _epsilon6 = 0.000001 ;
` ,Qre= ` / * *
* 0.0000001
*
* @ name czm _epsilon7
* @ glslConstant
* /
const float czm _epsilon7 = 0.0000001 ;
` ,Zre= ` / * *
* DOC _TBA
*
* @ name czm _infinity
* @ glslConstant
* /
const float czm _infinity = 5906376272000.0 ; // Distance from the Sun to Pluto in meters. TODO: What is best given lowp, mediump, and highp?
` ,ese= ` / * *
* A built - in GLSL floating - point constant for < code > 1 / pi < / c o d e > .
*
* @ alias czm _oneOverPi
* @ glslConstant
*
* @ see CesiumMath . ONE _OVER _PI
*
* @ example
* // GLSL declaration
* const float czm _oneOverPi = ... ;
*
* // Example
* float pi = 1.0 / czm _oneOverPi ;
* /
const float czm _oneOverPi = 0.3183098861837907 ;
` ,tse= ` / * *
* A built - in GLSL floating - point constant for < code > 1 / 2 pi < / c o d e > .
*
* @ alias czm _oneOverTwoPi
* @ glslConstant
*
* @ see CesiumMath . ONE _OVER _TWO _PI
*
* @ example
* // GLSL declaration
* const float czm _oneOverTwoPi = ... ;
*
* // Example
* float pi = 2.0 * czm _oneOverTwoPi ;
* /
const float czm _oneOverTwoPi = 0.15915494309189535 ;
` ,nse= ` / * *
* The automatic GLSL constant for { @ link Pass # CESIUM _3D _TILE }
*
* @ name czm _passCesium3DTile
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCesium3DTile = 4.0 ;
` ,ise= ` / * *
* The automatic GLSL constant for { @ link Pass # CESIUM _3D _TILE _CLASSIFICATION }
*
* @ name czm _passCesium3DTileClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCesium3DTileClassification = 5.0 ;
` ,ose= ` / * *
* The automatic GLSL constant for { @ link Pass # CESIUM _3D _TILE _CLASSIFICATION _IGNORE _SHOW }
*
* @ name czm _passCesium3DTileClassificationIgnoreShow
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCesium3DTileClassificationIgnoreShow = 6.0 ;
` ,rse= ` / * *
* The automatic GLSL constant for { @ link Pass # CLASSIFICATION }
*
* @ name czm _passClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passClassification = 7.0 ;
` ,sse= ` / * *
* The automatic GLSL constant for { @ link Pass # COMPUTE }
*
* @ name czm _passCompute
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCompute = 1.0 ;
` ,ase= ` / * *
* The automatic GLSL constant for { @ link Pass # ENVIRONMENT }
*
* @ name czm _passEnvironment
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passEnvironment = 0.0 ;
` ,cse= ` / * *
* The automatic GLSL constant for { @ link Pass # GLOBE }
*
* @ name czm _passGlobe
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passGlobe = 2.0 ;
` ,lse= ` / * *
* The automatic GLSL constant for { @ link Pass # OPAQUE }
*
* @ name czm _passOpaque
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passOpaque = 7.0 ;
` ,use= ` / * *
* The automatic GLSL constant for { @ link Pass # OVERLAY }
*
* @ name czm _passOverlay
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passOverlay = 10.0 ;
` ,fse= ` / * *
* The automatic GLSL constant for { @ link Pass # TERRAIN _CLASSIFICATION }
*
* @ name czm _passTerrainClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passTerrainClassification = 3.0 ;
` ,dse= ` / * *
* The automatic GLSL constant for { @ link Pass # TRANSLUCENT }
*
* @ name czm _passTranslucent
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passTranslucent = 8.0 ;
` ,hse= ` / * *
* The automatic GLSL constant for { @ link Pass # VOXELS }
*
* @ name czm _passVoxels
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passVoxels = 9.0 ;
` ,pse= ` / * *
* A built - in GLSL floating - point constant for < code > Math . PI < / c o d e > .
*
* @ alias czm _pi
* @ glslConstant
*
* @ see CesiumMath . PI
*
* @ example
* // GLSL declaration
* const float czm _pi = ... ;
*
* // Example
* float twoPi = 2.0 * czm _pi ;
* /
const float czm _pi = 3.141592653589793 ;
` ,mse= ` / * *
* A built - in GLSL floating - point constant for < code > pi / 4 < / c o d e > .
*
* @ alias czm _piOverFour
* @ glslConstant
*
* @ see CesiumMath . PI _OVER _FOUR
*
* @ example
* // GLSL declaration
* const float czm _piOverFour = ... ;
*
* // Example
* float pi = 4.0 * czm _piOverFour ;
* /
const float czm _piOverFour = 0.7853981633974483 ;
` ,_se= ` / * *
* A built - in GLSL floating - point constant for < code > pi / 6 < / c o d e > .
*
* @ alias czm _piOverSix
* @ glslConstant
*
* @ see CesiumMath . PI _OVER _SIX
*
* @ example
* // GLSL declaration
* const float czm _piOverSix = ... ;
*
* // Example
* float pi = 6.0 * czm _piOverSix ;
* /
const float czm _piOverSix = 0.5235987755982988 ;
` ,gse= ` / * *
* A built - in GLSL floating - point constant for < code > pi / 3 < / c o d e > .
*
* @ alias czm _piOverThree
* @ glslConstant
*
* @ see CesiumMath . PI _OVER _THREE
*
* @ example
* // GLSL declaration
* const float czm _piOverThree = ... ;
*
* // Example
* float pi = 3.0 * czm _piOverThree ;
* /
const float czm _piOverThree = 1.0471975511965976 ;
` ,yse= ` / * *
* A built - in GLSL floating - point constant for < code > pi / 2 < / c o d e > .
*
* @ alias czm _piOverTwo
* @ glslConstant
*
* @ see CesiumMath . PI _OVER _TWO
*
* @ example
* // GLSL declaration
* const float czm _piOverTwo = ... ;
*
* // Example
* float pi = 2.0 * czm _piOverTwo ;
* /
const float czm _piOverTwo = 1.5707963267948966 ;
` ,Ase= ` / * *
* A built - in GLSL floating - point constant for converting degrees to radians .
*
* @ alias czm _radiansPerDegree
* @ glslConstant
*
* @ see CesiumMath . RADIANS _PER _DEGREE
*
* @ example
* // GLSL declaration
* const float czm _radiansPerDegree = ... ;
*
* // Example
* float rad = czm _radiansPerDegree * deg ;
* /
const float czm _radiansPerDegree = 0.017453292519943295 ;
` ,Cse= ` / * *
* The constant identifier for the 2 D { @ link SceneMode }
*
* @ name czm _sceneMode2D
* @ glslConstant
* @ see czm _sceneMode
* @ see czm _sceneModeColumbusView
* @ see czm _sceneMode3D
* @ see czm _sceneModeMorphing
* /
const float czm _sceneMode2D = 2.0 ;
` ,Tse= ` / * *
* The constant identifier for the 3 D { @ link SceneMode }
*
* @ name czm _sceneMode3D
* @ glslConstant
* @ see czm _sceneMode
* @ see czm _sceneMode2D
* @ see czm _sceneModeColumbusView
* @ see czm _sceneModeMorphing
* /
const float czm _sceneMode3D = 3.0 ;
` ,bse= ` / * *
* The constant identifier for the Columbus View { @ link SceneMode }
*
* @ name czm _sceneModeColumbusView
* @ glslConstant
* @ see czm _sceneMode
* @ see czm _sceneMode2D
* @ see czm _sceneMode3D
* @ see czm _sceneModeMorphing
* /
const float czm _sceneModeColumbusView = 1.0 ;
` ,Ese= ` / * *
* The constant identifier for the Morphing { @ link SceneMode }
*
* @ name czm _sceneModeMorphing
* @ glslConstant
* @ see czm _sceneMode
* @ see czm _sceneMode2D
* @ see czm _sceneModeColumbusView
* @ see czm _sceneMode3D
* /
const float czm _sceneModeMorphing = 0.0 ;
` ,xse= ` / * *
* A built - in GLSL floating - point constant for one solar radius .
*
* @ alias czm _solarRadius
* @ glslConstant
*
* @ see CesiumMath . SOLAR _RADIUS
*
* @ example
* // GLSL declaration
* const float czm _solarRadius = ... ;
* /
const float czm _solarRadius = 695500000.0 ;
` ,wse= ` / * *
* A built - in GLSL floating - point constant for < code > 3 pi / 2 < / c o d e > .
*
* @ alias czm _threePiOver2
* @ glslConstant
*
* @ see CesiumMath . THREE _PI _OVER _TWO
*
* @ example
* // GLSL declaration
* const float czm _threePiOver2 = ... ;
*
* // Example
* float pi = ( 2.0 / 3.0 ) * czm _threePiOver2 ;
* /
const float czm _threePiOver2 = 4.71238898038469 ;
` ,Sse= ` / * *
* A built - in GLSL floating - point constant for < code > 2 pi < / c o d e > .
*
* @ alias czm _twoPi
* @ glslConstant
*
* @ see CesiumMath . TWO _PI
*
* @ example
* // GLSL declaration
* const float czm _twoPi = ... ;
*
* // Example
* float pi = czm _twoPi / 2.0 ;
* /
const float czm _twoPi = 6.283185307179586 ;
` ,vse= ` / * *
* The maximum latitude , in radians , both North and South , supported by a Web Mercator
* ( EPSG : 3857 ) projection . Technically , the Mercator projection is defined
* for any latitude up to ( but not including ) 90 degrees , but it makes sense
* to cut it off sooner because it grows exponentially with increasing latitude .
* The logic behind this particular cutoff value , which is the one used by
* Google Maps , Bing Maps , and Esri , is that it makes the projection
* square . That is , the rectangle is equal in the X and Y directions .
*
* The constant value is computed as follows :
* czm _pi * 0.5 - ( 2.0 * atan ( exp ( - czm _pi ) ) )
*
* @ name czm _webMercatorMaxLatitude
* @ glslConstant
* /
const float czm _webMercatorMaxLatitude = 1.4844222297453324 ;
` ,Dse= ` / * *
* @ name czm _depthRangeStruct
* @ glslStruct
* /
struct czm _depthRangeStruct
{
float near ;
float far ;
} ;
` ,Ise= ` / * *
* Holds material information that can be used for lighting . Returned by all czm _getMaterial functions .
*
* @ name czm _material
* @ glslStruct
*
* @ property { vec3 } diffuse Incoming light that scatters evenly in all directions .
* @ property { float } specular Intensity of incoming light reflecting in a single direction .
* @ property { float } shininess The sharpness of the specular reflection . Higher values create a smaller , more focused specular highlight .
* @ property { vec3 } normal Surface 's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface' s unmodified normal .
* @ property { vec3 } emission Light emitted by the material equally in all directions . The default is vec3 ( 0.0 ) , which emits no light .
* @ property { float } alpha Alpha of this material . 0.0 is completely transparent ; 1.0 is completely opaque .
* /
struct czm _material
{
vec3 diffuse ;
float specular ;
float shininess ;
vec3 normal ;
vec3 emission ;
float alpha ;
} ;
` ,Pse= ` / * *
* Used as input to every material ' s czm _getMaterial function .
*
* @ name czm _materialInput
* @ glslStruct
*
* @ property { float } s 1 D texture coordinates .
* @ property { vec2 } st 2 D texture coordinates .
* @ property { vec3 } str 3 D texture coordinates .
* @ property { vec3 } normalEC Unperturbed surface normal in eye coordinates .
* @ property { mat3 } tangentToEyeMatrix Matrix for converting a tangent space normal to eye space .
* @ property { vec3 } positionToEyeEC Vector from the fragment to the eye in eye coordinates . The magnitude is the distance in meters from the fragment to the eye .
* @ property { float } height The height of the terrain in meters above or below the WGS84 ellipsoid . Only available for globe materials .
* @ property { float } slope The slope of the terrain in radians . 0 is flat ; pi / 2 is vertical . Only available for globe materials .
* @ property { float } aspect The aspect of the terrain in radians . 0 is East , pi / 2 is North , pi is West , 3 pi / 2 is South . Only available for globe materials .
* /
struct czm _materialInput
{
float s ;
vec2 st ;
vec3 str ;
vec3 normalEC ;
mat3 tangentToEyeMatrix ;
vec3 positionToEyeEC ;
float height ;
float slope ;
float aspect ;
} ;
` ,Ose= ` / * *
* Struct for representing a material for a { @ link Model } . The model
* rendering pipeline will pass this struct between material , custom shaders ,
* and lighting stages . This is not to be confused with { @ link czm _material }
* which is used by the older Fabric materials system , although they are similar .
* < p >
* All color values ( diffuse , specular , emissive ) are in linear color space .
* < / p >
*
* @ name czm _modelMaterial
* @ glslStruct
*
* @ property { vec3 } diffuse Incoming light that scatters evenly in all directions .
* @ property { float } alpha Alpha of this material . 0.0 is completely transparent ; 1.0 is completely opaque .
* @ property { vec3 } specular Color of reflected light at normal incidence in PBR materials . This is sometimes referred to as f0 in the literature .
* @ property { float } roughness A number from 0.0 to 1.0 representing how rough the surface is . Values near 0.0 produce glossy surfaces , while values near 1.0 produce rough surfaces .
* @ property { vec3 } normalEC Surface 's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface' s unmodified normal .
* @ property { float } occlusion Ambient occlusion recieved at this point on the material . 1.0 means fully lit , 0.0 means fully occluded .
* @ property { vec3 } emissive Light emitted by the material equally in all directions . The default is vec3 ( 0.0 ) , which emits no light .
* /
struct czm _modelMaterial {
vec3 diffuse ;
float alpha ;
vec3 specular ;
float roughness ;
vec3 normalEC ;
float occlusion ;
vec3 emissive ;
} ;
` ,Lse= ` / * *
* Struct for representing the output of a custom vertex shader .
*
* @ name czm _modelVertexOutput
* @ glslStruct
*
* @ see { @ link CustomShader }
* @ see { @ link Model }
*
* @ property { vec3 } positionMC The position of the vertex in model coordinates
* @ property { float } pointSize A custom value for gl _PointSize . This is only used for point primitives .
* /
struct czm _modelVertexOutput {
vec3 positionMC ;
float pointSize ;
} ;
` ,Bse= ` / * *
* Parameters for { @ link czm _pbrLighting }
*
* @ name czm _material
* @ glslStruct
*
* @ property { vec3 } diffuseColor the diffuse color of the material for the lambert term of the rendering equation
* @ property { float } roughness a value from 0.0 to 1.0 that indicates how rough the surface of the material is .
* @ property { vec3 } f0 The reflectance of the material at normal incidence
* /
struct czm _pbrParameters
{
vec3 diffuseColor ;
float roughness ;
vec3 f0 ;
} ;
` ,Rse= ` / * *
* DOC _TBA
*
* @ name czm _ray
* @ glslStruct
* /
struct czm _ray
{
vec3 origin ;
vec3 direction ;
} ;
` ,Nse= ` / * *
* DOC _TBA
*
* @ name czm _raySegment
* @ glslStruct
* /
struct czm _raySegment
{
float start ;
float stop ;
} ;
/ * *
* DOC _TBA
*
* @ name czm _emptyRaySegment
* @ glslConstant
* /
const czm _raySegment czm _emptyRaySegment = czm _raySegment ( - czm _infinity , - czm _infinity ) ;
/ * *
* DOC _TBA
*
* @ name czm _fullRaySegment
* @ glslConstant
* /
const czm _raySegment czm _fullRaySegment = czm _raySegment ( 0.0 , czm _infinity ) ;
` ,Mse= ` struct czm _shadowParameters
{
# ifdef USE _CUBE _MAP _SHADOW
vec3 texCoords ;
# else
vec2 texCoords ;
# endif
float depthBias ;
float depth ;
float nDotL ;
vec2 texelStepSize ;
float normalShadingSmooth ;
float darkness ;
} ;
` ,Fse= ` / * *
* Converts an HSB color ( hue , saturation , brightness ) to RGB
* HSB < - > RGB conversion with minimal branching : { @ link http : //lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
*
* @ name czm _HSBToRGB
* @ glslFunction
*
* @ param { vec3 } hsb The color in HSB .
*
* @ returns { vec3 } The color in RGB .
*
* @ example
* vec3 hsb = czm _RGBToHSB ( rgb ) ;
* hsb . z *= 0.1 ;
* rgb = czm _HSBToRGB ( hsb ) ;
* /
const vec4 K _HSB2RGB = vec4 ( 1.0 , 2.0 / 3.0 , 1.0 / 3.0 , 3.0 ) ;
vec3 czm _HSBToRGB ( vec3 hsb )
{
vec3 p = abs ( fract ( hsb . xxx + K _HSB2RGB . xyz ) * 6.0 - K _HSB2RGB . www ) ;
return hsb . z * mix ( K _HSB2RGB . xxx , clamp ( p - K _HSB2RGB . xxx , 0.0 , 1.0 ) , hsb . y ) ;
}
` ,zse= ` / * *
* Converts an HSL color ( hue , saturation , lightness ) to RGB
* HSL < - > RGB conversion : { @ link http : //www.chilliant.com/rgb2hsv.html}
*
* @ name czm _HSLToRGB
* @ glslFunction
*
* @ param { vec3 } rgb The color in HSL .
*
* @ returns { vec3 } The color in RGB .
*
* @ example
* vec3 hsl = czm _RGBToHSL ( rgb ) ;
* hsl . z *= 0.1 ;
* rgb = czm _HSLToRGB ( hsl ) ;
* /
vec3 hueToRGB ( float hue )
{
float r = abs ( hue * 6.0 - 3.0 ) - 1.0 ;
float g = 2.0 - abs ( hue * 6.0 - 2.0 ) ;
float b = 2.0 - abs ( hue * 6.0 - 4.0 ) ;
return clamp ( vec3 ( r , g , b ) , 0.0 , 1.0 ) ;
}
vec3 czm _HSLToRGB ( vec3 hsl )
{
vec3 rgb = hueToRGB ( hsl . x ) ;
float c = ( 1.0 - abs ( 2.0 * hsl . z - 1.0 ) ) * hsl . y ;
return ( rgb - 0.5 ) * c + hsl . z ;
}
` ,Use= ` / * *
* Converts an RGB color to HSB ( hue , saturation , brightness )
* HSB < - > RGB conversion with minimal branching : { @ link http : //lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl}
*
* @ name czm _RGBToHSB
* @ glslFunction
*
* @ param { vec3 } rgb The color in RGB .
*
* @ returns { vec3 } The color in HSB .
*
* @ example
* vec3 hsb = czm _RGBToHSB ( rgb ) ;
* hsb . z *= 0.1 ;
* rgb = czm _HSBToRGB ( hsb ) ;
* /
const vec4 K _RGB2HSB = vec4 ( 0.0 , - 1.0 / 3.0 , 2.0 / 3.0 , - 1.0 ) ;
vec3 czm _RGBToHSB ( vec3 rgb )
{
vec4 p = mix ( vec4 ( rgb . bg , K _RGB2HSB . wz ) , vec4 ( rgb . gb , K _RGB2HSB . xy ) , step ( rgb . b , rgb . g ) ) ;
vec4 q = mix ( vec4 ( p . xyw , rgb . r ) , vec4 ( rgb . r , p . yzx ) , step ( p . x , rgb . r ) ) ;
float d = q . x - min ( q . w , q . y ) ;
return vec3 ( abs ( q . z + ( q . w - q . y ) / ( 6.0 * d + czm _epsilon7 ) ) , d / ( q . x + czm _epsilon7 ) , q . x ) ;
}
` ,Hse= ` / * *
* Converts an RGB color to HSL ( hue , saturation , lightness )
* HSL < - > RGB conversion : { @ link http : //www.chilliant.com/rgb2hsv.html}
*
* @ name czm _RGBToHSL
* @ glslFunction
*
* @ param { vec3 } rgb The color in RGB .
*
* @ returns { vec3 } The color in HSL .
*
* @ example
* vec3 hsl = czm _RGBToHSL ( rgb ) ;
* hsl . z *= 0.1 ;
* rgb = czm _HSLToRGB ( hsl ) ;
* /
vec3 RGBtoHCV ( vec3 rgb )
{
// Based on work by Sam Hocevar and Emil Persson
vec4 p = ( rgb . g < rgb . b ) ? vec4 ( rgb . bg , - 1.0 , 2.0 / 3.0 ) : vec4 ( rgb . gb , 0.0 , - 1.0 / 3.0 ) ;
vec4 q = ( rgb . r < p . x ) ? vec4 ( p . xyw , rgb . r ) : vec4 ( rgb . r , p . yzx ) ;
float c = q . x - min ( q . w , q . y ) ;
float h = abs ( ( q . w - q . y ) / ( 6.0 * c + czm _epsilon7 ) + q . z ) ;
return vec3 ( h , c , q . x ) ;
}
vec3 czm _RGBToHSL ( vec3 rgb )
{
vec3 hcv = RGBtoHCV ( rgb ) ;
float l = hcv . z - hcv . y * 0.5 ;
float s = hcv . y / ( 1.0 - abs ( l * 2.0 - 1.0 ) + czm _epsilon7 ) ;
return vec3 ( hcv . x , s , l ) ;
}
` ,Vse= ` / * *
* Converts an RGB color to CIE Yxy .
* < p > The conversion is described in
* { @ link http : //content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
* < / p >
*
* @ name czm _RGBToXYZ
* @ glslFunction
*
* @ param { vec3 } rgb The color in RGB .
*
* @ returns { vec3 } The color in CIE Yxy .
*
* @ example
* vec3 xyz = czm _RGBToXYZ ( rgb ) ;
* xyz . x = max ( xyz . x - luminanceThreshold , 0.0 ) ;
* rgb = czm _XYZToRGB ( xyz ) ;
* /
vec3 czm _RGBToXYZ ( vec3 rgb )
{
const mat3 RGB2XYZ = mat3 ( 0.4124 , 0.2126 , 0.0193 ,
0.3576 , 0.7152 , 0.1192 ,
0.1805 , 0.0722 , 0.9505 ) ;
vec3 xyz = RGB2XYZ * rgb ;
vec3 Yxy ;
Yxy . r = xyz . g ;
float temp = dot ( vec3 ( 1.0 ) , xyz ) ;
Yxy . gb = xyz . rg / temp ;
return Yxy ;
}
` ,kse= ` / * *
* Converts a CIE Yxy color to RGB .
* < p > The conversion is described in
* { @ link http : //content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform}
* < / p >
*
* @ name czm _XYZToRGB
* @ glslFunction
*
* @ param { vec3 } Yxy The color in CIE Yxy .
*
* @ returns { vec3 } The color in RGB .
*
* @ example
* vec3 xyz = czm _RGBToXYZ ( rgb ) ;
* xyz . x = max ( xyz . x - luminanceThreshold , 0.0 ) ;
* rgb = czm _XYZToRGB ( xyz ) ;
* /
vec3 czm _XYZToRGB ( vec3 Yxy )
{
const mat3 XYZ2RGB = mat3 ( 3.2405 , - 0.9693 , 0.0556 ,
- 1.5371 , 1.8760 , - 0.2040 ,
- 0.4985 , 0.0416 , 1.0572 ) ;
vec3 xyz ;
xyz . r = Yxy . r * Yxy . g / Yxy . b ;
xyz . g = Yxy . r ;
xyz . b = Yxy . r * ( 1.0 - Yxy . g - Yxy . b ) / Yxy . b ;
return XYZ2RGB * xyz ;
}
` ,Gse= ` // See:
// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/
vec3 czm _acesTonemapping ( vec3 color ) {
float g = 0.985 ;
float a = 0.065 ;
float b = 0.0001 ;
float c = 0.433 ;
float d = 0.238 ;
color = ( color * ( color + a ) - b ) / ( color * ( g * color + c ) + d ) ;
color = clamp ( color , 0.0 , 1.0 ) ;
return color ;
}
` ,Wse= ` / * *
* @ private
* /
float czm _alphaWeight ( float a )
{
float z = ( gl _FragCoord . z - czm _viewportTransformation [ 3 ] [ 2 ] ) / czm _viewportTransformation [ 2 ] [ 2 ] ;
// See Weighted Blended Order-Independent Transparency for examples of different weighting functions:
// http://jcgt.org/published/0002/02/09/
return pow ( a + 0.01 , 4.0 ) + max ( 1e-2 , min ( 3.0 * 1e3 , 0.003 / ( 1e-5 + pow ( abs ( z ) / 200.0 , 4.0 ) ) ) ) ;
}
` ,jse= ` / * *
* Procedural anti - aliasing by blurring two colors that meet at a sharp edge .
*
* @ name czm _antialias
* @ glslFunction
*
* @ param { vec4 } color1 The color on one side of the edge .
* @ param { vec4 } color2 The color on the other side of the edge .
* @ param { vec4 } currentcolor The current color , either < code > color1 < / c o d e > o r < c o d e > c o l o r 2 < / c o d e > .
* @ param { float } dist The distance to the edge in texture coordinates .
* @ param { float } [ fuzzFactor = 0.1 ] Controls the blurriness between the two colors .
* @ returns { vec4 } The anti - aliased color .
*
* @ example
* // GLSL declarations
* vec4 czm _antialias ( vec4 color1 , vec4 color2 , vec4 currentColor , float dist , float fuzzFactor ) ;
* vec4 czm _antialias ( vec4 color1 , vec4 color2 , vec4 currentColor , float dist ) ;
*
* // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
* float dist = abs ( textureCoordinates . t - 0.5 ) ;
* vec4 currentColor = mix ( bottomColor , topColor , step ( 0.5 , textureCoordinates . t ) ) ;
* vec4 color = czm _antialias ( bottomColor , topColor , currentColor , dist , 0.1 ) ;
* /
vec4 czm _antialias ( vec4 color1 , vec4 color2 , vec4 currentColor , float dist , float fuzzFactor )
{
float val1 = clamp ( dist / fuzzFactor , 0.0 , 1.0 ) ;
float val2 = clamp ( ( dist - 0.5 ) / fuzzFactor , 0.0 , 1.0 ) ;
val1 = val1 * ( 1.0 - val2 ) ;
val1 = val1 * val1 * ( 3.0 - ( 2.0 * val1 ) ) ;
val1 = pow ( val1 , 0.5 ) ; //makes the transition nicer
vec4 midColor = ( color1 + color2 ) * 0.5 ;
return mix ( midColor , currentColor , val1 ) ;
}
vec4 czm _antialias ( vec4 color1 , vec4 color2 , vec4 currentColor , float dist )
{
return czm _antialias ( color1 , color2 , currentColor , dist , 0.1 ) ;
}
` ,qse= ` / * *
* Approximately computes spherical coordinates given a normal .
* Uses approximate inverse trigonometry for speed and consistency ,
* since inverse trigonometry can differ from vendor - to - vendor and when compared with the CPU .
*
* @ name czm _approximateSphericalCoordinates
* @ glslFunction
*
* @ param { vec3 } normal arbitrary - length normal .
*
* @ returns { vec2 } Approximate latitude and longitude spherical coordinates .
* /
vec2 czm _approximateSphericalCoordinates ( vec3 normal ) {
// Project into plane with vertical for latitude
float latitudeApproximation = czm _fastApproximateAtan ( sqrt ( normal . x * normal . x + normal . y * normal . y ) , normal . z ) ;
float longitudeApproximation = czm _fastApproximateAtan ( normal . x , normal . y ) ;
return vec2 ( latitudeApproximation , longitudeApproximation ) ;
}
` ,Yse= ` / * *
* Determines if the fragment is back facing
*
* @ name czm _backFacing
* @ glslFunction
*
* @ returns { bool } < code > true < / c o d e > i f t h e f r a g m e n t i s b a c k f a c i n g ; o t h e r w i s e , < c o d e > f a l s e < / c o d e > .
* /
bool czm _backFacing ( )
{
// !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
return gl _FrontFacing == false ;
}
` ,Xse= ` / * *
* Branchless ternary operator to be used when it ' s inexpensive to explicitly
* evaluate both possibilities for a float expression .
*
* @ name czm _branchFreeTernary
* @ glslFunction
*
* @ param { bool } comparison A comparison statement
* @ param { float } a Value to return if the comparison is true .
* @ param { float } b Value to return if the comparison is false .
*
* @ returns { float } equivalent of comparison ? a : b
* /
float czm _branchFreeTernary ( bool comparison , float a , float b ) {
float useA = float ( comparison ) ;
return a * useA + b * ( 1.0 - useA ) ;
}
/ * *
* Branchless ternary operator to be used when it ' s inexpensive to explicitly
* evaluate both possibilities for a vec2 expression .
*
* @ name czm _branchFreeTernary
* @ glslFunction
*
* @ param { bool } comparison A comparison statement
* @ param { vec2 } a Value to return if the comparison is true .
* @ param { vec2 } b Value to return if the comparison is false .
*
* @ returns { vec2 } equivalent of comparison ? a : b
* /
vec2 czm _branchFreeTernary ( bool comparison , vec2 a , vec2 b ) {
float useA = float ( comparison ) ;
return a * useA + b * ( 1.0 - useA ) ;
}
/ * *
* Branchless ternary operator to be used when it ' s inexpensive to explicitly
* evaluate both possibilities for a vec3 expression .
*
* @ name czm _branchFreeTernary
* @ glslFunction
*
* @ param { bool } comparison A comparison statement
* @ param { vec3 } a Value to return if the comparison is true .
* @ param { vec3 } b Value to return if the comparison is false .
*
* @ returns { vec3 } equivalent of comparison ? a : b
* /
vec3 czm _branchFreeTernary ( bool comparison , vec3 a , vec3 b ) {
float useA = float ( comparison ) ;
return a * useA + b * ( 1.0 - useA ) ;
}
/ * *
* Branchless ternary operator to be used when it ' s inexpensive to explicitly
* evaluate both possibilities for a vec4 expression .
*
* @ name czm _branchFreeTernary
* @ glslFunction
*
* @ param { bool } comparison A comparison statement
* @ param { vec3 } a Value to return if the comparison is true .
* @ param { vec3 } b Value to return if the comparison is false .
*
* @ returns { vec3 } equivalent of comparison ? a : b
* /
vec4 czm _branchFreeTernary ( bool comparison , vec4 a , vec4 b ) {
float useA = float ( comparison ) ;
return a * useA + b * ( 1.0 - useA ) ;
}
` , $ se= `
vec4 czm _cascadeColor ( vec4 weights )
{
return vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) * weights . x +
vec4 ( 0.0 , 1.0 , 0.0 , 1.0 ) * weights . y +
vec4 ( 0.0 , 0.0 , 1.0 , 1.0 ) * weights . z +
vec4 ( 1.0 , 0.0 , 1.0 , 1.0 ) * weights . w ;
}
` ,Kse= `
uniform vec4 shadowMap _cascadeDistances ;
float czm _cascadeDistance ( vec4 weights )
{
return dot ( shadowMap _cascadeDistances , weights ) ;
}
` ,Jse= `
uniform mat4 shadowMap _cascadeMatrices [ 4 ] ;
mat4 czm _cascadeMatrix ( vec4 weights )
{
return shadowMap _cascadeMatrices [ 0 ] * weights . x +
shadowMap _cascadeMatrices [ 1 ] * weights . y +
shadowMap _cascadeMatrices [ 2 ] * weights . z +
shadowMap _cascadeMatrices [ 3 ] * weights . w ;
}
` ,Qse= `
uniform vec4 shadowMap _cascadeSplits [ 2 ] ;
vec4 czm _cascadeWeights ( float depthEye )
{
// One component is set to 1.0 and all others set to 0.0.
vec4 near = step ( shadowMap _cascadeSplits [ 0 ] , vec4 ( depthEye ) ) ;
vec4 far = step ( depthEye , shadowMap _cascadeSplits [ 1 ] ) ;
return near * far ;
}
` ,Zse= ` / * *
* DOC _TBA
*
* @ name czm _columbusViewMorph
* @ glslFunction
* /
vec4 czm _columbusViewMorph ( vec4 position2D , vec4 position3D , float time )
{
// Just linear for now.
vec3 p = mix ( position2D . xyz , position3D . xyz , time ) ;
return vec4 ( p , 1.0 ) ;
}
` ,eae= ` / * *
* Returns a position in model coordinates relative to eye taking into
* account the current scene mode : 3 D , 2 D , or Columbus view .
* < p >
* This uses standard position attributes , < code > position3DHigh < / c o d e > ,
* < code > position3DLow < / c o d e > , < c o d e > p o s i t i o n 2 D H i g h < / c o d e > , a n d < c o d e > p o s i t i o n 2 D L o w < / c o d e > ,
* and should be used when writing a vertex shader for an { @ link Appearance } .
* < / p >
*
* @ name czm _computePosition
* @ glslFunction
*
* @ returns { vec4 } The position relative to eye .
*
* @ example
* vec4 p = czm _computePosition ( ) ;
* v _positionEC = ( czm _modelViewRelativeToEye * p ) . xyz ;
* gl _Position = czm _modelViewProjectionRelativeToEye * p ;
*
* @ see czm _translateRelativeToEye
* /
vec4 czm _computePosition ( ) ;
` ,tae= ` / * *
* @ private
* /
vec2 cordic ( float angle )
{
// Scale the vector by the appropriate factor for the 24 iterations to follow.
vec2 vector = vec2 ( 6.0725293500888267 e - 1 , 0.0 ) ;
// Iteration 1
float sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
// float factor = sense * 1.0; // 2^-0
mat2 rotation = mat2 ( 1.0 , sense , - sense , 1.0 ) ;
vector = rotation * vector ;
angle -= sense * 7.8539816339744828 e - 1 ; // atan(2^-0)
// Iteration 2
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
float factor = sense * 5.0 e - 1 ; // 2^-1
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 4.6364760900080609 e - 1 ; // atan(2^-1)
// Iteration 3
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 2.5 e - 1 ; // 2^-2
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 2.4497866312686414 e - 1 ; // atan(2^-2)
// Iteration 4
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.25 e - 1 ; // 2^-3
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.2435499454676144 e - 1 ; // atan(2^-3)
// Iteration 5
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 6.25 e - 2 ; // 2^-4
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 6.2418809995957350 e - 2 ; // atan(2^-4)
// Iteration 6
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 3.125 e - 2 ; // 2^-5
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 3.1239833430268277 e - 2 ; // atan(2^-5)
// Iteration 7
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.5625 e - 2 ; // 2^-6
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.5623728620476831 e - 2 ; // atan(2^-6)
// Iteration 8
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 7.8125 e - 3 ; // 2^-7
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 7.8123410601011111 e - 3 ; // atan(2^-7)
// Iteration 9
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 3.90625 e - 3 ; // 2^-8
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 3.9062301319669718 e - 3 ; // atan(2^-8)
// Iteration 10
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.953125 e - 3 ; // 2^-9
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.9531225164788188 e - 3 ; // atan(2^-9)
// Iteration 11
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 9.765625 e - 4 ; // 2^-10
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 9.7656218955931946 e - 4 ; // atan(2^-10)
// Iteration 12
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 4.8828125 e - 4 ; // 2^-11
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 4.8828121119489829 e - 4 ; // atan(2^-11)
// Iteration 13
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 2.44140625 e - 4 ; // 2^-12
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 2.4414062014936177 e - 4 ; // atan(2^-12)
// Iteration 14
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.220703125 e - 4 ; // 2^-13
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.2207031189367021 e - 4 ; // atan(2^-13)
// Iteration 15
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 6.103515625 e - 5 ; // 2^-14
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 6.1035156174208773 e - 5 ; // atan(2^-14)
// Iteration 16
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 3.0517578125 e - 5 ; // 2^-15
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 3.0517578115526096 e - 5 ; // atan(2^-15)
// Iteration 17
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.52587890625 e - 5 ; // 2^-16
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.5258789061315762 e - 5 ; // atan(2^-16)
// Iteration 18
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 7.62939453125 e - 6 ; // 2^-17
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 7.6293945311019700 e - 6 ; // atan(2^-17)
// Iteration 19
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 3.814697265625 e - 6 ; // 2^-18
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 3.8146972656064961 e - 6 ; // atan(2^-18)
// Iteration 20
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.9073486328125 e - 6 ; // 2^-19
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 1.9073486328101870 e - 6 ; // atan(2^-19)
// Iteration 21
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 9.5367431640625 e - 7 ; // 2^-20
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 9.5367431640596084 e - 7 ; // atan(2^-20)
// Iteration 22
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 4.76837158203125 e - 7 ; // 2^-21
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 4.7683715820308884 e - 7 ; // atan(2^-21)
// Iteration 23
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 2.384185791015625 e - 7 ; // 2^-22
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
angle -= sense * 2.3841857910155797 e - 7 ; // atan(2^-22)
// Iteration 24
sense = ( angle < 0.0 ) ? - 1.0 : 1.0 ;
factor = sense * 1.1920928955078125 e - 7 ; // 2^-23
rotation [ 0 ] [ 1 ] = factor ;
rotation [ 1 ] [ 0 ] = - factor ;
vector = rotation * vector ;
// angle -= sense * 1.1920928955078068e-7; // atan(2^-23)
return vector ;
}
/ * *
* Computes the cosine and sine of the provided angle using the CORDIC algorithm .
*
* @ name czm _cosineAndSine
* @ glslFunction
*
* @ param { float } angle The angle in radians .
*
* @ returns { vec2 } The resulting cosine of the angle ( as the x coordinate ) and sine of the angle ( as the y coordinate ) .
*
* @ example
* vec2 v = czm _cosineAndSine ( czm _piOverSix ) ;
* float cosine = v . x ;
* float sine = v . y ;
* /
vec2 czm _cosineAndSine ( float angle )
{
if ( angle < - czm _piOverTwo || angle > czm _piOverTwo )
{
if ( angle < 0.0 )
{
return - cordic ( angle + czm _pi ) ;
}
else
{
return - cordic ( angle - czm _pi ) ;
}
}
else
{
return cordic ( angle ) ;
}
}
` ,nae= ` / * *
* Decompresses texture coordinates that were packed into a single float .
*
* @ name czm _decompressTextureCoordinates
* @ glslFunction
*
* @ param { float } encoded The compressed texture coordinates .
* @ returns { vec2 } The decompressed texture coordinates .
* /
vec2 czm _decompressTextureCoordinates ( float encoded )
{
float temp = encoded / 4096.0 ;
float xZeroTo4095 = floor ( temp ) ;
float stx = xZeroTo4095 / 4095.0 ;
float sty = ( encoded - xZeroTo4095 * 4096.0 ) / 4095.0 ;
return vec2 ( stx , sty ) ;
}
` ,iae= ` / * *
* Get default parameters for physically based rendering . These defaults
* describe a rough dielectric ( non - metal ) surface ( e . g . rough plastic ) .
*
* @ return { czm _pbrParameters } Default parameters for { @ link czm _pbrLighting }
* /
czm _pbrParameters czm _defaultPbrMaterial ( )
{
czm _pbrParameters results ;
results . diffuseColor = vec3 ( 1.0 ) ;
results . roughness = 1.0 ;
const vec3 REFLECTANCE _DIELECTRIC = vec3 ( 0.04 ) ;
results . f0 = REFLECTANCE _DIELECTRIC ;
return results ;
}
` ,oae= ` // emulated noperspective
# if defined ( GL _EXT _frag _depth ) && ! defined ( LOG _DEPTH )
varying float v _WindowZ ;
# endif
/ * *
* Emulates GL _DEPTH _CLAMP , which is not available in WebGL 1 or 2.
* GL _DEPTH _CLAMP clamps geometry that is outside the near and far planes ,
* capping the shadow volume . More information here :
* https : //www.khronos.org/registry/OpenGL/extensions/ARB/ARB_depth_clamp.txt.
*
* When GL _EXT _frag _depth is available we emulate GL _DEPTH _CLAMP by ensuring
* no geometry gets clipped by setting the clip space z value to 0.0 and then
* sending the unaltered screen space z value ( using emulated noperspective
* interpolation ) to the frag shader where it is clamped to [ 0 , 1 ] and then
* written with gl _FragDepth ( see czm _writeDepthClamp ) . This technique is based on :
* https : //stackoverflow.com/questions/5960757/how-to-emulate-gl-depth-clamp-nv.
*
* When GL _EXT _frag _depth is not available , which is the case on some mobile
* devices , we must attempt to fix this only in the vertex shader .
* The approach is to clamp the z value to the far plane , which closes the
* shadow volume but also distorts the geometry , so there can still be artifacts
* on frustum seams .
*
* @ name czm _depthClamp
* @ glslFunction
*
* @ param { vec4 } coords The vertex in clip coordinates .
* @ returns { vec4 } The modified vertex .
*
* @ example
* gl _Position = czm _depthClamp ( czm _modelViewProjection * vec4 ( position , 1.0 ) ) ;
*
* @ see czm _writeDepthClamp
* /
vec4 czm _depthClamp ( vec4 coords )
{
# ifndef LOG _DEPTH
# ifdef GL _EXT _frag _depth
v _WindowZ = ( 0.5 * ( coords . z / coords . w ) + 0.5 ) * coords . w ;
coords . z = 0.0 ;
# else
coords . z = min ( coords . z , coords . w ) ;
# endif
# endif
return coords ;
}
` ,rae= ` / * *
* Computes a 3 x3 rotation matrix that transforms vectors from an ellipsoid ' s east - north - up coordinate system
* to eye coordinates . In east - north - up coordinates , x points east , y points north , and z points along the
* surface normal . East - north - up can be used as an ellipsoid ' s tangent space for operations such as bump mapping .
* < br / > < br / >
* The ellipsoid is assumed to be centered at the model coordinate ' s origin .
*
* @ name czm _eastNorthUpToEyeCoordinates
* @ glslFunction
*
* @ param { vec3 } positionMC The position on the ellipsoid in model coordinates .
* @ param { vec3 } normalEC The normalized ellipsoid surface normal , at < code > positionMC < / c o d e > , i n e y e c o o r d i n a t e s .
*
* @ returns { mat3 } A 3 x3 rotation matrix that transforms vectors from the east - north - up coordinate system to eye coordinates .
*
* @ example
* // Transform a vector defined in the east-north-up coordinate
* // system, (0, 0, 1) which is the surface normal, to eye
* // coordinates.
* mat3 m = czm _eastNorthUpToEyeCoordinates ( positionMC , normalEC ) ;
* vec3 normalEC = m * vec3 ( 0.0 , 0.0 , 1.0 ) ;
* /
mat3 czm _eastNorthUpToEyeCoordinates ( vec3 positionMC , vec3 normalEC )
{
vec3 tangentMC = normalize ( vec3 ( - positionMC . y , positionMC . x , 0.0 ) ) ; // normalized surface tangent in model coordinates
vec3 tangentEC = normalize ( czm _normal3D * tangentMC ) ; // normalized surface tangent in eye coordiantes
vec3 bitangentEC = normalize ( cross ( normalEC , tangentEC ) ) ; // normalized surface bitangent in eye coordinates
return mat3 (
tangentEC . x , tangentEC . y , tangentEC . z ,
bitangentEC . x , bitangentEC . y , bitangentEC . z ,
normalEC . x , normalEC . y , normalEC . z ) ;
}
` ,sae= ` / * *
* DOC _TBA
*
* @ name czm _ellipsoidContainsPoint
* @ glslFunction
*
* /
bool czm _ellipsoidContainsPoint ( vec3 ellipsoid _inverseRadii , vec3 point )
{
vec3 scaled = ellipsoid _inverseRadii * ( czm _inverseModelView * vec4 ( point , 1.0 ) ) . xyz ;
return ( dot ( scaled , scaled ) <= 1.0 ) ;
}
` ,aae= ` / * *
* DOC _TBA
*
* @ name czm _ellipsoidWgs84TextureCoordinates
* @ glslFunction
* /
vec2 czm _ellipsoidWgs84TextureCoordinates ( vec3 normal )
{
return vec2 ( atan ( normal . y , normal . x ) * czm _oneOverTwoPi + 0.5 , asin ( normal . z ) * czm _oneOverPi + 0.5 ) ;
}
` ,cae= ` / * *
* Compares < code > left < / c o d e > a n d < c o d e > r i g h t < / c o d e > c o m p o n e n t w i s e . R e t u r n s < c o d e > t r u e < / c o d e >
* if they are within < code > epsilon < / c o d e > a n d < c o d e > f a l s e < / c o d e > o t h e r w i s e . T h e i n p u t s
* < code > left < / c o d e > a n d < c o d e > r i g h t < / c o d e > c a n b e < c o d e > f l o a t < / c o d e > s , < c o d e > v e c 2 < / c o d e > s ,
* < code > vec3 < / c o d e > s , o r < c o d e > v e c 4 < / c o d e > s .
*
* @ name czm _equalsEpsilon
* @ glslFunction
*
* @ param { } left The first vector .
* @ param { } right The second vector .
* @ param { float } epsilon The epsilon to use for equality testing .
* @ returns { bool } < code > true < / c o d e > i f t h e c o m p o n e n t s a r e w i t h i n < c o d e > e p s i l o n < / c o d e > a n d < c o d e > f a l s e < / c o d e > o t h e r w i s e .
*
* @ example
* // GLSL declarations
* bool czm _equalsEpsilon ( float left , float right , float epsilon ) ;
* bool czm _equalsEpsilon ( vec2 left , vec2 right , float epsilon ) ;
* bool czm _equalsEpsilon ( vec3 left , vec3 right , float epsilon ) ;
* bool czm _equalsEpsilon ( vec4 left , vec4 right , float epsilon ) ;
* /
bool czm _equalsEpsilon ( vec4 left , vec4 right , float epsilon ) {
return all ( lessThanEqual ( abs ( left - right ) , vec4 ( epsilon ) ) ) ;
}
bool czm _equalsEpsilon ( vec3 left , vec3 right , float epsilon ) {
return all ( lessThanEqual ( abs ( left - right ) , vec3 ( epsilon ) ) ) ;
}
bool czm _equalsEpsilon ( vec2 left , vec2 right , float epsilon ) {
return all ( lessThanEqual ( abs ( left - right ) , vec2 ( epsilon ) ) ) ;
}
bool czm _equalsEpsilon ( float left , float right , float epsilon ) {
return ( abs ( left - right ) <= epsilon ) ;
}
` ,lae= ` / * *
* DOC _TBA
*
* @ name czm _eyeOffset
* @ glslFunction
*
* @ param { vec4 } positionEC DOC _TBA .
* @ param { vec3 } eyeOffset DOC _TBA .
*
* @ returns { vec4 } DOC _TBA .
* /
vec4 czm _eyeOffset ( vec4 positionEC , vec3 eyeOffset )
{
// This equation is approximate in x and y.
vec4 p = positionEC ;
vec4 zEyeOffset = normalize ( p ) * eyeOffset . z ;
p . xy += eyeOffset . xy + zEyeOffset . xy ;
p . z += zEyeOffset . z ;
return p ;
}
` ,uae= ` / * *
* Transforms a position from eye to window coordinates . The transformation
* from eye to clip coordinates is done using { @ link czm _projection } .
* The transform from normalized device coordinates to window coordinates is
* done using { @ link czm _viewportTransformation } , which assumes a depth range
* of < code > near = 0 < / c o d e > a n d < c o d e > f a r = 1 < / c o d e > .
* < br / > < br / >
* This transform is useful when there is a need to manipulate window coordinates
* in a vertex shader as done by { @ link BillboardCollection } .
*
* @ name czm _eyeToWindowCoordinates
* @ glslFunction
*
* @ param { vec4 } position The position in eye coordinates to transform .
*
* @ returns { vec4 } The transformed position in window coordinates .
*
* @ see czm _modelToWindowCoordinates
* @ see czm _projection
* @ see czm _viewportTransformation
* @ see BillboardCollection
*
* @ example
* vec4 positionWC = czm _eyeToWindowCoordinates ( positionEC ) ;
* /
vec4 czm _eyeToWindowCoordinates ( vec4 positionEC )
{
vec4 q = czm _projection * positionEC ; // clip coordinates
q . xyz /= q . w ; // normalized device coordinates
q . xyz = ( czm _viewportTransformation * vec4 ( q . xyz , 1.0 ) ) . xyz ; // window coordinates
return q ;
}
` ,fae= ` / * *
* Approxiamtes atan over the range [ 0 , 1 ] . Safe to flip output for negative input .
*
* Based on Michal Drobot ' s approximation from ShaderFastLibs , which in turn is based on
* "Efficient approximations for the arctangent function," Rajan , S . Sichun Wang Inkol , R . Joyal , A . , May 2006.
* Adapted from ShaderFastLibs under MIT License .
*
* Chosen for the following characteristics over range [ 0 , 1 ] :
* - basically no error at 0 and 1 , important for getting around range limit ( naive atan2 via atan requires infinite range atan )
* - no visible artifacts from first - derivative discontinuities , unlike latitude via range - reduced sqrt asin approximations ( at equator )
*
* The original code is x * ( - 0.1784 * abs ( x ) - 0.0663 * x * x + 1.0301 ) ;
* Removed the abs ( ) in here because it isn 't needed, the input range is guaranteed as [0, 1] by how we' re approximating atan2 .
*
* @ name czm _fastApproximateAtan
* @ glslFunction
*
* @ param { float } x Value between 0 and 1 inclusive .
*
* @ returns { float } Approximation of atan ( x )
* /
float czm _fastApproximateAtan ( float x ) {
return x * ( - 0.1784 * x - 0.0663 * x * x + 1.0301 ) ;
}
/ * *
* Approximation of atan2 .
*
* Range reduction math based on nvidia ' s cg reference implementation for atan2 : http : //developer.download.nvidia.com/cg/atan2.html
* However , we replaced their atan curve with Michael Drobot ' s ( see above ) .
*
* @ name czm _fastApproximateAtan
* @ glslFunction
*
* @ param { float } x Value between - 1 and 1 inclusive .
* @ param { float } y Value between - 1 and 1 inclusive .
*
* @ returns { float } Approximation of atan2 ( x , y )
* /
float czm _fastApproximateAtan ( float x , float y ) {
// atan approximations are usually only reliable over [-1, 1], or, in our case, [0, 1] due to modifications.
// So range-reduce using abs and by flipping whether x or y is on top.
float t = abs ( x ) ; // t used as swap and atan result.
float opposite = abs ( y ) ;
float adjacent = max ( t , opposite ) ;
opposite = min ( t , opposite ) ;
t = czm _fastApproximateAtan ( opposite / adjacent ) ;
// Undo range reduction
t = czm _branchFreeTernary ( abs ( y ) > abs ( x ) , czm _piOverTwo - t , t ) ;
t = czm _branchFreeTernary ( x < 0.0 , czm _pi - t , t ) ;
t = czm _branchFreeTernary ( y < 0.0 , - t , t ) ;
return t ;
}
` ,dae= ` / * *
* Gets the color with fog at a distance from the camera .
*
* @ name czm _fog
* @ glslFunction
*
* @ param { float } distanceToCamera The distance to the camera in meters .
* @ param { vec3 } color The original color .
* @ param { vec3 } fogColor The color of the fog .
*
* @ returns { vec3 } The color adjusted for fog at the distance from the camera .
* /
vec3 czm _fog ( float distanceToCamera , vec3 color , vec3 fogColor )
{
float scalar = distanceToCamera * czm _fogDensity ;
float fog = 1.0 - exp ( - ( scalar * scalar ) ) ;
return mix ( color , fogColor , fog ) ;
}
/ * *
* Gets the color with fog at a distance from the camera .
*
* @ name czm _fog
* @ glslFunction
*
* @ param { float } distanceToCamera The distance to the camera in meters .
* @ param { vec3 } color The original color .
* @ param { vec3 } fogColor The color of the fog .
* @ param { float } fogModifierConstant A constant to modify the appearance of fog .
*
* @ returns { vec3 } The color adjusted for fog at the distance from the camera .
* /
vec3 czm _fog ( float distanceToCamera , vec3 color , vec3 fogColor , float fogModifierConstant )
{
float scalar = distanceToCamera * czm _fogDensity ;
float fog = 1.0 - exp ( - ( ( fogModifierConstant * scalar + fogModifierConstant ) * ( scalar * ( 1.0 + fogModifierConstant ) ) ) ) ;
return mix ( color , fogColor , fog ) ;
}
` ,hae= ` / * *
* Converts a color from RGB space to linear space .
*
* @ name czm _gammaCorrect
* @ glslFunction
*
* @ param { vec3 } color The color in RGB space .
* @ returns { vec3 } The color in linear space .
* /
vec3 czm _gammaCorrect ( vec3 color ) {
# ifdef HDR
color = pow ( color , vec3 ( czm _gamma ) ) ;
# endif
return color ;
}
vec4 czm _gammaCorrect ( vec4 color ) {
# ifdef HDR
color . rgb = pow ( color . rgb , vec3 ( czm _gamma ) ) ;
# endif
return color ;
}
` ,pae= ` / * *
* DOC _TBA
*
* @ name czm _geodeticSurfaceNormal
* @ glslFunction
*
* @ param { vec3 } positionOnEllipsoid DOC _TBA
* @ param { vec3 } ellipsoidCenter DOC _TBA
* @ param { vec3 } oneOverEllipsoidRadiiSquared DOC _TBA
*
* @ returns { vec3 } DOC _TBA .
* /
vec3 czm _geodeticSurfaceNormal ( vec3 positionOnEllipsoid , vec3 ellipsoidCenter , vec3 oneOverEllipsoidRadiiSquared )
{
return normalize ( ( positionOnEllipsoid - ellipsoidCenter ) * oneOverEllipsoidRadiiSquared ) ;
}
` ,mae= ` / * *
* An czm _material with default values . Every material ' s czm _getMaterial
* should use this default material as a base for the material it returns .
* The default normal value is given by materialInput . normalEC .
*
* @ name czm _getDefaultMaterial
* @ glslFunction
*
* @ param { czm _materialInput } input The input used to construct the default material .
*
* @ returns { czm _material } The default material .
*
* @ see czm _materialInput
* @ see czm _material
* @ see czm _getMaterial
* /
czm _material czm _getDefaultMaterial ( czm _materialInput materialInput )
{
czm _material material ;
material . diffuse = vec3 ( 0.0 ) ;
material . specular = 0.0 ;
material . shininess = 1.0 ;
material . normal = materialInput . normalEC ;
material . emission = vec3 ( 0.0 ) ;
material . alpha = 1.0 ;
return material ;
}
` ,_ae= ` / * *
* Calculates the intensity of diffusely reflected light .
*
* @ name czm _getLambertDiffuse
* @ glslFunction
*
* @ param { vec3 } lightDirectionEC Unit vector pointing to the light source in eye coordinates .
* @ param { vec3 } normalEC The surface normal in eye coordinates .
*
* @ returns { float } The intensity of the diffuse reflection .
*
* @ see czm _phong
*
* @ example
* float diffuseIntensity = czm _getLambertDiffuse ( lightDirectionEC , normalEC ) ;
* float specularIntensity = czm _getSpecular ( lightDirectionEC , toEyeEC , normalEC , 200 ) ;
* vec3 color = ( diffuseColor * diffuseIntensity ) + ( specularColor * specularIntensity ) ;
* /
float czm _getLambertDiffuse ( vec3 lightDirectionEC , vec3 normalEC )
{
return max ( dot ( lightDirectionEC , normalEC ) , 0.0 ) ;
}
` ,gae= ` / * *
* Calculates the specular intensity of reflected light .
*
* @ name czm _getSpecular
* @ glslFunction
*
* @ param { vec3 } lightDirectionEC Unit vector pointing to the light source in eye coordinates .
* @ param { vec3 } toEyeEC Unit vector pointing to the eye position in eye coordinates .
* @ param { vec3 } normalEC The surface normal in eye coordinates .
* @ param { float } shininess The sharpness of the specular reflection . Higher values create a smaller , more focused specular highlight .
*
* @ returns { float } The intensity of the specular highlight .
*
* @ see czm _phong
*
* @ example
* float diffuseIntensity = czm _getLambertDiffuse ( lightDirectionEC , normalEC ) ;
* float specularIntensity = czm _getSpecular ( lightDirectionEC , toEyeEC , normalEC , 200 ) ;
* vec3 color = ( diffuseColor * diffuseIntensity ) + ( specularColor * specularIntensity ) ;
* /
float czm _getSpecular ( vec3 lightDirectionEC , vec3 toEyeEC , vec3 normalEC , float shininess )
{
vec3 toReflectedLight = reflect ( - lightDirectionEC , normalEC ) ;
float specular = max ( dot ( toReflectedLight , toEyeEC ) , 0.0 ) ;
// pow has undefined behavior if both parameters <= 0.
// Prevent this by making sure shininess is at least czm_epsilon2.
return pow ( specular , max ( shininess , czm _epsilon2 ) ) ;
}
` ,yae= ` / * *
* @ private
* /
vec4 czm _getWaterNoise ( sampler2D normalMap , vec2 uv , float time , float angleInRadians )
{
float cosAngle = cos ( angleInRadians ) ;
float sinAngle = sin ( angleInRadians ) ;
// time dependent sampling directions
vec2 s0 = vec2 ( 1.0 / 17.0 , 0.0 ) ;
vec2 s1 = vec2 ( - 1.0 / 29.0 , 0.0 ) ;
vec2 s2 = vec2 ( 1.0 / 101.0 , 1.0 / 59.0 ) ;
vec2 s3 = vec2 ( - 1.0 / 109.0 , - 1.0 / 57.0 ) ;
// rotate sampling direction by specified angle
s0 = vec2 ( ( cosAngle * s0 . x ) - ( sinAngle * s0 . y ) , ( sinAngle * s0 . x ) + ( cosAngle * s0 . y ) ) ;
s1 = vec2 ( ( cosAngle * s1 . x ) - ( sinAngle * s1 . y ) , ( sinAngle * s1 . x ) + ( cosAngle * s1 . y ) ) ;
s2 = vec2 ( ( cosAngle * s2 . x ) - ( sinAngle * s2 . y ) , ( sinAngle * s2 . x ) + ( cosAngle * s2 . y ) ) ;
s3 = vec2 ( ( cosAngle * s3 . x ) - ( sinAngle * s3 . y ) , ( sinAngle * s3 . x ) + ( cosAngle * s3 . y ) ) ;
vec2 uv0 = ( uv / 103.0 ) + ( time * s0 ) ;
vec2 uv1 = uv / 107.0 + ( time * s1 ) + vec2 ( 0.23 ) ;
vec2 uv2 = uv / vec2 ( 897.0 , 983.0 ) + ( time * s2 ) + vec2 ( 0.51 ) ;
vec2 uv3 = uv / vec2 ( 991.0 , 877.0 ) + ( time * s3 ) + vec2 ( 0.71 ) ;
uv0 = fract ( uv0 ) ;
uv1 = fract ( uv1 ) ;
uv2 = fract ( uv2 ) ;
uv3 = fract ( uv3 ) ;
vec4 noise = ( texture2D ( normalMap , uv0 ) ) +
( texture2D ( normalMap , uv1 ) ) +
( texture2D ( normalMap , uv2 ) ) +
( texture2D ( normalMap , uv3 ) ) ;
// average and scale to between -1 and 1
return ( ( noise / 4.0 ) - 0.5 ) * 2.0 ;
}
` ,Aae= ` / * *
* Adjusts the hue of a color .
*
* @ name czm _hue
* @ glslFunction
*
* @ param { vec3 } rgb The color .
* @ param { float } adjustment The amount to adjust the hue of the color in radians .
*
* @ returns { float } The color with the hue adjusted .
*
* @ example
* vec3 adjustHue = czm _hue ( color , czm _pi ) ; // The same as czm_hue(color, -czm_pi)
* /
vec3 czm _hue ( vec3 rgb , float adjustment )
{
const mat3 toYIQ = mat3 ( 0.299 , 0.587 , 0.114 ,
0.595716 , - 0.274453 , - 0.321263 ,
0.211456 , - 0.522591 , 0.311135 ) ;
const mat3 toRGB = mat3 ( 1.0 , 0.9563 , 0.6210 ,
1.0 , - 0.2721 , - 0.6474 ,
1.0 , - 1.107 , 1.7046 ) ;
vec3 yiq = toYIQ * rgb ;
float hue = atan ( yiq . z , yiq . y ) + adjustment ;
float chroma = sqrt ( yiq . z * yiq . z + yiq . y * yiq . y ) ;
vec3 color = vec3 ( yiq . x , chroma * cos ( hue ) , chroma * sin ( hue ) ) ;
return toRGB * color ;
}
` ,Cae= ` / * *
* Converts a color in linear space to RGB space .
*
* @ name czm _inverseGamma
* @ glslFunction
*
* @ param { vec3 } color The color in linear space .
* @ returns { vec3 } The color in RGB space .
* /
vec3 czm _inverseGamma ( vec3 color ) {
return pow ( color , vec3 ( 1.0 / czm _gamma ) ) ;
}
` ,Tae= ` / * *
* Determines if a time interval is empty .
*
* @ name czm _isEmpty
* @ glslFunction
*
* @ param { czm _raySegment } interval The interval to test .
*
* @ returns { bool } < code > true < / c o d e > i f t h e t i m e i n t e r v a l i s e m p t y ; o t h e r w i s e , < c o d e > f a l s e < / c o d e > .
*
* @ example
* bool b0 = czm _isEmpty ( czm _emptyRaySegment ) ; // true
* bool b1 = czm _isEmpty ( czm _raySegment ( 0.0 , 1.0 ) ) ; // false
* bool b2 = czm _isEmpty ( czm _raySegment ( 1.0 , 1.0 ) ) ; // false, contains 1.0.
* /
bool czm _isEmpty ( czm _raySegment interval )
{
return ( interval . stop < 0.0 ) ;
}
` ,bae= ` / * *
* Determines if a time interval is empty .
*
* @ name czm _isFull
* @ glslFunction
*
* @ param { czm _raySegment } interval The interval to test .
*
* @ returns { bool } < code > true < / c o d e > i f t h e t i m e i n t e r v a l i s e m p t y ; o t h e r w i s e , < c o d e > f a l s e < / c o d e > .
*
* @ example
* bool b0 = czm _isEmpty ( czm _emptyRaySegment ) ; // true
* bool b1 = czm _isEmpty ( czm _raySegment ( 0.0 , 1.0 ) ) ; // false
* bool b2 = czm _isEmpty ( czm _raySegment ( 1.0 , 1.0 ) ) ; // false, contains 1.0.
* /
bool czm _isFull ( czm _raySegment interval )
{
return ( interval . start == 0.0 && interval . stop == czm _infinity ) ;
}
` ,Eae= ` / * *
* Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located .
*
* @ name czm _latitudeToWebMercatorFraction
* @ glslFunction
*
* @ param { float } latitude The geodetic latitude , in radians .
* @ param { float } southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle .
* @ param { float } oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates .
*
* @ returns { float } The fraction of the rectangle at which the latitude occurs . If the latitude is the southern
* boundary of the rectangle , the return value will be zero . If it is the northern boundary , the return
* value will be 1.0 . Latitudes in between are mapped according to the Web Mercator projection .
* /
float czm _latitudeToWebMercatorFraction ( float latitude , float southMercatorY , float oneOverMercatorHeight )
{
float sinLatitude = sin ( latitude ) ;
float mercatorY = 0.5 * log ( ( 1.0 + sinLatitude ) / ( 1.0 - sinLatitude ) ) ;
return ( mercatorY - southMercatorY ) * oneOverMercatorHeight ;
}
` ,xae= ` / * *
* Computes distance from an point in 2 D to a line in 2 D .
*
* @ name czm _lineDistance
* @ glslFunction
*
* param { vec2 } point1 A point along the line .
* param { vec2 } point2 A point along the line .
* param { vec2 } point A point that may or may not be on the line .
* returns { float } The distance from the point to the line .
* /
float czm _lineDistance ( vec2 point1 , vec2 point2 , vec2 point ) {
return abs ( ( point2 . y - point1 . y ) * point . x - ( point2 . x - point1 . x ) * point . y + point2 . x * point1 . y - point2 . y * point1 . x ) / distance ( point2 , point1 ) ;
}
` ,wae= ` / * *
* Converts a linear RGB color to an sRGB color .
*
* @ param { vec3 | vec4 } linearIn The color in linear color space .
* @ returns { vec3 | vec4 } The color in sRGB color space . The vector type matches the input .
* /
vec3 czm _linearToSrgb ( vec3 linearIn )
{
return pow ( linearIn , vec3 ( 1.0 / 2.2 ) ) ;
}
vec4 czm _linearToSrgb ( vec4 linearIn )
{
vec3 srgbOut = pow ( linearIn . rgb , vec3 ( 1.0 / 2.2 ) ) ;
return vec4 ( srgbOut , linearIn . a ) ;
}
` ,Sae= ` / * *
* Computes the luminance of a color .
*
* @ name czm _luminance
* @ glslFunction
*
* @ param { vec3 } rgb The color .
*
* @ returns { float } The luminance .
*
* @ example
* float light = czm _luminance ( vec3 ( 0.0 ) ) ; // 0.0
* float dark = czm _luminance ( vec3 ( 1.0 ) ) ; // ~1.0
* /
float czm _luminance ( vec3 rgb )
{
// Algorithm from Chapter 10 of Graphics Shaders.
const vec3 W = vec3 ( 0.2125 , 0.7154 , 0.0721 ) ;
return dot ( rgb , W ) ;
}
` ,vae= ` / * *
* Computes the size of a pixel in meters at a distance from the eye .
* < p >
* Use this version when passing in a custom pixel ratio . For example , passing in 1.0 will return meters per native device pixel .
* < / p >
* @ name czm _metersPerPixel
* @ glslFunction
*
* @ param { vec3 } positionEC The position to get the meters per pixel in eye coordinates .
* @ param { float } pixelRatio The scaling factor from pixel space to coordinate space
*
* @ returns { float } The meters per pixel at positionEC .
* /
float czm _metersPerPixel ( vec4 positionEC , float pixelRatio )
{
float width = czm _viewport . z ;
float height = czm _viewport . w ;
float pixelWidth ;
float pixelHeight ;
float top = czm _frustumPlanes . x ;
float bottom = czm _frustumPlanes . y ;
float left = czm _frustumPlanes . z ;
float right = czm _frustumPlanes . w ;
if ( czm _sceneMode == czm _sceneMode2D || czm _orthographicIn3D == 1.0 )
{
float frustumWidth = right - left ;
float frustumHeight = top - bottom ;
pixelWidth = frustumWidth / width ;
pixelHeight = frustumHeight / height ;
}
else
{
float distanceToPixel = - positionEC . z ;
float inverseNear = 1.0 / czm _currentFrustum . x ;
float tanTheta = top * inverseNear ;
pixelHeight = 2.0 * distanceToPixel * tanTheta / height ;
tanTheta = right * inverseNear ;
pixelWidth = 2.0 * distanceToPixel * tanTheta / width ;
}
return max ( pixelWidth , pixelHeight ) * pixelRatio ;
}
/ * *
* Computes the size of a pixel in meters at a distance from the eye .
* < p >
* Use this version when scaling by pixel ratio .
* < / p >
* @ name czm _metersPerPixel
* @ glslFunction
*
* @ param { vec3 } positionEC The position to get the meters per pixel in eye coordinates .
*
* @ returns { float } The meters per pixel at positionEC .
* /
float czm _metersPerPixel ( vec4 positionEC )
{
return czm _metersPerPixel ( positionEC , czm _pixelRatio ) ;
}
` ,Dae= ` / * *
* Transforms a position from model to window coordinates . The transformation
* from model to clip coordinates is done using { @ link czm _modelViewProjection } .
* The transform from normalized device coordinates to window coordinates is
* done using { @ link czm _viewportTransformation } , which assumes a depth range
* of < code > near = 0 < / c o d e > a n d < c o d e > f a r = 1 < / c o d e > .
* < br / > < br / >
* This transform is useful when there is a need to manipulate window coordinates
* in a vertex shader as done by { @ link BillboardCollection } .
* < br / > < br / >
* This function should not be confused with { @ link czm _viewportOrthographic } ,
* which is an orthographic projection matrix that transforms from window
* coordinates to clip coordinates .
*
* @ name czm _modelToWindowCoordinates
* @ glslFunction
*
* @ param { vec4 } position The position in model coordinates to transform .
*
* @ returns { vec4 } The transformed position in window coordinates .
*
* @ see czm _eyeToWindowCoordinates
* @ see czm _modelViewProjection
* @ see czm _viewportTransformation
* @ see czm _viewportOrthographic
* @ see BillboardCollection
*
* @ example
* vec4 positionWC = czm _modelToWindowCoordinates ( positionMC ) ;
* /
vec4 czm _modelToWindowCoordinates ( vec4 position )
{
vec4 q = czm _modelViewProjection * position ; // clip coordinates
q . xyz /= q . w ; // normalized device coordinates
q . xyz = ( czm _viewportTransformation * vec4 ( q . xyz , 1.0 ) ) . xyz ; // window coordinates
return q ;
}
` ,Iae= ` / * *
* DOC _TBA
*
* @ name czm _multiplyWithColorBalance
* @ glslFunction
* /
vec3 czm _multiplyWithColorBalance ( vec3 left , vec3 right )
{
// Algorithm from Chapter 10 of Graphics Shaders.
const vec3 W = vec3 ( 0.2125 , 0.7154 , 0.0721 ) ;
vec3 target = left * right ;
float leftLuminance = dot ( left , W ) ;
float rightLuminance = dot ( right , W ) ;
float targetLuminance = dot ( target , W ) ;
return ( ( leftLuminance + rightLuminance ) / ( 2.0 * targetLuminance ) ) * target ;
}
` ,Pae= ` / * *
* Computes a value that scales with distance . The scaling is clamped at the near and
* far distances , and does not extrapolate . This function works with the
* { @ link NearFarScalar } JavaScript class .
*
* @ name czm _nearFarScalar
* @ glslFunction
*
* @ param { vec4 } nearFarScalar A vector with 4 components : Near distance ( x ) , Near value ( y ) , Far distance ( z ) , Far value ( w ) .
* @ param { float } cameraDistSq The square of the current distance from the camera .
*
* @ returns { float } The value at this distance .
* /
float czm _nearFarScalar ( vec4 nearFarScalar , float cameraDistSq )
{
float valueAtMin = nearFarScalar . y ;
float valueAtMax = nearFarScalar . w ;
float nearDistanceSq = nearFarScalar . x * nearFarScalar . x ;
float farDistanceSq = nearFarScalar . z * nearFarScalar . z ;
float t = ( cameraDistSq - nearDistanceSq ) / ( farDistanceSq - nearDistanceSq ) ;
t = pow ( clamp ( t , 0.0 , 1.0 ) , 0.2 ) ;
return mix ( valueAtMin , valueAtMax , t ) ;
}
` ,Oae= ` / * *
* Decodes a unit - length vector in 'oct' encoding to a normalized 3 - component Cartesian vector .
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors" ,
* Cigolle et al 2014 : http : //jcgt.org/published/0003/02/01/
*
* @ name czm _octDecode
* @ param { vec2 } encoded The oct - encoded , unit - length vector
* @ param { float } range The maximum value of the SNORM range . The encoded vector is stored in log2 ( rangeMax + 1 ) bits .
* @ returns { vec3 } The decoded and normalized vector
* /
vec3 czm _octDecode ( vec2 encoded , float range )
{
if ( encoded . x == 0.0 && encoded . y == 0.0 ) {
return vec3 ( 0.0 , 0.0 , 0.0 ) ;
}
encoded = encoded / range * 2.0 - 1.0 ;
vec3 v = vec3 ( encoded . x , encoded . y , 1.0 - abs ( encoded . x ) - abs ( encoded . y ) ) ;
if ( v . z < 0.0 )
{
v . xy = ( 1.0 - abs ( v . yx ) ) * czm _signNotZero ( v . xy ) ;
}
return normalize ( v ) ;
}
/ * *
* Decodes a unit - length vector in 'oct' encoding to a normalized 3 - component Cartesian vector .
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors" ,
* Cigolle et al 2014 : http : //jcgt.org/published/0003/02/01/
*
* @ name czm _octDecode
* @ param { vec2 } encoded The oct - encoded , unit - length vector
* @ returns { vec3 } The decoded and normalized vector
* /
vec3 czm _octDecode ( vec2 encoded )
{
return czm _octDecode ( encoded , 255.0 ) ;
}
/ * *
* Decodes a unit - length vector in 'oct' encoding packed into a floating - point number to a normalized 3 - component Cartesian vector .
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors" ,
* Cigolle et al 2014 : http : //jcgt.org/published/0003/02/01/
*
* @ name czm _octDecode
* @ param { float } encoded The oct - encoded , unit - length vector
* @ returns { vec3 } The decoded and normalized vector
* /
vec3 czm _octDecode ( float encoded )
{
float temp = encoded / 256.0 ;
float x = floor ( temp ) ;
float y = ( temp - x ) * 256.0 ;
return czm _octDecode ( vec2 ( x , y ) ) ;
}
/ * *
* Decodes three unit - length vectors in 'oct' encoding packed into two floating - point numbers to normalized 3 - component Cartesian vectors .
* The 'oct' encoding is described in "A Survey of Efficient Representations of Independent Unit Vectors" ,
* Cigolle et al 2014 : http : //jcgt.org/published/0003/02/01/
*
* @ name czm _octDecode
* @ param { vec2 } encoded The packed oct - encoded , unit - length vectors .
* @ param { vec3 } vector1 One decoded and normalized vector .
* @ param { vec3 } vector2 One decoded and normalized vector .
* @ param { vec3 } vector3 One decoded and normalized vector .
* /
void czm _octDecode ( vec2 encoded , out vec3 vector1 , out vec3 vector2 , out vec3 vector3 )
{
float temp = encoded . x / 65536.0 ;
float x = floor ( temp ) ;
float encodedFloat1 = ( temp - x ) * 65536.0 ;
temp = encoded . y / 65536.0 ;
float y = floor ( temp ) ;
float encodedFloat2 = ( temp - y ) * 65536.0 ;
vector1 = czm _octDecode ( encodedFloat1 ) ;
vector2 = czm _octDecode ( encodedFloat2 ) ;
vector3 = czm _octDecode ( vec2 ( x , y ) ) ;
}
` ,Lae= ` / * *
* Packs a depth value into a vec3 that can be represented by unsigned bytes .
*
* @ name czm _packDepth
* @ glslFunction
*
* @ param { float } depth The floating - point depth .
* @ returns { vec3 } The packed depth .
* /
vec4 czm _packDepth ( float depth )
{
// See Aras Pranckevičius' post Encoding Floats to RGBA
// http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
vec4 enc = vec4 ( 1.0 , 255.0 , 65025.0 , 16581375.0 ) * depth ;
enc = fract ( enc ) ;
enc -= enc . yzww * vec4 ( 1.0 / 255.0 , 1.0 / 255.0 , 1.0 / 255.0 , 0.0 ) ;
return enc ;
}
` ,Bae= ` vec3 lambertianDiffuse ( vec3 diffuseColor )
{
return diffuseColor / czm _pi ;
}
vec3 fresnelSchlick2 ( vec3 f0 , vec3 f90 , float VdotH )
{
return f0 + ( f90 - f0 ) * pow ( clamp ( 1.0 - VdotH , 0.0 , 1.0 ) , 5.0 ) ;
}
float smithVisibilityG1 ( float NdotV , float roughness )
{
// this is the k value for direct lighting.
// for image based lighting it will be roughness^2 / 2
float k = ( roughness + 1.0 ) * ( roughness + 1.0 ) / 8.0 ;
return NdotV / ( NdotV * ( 1.0 - k ) + k ) ;
}
float smithVisibilityGGX ( float roughness , float NdotL , float NdotV )
{
return (
smithVisibilityG1 ( NdotL , roughness ) *
smithVisibilityG1 ( NdotV , roughness )
) ;
}
float GGX ( float roughness , float NdotH )
{
float roughnessSquared = roughness * roughness ;
float f = ( NdotH * roughnessSquared - NdotH ) * NdotH + 1.0 ;
return roughnessSquared / ( czm _pi * f * f ) ;
}
/ * *
* Compute the diffuse and specular contributions using physically based
* rendering . This function only handles direct lighting .
* < p >
* This function only handles the lighting calculations . Metallic / roughness
* and specular / glossy must be handled separately . See { @ czm _pbrMetallicRoughnessMaterial } , { @ czm _pbrSpecularGlossinessMaterial } and { @ czm _defaultPbrMaterial }
* < / p >
*
* @ name czm _pbrlighting
* @ glslFunction
*
* @ param { vec3 } positionEC The position of the fragment in eye coordinates
* @ param { vec3 } normalEC The surface normal in eye coordinates
* @ param { vec3 } lightDirectionEC Unit vector pointing to the light source in eye coordinates .
* @ param { vec3 } lightColorHdr radiance of the light source . This is a HDR value .
* @ param { czm _pbrParameters } The computed PBR parameters .
* @ return { vec3 } The computed HDR color
*
* @ example
* czm _pbrParameters pbrParameters = czm _pbrMetallicRoughnessMaterial (
* baseColor ,
* metallic ,
* roughness
* ) ;
* vec3 color = czm _pbrlighting (
* positionEC ,
* normalEC ,
* lightDirectionEC ,
* lightColorHdr ,
* pbrParameters ) ;
* /
vec3 czm _pbrLighting (
vec3 positionEC ,
vec3 normalEC ,
vec3 lightDirectionEC ,
vec3 lightColorHdr ,
czm _pbrParameters pbrParameters
)
{
vec3 v = - normalize ( positionEC ) ;
vec3 l = normalize ( lightDirectionEC ) ;
vec3 h = normalize ( v + l ) ;
vec3 n = normalEC ;
float NdotL = clamp ( dot ( n , l ) , 0.001 , 1.0 ) ;
float NdotV = abs ( dot ( n , v ) ) + 0.001 ;
float NdotH = clamp ( dot ( n , h ) , 0.0 , 1.0 ) ;
float LdotH = clamp ( dot ( l , h ) , 0.0 , 1.0 ) ;
float VdotH = clamp ( dot ( v , h ) , 0.0 , 1.0 ) ;
vec3 f0 = pbrParameters . f0 ;
float reflectance = max ( max ( f0 . r , f0 . g ) , f0 . b ) ;
vec3 f90 = vec3 ( clamp ( reflectance * 25.0 , 0.0 , 1.0 ) ) ;
vec3 F = fresnelSchlick2 ( f0 , f90 , VdotH ) ;
float alpha = pbrParameters . roughness ;
float G = smithVisibilityGGX ( alpha , NdotL , NdotV ) ;
float D = GGX ( alpha , NdotH ) ;
vec3 specularContribution = F * G * D / ( 4.0 * NdotL * NdotV ) ;
vec3 diffuseColor = pbrParameters . diffuseColor ;
// F here represents the specular contribution
vec3 diffuseContribution = ( 1.0 - F ) * lambertianDiffuse ( diffuseColor ) ;
// Lo = (diffuse + specular) * Li * NdotL
return ( diffuseContribution + specularContribution ) * NdotL * lightColorHdr ;
}
` ,Rae= ` / * *
* Compute parameters for physically based rendering using the
* metallic / roughness workflow . All inputs are linear ; sRGB texture values must
* be decoded beforehand
*
* @ name czm _pbrMetallicRoughnessMaterial
* @ glslFunction
*
* @ param { vec3 } baseColor For dielectrics , this is the base color . For metals , this is the f0 value ( reflectance at normal incidence )
* @ param { float } metallic 0.0 indicates dielectric . 1.0 indicates metal . Values in between are allowed ( e . g . to model rust or dirt ) ;
* @ param { float } roughness A value between 0.0 and 1.0
* @ return { czm _pbrParameters } parameters to pass into { @ link czm _pbrLighting }
* /
czm _pbrParameters czm _pbrMetallicRoughnessMaterial (
vec3 baseColor ,
float metallic ,
float roughness
)
{
czm _pbrParameters results ;
// roughness is authored as perceptual roughness
// square it to get material roughness
roughness = clamp ( roughness , 0.0 , 1.0 ) ;
results . roughness = roughness * roughness ;
// dielectrics use f0 = 0.04, metals use albedo as f0
metallic = clamp ( metallic , 0.0 , 1.0 ) ;
const vec3 REFLECTANCE _DIELECTRIC = vec3 ( 0.04 ) ;
vec3 f0 = mix ( REFLECTANCE _DIELECTRIC , baseColor , metallic ) ;
results . f0 = f0 ;
// diffuse only applies to dielectrics.
results . diffuseColor = baseColor * ( 1.0 - f0 ) * ( 1.0 - metallic ) ;
return results ;
}
` ,Nae= ` / * *
* Compute parameters for physically based rendering using the
* specular / glossy workflow . All inputs are linear ; sRGB texture values must
* be decoded beforehand
*
* @ name czm _pbrSpecularGlossinessMaterial
* @ glslFunction
*
* @ param { vec3 } diffuse The diffuse color for dielectrics ( non - metals )
* @ param { vec3 } specular The reflectance at normal incidence ( f0 )
* @ param { float } glossiness A number from 0.0 to 1.0 indicating how smooth the surface is .
* @ return { czm _pbrParameters } parameters to pass into { @ link czm _pbrLighting }
* /
czm _pbrParameters czm _pbrSpecularGlossinessMaterial (
vec3 diffuse ,
vec3 specular ,
float glossiness
)
{
czm _pbrParameters results ;
// glossiness is the opposite of roughness, but easier for artists to use.
float roughness = 1.0 - glossiness ;
results . roughness = roughness * roughness ;
results . diffuseColor = diffuse * ( 1.0 - max ( max ( specular . r , specular . g ) , specular . b ) ) ;
results . f0 = specular ;
return results ;
}
` ,Mae= ` float czm _private _getLambertDiffuseOfMaterial ( vec3 lightDirectionEC , czm _material material )
{
return czm _getLambertDiffuse ( lightDirectionEC , material . normal ) ;
}
float czm _private _getSpecularOfMaterial ( vec3 lightDirectionEC , vec3 toEyeEC , czm _material material )
{
return czm _getSpecular ( lightDirectionEC , toEyeEC , material . normal , material . shininess ) ;
}
/ * *
* Computes a color using the Phong lighting model .
*
* @ name czm _phong
* @ glslFunction
*
* @ param { vec3 } toEye A normalized vector from the fragment to the eye in eye coordinates .
* @ param { czm _material } material The fragment ' s material .
*
* @ returns { vec4 } The computed color .
*
* @ example
* vec3 positionToEyeEC = // ...
* czm _material material = // ...
* vec3 lightDirectionEC = // ...
* gl _FragColor = czm _phong ( normalize ( positionToEyeEC ) , material , lightDirectionEC ) ;
*
* @ see czm _getMaterial
* /
vec4 czm _phong ( vec3 toEye , czm _material material , vec3 lightDirectionEC )
{
// Diffuse from directional light sources at eye (for top-down)
float diffuse = czm _private _getLambertDiffuseOfMaterial ( vec3 ( 0.0 , 0.0 , 1.0 ) , material ) ;
if ( czm _sceneMode == czm _sceneMode3D ) {
// (and horizon views in 3D)
diffuse += czm _private _getLambertDiffuseOfMaterial ( vec3 ( 0.0 , 1.0 , 0.0 ) , material ) ;
}
float specular = czm _private _getSpecularOfMaterial ( lightDirectionEC , toEye , material ) ;
// Temporary workaround for adding ambient.
vec3 materialDiffuse = material . diffuse * 0.5 ;
vec3 ambient = materialDiffuse ;
vec3 color = ambient + material . emission ;
color += materialDiffuse * diffuse * czm _lightColor ;
color += material . specular * specular * czm _lightColor ;
return vec4 ( color , material . alpha ) ;
}
vec4 czm _private _phong ( vec3 toEye , czm _material material , vec3 lightDirectionEC )
{
float diffuse = czm _private _getLambertDiffuseOfMaterial ( lightDirectionEC , material ) ;
float specular = czm _private _getSpecularOfMaterial ( lightDirectionEC , toEye , material ) ;
vec3 ambient = vec3 ( 0.0 ) ;
vec3 color = ambient + material . emission ;
color += material . diffuse * diffuse * czm _lightColor ;
color += material . specular * specular * czm _lightColor ;
return vec4 ( color , material . alpha ) ;
}
` ,Fae= ` / * *
* Computes distance from a point to a plane .
*
* @ name czm _planeDistance
* @ glslFunction
*
* param { vec4 } plane A Plane in Hessian Normal Form . See Plane . js
* param { vec3 } point A point in the same space as the plane .
* returns { float } The distance from the point to the plane .
* /
float czm _planeDistance ( vec4 plane , vec3 point ) {
return ( dot ( plane . xyz , point ) + plane . w ) ;
}
/ * *
* Computes distance from a point to a plane .
*
* @ name czm _planeDistance
* @ glslFunction
*
* param { vec3 } planeNormal Normal for a plane in Hessian Normal Form . See Plane . js
* param { float } planeDistance Distance for a plane in Hessian Normal form . See Plane . js
* param { vec3 } point A point in the same space as the plane .
* returns { float } The distance from the point to the plane .
* /
float czm _planeDistance ( vec3 planeNormal , float planeDistance , vec3 point ) {
return ( dot ( planeNormal , point ) + planeDistance ) ;
}
` ,zae= ` / * *
* Computes the point along a ray at the given time . < code > time < / c o d e > c a n b e p o s i t i v e , n e g a t i v e , o r z e r o .
*
* @ name czm _pointAlongRay
* @ glslFunction
*
* @ param { czm _ray } ray The ray to compute the point along .
* @ param { float } time The time along the ray .
*
* @ returns { vec3 } The point along the ray at the given time .
*
* @ example
* czm _ray ray = czm _ray ( vec3 ( 0.0 ) , vec3 ( 1.0 , 0.0 , 0.0 ) ) ; // origin, direction
* vec3 v = czm _pointAlongRay ( ray , 2.0 ) ; // (2.0, 0.0, 0.0)
* /
vec3 czm _pointAlongRay ( czm _ray ray , float time )
{
return ray . origin + ( time * ray . direction ) ;
}
` ,Uae= ` / * *
* DOC _TBA
*
* @ name czm _rayEllipsoidIntersectionInterval
* @ glslFunction
* /
czm _raySegment czm _rayEllipsoidIntersectionInterval ( czm _ray ray , vec3 ellipsoid _center , vec3 ellipsoid _inverseRadii )
{
// ray and ellipsoid center in eye coordinates. radii in model coordinates.
vec3 q = ellipsoid _inverseRadii * ( czm _inverseModelView * vec4 ( ray . origin , 1.0 ) ) . xyz ;
vec3 w = ellipsoid _inverseRadii * ( czm _inverseModelView * vec4 ( ray . direction , 0.0 ) ) . xyz ;
q = q - ellipsoid _inverseRadii * ( czm _inverseModelView * vec4 ( ellipsoid _center , 1.0 ) ) . xyz ;
float q2 = dot ( q , q ) ;
float qw = dot ( q , w ) ;
if ( q2 > 1.0 ) // Outside ellipsoid.
{
if ( qw >= 0.0 ) // Looking outward or tangent (0 intersections).
{
return czm _emptyRaySegment ;
}
else // qw < 0.0.
{
float qw2 = qw * qw ;
float difference = q2 - 1.0 ; // Positively valued.
float w2 = dot ( w , w ) ;
float product = w2 * difference ;
if ( qw2 < product ) // Imaginary roots (0 intersections).
{
return czm _emptyRaySegment ;
}
else if ( qw2 > product ) // Distinct roots (2 intersections).
{
float discriminant = qw * qw - product ;
float temp = - qw + sqrt ( discriminant ) ; // Avoid cancellation.
float root0 = temp / w2 ;
float root1 = difference / temp ;
if ( root0 < root1 )
{
czm _raySegment i = czm _raySegment ( root0 , root1 ) ;
return i ;
}
else
{
czm _raySegment i = czm _raySegment ( root1 , root0 ) ;
return i ;
}
}
else // qw2 == product. Repeated roots (2 intersections).
{
float root = sqrt ( difference / w2 ) ;
czm _raySegment i = czm _raySegment ( root , root ) ;
return i ;
}
}
}
else if ( q2 < 1.0 ) // Inside ellipsoid (2 intersections).
{
float difference = q2 - 1.0 ; // Negatively valued.
float w2 = dot ( w , w ) ;
float product = w2 * difference ; // Negatively valued.
float discriminant = qw * qw - product ;
float temp = - qw + sqrt ( discriminant ) ; // Positively valued.
czm _raySegment i = czm _raySegment ( 0.0 , temp / w2 ) ;
return i ;
}
else // q2 == 1.0. On ellipsoid.
{
if ( qw < 0.0 ) // Looking inward.
{
float w2 = dot ( w , w ) ;
czm _raySegment i = czm _raySegment ( 0.0 , - qw / w2 ) ;
return i ;
}
else // qw >= 0.0. Looking outward or tangent.
{
return czm _emptyRaySegment ;
}
}
}
` ,Hae= ` / * *
* Compute the intersection interval of a ray with a sphere .
*
* @ name czm _raySphereIntersectionInterval
* @ glslFunction
*
* @ param { czm _ray } ray The ray .
* @ param { vec3 } center The center of the sphere .
* @ param { float } radius The radius of the sphere .
* @ return { czm _raySegment } The intersection interval of the ray with the sphere .
* /
czm _raySegment czm _raySphereIntersectionInterval ( czm _ray ray , vec3 center , float radius )
{
vec3 o = ray . origin ;
vec3 d = ray . direction ;
vec3 oc = o - center ;
float a = dot ( d , d ) ;
float b = 2.0 * dot ( d , oc ) ;
float c = dot ( oc , oc ) - ( radius * radius ) ;
float det = ( b * b ) - ( 4.0 * a * c ) ;
if ( det < 0.0 ) {
return czm _emptyRaySegment ;
}
float sqrtDet = sqrt ( det ) ;
float t0 = ( - b - sqrtDet ) / ( 2.0 * a ) ;
float t1 = ( - b + sqrtDet ) / ( 2.0 * a ) ;
czm _raySegment result = czm _raySegment ( t0 , t1 ) ;
return result ;
}
` ,Vae= ` float czm _readDepth ( sampler2D depthTexture , vec2 texCoords )
{
return czm _reverseLogDepth ( texture2D ( depthTexture , texCoords ) . r ) ;
}
` ,kae= ` / * *
* Reads a value previously transformed with { @ link czm _writeNonPerspective }
* by dividing it by \ ` w \` , the value used in the perspective divide.
* This function is intended to be called in a fragment shader to access a
* \ ` varying \` that should not be subject to perspective interpolation.
* For example , screen - space texture coordinates . The value should have been
* previously written in the vertex shader with a call to
* { @ link czm _writeNonPerspective } .
*
* @ name czm _readNonPerspective
* @ glslFunction
*
* @ param { float | vec2 | vec3 | vec4 } value The non - perspective value to be read .
* @ param { float } oneOverW One over the perspective divide value , \ ` w \` . Usually this is simply \` gl_FragCoord.w \` .
* @ returns { float | vec2 | vec3 | vec4 } The usable value .
* /
float czm _readNonPerspective ( float value , float oneOverW ) {
return value * oneOverW ;
}
vec2 czm _readNonPerspective ( vec2 value , float oneOverW ) {
return value * oneOverW ;
}
vec3 czm _readNonPerspective ( vec3 value , float oneOverW ) {
return value * oneOverW ;
}
vec4 czm _readNonPerspective ( vec4 value , float oneOverW ) {
return value * oneOverW ;
}
` ,Gae= ` float czm _reverseLogDepth ( float logZ )
{
# ifdef LOG _DEPTH
float near = czm _currentFrustum . x ;
float far = czm _currentFrustum . y ;
float log2Depth = logZ * czm _log2FarDepthFromNearPlusOne ;
float depthFromNear = pow ( 2.0 , log2Depth ) - 1.0 ;
return far * ( 1.0 - near / ( depthFromNear + near ) ) / ( far - near ) ;
# endif
return logZ ;
}
` ,Wae= ` / * *
* Round a floating point value . This function exists because round ( ) doesn ' t
* exist in GLSL 1.00 .
*
* @ param { float | vec2 | vec3 | vec4 } value The value to round
* @ param { float | vec2 | vec3 | vec3 } The rounded value . The type matches the input .
* /
float czm _round ( float value ) {
return floor ( value + 0.5 ) ;
}
vec2 czm _round ( vec2 value ) {
return floor ( value + 0.5 ) ;
}
vec3 czm _round ( vec3 value ) {
return floor ( value + 0.5 ) ;
}
vec4 czm _round ( vec4 value ) {
return floor ( value + 0.5 ) ;
}
` ,jae= ` / * *
* Samples the 4 neighboring pixels and return the weighted average .
*
* @ private
* /
vec3 czm _sampleOctahedralProjectionWithFiltering ( sampler2D projectedMap , vec2 textureSize , vec3 direction , float lod )
{
direction /= dot ( vec3 ( 1.0 ) , abs ( direction ) ) ;
vec2 rev = abs ( direction . zx ) - vec2 ( 1.0 ) ;
vec2 neg = vec2 ( direction . x < 0.0 ? rev . x : - rev . x ,
direction . z < 0.0 ? rev . y : - rev . y ) ;
vec2 uv = direction . y < 0.0 ? neg : direction . xz ;
vec2 coord = 0.5 * uv + vec2 ( 0.5 ) ;
vec2 pixel = 1.0 / textureSize ;
if ( lod > 0.0 )
{
// Each subseqeuent mip level is half the size
float scale = 1.0 / pow ( 2.0 , lod ) ;
float offset = ( ( textureSize . y + 1.0 ) / textureSize . x ) ;
coord . x *= offset ;
coord *= scale ;
coord . x += offset + pixel . x ;
coord . y += ( 1.0 - ( 1.0 / pow ( 2.0 , lod - 1.0 ) ) ) + pixel . y * ( lod - 1.0 ) * 2.0 ;
}
else
{
coord . x *= ( textureSize . y / textureSize . x ) ;
}
// Do bilinear filtering
# ifndef OES _texture _float _linear
vec3 color1 = texture2D ( projectedMap , coord + vec2 ( 0.0 , pixel . y ) ) . rgb ;
vec3 color2 = texture2D ( projectedMap , coord + vec2 ( pixel . x , 0.0 ) ) . rgb ;
vec3 color3 = texture2D ( projectedMap , coord + pixel ) . rgb ;
vec3 color4 = texture2D ( projectedMap , coord ) . rgb ;
vec2 texturePosition = coord * textureSize ;
float fu = fract ( texturePosition . x ) ;
float fv = fract ( texturePosition . y ) ;
vec3 average1 = mix ( color4 , color2 , fu ) ;
vec3 average2 = mix ( color1 , color3 , fu ) ;
vec3 color = mix ( average1 , average2 , fv ) ;
# else
vec3 color = texture2D ( projectedMap , coord ) . rgb ;
# endif
return color ;
}
/ * *
* Samples from a cube map that has been projected using an octahedral projection from the given direction .
*
* @ name czm _sampleOctahedralProjection
* @ glslFunction
*
* @ param { sampler2D } projectedMap The texture with the octahedral projected cube map .
* @ param { vec2 } textureSize The width and height dimensions in pixels of the projected map .
* @ param { vec3 } direction The normalized direction used to sample the cube map .
* @ param { float } lod The level of detail to sample .
* @ param { float } maxLod The maximum level of detail .
* @ returns { vec3 } The color of the cube map at the direction .
* /
vec3 czm _sampleOctahedralProjection ( sampler2D projectedMap , vec2 textureSize , vec3 direction , float lod , float maxLod ) {
float currentLod = floor ( lod + 0.5 ) ;
float nextLod = min ( currentLod + 1.0 , maxLod ) ;
vec3 colorCurrentLod = czm _sampleOctahedralProjectionWithFiltering ( projectedMap , textureSize , direction , currentLod ) ;
vec3 colorNextLod = czm _sampleOctahedralProjectionWithFiltering ( projectedMap , textureSize , direction , nextLod ) ;
return mix ( colorNextLod , colorCurrentLod , nextLod - lod ) ;
}
` ,qae= ` / * *
* Adjusts the saturation of a color .
*
* @ name czm _saturation
* @ glslFunction
*
* @ param { vec3 } rgb The color .
* @ param { float } adjustment The amount to adjust the saturation of the color .
*
* @ returns { float } The color with the saturation adjusted .
*
* @ example
* vec3 greyScale = czm _saturation ( color , 0.0 ) ;
* vec3 doubleSaturation = czm _saturation ( color , 2.0 ) ;
* /
vec3 czm _saturation ( vec3 rgb , float adjustment )
{
// Algorithm from Chapter 16 of OpenGL Shading Language
const vec3 W = vec3 ( 0.2125 , 0.7154 , 0.0721 ) ;
vec3 intensity = vec3 ( dot ( rgb , W ) ) ;
return mix ( intensity , rgb , adjustment ) ;
}
` ,Yae= `
float czm _sampleShadowMap ( highp samplerCube shadowMap , vec3 d )
{
return czm _unpackDepth ( textureCube ( shadowMap , d ) ) ;
}
float czm _sampleShadowMap ( highp sampler2D shadowMap , vec2 uv )
{
# ifdef USE _SHADOW _DEPTH _TEXTURE
return texture2D ( shadowMap , uv ) . r ;
# else
return czm _unpackDepth ( texture2D ( shadowMap , uv ) ) ;
# endif
}
float czm _shadowDepthCompare ( samplerCube shadowMap , vec3 uv , float depth )
{
return step ( depth , czm _sampleShadowMap ( shadowMap , uv ) ) ;
}
float czm _shadowDepthCompare ( sampler2D shadowMap , vec2 uv , float depth )
{
return step ( depth , czm _sampleShadowMap ( shadowMap , uv ) ) ;
}
` ,Xae= `
float czm _private _shadowVisibility ( float visibility , float nDotL , float normalShadingSmooth , float darkness )
{
# ifdef USE _NORMAL _SHADING
# ifdef USE _NORMAL _SHADING _SMOOTH
float strength = clamp ( nDotL / normalShadingSmooth , 0.0 , 1.0 ) ;
# else
float strength = step ( 0.0 , nDotL ) ;
# endif
visibility *= strength ;
# endif
visibility = max ( visibility , darkness ) ;
return visibility ;
}
# ifdef USE _CUBE _MAP _SHADOW
float czm _shadowVisibility ( samplerCube shadowMap , czm _shadowParameters shadowParameters )
{
float depthBias = shadowParameters . depthBias ;
float depth = shadowParameters . depth ;
float nDotL = shadowParameters . nDotL ;
float normalShadingSmooth = shadowParameters . normalShadingSmooth ;
float darkness = shadowParameters . darkness ;
vec3 uvw = shadowParameters . texCoords ;
depth -= depthBias ;
float visibility = czm _shadowDepthCompare ( shadowMap , uvw , depth ) ;
return czm _private _shadowVisibility ( visibility , nDotL , normalShadingSmooth , darkness ) ;
}
# else
float czm _shadowVisibility ( sampler2D shadowMap , czm _shadowParameters shadowParameters )
{
float depthBias = shadowParameters . depthBias ;
float depth = shadowParameters . depth ;
float nDotL = shadowParameters . nDotL ;
float normalShadingSmooth = shadowParameters . normalShadingSmooth ;
float darkness = shadowParameters . darkness ;
vec2 uv = shadowParameters . texCoords ;
depth -= depthBias ;
# ifdef USE _SOFT _SHADOWS
vec2 texelStepSize = shadowParameters . texelStepSize ;
float radius = 1.0 ;
float dx0 = - texelStepSize . x * radius ;
float dy0 = - texelStepSize . y * radius ;
float dx1 = texelStepSize . x * radius ;
float dy1 = texelStepSize . y * radius ;
float visibility = (
czm _shadowDepthCompare ( shadowMap , uv , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx0 , dy0 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( 0.0 , dy0 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx1 , dy0 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx0 , 0.0 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx1 , 0.0 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx0 , dy1 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( 0.0 , dy1 ) , depth ) +
czm _shadowDepthCompare ( shadowMap , uv + vec2 ( dx1 , dy1 ) , depth )
) * ( 1.0 / 9.0 ) ;
# else
float visibility = czm _shadowDepthCompare ( shadowMap , uv , depth ) ;
# endif
return czm _private _shadowVisibility ( visibility , nDotL , normalShadingSmooth , darkness ) ;
}
# endif
` , $ ae= ` / * *
* Returns 1.0 if the given value is positive or zero , and - 1.0 if it is negative . This is similar to the GLSL
* built - in function < code > sign < / c o d e > e x c e p t t h a t r e t u r n s 1 . 0 i n s t e a d o f 0 . 0 w h e n t h e i n p u t v a l u e i s 0 . 0 .
*
* @ name czm _signNotZero
* @ glslFunction
*
* @ param { } value The value for which to determine the sign .
* @ returns { } 1.0 if the value is positive or zero , - 1.0 if the value is negative .
* /
float czm _signNotZero ( float value )
{
return value >= 0.0 ? 1.0 : - 1.0 ;
}
vec2 czm _signNotZero ( vec2 value )
{
return vec2 ( czm _signNotZero ( value . x ) , czm _signNotZero ( value . y ) ) ;
}
vec3 czm _signNotZero ( vec3 value )
{
return vec3 ( czm _signNotZero ( value . x ) , czm _signNotZero ( value . y ) , czm _signNotZero ( value . z ) ) ;
}
vec4 czm _signNotZero ( vec4 value )
{
return vec4 ( czm _signNotZero ( value . x ) , czm _signNotZero ( value . y ) , czm _signNotZero ( value . z ) , czm _signNotZero ( value . w ) ) ;
}
` ,Kae= ` / * *
* Computes a color from the third order spherical harmonic coefficients and a normalized direction vector .
* < p >
* The order of the coefficients is [ L00 , L1 _1 , L10 , L11 , L2 _2 , L2 _1 , L20 , L21 , L22 ] .
* < / p >
*
* @ name czm _sphericalHarmonics
* @ glslFunction
*
* @ param { vec3 } normal The normalized direction .
* @ param { vec3 [ 9 ] } coefficients The third order spherical harmonic coefficients .
* @ returns { vec3 } The color at the direction .
*
* @ see https : //graphics.stanford.edu/papers/envmap/envmap.pdf
* /
vec3 czm _sphericalHarmonics ( vec3 normal , vec3 coefficients [ 9 ] )
{
vec3 L00 = coefficients [ 0 ] ;
vec3 L1 _1 = coefficients [ 1 ] ;
vec3 L10 = coefficients [ 2 ] ;
vec3 L11 = coefficients [ 3 ] ;
vec3 L2 _2 = coefficients [ 4 ] ;
vec3 L2 _1 = coefficients [ 5 ] ;
vec3 L20 = coefficients [ 6 ] ;
vec3 L21 = coefficients [ 7 ] ;
vec3 L22 = coefficients [ 8 ] ;
float x = normal . x ;
float y = normal . y ;
float z = normal . z ;
return
L00
+ L1 _1 * y
+ L10 * z
+ L11 * x
+ L2 _2 * ( y * x )
+ L2 _1 * ( y * z )
+ L20 * ( 3.0 * z * z - 1.0 )
+ L21 * ( z * x )
+ L22 * ( x * x - y * y ) ;
}
` ,Jae= ` / * *
* Converts an sRGB color to a linear RGB color .
*
* @ param { vec3 | vec4 } srgbIn The color in sRGB space
* @ returns { vec3 | vec4 } The color in linear color space . The vector type matches the input .
* /
vec3 czm _srgbToLinear ( vec3 srgbIn )
{
return pow ( srgbIn , vec3 ( 2.2 ) ) ;
}
vec4 czm _srgbToLinear ( vec4 srgbIn )
{
vec3 linearOut = pow ( srgbIn . rgb , vec3 ( 2.2 ) ) ;
return vec4 ( linearOut , srgbIn . a ) ;
}
` ,Qae= ` / * *
* Creates a matrix that transforms vectors from tangent space to eye space .
*
* @ name czm _tangentToEyeSpaceMatrix
* @ glslFunction
*
* @ param { vec3 } normalEC The normal vector in eye coordinates .
* @ param { vec3 } tangentEC The tangent vector in eye coordinates .
* @ param { vec3 } bitangentEC The bitangent vector in eye coordinates .
*
* @ returns { mat3 } The matrix that transforms from tangent space to eye space .
*
* @ example
* mat3 tangentToEye = czm _tangentToEyeSpaceMatrix ( normalEC , tangentEC , bitangentEC ) ;
* vec3 normal = tangentToEye * texture2D ( normalMap , st ) . xyz ;
* /
mat3 czm _tangentToEyeSpaceMatrix ( vec3 normalEC , vec3 tangentEC , vec3 bitangentEC )
{
vec3 normal = normalize ( normalEC ) ;
vec3 tangent = normalize ( tangentEC ) ;
vec3 bitangent = normalize ( bitangentEC ) ;
return mat3 ( tangent . x , tangent . y , tangent . z ,
bitangent . x , bitangent . y , bitangent . z ,
normal . x , normal . y , normal . z ) ;
}
` ,Zae= ` / * *
* Transforms a plane .
*
* @ name czm _transformPlane
* @ glslFunction
*
* @ param { vec4 } plane The plane in Hessian Normal Form .
* @ param { mat4 } transform The inverse - transpose of a transformation matrix .
* /
vec4 czm _transformPlane ( vec4 plane , mat4 transform ) {
vec4 transformedPlane = transform * plane ;
// Convert the transformed plane to Hessian Normal Form
float normalMagnitude = length ( transformedPlane . xyz ) ;
return transformedPlane / normalMagnitude ;
}
` ,ece= ` / * *
* Translates a position ( or any < code > vec3 < / c o d e > ) t h a t w a s e n c o d e d w i t h { @ l i n k E n c o d e d C a r t e s i a n 3 } ,
* and then provided to the shader as separate < code > high < / c o d e > a n d < c o d e > l o w < / c o d e > b i t s t o
* be relative to the eye . As shown in the example , the position can then be transformed in eye
* or clip coordinates using { @ link czm _modelViewRelativeToEye } or { @ link czm _modelViewProjectionRelativeToEye } ,
* respectively .
* < p >
* This technique , called GPU RTE , eliminates jittering artifacts when using large coordinates as
* described in { @ link http : //help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}.
* < / p >
*
* @ name czm _translateRelativeToEye
* @ glslFunction
*
* @ param { vec3 } high The position ' s high bits .
* @ param { vec3 } low The position ' s low bits .
* @ returns { vec3 } The position translated to be relative to the camera ' s position .
*
* @ example
* attribute vec3 positionHigh ;
* attribute vec3 positionLow ;
*
* void main ( )
* {
* vec4 p = czm _translateRelativeToEye ( positionHigh , positionLow ) ;
* gl _Position = czm _modelViewProjectionRelativeToEye * p ;
* }
*
* @ see czm _modelViewRelativeToEye
* @ see czm _modelViewProjectionRelativeToEye
* @ see czm _computePosition
* @ see EncodedCartesian3
* /
vec4 czm _translateRelativeToEye ( vec3 high , vec3 low )
{
vec3 highDifference = high - czm _encodedCameraPositionMCHigh ;
vec3 lowDifference = low - czm _encodedCameraPositionMCLow ;
return vec4 ( highDifference + lowDifference , 1.0 ) ;
}
` ,tce= ` / * *
* @ private
* /
vec4 czm _translucentPhong ( vec3 toEye , czm _material material , vec3 lightDirectionEC )
{
// Diffuse from directional light sources at eye (for top-down and horizon views)
float diffuse = czm _getLambertDiffuse ( vec3 ( 0.0 , 0.0 , 1.0 ) , material . normal ) ;
if ( czm _sceneMode == czm _sceneMode3D ) {
// (and horizon views in 3D)
diffuse += czm _getLambertDiffuse ( vec3 ( 0.0 , 1.0 , 0.0 ) , material . normal ) ;
}
diffuse = clamp ( diffuse , 0.0 , 1.0 ) ;
float specular = czm _getSpecular ( lightDirectionEC , toEye , material . normal , material . shininess ) ;
// Temporary workaround for adding ambient.
vec3 materialDiffuse = material . diffuse * 0.5 ;
vec3 ambient = materialDiffuse ;
vec3 color = ambient + material . emission ;
color += materialDiffuse * diffuse * czm _lightColor ;
color += material . specular * specular * czm _lightColor ;
return vec4 ( color , material . alpha ) ;
}
` ,nce= ` / * *
* Returns the transpose of the matrix . The input < code > matrix < / c o d e > c a n b e
* a < code > mat2 < / c o d e > , < c o d e > m a t 3 < / c o d e > , o r < c o d e > m a t 4 < / c o d e > .
*
* @ name czm _transpose
* @ glslFunction
*
* @ param { } matrix The matrix to transpose .
*
* @ returns { } The transposed matrix .
*
* @ example
* // GLSL declarations
* mat2 czm _transpose ( mat2 matrix ) ;
* mat3 czm _transpose ( mat3 matrix ) ;
* mat4 czm _transpose ( mat4 matrix ) ;
*
* // Transpose a 3x3 rotation matrix to find its inverse.
* mat3 eastNorthUpToEye = czm _eastNorthUpToEyeCoordinates (
* positionMC , normalEC ) ;
* mat3 eyeToEastNorthUp = czm _transpose ( eastNorthUpToEye ) ;
* /
mat2 czm _transpose ( mat2 matrix )
{
return mat2 (
matrix [ 0 ] [ 0 ] , matrix [ 1 ] [ 0 ] ,
matrix [ 0 ] [ 1 ] , matrix [ 1 ] [ 1 ] ) ;
}
mat3 czm _transpose ( mat3 matrix )
{
return mat3 (
matrix [ 0 ] [ 0 ] , matrix [ 1 ] [ 0 ] , matrix [ 2 ] [ 0 ] ,
matrix [ 0 ] [ 1 ] , matrix [ 1 ] [ 1 ] , matrix [ 2 ] [ 1 ] ,
matrix [ 0 ] [ 2 ] , matrix [ 1 ] [ 2 ] , matrix [ 2 ] [ 2 ] ) ;
}
mat4 czm _transpose ( mat4 matrix )
{
return mat4 (
matrix [ 0 ] [ 0 ] , matrix [ 1 ] [ 0 ] , matrix [ 2 ] [ 0 ] , matrix [ 3 ] [ 0 ] ,
matrix [ 0 ] [ 1 ] , matrix [ 1 ] [ 1 ] , matrix [ 2 ] [ 1 ] , matrix [ 3 ] [ 1 ] ,
matrix [ 0 ] [ 2 ] , matrix [ 1 ] [ 2 ] , matrix [ 2 ] [ 2 ] , matrix [ 3 ] [ 2 ] ,
matrix [ 0 ] [ 3 ] , matrix [ 1 ] [ 3 ] , matrix [ 2 ] [ 3 ] , matrix [ 3 ] [ 3 ] ) ;
}
` ,ice= ` / * *
* Unpacks a vec4 depth value to a float in [ 0 , 1 ) range .
*
* @ name czm _unpackDepth
* @ glslFunction
*
* @ param { vec4 } packedDepth The packed depth .
*
* @ returns { float } The floating - point depth in [ 0 , 1 ) range .
* /
float czm _unpackDepth ( vec4 packedDepth )
{
// See Aras Pranckevičius' post Encoding Floats to RGBA
// http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
return dot ( packedDepth , vec4 ( 1.0 , 1.0 / 255.0 , 1.0 / 65025.0 , 1.0 / 16581375.0 ) ) ;
}
` ,oce= ` / * *
* Unpack an IEEE 754 single - precision float that is packed as a little - endian unsigned normalized vec4 .
*
* @ name czm _unpackFloat
* @ glslFunction
*
* @ param { vec4 } packedFloat The packed float .
*
* @ returns { float } The floating - point depth in arbitrary range .
* /
float czm _unpackFloat ( vec4 packedFloat )
{
// Convert to [0.0, 255.0] and round to integer
packedFloat = floor ( packedFloat * 255.0 + 0.5 ) ;
float sign = 1.0 - step ( 128.0 , packedFloat [ 3 ] ) * 2.0 ;
float exponent = 2.0 * mod ( packedFloat [ 3 ] , 128.0 ) + step ( 128.0 , packedFloat [ 2 ] ) - 127.0 ;
if ( exponent == - 127.0 )
{
return 0.0 ;
}
float mantissa = mod ( packedFloat [ 2 ] , 128.0 ) * 65536.0 + packedFloat [ 1 ] * 256.0 + packedFloat [ 0 ] + float ( 0x800000 ) ;
float result = sign * exp2 ( exponent - 23.0 ) * mantissa ;
return result ;
}
` ,rce= ` / * *
* Unpack unsigned integers of 1 - 4 bytes . in WebGL 1 , there is no uint type ,
* so the return value is an int .
* < p >
* There are also precision limitations in WebGL 1. highp int is still limited
* to 24 bits . Above the value of 2 ^ 24 = 16777216 , precision loss may occur .
* < / p >
*
* @ param { float | vec2 | vec3 | vec4 } packed The packed value . For vectors , the components are listed in little - endian order .
*
* @ return { int } The unpacked value .
* /
int czm _unpackUint ( float packedValue ) {
float rounded = czm _round ( packedValue * 255.0 ) ;
return int ( rounded ) ;
}
int czm _unpackUint ( vec2 packedValue ) {
vec2 rounded = czm _round ( packedValue * 255.0 ) ;
return int ( dot ( rounded , vec2 ( 1.0 , 256.0 ) ) ) ;
}
int czm _unpackUint ( vec3 packedValue ) {
vec3 rounded = czm _round ( packedValue * 255.0 ) ;
return int ( dot ( rounded , vec3 ( 1.0 , 256.0 , 65536.0 ) ) ) ;
}
int czm _unpackUint ( vec4 packedValue ) {
vec4 rounded = czm _round ( packedValue * 255.0 ) ;
return int ( dot ( rounded , vec4 ( 1.0 , 256.0 , 65536.0 , 16777216.0 ) ) ) ;
}
` ,sce= ` / * *
* Transform metadata values following the EXT _structural _metadata spec
* by multiplying by scale and adding the offset . Operations are always
* performed component - wise , even for matrices .
*
* @ param { float | vec2 | vec3 | vec4 | mat2 | mat3 | mat4 } offset The offset to add
* @ param { float | vec2 | vec3 | vec4 | mat2 | mat3 | mat4 } scale The scale factor to multiply
* @ param { float | vec2 | vec3 | vec4 | mat2 | mat3 | mat4 } value The original value .
*
* @ return { float | vec2 | vec3 | vec4 | mat2 | mat3 | mat4 } The transformed value of the same scalar / vector / matrix type as the input .
* /
float czm _valueTransform ( float offset , float scale , float value ) {
return scale * value + offset ;
}
vec2 czm _valueTransform ( vec2 offset , vec2 scale , vec2 value ) {
return scale * value + offset ;
}
vec3 czm _valueTransform ( vec3 offset , vec3 scale , vec3 value ) {
return scale * value + offset ;
}
vec4 czm _valueTransform ( vec4 offset , vec4 scale , vec4 value ) {
return scale * value + offset ;
}
mat2 czm _valueTransform ( mat2 offset , mat2 scale , mat2 value ) {
return matrixCompMult ( scale , value ) + offset ;
}
mat3 czm _valueTransform ( mat3 offset , mat3 scale , mat3 value ) {
return matrixCompMult ( scale , value ) + offset ;
}
mat4 czm _valueTransform ( mat4 offset , mat4 scale , mat4 value ) {
return matrixCompMult ( scale , value ) + offset ;
}
` ,ace= ` # ifdef LOG _DEPTH
// 1.0 at the near plane, increasing linearly from there.
varying float v _depthFromNearPlusOne ;
# ifdef SHADOW _MAP
varying vec3 v _logPositionEC ;
# endif
# endif
vec4 czm _updatePositionDepth ( vec4 coords ) {
# if defined ( LOG _DEPTH )
# ifdef SHADOW _MAP
vec3 logPositionEC = ( czm _inverseProjection * coords ) . xyz ;
v _logPositionEC = logPositionEC ;
# endif
// With the very high far/near ratios used with the logarithmic depth
// buffer, floating point rounding errors can cause linear depth values
// to end up on the wrong side of the far plane, even for vertices that
// are really nowhere near it. Since we always write a correct logarithmic
// depth value in the fragment shader anyway, we just need to make sure
// such errors don't cause the primitive to be clipped entirely before
// we even get to the fragment shader.
coords . z = clamp ( coords . z / coords . w , - 1.0 , 1.0 ) * coords . w ;
# endif
return coords ;
}
/ * *
* Writes the logarithmic depth to gl _Position using the already computed gl _Position .
*
* @ name czm _vertexLogDepth
* @ glslFunction
* /
void czm _vertexLogDepth ( )
{
# ifdef LOG _DEPTH
v _depthFromNearPlusOne = ( gl _Position . w - czm _currentFrustum . x ) + 1.0 ;
gl _Position = czm _updatePositionDepth ( gl _Position ) ;
# endif
}
/ * *
* Writes the logarithmic depth to gl _Position using the provided clip coordinates .
* < p >
* An example use case for this function would be moving the vertex in window coordinates
* before converting back to clip coordinates . Use the original vertex clip coordinates .
* < / p >
* @ name czm _vertexLogDepth
* @ glslFunction
*
* @ param { vec4 } clipCoords The vertex in clip coordinates .
*
* @ example
* czm _vertexLogDepth ( czm _projection * vec4 ( positionEyeCoordinates , 1.0 ) ) ;
* /
void czm _vertexLogDepth ( vec4 clipCoords )
{
# ifdef LOG _DEPTH
v _depthFromNearPlusOne = ( clipCoords . w - czm _currentFrustum . x ) + 1.0 ;
czm _updatePositionDepth ( clipCoords ) ;
# endif
}
` ,cce= ` vec4 czm _screenToEyeCoordinates ( vec4 screenCoordinate )
{
// Reconstruct NDC coordinates
float x = 2.0 * screenCoordinate . x - 1.0 ;
float y = 2.0 * screenCoordinate . y - 1.0 ;
float z = ( screenCoordinate . z - czm _viewportTransformation [ 3 ] [ 2 ] ) / czm _viewportTransformation [ 2 ] [ 2 ] ;
vec4 q = vec4 ( x , y , z , 1.0 ) ;
// Reverse the perspective division to obtain clip coordinates.
q /= screenCoordinate . w ;
// Reverse the projection transformation to obtain eye coordinates.
if ( ! ( czm _inverseProjection == mat4 ( 0.0 ) ) ) // IE and Edge sometimes do something weird with != between mat4s
{
q = czm _inverseProjection * q ;
}
else
{
float top = czm _frustumPlanes . x ;
float bottom = czm _frustumPlanes . y ;
float left = czm _frustumPlanes . z ;
float right = czm _frustumPlanes . w ;
float near = czm _currentFrustum . x ;
float far = czm _currentFrustum . y ;
q . x = ( q . x * ( right - left ) + left + right ) * 0.5 ;
q . y = ( q . y * ( top - bottom ) + bottom + top ) * 0.5 ;
q . z = ( q . z * ( near - far ) - near - far ) * 0.5 ;
q . w = 1.0 ;
}
return q ;
}
/ * *
* Transforms a position from window to eye coordinates .
* The transform from window to normalized device coordinates is done using components
* of ( @ link czm _viewport } and { @ link czm _viewportTransformation } instead of calculating
* the inverse of < code > czm _viewportTransformation < / c o d e > . T h e t r a n s f o r m a t i o n f r o m
* normalized device coordinates to clip coordinates is done using < code > fragmentCoordinate . w < / c o d e > ,
* which is expected to be the scalar used in the perspective divide . The transformation
* from clip to eye coordinates is done using { @ link czm _inverseProjection } .
*
* @ name czm _windowToEyeCoordinates
* @ glslFunction
*
* @ param { vec4 } fragmentCoordinate The position in window coordinates to transform .
*
* @ returns { vec4 } The transformed position in eye coordinates .
*
* @ see czm _modelToWindowCoordinates
* @ see czm _eyeToWindowCoordinates
* @ see czm _inverseProjection
* @ see czm _viewport
* @ see czm _viewportTransformation
*
* @ example
* vec4 positionEC = czm _windowToEyeCoordinates ( gl _FragCoord ) ;
* /
vec4 czm _windowToEyeCoordinates ( vec4 fragmentCoordinate )
{
vec2 screenCoordXY = ( fragmentCoordinate . xy - czm _viewport . xy ) / czm _viewport . zw ;
return czm _screenToEyeCoordinates ( vec4 ( screenCoordXY , fragmentCoordinate . zw ) ) ;
}
vec4 czm _screenToEyeCoordinates ( vec2 screenCoordinateXY , float depthOrLogDepth )
{
// See reverseLogDepth.glsl. This is separate to re-use the pow.
# if defined ( LOG _DEPTH ) || defined ( LOG _DEPTH _READ _ONLY )
float near = czm _currentFrustum . x ;
float far = czm _currentFrustum . y ;
float log2Depth = depthOrLogDepth * czm _log2FarDepthFromNearPlusOne ;
float depthFromNear = pow ( 2.0 , log2Depth ) - 1.0 ;
float depthFromCamera = depthFromNear + near ;
vec4 screenCoord = vec4 ( screenCoordinateXY , far * ( 1.0 - near / depthFromCamera ) / ( far - near ) , 1.0 ) ;
vec4 eyeCoordinate = czm _screenToEyeCoordinates ( screenCoord ) ;
eyeCoordinate . w = 1.0 / depthFromCamera ; // Better precision
return eyeCoordinate ;
# else
vec4 screenCoord = vec4 ( screenCoordinateXY , depthOrLogDepth , 1.0 ) ;
vec4 eyeCoordinate = czm _screenToEyeCoordinates ( screenCoord ) ;
# endif
return eyeCoordinate ;
}
/ * *
* Transforms a position given as window x / y and a depth or a log depth from window to eye coordinates .
* This function produces more accurate results for window positions with log depth than
* conventionally unpacking the log depth using czm _reverseLogDepth and using the standard version
* of czm _windowToEyeCoordinates .
*
* @ name czm _windowToEyeCoordinates
* @ glslFunction
*
* @ param { vec2 } fragmentCoordinateXY The XY position in window coordinates to transform .
* @ param { float } depthOrLogDepth A depth or log depth for the fragment .
*
* @ see czm _modelToWindowCoordinates
* @ see czm _eyeToWindowCoordinates
* @ see czm _inverseProjection
* @ see czm _viewport
* @ see czm _viewportTransformation
*
* @ returns { vec4 } The transformed position in eye coordinates .
* /
vec4 czm _windowToEyeCoordinates ( vec2 fragmentCoordinateXY , float depthOrLogDepth )
{
vec2 screenCoordXY = ( fragmentCoordinateXY . xy - czm _viewport . xy ) / czm _viewport . zw ;
return czm _screenToEyeCoordinates ( screenCoordXY , depthOrLogDepth ) ;
}
` ,lce= ` // emulated noperspective
# if defined ( GL _EXT _frag _depth ) && ! defined ( LOG _DEPTH )
varying float v _WindowZ ;
# endif
/ * *
* Emulates GL _DEPTH _CLAMP . Clamps a fragment to the near and far plane
* by writing the fragment ' s depth . See czm _depthClamp for more details .
* < p >
* The shader must enable the GL _EXT _frag _depth extension .
* < / p >
*
* @ name czm _writeDepthClamp
* @ glslFunction
*
* @ example
* gl _FragColor = color ;
* czm _writeDepthClamp ( ) ;
*
* @ see czm _depthClamp
* /
void czm _writeDepthClamp ( )
{
# if defined ( GL _EXT _frag _depth ) && ! defined ( LOG _DEPTH )
gl _FragDepthEXT = clamp ( v _WindowZ * gl _FragCoord . w , 0.0 , 1.0 ) ;
# endif
}
` ,uce= ` # ifdef LOG _DEPTH
varying float v _depthFromNearPlusOne ;
# ifdef POLYGON _OFFSET
uniform vec2 u _polygonOffset ;
# ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
# endif
# endif
/ * *
* Writes the fragment depth to the logarithmic depth buffer .
* < p >
* Use this when the vertex shader does not call { @ link czm _vertexlogDepth } , for example , when
* ray - casting geometry using a full screen quad .
* < / p >
* @ name czm _writeLogDepth
* @ glslFunction
*
* @ param { float } depth The depth coordinate , where 1.0 is on the near plane and
* depth increases in eye - space units from there
*
* @ example
* czm _writeLogDepth ( ( czm _projection * v _positionEyeCoordinates ) . w + 1.0 ) ;
* /
void czm _writeLogDepth ( float depth )
{
# if defined ( GL _EXT _frag _depth ) && defined ( LOG _DEPTH )
// Discard the vertex if it's not between the near and far planes.
// We allow a bit of epsilon on the near plane comparison because a 1.0
// from the vertex shader (indicating the vertex should be _on_ the near
// plane) will not necessarily come here as exactly 1.0.
if ( depth <= 0.9999999 || depth > czm _farDepthFromNearPlusOne ) {
discard ;
}
# ifdef POLYGON _OFFSET
// Polygon offset: m * factor + r * units
float factor = u _polygonOffset [ 0 ] ;
float units = u _polygonOffset [ 1 ] ;
// If we can't compute derivatives, just leave out the factor I guess?
# ifdef GL _OES _standard _derivatives
if ( factor != 0.0 ) {
// m = sqrt(dZdX^2 + dZdY^2);
float x = dFdx ( depth ) ;
float y = dFdy ( depth ) ;
float m = sqrt ( x * x + y * y ) ;
// Apply the factor before computing the log depth.
depth += m * factor ;
}
# endif
# endif
gl _FragDepthEXT = log2 ( depth ) * czm _oneOverLog2FarDepthFromNearPlusOne ;
# ifdef POLYGON _OFFSET
// Apply the units after the log depth.
gl _FragDepthEXT += czm _epsilon7 * units ;
# endif
# endif
}
/ * *
* Writes the fragment depth to the logarithmic depth buffer .
* < p >
* Use this when the vertex shader calls { @ link czm _vertexlogDepth } .
* < / p >
*
* @ name czm _writeLogDepth
* @ glslFunction
* /
void czm _writeLogDepth ( ) {
# ifdef LOG _DEPTH
czm _writeLogDepth ( v _depthFromNearPlusOne ) ;
# endif
}
` ,fce= ` / * *
* Transforms a value for non - perspective interpolation by multiplying
* it by w , the value used in the perspective divide . This function is
* intended to be called in a vertex shader to compute the value of a
* \ ` varying \` that should not be subject to perspective interpolation.
* For example , screen - space texture coordinates . The fragment shader
* must call { @ link czm _readNonPerspective } to retrieve the final
* non - perspective value .
*
* @ name czm _writeNonPerspective
* @ glslFunction
*
* @ param { float | vec2 | vec3 | vec4 } value The value to be interpolated without accounting for perspective .
* @ param { float } w The perspective divide value . Usually this is the computed \ ` gl_Position.w \` .
* @ returns { float | vec2 | vec3 | vec4 } The transformed value , intended to be stored in a \ ` varying \` and read in the
* fragment shader with { @ link czm _readNonPerspective } .
* /
float czm _writeNonPerspective ( float value , float w ) {
return value * w ;
}
vec2 czm _writeNonPerspective ( vec2 value , float w ) {
return value * w ;
}
vec3 czm _writeNonPerspective ( vec3 value , float w ) {
return value * w ;
}
vec4 czm _writeNonPerspective ( vec4 value , float w ) {
return value * w ;
}
` ,CD={czm_degreesPerRadian:Wre,czm_depthRange:jre,czm_epsilon1:qre,czm_epsilon2:Yre,czm_epsilon3:Xre,czm_epsilon4: $ re,czm_epsilon5:Kre,czm_epsilon6:Jre,czm_epsilon7:Qre,czm_infinity:Zre,czm_oneOverPi:ese,czm_oneOverTwoPi:tse,czm_passCesium3DTile:nse,czm_passCesium3DTileClassification:ise,czm_passCesium3DTileClassificationIgnoreShow:ose,czm_passClassification:rse,czm_passCompute:sse,czm_passEnvironment:ase,czm_passGlobe:cse,czm_passOpaque:lse,czm_passOverlay:use,czm_passTerrainClassification:fse,czm_passTranslucent:dse,czm_passVoxels:hse,czm_pi:pse,czm_piOverFour:mse,czm_piOverSix:_se,czm_piOverThree:gse,czm_piOverTwo:yse,czm_radiansPerDegree:Ase,czm_sceneMode2D:Cse,czm_sceneMode3D:Tse,czm_sceneModeColumbusView:bse,czm_sceneModeMorphing:Ese,czm_solarRadius:xse,czm_threePiOver2:wse,czm_twoPi:Sse,czm_webMercatorMaxLatitude:vse,czm_depthRangeStruct:Dse,czm_material:Ise,czm_materialInput:Pse,czm_modelMaterial:Ose,czm_modelVertexOutput:Lse,czm_pbrParameters:Bse,czm_ray:Rse,czm_raySegment:Nse,czm_shadowParameters:Mse,czm_HSBToRGB:Fse,czm_HSLToRGB:zse,czm_RGBToHSB:Use,czm_RGBToHSL:Hse,czm_RGBToXYZ:Vse,czm_XYZToRGB:kse,czm_acesTonemapping:Gse,czm_alphaWeight:Wse,czm_antialias:jse,czm_approximateSphericalCoordinates:qse,czm_backFacing:Yse,czm_branchFreeTernary:Xse,czm_cascadeColor: $ se,czm_cascadeDistance:Kse,czm_cascadeMatrix:Jse,czm_cascadeWeights:Qse,czm_columbusViewMorph:Zse,czm_computePosition:eae,czm_cosineAndSine:tae,czm_decompressTextureCoordinates:nae,czm_defaultPbrMaterial:iae,czm_depthClamp:oae,czm_eastNorthUpToEyeCoordinates:rae,czm_ellipsoidContainsPoint:sae,czm_ellipsoidWgs84TextureCoordinates:aae,czm_equalsEpsilon:cae,czm_eyeOffset:lae,czm_eyeToWindowCoordinates:uae,czm_fastApproximateAtan:fae,czm_fog:dae,czm_gammaCorrect:hae,czm_geodeticSurfaceNormal:pae,czm_getDefaultMaterial:mae,czm_getLambertDiffuse:_ae,czm_getSpecular:gae,czm_getWaterNoise:yae,czm_hue:Aae,czm_inverseGamma:Cae,czm_isEmpty:Tae,czm_isFull:bae,czm_latitudeToWebMercatorFraction:Eae,czm_lineDistance:xae,czm_linearToSrgb:wae,czm_luminance:Sae,czm_metersPerPixel:vae,czm_modelToWindowCoordinates:Dae,czm_multiplyWithColorBalance:Iae,czm_nearFarScalar:Pae,czm_octDecode:Oae,czm_packDepth:Lae,czm_pbrLighting:Bae,czm_pbrMetallicRoughnessMaterial:Rae,czm_pbrSpecularGlossinessMaterial:Nae,czm_phong:Mae,czm_planeDistance:Fae,czm_pointAlongRay:zae,czm_rayEllipsoidIntersectionInterval:Uae,czm_raySphereIntersectionInterval:Hae,czm_readDepth:Vae,czm_readNonPerspective:kae,czm_reverseLogDepth:Gae,czm_round:Wae,czm_sampleOctahedralProjection:jae,czm_saturation:qae,czm_shadowDepthCompare:Yae,czm_shadowVisibility:Xae,czm_signNotZero: $ ae,czm_sphericalHarmonics:Kae,czm_srgbToLinear:Jae,czm_tangentToEyeSpaceMatrix:Qae,czm_transformPlane:Zae,czm_translateRelativeToEye:ece,czm_translucentPhong:tce,czm_transpose:nce,czm_unpackDepth:ice,czm_unpackFloat:oce,czm_unpackUint:rce,czm_valueTransform:sce,czm_vertexLogDepth:ace,czm_windowToEyeCoordinates:cce,czm_writeDepthClamp:lce,czm_writeLogDepth:uce,czm_writeNonPerspective:fce};function $ 8(e){return e=e.replace(/ \/ \/ .*/g,""),e.replace(/ \/ \* \* [ \s \S ]*? \* \/ /gm,function(t){const n=t.match(/ \n /gm).length;let i="";for(let o=0;o<n;++o)i+= `
` ;return i})}function K8(e,t,n){let i;for(let o=0;o<n.length;++o)n[o].name===e&&(i=n[o]);return l(i)||(t= $ 8(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function J8(e,t){if(e.evaluated)return;e.evaluated=!0;let n=e.glslSource.match(/ \b czm_[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&&Ge._czmBuiltinsAndUniforms.hasOwnProperty(i)){const o=K8(i,Ge._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(o),o.requiredBy.push(e),J8(o,t)}}))}function dce(e){const t=[],n=[];for(;e.length>0;){const o=e.pop();n.push(o),o.requiredBy.length===0&&t.push(o)}for(;t.length>0;){const o=t.shift();e.push(o);for(let r=0;r<o.dependsOn.length;++r){const s=o.dependsOn[r],a=s.requiredBy.indexOf(o);s.requiredBy.splice(a,1),s.requiredBy.length===0&&t.push(s)}}const i=[];for(let o=0;o<n.length;++o)n[o].requiredBy.length!==0&&i.push(n[o]);if(i.length!==0){let o= ` A circular dependency was found in the following built - in functions / structs / constants :
` ;for(let r=0;r<i.length;++r)o= ` $ { o + i [ r ] . name }
` ;throw new E(o)}}function hce(e){const t=[],n=K8("main",e,t);J8(n,t),dce(t);let i="";for(let o=t.length-1;o>=0;--o)i= ` $ { i + t [ o ] . glslSource }
` ;return i.replace(n.glslSource,"")}function Q8(e,t,n){let i,o,r="";const s=e.sources;if(l(s))for(i=0,o=s.length;i<o;++i)r+= `
# line 0
$ { s [ i ] } ` ;r= $ 8(r);let a;r=r.replace(/#version \s +(.*?) \n /gm,function(g,p){if(l(a)&&a!==p)throw new E( ` inconsistent versions found : $ { a } and $ { p } ` );return a=p, `
` });const c=[];r=r.replace(/#extension.* \n /gm,function(g){return c.push(g), `
` }),r=r.replace(/precision \s (lowp|mediump|highp) \s (float|int);/,"");const u=e.pickColorQualifier;l(u)&&(r=Ge.createPickFragmentShaderSource(r,u));let f="";l(a)&&(f= ` # version $ { a }
` );const h=c.length;for(i=0;i<h;i++)f+=c[i];t&&(f+= ` # ifdef GL _FRAGMENT _PRECISION _HIGH
precision highp float ;
precision highp int ;
# else
precision mediump float ;
precision mediump int ;
# define highp mediump
# endif
` );const _=e.defines;if(l(_))for(i=0,o=_.length;i<o;++i){const g=_[i];g.length!==0&&(f+= ` # define $ { g }
` )}return n.webgl2&&(f+= ` # define OUTPUT _DECLARATION
` ),n.textureFloatLinear&&(f+= ` # define OES _texture _float _linear
` ),n.floatingPointTexture&&(f+= ` # define OES _texture _float
` ),e.includeBuiltIns&&(f+=hce(r)),f+= `
# line 0
` ,f+=r,n.webgl2&&(f=Ure(f,t)),f}function Ge(e){e=y(e,y.EMPTY_OBJECT);const t=e.pickColorQualifier;if(l(t)&&t!=="uniform"&&t!=="varying")throw new E("options.pickColorQualifier must be 'uniform' or 'varying'.");this.defines=l(e.defines)?e.defines.slice(0):[],this.sources=l(e.sources)?e.sources.slice(0):[],this.pickColorQualifier=t,this.includeBuiltIns=y(e.includeBuiltIns,!0)}Ge.prototype.clone=function(){return new Ge({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};Ge.replaceMain=function(e,t){return t= ` void $ { t } ( ) ` ,e.replace(/void \s +main \s * \( \s *(?:void)? \s * \) /g,t)};Ge.prototype.getCacheKey=function(){const t=this.defines.slice().sort().join(","),n=this.pickColorQualifier,i=this.includeBuiltIns,o=this.sources.join( `
` );return ` $ { t } : $ { n } : $ { i } : $ { o } ` };Ge.prototype.createCombinedVertexShader=function(e){return Q8(this,!1,e)};Ge.prototype.createCombinedFragmentShader=function(e){return Q8(this,!0,e)};Ge._czmBuiltinsAndUniforms={};for(const e in CD)CD.hasOwnProperty(e)&&(Ge._czmBuiltinsAndUniforms[e]=CD[e]);for(const e in KE)if(KE.hasOwnProperty(e)){const t=KE[e];typeof t.getDeclaration=="function"&&(Ge._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}Ge.createPickVertexShaderSource=function(e){return ` $ { Ge . replaceMain ( e , "czm_old_main" ) }
attribute vec4 pickColor ;
varying vec4 czm _pickColor ;
void main ( )
{
czm _old _main ( ) ;
czm _pickColor = pickColor ;
} ` };Ge.createPickFragmentShaderSource=function(e,t){const n=Ge.replaceMain(e,"czm_old_main"),i= ` $ { t } vec4 czm _pickColor ;
void main ( )
{
czm _old _main ( ) ;
if ( gl _FragColor . a == 0.0 ) {
discard ;
}
gl _FragColor = czm _pickColor ;
} ` ;return ` $ { n }
$ { i } ` };function pce(e,t){const n=e.defines,i=n.length;for(let o=0;o<i;++o)if(n[o]===t)return!0;return!1}function Z8(e,t){const n=e.sources,i=n.length;for(let o=0;o<i;++o)if(n[o].indexOf(t)!==-1)return!0;return!1}function e6(e,t){const n=t.length;for(let i=0;i<n;++i){const o=t[i];if(Z8(e,o))return o}}const mce=["v_normalEC","v_normal"];Ge.findNormalVarying=function(e){return Z8(e,"#ifdef HAS_NORMALS")?pce(e,"HAS_NORMALS")?"v_normalEC":void 0:e6(e,mce)};const _ce=["v_positionEC"];Ge.findPositionVarying=function(e){return e6(e,_ce)};function Gl(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(Gl.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});Gl.prototype.replaceShaderProgram=function(e){return l(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function gce(e){const t=Object.keys(e).sort();return JSON.stringify(e,t)}Gl.prototype.getShaderProgram=function(e){let t=e.vertexShaderSource,n=e.fragmentShaderSource;const i=e.attributeLocations;typeof t=="string"&&(t=new Ge({sources:[t]})),typeof n=="string"&&(n=new Ge({sources:[n]}));const o=t.getCacheKey(),r=n.getCacheKey(),s=l(i)?gce(i):"",a= ` $ { o } : $ { r } : $ { s } ` ;let c;if(l(this._shaders[a]))c=this._shaders[a],delete this._shadersToRelease[a];else{const u=this._context,f=t.createCombinedVertexShader(u),h=n.createCombinedFragmentShader(u),_=new un({gl:u._gl,logShaderCompilation:u.logShaderCompilation,debugShaders:u.debugShaders,vertexShaderSource:t,vertexShaderText:f,fragmentShaderSource:n,fragmentShaderText:h,attributeLocations:i});c={cache:this,shaderProgram:_,keyword:a,derivedKeywords:[],count:0},_._cachedShader=c,this._shaders[a]=c,++this._numberOfShaders}return++c.count,c.shaderProgram};Gl.prototype.replaceDerivedShaderProgram=function(e,t,n){const i=e._cachedShader,o=t+i.keyword,r=this._shaders[o];if(l(r)){UB(this,r);const s=i.derivedKeywords.indexOf(t);s>-1&&i.derivedKeywords.splice(s,1)}return this.createDerivedShaderProgram(e,t,n)};Gl.prototype.getDerivedShaderProgram=function(e,t){const n=e._cachedShader,i=t+n.keyword,o=this._shaders[i];if(l(o))return o.shaderProgram};Gl.prototype.createDerivedShaderProgram=function(e,t,n){const i=e._cachedShader,o=t+i.keyword;let r=n.vertexShaderSource,s=n.fragmentShaderSource;const a=n.attributeLocations;typeof r=="string"&&(r=new Ge({sources:[r]})),typeof s=="string"&&(s=new Ge({sources:[s]}));const c=this._context,u=r.createCombinedVertexShader(c),f=s.createCombinedFragmentShader(c),h=new un({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:r,vertexShaderText:u,fragmentShaderSource:s,fragmentShaderText:f,attributeLocations:a}),_={cache:this,shaderProgram:h,keyword:o,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),h._cachedShader=_,this._shaders[o]=_,h};function UB(e,t){const n=t.derivedKeywords,i=n.length;for(let o=0;o<i;++o){const r=n[o]+t.keyword,s=e._shaders[r];UB(e,s)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}Gl.prototype.destroyReleasedShaderPrograms=function(){const e=this._shadersToRelease;for(const t in e)if(e.hasOwnProperty(t)){const n=e[t];UB(this,n),--this._numberOfShaders}this._shadersToRelease={}};Gl.prototype.releaseShaderProgram=function(e){if(l(e)){const t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};Gl.prototype.isDestroyed=function(){return!1};Gl.prototype.destroy=function(){const e=this._shaders;for(const t in e)e.hasOwnProperty(t)&&e[t].shaderProgram.finalDestroy();return Ue(this)};function Ft(e){e=y(e,y.EMPTY_OBJECT),T.defined("options.context",e.context);const t=e.context;let n=e.width,i=e.height;const o=e.source;l(o)&&(l(n)||(n=y(o.videoWidth,o.width)),l(i)||(i=y(o.videoHeight,o.height)));const r=y(e.pixelFormat,nt.RGBA),s=y(e.pixelDatatype,Ke.UNSIGNED_BYTE),a=nt.toInternalFormat(r,s,t),c=nt.isCompressedFormat(a);if(!l(n)||!l(i))throw new E("options requires a source field to create an initialized texture or width and height fields to create a blank texture.");if(T.typeOf.number.greaterThan("width
` ),r=new Ge({defines:this._vertexShaderParts.defineLines,sources:[o]}),s=this._fragmentShaderParts.uniformLines.concat(this._fragmentShaderParts.varyingLines,n.fragmentLines,i.fragmentLines,this._fragmentShaderParts.shaderLines).join( `
` ),a=new Ge({defines:this._fragmentShaderParts.defineLines,sources:[s]});return un.fromCache({context:e,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:this._attributeLocations})};Ys.prototype.clone=function(){return lt(this,!0)};function _ue(e){const t=[],n=[];let i,o=e._vertexShaderParts.structIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),t.push.apply(t,a);for(o=e._fragmentShaderParts.structIds,i=0;i<o.length;i++)r=o[i],s=e._structs[r],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}function gue(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function yue(e){const t=[],n=[];let i,o=e._vertexShaderParts.functionIds,r,s,a;for(i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),t.push.apply(t,a);for(o=e._fragmentShaderParts.functionIds,i=0;i<o.length;i++)r=o[i],s=e._functions[r],a=s.generateGlslLines(),n.push.apply(n,a);return{vertexLines:t,fragmentLines:n}}function pr(e,t,n,i){if(T.defined("context",e),!t||t.length===0)throw new E("At least one attribute is required.");const o=pr._verifyAttributes(t);n=y(n,0);const r=[],s={};let a,c;const u=o.length;for(let h=0;h<u;++h){const _=o[h];if(_.vertexBuffer){r.push(_);continue}c=_.usage,a=s[c],l(a)||(a=s[c]=[]),a.push(_)}function f(h,_){return ee.getSizeInBytes(_.componentDatatype)-ee.getSizeInBytes(h.componentDatatype)}this._allBuffers=[];for(c in s)if(s.hasOwnProperty(c)){a=s[c],a.sort(f);const h=pr._vertexSizeInBytes(a),_=a[0].usage,g={vertexSizeInBytes:h,vertexBuffer:void 0,usage:_,needsCommit:!1,arrayBuffer:void 0,arrayViews:pr._createArrayViews(a,h)};this._allBuffers.push(g)}this._size=0,this._instanced=y(i,!1),this._precreated=r,this._context=e,this.writers=void 0,this.va=void 0,this.resize(n)}pr._verifyAttributes=function(e){const t=[];for(let i=0;i<e.length;++i){const o=e[i],r={index:y(o.index,i),enabled:y(o.enabled,!0),componentsPerAttribute:o.componentsPerAttribute,componentDatatype:y(o.componentDatatype,ee.FLOAT),normalize:y(o.normalize,!1),vertexBuffer:o.vertexBuffer,usage:y(o.usage,Ze.STATIC_DRAW)};if(t.push(r),r.componentsPerAttribute!==1&&r.componentsPerAttribute!==2&&r.componentsPerAttribute!==3&&r.componentsPerAttribute!==4)throw new E("attribute.componentsPerAttribute must be in the range [1, 4].");const s=r.componentDatatype;if(!ee.validate(s))throw new E("Attribute must have a valid componentDatatype or not specify it.");if(!Ze.validate(r.usage))throw new E("Attribute must have a valid usage or not specify it.")}const n=new Array(t.length);for(let i=0;i<t.length;++i){const r=t[i].index;if(n[r])throw new E( ` Index $ { r } is used by more than one attribute . ` );n[r]=!0}return t};pr._vertexSizeInBytes=function(e){let t=0;const n=e.length;for(let s=0;s<n;++s){const a=e[s];t+=a.componentsPerAttribute*ee.getSizeInBytes(a.componentDatatype)}const i=n>0?ee.getSizeInBytes(e[0].componentDatatype):0,o=i>0?t%i:0,r=o===0?0:i-o;return t+=r,t};pr._createArrayViews=function(e,t){const n=[];let i=0;const o=e.length;for(let r=0;r<o;++r){const s=e[r],a=s.componentDatatype;n.push({index:s.index,enabled:s.enabled,componentsPerAttribute:s.componentsPerAttribute,componentDatatype:a,normalize:s.normalize,offsetInBytes:i,vertexSizeInComponentType:t/ee.getSizeInBytes(a),view:void 0}),i+=s.componentsPerAttribute*ee.getSizeInBytes(a)}return n};pr.prototype.resize=function(e){this._size=e;const t=this._allBuffers;this.writers=[];for(let n=0,i=t.length;n<i;++n){const o=t[n];pr._resize(o,this._size),pr._appendWriters(this.writers,o)}qB(this)};pr._resize=function(e,t){if(e.vertexSizeInBytes>0){const n=new ArrayBuffer(t*e.vertexSizeInBytes);if(l(e.arrayBuffer)){const r=new Uint8Array(n),s=new Uint8Array(e.arrayBuffer),a=s.length;for(let c=0;c<a;++c)r[c]=s[c]}const i=e.arrayViews,o=i.length;for(let r=0;r<o;++r){const s=i[r];s.view=ee.createArrayBufferView(s.componentDatatype,n,s.offsetInBytes)}e.arrayBuffer=n}};const Aue=[function(e,t,n){return function(i,o){t[i*n]=o,e.needsCommit=!0}},function(e,t,n){return function(i,o,r){const s=i*n;t[s]=o,t[s+1]=r,e.nee
# extension GL _EXT _draw _buffers : enable
# endif
uniform vec4 u _bgColor ;
uniform sampler2D u _depthTexture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
if ( texture2D ( u _depthTexture , v _textureCoordinates ) . r < 1.0 )
{
# ifdef MRT
gl _FragData [ 0 ] = u _bgColor ;
gl _FragData [ 1 ] = vec4 ( u _bgColor . a ) ;
# else
gl _FragColor = u _bgColor ;
# endif
return ;
}
discard ;
}
` ,ow= ` uniform vec3 u _radiiAndDynamicAtmosphereColor ;
uniform float u _atmosphereLightIntensity ;
uniform float u _atmosphereRayleighScaleHeight ;
uniform float u _atmosphereMieScaleHeight ;
uniform float u _atmosphereMieAnisotropy ;
uniform vec3 u _atmosphereRayleighCoefficient ;
uniform vec3 u _atmosphereMieCoefficient ;
const float ATMOSPHERE _THICKNESS = 111e3 ; // The thickness of the atmosphere in meters.
const int PRIMARY _STEPS = 16 ; // Number of times the ray from the camera to the world position (primary ray) is sampled.
const int LIGHT _STEPS = 4 ; // Number of times the light is sampled from the light source's intersection with the atmosphere to a sample position on the primary ray.
/ * *
* This function computes the colors contributed by Rayliegh and Mie scattering on a given ray , as well as
* the transmittance value for the ray .
*
* @ param { czm _ray } primaryRay The ray from the camera to the position .
* @ param { float } primaryRayLength The length of the primary ray .
* @ param { vec3 } lightDirection The direction of the light to calculate the scattering from .
* @ param { vec3 } rayleighColor The variable the Rayleigh scattering will be written to .
* @ param { vec3 } mieColor The variable the Mie scattering will be written to .
* @ param { float } opacity The variable the transmittance will be written to .
* @ glslFunction
* /
void computeScattering (
czm _ray primaryRay ,
float primaryRayLength ,
vec3 lightDirection ,
float atmosphereInnerRadius ,
out vec3 rayleighColor ,
out vec3 mieColor ,
out float opacity
) {
// Initialize the default scattering amounts to 0.
rayleighColor = vec3 ( 0.0 ) ;
mieColor = vec3 ( 0.0 ) ;
opacity = 0.0 ;
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE _THICKNESS ;
vec3 origin = vec3 ( 0.0 ) ;
// Calculate intersection from the camera to the outer ring of the atmosphere.
czm _raySegment primaryRayAtmosphereIntersect = czm _raySphereIntersectionInterval ( primaryRay , origin , atmosphereOuterRadius ) ;
// Return empty colors if no intersection with the atmosphere geometry.
if ( primaryRayAtmosphereIntersect == czm _emptyRaySegment ) {
return ;
}
// The ray should start from the first intersection with the outer atmopshere, or from the camera position, if it is inside the atmosphere.
primaryRayAtmosphereIntersect . start = max ( primaryRayAtmosphereIntersect . start , 0.0 ) ;
// The ray should end at the exit from the atmosphere or at the distance to the vertex, whichever is smaller.
primaryRayAtmosphereIntersect . stop = min ( primaryRayAtmosphereIntersect . stop , length ( primaryRayLength ) ) ;
// Setup for sampling positions along the ray - starting from the intersection with the outer ring of the atmosphere.
float rayStepLength = ( primaryRayAtmosphereIntersect . stop - primaryRayAtmosphereIntersect . start ) / float ( PRIMARY _STEPS ) ;
float rayPositionLength = primaryRayAtmosphereIntersect . start ;
vec3 rayleighAccumulation = vec3 ( 0.0 ) ;
vec3 mieAccumulation = vec3 ( 0.0 ) ;
vec2 opticalDepth = vec2 ( 0.0 ) ;
vec2 heightScale = vec2 ( u _atmosphereRayleighScaleHeight , u _atmosphereMieScaleHeight ) ;
// Sample positions on the primary ray.
for ( int i = 0 ; i < PRIMARY _STEPS ; i ++ ) {
// Calculate sample position along viewpoint ray.
vec3 samplePosition = primaryRay . origin + primaryRay . direction * ( rayPositionLength + rayStepLength ) ;
// Calculate height of sample position above ellipsoid.
float sampleHeight = length ( samplePosition ) - atmosphereInnerRadius ;
// Calculate and accumulate density of particles at the sample position.
vec2 sampleDensity = exp ( - sampleHeight / heightScale ) * rayStepLength ;
opticalDepth += sampleDensity ;
// Generate ray from the sample position segment to the light source, up to the outer ring of the atmosphere.
czm _ray lightRay = czm _ray ( samplePosition , lightDirection ) ;
czm _raySegment lightRayAtmosphereIntersect = czm _raySphereIntersectionInterval ( lightRay , origin , atmosphereOuterRadius ) ;
float lightStepLength = lightRayAtmosphereIntersect . stop / float ( LIGHT _STEPS ) ;
float lightPositionLength = 0.0 ;
vec2 lightOpticalDepth = vec2 ( 0.0 ) ;
// Sample positions along the light ray, to accumulate incidence of light on the latest sample segment.
for ( int j = 0 ; j < LIGHT _STEPS ; j ++ ) {
// Calculate sample position along light ray.
vec3 lightPosition = samplePosition + lightDirection * ( lightPositionLength + lightStepLength * 0.5 ) ;
// Calculate height of the light sample position above ellipsoid.
float lightHeight = length ( lightPosition ) - atmosphereInnerRadius ;
// Calculate density of photons at the light sample position.
lightOpticalDepth += exp ( - lightHeight / heightScale ) * lightStepLength ;
// Increment distance on light ray.
lightPositionLength += lightStepLength ;
}
// Compute attenuation via the primary ray and the light ray.
vec3 attenuation = exp ( - ( ( u _atmosphereMieCoefficient * ( opticalDepth . y + lightOpticalDepth . y ) ) + ( u _atmosphereRayleighCoefficient * ( opticalDepth . x + lightOpticalDepth . x ) ) ) ) ;
// Accumulate the scattering.
rayleighAccumulation += sampleDensity . x * attenuation ;
mieAccumulation += sampleDensity . y * attenuation ;
// Increment distance on primary ray.
rayPositionLength += rayStepLength ;
}
// Compute the scattering amount.
rayleighColor = u _atmosphereRayleighCoefficient * rayleighAccumulation ;
mieColor = u _atmosphereMieCoefficient * mieAccumulation ;
// Compute the transmittance i.e. how much light is passing through the atmosphere.
opacity = length ( exp ( - ( ( u _atmosphereMieCoefficient * opticalDepth . y ) + ( u _atmosphereRayleighCoefficient * opticalDepth . x ) ) ) ) ;
}
vec4 computeAtmosphereColor (
vec3 positionWC ,
vec3 lightDirection ,
vec3 rayleighColor ,
vec3 mieColor ,
float opacity
) {
// Setup the primary ray: from the camera position to the vertex position.
vec3 cameraToPositionWC = positionWC - czm _viewerPositionWC ;
vec3 cameraToPositionWCDirection = normalize ( cameraToPositionWC ) ;
float cosAngle = dot ( cameraToPositionWCDirection , lightDirection ) ;
float cosAngleSq = cosAngle * cosAngle ;
float G = u _atmosphereMieAnisotropy ;
float GSq = G * G ;
// The Rayleigh phase function.
float rayleighPhase = 3.0 / ( 50.2654824574 ) * ( 1.0 + cosAngleSq ) ;
// The Mie phase function.
float miePhase = 3.0 / ( 25.1327412287 ) * ( ( 1.0 - GSq ) * ( cosAngleSq + 1.0 ) ) / ( pow ( 1.0 + GSq - 2.0 * cosAngle * G , 1.5 ) * ( 2.0 + GSq ) ) ;
// The final color is generated by combining the effects of the Rayleigh and Mie scattering.
vec3 rayleigh = rayleighPhase * rayleighColor ;
vec3 mie = miePhase * mieColor ;
vec3 color = ( rayleigh + mie ) * u _atmosphereLightIntensity ;
return vec4 ( color , opacity ) ;
}
` ,Eue= ` # ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
uniform sampler2D u _atlas ;
# ifdef VECTOR _TILE
uniform vec4 u _highlightColor ;
# endif
varying vec2 v _textureCoordinates ;
varying vec4 v _pickColor ;
varying vec4 v _color ;
# ifdef SDF
varying vec4 v _outlineColor ;
varying float v _outlineWidth ;
# endif
# ifdef FRAGMENT _DEPTH _CHECK
varying vec4 v _textureCoordinateBounds ; // the min and max x and y values for the texture coordinates
varying vec4 v _originTextureCoordinateAndTranslate ; // texture coordinate at the origin, billboard translate (used for label glyphs)
varying vec4 v _compressed ; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
varying mat2 v _rotationMatrix ;
const float SHIFT _LEFT12 = 4096.0 ;
const float SHIFT _LEFT1 = 2.0 ;
const float SHIFT _RIGHT12 = 1.0 / 4096.0 ;
const float SHIFT _RIGHT1 = 1.0 / 2.0 ;
float getGlobeDepth ( vec2 adjustedST , vec2 depthLookupST , bool applyTranslate , vec2 dimensions , vec2 imageSize )
{
vec2 lookupVector = imageSize * ( depthLookupST - adjustedST ) ;
lookupVector = v _rotationMatrix * lookupVector ;
vec2 labelOffset = ( dimensions - imageSize ) * ( depthLookupST - vec2 ( 0.0 , v _originTextureCoordinateAndTranslate . y ) ) ; // aligns label glyph with bounding rectangle. Will be zero for billboards because dimensions and imageSize will be equal
vec2 translation = v _originTextureCoordinateAndTranslate . zw ;
if ( applyTranslate )
{
// this is only needed for labels where the horizontal origin is not LEFT
// it moves the label back to where the "origin" should be since all label glyphs are set to HorizontalOrigin.LEFT
translation += ( dimensions * v _originTextureCoordinateAndTranslate . xy * vec2 ( 1.0 , 0.0 ) ) ;
}
vec2 st = ( ( lookupVector - translation + labelOffset ) + gl _FragCoord . xy ) / czm _viewport . zw ;
float logDepthOrDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , st ) ) ;
if ( logDepthOrDepth == 0.0 )
{
return 0.0 ; // not on the globe
}
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , logDepthOrDepth ) ;
return eyeCoordinate . z / eyeCoordinate . w ;
}
# endif
# ifdef SDF
// Get the distance from the edge of a glyph at a given position sampling an SDF texture.
float getDistance ( vec2 position )
{
return texture2D ( u _atlas , position ) . r ;
}
// Samples the sdf texture at the given position and produces a color based on the fill color and the outline.
vec4 getSDFColor ( vec2 position , float outlineWidth , vec4 outlineColor , float smoothing )
{
float distance = getDistance ( position ) ;
if ( outlineWidth > 0.0 )
{
// Don't get the outline edge exceed the SDF_EDGE
float outlineEdge = clamp ( SDF _EDGE - outlineWidth , 0.0 , SDF _EDGE ) ;
float outlineFactor = smoothstep ( SDF _EDGE - smoothing , SDF _EDGE + smoothing , distance ) ;
vec4 sdfColor = mix ( outlineColor , v _color , outlineFactor ) ;
float alpha = smoothstep ( outlineEdge - smoothing , outlineEdge + smoothing , distance ) ;
return vec4 ( sdfColor . rgb , sdfColor . a * alpha ) ;
}
else
{
float alpha = smoothstep ( SDF _EDGE - smoothing , SDF _EDGE + smoothing , distance ) ;
return vec4 ( v _color . rgb , v _color . a * alpha ) ;
}
}
# endif
void main ( )
{
vec4 color = texture2D ( u _atlas , v _textureCoordinates ) ;
# ifdef SDF
float outlineWidth = v _outlineWidth ;
vec4 outlineColor = v _outlineColor ;
// Get the current distance
float distance = getDistance ( v _textureCoordinates ) ;
# ifdef GL _OES _standard _derivatives
float smoothing = fwidth ( distance ) ;
// Get an offset that is approximately half the distance to the neighbor pixels
// 0.354 is approximately half of 1/sqrt(2)
vec2 sampleOffset = 0.354 * vec2 ( dFdx ( v _textureCoordinates ) + dFdy ( v _textureCoordinates ) ) ;
// Sample the center point
vec4 center = getSDFColor ( v _textureCoordinates , outlineWidth , outlineColor , smoothing ) ;
// Sample the 4 neighbors
vec4 color1 = getSDFColor ( v _textureCoordinates + vec2 ( sampleOffset . x , sampleOffset . y ) , outlineWidth , outlineColor , smoothing ) ;
vec4 color2 = getSDFColor ( v _textureCoordinates + vec2 ( - sampleOffset . x , sampleOffset . y ) , outlineWidth , outlineColor , smoothing ) ;
vec4 color3 = getSDFColor ( v _textureCoordinates + vec2 ( - sampleOffset . x , - sampleOffset . y ) , outlineWidth , outlineColor , smoothing ) ;
vec4 color4 = getSDFColor ( v _textureCoordinates + vec2 ( sampleOffset . x , - sampleOffset . y ) , outlineWidth , outlineColor , smoothing ) ;
// Equally weight the center sample and the 4 neighboring samples
color = ( center + color1 + color2 + color3 + color4 ) / 5.0 ;
# else
// Just do a single sample
float smoothing = 1.0 / 32.0 ;
color = getSDFColor ( v _textureCoordinates , outlineWidth , outlineColor , smoothing ) ;
# endif
color = czm _gammaCorrect ( color ) ;
# else
color = czm _gammaCorrect ( color ) ;
color *= czm _gammaCorrect ( v _color ) ;
# endif
// Fully transparent parts of the billboard are not pickable.
# if ! defined ( OPAQUE ) && ! defined ( TRANSLUCENT )
if ( color . a < 0.005 ) // matches 0/255 and 1/255
{
discard ;
}
# else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
# ifdef OPAQUE
if ( color . a < 0.995 ) // matches < 254/255
{
discard ;
}
# else
if ( color . a >= 0.995 ) // matches 254/255 and 255/255
{
discard ;
}
# endif
# endif
# ifdef VECTOR _TILE
color *= u _highlightColor ;
# endif
gl _FragColor = color ;
# ifdef LOG _DEPTH
czm _writeLogDepth ( ) ;
# endif
# ifdef FRAGMENT _DEPTH _CHECK
float temp = v _compressed . y ;
temp = temp * SHIFT _RIGHT1 ;
float temp2 = ( temp - floor ( temp ) ) * SHIFT _LEFT1 ;
bool enableDepthTest = temp2 != 0.0 ;
bool applyTranslate = floor ( temp ) != 0.0 ;
if ( enableDepthTest ) {
temp = v _compressed . z ;
temp = temp * SHIFT _RIGHT12 ;
vec2 dimensions ;
dimensions . y = ( temp - floor ( temp ) ) * SHIFT _LEFT12 ;
dimensions . x = floor ( temp ) ;
temp = v _compressed . w ;
temp = temp * SHIFT _RIGHT12 ;
vec2 imageSize ;
imageSize . y = ( temp - floor ( temp ) ) * SHIFT _LEFT12 ;
imageSize . x = floor ( temp ) ;
vec2 adjustedST = v _textureCoordinates - v _textureCoordinateBounds . xy ;
adjustedST = adjustedST / vec2 ( v _textureCoordinateBounds . z - v _textureCoordinateBounds . x , v _textureCoordinateBounds . w - v _textureCoordinateBounds . y ) ;
float epsilonEyeDepth = v _compressed . x + czm _epsilon1 ;
float globeDepth1 = getGlobeDepth ( adjustedST , v _originTextureCoordinateAndTranslate . xy , applyTranslate , dimensions , imageSize ) ;
// negative values go into the screen
if ( globeDepth1 != 0.0 && globeDepth1 > epsilonEyeDepth )
{
float globeDepth2 = getGlobeDepth ( adjustedST , vec2 ( 0.0 , 1.0 ) , applyTranslate , dimensions , imageSize ) ; // top left corner
if ( globeDepth2 != 0.0 && globeDepth2 > epsilonEyeDepth )
{
float globeDepth3 = getGlobeDepth ( adjustedST , vec2 ( 1.0 , 1.0 ) , applyTranslate , dimensions , imageSize ) ; // top right corner
if ( globeDepth3 != 0.0 && globeDepth3 > epsilonEyeDepth )
{
discard ;
}
}
}
}
# endif
}
` ,xue= ` # ifdef INSTANCED
attribute vec2 direction ;
# endif
attribute vec4 positionHighAndScale ;
attribute vec4 positionLowAndRotation ;
attribute vec4 compressedAttribute0 ; // pixel offset, translate, horizontal origin, vertical origin, show, direction, texture coordinates (texture offset)
attribute vec4 compressedAttribute1 ; // aligned axis, translucency by distance, image width
attribute vec4 compressedAttribute2 ; // label horizontal origin, image height, color, pick color, size in meters, valid aligned axis, 13 bits free
attribute vec4 eyeOffset ; // eye offset in meters, 4 bytes free (texture range)
attribute vec4 scaleByDistance ; // near, nearScale, far, farScale
attribute vec4 pixelOffsetScaleByDistance ; // near, nearScale, far, farScale
attribute vec4 compressedAttribute3 ; // distance display condition near, far, disableDepthTestDistance, dimensions
attribute vec2 sdf ; // sdf outline color (rgb) and width (w)
# if defined ( VERTEX _DEPTH _CHECK ) || defined ( FRAGMENT _DEPTH _CHECK )
attribute vec4 textureCoordinateBoundsOrLabelTranslate ; // the min and max x and y values for the texture coordinates
# endif
# ifdef VECTOR _TILE
attribute float a _batchId ;
# endif
varying vec2 v _textureCoordinates ;
# ifdef FRAGMENT _DEPTH _CHECK
varying vec4 v _textureCoordinateBounds ;
varying vec4 v _originTextureCoordinateAndTranslate ;
varying vec4 v _compressed ; // x: eyeDepth, y: applyTranslate & enableDepthCheck, z: dimensions, w: imageSize
varying mat2 v _rotationMatrix ;
# endif
varying vec4 v _pickColor ;
varying vec4 v _color ;
# ifdef SDF
varying vec4 v _outlineColor ;
varying float v _outlineWidth ;
# endif
const float UPPER _BOUND = 32768.0 ;
const float SHIFT _LEFT16 = 65536.0 ;
const float SHIFT _LEFT12 = 4096.0 ;
const float SHIFT _LEFT8 = 256.0 ;
const float SHIFT _LEFT7 = 128.0 ;
const float SHIFT _LEFT5 = 32.0 ;
const float SHIFT _LEFT3 = 8.0 ;
const float SHIFT _LEFT2 = 4.0 ;
const float SHIFT _LEFT1 = 2.0 ;
const float SHIFT _RIGHT12 = 1.0 / 4096.0 ;
const float SHIFT _RIGHT8 = 1.0 / 256.0 ;
const float SHIFT _RIGHT7 = 1.0 / 128.0 ;
const float SHIFT _RIGHT5 = 1.0 / 32.0 ;
const float SHIFT _RIGHT3 = 1.0 / 8.0 ;
const float SHIFT _RIGHT2 = 1.0 / 4.0 ;
const float SHIFT _RIGHT1 = 1.0 / 2.0 ;
vec4 addScreenSpaceOffset ( vec4 positionEC , vec2 imageSize , float scale , vec2 direction , vec2 origin , vec2 translate , vec2 pixelOffset , vec3 alignedAxis , bool validAlignedAxis , float rotation , bool sizeInMeters , out mat2 rotationMatrix , out float mpp )
{
// Note the halfSize cannot be computed in JavaScript because it is sent via
// compressed vertex attributes that coerce it to an integer.
vec2 halfSize = imageSize * scale * 0.5 ;
halfSize *= ( ( direction * 2.0 ) - 1.0 ) ;
vec2 originTranslate = origin * abs ( halfSize ) ;
# if defined ( ROTATION ) || defined ( ALIGNED _AXIS )
if ( validAlignedAxis || rotation != 0.0 )
{
float angle = rotation ;
if ( validAlignedAxis )
{
vec4 projectedAlignedAxis = czm _modelView3D * vec4 ( alignedAxis , 0.0 ) ;
angle += sign ( - projectedAlignedAxis . x ) * acos ( sign ( projectedAlignedAxis . y ) * ( projectedAlignedAxis . y * projectedAlignedAxis . y ) /
( projectedAlignedAxis . x * projectedAlignedAxis . x + projectedAlignedAxis . y * projectedAlignedAxis . y ) ) ;
}
float cosTheta = cos ( angle ) ;
float sinTheta = sin ( angle ) ;
rotationMatrix = mat2 ( cosTheta , sinTheta , - sinTheta , cosTheta ) ;
halfSize = rotationMatrix * halfSize ;
}
else
{
rotationMatrix = mat2 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
}
# endif
mpp = czm _metersPerPixel ( positionEC ) ;
positionEC . xy += ( originTranslate + halfSize ) * czm _branchFreeTernary ( sizeInMeters , 1.0 , mpp ) ;
positionEC . xy += ( translate + pixelOffset ) * mpp ;
return positionEC ;
}
# ifdef VERTEX _DEPTH _CHECK
float getGlobeDepth ( vec4 positionEC )
{
vec4 posWC = czm _eyeToWindowCoordinates ( positionEC ) ;
float globeDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , posWC . xy / czm _viewport . zw ) ) ;
if ( globeDepth == 0.0 )
{
return 0.0 ; // not on the globe
}
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( posWC . xy , globeDepth ) ;
return eyeCoordinate . z / eyeCoordinate . w ;
}
# endif
void main ( )
{
// Modifying this shader may also require modifications to Billboard._computeScreenSpacePosition
// unpack attributes
vec3 positionHigh = positionHighAndScale . xyz ;
vec3 positionLow = positionLowAndRotation . xyz ;
float scale = positionHighAndScale . w ;
# if defined ( ROTATION ) || defined ( ALIGNED _AXIS )
float rotation = positionLowAndRotation . w ;
# else
float rotation = 0.0 ;
# endif
float compressed = compressedAttribute0 . x ;
vec2 pixelOffset ;
pixelOffset . x = floor ( compressed * SHIFT _RIGHT7 ) ;
compressed -= pixelOffset . x * SHIFT _LEFT7 ;
pixelOffset . x -= UPPER _BOUND ;
vec2 origin ;
origin . x = floor ( compressed * SHIFT _RIGHT5 ) ;
compressed -= origin . x * SHIFT _LEFT5 ;
origin . y = floor ( compressed * SHIFT _RIGHT3 ) ;
compressed -= origin . y * SHIFT _LEFT3 ;
# ifdef FRAGMENT _DEPTH _CHECK
vec2 depthOrigin = origin . xy ;
# endif
origin -= vec2 ( 1.0 ) ;
float show = floor ( compressed * SHIFT _RIGHT2 ) ;
compressed -= show * SHIFT _LEFT2 ;
# ifdef INSTANCED
vec2 textureCoordinatesBottomLeft = czm _decompressTextureCoordinates ( compressedAttribute0 . w ) ;
vec2 textureCoordinatesRange = czm _decompressTextureCoordinates ( eyeOffset . w ) ;
vec2 textureCoordinates = textureCoordinatesBottomLeft + direction * textureCoordinatesRange ;
# else
vec2 direction ;
direction . x = floor ( compressed * SHIFT _RIGHT1 ) ;
direction . y = compressed - direction . x * SHIFT _LEFT1 ;
vec2 textureCoordinates = czm _decompressTextureCoordinates ( compressedAttribute0 . w ) ;
# endif
float temp = compressedAttribute0 . y * SHIFT _RIGHT8 ;
pixelOffset . y = - ( floor ( temp ) - UPPER _BOUND ) ;
vec2 translate ;
translate . y = ( temp - floor ( temp ) ) * SHIFT _LEFT16 ;
temp = compressedAttribute0 . z * SHIFT _RIGHT8 ;
translate . x = floor ( temp ) - UPPER _BOUND ;
translate . y += ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
translate . y -= UPPER _BOUND ;
temp = compressedAttribute1 . x * SHIFT _RIGHT8 ;
float temp2 = floor ( compressedAttribute2 . w * SHIFT _RIGHT2 ) ;
vec2 imageSize = vec2 ( floor ( temp ) , temp2 ) ;
# ifdef FRAGMENT _DEPTH _CHECK
float labelHorizontalOrigin = floor ( compressedAttribute2 . w - ( temp2 * SHIFT _LEFT2 ) ) ;
float applyTranslate = 0.0 ;
if ( labelHorizontalOrigin != 0.0 ) // is a billboard, so set apply translate to false
{
applyTranslate = 1.0 ;
labelHorizontalOrigin -= 2.0 ;
depthOrigin . x = labelHorizontalOrigin + 1.0 ;
}
depthOrigin = vec2 ( 1.0 ) - ( depthOrigin * 0.5 ) ;
# endif
# ifdef EYE _DISTANCE _TRANSLUCENCY
vec4 translucencyByDistance ;
translucencyByDistance . x = compressedAttribute1 . z ;
translucencyByDistance . z = compressedAttribute1 . w ;
translucencyByDistance . y = ( ( temp - floor ( temp ) ) * SHIFT _LEFT8 ) / 255.0 ;
temp = compressedAttribute1 . y * SHIFT _RIGHT8 ;
translucencyByDistance . w = ( ( temp - floor ( temp ) ) * SHIFT _LEFT8 ) / 255.0 ;
# endif
# if defined ( VERTEX _DEPTH _CHECK ) || defined ( FRAGMENT _DEPTH _CHECK )
temp = compressedAttribute3 . w ;
temp = temp * SHIFT _RIGHT12 ;
vec2 dimensions ;
dimensions . y = ( temp - floor ( temp ) ) * SHIFT _LEFT12 ;
dimensions . x = floor ( temp ) ;
# endif
# ifdef ALIGNED _AXIS
vec3 alignedAxis = czm _octDecode ( floor ( compressedAttribute1 . y * SHIFT _RIGHT8 ) ) ;
temp = compressedAttribute2 . z * SHIFT _RIGHT5 ;
bool validAlignedAxis = ( temp - floor ( temp ) ) * SHIFT _LEFT1 > 0.0 ;
# else
vec3 alignedAxis = vec3 ( 0.0 ) ;
bool validAlignedAxis = false ;
# endif
vec4 pickColor ;
vec4 color ;
temp = compressedAttribute2 . y ;
temp = temp * SHIFT _RIGHT8 ;
pickColor . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
pickColor . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
pickColor . r = floor ( temp ) ;
temp = compressedAttribute2 . x ;
temp = temp * SHIFT _RIGHT8 ;
color . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
color . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
color . r = floor ( temp ) ;
temp = compressedAttribute2 . z * SHIFT _RIGHT8 ;
bool sizeInMeters = floor ( ( temp - floor ( temp ) ) * SHIFT _LEFT7 ) > 0.0 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
pickColor . a = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
pickColor /= 255.0 ;
color . a = floor ( temp ) ;
color /= 255.0 ;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm _translateRelativeToEye ( positionHigh , positionLow ) ;
vec4 positionEC = czm _modelViewRelativeToEye * p ;
# if defined ( FRAGMENT _DEPTH _CHECK ) || defined ( VERTEX _DEPTH _CHECK )
float eyeDepth = positionEC . z ;
# endif
positionEC = czm _eyeOffset ( positionEC , eyeOffset . xyz ) ;
positionEC . xyz *= show ;
///////////////////////////////////////////////////////////////////////////
# if defined ( EYE _DISTANCE _SCALING ) || defined ( EYE _DISTANCE _TRANSLUCENCY ) || defined ( EYE _DISTANCE _PIXEL _OFFSET ) || defined ( DISTANCE _DISPLAY _CONDITION ) || defined ( DISABLE _DEPTH _DISTANCE )
float lengthSq ;
if ( czm _sceneMode == czm _sceneMode2D )
{
// 2D camera distance is a special case
// treat all billboards as flattened to the z=0.0 plane
lengthSq = czm _eyeHeight2D . y ;
}
else
{
lengthSq = dot ( positionEC . xyz , positionEC . xyz ) ;
}
# endif
# ifdef EYE _DISTANCE _SCALING
float distanceScale = czm _nearFarScalar ( scaleByDistance , lengthSq ) ;
scale *= distanceScale ;
translate *= distanceScale ;
// push vertex behind near plane for clipping
if ( scale == 0.0 )
{
positionEC . xyz = vec3 ( 0.0 ) ;
}
# endif
float translucency = 1.0 ;
# ifdef EYE _DISTANCE _TRANSLUCENCY
translucency = czm _nearFarScalar ( translucencyByDistance , lengthSq ) ;
// push vertex behind near plane for clipping
if ( translucency == 0.0 )
{
positionEC . xyz = vec3 ( 0.0 ) ;
}
# endif
# ifdef EYE _DISTANCE _PIXEL _OFFSET
float pixelOffsetScale = czm _nearFarScalar ( pixelOffsetScaleByDistance , lengthSq ) ;
pixelOffset *= pixelOffsetScale ;
# endif
# ifdef DISTANCE _DISPLAY _CONDITION
float nearSq = compressedAttribute3 . x ;
float farSq = compressedAttribute3 . y ;
if ( lengthSq < nearSq || lengthSq > farSq )
{
positionEC . xyz = vec3 ( 0.0 ) ;
}
# endif
mat2 rotationMatrix ;
float mpp ;
# ifdef DISABLE _DEPTH _DISTANCE
float disableDepthTestDistance = compressedAttribute3 . z ;
# endif
# ifdef VERTEX _DEPTH _CHECK
if ( lengthSq < disableDepthTestDistance ) {
float depthsilon = 10.0 ;
vec2 labelTranslate = textureCoordinateBoundsOrLabelTranslate . xy ;
vec4 pEC1 = addScreenSpaceOffset ( positionEC , dimensions , scale , vec2 ( 0.0 ) , origin , labelTranslate , pixelOffset , alignedAxis , validAlignedAxis , rotation , sizeInMeters , rotationMatrix , mpp ) ;
float globeDepth1 = getGlobeDepth ( pEC1 ) ;
if ( globeDepth1 != 0.0 && pEC1 . z + depthsilon < globeDepth1 )
{
vec4 pEC2 = addScreenSpaceOffset ( positionEC , dimensions , scale , vec2 ( 0.0 , 1.0 ) , origin , labelTranslate , pixelOffset , alignedAxis , validAlignedAxis , rotation , sizeInMeters , rotationMatrix , mpp ) ;
float globeDepth2 = getGlobeDepth ( pEC2 ) ;
if ( globeDepth2 != 0.0 && pEC2 . z + depthsilon < globeDepth2 )
{
vec4 pEC3 = addScreenSpaceOffset ( positionEC , dimensions , scale , vec2 ( 1.0 ) , origin , labelTranslate , pixelOffset , alignedAxis , validAlignedAxis , rotation , sizeInMeters , rotationMatrix , mpp ) ;
float globeDepth3 = getGlobeDepth ( pEC3 ) ;
if ( globeDepth3 != 0.0 && pEC3 . z + depthsilon < globeDepth3 )
{
positionEC . xyz = vec3 ( 0.0 ) ;
}
}
}
}
# endif
positionEC = addScreenSpaceOffset ( positionEC , imageSize , scale , direction , origin , translate , pixelOffset , alignedAxis , validAlignedAxis , rotation , sizeInMeters , rotationMatrix , mpp ) ;
gl _Position = czm _projection * positionEC ;
v _textureCoordinates = textureCoordinates ;
# ifdef LOG _DEPTH
czm _vertexLogDepth ( ) ;
# endif
# ifdef DISABLE _DEPTH _DISTANCE
if ( disableDepthTestDistance == 0.0 && czm _minimumDisableDepthTestDistance != 0.0 )
{
disableDepthTestDistance = czm _minimumDisableDepthTestDistance ;
}
if ( disableDepthTestDistance != 0.0 )
{
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl _Position . z / gl _Position . w ;
bool clipped = ( zclip < - 1.0 || zclip > 1.0 ) ;
if ( ! clipped && ( disableDepthTestDistance < 0.0 || ( lengthSq > 0.0 && lengthSq < disableDepthTestDistance ) ) )
{
// Position z on the near plane.
gl _Position . z = - gl _Position . w ;
# ifdef LOG _DEPTH
v _depthFromNearPlusOne = 1.0 ;
# endif
}
}
# endif
# ifdef FRAGMENT _DEPTH _CHECK
if ( sizeInMeters ) {
translate /= mpp ;
dimensions /= mpp ;
imageSize /= mpp ;
}
# if defined ( ROTATION ) || defined ( ALIGNED _AXIS )
v _rotationMatrix = rotationMatrix ;
# else
v _rotationMatrix = mat2 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
# endif
float enableDepthCheck = 0.0 ;
if ( lengthSq < disableDepthTestDistance )
{
enableDepthCheck = 1.0 ;
}
float dw = floor ( clamp ( dimensions . x , 0.0 , SHIFT _LEFT12 ) ) ;
float dh = floor ( clamp ( dimensions . y , 0.0 , SHIFT _LEFT12 ) ) ;
float iw = floor ( clamp ( imageSize . x , 0.0 , SHIFT _LEFT12 ) ) ;
float ih = floor ( clamp ( imageSize . y , 0.0 , SHIFT _LEFT12 ) ) ;
v _compressed . x = eyeDepth ;
v _compressed . y = applyTranslate * SHIFT _LEFT1 + enableDepthCheck ;
v _compressed . z = dw * SHIFT _LEFT12 + dh ;
v _compressed . w = iw * SHIFT _LEFT12 + ih ;
v _originTextureCoordinateAndTranslate . xy = depthOrigin ;
v _originTextureCoordinateAndTranslate . zw = translate ;
v _textureCoordinateBounds = textureCoordinateBoundsOrLabelTranslate ;
# endif
# ifdef SDF
vec4 outlineColor ;
float outlineWidth ;
temp = sdf . x ;
temp = temp * SHIFT _RIGHT8 ;
outlineColor . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
outlineColor . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
outlineColor . r = floor ( temp ) ;
temp = sdf . y ;
temp = temp * SHIFT _RIGHT8 ;
float temp3 = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
outlineWidth = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
outlineColor . a = floor ( temp ) ;
outlineColor /= 255.0 ;
v _outlineWidth = outlineWidth / 255.0 ;
v _outlineColor = outlineColor ;
v _outlineColor . a *= translucency ;
# endif
v _pickColor = pickColor ;
v _color = color ;
v _color . a *= translucency ;
}
` ,wue= ` varying vec2 v _textureCoordinates ;
const float M _PI = 3.141592653589793 ;
float vdcRadicalInverse ( int i )
{
float r ;
float base = 2.0 ;
float value = 0.0 ;
float invBase = 1.0 / base ;
float invBi = invBase ;
for ( int x = 0 ; x < 100 ; x ++ )
{
if ( i <= 0 )
{
break ;
}
r = mod ( float ( i ) , base ) ;
value += r * invBi ;
invBi *= invBase ;
i = int ( float ( i ) * invBase ) ;
}
return value ;
}
vec2 hammersley2D ( int i , int N )
{
return vec2 ( float ( i ) / float ( N ) , vdcRadicalInverse ( i ) ) ;
}
vec3 importanceSampleGGX ( vec2 xi , float roughness , vec3 N )
{
float a = roughness * roughness ;
float phi = 2.0 * M _PI * xi . x ;
float cosTheta = sqrt ( ( 1.0 - xi . y ) / ( 1.0 + ( a * a - 1.0 ) * xi . y ) ) ;
float sinTheta = sqrt ( 1.0 - cosTheta * cosTheta ) ;
vec3 H = vec3 ( sinTheta * cos ( phi ) , sinTheta * sin ( phi ) , cosTheta ) ;
vec3 upVector = abs ( N . z ) < 0.999 ? vec3 ( 0.0 , 0.0 , 1.0 ) : vec3 ( 1.0 , 0.0 , 0.0 ) ;
vec3 tangentX = normalize ( cross ( upVector , N ) ) ;
vec3 tangentY = cross ( N , tangentX ) ;
return tangentX * H . x + tangentY * H . y + N * H . z ;
}
float G1 _Smith ( float NdotV , float k )
{
return NdotV / ( NdotV * ( 1.0 - k ) + k ) ;
}
float G _Smith ( float roughness , float NdotV , float NdotL )
{
float k = roughness * roughness / 2.0 ;
return G1 _Smith ( NdotV , k ) * G1 _Smith ( NdotL , k ) ;
}
vec2 integrateBrdf ( float roughness , float NdotV )
{
vec3 V = vec3 ( sqrt ( 1.0 - NdotV * NdotV ) , 0.0 , NdotV ) ;
float A = 0.0 ;
float B = 0.0 ;
const int NumSamples = 1024 ;
for ( int i = 0 ; i < NumSamples ; i ++ )
{
vec2 xi = hammersley2D ( i , NumSamples ) ;
vec3 H = importanceSampleGGX ( xi , roughness , vec3 ( 0.0 , 0.0 , 1.0 ) ) ;
vec3 L = 2.0 * dot ( V , H ) * H - V ;
float NdotL = clamp ( L . z , 0.0 , 1.0 ) ;
float NdotH = clamp ( H . z , 0.0 , 1.0 ) ;
float VdotH = clamp ( dot ( V , H ) , 0.0 , 1.0 ) ;
if ( NdotL > 0.0 )
{
float G = G _Smith ( roughness , NdotV , NdotL ) ;
float G _Vis = G * VdotH / ( NdotH * NdotV ) ;
float Fc = pow ( 1.0 - VdotH , 5.0 ) ;
A += ( 1.0 - Fc ) * G _Vis ;
B += Fc * G _Vis ;
}
}
return vec2 ( A , B ) / float ( NumSamples ) ;
}
void main ( )
{
gl _FragColor = vec4 ( integrateBrdf ( v _textureCoordinates . y , v _textureCoordinates . x ) , 0.0 , 1.0 ) ;
}
` ,Sue= ` uniform sampler2D u _opaqueDepthTexture ;
uniform sampler2D u _translucentDepthTexture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
float opaqueDepth = texture2D ( u _opaqueDepthTexture , v _textureCoordinates ) . r ;
float translucentDepth = texture2D ( u _translucentDepthTexture , v _textureCoordinates ) . r ;
translucentDepth = czm _branchFreeTernary ( translucentDepth > opaqueDepth , 1.0 , translucentDepth ) ;
gl _FragColor = czm _packDepth ( translucentDepth ) ;
}
` ,vue= ` / * *
* Compositing for Weighted Blended Order - Independent Transparency . See :
* - http : //jcgt.org/published/0002/02/09/
* - http : //casual-effects.blogspot.com/2014/03/weighted-blended-order-independent.html
* /
uniform sampler2D u _opaque ;
uniform sampler2D u _accumulation ;
uniform sampler2D u _revealage ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 opaque = texture2D ( u _opaque , v _textureCoordinates ) ;
vec4 accum = texture2D ( u _accumulation , v _textureCoordinates ) ;
float r = texture2D ( u _revealage , v _textureCoordinates ) . r ;
# ifdef MRT
vec4 transparent = vec4 ( accum . rgb / clamp ( r , 1e-4 , 5e4 ) , accum . a ) ;
# else
vec4 transparent = vec4 ( accum . rgb / clamp ( accum . a , 1e-4 , 5e4 ) , r ) ;
# endif
gl _FragColor = ( 1.0 - transparent . a ) * transparent + transparent . a * opaque ;
if ( opaque != czm _backgroundColor )
{
gl _FragColor . a = 1.0 ;
}
}
` ,Due= ` varying vec4 positionEC ;
void main ( )
{
vec3 position ;
vec3 direction ;
if ( czm _orthographicIn3D == 1.0 )
{
vec2 uv = ( gl _FragCoord . xy - czm _viewport . xy ) / czm _viewport . zw ;
vec2 minPlane = vec2 ( czm _frustumPlanes . z , czm _frustumPlanes . y ) ; // left, bottom
vec2 maxPlane = vec2 ( czm _frustumPlanes . w , czm _frustumPlanes . x ) ; // right, top
position = vec3 ( mix ( minPlane , maxPlane , uv ) , 0.0 ) ;
direction = vec3 ( 0.0 , 0.0 , - 1.0 ) ;
}
else
{
position = vec3 ( 0.0 ) ;
direction = normalize ( positionEC . xyz ) ;
}
czm _ray ray = czm _ray ( position , direction ) ;
vec3 ellipsoid _center = czm _view [ 3 ] . xyz ;
czm _raySegment intersection = czm _rayEllipsoidIntersectionInterval ( ray , ellipsoid _center , czm _ellipsoidInverseRadii ) ;
if ( ! czm _isEmpty ( intersection ) )
{
gl _FragColor = vec4 ( 1.0 , 1.0 , 0.0 , 1.0 ) ;
}
else
{
discard ;
}
czm _writeLogDepth ( ) ;
}
` ,Iue= ` attribute vec4 position ;
varying vec4 positionEC ;
void main ( )
{
positionEC = czm _modelView * position ;
gl _Position = czm _projection * positionEC ;
czm _vertexLogDepth ( ) ;
}
` ,x2= ` # ifdef WRITE _DEPTH
# ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
# endif
uniform vec3 u _radii ;
uniform vec3 u _oneOverEllipsoidRadiiSquared ;
varying vec3 v _positionEC ;
vec4 computeEllipsoidColor ( czm _ray ray , float intersection , float side )
{
vec3 positionEC = czm _pointAlongRay ( ray , intersection ) ;
vec3 positionMC = ( czm _inverseModelView * vec4 ( positionEC , 1.0 ) ) . xyz ;
vec3 geodeticNormal = normalize ( czm _geodeticSurfaceNormal ( positionMC , vec3 ( 0.0 ) , u _oneOverEllipsoidRadiiSquared ) ) ;
vec3 sphericalNormal = normalize ( positionMC / u _radii ) ;
vec3 normalMC = geodeticNormal * side ; // normalized surface normal (always facing the viewer) in model coordinates
vec3 normalEC = normalize ( czm _normal * normalMC ) ; // normalized surface normal in eye coordiantes
vec2 st = czm _ellipsoidWgs84TextureCoordinates ( sphericalNormal ) ;
vec3 positionToEyeEC = - positionEC ;
czm _materialInput materialInput ;
materialInput . s = st . s ;
materialInput . st = st ;
materialInput . str = ( positionMC + u _radii ) / u _radii ;
materialInput . normalEC = normalEC ;
materialInput . tangentToEyeMatrix = czm _eastNorthUpToEyeCoordinates ( positionMC , normalEC ) ;
materialInput . positionToEyeEC = positionToEyeEC ;
czm _material material = czm _getMaterial ( materialInput ) ;
# ifdef ONLY _SUN _LIGHTING
return czm _private _phong ( normalize ( positionToEyeEC ) , material , czm _sunDirectionEC ) ;
# else
return czm _phong ( normalize ( positionToEyeEC ) , material , czm _lightDirectionEC ) ;
# endif
}
void main ( )
{
// PERFORMANCE_TODO: When dynamic branching is available, compute ratio of maximum and minimum radii
// in the vertex shader. Only when it is larger than some constant, march along the ray.
// Otherwise perform one intersection test which will be the common case.
// Test if the ray intersects a sphere with the ellipsoid's maximum radius.
// For very oblate ellipsoids, using the ellipsoid's radii for an intersection test
// may cause false negatives. This will discard fragments before marching the ray forward.
float maxRadius = max ( u _radii . x , max ( u _radii . y , u _radii . z ) ) * 1.5 ;
vec3 direction = normalize ( v _positionEC ) ;
vec3 ellipsoidCenter = czm _modelView [ 3 ] . xyz ;
float t1 = - 1.0 ;
float t2 = - 1.0 ;
float b = - 2.0 * dot ( direction , ellipsoidCenter ) ;
float c = dot ( ellipsoidCenter , ellipsoidCenter ) - maxRadius * maxRadius ;
float discriminant = b * b - 4.0 * c ;
if ( discriminant >= 0.0 ) {
t1 = ( - b - sqrt ( discriminant ) ) * 0.5 ;
t2 = ( - b + sqrt ( discriminant ) ) * 0.5 ;
}
if ( t1 < 0.0 && t2 < 0.0 ) {
discard ;
}
float t = min ( t1 , t2 ) ;
if ( t < 0.0 ) {
t = 0.0 ;
}
// March ray forward to intersection with larger sphere and find
czm _ray ray = czm _ray ( t * direction , direction ) ;
vec3 ellipsoid _inverseRadii = vec3 ( 1.0 / u _radii . x , 1.0 / u _radii . y , 1.0 / u _radii . z ) ;
czm _raySegment intersection = czm _rayEllipsoidIntersectionInterval ( ray , ellipsoidCenter , ellipsoid _inverseRadii ) ;
if ( czm _isEmpty ( intersection ) )
{
discard ;
}
// If the viewer is outside, compute outsideFaceColor, with normals facing outward.
vec4 outsideFaceColor = ( intersection . start != 0.0 ) ? computeEllipsoidColor ( ray , intersection . start , 1.0 ) : vec4 ( 0.0 ) ;
// If the viewer either is inside or can see inside, compute insideFaceColor, with normals facing inward.
vec4 insideFaceColor = ( outsideFaceColor . a < 1.0 ) ? computeEllipsoidColor ( ray , intersection . stop , - 1.0 ) : vec4 ( 0.0 ) ;
gl _FragColor = mix ( insideFaceColor , outsideFaceColor , outsideFaceColor . a ) ;
gl _FragColor . a = 1.0 - ( 1.0 - insideFaceColor . a ) * ( 1.0 - outsideFaceColor . a ) ;
# ifdef WRITE _DEPTH
# ifdef GL _EXT _frag _depth
t = ( intersection . start != 0.0 ) ? intersection . start : intersection . stop ;
vec3 positionEC = czm _pointAlongRay ( ray , t ) ;
vec4 positionCC = czm _projection * vec4 ( positionEC , 1.0 ) ;
# ifdef LOG _DEPTH
czm _writeLogDepth ( 1.0 + positionCC . w ) ;
# else
float z = positionCC . z / positionCC . w ;
float n = czm _depthRange . near ;
float f = czm _depthRange . far ;
gl _FragDepthEXT = ( z * ( f - n ) + f + n ) * 0.5 ;
# endif
# endif
# endif
}
` ,w2= ` attribute vec3 position ;
uniform vec3 u _radii ;
varying vec3 v _positionEC ;
void main ( )
{
// In the vertex data, the cube goes from (-1.0, -1.0, -1.0) to (1.0, 1.0, 1.0) in model coordinates.
// Scale to consider the radii. We could also do this once on the CPU when using the BoxGeometry,
// but doing it here allows us to change the radii without rewriting the vertex data, and
// allows all ellipsoids to reuse the same vertex data.
vec4 p = vec4 ( u _radii * position , 1.0 ) ;
v _positionEC = ( czm _modelView * p ) . xyz ; // position in eye coordinates
gl _Position = czm _modelViewProjection * p ; // position in clip coordinates
// With multi-frustum, when the ellipsoid primitive is positioned on the intersection of two frustums
// and close to terrain, the terrain (writes depth) in the closest frustum can overwrite part of the
// ellipsoid (does not write depth) that was rendered in the farther frustum.
//
// Here, we clamp the depth in the vertex shader to avoid being overwritten; however, this creates
// artifacts since some fragments can be alpha blended twice. This is solved by only rendering
// the ellipsoid in the closest frustum to the viewer.
gl _Position . z = clamp ( gl _Position . z , czm _depthRange . near , czm _depthRange . far ) ;
czm _vertexLogDepth ( ) ;
}
` ;/**
* @ license
* Copyright ( c ) 2014 - 2015 , NVIDIA CORPORATION . All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* * Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* * Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ` ` AS IS '' AND ANY
* EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL ,
* EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO ,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR
* PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /const Pue=`/ * *
* @ license
* Copyright ( c ) 2014 - 2015 , NVIDIA CORPORATION . All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* * Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* * Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* * Neither the name of NVIDIA CORPORATION nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS \ ` \` AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL , SPECIAL ,
* EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT LIMITED TO ,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE , DATA , OR
* PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
* /
// NVIDIA GameWorks Graphics Samples GitHub link: https://github.com/NVIDIAGameWorks/GraphicsSamples
// Original FXAA 3.11 shader link: https://github.com/NVIDIAGameWorks/GraphicsSamples/blob/master/samples/es3-kepler/FXAA/FXAA3_11.h
// Steps used to integrate into Cesium:
// * The following defines are set:
// #define FXAA_PC 1
// #define FXAA_WEBGL_1 1
// #define FXAA_GREEN_AS_LUMA 1
// #define FXAA_EARLY_EXIT 1
// #define FXAA_GLSL_120 1
// * All other preprocessor directives besides the FXAA_QUALITY__P* directives were removed.
// * Double underscores are invalid for preprocessor directives so replace them with a single underscore. Replace
// /FXAA_QUALITY__P(.*)/g with /FXAA_QUALITY__P$1/.
// * There are no implicit conversions from ivec* to vec* so replace:
// #define FxaaInt2 ivec2
// with
// #define FxaaInt2 vec2
// * The texture2DLod function is only available in vertex shaders so replace:
// #define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)
// #define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)
// with
// #define FxaaTexTop(t, p) texture2D(t, p)
// #define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r))
// * FXAA_QUALITY_PRESET is prepended in the javascript code. We may want to expose that setting in the future.
// * The following parameters to FxaaPixelShader are unused and can be removed:
// fxaaConsolePosPos
// fxaaConsoleRcpFrameOpt
// fxaaConsoleRcpFrameOpt2
// fxaaConsole360RcpFrameOpt2
// fxaaConsoleEdgeSharpness
// fxaaConsoleEdgeThreshold
// fxaaConsoleEdgeThresholdMi
// fxaaConsole360ConstDir
//
// Choose the quality preset.
// This needs to be compiled into the shader as it effects code.
// Best option to include multiple presets is to
// in each shader define the preset, then include this file.
//
// OPTIONS
// -----------------------------------------------------------------------
// 10 to 15 - default medium dither (10=fastest, 15=highest quality)
// 20 to 29 - less dither, more expensive (20=fastest, 29=highest quality)
// 39 - no dither, very expensive
//
// NOTES
// -----------------------------------------------------------------------
// 12 = slightly faster then FXAA 3.9 and higher edge quality (default)
// 13 = about same speed as FXAA 3.9 and better than 12
// 23 = closest to FXAA 3.9 visually and performance wise
// _ = the lowest digit is directly related to performance
// _ = the highest digit is directly related to style
//
//#define FXAA_QUALITY_PRESET 12
# if ( FXAA _QUALITY _PRESET == 10 )
# define FXAA _QUALITY _PS 3
# define FXAA _QUALITY _P0 1.5
# define FXAA _QUALITY _P1 3.0
# define FXAA _QUALITY _P2 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 11 )
# define FXAA _QUALITY _PS 4
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 3.0
# define FXAA _QUALITY _P3 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 12 )
# define FXAA _QUALITY _PS 5
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 4.0
# define FXAA _QUALITY _P4 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 13 )
# define FXAA _QUALITY _PS 6
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 4.0
# define FXAA _QUALITY _P5 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 14 )
# define FXAA _QUALITY _PS 7
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 4.0
# define FXAA _QUALITY _P6 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 15 )
# define FXAA _QUALITY _PS 8
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 4.0
# define FXAA _QUALITY _P7 12.0
# endif
# if ( FXAA _QUALITY _PRESET == 20 )
# define FXAA _QUALITY _PS 3
# define FXAA _QUALITY _P0 1.5
# define FXAA _QUALITY _P1 2.0
# define FXAA _QUALITY _P2 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 21 )
# define FXAA _QUALITY _PS 4
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 22 )
# define FXAA _QUALITY _PS 5
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 23 )
# define FXAA _QUALITY _PS 6
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 24 )
# define FXAA _QUALITY _PS 7
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 3.0
# define FXAA _QUALITY _P6 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 25 )
# define FXAA _QUALITY _PS 8
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 4.0
# define FXAA _QUALITY _P7 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 26 )
# define FXAA _QUALITY _PS 9
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 2.0
# define FXAA _QUALITY _P7 4.0
# define FXAA _QUALITY _P8 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 27 )
# define FXAA _QUALITY _PS 10
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 2.0
# define FXAA _QUALITY _P7 2.0
# define FXAA _QUALITY _P8 4.0
# define FXAA _QUALITY _P9 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 28 )
# define FXAA _QUALITY _PS 11
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 2.0
# define FXAA _QUALITY _P7 2.0
# define FXAA _QUALITY _P8 2.0
# define FXAA _QUALITY _P9 4.0
# define FXAA _QUALITY _P10 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 29 )
# define FXAA _QUALITY _PS 12
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.5
# define FXAA _QUALITY _P2 2.0
# define FXAA _QUALITY _P3 2.0
# define FXAA _QUALITY _P4 2.0
# define FXAA _QUALITY _P5 2.0
# define FXAA _QUALITY _P6 2.0
# define FXAA _QUALITY _P7 2.0
# define FXAA _QUALITY _P8 2.0
# define FXAA _QUALITY _P9 2.0
# define FXAA _QUALITY _P10 4.0
# define FXAA _QUALITY _P11 8.0
# endif
# if ( FXAA _QUALITY _PRESET == 39 )
# define FXAA _QUALITY _PS 12
# define FXAA _QUALITY _P0 1.0
# define FXAA _QUALITY _P1 1.0
# define FXAA _QUALITY _P2 1.0
# define FXAA _QUALITY _P3 1.0
# define FXAA _QUALITY _P4 1.0
# define FXAA _QUALITY _P5 1.5
# define FXAA _QUALITY _P6 2.0
# define FXAA _QUALITY _P7 2.0
# define FXAA _QUALITY _P8 2.0
# define FXAA _QUALITY _P9 2.0
# define FXAA _QUALITY _P10 4.0
# define FXAA _QUALITY _P11 8.0
# endif
# define FxaaBool bool
# define FxaaFloat float
# define FxaaFloat2 vec2
# define FxaaFloat3 vec3
# define FxaaFloat4 vec4
# define FxaaHalf float
# define FxaaHalf2 vec2
# define FxaaHalf3 vec3
# define FxaaHalf4 vec4
# define FxaaInt2 vec2
# define FxaaTex sampler2D
# define FxaaSat ( x ) clamp ( x , 0.0 , 1.0 )
# define FxaaTexTop ( t , p ) texture2D ( t , p )
# define FxaaTexOff ( t , p , o , r ) texture2D ( t , p + ( o * r ) )
FxaaFloat FxaaLuma ( FxaaFloat4 rgba ) { return rgba . y ; }
FxaaFloat4 FxaaPixelShader (
//
// Use noperspective interpolation here (turn off perspective interpolation).
// {xy} = center of pixel
FxaaFloat2 pos ,
//
// Input color texture.
// {rgb_} = color in linear or perceptual color space
// if (FXAA_GREEN_AS_LUMA == 0)
// {___a} = luma in perceptual color space (not linear)
FxaaTex tex ,
//
// Only used on FXAA Quality.
// This must be from a constant/uniform.
// {x_} = 1.0/screenWidthInPixels
// {_y} = 1.0/screenHeightInPixels
FxaaFloat2 fxaaQualityRcpFrame ,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_SUBPIX define.
// It is here now to allow easier tuning.
// Choose the amount of sub-pixel aliasing removal.
// This can effect sharpness.
// 1.00 - upper limit (softer)
// 0.75 - default amount of filtering
// 0.50 - lower limit (sharper, less sub-pixel aliasing removal)
// 0.25 - almost off
// 0.00 - completely off
FxaaFloat fxaaQualitySubpix ,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD define.
// It is here now to allow easier tuning.
// The minimum amount of local contrast required to apply algorithm.
// 0.333 - too little (faster)
// 0.250 - low quality
// 0.166 - default
// 0.125 - high quality
// 0.063 - overkill (slower)
FxaaFloat fxaaQualityEdgeThreshold ,
//
// Only used on FXAA Quality.
// This used to be the FXAA_QUALITY_EDGE_THRESHOLD_MIN define.
// It is here now to allow easier tuning.
// Trims the algorithm from processing darks.
// 0.0833 - upper limit (default, the start of visible unfiltered edges)
// 0.0625 - high quality (faster)
// 0.0312 - visible limit (slower)
// Special notes when using FXAA_GREEN_AS_LUMA,
// Likely want to set this to zero.
// As colors that are mostly not-green
// will appear very dark in the green channel!
// Tune by looking at mostly non-green content,
// then start at zero and increase until aliasing is a problem.
FxaaFloat fxaaQualityEdgeThresholdMin
) {
/*--------------------------------------------------------------------------*/
FxaaFloat2 posM ;
posM . x = pos . x ;
posM . y = pos . y ;
FxaaFloat4 rgbyM = FxaaTexTop ( tex , posM ) ;
# define lumaM rgbyM . y
FxaaFloat lumaS = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( 0 , 1 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaE = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( 1 , 0 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaN = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( 0 , - 1 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaW = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( - 1 , 0 ) , fxaaQualityRcpFrame . xy ) ) ;
/*--------------------------------------------------------------------------*/
FxaaFloat maxSM = max ( lumaS , lumaM ) ;
FxaaFloat minSM = min ( lumaS , lumaM ) ;
FxaaFloat maxESM = max ( lumaE , maxSM ) ;
FxaaFloat minESM = min ( lumaE , minSM ) ;
FxaaFloat maxWN = max ( lumaN , lumaW ) ;
FxaaFloat minWN = min ( lumaN , lumaW ) ;
FxaaFloat rangeMax = max ( maxWN , maxESM ) ;
FxaaFloat rangeMin = min ( minWN , minESM ) ;
FxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold ;
FxaaFloat range = rangeMax - rangeMin ;
FxaaFloat rangeMaxClamped = max ( fxaaQualityEdgeThresholdMin , rangeMaxScaled ) ;
FxaaBool earlyExit = range < rangeMaxClamped ;
/*--------------------------------------------------------------------------*/
if ( earlyExit )
return rgbyM ;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNW = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( - 1 , - 1 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaSE = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( 1 , 1 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaNE = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( 1 , - 1 ) , fxaaQualityRcpFrame . xy ) ) ;
FxaaFloat lumaSW = FxaaLuma ( FxaaTexOff ( tex , posM , FxaaInt2 ( - 1 , 1 ) , fxaaQualityRcpFrame . xy ) ) ;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNS = lumaN + lumaS ;
FxaaFloat lumaWE = lumaW + lumaE ;
FxaaFloat subpixRcpRange = 1.0 / range ;
FxaaFloat subpixNSWE = lumaNS + lumaWE ;
FxaaFloat edgeHorz1 = ( - 2.0 * lumaM ) + lumaNS ;
FxaaFloat edgeVert1 = ( - 2.0 * lumaM ) + lumaWE ;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNESE = lumaNE + lumaSE ;
FxaaFloat lumaNWNE = lumaNW + lumaNE ;
FxaaFloat edgeHorz2 = ( - 2.0 * lumaE ) + lumaNESE ;
FxaaFloat edgeVert2 = ( - 2.0 * lumaN ) + lumaNWNE ;
/*--------------------------------------------------------------------------*/
FxaaFloat lumaNWSW = lumaNW + lumaSW ;
FxaaFloat lumaSWSE = lumaSW + lumaSE ;
FxaaFloat edgeHorz4 = ( abs ( edgeHorz1 ) * 2.0 ) + abs ( edgeHorz2 ) ;
FxaaFloat edgeVert4 = ( abs ( edgeVert1 ) * 2.0 ) + abs ( edgeVert2 ) ;
FxaaFloat edgeHorz3 = ( - 2.0 * lumaW ) + lumaNWSW ;
FxaaFloat edgeVert3 = ( - 2.0 * lumaS ) + lumaSWSE ;
FxaaFloat edgeHorz = abs ( edgeHorz3 ) + edgeHorz4 ;
FxaaFloat edgeVert = abs ( edgeVert3 ) + edgeVert4 ;
/*--------------------------------------------------------------------------*/
FxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE ;
FxaaFloat lengthSign = fxaaQualityRcpFrame . x ;
FxaaBool horzSpan = edgeHorz >= edgeVert ;
FxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE ;
/*--------------------------------------------------------------------------*/
if ( ! horzSpan ) lumaN = lumaW ;
if ( ! horzSpan ) lumaS = lumaE ;
if ( horzSpan ) lengthSign = fxaaQualityRcpFrame . y ;
FxaaFloat subpixB = ( subpixA * ( 1.0 / 12.0 ) ) - lumaM ;
/*--------------------------------------------------------------------------*/
FxaaFloat gradientN = lumaN - lumaM ;
FxaaFloat gradientS = lumaS - lumaM ;
FxaaFloat lumaNN = lumaN + lumaM ;
FxaaFloat lumaSS = lumaS + lumaM ;
FxaaBool pairN = abs ( gradientN ) >= abs ( gradientS ) ;
FxaaFloat gradient = max ( abs ( gradientN ) , abs ( gradientS ) ) ;
if ( pairN ) lengthSign = - lengthSign ;
FxaaFloat subpixC = FxaaSat ( abs ( subpixB ) * subpixRcpRange ) ;
/*--------------------------------------------------------------------------*/
FxaaFloat2 posB ;
posB . x = posM . x ;
posB . y = posM . y ;
FxaaFloat2 offNP ;
offNP . x = ( ! horzSpan ) ? 0.0 : fxaaQualityRcpFrame . x ;
offNP . y = ( horzSpan ) ? 0.0 : fxaaQualityRcpFrame . y ;
if ( ! horzSpan ) posB . x += lengthSign * 0.5 ;
if ( horzSpan ) posB . y += lengthSign * 0.5 ;
/*--------------------------------------------------------------------------*/
FxaaFloat2 posN ;
posN . x = posB . x - offNP . x * FXAA _QUALITY _P0 ;
posN . y = posB . y - offNP . y * FXAA _QUALITY _P0 ;
FxaaFloat2 posP ;
posP . x = posB . x + offNP . x * FXAA _QUALITY _P0 ;
posP . y = posB . y + offNP . y * FXAA _QUALITY _P0 ;
FxaaFloat subpixD = ( ( - 2.0 ) * subpixC ) + 3.0 ;
FxaaFloat lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN ) ) ;
FxaaFloat subpixE = subpixC * subpixC ;
FxaaFloat lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP ) ) ;
/*--------------------------------------------------------------------------*/
if ( ! pairN ) lumaNN = lumaSS ;
FxaaFloat gradientScaled = gradient * 1.0 / 4.0 ;
FxaaFloat lumaMM = lumaM - lumaNN * 0.5 ;
FxaaFloat subpixF = subpixD * subpixE ;
FxaaBool lumaMLTZero = lumaMM < 0.0 ;
/*--------------------------------------------------------------------------*/
lumaEndN -= lumaNN * 0.5 ;
lumaEndP -= lumaNN * 0.5 ;
FxaaBool doneN = abs ( lumaEndN ) >= gradientScaled ;
FxaaBool doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P1 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P1 ;
FxaaBool doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P1 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P1 ;
/*--------------------------------------------------------------------------*/
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P2 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P2 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P2 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P2 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 3 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P3 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P3 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P3 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P3 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 4 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P4 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P4 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P4 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P4 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 5 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P5 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P5 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P5 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P5 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 6 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P6 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P6 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P6 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P6 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 7 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P7 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P7 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P7 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P7 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 8 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P8 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P8 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P8 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P8 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 9 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P9 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P9 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P9 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P9 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 10 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P10 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P10 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P10 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P10 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 11 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P11 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P11 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P11 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P11 ;
/*--------------------------------------------------------------------------*/
# if ( FXAA _QUALITY _PS > 12 )
if ( doneNP ) {
if ( ! doneN ) lumaEndN = FxaaLuma ( FxaaTexTop ( tex , posN . xy ) ) ;
if ( ! doneP ) lumaEndP = FxaaLuma ( FxaaTexTop ( tex , posP . xy ) ) ;
if ( ! doneN ) lumaEndN = lumaEndN - lumaNN * 0.5 ;
if ( ! doneP ) lumaEndP = lumaEndP - lumaNN * 0.5 ;
doneN = abs ( lumaEndN ) >= gradientScaled ;
doneP = abs ( lumaEndP ) >= gradientScaled ;
if ( ! doneN ) posN . x -= offNP . x * FXAA _QUALITY _P12 ;
if ( ! doneN ) posN . y -= offNP . y * FXAA _QUALITY _P12 ;
doneNP = ( ! doneN ) || ( ! doneP ) ;
if ( ! doneP ) posP . x += offNP . x * FXAA _QUALITY _P12 ;
if ( ! doneP ) posP . y += offNP . y * FXAA _QUALITY _P12 ;
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
# endif
/*--------------------------------------------------------------------------*/
}
/*--------------------------------------------------------------------------*/
FxaaFloat dstN = posM . x - posN . x ;
FxaaFloat dstP = posP . x - posM . x ;
if ( ! horzSpan ) dstN = posM . y - posN . y ;
if ( ! horzSpan ) dstP = posP . y - posM . y ;
/*--------------------------------------------------------------------------*/
FxaaBool goodSpanN = ( lumaEndN < 0.0 ) != lumaMLTZero ;
FxaaFloat spanLength = ( dstP + dstN ) ;
FxaaBool goodSpanP = ( lumaEndP < 0.0 ) != lumaMLTZero ;
FxaaFloat spanLengthRcp = 1.0 / spanLength ;
/*--------------------------------------------------------------------------*/
FxaaBool directionN = dstN < dstP ;
FxaaFloat dst = min ( dstN , dstP ) ;
FxaaBool goodSpan = directionN ? goodSpanN : goodSpanP ;
FxaaFloat subpixG = subpixF * subpixF ;
FxaaFloat pixelOffset = ( dst * ( - spanLengthRcp ) ) + 0.5 ;
FxaaFloat subpixH = subpixG * fxaaQualitySubpix ;
/*--------------------------------------------------------------------------*/
FxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0 ;
FxaaFloat pixelOffsetSubpix = max ( pixelOffsetGood , subpixH ) ;
if ( ! horzSpan ) posM . x += pixelOffsetSubpix * lengthSign ;
if ( horzSpan ) posM . y += pixelOffsetSubpix * lengthSign ;
return FxaaFloat4 ( FxaaTexTop ( tex , posM ) . xyz , lumaM ) ;
}
` ,Oue= ` uniform vec4 u _initialColor ;
# if TEXTURE _UNITS > 0
uniform sampler2D u _dayTextures [ TEXTURE _UNITS ] ;
uniform vec4 u _dayTextureTranslationAndScale [ TEXTURE _UNITS ] ;
uniform bool u _dayTextureUseWebMercatorT [ TEXTURE _UNITS ] ;
# ifdef APPLY _ALPHA
uniform float u _dayTextureAlpha [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _DAY _NIGHT _ALPHA
uniform float u _dayTextureNightAlpha [ TEXTURE _UNITS ] ;
uniform float u _dayTextureDayAlpha [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _SPLIT
uniform float u _dayTextureSplit [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _BRIGHTNESS
uniform float u _dayTextureBrightness [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _CONTRAST
uniform float u _dayTextureContrast [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _HUE
uniform float u _dayTextureHue [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _SATURATION
uniform float u _dayTextureSaturation [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _GAMMA
uniform float u _dayTextureOneOverGamma [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _IMAGERY _CUTOUT
uniform vec4 u _dayTextureCutoutRectangles [ TEXTURE _UNITS ] ;
# endif
# ifdef APPLY _COLOR _TO _ALPHA
uniform vec4 u _colorsToAlpha [ TEXTURE _UNITS ] ;
# endif
uniform vec4 u _dayTextureTexCoordsRectangle [ TEXTURE _UNITS ] ;
# endif
# ifdef SHOW _REFLECTIVE _OCEAN
uniform sampler2D u _waterMask ;
uniform vec4 u _waterMaskTranslationAndScale ;
uniform float u _zoomedOutOceanSpecularIntensity ;
# endif
# ifdef SHOW _OCEAN _WAVES
uniform sampler2D u _oceanNormalMap ;
# endif
# if defined ( ENABLE _DAYNIGHT _SHADING ) || defined ( GROUND _ATMOSPHERE )
uniform vec2 u _lightingFadeDistance ;
# endif
# ifdef TILE _LIMIT _RECTANGLE
uniform vec4 u _cartographicLimitRectangle ;
# endif
# ifdef GROUND _ATMOSPHERE
uniform vec2 u _nightFadeDistance ;
# endif
# ifdef ENABLE _CLIPPING _PLANES
uniform highp sampler2D u _clippingPlanes ;
uniform mat4 u _clippingPlanesMatrix ;
uniform vec4 u _clippingPlanesEdgeStyle ;
# endif
# if defined ( GROUND _ATMOSPHERE ) || defined ( FOG ) && defined ( DYNAMIC _ATMOSPHERE _LIGHTING ) && ( defined ( ENABLE _VERTEX _LIGHTING ) || defined ( ENABLE _DAYNIGHT _SHADING ) )
uniform float u _minimumBrightness ;
# endif
# ifdef COLOR _CORRECT
uniform vec3 u _hsbShift ; // Hue, saturation, brightness
# endif
# ifdef HIGHLIGHT _FILL _TILE
uniform vec4 u _fillHighlightColor ;
# endif
# ifdef TRANSLUCENT
uniform vec4 u _frontFaceAlphaByDistance ;
uniform vec4 u _backFaceAlphaByDistance ;
uniform vec4 u _translucencyRectangle ;
# endif
# ifdef UNDERGROUND _COLOR
uniform vec4 u _undergroundColor ;
uniform vec4 u _undergroundColorAlphaByDistance ;
# endif
# ifdef ENABLE _VERTEX _LIGHTING
uniform float u _lambertDiffuseMultiplier ;
uniform float u _vertexShadowDarkness ;
# endif
varying vec3 v _positionMC ;
varying vec3 v _positionEC ;
varying vec3 v _textureCoordinates ;
varying vec3 v _normalMC ;
varying vec3 v _normalEC ;
# ifdef APPLY _MATERIAL
varying float v _height ;
varying float v _slope ;
varying float v _aspect ;
# endif
# if defined ( FOG ) || defined ( GROUND _ATMOSPHERE ) || defined ( UNDERGROUND _COLOR ) || defined ( TRANSLUCENT )
varying float v _distance ;
# endif
# if defined ( GROUND _ATMOSPHERE ) || defined ( FOG )
varying vec3 v _atmosphereRayleighColor ;
varying vec3 v _atmosphereMieColor ;
varying float v _atmosphereOpacity ;
# endif
# if defined ( UNDERGROUND _COLOR ) || defined ( TRANSLUCENT )
float interpolateByDistance ( vec4 nearFarScalar , float distance )
{
float startDistance = nearFarScalar . x ;
float startValue = nearFarScalar . y ;
float endDistance = nearFarScalar . z ;
float endValue = nearFarScalar . w ;
float t = clamp ( ( distance - startDistance ) / ( endDistance - startDistance ) , 0.0 , 1.0 ) ;
return mix ( startValue , endValue , t ) ;
}
# endif
# if defined ( UNDERGROUND _COLOR ) || defined ( TRANSLUCENT ) || defined ( APPLY _MATERIAL )
vec4 alphaBlend ( vec4 sourceColor , vec4 destinationColor )
{
return sourceColor * vec4 ( sourceColor . aaa , 1.0 ) + destinationColor * ( 1.0 - sourceColor . a ) ;
}
# endif
# ifdef TRANSLUCENT
bool inTranslucencyRectangle ( )
{
return
v _textureCoordinates . x > u _translucencyRectangle . x &&
v _textureCoordinates . x < u _translucencyRectangle . z &&
v _textureCoordinates . y > u _translucencyRectangle . y &&
v _textureCoordinates . y < u _translucencyRectangle . w ;
}
# endif
vec4 sampleAndBlend (
vec4 previousColor ,
sampler2D textureToSample ,
vec2 tileTextureCoordinates ,
vec4 textureCoordinateRectangle ,
vec4 textureCoordinateTranslationAndScale ,
float textureAlpha ,
float textureNightAlpha ,
float textureDayAlpha ,
float textureBrightness ,
float textureContrast ,
float textureHue ,
float textureSaturation ,
float textureOneOverGamma ,
float split ,
vec4 colorToAlpha ,
float nightBlend )
{
// This crazy step stuff sets the alpha to 0.0 if this following condition is true:
// tileTextureCoordinates.s < textureCoordinateRectangle.s ||
// tileTextureCoordinates.s > textureCoordinateRectangle.p ||
// tileTextureCoordinates.t < textureCoordinateRectangle.t ||
// tileTextureCoordinates.t > textureCoordinateRectangle.q
// In other words, the alpha is zero if the fragment is outside the rectangle
// covered by this texture. Would an actual 'if' yield better performance?
vec2 alphaMultiplier = step ( textureCoordinateRectangle . st , tileTextureCoordinates ) ;
textureAlpha = textureAlpha * alphaMultiplier . x * alphaMultiplier . y ;
alphaMultiplier = step ( vec2 ( 0.0 ) , textureCoordinateRectangle . pq - tileTextureCoordinates ) ;
textureAlpha = textureAlpha * alphaMultiplier . x * alphaMultiplier . y ;
# if defined ( APPLY _DAY _NIGHT _ALPHA ) && defined ( ENABLE _DAYNIGHT _SHADING )
textureAlpha *= mix ( textureDayAlpha , textureNightAlpha , nightBlend ) ;
# endif
vec2 translation = textureCoordinateTranslationAndScale . xy ;
vec2 scale = textureCoordinateTranslationAndScale . zw ;
vec2 textureCoordinates = tileTextureCoordinates * scale + translation ;
vec4 value = texture2D ( textureToSample , textureCoordinates ) ;
vec3 color = value . rgb ;
float alpha = value . a ;
# ifdef APPLY _COLOR _TO _ALPHA
vec3 colorDiff = abs ( color . rgb - colorToAlpha . rgb ) ;
colorDiff . r = max ( max ( colorDiff . r , colorDiff . g ) , colorDiff . b ) ;
alpha = czm _branchFreeTernary ( colorDiff . r < colorToAlpha . a , 0.0 , alpha ) ;
# endif
# if ! defined ( APPLY _GAMMA )
vec4 tempColor = czm _gammaCorrect ( vec4 ( color , alpha ) ) ;
color = tempColor . rgb ;
alpha = tempColor . a ;
# else
color = pow ( color , vec3 ( textureOneOverGamma ) ) ;
# endif
# ifdef APPLY _SPLIT
float splitPosition = czm _splitPosition ;
// Split to the left
if ( split < 0.0 && gl _FragCoord . x > splitPosition ) {
alpha = 0.0 ;
}
// Split to the right
else if ( split > 0.0 && gl _FragCoord . x < splitPosition ) {
alpha = 0.0 ;
}
# endif
# ifdef APPLY _BRIGHTNESS
color = mix ( vec3 ( 0.0 ) , color , textureBrightness ) ;
# endif
# ifdef APPLY _CONTRAST
color = mix ( vec3 ( 0.5 ) , color , textureContrast ) ;
# endif
# ifdef APPLY _HUE
color = czm _hue ( color , textureHue ) ;
# endif
# ifdef APPLY _SATURATION
color = czm _saturation ( color , textureSaturation ) ;
# endif
float sourceAlpha = alpha * textureAlpha ;
float outAlpha = mix ( previousColor . a , 1.0 , sourceAlpha ) ;
outAlpha += sign ( outAlpha ) - 1.0 ;
vec3 outColor = mix ( previousColor . rgb * previousColor . a , color , sourceAlpha ) / outAlpha ;
// When rendering imagery for a tile in multiple passes,
// some GPU/WebGL implementation combinations will not blend fragments in
// additional passes correctly if their computation includes an unmasked
// divide-by-zero operation,
// even if it's not in the output or if the output has alpha zero.
//
// For example, without sanitization for outAlpha,
// this renders without artifacts:
// if (outAlpha == 0.0) { outColor = vec3(0.0); }
//
// but using czm_branchFreeTernary will cause portions of the tile that are
// alpha-zero in the additional pass to render as black instead of blending
// with the previous pass:
// outColor = czm_branchFreeTernary(outAlpha == 0.0, vec3(0.0), outColor);
//
// So instead, sanitize against divide-by-zero,
// store this state on the sign of outAlpha, and correct on return.
return vec4 ( outColor , max ( outAlpha , 0.0 ) ) ;
}
vec3 colorCorrect ( vec3 rgb ) {
# ifdef COLOR _CORRECT
// Convert rgb color to hsb
vec3 hsb = czm _RGBToHSB ( rgb ) ;
// Perform hsb shift
hsb . x += u _hsbShift . x ; // hue
hsb . y = clamp ( hsb . y + u _hsbShift . y , 0.0 , 1.0 ) ; // saturation
hsb . z = hsb . z > czm _epsilon7 ? hsb . z + u _hsbShift . z : 0.0 ; // brightness
// Convert shifted hsb back to rgb
rgb = czm _HSBToRGB ( hsb ) ;
# endif
return rgb ;
}
vec4 computeDayColor ( vec4 initialColor , vec3 textureCoordinates , float nightBlend ) ;
vec4 computeWaterColor ( vec3 positionEyeCoordinates , vec2 textureCoordinates , mat3 enuToEye , vec4 imageryColor , float specularMapValue , float fade ) ;
const float fExposure = 2.0 ;
vec3 computeEllipsoidPosition ( )
{
float mpp = czm _metersPerPixel ( vec4 ( 0.0 , 0.0 , - czm _currentFrustum . x , 1.0 ) , 1.0 ) ;
vec2 xy = gl _FragCoord . xy / czm _viewport . zw * 2.0 - vec2 ( 1.0 ) ;
xy *= czm _viewport . zw * mpp * 0.5 ;
vec3 direction = normalize ( vec3 ( xy , - czm _currentFrustum . x ) ) ;
czm _ray ray = czm _ray ( vec3 ( 0.0 ) , direction ) ;
vec3 ellipsoid _center = czm _view [ 3 ] . xyz ;
czm _raySegment intersection = czm _rayEllipsoidIntersectionInterval ( ray , ellipsoid _center , czm _ellipsoidInverseRadii ) ;
vec3 ellipsoidPosition = czm _pointAlongRay ( ray , intersection . start ) ;
return ( czm _inverseView * vec4 ( ellipsoidPosition , 1.0 ) ) . xyz ;
}
void main ( )
{
# ifdef TILE _LIMIT _RECTANGLE
if ( v _textureCoordinates . x < u _cartographicLimitRectangle . x || u _cartographicLimitRectangle . z < v _textureCoordinates . x ||
v _textureCoordinates . y < u _cartographicLimitRectangle . y || u _cartographicLimitRectangle . w < v _textureCoordinates . y )
{
discard ;
}
# endif
# ifdef ENABLE _CLIPPING _PLANES
float clipDistance = clip ( gl _FragCoord , u _clippingPlanes , u _clippingPlanesMatrix ) ;
# endif
# if defined ( SHOW _REFLECTIVE _OCEAN ) || defined ( ENABLE _DAYNIGHT _SHADING ) || defined ( HDR )
vec3 normalMC = czm _geodeticSurfaceNormal ( v _positionMC , vec3 ( 0.0 ) , vec3 ( 1.0 ) ) ; // normalized surface normal in model coordinates
vec3 normalEC = czm _normal3D * normalMC ; // normalized surface normal in eye coordiantes
# endif
# if defined ( APPLY _DAY _NIGHT _ALPHA ) && defined ( ENABLE _DAYNIGHT _SHADING )
float nightBlend = 1.0 - clamp ( czm _getLambertDiffuse ( czm _lightDirectionEC , normalEC ) * 5.0 , 0.0 , 1.0 ) ;
# else
float nightBlend = 0.0 ;
# endif
// The clamp below works around an apparent bug in Chrome Canary v23.0.1241.0
// where the fragment shader sees textures coordinates < 0.0 and > 1.0 for the
// fragments on the edges of tiles even though the vertex shader is outputting
// coordinates strictly in the 0-1 range.
vec4 color = computeDayColor ( u _initialColor , clamp ( v _textureCoordinates , 0.0 , 1.0 ) , nightBlend ) ;
# ifdef SHOW _TILE _BOUNDARIES
if ( v _textureCoordinates . x < ( 1.0 / 256.0 ) || v _textureCoordinates . x > ( 255.0 / 256.0 ) ||
v _textureCoordinates . y < ( 1.0 / 256.0 ) || v _textureCoordinates . y > ( 255.0 / 256.0 ) )
{
color = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
}
# endif
# if defined ( ENABLE _DAYNIGHT _SHADING ) || defined ( GROUND _ATMOSPHERE )
float cameraDist ;
if ( czm _sceneMode == czm _sceneMode2D )
{
cameraDist = max ( czm _frustumPlanes . x - czm _frustumPlanes . y , czm _frustumPlanes . w - czm _frustumPlanes . z ) * 0.5 ;
}
else if ( czm _sceneMode == czm _sceneModeColumbusView )
{
cameraDist = - czm _view [ 3 ] . z ;
}
else
{
cameraDist = length ( czm _view [ 3 ] ) ;
}
float fadeOutDist = u _lightingFadeDistance . x ;
float fadeInDist = u _lightingFadeDistance . y ;
if ( czm _sceneMode != czm _sceneMode3D ) {
vec3 radii = czm _ellipsoidRadii ;
float maxRadii = max ( radii . x , max ( radii . y , radii . z ) ) ;
fadeOutDist -= maxRadii ;
fadeInDist -= maxRadii ;
}
float fade = clamp ( ( cameraDist - fadeOutDist ) / ( fadeInDist - fadeOutDist ) , 0.0 , 1.0 ) ;
# else
float fade = 0.0 ;
# endif
# ifdef SHOW _REFLECTIVE _OCEAN
vec2 waterMaskTranslation = u _waterMaskTranslationAndScale . xy ;
vec2 waterMaskScale = u _waterMaskTranslationAndScale . zw ;
vec2 waterMaskTextureCoordinates = v _textureCoordinates . xy * waterMaskScale + waterMaskTranslation ;
waterMaskTextureCoordinates . y = 1.0 - waterMaskTextureCoordinates . y ;
float mask = texture2D ( u _waterMask , waterMaskTextureCoordinates ) . r ;
if ( mask > 0.0 )
{
mat3 enuToEye = czm _eastNorthUpToEyeCoordinates ( v _positionMC , normalEC ) ;
vec2 ellipsoidTextureCoordinates = czm _ellipsoidWgs84TextureCoordinates ( normalMC ) ;
vec2 ellipsoidFlippedTextureCoordinates = czm _ellipsoidWgs84TextureCoordinates ( normalMC . zyx ) ;
vec2 textureCoordinates = mix ( ellipsoidTextureCoordinates , ellipsoidFlippedTextureCoordinates , czm _morphTime * smoothstep ( 0.9 , 0.95 , normalMC . z ) ) ;
color = computeWaterColor ( v _positionEC , textureCoordinates , enuToEye , color , mask , fade ) ;
}
# endif
# ifdef APPLY _MATERIAL
czm _materialInput materialInput ;
materialInput . st = v _textureCoordinates . st ;
materialInput . normalEC = normalize ( v _normalEC ) ;
materialInput . positionToEyeEC = - v _positionEC ;
materialInput . tangentToEyeMatrix = czm _eastNorthUpToEyeCoordinates ( v _positionMC , normalize ( v _normalEC ) ) ;
materialInput . slope = v _slope ;
materialInput . height = v _height ;
materialInput . aspect = v _aspect ;
czm _material material = czm _getMaterial ( materialInput ) ;
vec4 materialColor = vec4 ( material . diffuse , material . alpha ) ;
color = alphaBlend ( materialColor , color ) ;
# endif
# ifdef ENABLE _VERTEX _LIGHTING
float diffuseIntensity = clamp ( czm _getLambertDiffuse ( czm _lightDirectionEC , normalize ( v _normalEC ) ) * u _lambertDiffuseMultiplier + u _vertexShadowDarkness , 0.0 , 1.0 ) ;
vec4 finalColor = vec4 ( color . rgb * czm _lightColor * diffuseIntensity , color . a ) ;
# elif defined ( ENABLE _DAYNIGHT _SHADING )
float diffuseIntensity = clamp ( czm _getLambertDiffuse ( czm _lightDirectionEC , normalEC ) * 5.0 + 0.3 , 0.0 , 1.0 ) ;
diffuseIntensity = mix ( 1.0 , diffuseIntensity , fade ) ;
vec4 finalColor = vec4 ( color . rgb * czm _lightColor * diffuseIntensity , color . a ) ;
# else
vec4 finalColor = color ;
# endif
# ifdef ENABLE _CLIPPING _PLANES
vec4 clippingPlanesEdgeColor = vec4 ( 1.0 ) ;
clippingPlanesEdgeColor . rgb = u _clippingPlanesEdgeStyle . rgb ;
float clippingPlanesEdgeWidth = u _clippingPlanesEdgeStyle . a ;
if ( clipDistance < clippingPlanesEdgeWidth )
{
finalColor = clippingPlanesEdgeColor ;
}
# endif
# ifdef HIGHLIGHT _FILL _TILE
finalColor = vec4 ( mix ( finalColor . rgb , u _fillHighlightColor . rgb , u _fillHighlightColor . a ) , finalColor . a ) ;
# endif
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING _FROM _SUN )
vec3 atmosphereLightDirection = czm _sunDirectionWC ;
# else
vec3 atmosphereLightDirection = czm _lightDirectionWC ;
# endif
# if defined ( GROUND _ATMOSPHERE ) || defined ( FOG )
if ( ! czm _backFacing ( ) )
{
bool dynamicLighting = false ;
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING ) && ( defined ( ENABLE _DAYNIGHT _SHADING ) || defined ( ENABLE _VERTEX _LIGHTING ) )
dynamicLighting = true ;
# endif
vec3 rayleighColor ;
vec3 mieColor ;
float opacity ;
vec3 positionWC ;
vec3 lightDirection ;
// When the camera is far away (camera distance > nightFadeOutDistance), the scattering is computed in the fragment shader.
// Otherwise, the scattering is computed in the vertex shader.
# ifdef PER _FRAGMENT _GROUND _ATMOSPHERE
positionWC = computeEllipsoidPosition ( ) ;
lightDirection = czm _branchFreeTernary ( dynamicLighting , atmosphereLightDirection , normalize ( positionWC ) ) ;
computeAtmosphereScattering (
positionWC ,
lightDirection ,
rayleighColor ,
mieColor ,
opacity
) ;
# else
positionWC = v _positionMC ;
lightDirection = czm _branchFreeTernary ( dynamicLighting , atmosphereLightDirection , normalize ( positionWC ) ) ;
rayleighColor = v _atmosphereRayleighColor ;
mieColor = v _atmosphereMieColor ;
opacity = v _atmosphereOpacity ;
# endif
rayleighColor = colorCorrect ( rayleighColor ) ;
mieColor = colorCorrect ( mieColor ) ;
vec4 groundAtmosphereColor = computeAtmosphereColor ( positionWC , lightDirection , rayleighColor , mieColor , opacity ) ;
// Fog is applied to tiles selected for fog, close to the Earth.
# ifdef FOG
vec3 fogColor = groundAtmosphereColor . rgb ;
// If there is lighting, apply that to the fog.
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING ) && ( defined ( ENABLE _VERTEX _LIGHTING ) || defined ( ENABLE _DAYNIGHT _SHADING ) )
float darken = clamp ( dot ( normalize ( czm _viewerPositionWC ) , atmosphereLightDirection ) , u _minimumBrightness , 1.0 ) ;
fogColor *= darken ;
# endif
# ifndef HDR
fogColor . rgb = czm _acesTonemapping ( fogColor . rgb ) ;
fogColor . rgb = czm _inverseGamma ( fogColor . rgb ) ;
# endif
const float modifier = 0.15 ;
finalColor = vec4 ( czm _fog ( v _distance , finalColor . rgb , fogColor . rgb , modifier ) , finalColor . a ) ;
# else
// The transmittance is based on optical depth i.e. the length of segment of the ray inside the atmosphere.
// This value is larger near the "circumference", as it is further away from the camera. We use it to
// brighten up that area of the ground atmosphere.
const float transmittanceModifier = 0.5 ;
float transmittance = transmittanceModifier + clamp ( 1.0 - groundAtmosphereColor . a , 0.0 , 1.0 ) ;
vec3 finalAtmosphereColor = finalColor . rgb + groundAtmosphereColor . rgb * transmittance ;
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING ) && ( defined ( ENABLE _VERTEX _LIGHTING ) || defined ( ENABLE _DAYNIGHT _SHADING ) )
float fadeInDist = u _nightFadeDistance . x ;
float fadeOutDist = u _nightFadeDistance . y ;
float sunlitAtmosphereIntensity = clamp ( ( cameraDist - fadeOutDist ) / ( fadeInDist - fadeOutDist ) , 0.05 , 1.0 ) ;
float darken = clamp ( dot ( normalize ( positionWC ) , atmosphereLightDirection ) , 0.0 , 1.0 ) ;
vec3 darkenendGroundAtmosphereColor = mix ( groundAtmosphereColor . rgb , finalAtmosphereColor . rgb , darken ) ;
finalAtmosphereColor = mix ( darkenendGroundAtmosphereColor , finalAtmosphereColor , sunlitAtmosphereIntensity ) ;
# endif
# ifndef HDR
finalAtmosphereColor . rgb = vec3 ( 1.0 ) - exp ( - fExposure * finalAtmosphereColor . rgb ) ;
# else
finalAtmosphereColor . rgb = czm _saturation ( finalAtmosphereColor . rgb , 1.6 ) ;
# endif
finalColor . rgb = mix ( finalColor . rgb , finalAtmosphereColor . rgb , fade ) ;
# endif
}
# endif
# ifdef UNDERGROUND _COLOR
if ( czm _backFacing ( ) )
{
float distanceFromEllipsoid = max ( czm _eyeHeight , 0.0 ) ;
float distance = max ( v _distance - distanceFromEllipsoid , 0.0 ) ;
float blendAmount = interpolateByDistance ( u _undergroundColorAlphaByDistance , distance ) ;
vec4 undergroundColor = vec4 ( u _undergroundColor . rgb , u _undergroundColor . a * blendAmount ) ;
finalColor = alphaBlend ( undergroundColor , finalColor ) ;
}
# endif
# ifdef TRANSLUCENT
if ( inTranslucencyRectangle ( ) )
{
vec4 alphaByDistance = gl _FrontFacing ? u _frontFaceAlphaByDistance : u _backFaceAlphaByDistance ;
finalColor . a *= interpolateByDistance ( alphaByDistance , v _distance ) ;
}
# endif
gl _FragColor = finalColor ;
}
# ifdef SHOW _REFLECTIVE _OCEAN
float waveFade ( float edge0 , float edge1 , float x )
{
float y = clamp ( ( x - edge0 ) / ( edge1 - edge0 ) , 0.0 , 1.0 ) ;
return pow ( 1.0 - y , 5.0 ) ;
}
float linearFade ( float edge0 , float edge1 , float x )
{
return clamp ( ( x - edge0 ) / ( edge1 - edge0 ) , 0.0 , 1.0 ) ;
}
// Based on water rendering by Jonas Wagner:
// http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog
// low altitude wave settings
const float oceanFrequencyLowAltitude = 825000.0 ;
const float oceanAnimationSpeedLowAltitude = 0.004 ;
const float oceanOneOverAmplitudeLowAltitude = 1.0 / 2.0 ;
const float oceanSpecularIntensity = 0.5 ;
// high altitude wave settings
const float oceanFrequencyHighAltitude = 125000.0 ;
const float oceanAnimationSpeedHighAltitude = 0.008 ;
const float oceanOneOverAmplitudeHighAltitude = 1.0 / 2.0 ;
vec4 computeWaterColor ( vec3 positionEyeCoordinates , vec2 textureCoordinates , mat3 enuToEye , vec4 imageryColor , float maskValue , float fade )
{
vec3 positionToEyeEC = - positionEyeCoordinates ;
float positionToEyeECLength = length ( positionToEyeEC ) ;
// The double normalize below works around a bug in Firefox on Android devices.
vec3 normalizedPositionToEyeEC = normalize ( normalize ( positionToEyeEC ) ) ;
// Fade out the waves as the camera moves far from the surface.
float waveIntensity = waveFade ( 70000.0 , 1000000.0 , positionToEyeECLength ) ;
# ifdef SHOW _OCEAN _WAVES
// high altitude waves
float time = czm _frameNumber * oceanAnimationSpeedHighAltitude ;
vec4 noise = czm _getWaterNoise ( u _oceanNormalMap , textureCoordinates * oceanFrequencyHighAltitude , time , 0.0 ) ;
vec3 normalTangentSpaceHighAltitude = vec3 ( noise . xy , noise . z * oceanOneOverAmplitudeHighAltitude ) ;
// low altitude waves
time = czm _frameNumber * oceanAnimationSpeedLowAltitude ;
noise = czm _getWaterNoise ( u _oceanNormalMap , textureCoordinates * oceanFrequencyLowAltitude , time , 0.0 ) ;
vec3 normalTangentSpaceLowAltitude = vec3 ( noise . xy , noise . z * oceanOneOverAmplitudeLowAltitude ) ;
// blend the 2 wave layers based on distance to surface
float highAltitudeFade = linearFade ( 0.0 , 60000.0 , positionToEyeECLength ) ;
float lowAltitudeFade = 1.0 - linearFade ( 20000.0 , 60000.0 , positionToEyeECLength ) ;
vec3 normalTangentSpace =
( highAltitudeFade * normalTangentSpaceHighAltitude ) +
( lowAltitudeFade * normalTangentSpaceLowAltitude ) ;
normalTangentSpace = normalize ( normalTangentSpace ) ;
// fade out the normal perturbation as we move farther from the water surface
normalTangentSpace . xy *= waveIntensity ;
normalTangentSpace = normalize ( normalTangentSpace ) ;
# else
vec3 normalTangentSpace = vec3 ( 0.0 , 0.0 , 1.0 ) ;
# endif
vec3 normalEC = enuToEye * normalTangentSpace ;
const vec3 waveHighlightColor = vec3 ( 0.3 , 0.45 , 0.6 ) ;
// Use diffuse light to highlight the waves
float diffuseIntensity = czm _getLambertDiffuse ( czm _lightDirectionEC , normalEC ) * maskValue ;
vec3 diffuseHighlight = waveHighlightColor * diffuseIntensity * ( 1.0 - fade ) ;
# ifdef SHOW _OCEAN _WAVES
// Where diffuse light is low or non-existent, use wave highlights based solely on
// the wave bumpiness and no particular light direction.
float tsPerturbationRatio = normalTangentSpace . z ;
vec3 nonDiffuseHighlight = mix ( waveHighlightColor * 5.0 * ( 1.0 - tsPerturbationRatio ) , vec3 ( 0.0 ) , diffuseIntensity ) ;
# else
vec3 nonDiffuseHighlight = vec3 ( 0.0 ) ;
# endif
// Add specular highlights in 3D, and in all modes when zoomed in.
float specularIntensity = czm _getSpecular ( czm _lightDirectionEC , normalizedPositionToEyeEC , normalEC , 10.0 ) ;
float surfaceReflectance = mix ( 0.0 , mix ( u _zoomedOutOceanSpecularIntensity , oceanSpecularIntensity , waveIntensity ) , maskValue ) ;
float specular = specularIntensity * surfaceReflectance ;
# ifdef HDR
specular *= 1.4 ;
float e = 0.2 ;
float d = 3.3 ;
float c = 1.7 ;
vec3 color = imageryColor . rgb + ( c * ( vec3 ( e ) + imageryColor . rgb * d ) * ( diffuseHighlight + nonDiffuseHighlight + specular ) ) ;
# else
vec3 color = imageryColor . rgb + diffuseHighlight + nonDiffuseHighlight + specular ;
# endif
return vec4 ( color , imageryColor . a ) ;
}
# endif // #ifdef SHOW_REFLECTIVE_OCEAN
` ,Lue= ` # ifdef QUANTIZATION _BITS12
attribute vec4 compressed0 ;
attribute float compressed1 ;
# else
attribute vec4 position3DAndHeight ;
attribute vec4 textureCoordAndEncodedNormals ;
# endif
# ifdef GEODETIC _SURFACE _NORMALS
attribute vec3 geodeticSurfaceNormal ;
# endif
# ifdef EXAGGERATION
uniform vec2 u _terrainExaggerationAndRelativeHeight ;
# endif
uniform vec3 u _center3D ;
uniform mat4 u _modifiedModelView ;
uniform mat4 u _modifiedModelViewProjection ;
uniform vec4 u _tileRectangle ;
// Uniforms for 2D Mercator projection
uniform vec2 u _southAndNorthLatitude ;
uniform vec2 u _southMercatorYAndOneOverHeight ;
varying vec3 v _positionMC ;
varying vec3 v _positionEC ;
varying vec3 v _textureCoordinates ;
varying vec3 v _normalMC ;
varying vec3 v _normalEC ;
# ifdef APPLY _MATERIAL
varying float v _slope ;
varying float v _aspect ;
varying float v _height ;
# endif
# if defined ( FOG ) || defined ( GROUND _ATMOSPHERE ) || defined ( UNDERGROUND _COLOR ) || defined ( TRANSLUCENT )
varying float v _distance ;
# endif
# if defined ( FOG ) || defined ( GROUND _ATMOSPHERE )
varying vec3 v _atmosphereRayleighColor ;
varying vec3 v _atmosphereMieColor ;
varying float v _atmosphereOpacity ;
# endif
// These functions are generated at runtime.
vec4 getPosition ( vec3 position , float height , vec2 textureCoordinates ) ;
float get2DYPositionFraction ( vec2 textureCoordinates ) ;
vec4 getPosition3DMode ( vec3 position , float height , vec2 textureCoordinates )
{
return u _modifiedModelViewProjection * vec4 ( position , 1.0 ) ;
}
float get2DMercatorYPositionFraction ( vec2 textureCoordinates )
{
// The width of a tile at level 11, in radians and assuming a single root tile, is
// 2.0 * czm_pi / pow(2.0, 11.0)
// We want to just linearly interpolate the 2D position from the texture coordinates
// when we're at this level or higher. The constant below is the expression
// above evaluated and then rounded up at the 4th significant digit.
const float maxTileWidth = 0.003068 ;
float positionFraction = textureCoordinates . y ;
float southLatitude = u _southAndNorthLatitude . x ;
float northLatitude = u _southAndNorthLatitude . y ;
if ( northLatitude - southLatitude > maxTileWidth )
{
float southMercatorY = u _southMercatorYAndOneOverHeight . x ;
float oneOverMercatorHeight = u _southMercatorYAndOneOverHeight . y ;
float currentLatitude = mix ( southLatitude , northLatitude , textureCoordinates . y ) ;
currentLatitude = clamp ( currentLatitude , - czm _webMercatorMaxLatitude , czm _webMercatorMaxLatitude ) ;
positionFraction = czm _latitudeToWebMercatorFraction ( currentLatitude , southMercatorY , oneOverMercatorHeight ) ;
}
return positionFraction ;
}
float get2DGeographicYPositionFraction ( vec2 textureCoordinates )
{
return textureCoordinates . y ;
}
vec4 getPositionPlanarEarth ( vec3 position , float height , vec2 textureCoordinates )
{
float yPositionFraction = get2DYPositionFraction ( textureCoordinates ) ;
vec4 rtcPosition2D = vec4 ( height , mix ( u _tileRectangle . st , u _tileRectangle . pq , vec2 ( textureCoordinates . x , yPositionFraction ) ) , 1.0 ) ;
return u _modifiedModelViewProjection * rtcPosition2D ;
}
vec4 getPosition2DMode ( vec3 position , float height , vec2 textureCoordinates )
{
return getPositionPlanarEarth ( position , 0.0 , textureCoordinates ) ;
}
vec4 getPositionColumbusViewMode ( vec3 position , float height , vec2 textureCoordinates )
{
return getPositionPlanarEarth ( position , height , textureCoordinates ) ;
}
vec4 getPositionMorphingMode ( vec3 position , float height , vec2 textureCoordinates )
{
// We do not do RTC while morphing, so there is potential for jitter.
// This is unlikely to be noticeable, though.
vec3 position3DWC = position + u _center3D ;
float yPositionFraction = get2DYPositionFraction ( textureCoordinates ) ;
vec4 position2DWC = vec4 ( height , mix ( u _tileRectangle . st , u _tileRectangle . pq , vec2 ( textureCoordinates . x , yPositionFraction ) ) , 1.0 ) ;
vec4 morphPosition = czm _columbusViewMorph ( position2DWC , vec4 ( position3DWC , 1.0 ) , czm _morphTime ) ;
return czm _modelViewProjection * morphPosition ;
}
# ifdef QUANTIZATION _BITS12
uniform vec2 u _minMaxHeight ;
uniform mat4 u _scaleAndBias ;
# endif
void main ( )
{
# ifdef QUANTIZATION _BITS12
vec2 xy = czm _decompressTextureCoordinates ( compressed0 . x ) ;
vec2 zh = czm _decompressTextureCoordinates ( compressed0 . y ) ;
vec3 position = vec3 ( xy , zh . x ) ;
float height = zh . y ;
vec2 textureCoordinates = czm _decompressTextureCoordinates ( compressed0 . z ) ;
height = height * ( u _minMaxHeight . y - u _minMaxHeight . x ) + u _minMaxHeight . x ;
position = ( u _scaleAndBias * vec4 ( position , 1.0 ) ) . xyz ;
# if ( defined ( ENABLE _VERTEX _LIGHTING ) || defined ( GENERATE _POSITION _AND _NORMAL ) ) && defined ( INCLUDE _WEB _MERCATOR _Y )
float webMercatorT = czm _decompressTextureCoordinates ( compressed0 . w ) . x ;
float encodedNormal = compressed1 ;
# elif defined ( INCLUDE _WEB _MERCATOR _Y )
float webMercatorT = czm _decompressTextureCoordinates ( compressed0 . w ) . x ;
float encodedNormal = 0.0 ;
# elif defined ( ENABLE _VERTEX _LIGHTING ) || defined ( GENERATE _POSITION _AND _NORMAL )
float webMercatorT = textureCoordinates . y ;
float encodedNormal = compressed0 . w ;
# else
float webMercatorT = textureCoordinates . y ;
float encodedNormal = 0.0 ;
# endif
# else
// A single float per element
vec3 position = position3DAndHeight . xyz ;
float height = position3DAndHeight . w ;
vec2 textureCoordinates = textureCoordAndEncodedNormals . xy ;
# if ( defined ( ENABLE _VERTEX _LIGHTING ) || defined ( GENERATE _POSITION _AND _NORMAL ) || defined ( APPLY _MATERIAL ) ) && defined ( INCLUDE _WEB _MERCATOR _Y )
float webMercatorT = textureCoordAndEncodedNormals . z ;
float encodedNormal = textureCoordAndEncodedNormals . w ;
# elif defined ( ENABLE _VERTEX _LIGHTING ) || defined ( GENERATE _POSITION _AND _NORMAL ) || defined ( APPLY _MATERIAL )
float webMercatorT = textureCoordinates . y ;
float encodedNormal = textureCoordAndEncodedNormals . z ;
# elif defined ( INCLUDE _WEB _MERCATOR _Y )
float webMercatorT = textureCoordAndEncodedNormals . z ;
float encodedNormal = 0.0 ;
# else
float webMercatorT = textureCoordinates . y ;
float encodedNormal = 0.0 ;
# endif
# endif
vec3 position3DWC = position + u _center3D ;
# ifdef GEODETIC _SURFACE _NORMALS
vec3 ellipsoidNormal = geodeticSurfaceNormal ;
# else
vec3 ellipsoidNormal = normalize ( position3DWC ) ;
# endif
# if defined ( EXAGGERATION ) && defined ( GEODETIC _SURFACE _NORMALS )
float exaggeration = u _terrainExaggerationAndRelativeHeight . x ;
float relativeHeight = u _terrainExaggerationAndRelativeHeight . y ;
float newHeight = ( height - relativeHeight ) * exaggeration + relativeHeight ;
// stop from going through center of earth
float minRadius = min ( min ( czm _ellipsoidRadii . x , czm _ellipsoidRadii . y ) , czm _ellipsoidRadii . z ) ;
newHeight = max ( newHeight , - minRadius ) ;
vec3 offset = ellipsoidNormal * ( newHeight - height ) ;
position += offset ;
position3DWC += offset ;
height = newHeight ;
# endif
gl _Position = getPosition ( position , height , textureCoordinates ) ;
v _positionEC = ( u _modifiedModelView * vec4 ( position , 1.0 ) ) . xyz ;
v _positionMC = position3DWC ; // position in model coordinates
v _textureCoordinates = vec3 ( textureCoordinates , webMercatorT ) ;
# if defined ( ENABLE _VERTEX _LIGHTING ) || defined ( GENERATE _POSITION _AND _NORMAL ) || defined ( APPLY _MATERIAL )
vec3 normalMC = czm _octDecode ( encodedNormal ) ;
# if defined ( EXAGGERATION ) && defined ( GEODETIC _SURFACE _NORMALS )
vec3 projection = dot ( normalMC , ellipsoidNormal ) * ellipsoidNormal ;
vec3 rejection = normalMC - projection ;
normalMC = normalize ( projection + rejection * exaggeration ) ;
# endif
v _normalMC = normalMC ;
v _normalEC = czm _normal3D * v _normalMC ;
# endif
# if defined ( FOG ) || ( defined ( GROUND _ATMOSPHERE ) && ! defined ( PER _FRAGMENT _GROUND _ATMOSPHERE ) )
bool dynamicLighting = false ;
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING ) && ( defined ( ENABLE _DAYNIGHT _SHADING ) || defined ( ENABLE _VERTEX _LIGHTING ) )
dynamicLighting = true ;
# endif
# if defined ( DYNAMIC _ATMOSPHERE _LIGHTING _FROM _SUN )
vec3 atmosphereLightDirection = czm _sunDirectionWC ;
# else
vec3 atmosphereLightDirection = czm _lightDirectionWC ;
# endif
vec3 lightDirection = czm _branchFreeTernary ( dynamicLighting , atmosphereLightDirection , normalize ( position3DWC ) ) ;
computeAtmosphereScattering (
position3DWC ,
lightDirection ,
v _atmosphereRayleighColor ,
v _atmosphereMieColor ,
v _atmosphereOpacity
) ;
# endif
# if defined ( FOG ) || defined ( GROUND _ATMOSPHERE ) || defined ( UNDERGROUND _COLOR ) || defined ( TRANSLUCENT )
v _distance = length ( ( czm _modelView3D * vec4 ( position3DWC , 1.0 ) ) . xyz ) ;
# endif
# ifdef APPLY _MATERIAL
float northPoleZ = czm _ellipsoidRadii . z ;
vec3 northPolePositionMC = vec3 ( 0.0 , 0.0 , northPoleZ ) ;
vec3 vectorEastMC = normalize ( cross ( northPolePositionMC - v _positionMC , ellipsoidNormal ) ) ;
float dotProd = abs ( dot ( ellipsoidNormal , v _normalMC ) ) ;
v _slope = acos ( dotProd ) ;
vec3 normalRejected = ellipsoidNormal * dotProd ;
vec3 normalProjected = v _normalMC - normalRejected ;
vec3 aspectVector = normalize ( normalProjected ) ;
v _aspect = acos ( dot ( aspectVector , vectorEastMC ) ) ;
float determ = dot ( cross ( vectorEastMC , aspectVector ) , ellipsoidNormal ) ;
v _aspect = czm _branchFreeTernary ( determ < 0.0 , 2.0 * czm _pi - v _aspect , v _aspect ) ;
v _height = height ;
# endif
}
` ,S2= ` void computeAtmosphereScattering ( vec3 positionWC , vec3 lightDirection , out vec3 rayleighColor , out vec3 mieColor , out float opacity ) {
vec3 cameraToPositionWC = positionWC - czm _viewerPositionWC ;
vec3 cameraToPositionWCDirection = normalize ( cameraToPositionWC ) ;
czm _ray primaryRay = czm _ray ( czm _viewerPositionWC , cameraToPositionWCDirection ) ;
float atmosphereInnerRadius = length ( positionWC ) ;
computeScattering (
primaryRay ,
length ( cameraToPositionWC ) ,
lightDirection ,
atmosphereInnerRadius ,
rayleighColor ,
mieColor ,
opacity
) ;
}
` ,Bue= ` varying vec2 v _textureCoordinates ;
uniform float originalSize ;
uniform sampler2D texture0 ;
uniform sampler2D texture1 ;
uniform sampler2D texture2 ;
uniform sampler2D texture3 ;
uniform sampler2D texture4 ;
uniform sampler2D texture5 ;
const float yMipLevel1 = 1.0 - ( 1.0 / pow ( 2.0 , 1.0 ) ) ;
const float yMipLevel2 = 1.0 - ( 1.0 / pow ( 2.0 , 2.0 ) ) ;
const float yMipLevel3 = 1.0 - ( 1.0 / pow ( 2.0 , 3.0 ) ) ;
const float yMipLevel4 = 1.0 - ( 1.0 / pow ( 2.0 , 4.0 ) ) ;
void main ( )
{
vec2 uv = v _textureCoordinates ;
vec2 textureSize = vec2 ( originalSize * 1.5 + 2.0 , originalSize ) ;
vec2 pixel = 1.0 / textureSize ;
float mipLevel = 0.0 ;
if ( uv . x - pixel . x > ( textureSize . y / textureSize . x ) )
{
mipLevel = 1.0 ;
if ( uv . y - pixel . y > yMipLevel1 )
{
mipLevel = 2.0 ;
if ( uv . y - pixel . y * 3.0 > yMipLevel2 )
{
mipLevel = 3.0 ;
if ( uv . y - pixel . y * 5.0 > yMipLevel3 )
{
mipLevel = 4.0 ;
if ( uv . y - pixel . y * 7.0 > yMipLevel4 )
{
mipLevel = 5.0 ;
}
}
}
}
}
if ( mipLevel > 0.0 )
{
float scale = pow ( 2.0 , mipLevel ) ;
uv . y -= ( pixel . y * ( mipLevel - 1.0 ) * 2.0 ) ;
uv . x *= ( ( textureSize . x - 2.0 ) / textureSize . y ) ;
uv . x -= 1.0 + pixel . x ;
uv . y -= ( 1.0 - ( 1.0 / pow ( 2.0 , mipLevel - 1.0 ) ) ) ;
uv *= scale ;
}
else
{
uv . x *= ( textureSize . x / textureSize . y ) ;
}
if ( mipLevel == 0.0 )
{
gl _FragColor = texture2D ( texture0 , uv ) ;
}
else if ( mipLevel == 1.0 )
{
gl _FragColor = texture2D ( texture1 , uv ) ;
}
else if ( mipLevel == 2.0 )
{
gl _FragColor = texture2D ( texture2 , uv ) ;
}
else if ( mipLevel == 3.0 )
{
gl _FragColor = texture2D ( texture3 , uv ) ;
}
else if ( mipLevel == 4.0 )
{
gl _FragColor = texture2D ( texture4 , uv ) ;
}
else if ( mipLevel == 5.0 )
{
gl _FragColor = texture2D ( texture5 , uv ) ;
}
else
{
gl _FragColor = vec4 ( 0.0 ) ;
}
}
` ,Rue= ` varying vec3 v _cubeMapCoordinates ;
uniform samplerCube cubeMap ;
void main ( )
{
vec4 rgba = textureCube ( cubeMap , v _cubeMapCoordinates ) ;
# ifdef RGBA _NORMALIZED
gl _FragColor = vec4 ( rgba . rgb , 1.0 ) ;
# else
float m = rgba . a * 16.0 ;
vec3 r = rgba . rgb * m ;
gl _FragColor = vec4 ( r * r , 1.0 ) ;
# endif
}
` ,Nue= ` attribute vec4 position ;
attribute vec3 cubeMapCoordinates ;
varying vec3 v _cubeMapCoordinates ;
void main ( )
{
gl _Position = position ;
v _cubeMapCoordinates = cubeMapCoordinates ;
}
` ,cb= ` varying vec4 v _color ;
varying vec4 v _outlineColor ;
varying float v _innerPercent ;
varying float v _pixelDistance ;
varying vec4 v _pickColor ;
void main ( )
{
// The distance in UV space from this fragment to the center of the point, at most 0.5.
float distanceToCenter = length ( gl _PointCoord - vec2 ( 0.5 ) ) ;
// The max distance stops one pixel shy of the edge to leave space for anti-aliasing.
float maxDistance = max ( 0.0 , 0.5 - v _pixelDistance ) ;
float wholeAlpha = 1.0 - smoothstep ( maxDistance , 0.5 , distanceToCenter ) ;
float innerAlpha = 1.0 - smoothstep ( maxDistance * v _innerPercent , 0.5 * v _innerPercent , distanceToCenter ) ;
vec4 color = mix ( v _outlineColor , v _color , innerAlpha ) ;
color . a *= wholeAlpha ;
// Fully transparent parts of the billboard are not pickable.
# if ! defined ( OPAQUE ) && ! defined ( TRANSLUCENT )
if ( color . a < 0.005 ) // matches 0/255 and 1/255
{
discard ;
}
# else
// The billboard is rendered twice. The opaque pass discards translucent fragments
// and the translucent pass discards opaque fragments.
# ifdef OPAQUE
if ( color . a < 0.995 ) // matches < 254/255
{
discard ;
}
# else
if ( color . a >= 0.995 ) // matches 254/255 and 255/255
{
discard ;
}
# endif
# endif
gl _FragColor = czm _gammaCorrect ( color ) ;
czm _writeLogDepth ( ) ;
}
` ,Mue= ` uniform float u _maxTotalPointSize ;
attribute vec4 positionHighAndSize ;
attribute vec4 positionLowAndOutline ;
attribute vec4 compressedAttribute0 ; // color, outlineColor, pick color
attribute vec4 compressedAttribute1 ; // show, translucency by distance, some free space
attribute vec4 scaleByDistance ; // near, nearScale, far, farScale
attribute vec3 distanceDisplayConditionAndDisableDepth ; // near, far, disableDepthTestDistance
varying vec4 v _color ;
varying vec4 v _outlineColor ;
varying float v _innerPercent ;
varying float v _pixelDistance ;
varying vec4 v _pickColor ;
const float SHIFT _LEFT8 = 256.0 ;
const float SHIFT _RIGHT8 = 1.0 / 256.0 ;
void main ( )
{
// Modifying this shader may also require modifications to PointPrimitive._computeScreenSpacePosition
// unpack attributes
vec3 positionHigh = positionHighAndSize . xyz ;
vec3 positionLow = positionLowAndOutline . xyz ;
float outlineWidthBothSides = 2.0 * positionLowAndOutline . w ;
float totalSize = positionHighAndSize . w + outlineWidthBothSides ;
float outlinePercent = outlineWidthBothSides / totalSize ;
// Scale in response to browser-zoom.
totalSize *= czm _pixelRatio ;
float temp = compressedAttribute1 . x * SHIFT _RIGHT8 ;
float show = floor ( temp ) ;
# ifdef EYE _DISTANCE _TRANSLUCENCY
vec4 translucencyByDistance ;
translucencyByDistance . x = compressedAttribute1 . z ;
translucencyByDistance . z = compressedAttribute1 . w ;
translucencyByDistance . y = ( ( temp - floor ( temp ) ) * SHIFT _LEFT8 ) / 255.0 ;
temp = compressedAttribute1 . y * SHIFT _RIGHT8 ;
translucencyByDistance . w = ( ( temp - floor ( temp ) ) * SHIFT _LEFT8 ) / 255.0 ;
# endif
///////////////////////////////////////////////////////////////////////////
vec4 color ;
vec4 outlineColor ;
vec4 pickColor ;
// compressedAttribute0.z => pickColor.rgb
temp = compressedAttribute0 . z * SHIFT _RIGHT8 ;
pickColor . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
pickColor . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
pickColor . r = floor ( temp ) ;
// compressedAttribute0.x => color.rgb
temp = compressedAttribute0 . x * SHIFT _RIGHT8 ;
color . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
color . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
color . r = floor ( temp ) ;
// compressedAttribute0.y => outlineColor.rgb
temp = compressedAttribute0 . y * SHIFT _RIGHT8 ;
outlineColor . b = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
outlineColor . g = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
outlineColor . r = floor ( temp ) ;
// compressedAttribute0.w => color.a, outlineColor.a, pickColor.a
temp = compressedAttribute0 . w * SHIFT _RIGHT8 ;
pickColor . a = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
pickColor = pickColor / 255.0 ;
temp = floor ( temp ) * SHIFT _RIGHT8 ;
outlineColor . a = ( temp - floor ( temp ) ) * SHIFT _LEFT8 ;
outlineColor /= 255.0 ;
color . a = floor ( temp ) ;
color /= 255.0 ;
///////////////////////////////////////////////////////////////////////////
vec4 p = czm _translateRelativeToEye ( positionHigh , positionLow ) ;
vec4 positionEC = czm _modelViewRelativeToEye * p ;
///////////////////////////////////////////////////////////////////////////
# if defined ( EYE _DISTANCE _SCALING ) || defined ( EYE _DISTANCE _TRANSLUCENCY ) || defined ( DISTANCE _DISPLAY _CONDITION ) || defined ( DISABLE _DEPTH _DISTANCE )
float lengthSq ;
if ( czm _sceneMode == czm _sceneMode2D )
{
// 2D camera distance is a special case
// treat all billboards as flattened to the z=0.0 plane
lengthSq = czm _eyeHeight2D . y ;
}
else
{
lengthSq = dot ( positionEC . xyz , positionEC . xyz ) ;
}
# endif
# ifdef EYE _DISTANCE _SCALING
totalSize *= czm _nearFarScalar ( scaleByDistance , lengthSq ) ;
# endif
if ( totalSize > 0.0 ) {
// Add padding for anti-aliasing on both sides.
totalSize += 3.0 ;
}
// Clamp to max point size.
totalSize = min ( totalSize , u _maxTotalPointSize ) ;
// If size is too small, push vertex behind near plane for clipping.
// Note that context.minimumAliasedPointSize "will be at most 1.0".
if ( totalSize < 1.0 )
{
positionEC . xyz = vec3 ( 0.0 ) ;
totalSize = 1.0 ;
}
float translucency = 1.0 ;
# ifdef EYE _DISTANCE _TRANSLUCENCY
translucency = czm _nearFarScalar ( translucencyByDistance , lengthSq ) ;
// push vertex behind near plane for clipping
if ( translucency < 0.004 )
{
positionEC . xyz = vec3 ( 0.0 ) ;
}
# endif
# ifdef DISTANCE _DISPLAY _CONDITION
float nearSq = distanceDisplayConditionAndDisableDepth . x ;
float farSq = distanceDisplayConditionAndDisableDepth . y ;
if ( lengthSq < nearSq || lengthSq > farSq ) {
// push vertex behind camera to force it to be clipped
positionEC . xyz = vec3 ( 0.0 , 0.0 , 1.0 ) ;
}
# endif
gl _Position = czm _projection * positionEC ;
czm _vertexLogDepth ( ) ;
# ifdef DISABLE _DEPTH _DISTANCE
float disableDepthTestDistance = distanceDisplayConditionAndDisableDepth . z ;
if ( disableDepthTestDistance == 0.0 && czm _minimumDisableDepthTestDistance != 0.0 )
{
disableDepthTestDistance = czm _minimumDisableDepthTestDistance ;
}
if ( disableDepthTestDistance != 0.0 )
{
// Don't try to "multiply both sides" by w. Greater/less-than comparisons won't work for negative values of w.
float zclip = gl _Position . z / gl _Position . w ;
bool clipped = ( zclip < - 1.0 || zclip > 1.0 ) ;
if ( ! clipped && ( disableDepthTestDistance < 0.0 || ( lengthSq > 0.0 && lengthSq < disableDepthTestDistance ) ) )
{
// Position z on the near plane.
gl _Position . z = - gl _Position . w ;
# ifdef LOG _DEPTH
czm _vertexLogDepth ( vec4 ( czm _currentFrustum . x ) ) ;
# endif
}
}
# endif
v _color = color ;
v _color . a *= translucency * show ;
v _outlineColor = outlineColor ;
v _outlineColor . a *= translucency * show ;
v _innerPercent = 1.0 - outlinePercent ;
v _pixelDistance = 2.0 / totalSize ;
gl _PointSize = totalSize * show ;
gl _Position *= show ;
v _pickColor = pickColor ;
}
` ,kC= ` void clipLineSegmentToNearPlane (
vec3 p0 ,
vec3 p1 ,
out vec4 positionWC ,
out bool clipped ,
out bool culledByNearPlane ,
out vec4 clippedPositionEC )
{
culledByNearPlane = false ;
clipped = false ;
vec3 p0ToP1 = p1 - p0 ;
float magnitude = length ( p0ToP1 ) ;
vec3 direction = normalize ( p0ToP1 ) ;
// Distance that p0 is behind the near plane. Negative means p0 is
// in front of the near plane.
float endPoint0Distance = czm _currentFrustum . x + p0 . z ;
// Camera looks down -Z.
// When moving a point along +Z: LESS VISIBLE
// * Points in front of the camera move closer to the camera.
// * Points behind the camrea move farther away from the camera.
// When moving a point along -Z: MORE VISIBLE
// * Points in front of the camera move farther away from the camera.
// * Points behind the camera move closer to the camera.
// Positive denominator: -Z, becoming more visible
// Negative denominator: +Z, becoming less visible
// Nearly zero: parallel to near plane
float denominator = - direction . z ;
if ( endPoint0Distance > 0.0 && abs ( denominator ) < czm _epsilon7 )
{
// p0 is behind the near plane and the line to p1 is nearly parallel to
// the near plane, so cull the segment completely.
culledByNearPlane = true ;
}
else if ( endPoint0Distance > 0.0 )
{
// p0 is behind the near plane, and the line to p1 is moving distinctly
// toward or away from it.
// t = (-plane distance - dot(plane normal, ray origin)) / dot(plane normal, ray direction)
float t = endPoint0Distance / denominator ;
if ( t < 0.0 || t > magnitude )
{
// Near plane intersection is not between the two points.
// We already confirmed p0 is behind the naer plane, so now
// we know the entire segment is behind it.
culledByNearPlane = true ;
}
else
{
// Segment crosses the near plane, update p0 to lie exactly on it.
p0 = p0 + t * direction ;
// Numerical noise might put us a bit on the wrong side of the near plane.
// Don't let that happen.
p0 . z = min ( p0 . z , - czm _currentFrustum . x ) ;
clipped = true ;
}
}
clippedPositionEC = vec4 ( p0 , 1.0 ) ;
positionWC = czm _eyeToWindowCoordinates ( clippedPositionEC ) ;
}
vec4 getPolylineWindowCoordinatesEC ( vec4 positionEC , vec4 prevEC , vec4 nextEC , float expandDirection , float width , bool usePrevious , out float angle )
{
// expandDirection +1 is to the _left_ when looking from positionEC toward nextEC.
# ifdef POLYLINE _DASH
// Compute the window coordinates of the points.
vec4 positionWindow = czm _eyeToWindowCoordinates ( positionEC ) ;
vec4 previousWindow = czm _eyeToWindowCoordinates ( prevEC ) ;
vec4 nextWindow = czm _eyeToWindowCoordinates ( nextEC ) ;
// Determine the relative screen space direction of the line.
vec2 lineDir ;
if ( usePrevious ) {
lineDir = normalize ( positionWindow . xy - previousWindow . xy ) ;
}
else {
lineDir = normalize ( nextWindow . xy - positionWindow . xy ) ;
}
angle = atan ( lineDir . x , lineDir . y ) - 1.570796327 ; // precomputed atan(1,0)
// Quantize the angle so it doesn't change rapidly between segments.
angle = floor ( angle / czm _piOverFour + 0.5 ) * czm _piOverFour ;
# endif
vec4 clippedPrevWC , clippedPrevEC ;
bool prevSegmentClipped , prevSegmentCulled ;
clipLineSegmentToNearPlane ( prevEC . xyz , positionEC . xyz , clippedPrevWC , prevSegmentClipped , prevSegmentCulled , clippedPrevEC ) ;
vec4 clippedNextWC , clippedNextEC ;
bool nextSegmentClipped , nextSegmentCulled ;
clipLineSegmentToNearPlane ( nextEC . xyz , positionEC . xyz , clippedNextWC , nextSegmentClipped , nextSegmentCulled , clippedNextEC ) ;
bool segmentClipped , segmentCulled ;
vec4 clippedPositionWC , clippedPositionEC ;
clipLineSegmentToNearPlane ( positionEC . xyz , usePrevious ? prevEC . xyz : nextEC . xyz , clippedPositionWC , segmentClipped , segmentCulled , clippedPositionEC ) ;
if ( segmentCulled )
{
return vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
}
vec2 directionToPrevWC = normalize ( clippedPrevWC . xy - clippedPositionWC . xy ) ;
vec2 directionToNextWC = normalize ( clippedNextWC . xy - clippedPositionWC . xy ) ;
// If a segment was culled, we can't use the corresponding direction
// computed above. We should never see both of these be true without
// \`segmentCulled\` above also being true.
if ( prevSegmentCulled )
{
directionToPrevWC = - directionToNextWC ;
}
else if ( nextSegmentCulled )
{
directionToNextWC = - directionToPrevWC ;
}
vec2 thisSegmentForwardWC , otherSegmentForwardWC ;
if ( usePrevious )
{
thisSegmentForwardWC = - directionToPrevWC ;
otherSegmentForwardWC = directionToNextWC ;
}
else
{
thisSegmentForwardWC = directionToNextWC ;
otherSegmentForwardWC = - directionToPrevWC ;
}
vec2 thisSegmentLeftWC = vec2 ( - thisSegmentForwardWC . y , thisSegmentForwardWC . x ) ;
vec2 leftWC = thisSegmentLeftWC ;
float expandWidth = width * 0.5 ;
// When lines are split at the anti-meridian, the position may be at the
// same location as the next or previous position, and we need to handle
// that to avoid producing NaNs.
if ( ! czm _equalsEpsilon ( prevEC . xyz - positionEC . xyz , vec3 ( 0.0 ) , czm _epsilon1 ) && ! czm _equalsEpsilon ( nextEC . xyz - positionEC . xyz , vec3 ( 0.0 ) , czm _epsilon1 ) )
{
vec2 otherSegmentLeftWC = vec2 ( - otherSegmentForwardWC . y , otherSegmentForwardWC . x ) ;
vec2 leftSumWC = thisSegmentLeftWC + otherSegmentLeftWC ;
float leftSumLength = length ( leftSumWC ) ;
leftWC = leftSumLength < czm _epsilon6 ? thisSegmentLeftWC : ( leftSumWC / leftSumLength ) ;
// The sine of the angle between the two vectors is given by the formula
// |a x b| = |a||b|sin(theta)
// which is
// float sinAngle = length(cross(vec3(leftWC, 0.0), vec3(-thisSegmentForwardWC, 0.0)));
// Because the z components of both vectors are zero, the x and y coordinate will be zero.
// Therefore, the sine of the angle is just the z component of the cross product.
vec2 u = - thisSegmentForwardWC ;
vec2 v = leftWC ;
float sinAngle = abs ( u . x * v . y - u . y * v . x ) ;
expandWidth = clamp ( expandWidth / sinAngle , 0.0 , width * 2.0 ) ;
}
vec2 offset = leftWC * expandDirection * expandWidth * czm _pixelRatio ;
return vec4 ( clippedPositionWC . xy + offset , - clippedPositionWC . z , 1.0 ) * ( czm _projection * clippedPositionEC ) . w ;
}
vec4 getPolylineWindowCoordinates ( vec4 position , vec4 previous , vec4 next , float expandDirection , float width , bool usePrevious , out float angle )
{
vec4 positionEC = czm _modelViewRelativeToEye * position ;
vec4 prevEC = czm _modelViewRelativeToEye * previous ;
vec4 nextEC = czm _modelViewRelativeToEye * next ;
return getPolylineWindowCoordinatesEC ( positionEC , prevEC , nextEC , expandDirection , width , usePrevious , angle ) ;
}
` ,u6= ` # ifdef VECTOR _TILE
uniform vec4 u _highlightColor ;
# endif
varying vec2 v _st ;
void main ( )
{
czm _materialInput materialInput ;
vec2 st = v _st ;
st . t = czm _readNonPerspective ( st . t , gl _FragCoord . w ) ;
materialInput . s = st . s ;
materialInput . st = st ;
materialInput . str = vec3 ( st , 0.0 ) ;
czm _material material = czm _getMaterial ( materialInput ) ;
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# ifdef VECTOR _TILE
gl _FragColor *= u _highlightColor ;
# endif
czm _writeLogDepth ( ) ;
}
` ,Fue= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
varying vec4 v _startPlaneNormalEcAndHalfWidth ;
varying vec4 v _endPlaneNormalEcAndBatchId ;
varying vec4 v _rightPlaneEC ; // Technically can compute distance for this here
varying vec4 v _endEcAndStartEcX ;
varying vec4 v _texcoordNormalizationAndStartEcYZ ;
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# endif
void main ( void )
{
float logDepthOrDepth = czm _branchFreeTernary ( czm _sceneMode == czm _sceneMode2D , gl _FragCoord . z , czm _unpackDepth ( texture2D ( czm _globeDepthTexture , gl _FragCoord . xy / czm _viewport . zw ) ) ) ;
vec3 ecStart = vec3 ( v _endEcAndStartEcX . w , v _texcoordNormalizationAndStartEcYZ . zw ) ;
// Discard for sky
if ( logDepthOrDepth == 0.0 ) {
# ifdef DEBUG _SHOW _VOLUME
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 0.5 ) ;
return ;
# else // DEBUG_SHOW_VOLUME
discard ;
# endif // DEBUG_SHOW_VOLUME
}
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , logDepthOrDepth ) ;
eyeCoordinate /= eyeCoordinate . w ;
float halfMaxWidth = v _startPlaneNormalEcAndHalfWidth . w * czm _metersPerPixel ( eyeCoordinate ) ;
// Check distance of the eye coordinate against the right-facing plane
float widthwiseDistance = czm _planeDistance ( v _rightPlaneEC , eyeCoordinate . xyz ) ;
// Check eye coordinate against the mitering planes
float distanceFromStart = czm _planeDistance ( v _startPlaneNormalEcAndHalfWidth . xyz , - dot ( ecStart , v _startPlaneNormalEcAndHalfWidth . xyz ) , eyeCoordinate . xyz ) ;
float distanceFromEnd = czm _planeDistance ( v _endPlaneNormalEcAndBatchId . xyz , - dot ( v _endEcAndStartEcX . xyz , v _endPlaneNormalEcAndBatchId . xyz ) , eyeCoordinate . xyz ) ;
if ( abs ( widthwiseDistance ) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0 ) {
# ifdef DEBUG _SHOW _VOLUME
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 0.5 ) ;
return ;
# else // DEBUG_SHOW_VOLUME
discard ;
# endif // DEBUG_SHOW_VOLUME
}
// Check distance of the eye coordinate against start and end planes with normals in the right plane.
// For computing unskewed lengthwise texture coordinate.
// Can also be used for clipping extremely pointy miters, but in practice unnecessary because of miter breaking.
// aligned plane: cross the right plane normal with miter plane normal, then cross the result with right again to point it more "forward"
vec3 alignedPlaneNormal ;
// start aligned plane
alignedPlaneNormal = cross ( v _rightPlaneEC . xyz , v _startPlaneNormalEcAndHalfWidth . xyz ) ;
alignedPlaneNormal = normalize ( cross ( alignedPlaneNormal , v _rightPlaneEC . xyz ) ) ;
distanceFromStart = czm _planeDistance ( alignedPlaneNormal , - dot ( alignedPlaneNormal , ecStart ) , eyeCoordinate . xyz ) ;
// end aligned plane
alignedPlaneNormal = cross ( v _rightPlaneEC . xyz , v _endPlaneNormalEcAndBatchId . xyz ) ;
alignedPlaneNormal = normalize ( cross ( alignedPlaneNormal , v _rightPlaneEC . xyz ) ) ;
distanceFromEnd = czm _planeDistance ( alignedPlaneNormal , - dot ( alignedPlaneNormal , v _endEcAndStartEcX . xyz ) , eyeCoordinate . xyz ) ;
# ifdef PER _INSTANCE _COLOR
gl _FragColor = czm _gammaCorrect ( v _color ) ;
# else // PER_INSTANCE_COLOR
// Clamp - distance to aligned planes may be negative due to mitering,
// so fragment texture coordinate might be out-of-bounds.
float s = clamp ( distanceFromStart / ( distanceFromStart + distanceFromEnd ) , 0.0 , 1.0 ) ;
s = ( s * v _texcoordNormalizationAndStartEcYZ . x ) + v _texcoordNormalizationAndStartEcYZ . y ;
float t = ( widthwiseDistance + halfMaxWidth ) / ( 2.0 * halfMaxWidth ) ;
czm _materialInput materialInput ;
materialInput . s = s ;
materialInput . st = vec2 ( s , t ) ;
materialInput . str = vec3 ( s , t , 0.0 ) ;
czm _material material = czm _getMaterial ( materialInput ) ;
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# endif // PER_INSTANCE_COLOR
// Premultiply alpha. Required for classification primitives on translucent globe.
gl _FragColor . rgb *= gl _FragColor . a ;
czm _writeDepthClamp ( ) ;
}
` ,zue= ` varying vec3 v _forwardDirectionEC ;
varying vec3 v _texcoordNormalizationAndHalfWidth ;
varying float v _batchId ;
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# else
varying vec2 v _alignedPlaneDistances ;
varying float v _texcoordT ;
# endif
float rayPlaneDistanceUnsafe ( vec3 origin , vec3 direction , vec3 planeNormal , float planeDistance ) {
// We don't expect the ray to ever be parallel to the plane
return ( - planeDistance - dot ( planeNormal , origin ) ) / dot ( planeNormal , direction ) ;
}
void main ( void )
{
vec4 eyeCoordinate = gl _FragCoord ;
eyeCoordinate /= eyeCoordinate . w ;
# ifdef PER _INSTANCE _COLOR
gl _FragColor = czm _gammaCorrect ( v _color ) ;
# else // PER_INSTANCE_COLOR
// Use distances for planes aligned with segment to prevent skew in dashing
float distanceFromStart = rayPlaneDistanceUnsafe ( eyeCoordinate . xyz , - v _forwardDirectionEC , v _forwardDirectionEC . xyz , v _alignedPlaneDistances . x ) ;
float distanceFromEnd = rayPlaneDistanceUnsafe ( eyeCoordinate . xyz , v _forwardDirectionEC , - v _forwardDirectionEC . xyz , v _alignedPlaneDistances . y ) ;
// Clamp - distance to aligned planes may be negative due to mitering
distanceFromStart = max ( 0.0 , distanceFromStart ) ;
distanceFromEnd = max ( 0.0 , distanceFromEnd ) ;
float s = distanceFromStart / ( distanceFromStart + distanceFromEnd ) ;
s = ( s * v _texcoordNormalizationAndHalfWidth . x ) + v _texcoordNormalizationAndHalfWidth . y ;
czm _materialInput materialInput ;
materialInput . s = s ;
materialInput . st = vec2 ( s , v _texcoordT ) ;
materialInput . str = vec3 ( s , v _texcoordT , 0.0 ) ;
czm _material material = czm _getMaterial ( materialInput ) ;
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# endif // PER_INSTANCE_COLOR
}
` ,Uue= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec4 startHiAndForwardOffsetX ;
attribute vec4 startLoAndForwardOffsetY ;
attribute vec4 startNormalAndForwardOffsetZ ;
attribute vec4 endNormalAndTextureCoordinateNormalizationX ;
attribute vec4 rightNormalAndTextureCoordinateNormalizationY ;
attribute vec4 startHiLo2D ;
attribute vec4 offsetAndRight2D ;
attribute vec4 startEndNormals2D ;
attribute vec2 texcoordNormalization2D ;
attribute float batchId ;
varying vec3 v _forwardDirectionEC ;
varying vec3 v _texcoordNormalizationAndHalfWidth ;
varying float v _batchId ;
// For materials
# ifdef WIDTH _VARYING
varying float v _width ;
# endif
# ifdef ANGLE _VARYING
varying float v _polylineAngle ;
# endif
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# else
varying vec2 v _alignedPlaneDistances ;
varying float v _texcoordT ;
# endif
// Morphing planes using SLERP or NLERP doesn't seem to work, so instead draw the material directly on the shadow volume.
// Morph views are from very far away and aren't meant to be used precisely, so this should be sufficient.
void main ( )
{
v _batchId = batchId ;
// Start position
vec4 posRelativeToEye2D = czm _translateRelativeToEye ( vec3 ( 0.0 , startHiLo2D . xy ) , vec3 ( 0.0 , startHiLo2D . zw ) ) ;
vec4 posRelativeToEye3D = czm _translateRelativeToEye ( startHiAndForwardOffsetX . xyz , startLoAndForwardOffsetY . xyz ) ;
vec4 posRelativeToEye = czm _columbusViewMorph ( posRelativeToEye2D , posRelativeToEye3D , czm _morphTime ) ;
vec3 posEc2D = ( czm _modelViewRelativeToEye * posRelativeToEye2D ) . xyz ;
vec3 posEc3D = ( czm _modelViewRelativeToEye * posRelativeToEye3D ) . xyz ;
vec3 startEC = ( czm _modelViewRelativeToEye * posRelativeToEye ) . xyz ;
// Start plane
vec4 startPlane2D ;
vec4 startPlane3D ;
startPlane2D . xyz = czm _normal * vec3 ( 0.0 , startEndNormals2D . xy ) ;
startPlane3D . xyz = czm _normal * startNormalAndForwardOffsetZ . xyz ;
startPlane2D . w = - dot ( startPlane2D . xyz , posEc2D ) ;
startPlane3D . w = - dot ( startPlane3D . xyz , posEc3D ) ;
// Right plane
vec4 rightPlane2D ;
vec4 rightPlane3D ;
rightPlane2D . xyz = czm _normal * vec3 ( 0.0 , offsetAndRight2D . zw ) ;
rightPlane3D . xyz = czm _normal * rightNormalAndTextureCoordinateNormalizationY . xyz ;
rightPlane2D . w = - dot ( rightPlane2D . xyz , posEc2D ) ;
rightPlane3D . w = - dot ( rightPlane3D . xyz , posEc3D ) ;
// End position
posRelativeToEye2D = posRelativeToEye2D + vec4 ( 0.0 , offsetAndRight2D . xy , 0.0 ) ;
posRelativeToEye3D = posRelativeToEye3D + vec4 ( startHiAndForwardOffsetX . w , startLoAndForwardOffsetY . w , startNormalAndForwardOffsetZ . w , 0.0 ) ;
posRelativeToEye = czm _columbusViewMorph ( posRelativeToEye2D , posRelativeToEye3D , czm _morphTime ) ;
posEc2D = ( czm _modelViewRelativeToEye * posRelativeToEye2D ) . xyz ;
posEc3D = ( czm _modelViewRelativeToEye * posRelativeToEye3D ) . xyz ;
vec3 endEC = ( czm _modelViewRelativeToEye * posRelativeToEye ) . xyz ;
vec3 forwardEc3D = czm _normal * normalize ( vec3 ( startHiAndForwardOffsetX . w , startLoAndForwardOffsetY . w , startNormalAndForwardOffsetZ . w ) ) ;
vec3 forwardEc2D = czm _normal * normalize ( vec3 ( 0.0 , offsetAndRight2D . xy ) ) ;
// End plane
vec4 endPlane2D ;
vec4 endPlane3D ;
endPlane2D . xyz = czm _normal * vec3 ( 0.0 , startEndNormals2D . zw ) ;
endPlane3D . xyz = czm _normal * endNormalAndTextureCoordinateNormalizationX . xyz ;
endPlane2D . w = - dot ( endPlane2D . xyz , posEc2D ) ;
endPlane3D . w = - dot ( endPlane3D . xyz , posEc3D ) ;
// Forward direction
v _forwardDirectionEC = normalize ( endEC - startEC ) ;
vec2 cleanTexcoordNormalization2D ;
cleanTexcoordNormalization2D . x = abs ( texcoordNormalization2D . x ) ;
cleanTexcoordNormalization2D . y = czm _branchFreeTernary ( texcoordNormalization2D . y > 1.0 , 0.0 , abs ( texcoordNormalization2D . y ) ) ;
vec2 cleanTexcoordNormalization3D ;
cleanTexcoordNormalization3D . x = abs ( endNormalAndTextureCoordinateNormalizationX . w ) ;
cleanTexcoordNormalization3D . y = rightNormalAndTextureCoordinateNormalizationY . w ;
cleanTexcoordNormalization3D . y = czm _branchFreeTernary ( cleanTexcoordNormalization3D . y > 1.0 , 0.0 , abs ( cleanTexcoordNormalization3D . y ) ) ;
v _texcoordNormalizationAndHalfWidth . xy = mix ( cleanTexcoordNormalization2D , cleanTexcoordNormalization3D , czm _morphTime ) ;
# ifdef PER _INSTANCE _COLOR
v _color = czm _batchTable _color ( batchId ) ;
# else // PER_INSTANCE_COLOR
// For computing texture coordinates
v _alignedPlaneDistances . x = - dot ( v _forwardDirectionEC , startEC ) ;
v _alignedPlaneDistances . y = - dot ( - v _forwardDirectionEC , endEC ) ;
# endif // PER_INSTANCE_COLOR
# ifdef WIDTH _VARYING
float width = czm _batchTable _width ( batchId ) ;
float halfWidth = width * 0.5 ;
v _width = width ;
v _texcoordNormalizationAndHalfWidth . z = halfWidth ;
# else
float halfWidth = 0.5 * czm _batchTable _width ( batchId ) ;
v _texcoordNormalizationAndHalfWidth . z = halfWidth ;
# endif
// Compute a normal along which to "push" the position out, extending the miter depending on view distance.
// Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes.
// Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be.
// Since this is morphing, compute both 3D and 2D positions and then blend.
// ****** 3D ******
// Check distance to the end plane and start plane, pick the plane that is closer
vec4 positionEc3D = czm _modelViewRelativeToEye * czm _translateRelativeToEye ( position3DHigh , position3DLow ) ; // w = 1.0, see czm_computePosition
float absStartPlaneDistance = abs ( czm _planeDistance ( startPlane3D , positionEc3D . xyz ) ) ;
float absEndPlaneDistance = abs ( czm _planeDistance ( endPlane3D , positionEc3D . xyz ) ) ;
vec3 planeDirection = czm _branchFreeTernary ( absStartPlaneDistance < absEndPlaneDistance , startPlane3D . xyz , endPlane3D . xyz ) ;
vec3 upOrDown = normalize ( cross ( rightPlane3D . xyz , planeDirection ) ) ; // Points "up" for start plane, "down" at end plane.
vec3 normalEC = normalize ( cross ( planeDirection , upOrDown ) ) ; // In practice, the opposite seems to work too.
// Nudge the top vertex upwards to prevent flickering
vec3 geodeticSurfaceNormal = normalize ( cross ( normalEC , forwardEc3D ) ) ;
geodeticSurfaceNormal *= float ( 0.0 <= rightNormalAndTextureCoordinateNormalizationY . w && rightNormalAndTextureCoordinateNormalizationY . w <= 1.0 ) ;
geodeticSurfaceNormal *= MAX _TERRAIN _HEIGHT ;
positionEc3D . xyz += geodeticSurfaceNormal ;
// Determine if this vertex is on the "left" or "right"
normalEC *= sign ( endNormalAndTextureCoordinateNormalizationX . w ) ;
// A "perfect" implementation would push along normals according to the angle against forward.
// In practice, just pushing the normal out by halfWidth is sufficient for morph views.
positionEc3D . xyz += halfWidth * max ( 0.0 , czm _metersPerPixel ( positionEc3D ) ) * normalEC ; // prevent artifacts when czm_metersPerPixel is negative (behind camera)
// ****** 2D ******
// Check distance to the end plane and start plane, pick the plane that is closer
vec4 positionEc2D = czm _modelViewRelativeToEye * czm _translateRelativeToEye ( position2DHigh . zxy , position2DLow . zxy ) ; // w = 1.0, see czm_computePosition
absStartPlaneDistance = abs ( czm _planeDistance ( startPlane2D , positionEc2D . xyz ) ) ;
absEndPlaneDistance = abs ( czm _planeDistance ( endPlane2D , positionEc2D . xyz ) ) ;
planeDirection = czm _branchFreeTernary ( absStartPlaneDistance < absEndPlaneDistance , startPlane2D . xyz , endPlane2D . xyz ) ;
upOrDown = normalize ( cross ( rightPlane2D . xyz , planeDirection ) ) ; // Points "up" for start plane, "down" at end plane.
normalEC = normalize ( cross ( planeDirection , upOrDown ) ) ; // In practice, the opposite seems to work too.
// Nudge the top vertex upwards to prevent flickering
geodeticSurfaceNormal = normalize ( cross ( normalEC , forwardEc2D ) ) ;
geodeticSurfaceNormal *= float ( 0.0 <= texcoordNormalization2D . y && texcoordNormalization2D . y <= 1.0 ) ;
geodeticSurfaceNormal *= MAX _TERRAIN _HEIGHT ;
positionEc2D . xyz += geodeticSurfaceNormal ;
// Determine if this vertex is on the "left" or "right"
normalEC *= sign ( texcoordNormalization2D . x ) ;
# ifndef PER _INSTANCE _COLOR
// Use vertex's sidedness to compute its texture coordinate.
v _texcoordT = clamp ( sign ( texcoordNormalization2D . x ) , 0.0 , 1.0 ) ;
# endif
// A "perfect" implementation would push along normals according to the angle against forward.
// In practice, just pushing the normal out by halfWidth is sufficient for morph views.
positionEc2D . xyz += halfWidth * max ( 0.0 , czm _metersPerPixel ( positionEc2D ) ) * normalEC ; // prevent artifacts when czm_metersPerPixel is negative (behind camera)
// Blend for actual position
gl _Position = czm _projection * mix ( positionEc2D , positionEc3D , czm _morphTime ) ;
# ifdef ANGLE _VARYING
// Approximate relative screen space direction of the line.
vec2 approxLineDirection = normalize ( vec2 ( v _forwardDirectionEC . x , - v _forwardDirectionEC . y ) ) ;
approxLineDirection . y = czm _branchFreeTernary ( approxLineDirection . x == 0.0 && approxLineDirection . y == 0.0 , - 1.0 , approxLineDirection . y ) ;
v _polylineAngle = czm _fastApproximateAtan ( approxLineDirection . x , approxLineDirection . y ) ;
# endif
}
` ,Hue= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
// In 2D and in 3D, texture coordinate normalization component signs encodes:
// * X sign - sidedness relative to right plane
// * Y sign - is negative OR magnitude is greater than 1.0 if vertex is on bottom of volume
# ifndef COLUMBUS _VIEW _2D
attribute vec4 startHiAndForwardOffsetX ;
attribute vec4 startLoAndForwardOffsetY ;
attribute vec4 startNormalAndForwardOffsetZ ;
attribute vec4 endNormalAndTextureCoordinateNormalizationX ;
attribute vec4 rightNormalAndTextureCoordinateNormalizationY ;
# else
attribute vec4 startHiLo2D ;
attribute vec4 offsetAndRight2D ;
attribute vec4 startEndNormals2D ;
attribute vec2 texcoordNormalization2D ;
# endif
attribute float batchId ;
varying vec4 v _startPlaneNormalEcAndHalfWidth ;
varying vec4 v _endPlaneNormalEcAndBatchId ;
varying vec4 v _rightPlaneEC ;
varying vec4 v _endEcAndStartEcX ;
varying vec4 v _texcoordNormalizationAndStartEcYZ ;
// For materials
# ifdef WIDTH _VARYING
varying float v _width ;
# endif
# ifdef ANGLE _VARYING
varying float v _polylineAngle ;
# endif
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# endif
void main ( )
{
# ifdef COLUMBUS _VIEW _2D
vec3 ecStart = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( vec3 ( 0.0 , startHiLo2D . xy ) , vec3 ( 0.0 , startHiLo2D . zw ) ) ) . xyz ;
vec3 forwardDirectionEC = czm _normal * vec3 ( 0.0 , offsetAndRight2D . xy ) ;
vec3 ecEnd = forwardDirectionEC + ecStart ;
forwardDirectionEC = normalize ( forwardDirectionEC ) ;
// Right plane
v _rightPlaneEC . xyz = czm _normal * vec3 ( 0.0 , offsetAndRight2D . zw ) ;
v _rightPlaneEC . w = - dot ( v _rightPlaneEC . xyz , ecStart ) ;
// start plane
vec4 startPlaneEC ;
startPlaneEC . xyz = czm _normal * vec3 ( 0.0 , startEndNormals2D . xy ) ;
startPlaneEC . w = - dot ( startPlaneEC . xyz , ecStart ) ;
// end plane
vec4 endPlaneEC ;
endPlaneEC . xyz = czm _normal * vec3 ( 0.0 , startEndNormals2D . zw ) ;
endPlaneEC . w = - dot ( endPlaneEC . xyz , ecEnd ) ;
v _texcoordNormalizationAndStartEcYZ . x = abs ( texcoordNormalization2D . x ) ;
v _texcoordNormalizationAndStartEcYZ . y = texcoordNormalization2D . y ;
# else // COLUMBUS_VIEW_2D
vec3 ecStart = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( startHiAndForwardOffsetX . xyz , startLoAndForwardOffsetY . xyz ) ) . xyz ;
vec3 offset = czm _normal * vec3 ( startHiAndForwardOffsetX . w , startLoAndForwardOffsetY . w , startNormalAndForwardOffsetZ . w ) ;
vec3 ecEnd = ecStart + offset ;
vec3 forwardDirectionEC = normalize ( offset ) ;
// start plane
vec4 startPlaneEC ;
startPlaneEC . xyz = czm _normal * startNormalAndForwardOffsetZ . xyz ;
startPlaneEC . w = - dot ( startPlaneEC . xyz , ecStart ) ;
// end plane
vec4 endPlaneEC ;
endPlaneEC . xyz = czm _normal * endNormalAndTextureCoordinateNormalizationX . xyz ;
endPlaneEC . w = - dot ( endPlaneEC . xyz , ecEnd ) ;
// Right plane
v _rightPlaneEC . xyz = czm _normal * rightNormalAndTextureCoordinateNormalizationY . xyz ;
v _rightPlaneEC . w = - dot ( v _rightPlaneEC . xyz , ecStart ) ;
v _texcoordNormalizationAndStartEcYZ . x = abs ( endNormalAndTextureCoordinateNormalizationX . w ) ;
v _texcoordNormalizationAndStartEcYZ . y = rightNormalAndTextureCoordinateNormalizationY . w ;
# endif // COLUMBUS_VIEW_2D
v _endEcAndStartEcX . xyz = ecEnd ;
v _endEcAndStartEcX . w = ecStart . x ;
v _texcoordNormalizationAndStartEcYZ . zw = ecStart . yz ;
# ifdef PER _INSTANCE _COLOR
v _color = czm _batchTable _color ( batchId ) ;
# endif // PER_INSTANCE_COLOR
// Compute a normal along which to "push" the position out, extending the miter depending on view distance.
// Position has already been "pushed" by unit length along miter normal, and miter normals are encoded in the planes.
// Decode the normal to use at this specific vertex, push the position back, and then push to where it needs to be.
vec4 positionRelativeToEye = czm _computePosition ( ) ;
// Check distance to the end plane and start plane, pick the plane that is closer
vec4 positionEC = czm _modelViewRelativeToEye * positionRelativeToEye ; // w = 1.0, see czm_computePosition
float absStartPlaneDistance = abs ( czm _planeDistance ( startPlaneEC , positionEC . xyz ) ) ;
float absEndPlaneDistance = abs ( czm _planeDistance ( endPlaneEC , positionEC . xyz ) ) ;
vec3 planeDirection = czm _branchFreeTernary ( absStartPlaneDistance < absEndPlaneDistance , startPlaneEC . xyz , endPlaneEC . xyz ) ;
vec3 upOrDown = normalize ( cross ( v _rightPlaneEC . xyz , planeDirection ) ) ; // Points "up" for start plane, "down" at end plane.
vec3 normalEC = normalize ( cross ( planeDirection , upOrDown ) ) ; // In practice, the opposite seems to work too.
// Extrude bottom vertices downward for far view distances, like for GroundPrimitives
upOrDown = cross ( forwardDirectionEC , normalEC ) ;
upOrDown = float ( czm _sceneMode == czm _sceneMode3D ) * upOrDown ;
upOrDown = float ( v _texcoordNormalizationAndStartEcYZ . y > 1.0 || v _texcoordNormalizationAndStartEcYZ . y < 0.0 ) * upOrDown ;
upOrDown = min ( GLOBE _MINIMUM _ALTITUDE , czm _geometricToleranceOverMeter * length ( positionRelativeToEye . xyz ) ) * upOrDown ;
positionEC . xyz += upOrDown ;
v _texcoordNormalizationAndStartEcYZ . y = czm _branchFreeTernary ( v _texcoordNormalizationAndStartEcYZ . y > 1.0 , 0.0 , abs ( v _texcoordNormalizationAndStartEcYZ . y ) ) ;
// Determine distance along normalEC to push for a volume of appropriate width.
// Make volumes about double pixel width for a conservative fit - in practice the
// extra cost here is minimal compared to the loose volume heights.
//
// N = normalEC (guaranteed "right-facing")
// R = rightEC
// p = angle between N and R
// w = distance to push along R if R == N
// d = distance to push along N
//
// N R
// { p| } * cos(p) = dot(N, R) = w / d
// d | |w * d = w / dot(N, R)
// { | }
// o---------- polyline segment ---->
//
float width = czm _batchTable _width ( batchId ) ;
# ifdef WIDTH _VARYING
v _width = width ;
# endif
v _startPlaneNormalEcAndHalfWidth . xyz = startPlaneEC . xyz ;
v _startPlaneNormalEcAndHalfWidth . w = width * 0.5 ;
v _endPlaneNormalEcAndBatchId . xyz = endPlaneEC . xyz ;
v _endPlaneNormalEcAndBatchId . w = batchId ;
width = width * max ( 0.0 , czm _metersPerPixel ( positionEC ) ) ; // width = distance to push along R
width = width / dot ( normalEC , v _rightPlaneEC . xyz ) ; // width = distance to push along N
// Determine if this vertex is on the "left" or "right"
# ifdef COLUMBUS _VIEW _2D
normalEC *= sign ( texcoordNormalization2D . x ) ;
# else
normalEC *= sign ( endNormalAndTextureCoordinateNormalizationX . w ) ;
# endif
positionEC . xyz += width * normalEC ;
gl _Position = czm _depthClamp ( czm _projection * positionEC ) ;
# ifdef ANGLE _VARYING
// Approximate relative screen space direction of the line.
vec2 approxLineDirection = normalize ( vec2 ( forwardDirectionEC . x , - forwardDirectionEC . y ) ) ;
approxLineDirection . y = czm _branchFreeTernary ( approxLineDirection . x == 0.0 && approxLineDirection . y == 0.0 , - 1.0 , approxLineDirection . y ) ;
v _polylineAngle = czm _fastApproximateAtan ( approxLineDirection . x , approxLineDirection . y ) ;
# endif
}
` ,Vue= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 position2DHigh ;
attribute vec3 position2DLow ;
attribute vec3 prevPosition3DHigh ;
attribute vec3 prevPosition3DLow ;
attribute vec3 prevPosition2DHigh ;
attribute vec3 prevPosition2DLow ;
attribute vec3 nextPosition3DHigh ;
attribute vec3 nextPosition3DLow ;
attribute vec3 nextPosition2DHigh ;
attribute vec3 nextPosition2DLow ;
attribute vec4 texCoordExpandAndBatchIndex ;
varying vec2 v _st ;
varying float v _width ;
varying vec4 v _pickColor ;
varying float v _polylineAngle ;
void main ( )
{
float texCoord = texCoordExpandAndBatchIndex . x ;
float expandDir = texCoordExpandAndBatchIndex . y ;
bool usePrev = texCoordExpandAndBatchIndex . z < 0.0 ;
float batchTableIndex = texCoordExpandAndBatchIndex . w ;
vec2 widthAndShow = batchTable _getWidthAndShow ( batchTableIndex ) ;
float width = widthAndShow . x + 0.5 ;
float show = widthAndShow . y ;
if ( width < 1.0 )
{
show = 0.0 ;
}
vec4 pickColor = batchTable _getPickColor ( batchTableIndex ) ;
vec4 p , prev , next ;
if ( czm _morphTime == 1.0 )
{
p = czm _translateRelativeToEye ( position3DHigh . xyz , position3DLow . xyz ) ;
prev = czm _translateRelativeToEye ( prevPosition3DHigh . xyz , prevPosition3DLow . xyz ) ;
next = czm _translateRelativeToEye ( nextPosition3DHigh . xyz , nextPosition3DLow . xyz ) ;
}
else if ( czm _morphTime == 0.0 )
{
p = czm _translateRelativeToEye ( position2DHigh . zxy , position2DLow . zxy ) ;
prev = czm _translateRelativeToEye ( prevPosition2DHigh . zxy , prevPosition2DLow . zxy ) ;
next = czm _translateRelativeToEye ( nextPosition2DHigh . zxy , nextPosition2DLow . zxy ) ;
}
else
{
p = czm _columbusViewMorph (
czm _translateRelativeToEye ( position2DHigh . zxy , position2DLow . zxy ) ,
czm _translateRelativeToEye ( position3DHigh . xyz , position3DLow . xyz ) ,
czm _morphTime ) ;
prev = czm _columbusViewMorph (
czm _translateRelativeToEye ( prevPosition2DHigh . zxy , prevPosition2DLow . zxy ) ,
czm _translateRelativeToEye ( prevPosition3DHigh . xyz , prevPosition3DLow . xyz ) ,
czm _morphTime ) ;
next = czm _columbusViewMorph (
czm _translateRelativeToEye ( nextPosition2DHigh . zxy , nextPosition2DLow . zxy ) ,
czm _translateRelativeToEye ( nextPosition3DHigh . xyz , nextPosition3DLow . xyz ) ,
czm _morphTime ) ;
}
# ifdef DISTANCE _DISPLAY _CONDITION
vec3 centerHigh = batchTable _getCenterHigh ( batchTableIndex ) ;
vec4 centerLowAndRadius = batchTable _getCenterLowAndRadius ( batchTableIndex ) ;
vec3 centerLow = centerLowAndRadius . xyz ;
float radius = centerLowAndRadius . w ;
vec2 distanceDisplayCondition = batchTable _getDistanceDisplayCondition ( batchTableIndex ) ;
float lengthSq ;
if ( czm _sceneMode == czm _sceneMode2D )
{
lengthSq = czm _eyeHeight2D . y ;
}
else
{
vec4 center = czm _translateRelativeToEye ( centerHigh . xyz , centerLow . xyz ) ;
lengthSq = max ( 0.0 , dot ( center . xyz , center . xyz ) - radius * radius ) ;
}
float nearSq = distanceDisplayCondition . x * distanceDisplayCondition . x ;
float farSq = distanceDisplayCondition . y * distanceDisplayCondition . y ;
if ( lengthSq < nearSq || lengthSq > farSq )
{
show = 0.0 ;
}
# endif
float polylineAngle ;
vec4 positionWC = getPolylineWindowCoordinates ( p , prev , next , expandDir , width , usePrev , polylineAngle ) ;
gl _Position = czm _viewportOrthographic * positionWC * show ;
v _st . s = texCoord ;
v _st . t = czm _writeNonPerspective ( clamp ( expandDir , 0.0 , 1.0 ) , gl _Position . w ) ;
v _width = width ;
v _pickColor = pickColor ;
v _polylineAngle = polylineAngle ;
}
` ,kue= ` uniform sampler2D u _texture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( u _texture , v _textureCoordinates ) ;
}
` ,Gue= ` attribute vec4 position ;
attribute float webMercatorT ;
uniform vec2 u _textureDimensions ;
varying vec2 v _textureCoordinates ;
void main ( )
{
v _textureCoordinates = vec2 ( position . x , webMercatorT ) ;
gl _Position = czm _viewportOrthographic * ( position * vec4 ( u _textureDimensions , 1.0 , 1.0 ) ) ;
}
` ,f6= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
# ifdef TEXTURE _COORDINATES
# ifdef SPHERICAL
varying vec4 v _sphericalExtents ;
# else // SPHERICAL
varying vec2 v _inversePlaneExtents ;
varying vec4 v _westPlane ;
varying vec4 v _southPlane ;
# endif // SPHERICAL
varying vec3 v _uvMinAndSphericalLongitudeRotation ;
varying vec3 v _uMaxAndInverseDistance ;
varying vec3 v _vMaxAndInverseDistance ;
# endif // TEXTURE_COORDINATES
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# endif
# ifdef NORMAL _EC
vec3 getEyeCoordinate3FromWindowCoordinate ( vec2 fragCoord , float logDepthOrDepth ) {
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( fragCoord , logDepthOrDepth ) ;
return eyeCoordinate . xyz / eyeCoordinate . w ;
}
vec3 vectorFromOffset ( vec4 eyeCoordinate , vec2 positiveOffset ) {
vec2 glFragCoordXY = gl _FragCoord . xy ;
// Sample depths at both offset and negative offset
float upOrRightLogDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , ( glFragCoordXY + positiveOffset ) / czm _viewport . zw ) ) ;
float downOrLeftLogDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , ( glFragCoordXY - positiveOffset ) / czm _viewport . zw ) ) ;
// Explicitly evaluate both paths
// Necessary for multifrustum and for edges of the screen
bvec2 upOrRightInBounds = lessThan ( glFragCoordXY + positiveOffset , czm _viewport . zw ) ;
float useUpOrRight = float ( upOrRightLogDepth > 0.0 && upOrRightInBounds . x && upOrRightInBounds . y ) ;
float useDownOrLeft = float ( useUpOrRight == 0.0 ) ;
vec3 upOrRightEC = getEyeCoordinate3FromWindowCoordinate ( glFragCoordXY + positiveOffset , upOrRightLogDepth ) ;
vec3 downOrLeftEC = getEyeCoordinate3FromWindowCoordinate ( glFragCoordXY - positiveOffset , downOrLeftLogDepth ) ;
return ( upOrRightEC - ( eyeCoordinate . xyz / eyeCoordinate . w ) ) * useUpOrRight + ( ( eyeCoordinate . xyz / eyeCoordinate . w ) - downOrLeftEC ) * useDownOrLeft ;
}
# endif // NORMAL_EC
void main ( void )
{
# ifdef REQUIRES _EC
float logDepthOrDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , gl _FragCoord . xy / czm _viewport . zw ) ) ;
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , logDepthOrDepth ) ;
# endif
# ifdef REQUIRES _WC
vec4 worldCoordinate4 = czm _inverseView * eyeCoordinate ;
vec3 worldCoordinate = worldCoordinate4 . xyz / worldCoordinate4 . w ;
# endif
# ifdef TEXTURE _COORDINATES
vec2 uv ;
# ifdef SPHERICAL
// Treat world coords as a sphere normal for spherical coordinates
vec2 sphericalLatLong = czm _approximateSphericalCoordinates ( worldCoordinate ) ;
sphericalLatLong . y += v _uvMinAndSphericalLongitudeRotation . z ;
sphericalLatLong . y = czm _branchFreeTernary ( sphericalLatLong . y < czm _pi , sphericalLatLong . y , sphericalLatLong . y - czm _twoPi ) ;
uv . x = ( sphericalLatLong . y - v _sphericalExtents . y ) * v _sphericalExtents . w ;
uv . y = ( sphericalLatLong . x - v _sphericalExtents . x ) * v _sphericalExtents . z ;
# else // SPHERICAL
// Unpack planes and transform to eye space
uv . x = czm _planeDistance ( v _westPlane , eyeCoordinate . xyz / eyeCoordinate . w ) * v _inversePlaneExtents . x ;
uv . y = czm _planeDistance ( v _southPlane , eyeCoordinate . xyz / eyeCoordinate . w ) * v _inversePlaneExtents . y ;
# endif // SPHERICAL
# endif // TEXTURE_COORDINATES
# ifdef PICK
# ifdef CULL _FRAGMENTS
// When classifying translucent geometry, logDepthOrDepth == 0.0
// indicates a region that should not be classified, possibly due to there
// being opaque pixels there in another buffer.
// Check for logDepthOrDepth != 0.0 to make sure this should be classified.
if ( 0.0 <= uv . x && uv . x <= 1.0 && 0.0 <= uv . y && uv . y <= 1.0 || logDepthOrDepth != 0.0 ) {
gl _FragColor . a = 1.0 ; // 0.0 alpha leads to discard from ShaderSource.createPickFragmentShaderSource
czm _writeDepthClamp ( ) ;
}
# else // CULL_FRAGMENTS
gl _FragColor . a = 1.0 ;
# endif // CULL_FRAGMENTS
# else // PICK
# ifdef CULL _FRAGMENTS
// When classifying translucent geometry, logDepthOrDepth == 0.0
// indicates a region that should not be classified, possibly due to there
// being opaque pixels there in another buffer.
if ( uv . x <= 0.0 || 1.0 <= uv . x || uv . y <= 0.0 || 1.0 <= uv . y || logDepthOrDepth == 0.0 ) {
discard ;
}
# endif
# ifdef NORMAL _EC
// Compute normal by sampling adjacent pixels in 2x2 block in screen space
vec3 downUp = vectorFromOffset ( eyeCoordinate , vec2 ( 0.0 , 1.0 ) ) ;
vec3 leftRight = vectorFromOffset ( eyeCoordinate , vec2 ( 1.0 , 0.0 ) ) ;
vec3 normalEC = normalize ( cross ( leftRight , downUp ) ) ;
# endif
# ifdef PER _INSTANCE _COLOR
vec4 color = czm _gammaCorrect ( v _color ) ;
# ifdef FLAT
gl _FragColor = color ;
# else // FLAT
czm _materialInput materialInput ;
materialInput . normalEC = normalEC ;
materialInput . positionToEyeEC = - eyeCoordinate . xyz ;
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
gl _FragColor = czm _phong ( normalize ( - eyeCoordinate . xyz ) , material , czm _lightDirectionEC ) ;
# endif // FLAT
// Premultiply alpha. Required for classification primitives on translucent globe.
gl _FragColor . rgb *= gl _FragColor . a ;
# else // PER_INSTANCE_COLOR
// Material support.
// USES_ is distinct from REQUIRES_, because some things are dependencies of each other or
// dependencies for culling but might not actually be used by the material.
czm _materialInput materialInput ;
# ifdef USES _NORMAL _EC
materialInput . normalEC = normalEC ;
# endif
# ifdef USES _POSITION _TO _EYE _EC
materialInput . positionToEyeEC = - eyeCoordinate . xyz ;
# endif
# ifdef USES _TANGENT _TO _EYE
materialInput . tangentToEyeMatrix = czm _eastNorthUpToEyeCoordinates ( worldCoordinate , normalEC ) ;
# endif
# ifdef USES _ST
// Remap texture coordinates from computed (approximately aligned with cartographic space) to the desired
// texture coordinate system, which typically forms a tight oriented bounding box around the geometry.
// Shader is provided a set of reference points for remapping.
materialInput . st . x = czm _lineDistance ( v _uvMinAndSphericalLongitudeRotation . xy , v _uMaxAndInverseDistance . xy , uv ) * v _uMaxAndInverseDistance . z ;
materialInput . st . y = czm _lineDistance ( v _uvMinAndSphericalLongitudeRotation . xy , v _vMaxAndInverseDistance . xy , uv ) * v _vMaxAndInverseDistance . z ;
# endif
czm _material material = czm _getMaterial ( materialInput ) ;
# ifdef FLAT
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# else // FLAT
gl _FragColor = czm _phong ( normalize ( - eyeCoordinate . xyz ) , material , czm _lightDirectionEC ) ;
# endif // FLAT
// Premultiply alpha. Required for classification primitives on translucent globe.
gl _FragColor . rgb *= gl _FragColor . a ;
# endif // PER_INSTANCE_COLOR
czm _writeDepthClamp ( ) ;
# endif // PICK
}
` ,Wue= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute float batchId ;
# ifdef EXTRUDED _GEOMETRY
attribute vec3 extrudeDirection ;
uniform float u _globeMinimumAltitude ;
# endif // EXTRUDED_GEOMETRY
# ifdef PER _INSTANCE _COLOR
varying vec4 v _color ;
# endif // PER_INSTANCE_COLOR
# ifdef TEXTURE _COORDINATES
# ifdef SPHERICAL
varying vec4 v _sphericalExtents ;
# else // SPHERICAL
varying vec2 v _inversePlaneExtents ;
varying vec4 v _westPlane ;
varying vec4 v _southPlane ;
# endif // SPHERICAL
varying vec3 v _uvMinAndSphericalLongitudeRotation ;
varying vec3 v _uMaxAndInverseDistance ;
varying vec3 v _vMaxAndInverseDistance ;
# endif // TEXTURE_COORDINATES
void main ( )
{
vec4 position = czm _computePosition ( ) ;
# ifdef EXTRUDED _GEOMETRY
float delta = min ( u _globeMinimumAltitude , czm _geometricToleranceOverMeter * length ( position . xyz ) ) ;
delta *= czm _sceneMode == czm _sceneMode3D ? 1.0 : 0.0 ;
//extrudeDirection is zero for the top layer
position = position + vec4 ( extrudeDirection * delta , 0.0 ) ;
# endif
# ifdef TEXTURE _COORDINATES
# ifdef SPHERICAL
v _sphericalExtents = czm _batchTable _sphericalExtents ( batchId ) ;
v _uvMinAndSphericalLongitudeRotation . z = czm _batchTable _longitudeRotation ( batchId ) ;
# else // SPHERICAL
# ifdef COLUMBUS _VIEW _2D
vec4 planes2D _high = czm _batchTable _planes2D _HIGH ( batchId ) ;
vec4 planes2D _low = czm _batchTable _planes2D _LOW ( batchId ) ;
// If the primitive is split across the IDL (planes2D_high.x > planes2D_high.w):
// - If this vertex is on the east side of the IDL (position3DLow.y > 0.0, comparison with position3DHigh may produce artifacts)
// - existing "east" is on the wrong side of the world, far away (planes2D_high/low.w)
// - so set "east" as beyond the eastmost extent of the projection (idlSplitNewPlaneHiLow)
vec2 idlSplitNewPlaneHiLow = vec2 ( EAST _MOST _X _HIGH - ( WEST _MOST _X _HIGH - planes2D _high . w ) , EAST _MOST _X _LOW - ( WEST _MOST _X _LOW - planes2D _low . w ) ) ;
bool idlSplit = planes2D _high . x > planes2D _high . w && position3DLow . y > 0.0 ;
planes2D _high . w = czm _branchFreeTernary ( idlSplit , idlSplitNewPlaneHiLow . x , planes2D _high . w ) ;
planes2D _low . w = czm _branchFreeTernary ( idlSplit , idlSplitNewPlaneHiLow . y , planes2D _low . w ) ;
// - else, if this vertex is on the west side of the IDL (position3DLow.y < 0.0)
// - existing "west" is on the wrong side of the world, far away (planes2D_high/low.x)
// - so set "west" as beyond the westmost extent of the projection (idlSplitNewPlaneHiLow)
idlSplit = planes2D _high . x > planes2D _high . w && position3DLow . y < 0.0 ;
idlSplitNewPlaneHiLow = vec2 ( WEST _MOST _X _HIGH - ( EAST _MOST _X _HIGH - planes2D _high . x ) , WEST _MOST _X _LOW - ( EAST _MOST _X _LOW - planes2D _low . x ) ) ;
planes2D _high . x = czm _branchFreeTernary ( idlSplit , idlSplitNewPlaneHiLow . x , planes2D _high . x ) ;
planes2D _low . x = czm _branchFreeTernary ( idlSplit , idlSplitNewPlaneHiLow . y , planes2D _low . x ) ;
vec3 southWestCorner = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( vec3 ( 0.0 , planes2D _high . xy ) , vec3 ( 0.0 , planes2D _low . xy ) ) ) . xyz ;
vec3 northWestCorner = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( vec3 ( 0.0 , planes2D _high . x , planes2D _high . z ) , vec3 ( 0.0 , planes2D _low . x , planes2D _low . z ) ) ) . xyz ;
vec3 southEastCorner = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( vec3 ( 0.0 , planes2D _high . w , planes2D _high . y ) , vec3 ( 0.0 , planes2D _low . w , planes2D _low . y ) ) ) . xyz ;
# else // COLUMBUS_VIEW_2D
// 3D case has smaller "plane extents," so planes encoded as a 64 bit position and 2 vec3s for distances/direction
vec3 southWestCorner = ( czm _modelViewRelativeToEye * czm _translateRelativeToEye ( czm _batchTable _southWest _HIGH ( batchId ) , czm _batchTable _southWest _LOW ( batchId ) ) ) . xyz ;
vec3 northWestCorner = czm _normal * czm _batchTable _northward ( batchId ) + southWestCorner ;
vec3 southEastCorner = czm _normal * czm _batchTable _eastward ( batchId ) + southWestCorner ;
# endif // COLUMBUS_VIEW_2D
vec3 eastWard = southEastCorner - southWestCorner ;
float eastExtent = length ( eastWard ) ;
eastWard /= eastExtent ;
vec3 northWard = northWestCorner - southWestCorner ;
float northExtent = length ( northWard ) ;
northWard /= northExtent ;
v _westPlane = vec4 ( eastWard , - dot ( eastWard , southWestCorner ) ) ;
v _southPlane = vec4 ( northWard , - dot ( northWard , southWestCorner ) ) ;
v _inversePlaneExtents = vec2 ( 1.0 / eastExtent , 1.0 / northExtent ) ;
# endif // SPHERICAL
vec4 uvMinAndExtents = czm _batchTable _uvMinAndExtents ( batchId ) ;
vec4 uMaxVmax = czm _batchTable _uMaxVmax ( batchId ) ;
v _uMaxAndInverseDistance = vec3 ( uMaxVmax . xy , uvMinAndExtents . z ) ;
v _vMaxAndInverseDistance = vec3 ( uMaxVmax . zw , uvMinAndExtents . w ) ;
v _uvMinAndSphericalLongitudeRotation . xy = uvMinAndExtents . xy ;
# endif // TEXTURE_COORDINATES
# ifdef PER _INSTANCE _COLOR
v _color = czm _batchTable _color ( batchId ) ;
# endif
gl _Position = czm _depthClamp ( czm _modelViewProjectionRelativeToEye * position ) ;
}
` ,r1= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
# ifdef VECTOR _TILE
uniform vec4 u _highlightColor ;
# endif
void main ( void )
{
# ifdef VECTOR _TILE
gl _FragColor = czm _gammaCorrect ( u _highlightColor ) ;
# else
gl _FragColor = vec4 ( 1.0 ) ;
# endif
czm _writeDepthClamp ( ) ;
}
` ,v2= ` float interpolateByDistance ( vec4 nearFarScalar , float distance )
{
float startDistance = nearFarScalar . x ;
float startValue = nearFarScalar . y ;
float endDistance = nearFarScalar . z ;
float endValue = nearFarScalar . w ;
float t = clamp ( ( distance - startDistance ) / ( endDistance - startDistance ) , 0.0 , 1.0 ) ;
return mix ( startValue , endValue , t ) ;
}
vec3 getLightDirection ( vec3 positionWC )
{
float lightEnum = u _radiiAndDynamicAtmosphereColor . z ;
vec3 lightDirection =
positionWC * float ( lightEnum == 0.0 ) +
czm _lightDirectionWC * float ( lightEnum == 1.0 ) +
czm _sunDirectionWC * float ( lightEnum == 2.0 ) ;
return normalize ( lightDirection ) ;
}
void computeAtmosphereScattering ( vec3 positionWC , vec3 lightDirection , out vec3 rayleighColor , out vec3 mieColor , out float opacity , out float underTranslucentGlobe )
{
float ellipsoidRadiiDifference = czm _ellipsoidRadii . x - czm _ellipsoidRadii . z ;
// Adjustment to the atmosphere radius applied based on the camera height.
float distanceAdjustMin = czm _ellipsoidRadii . x / 4.0 ;
float distanceAdjustMax = czm _ellipsoidRadii . x ;
float distanceAdjustModifier = ellipsoidRadiiDifference / 2.0 ;
float distanceAdjust = distanceAdjustModifier * clamp ( ( czm _eyeHeight - distanceAdjustMin ) / ( distanceAdjustMax - distanceAdjustMin ) , 0.0 , 1.0 ) ;
// Since atmosphere scattering assumes the atmosphere is a spherical shell, we compute an inner radius of the atmosphere best fit
// for the position on the ellipsoid.
float radiusAdjust = ( ellipsoidRadiiDifference / 4.0 ) + distanceAdjust ;
float atmosphereInnerRadius = ( length ( czm _viewerPositionWC ) - czm _eyeHeight ) - radiusAdjust ;
// Setup the primary ray: from the camera position to the vertex position.
vec3 cameraToPositionWC = positionWC - czm _viewerPositionWC ;
vec3 cameraToPositionWCDirection = normalize ( cameraToPositionWC ) ;
czm _ray primaryRay = czm _ray ( czm _viewerPositionWC , cameraToPositionWCDirection ) ;
underTranslucentGlobe = 0.0 ;
// Brighten the sky atmosphere under the Earth's atmosphere when translucency is enabled.
# if defined ( GLOBE _TRANSLUCENT )
// Check for intersection with the inner radius of the atmopshere.
czm _raySegment primaryRayEarthIntersect = czm _raySphereIntersectionInterval ( primaryRay , vec3 ( 0.0 ) , atmosphereInnerRadius + radiusAdjust ) ;
if ( primaryRayEarthIntersect . start > 0.0 && primaryRayEarthIntersect . stop > 0.0 ) {
// Compute position on globe.
vec3 direction = normalize ( positionWC ) ;
czm _ray ellipsoidRay = czm _ray ( positionWC , - direction ) ;
czm _raySegment ellipsoidIntersection = czm _rayEllipsoidIntersectionInterval ( ellipsoidRay , vec3 ( 0.0 ) , czm _ellipsoidInverseRadii ) ;
vec3 onEarth = positionWC - ( direction * ellipsoidIntersection . start ) ;
// Control the color using the camera angle.
float angle = dot ( normalize ( czm _viewerPositionWC ) , normalize ( onEarth ) ) ;
// Control the opacity using the distance from Earth.
opacity = interpolateByDistance ( vec4 ( 0.0 , 1.0 , czm _ellipsoidRadii . x , 0.0 ) , length ( czm _viewerPositionWC - onEarth ) ) ;
vec3 horizonColor = vec3 ( 0.1 , 0.2 , 0.3 ) ;
vec3 nearColor = vec3 ( 0.0 ) ;
rayleighColor = mix ( nearColor , horizonColor , exp ( - angle ) * opacity ) ;
// Set the traslucent flag to avoid alpha adjustment in computeFinalColor funciton.
underTranslucentGlobe = 1.0 ;
return ;
}
# endif
computeScattering (
primaryRay ,
length ( cameraToPositionWC ) ,
lightDirection ,
atmosphereInnerRadius ,
rayleighColor ,
mieColor ,
opacity
) ;
// Alter the opacity based on how close the viewer is to the ground.
// (0.0 = At edge of atmosphere, 1.0 = On ground)
float cameraHeight = czm _eyeHeight + atmosphereInnerRadius ;
float atmosphereOuterRadius = atmosphereInnerRadius + ATMOSPHERE _THICKNESS ;
opacity = clamp ( ( atmosphereOuterRadius - cameraHeight ) / ( atmosphereOuterRadius - atmosphereInnerRadius ) , 0.0 , 1.0 ) ;
// Alter alpha based on time of day (0.0 = night , 1.0 = day)
float nightAlpha = ( u _radiiAndDynamicAtmosphereColor . z != 0.0 ) ? clamp ( dot ( normalize ( positionWC ) , lightDirection ) , 0.0 , 1.0 ) : 1.0 ;
opacity *= pow ( nightAlpha , 0.5 ) ;
}
` ,jue= ` varying vec3 v _outerPositionWC ;
uniform vec3 u _hsbShift ;
# ifndef PER _FRAGMENT _ATMOSPHERE
varying vec3 v _mieColor ;
varying vec3 v _rayleighColor ;
varying float v _opacity ;
varying float v _translucent ;
# endif
void main ( void )
{
vec3 lightDirection = getLightDirection ( v _outerPositionWC ) ;
vec3 mieColor ;
vec3 rayleighColor ;
float opacity ;
float translucent ;
# ifdef PER _FRAGMENT _ATMOSPHERE
computeAtmosphereScattering (
v _outerPositionWC ,
lightDirection ,
rayleighColor ,
mieColor ,
opacity ,
translucent
) ;
# else
mieColor = v _mieColor ;
rayleighColor = v _rayleighColor ;
opacity = v _opacity ;
translucent = v _translucent ;
# endif
vec4 color = computeAtmosphereColor ( v _outerPositionWC , lightDirection , rayleighColor , mieColor , opacity ) ;
# ifndef HDR
color . rgb = czm _acesTonemapping ( color . rgb ) ;
color . rgb = czm _inverseGamma ( color . rgb ) ;
# endif
# ifdef COLOR _CORRECT
// Convert rgb color to hsb
vec3 hsb = czm _RGBToHSB ( color . rgb ) ;
// Perform hsb shift
hsb . x += u _hsbShift . x ; // hue
hsb . y = clamp ( hsb . y + u _hsbShift . y , 0.0 , 1.0 ) ; // saturation
hsb . z = hsb . z > czm _epsilon7 ? hsb . z + u _hsbShift . z : 0.0 ; // brightness
// Convert shifted hsb back to rgb
color . rgb = czm _HSBToRGB ( hsb ) ;
# endif
// For the parts of the sky atmosphere that are not behind a translucent globe,
// we mix in the default opacity so that the sky atmosphere still appears at distance.
// This is needed because the opacity in the sky atmosphere is initially adjusted based
// on the camera height.
if ( translucent == 0.0 ) {
color . a = mix ( color . b , 1.0 , color . a ) * smoothstep ( 0.0 , 1.0 , czm _morphTime ) ;
}
gl _FragColor = color ;
}
` ,que= ` attribute vec4 position ;
varying vec3 v _outerPositionWC ;
# ifndef PER _FRAGMENT _ATMOSPHERE
varying vec3 v _mieColor ;
varying vec3 v _rayleighColor ;
varying float v _opacity ;
varying float v _translucent ;
# endif
void main ( void )
{
vec4 positionWC = czm _model * position ;
vec3 lightDirection = getLightDirection ( positionWC . xyz ) ;
# ifndef PER _FRAGMENT _ATMOSPHERE
computeAtmosphereScattering (
positionWC . xyz ,
lightDirection ,
v _rayleighColor ,
v _mieColor ,
v _opacity ,
v _translucent
) ;
# endif
v _outerPositionWC = positionWC . xyz ;
gl _Position = czm _modelViewProjection * position ;
}
` ,Yue= ` uniform samplerCube u _cubeMap ;
varying vec3 v _texCoord ;
void main ( )
{
vec4 color = textureCube ( u _cubeMap , normalize ( v _texCoord ) ) ;
gl _FragColor = vec4 ( czm _gammaCorrect ( color ) . rgb , czm _morphTime ) ;
}
` ,Xue= ` attribute vec3 position ;
varying vec3 v _texCoord ;
void main ( )
{
vec3 p = czm _viewRotation * ( czm _temeToPseudoFixed * ( czm _entireFrustum . y * position ) ) ;
gl _Position = czm _projection * vec4 ( p , 1.0 ) ;
v _texCoord = position . xyz ;
}
` , $ ue= ` uniform sampler2D u _texture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 color = texture2D ( u _texture , v _textureCoordinates ) ;
gl _FragColor = czm _gammaCorrect ( color ) ;
}
` ,Kue= ` uniform float u _radiusTS ;
varying vec2 v _textureCoordinates ;
vec2 rotate ( vec2 p , vec2 direction )
{
return vec2 ( p . x * direction . x - p . y * direction . y , p . x * direction . y + p . y * direction . x ) ;
}
vec4 addBurst ( vec2 position , vec2 direction , float lengthScalar )
{
vec2 rotatedPosition = rotate ( position , direction ) * vec2 ( 25.0 , 0.75 ) ;
float radius = length ( rotatedPosition ) * lengthScalar ;
float burst = 1.0 - smoothstep ( 0.0 , 0.55 , radius ) ;
return vec4 ( burst ) ;
}
void main ( )
{
float lengthScalar = 2.0 / sqrt ( 2.0 ) ;
vec2 position = v _textureCoordinates - vec2 ( 0.5 ) ;
float radius = length ( position ) * lengthScalar ;
float surface = step ( radius , u _radiusTS ) ;
vec4 color = vec4 ( vec2 ( 1.0 ) , surface + 0.2 , surface ) ;
float glow = 1.0 - smoothstep ( 0.0 , 0.55 , radius ) ;
color . ba += mix ( vec2 ( 0.0 ) , vec2 ( 1.0 ) , glow ) * 0.75 ;
vec4 burst = vec4 ( 0.0 ) ;
// The following loop has been manually unrolled for speed, to
// avoid sin() and cos().
//
//for (float i = 0.4; i < 3.2; i += 1.047) {
// vec2 direction = vec2(sin(i), cos(i));
// burst += 0.4 * addBurst(position, direction, lengthScalar);
//
// direction = vec2(sin(i - 0.08), cos(i - 0.08));
// burst += 0.3 * addBurst(position, direction, lengthScalar);
//}
burst += 0.4 * addBurst ( position , vec2 ( 0.38942 , 0.92106 ) , lengthScalar ) ; // angle == 0.4
burst += 0.4 * addBurst ( position , vec2 ( 0.99235 , 0.12348 ) , lengthScalar ) ; // angle == 0.4 + 1.047
burst += 0.4 * addBurst ( position , vec2 ( 0.60327 , - 0.79754 ) , lengthScalar ) ; // angle == 0.4 + 1.047 * 2.0
burst += 0.3 * addBurst ( position , vec2 ( 0.31457 , 0.94924 ) , lengthScalar ) ; // angle == 0.4 - 0.08
burst += 0.3 * addBurst ( position , vec2 ( 0.97931 , 0.20239 ) , lengthScalar ) ; // angle == 0.4 + 1.047 - 0.08
burst += 0.3 * addBurst ( position , vec2 ( 0.66507 , - 0.74678 ) , lengthScalar ) ; // angle == 0.4 + 1.047 * 2.0 - 0.08
// End of manual loop unrolling.
color += clamp ( burst , vec4 ( 0.0 ) , vec4 ( 1.0 ) ) * 0.15 ;
gl _FragColor = clamp ( color , vec4 ( 0.0 ) , vec4 ( 1.0 ) ) ;
}
` ,Jue= ` attribute vec2 direction ;
uniform float u _size ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 position ;
if ( czm _morphTime == 1.0 )
{
position = vec4 ( czm _sunPositionWC , 1.0 ) ;
}
else
{
position = vec4 ( czm _sunPositionColumbusView . zxy , 1.0 ) ;
}
vec4 positionEC = czm _view * position ;
vec4 positionWC = czm _eyeToWindowCoordinates ( positionEC ) ;
vec2 halfSize = vec2 ( u _size * 0.5 ) ;
halfSize *= ( ( direction * 2.0 ) - 1.0 ) ;
gl _Position = czm _viewportOrthographic * vec4 ( positionWC . xy + halfSize , - positionWC . z , 1.0 ) ;
v _textureCoordinates = direction ;
}
` ,Que= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
varying vec4 v _startPlaneEC ;
varying vec4 v _endPlaneEC ;
varying vec4 v _rightPlaneEC ;
varying float v _halfWidth ;
varying vec3 v _volumeUpEC ;
uniform vec4 u _highlightColor ;
void main ( )
{
float logDepthOrDepth = czm _branchFreeTernary ( czm _sceneMode == czm _sceneMode2D , gl _FragCoord . z , czm _unpackDepth ( texture2D ( czm _globeDepthTexture , gl _FragCoord . xy / czm _viewport . zw ) ) ) ;
// Discard for sky
if ( logDepthOrDepth == 0.0 ) {
# ifdef DEBUG _SHOW _VOLUME
gl _FragColor = vec4 ( 0.0 , 0.0 , 1.0 , 0.5 ) ;
return ;
# else // DEBUG_SHOW_VOLUME
discard ;
# endif // DEBUG_SHOW_VOLUME
}
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , logDepthOrDepth ) ;
eyeCoordinate /= eyeCoordinate . w ;
float halfMaxWidth = v _halfWidth * czm _metersPerPixel ( eyeCoordinate ) ;
// Expand halfMaxWidth if direction to camera is almost perpendicular with the volume's up direction
halfMaxWidth += halfMaxWidth * ( 1.0 - dot ( - normalize ( eyeCoordinate . xyz ) , v _volumeUpEC ) ) ;
// Check distance of the eye coordinate against the right-facing plane
float widthwiseDistance = czm _planeDistance ( v _rightPlaneEC , eyeCoordinate . xyz ) ;
// Check eye coordinate against the mitering planes
float distanceFromStart = czm _planeDistance ( v _startPlaneEC , eyeCoordinate . xyz ) ;
float distanceFromEnd = czm _planeDistance ( v _endPlaneEC , eyeCoordinate . xyz ) ;
if ( abs ( widthwiseDistance ) > halfMaxWidth || distanceFromStart < 0.0 || distanceFromEnd < 0.0 ) {
# ifdef DEBUG _SHOW _VOLUME
gl _FragColor = vec4 ( logDepthOrDepth , 0.0 , 0.0 , 0.5 ) ;
return ;
# else // DEBUG_SHOW_VOLUME
discard ;
# endif // DEBUG_SHOW_VOLUME
}
gl _FragColor = u _highlightColor ;
czm _writeDepthClamp ( ) ;
}
` ,Zue= ` attribute vec3 startEllipsoidNormal ;
attribute vec3 endEllipsoidNormal ;
attribute vec4 startPositionAndHeight ;
attribute vec4 endPositionAndHeight ;
attribute vec4 startFaceNormalAndVertexCorner ;
attribute vec4 endFaceNormalAndHalfWidth ;
attribute float a _batchId ;
uniform mat4 u _modifiedModelView ;
uniform vec2 u _minimumMaximumVectorHeights ;
varying vec4 v _startPlaneEC ;
varying vec4 v _endPlaneEC ;
varying vec4 v _rightPlaneEC ;
varying float v _halfWidth ;
varying vec3 v _volumeUpEC ;
void main ( )
{
// vertex corner IDs
// 3-----------7
// /| left /|
// / | 1 / |
// 2-----------6 5 end
// | / | /
// start |/ right |/
// 0-----------4
//
float isEnd = floor ( startFaceNormalAndVertexCorner . w * 0.251 ) ; // 0 for front, 1 for end
float isTop = floor ( startFaceNormalAndVertexCorner . w * mix ( 0.51 , 0.19 , isEnd ) ) ; // 0 for bottom, 1 for top
vec3 forward = endPositionAndHeight . xyz - startPositionAndHeight . xyz ;
vec3 right = normalize ( cross ( forward , startEllipsoidNormal ) ) ;
vec4 position = vec4 ( startPositionAndHeight . xyz , 1.0 ) ;
position . xyz += forward * isEnd ;
v _volumeUpEC = czm _normal * normalize ( cross ( right , forward ) ) ;
// Push for volume height
float offset ;
vec3 ellipsoidNormal = mix ( startEllipsoidNormal , endEllipsoidNormal , isEnd ) ;
// offset height to create volume
offset = mix ( startPositionAndHeight . w , endPositionAndHeight . w , isEnd ) ;
offset = mix ( u _minimumMaximumVectorHeights . y , u _minimumMaximumVectorHeights . x , isTop ) - offset ;
position . xyz += offset * ellipsoidNormal ;
// move from RTC to EC
position = u _modifiedModelView * position ;
right = czm _normal * right ;
// Push for width in a direction that is in the start or end plane and in a plane with right
// N = normalEC ("right-facing" direction for push)
// R = right
// p = angle between N and R
// w = distance to push along R if R == N
// d = distance to push along N
//
// N R
// { p| } * cos(p) = dot(N, R) = w / d
// d | |w * d = w / dot(N, R)
// { | }
// o---------- polyline segment ---->
//
vec3 scratchNormal = mix ( - startFaceNormalAndVertexCorner . xyz , endFaceNormalAndHalfWidth . xyz , isEnd ) ;
scratchNormal = cross ( scratchNormal , mix ( startEllipsoidNormal , endEllipsoidNormal , isEnd ) ) ;
vec3 miterPushNormal = czm _normal * normalize ( scratchNormal ) ;
offset = 2.0 * endFaceNormalAndHalfWidth . w * max ( 0.0 , czm _metersPerPixel ( position ) ) ; // offset = widthEC
offset = offset / dot ( miterPushNormal , right ) ;
position . xyz += miterPushNormal * ( offset * sign ( 0.5 - mod ( startFaceNormalAndVertexCorner . w , 2.0 ) ) ) ;
gl _Position = czm _depthClamp ( czm _projection * position ) ;
position = u _modifiedModelView * vec4 ( startPositionAndHeight . xyz , 1.0 ) ;
vec3 startNormalEC = czm _normal * startFaceNormalAndVertexCorner . xyz ;
v _startPlaneEC = vec4 ( startNormalEC , - dot ( startNormalEC , position . xyz ) ) ;
v _rightPlaneEC = vec4 ( right , - dot ( right , position . xyz ) ) ;
position = u _modifiedModelView * vec4 ( endPositionAndHeight . xyz , 1.0 ) ;
vec3 endNormalEC = czm _normal * endFaceNormalAndHalfWidth . xyz ;
v _endPlaneEC = vec4 ( endNormalEC , - dot ( endNormalEC , position . xyz ) ) ;
v _halfWidth = endFaceNormalAndHalfWidth . w ;
}
` ,efe= ` attribute vec4 currentPosition ;
attribute vec4 previousPosition ;
attribute vec4 nextPosition ;
attribute vec2 expandAndWidth ;
attribute float a _batchId ;
uniform mat4 u _modifiedModelView ;
void main ( )
{
float expandDir = expandAndWidth . x ;
float width = abs ( expandAndWidth . y ) + 0.5 ;
bool usePrev = expandAndWidth . y < 0.0 ;
vec4 p = u _modifiedModelView * currentPosition ;
vec4 prev = u _modifiedModelView * previousPosition ;
vec4 next = u _modifiedModelView * nextPosition ;
float angle ;
vec4 positionWC = getPolylineWindowCoordinatesEC ( p , prev , next , expandDir , width , usePrev , angle ) ;
gl _Position = czm _viewportOrthographic * positionWC ;
}
` ,D2= ` attribute vec3 position ;
attribute float a _batchId ;
uniform mat4 u _modifiedModelViewProjection ;
void main ( )
{
gl _Position = czm _depthClamp ( u _modifiedModelViewProjection * vec4 ( position , 1.0 ) ) ;
}
` ;/*! @license DOMPurify 2.4.1 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.4.1/LICENSE */function ah(e){return ah=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ah(e)}function s1(e,t){return s1=Object.setPrototypeOf||function(i,o){return i.__proto__=o,i},s1(e,t)}function tfe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function rx(e,t,n){return tfe()?rx=Reflect.construct:rx=function(o,r,s){var a=[null];a.push.apply(a,r);var c=Function.bind.apply(o,a),u=new c;return s&&s1(u,s.prototype),u},rx.apply(null,arguments)}function cl(e){return nfe(e)||ife(e)||ofe(e)||rfe()}function nfe(e){if(Array.isArray(e))return a1(e)}function ife(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ofe(e,t){if(e){if(typeof e=="string")return a1(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array $ /.test(n))return a1(e,t)}}function a1(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n<t;n++)i[n]=e[n];return i}function rfe(){throw new TypeError( ` Invalid attempt to spread non - iterable instance .
In order to be iterable , non - array objects must have a [ Symbol . iterator ] ( ) method . ` )}var sfe=Object.hasOwnProperty,I2=Object.setPrototypeOf,afe=Object.isFrozen,cfe=Object.getPrototypeOf,lfe=Object.getOwnPropertyDescriptor,aa=Object.freeze,Bl=Object.seal,ufe=Object.create,d6=typeof Reflect<"u"&&Reflect,rw=d6.apply,c1=d6.construct;rw||(rw=function(t,n,i){return t.apply(n,i)});aa||(aa=function(t){return t});Bl||(Bl=function(t){return t});c1||(c1=function(t,n){return rx(t,cl(n))});var ffe=Hc(Array.prototype.forEach),P2=Hc(Array.prototype.pop),t0=Hc(Array.prototype.push),sx=Hc(String.prototype.toLowerCase),xD=Hc(String.prototype.toString),dfe=Hc(String.prototype.match),nl=Hc(String.prototype.replace),hfe=Hc(String.prototype.indexOf),pfe=Hc(String.prototype.trim),Qs=Hc(RegExp.prototype.test),wD=mfe(TypeError);function Hc(e){return function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];return rw(e,t,i)}}function mfe(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return c1(e,n)}}function Nn(e,t,n){n=n||sx,I2&&I2(e,null);for(var i=t.length;i--;){var o=t[i];if(typeof o=="string"){var r=n(o);r!==o&&(afe(t)||(t[i]=r),o=r)}e[o]=!0}return e}function Tp(e){var t=ufe(null),n;for(n in e)rw(sfe,e,[n])&&(t[n]=e[n]);return t}function lb(e,t){for(;e!==null;){var n=lfe(e,t);if(n){if(n.get)return Hc(n.get);if(typeof n.value=="function")return Hc(n.value)}e=cfe(e)}function i(o){return console.warn("fallback value for",o),null}return i}var O2=aa(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),SD=aa(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),vD=aa(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),_fe=aa(["animate","color-profile","cursor","discard","fedropshadow","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),DD=aa(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),gfe=aa(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),L2=aa(["#text"]),B2=aa(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked",
` +mo),Q&&(mo=nl(mo,D," "),mo=nl(mo,O," "),mo=nl(mo,M," ")),S&&Pe?S.createHTML(mo):mo},t.setConfig=function(gt){ $ n(gt),de=!0},t.clearConfig=function(){Ti=null,de=!1},t.isValidAttribute=function(gt,be,je){Ti|| $ n({});var tt=Jt(gt),Hn=Jt(be);return Mi(tt,Hn,je)},t.addHook=function(gt,be){typeof be=="function"&&(m[gt]=m[gt]||[],t0(m[gt],be))},t.removeHook=function(gt){if(m[gt])return P2(m[gt])},t.removeHooks=function(gt){m[gt]&&(m[gt]=[])},t.removeAllHooks=function(){m={}},t}var Ife=h6();let Pfe=0;const PD={};function Xn(e,t){T.typeOf.string("html",e);let n;const i=e;l(PD[i])?n=PD[i]:(n=Pfe++,PD[i]=n),t=y(t,!1),this._id=n,this._html=e,this._showOnScreen=t,this._element=void 0}Object.defineProperties(Xn.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)){const e=Ife.sanitize(this._html),t=document.createElement("div");t._creditId=this._id,t.style.display="inline",t.innerHTML=e;const n=t.querySelectorAll("a");for(let i=0;i<n.length;i++)n[i].setAttribute("target","_blank");this._element=t}return this._element}}});Xn.equals=function(e,t){return e===t||l(e)&&l(t)&&e._id===t._id&&e._showOnScreen===t._showOnScreen};Xn.prototype.equals=function(e){return Xn.equals(this,e)};Xn.getIonCredit=function(e){const t=l(e.collapsible)&&!e.collapsible,n=new Xn(e.html,t);return n._isIon=n.html.indexOf("ion-credit.png")!==-1,n};Xn.clone=function(e){if(l(e))return new Xn(e.html,e.showOnScreen)};let OD;const p6="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyZTlhMmUzMS1iZjI3LTRhMmQtYjFkZi02MDhlMDZjZDlmNDIiLCJpZCI6MjU5LCJpYXQiOjE2NzI2ODQyMDR9.GfS2oIjtP-hkhYm4g_Y6Vvpdp954z30qPWJnlNBF-co",AS={};AS.defaultAccessToken=p6;AS.defaultServer=new Re({url:"https://api.cesium.com/"});AS.getDefaultTokenCredit=function(e){if(e===p6){if(!l(OD)){const t= ` < b > This application is using Cesium ' s default ion access token . Please assign < i > Cesium . Ion . defaultAccessToken < /i> with an access token from your ion account before making any Cesium API calls. You can sign up for a free ion account at <a href="https:/ / cesium . com ">https://cesium.com</a>.</b>`;OD=new Xn(t,!0)}return OD}};const _m=AS;function qr(e,t){T.defined(" endpoint ",e),T.defined(" endpointResource ",t);let n;const i=e.externalType,o=l(i);if(!o)n={url:e.url,retryAttempts:1,retryCallback:Ofe};else if(i===" 3 DTILES "||i===" STK _TERRAIN _SERVER ")n={url:e.options.url};else throw new Se(" Ion . createResource does not support external imagery assets ; use IonImageryProvider instead . " ) ; Re . call ( this , n ) , this . _ionEndpoint = e , this . _ionEndpointDomain = o ? void 0 : new us ( e . url ) . authority ( ) , this . _ionEndpointResource = t , this . _ionRoot = void 0 , this . _pendingPromise = void 0 , this . _credits = void 0 , this . _isExternal = o } l ( Object . create ) && ( qr . prototype = Object . create ( Re . prototype ) , qr . prototype . constructor = qr ) ; qr . fromAssetId = function ( e , t ) { const n = qr . _createEndpointResource ( e , t ) ; return n . fetchJson ( ) . then ( function ( i ) { return new qr ( i , n ) } ) } ; Object . defineProperties ( qr . prototype , { credits : { get : function ( ) { return l ( this . _ionRoot ) ? this . _ionRoot . credits : l ( this . _credits ) ? this . _credits : ( this . _credits = qr . getCreditsFromEndpoint ( this . _ionEndpoint , this . _ionEndpointResource ) , this . _credits ) } } } ) ; qr . getCreditsFromEndpoint = function ( e , t ) { const n = e . attributions . map ( Xn . getIonCredit ) , i = _m . getDefaultTokenCredit ( t . queryParameters . access _token ) ; return l ( i ) && n . push ( Xn . clone ( i ) ) , n } ; qr . prototype . clone = function ( e ) { const t = y ( this . _ionRoot , this ) ; return l ( e ) || ( e = new qr ( t . _ionEndpoint , t . _ionEndpointResource ) ) , e = Re . prototype . clone . call ( this , e ) , e . _ionRoot = t , e . _isExternal = this . _isExternal , e } ; qr . prototype . fetchImage = function ( e ) { if ( ! this . _isExternal ) { const t = e ; e = { preferBlob : ! 0 } , l ( t ) && ( e . flipY = t . flipY , e . preferImageBitmap = t . preferImageBitmap ) } return Re . prototype . fetchImage . call ( this , e ) } ; qr . prototype . _makeRequest = function ( e ) { return this . _isExternal || new us ( this . url ) . authority ( ) !== this . _ionEndpointDomain ? Re . prototype . _makeRequest . call ( this , e ) : ( l ( e . headers ) || ( e . headers = { } ) , e . headers . Author
$ { o } ` ),t}function Wi(e,t,n,i,o,r,s){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=o,this.timesRetried=y(r,0),this.retry=!1,this.error=s}Wi.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 Wi(t,i,o,r,s,0,a),n.numberOfListeners>0?n.raiseEvent(c):console.log( ` An error occurred in "${t.constructor.name}" : $ { l1 ( i ) } ` ),c};Wi.reportSuccess=function(e){l(e)&&(e.timesRetried=-1)};function Jn(e){this._ellipsoid=y(e,pe.WGS84),this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(Jn.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});Jn.mercatorAngleToGeodeticLatitude=function(e){return N.PI_OVER_TWO-2*Math.atan(Math.exp(-e))};Jn.geodeticLatitudeToMercatorAngle=function(e){e>Jn.MaximumLatitude?e=Jn.MaximumLatitude:e<-Jn.MaximumLatitude&&(e=-Jn.MaximumLatitude);const t=Math.sin(e);return .5*Math.log((1+t)/(1-t))};Jn.MaximumLatitude=Jn.mercatorAngleToGeodeticLatitude(Math.PI);Jn.prototype.project=function(e,t){const n=this._semimajorAxis,i=e.longitude*n,o=Jn.geodeticLatitudeToMercatorAngle(e.latitude)*n,r=e.height;return l(t)?(t.x=i,t.y=o,t.z=r,t):new d(i,o,r)};Jn.prototype.unproject=function(e,t){if(!l(e))throw new E("cartesian is required");const n=this._oneOverSemimajorAxis,i=e.x*n,o=Jn.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)};function Xs(e){if(e=y(e,y.EMPTY_OBJECT),this._ellipsoid=y(e.ellipsoid,pe.WGS84),this._numberOfLevelZeroTilesX=y(e.numberOfLevelZeroTilesX,1),this._numberOfLevelZeroTilesY=y(e.numberOfLevelZeroTilesY,1),this._projection=new Jn(this._ellipsoid),l(e.rectangleSouthwestInMeters)&&l(e.rectangleNortheastInMeters))this._rectangleSouthwestInMeters=e.rectangleSouthwestInMeters,this._rectangleNortheastInMeters=e.rectangleNortheastInMeters;else{const i=this._ellipsoid.maximumRadius*Math.PI;this._rectangleSouthwestInMeters=new j(-i,-i),this._rectangleNortheastInMeters=new j(i,i)}const t=this._projection.unproject(this._rectangleSouthwestInMeters),n=this._projection.unproject(this._rectangleNortheastInMeters);this._rectangle=new _e(t.longitude,t.latitude,n.longitude,n.latitude)}Object.defineProperties(Xs.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});Xs.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};Xs.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};Xs.prototype.rectangleToNativeRectangle=function(e,t){const n=this._projection,i=n.project(_e.southwest(e)),o=n.project(_e.northeast(e));return l(t)?(t.west=i.x,t.south=i.y,t.east=o.x,t.north=o.y,t):new _e(i.x,i.y,o.x,o.y)};Xs.prototype.tileXYToNativeRectangle=function(e,t,n,i){const o=this.getNumberOfXTilesAtLevel(n),r=this.getNumberOfYTilesAtLevel(n),s=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/o,a=this._rectangleSouthwestInMeters.x+e*s,c=this._rectangleSouthwestInMeters.x+(e+1)*s,u=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/r,f=this._rectangleNortheastInMeters.y-t*u,h=this._rectangleNortheastInMeters.y-(t+1)*u;return l(i)?(i.west=a,i.south=h,i.east=c,i.north=f,i):new _e(a,h,c,f)};Xs.prototype.tileXYToRectangle=function(e,t,n,i){const o=this.tileXYToNativeRectangle(e,t,n,i),r=this._projection,s=r.unproject(new j(o.west,o.south)),a=r.unproject(new j(o.east,o.north));return o.west=s.longitude,o.south=s.latitude,o.east=a.longitude,o.north=a.latitude,o};Xs.prototype.positionToTileXY=function(e,t,n){const i=this._rectangle;if(!_e.contains(i,e))return;const o=this.getNumberOfXTilesAtLevel(t),r=this.getNumberOfYTilesAtLevel(t),a=(this._rectangleNortheastInMeters.x-this._rectangleSouthwestInMeters.x)/o,u=(this._rectangleNortheastInMeters.y-this._rectangleSouthwestInMeters.y)/r,h=this._projection.project(e),_=h.x-this._rectangleSouthwestInMeters.x,g=this._rectangle
` ,c+=n?Upe(i):Hpe(i),c}function Upe(e){return ` float clip ( vec4 fragCoord , sampler2D clippingPlanes , mat4 clippingPlanesMatrix )
{
vec4 position = czm _windowToEyeCoordinates ( fragCoord ) ;
vec3 clipNormal = vec3 ( 0.0 ) ;
vec3 clipPosition = vec3 ( 0.0 ) ;
float clipAmount ;
float pixelWidth = czm _metersPerPixel ( position ) ;
bool breakAndDiscard = false ;
for ( int i = 0 ; i < $ { e } ; ++ i )
{
vec4 clippingPlane = getClippingPlane ( clippingPlanes , i , clippingPlanesMatrix ) ;
clipNormal = clippingPlane . xyz ;
clipPosition = - clippingPlane . w * clipNormal ;
float amount = dot ( clipNormal , ( position . xyz - clipPosition ) ) / pixelWidth ;
clipAmount = czm _branchFreeTernary ( i == 0 , amount , min ( amount , clipAmount ) ) ;
if ( amount <= 0.0 )
{
breakAndDiscard = true ;
break ;
}
}
if ( breakAndDiscard ) {
discard ;
}
return clipAmount ;
}
` }function Hpe(e){return ` float clip ( vec4 fragCoord , sampler2D clippingPlanes , mat4 clippingPlanesMatrix )
{
bool clipped = true ;
vec4 position = czm _windowToEyeCoordinates ( fragCoord ) ;
vec3 clipNormal = vec3 ( 0.0 ) ;
vec3 clipPosition = vec3 ( 0.0 ) ;
float clipAmount = 0.0 ;
float pixelWidth = czm _metersPerPixel ( position ) ;
for ( int i = 0 ; i < $ { e } ; ++ i )
{
vec4 clippingPlane = getClippingPlane ( clippingPlanes , i , clippingPlanesMatrix ) ;
clipNormal = clippingPlane . xyz ;
clipPosition = - clippingPlane . w * clipNormal ;
float amount = dot ( clipNormal , ( position . xyz - clipPosition ) ) / pixelWidth ;
clipAmount = max ( amount , clipAmount ) ;
clipped = clipped && ( amount <= 0.0 ) ;
}
if ( clipped )
{
discard ;
}
return clipAmount ;
}
` }function Vpe(e,t){const n=1/e,i=1/t;let o= ` $ { n } ` ;o.indexOf(".")===-1&&(o+=".0");let r= ` $ { i } ` ;return r.indexOf(".")===-1&&(r+=".0"), ` vec4 getClippingPlane ( highp sampler2D packedClippingPlanes , int clippingPlaneNumber , mat4 transform )
{
int pixY = clippingPlaneNumber / $ { e } ;
int pixX = clippingPlaneNumber - ( pixY * $ { e } ) ;
float u = ( float ( pixX ) + 0.5 ) * $ { o } ;
float v = ( float ( pixY ) + 0.5 ) * $ { r } ;
vec4 plane = texture2D ( packedClippingPlanes , vec2 ( u , v ) ) ;
return czm _transformPlane ( plane , transform ) ;
}
` }function kpe(e,t){const n=1/e,i=1/t;let o= ` $ { n } ` ;o.indexOf(".")===-1&&(o+=".0");let r= ` $ { i } ` ;return r.indexOf(".")===-1&&(r+=".0"), ` vec4 getClippingPlane ( highp sampler2D packedClippingPlanes , int clippingPlaneNumber , mat4 transform )
{
int clippingPlaneStartIndex = clippingPlaneNumber * 2 ;
int pixY = clippingPlaneStartIndex / $ { e } ;
int pixX = clippingPlaneStartIndex - ( pixY * $ { e } ) ;
float u = ( float ( pixX ) + 0.5 ) * $ { o } ;
float v = ( float ( pixY ) + 0.5 ) * $ { r } ;
vec4 oct32 = texture2D ( packedClippingPlanes , vec2 ( u , v ) ) * 255.0 ;
vec2 oct = vec2 ( oct32 . x * 256.0 + oct32 . y , oct32 . z * 256.0 + oct32 . w ) ;
vec4 plane ;
plane . xyz = czm _octDecode ( oct , 65535.0 ) ;
plane . w = czm _unpackFloat ( texture2D ( packedClippingPlanes , vec2 ( u + $ { o } , v ) ) ) ;
return czm _transformPlane ( plane , transform ) ;
}
` }function Gpe(e,t,n,i,o){this.numberOfDayTextures=e,this.flags=t,this.material=n,this.shaderProgram=i,this.clippingShaderState=o}function hR(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function Wpe(e){const 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); }";let o;switch(e){case le.SCENE3D:o=t;break;case le.SCENE2D:case le.COLUMBUS_VIEW:o=n;break;case le.MORPHING:o=i;break}return o}function jpe(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}hR.prototype.getShaderProgram=function(e){const t=e.frameState,n=e.surfaceTile,i=e.numberOfDayTextures,o=e.applyBrightness,r=e.applyContrast,s=e.applyHue,a=e.applySaturation,c=e.applyGamma,u=e.applyAlpha,f=e.applyDayNightAlpha,h=e.applySplit,_=e.showReflectiveOcean,g=e.showOceanWaves,p=e.enableLighting,A=e.dynamicAtmosphereLighting,C=e.dynamicAtmosphereLightingFromSun,b=e.showGroundAtmosphere,x=e.perFragmentGroundAtmosphere,w=e.hasVertexNormals,S=e.useWebMercatorProjection,P=e.enableFog,L=e.enableClippingPlanes,H=e.clippingPlanes,R=e.clippedByBoundaries,z=e.hasImageryLayerCutout,U=e.colorCorrect,v=e.highlightFillTile,I=e.colorToAlpha,m=e.hasGeodeticSurfaceNormals,D=e.hasExaggeration,O=e.showUndergroundColor,M=e.translucent;let V=0,k="";const G=n.renderedMesh.encoding;G.quantization===Ua.BITS12&&(V=1,k="QUANTIZATION_BITS12");let q=0,te="";R&&(q=1,te="TILE_LIMIT_RECTANGLE");let X=0, $ ="";z&&(X=1, $ ="APPLY_IMAGERY_CUTOUT");const Y=t.mode,ae=Y|o<<2|r<<3|s<<4|a<<5|c<<6|u<<7|_<<8|g<<9|p<<10|A<<11|C<<12|b<<13|x<<14|w<<15|S<<16|P<<17|V<<18|h<<19|L<<20|q<<21|X<<22|U<<23|v<<24|I<<25|m<<26|D<<27|O<<28|M<<29|f<<30;let ue=0;l(H)&&H.length>0&&(ue=L?H.clippingPlanesState:0);let re=n.surfaceShader;if(l(re)&&re.numberOfDayTextures===i&&re.flags===ae&&re.material===this.material&&re.clippingShaderState===ue)return re.shaderProgram;let he=this._shadersByTexturesFlags[i];if(l(he)||(he=this._shadersByTexturesFlags[i]=[]),re=he[ae],!l(re)||re.material!==this.material||re.clippingShaderState!==ue){const ce=this.baseVertexShaderSource.clone(),Q=this.baseFragmentShaderSource.clone();ue!==0&&Q.sources.unshift(dR(H,t.context)),ce.defines.push(k),Q.defines.push( ` TEXTURE _UNITS $ { i } ` ,te, $ ),o&&Q.defines.push("APPLY_BRIGHTNESS"),r&&Q.defines.push("APPLY_CONTRAST"),s&&Q.defines.push("APPLY_HUE"),a&&Q.defines.push("APPLY_SATURATION"),c&&Q.defines.push("APPLY_GAMMA"),u&&Q.defines.push("APPLY_ALPHA"),f&&Q.defines.push("APPLY_DAY_NIGHT_ALPHA"),_&&(Q.defines.push("SHOW_REFLECTIVE_OCEAN"),ce.defines.push("SHOW_REFLECTIVE_OCEAN")),g&&Q.defines.push("SHOW_OCEAN_WAVES"),I&&Q.defines.push("APPLY_COLOR_TO_ALPHA"),O&&(ce.defines.push("UNDERGROUND_COLOR"),Q.defines.push("UNDERGROUND_COLOR")),M&&(ce.defines.push("TRANSLUCENT"),Q.defines.push("TRANSLUCENT")),p&&(w?(ce.defines.push("ENABLE_VERTEX_LIGHTING"),Q.defines.push("ENABLE_VERTEX_LIGHTING")):(ce.defines.push("ENABLE_DAYNIGHT_SHADING"),Q.defines.push("ENABLE_DAYNIGHT_SHADING"))),A&&(ce.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),Q.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),C&&(ce.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),Q.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),b&&(ce.defines.push("GROUND_ATMOSPHERE"),Q.defines.push("GROUND_ATMOSPHERE"),x&&(ce.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"),Q.defines.push("PER_FRAGMENT_GROUND_ATMOSPHERE"))),ce.defines.push("INCLUDE_WEB_MERCATOR_Y"),Q.defines.push("INCLUDE_WEB_MERCATOR_Y"),P&&(ce.defines.push("FOG"),Q.defines.push("FOG")),h&&Q.define
{
vec4 color = initialColor ;
` ;z&&(ie+= ` vec4 cutoutAndColorResult ;
bool texelUnclipped ;
` );for(let me=0;me<i;++me)z?ie+= ` cutoutAndColorResult = u _dayTextureCutoutRectangles [ $ { me } ] ;
texelUnclipped = v _textureCoordinates . x < cutoutAndColorResult . x || cutoutAndColorResult . z < v _textureCoordinates . x || v _textureCoordinates . y < cutoutAndColorResult . y || cutoutAndColorResult . w < v _textureCoordinates . y ;
cutoutAndColorResult = sampleAndBlend (
` :ie+= ` color = sampleAndBlend (
` ,ie+= ` color ,
u _dayTextures [ $ { me } ] ,
u _dayTextureUseWebMercatorT [ $ { me } ] ? textureCoordinates . xz : textureCoordinates . xy ,
u _dayTextureTexCoordsRectangle [ $ { me } ] ,
u _dayTextureTranslationAndScale [ $ { me } ] ,
$ { u ? ` u_dayTextureAlpha[ ${ me } ] ` : "1.0" } ,
$ { f ? ` u_dayTextureNightAlpha[ ${ me } ] ` : "1.0" } ,
$ { f ? ` u_dayTextureDayAlpha[ ${ me } ] ` : "1.0" } ,
$ { o ? ` u_dayTextureBrightness[ ${ me } ] ` : "0.0" } ,
$ { r ? ` u_dayTextureContrast[ ${ me } ] ` : "0.0" } ,
$ { s ? ` u_dayTextureHue[ ${ me } ] ` : "0.0" } ,
$ { a ? ` u_dayTextureSaturation[ ${ me } ] ` : "0.0" } ,
$ { c ? ` u_dayTextureOneOverGamma[ ${ me } ] ` : "0.0" } ,
$ { h ? ` u_dayTextureSplit[ ${ me } ] ` : "0.0" } ,
$ { I ? ` u_colorsToAlpha[ ${ me } ] ` : "vec4(0.0)" } ,
nightBlend ) ;
` ,z&&(ie+= ` color = czm _branchFreeTernary ( texelUnclipped , cutoutAndColorResult , color ) ;
` );ie+= ` return color ;
} ` ,Q.sources.push(ie),ce.sources.push(Wpe(Y)),ce.sources.push(jpe(S));const de=un.fromCache({context:t.context,vertexShaderSource:ce,fragmentShaderSource:Q,attributeLocations:G.getAttributeLocations()});re=he[ae]=new Gpe(i,ae,this.material,de,ue)}return n.surfaceShader=re,re.shaderProgram};hR.prototype.destroy=function(){let e,t;const n=this._shadersByTexturesFlags;for(const i in n)if(n.hasOwnProperty(i)){const o=n[i];if(!l(o))continue;for(e in o)o.hasOwnProperty(e)&&(t=o[e],l(t)&&t.shaderProgram.destroy())}return Ue(this)};function Ri(e){e=y(e,y.EMPTY_OBJECT),this.position=e.position,this.normal=e.normal,this.st=e.st,this.bitangent=e.bitangent,this.tangent=e.tangent,this.color=e.color}const qpe={NONE:0,TOP:1,ALL:2},cn=Object.freeze(qpe),Ype=new d;function Xa(e){e=y(e,y.EMPTY_OBJECT);const t=e.minimum,n=e.maximum;if(T.typeOf.object("min",t),T.typeOf.object("max",n),l(e.offsetAttribute)&&e.offsetAttribute===cn.TOP)throw new E("GeometryOffsetAttribute.TOP is not a supported options.offsetAttribute for this geometry.");this._min=d.clone(t),this._max=d.clone(n),this._offsetAttribute=e.offsetAttribute,this._workerName="createBoxOutlineGeometry"}Xa.fromDimensions=function(e){e=y(e,y.EMPTY_OBJECT);const t=e.dimensions;T.typeOf.object("dimensions",t),T.typeOf.number.greaterThanOrEquals("dimensions.x",t.x,0),T.typeOf.number.greaterThanOrEquals("dimensions.y",t.y,0),T.typeOf.number.greaterThanOrEquals("dimensions.z",t.z,0);const n=d.multiplyByScalar(t,.5,new d);return new Xa({minimum:d.negate(n,new d),maximum:n,offsetAttribute:e.offsetAttribute})};Xa.fromAxisAlignedBoundingBox=function(e){return T.typeOf.object("boundindBox",e),new Xa({minimum:e.minimum,maximum:e.maximum})};Xa.packedLength=2*d.packedLength+1;Xa.pack=function(e,t,n){return T.typeOf.object("value",e),T.defined("array",t),n=y(n,0),d.pack(e._min,t,n),d.pack(e._max,t,n+d.packedLength),t[n+d.packedLength*2]=y(e._offsetAttribute,-1),t};const e9=new d,t9=new d,a3={minimum:e9,maximum:t9,offsetAttribute:void 0};Xa.unpack=function(e,t,n){T.defined("array",e),t=y(t,0);const i=d.unpack(e,t,e9),o=d.unpack(e,t+d.packedLength,t9),r=e[t+d.packedLength*2];return l(n)?(n._min=d.clone(i,n._min),n._max=d.clone(o,n._max),n._offsetAttribute=r===-1?void 0:r,n):(a3.offsetAttribute=r===-1?void 0:r,new Xa(a3))};Xa.createGeometry=function(e){const t=e._min,n=e._max;if(d.equals(t,n))return;const i=new Ri,o=new Uint16Array(12*2),r=new Float64Array(8*3);r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=n.x,r[4]=t.y,r[5]=t.z,r[6]=n.x,r[7]=n.y,r[8]=t.z,r[9]=t.x,r[10]=n.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=n.z,r[15]=n.x,r[16]=t.y,r[17]=n.z,r[18]=n.x,r[19]=n.y,r[20]=n.z,r[21]=t.x,r[22]=n.y,r[23]=n.z,i.position=new ze({componentDatatype:ee.DOUBLE,componentsPerAttribute:3,values:r}),o[0]=4,o[1]=5,o[2]=5,o[3]=6,o[4]=6,o[5]=7,o[6]=7,o[7]=4,o[8]=0,o[9]=1,o[10]=1,o[11]=2,o[12]=2,o[13]=3,o[14]=3,o[15]=0,o[16]=0,o[17]=4,o[18]=1,o[19]=5,o[20]=2,o[21]=6,o[22]=3,o[23]=7;const s=d.subtract(n,t,Ype),a=d.magnitude(s)*.5;if(l(e._offsetAttribute)){const c=r.length,u=e._offsetAttribute===cn.NONE?0:1,f=new Uint8Array(c/3).fill(u);i.applyOffset=new ze({componentDatatype:ee.UNSIGNED_BYTE,componentsPerAttribute:1,values:f})}return new vt({attributes:i,indices:o,primitiveType:Je.LINES,boundingSphere:new fe(d.ZERO,a),offsetAttribute:e._offsetAttribute})};function on(e,t,n,i){e=y(e,1),t=y(t,1),n=y(n,1),i=y(i,1),this.value=new Uint8Array([F.floatToByte(e),F.floatToByte(t),F.floatToByte(n),F.floatToByte(i)])}Object.defineProperties(on.prototype,{componentDatatype:{get:function(){return ee.UNSIGNED_BYTE}},componentsPerAttribute:{get:function(){return 4}},normalize:{get:function(){return!0}}});on.fromColor=function(e){if(!l(e))throw new E("color is required.");return new on(e.red,e.green,e.blue,e.alpha)};on.toValue=function(e,t){if(!l(e))throw new E("color is required.");return l(t)?e.toBytes(t):new Uint8Array(e.toBytes())};on.equals=function(e,t){return e===t||l(e)&&l(t)&&e.value[0]===t.value[0]&&e.value[1]===t.value[1]&&e.value[2]===t.value[2]&&e.value[3]===t.value[3]};function Zt(e){if(e=y(e,y.EMPTY_OBJECT),!l(e.geometry))throw new E(
varying vec3 v _normalEC ;
varying vec4 v _color ;
void main ( )
{
vec3 positionToEyeEC = - v _positionEC ;
vec3 normalEC = normalize ( v _normalEC ) ;
# ifdef FACE _FORWARD
normalEC = faceforward ( normalEC , vec3 ( 0.0 , 0.0 , 1.0 ) , - normalEC ) ;
# endif
vec4 color = czm _gammaCorrect ( v _color ) ;
czm _materialInput materialInput ;
materialInput . normalEC = normalEC ;
materialInput . positionToEyeEC = positionToEyeEC ;
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
gl _FragColor = czm _phong ( normalize ( positionToEyeEC ) , material , czm _lightDirectionEC ) ;
}
` ,t_e= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 normal ;
attribute vec4 color ;
attribute float batchId ;
varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
varying vec4 v _color ;
void main ( )
{
vec4 p = czm _computePosition ( ) ;
v _positionEC = ( czm _modelViewRelativeToEye * p ) . xyz ; // position in eye coordinates
v _normalEC = czm _normal * normal ; // normal in eye coordinates
v _color = color ;
gl _Position = czm _modelViewProjectionRelativeToEye * p ;
}
` ,d9= ` varying vec4 v _color ;
void main ( )
{
gl _FragColor = czm _gammaCorrect ( v _color ) ;
}
` ,n_e= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec4 color ;
attribute float batchId ;
varying vec4 v _color ;
void main ( )
{
vec4 p = czm _computePosition ( ) ;
v _color = color ;
gl _Position = czm _modelViewProjectionRelativeToEye * p ;
}
` ,i_e={FRONT:se.FRONT,BACK:se.BACK,FRONT_AND_BACK:se.FRONT_AND_BACK},Eo=Object.freeze(i_e);function ir(e){e=y(e,y.EMPTY_OBJECT),this.material=e.material,this.translucent=y(e.translucent,!0),this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=y(e.closed,!1)}Object.defineProperties(ir.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}}});ir.prototype.getFragmentShaderSource=function(){const 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( `
` )};ir.prototype.isTranslucent=function(){return l(this.material)&&this.material.isTranslucent()||!l(this.material)&&this.translucent};ir.prototype.getRenderState=function(){const e=this.isTranslucent(),t=lt(this.renderState,!1);return e?(t.depthMask=!1,t.blending=Si.ALPHA_BLEND):t.depthMask=!0,t};ir.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=Si.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:Eo.BACK}),l(n)&&(i=nn(n,i,!0)),i};function hn(e){e=y(e,y.EMPTY_OBJECT);const t=y(e.translucent,!0),n=y(e.closed,!1),i=y(e.flat,!1),o=i?n_e:t_e,r=i?d9:e_e,s=i?hn.FLAT_VERTEX_FORMAT:hn.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,o),this._fragmentShaderSource=y(e.fragmentShaderSource,r),this._renderState=ir.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=y(e.faceForward,!n)}Object.defineProperties(hn.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}}});hn.VERTEX_FORMAT=Ne.POSITION_AND_NORMAL;hn.FLAT_VERTEX_FORMAT=Ne.POSITION_ONLY;hn.prototype.getFragmentShaderSource=ir.prototype.getFragmentShaderSource;hn.prototype.isTranslucent=ir.prototype.isTranslucent;hn.prototype.getRenderState=ir.prototype.getRenderState;function o_e(e,t){if(!l(e))throw new E("array is required.");if(!l(t)||t<1)throw new E("numberOfArrays must be greater than 0.");const n=[],i=e.length;let o=0;for(;o<i;){const r=Math.ceil((i-o)/t--);n.push(e.slice(o,o+r)),o+=r}return n}function Wu(e,t,n){if(!l(e))throw new E("context is required");if(!l(t))throw new E("attributes is required");if(!l(n))throw new E("numberOfInstances is required");if(this._attributes=t,this._numberOfInstances=n,t.length===0)return;const i=r_e(t),o=e.floatingPointTexture,r=i===Ke.FLOAT&&!o,s=s_e(t,r),a=a_e(s,t,r),c=Math.floor(xt.maximumTextureSize/a),u=Math.min(n,c),f=a*u,h=Math.ceil(n/u),_=1/f,g=_*.5,p=1/h,A=p*.5;this._textureDimensions=new j(f,h),this._textureStep=new oe(_,g,p,A),this._pixelDatatype=r?Ke.UNSIGNED_BYTE:i,this._packFloats=r,this._offsets=s,this._stride=a,this._texture=void 0;const C=4*f*h;this._batchValues=i===Ke.FLOAT&&!r?new Float32Array(C):new Uint8Array(C),this._batchValuesDirty=!1}Object.defineProperties(Wu.prototype,{attributes:{get:function(){return this._attributes}},numberOfInstances:{get:function(){return this._numberOfInstances}}});function r_e(e){let t=!1;const n=e.length;for(let i=0;i<n;++i)if(e[i].componentDatatype!==ee.UNSIGNED_BYTE){t=!0;break}return t?Ke.FLOAT:Ke.UNSIGNED_BYTE}function h9(e,t){const n=e[t].componentsPerAttribute;return n===2?j:n===3?d:n===4?oe:Number}function s_e(e,t){const n=new Array(e.length);let i=0;const o=e.length;for(let r=0;r<o;++r){const a=e[r].componentDatatype;n[r]=i,a!==ee.UNSIGNED_BYTE&&t?i+=4:++i}return n}function a_e(e,t,n){const i=e.length,o=e[i-1];return t[i-1].componentDatatype!==ee.UNSIGNED_BYTE&&n?o+4:o+1}const X0=new oe;function c_e(e,t,n){let i=oe.unpack(e,t,X0);const o=oe.unpackFloat(i);i=oe.unpack(e,t+4,X0);const r=oe.unpackFloat(i);i=oe.unpack(e,t+8,X0);const s=oe.unpackFloat(i);i=oe.unpack(e,t+12,X0);const a=oe.unpackFloat(i);return oe.fromElements(o,r,s,a,n)}function l_e(e,t,n){let i=oe.packFloat(e.x,X0);oe.pack(i,t,n),i=oe.packFloat(e.y,i),oe.pack(i,t,n+4),i=oe.packFloat(e.z,i),oe.pack(i,t,n+8),i=oe.packFloat(e.w,i),oe.pack(i,t,n+12)}const w3=new oe;Wu.prototype.getBatchedAttribute=function(e,t,n){if(e<0||e>=this._numberOfInstances)throw new E("instanceIndex is out of range.");if(t<0||t>=this._attributes.length)throw new E("attributeIndex is out of range");const i=this._attributes,o=this._offsets[t],s=4*this._stride*e+4*o;let a;this._packFloats&&i[t].componentDatatype!==Ke.UNSIGNED_BYTE?a=c_e(this._ba
vec2 computeSt ( float batchId )
{
float stepX = batchTextureStep . x ;
float centerX = batchTextureStep . y ;
float numberOfAttributes = float ( $ { t } ) ;
return vec2 ( centerX + ( batchId * numberOfAttributes * stepX ) , 0.5 ) ;
}
` : ` uniform vec4 batchTextureStep ;
uniform vec2 batchTextureDimensions ;
vec2 computeSt ( float batchId )
{
float stepX = batchTextureStep . x ;
float centerX = batchTextureStep . y ;
float stepY = batchTextureStep . z ;
float centerY = batchTextureStep . w ;
float numberOfAttributes = float ( $ { t } ) ;
float xId = mod ( batchId * numberOfAttributes , batchTextureDimensions . x ) ;
float yId = floor ( batchId * numberOfAttributes / batchTextureDimensions . x ) ;
return vec2 ( centerX + ( xId * stepX ) , centerY + ( yId * stepY ) ) ;
}
` }function m_e(e){return e===1?"float": ` vec$ { e } ` }function __e(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function g_e(e,t){const i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,s=m_e(o),a=__e(o),c=e._offsets[t];let u= ` $ { s } $ { r } ( float batchId )
{
vec2 st = computeSt ( batchId ) ;
st . x += batchTextureStep . x * float ( $ { c } ) ;
` ;return e._packFloats&&i.componentDatatype!==Ke.UNSIGNED_BYTE?u+= ` vec4 textureValue ;
textureValue . x = czm _unpackFloat ( texture2D ( batchTexture , st ) ) ;
textureValue . y = czm _unpackFloat ( texture2D ( batchTexture , st + vec2 ( batchTextureStep . x , 0.0 ) ) ) ;
textureValue . z = czm _unpackFloat ( texture2D ( batchTexture , st + vec2 ( batchTextureStep . x * 2.0 , 0.0 ) ) ) ;
textureValue . w = czm _unpackFloat ( texture2D ( batchTexture , st + vec2 ( batchTextureStep . x * 3.0 , 0.0 ) ) ) ;
` :u+= ` vec4 textureValue = texture2D ( batchTexture , st ) ;
` ,u+= ` $ { s } value = textureValue$ { a } ;
` ,e._pixelDatatype===Ke.UNSIGNED_BYTE&&i.componentDatatype===ee.UNSIGNED_BYTE&&!i.normalize?u+= ` value *= 255.0 ;
` :e._pixelDatatype===Ke.FLOAT&&i.componentDatatype===ee.UNSIGNED_BYTE&&i.normalize&&(u+= ` value /= 255.0 ;
` ),u+= ` return value ;
}
` ,u}Wu.prototype.getVertexShaderCallback=function(){const e=this._attributes;if(e.length===0)return function(i){return i};let t= ` uniform highp sampler2D batchTexture ;
` ;t+= ` $ { p _e ( this ) }
` ;const n=e.length;for(let i=0;i<n;++i)t+=g_e(this,i);return function(i){const o=i.indexOf("void main"),r=i.substring(0,o),s=i.substring(o);return ` $ { r }
$ { t }
$ { s } ` }};Wu.prototype.isDestroyed=function(){return!1};Wu.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),Ue(this)};function vo(e,t,n){e=y(e,0),t=y(t,0),n=y(n,0),this.value=new Float32Array([e,t,n])}Object.defineProperties(vo.prototype,{componentDatatype:{get:function(){return ee.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}});vo.fromCartesian3=function(e){return T.defined("offset",e),new vo(e.x,e.y,e.z)};vo.toValue=function(e,t){return T.defined("offset",e),l(t)||(t=new Float32Array([e.x,e.y,e.z])),t[0]=e.x,t[1]=e.y,t[2]=e.z,t};function y_e(e,t,n){let i=!n;const o=e.length;let r;if(!i&&o>1){const s=e[0].modelMatrix;for(r=1;r<o;++r)if(!B.equals(s,e[r].modelMatrix)){i=!0;break}}if(i)for(r=0;r<o;++r)l(e[r].geometry)&&Oi.transformToWorldCoordinates(e[r]);else B.multiplyTransformation(t,e[0].modelMatrix,t)}function XD(e,t){const n=e.attributes,i=n.position,o=i.values.length/i.componentsPerAttribute;n.batchId=new ze({componentDatatype:ee.FLOAT,componentsPerAttribute:1,values:new Float32Array(o)});const r=n.batchId.values;for(let s=0;s<o;++s)r[s]=t}function A_e(e){const t=e.length;for(let n=0;n<t;++n){const i=e[n];l(i.geometry)?XD(i.geometry,n):l(i.westHemisphereGeometry)&&l(i.eastHemisphereGeometry)&&(XD(i.westHemisphereGeometry,n),XD(i.eastHemisphereGeometry,n))}}function C_e(e){const t=e.instances,n=e.projection,i=e.elementIndexUintSupported,o=e.scene3DOnly,r=e.vertexCacheOptimize,s=e.compressVertices,a=e.modelMatrix;let c,u,f,h=t.length;for(c=0;c<h;++c)if(l(t[c].geometry)){f=t[c].geometry.primitiveType;break}for(c=1;c<h;++c)if(l(t[c].geometry)&&t[c].geometry.primitiveType!==f)throw new E("All instance geometries must have the same primitiveType.");if(y_e(t,a,o),!o)for(c=0;c<h;++c)l(t[c].geometry)&&Oi.splitLongitude(t[c]);if(A_e(t),r)for(c=0;c<h;++c){const g=t[c];l(g.geometry)?(Oi.reorderForPostVertexCache(g.geometry),Oi.reorderForPreVertexCache(g.geometry)):l(g.westHemisphereGeometry)&&l(g.eastHemisphereGeometry)&&(Oi.reorderForPostVertexCache(g.westHemisphereGeometry),Oi.reorderForPreVertexCache(g.westHemisphereGeometry),Oi.reorderForPostVertexCache(g.eastHemisphereGeometry),Oi.reorderForPreVertexCache(g.eastHemisphereGeometry))}let _=Oi.combineInstances(t);for(h=_.length,c=0;c<h;++c){u=_[c];const g=u.attributes;if(o)for(const p in g)g.hasOwnProperty(p)&&g[p].componentDatatype===ee.DOUBLE&&Oi.encodeAttribute(u,p, ` $ { p } 3 DHigh ` , ` $ { p } 3 DLow ` );else for(const p in g)if(g.hasOwnProperty(p)&&g[p].componentDatatype===ee.DOUBLE){const A= ` $ { p } 3 D ` ,C= ` $ { p } 2 D ` ;Oi.projectTo2D(u,p,A,C,n),l(u.boundingSphere)&&p==="position"&&(u.boundingSphereCV=fe.fromVertices(u.attributes.position2D.values)),Oi.encodeAttribute(u,A, ` $ { A } High ` , ` $ { A } Low ` ),Oi.encodeAttribute(u,C, ` $ { C } High ` , ` $ { C } Low ` )}s&&Oi.compressVertices(u)}if(!i){let g=[];for(h=_.length,c=0;c<h;++c)u=_[c],g=g.concat(Oi.fitToUnsignedShortIndices(u));_=g}return _}function $ D(e,t,n,i){let o,r,s;const a=i.length-1;if(a>=0){const u=i[a];o=u.offset+u.count,s=u.index,r=n[s].indices.length}else o=0,s=0,r=n[s].indices.length;const c=e.length;for(let u=0;u<c;++u){const h=e[u][t];if(!l(h))continue;const _=h.indices.length;o+_>r&&(o=0,r=n[++s].indices.length),i.push({index:s,offset:o,count:_}),o+=_}}function T_e(e,t){const n=[];return $ D(e,"geometry",t,n), $ D(e,"westHemisphereGeometry",t,n), $ D(e,"eastHemisphereGeometry",t,n),n}const $ f={}; $ f.combineGeometry=function(e){let t,n;const i=e.instances,o=i.length;let r,s,a=!1;o>0&&(t=C_e(e),t.length>0&&(n=Oi.createAttributeLocations(t[0]),e.createPickOffsets&&(r=T_e(i,t))),l(i[0].attributes)&&l(i[0].attributes.offset)&&(s=new Array(o),a=!0));const c=new Array(o),u=new Array(o);for(let f=0;f<o;++f){const h=i[f],_=h.geometry;l(_)&&(c[f]=_.boundingSphere,u[f]=_.boundingSphereCV,a&&(s[f]=h.geometry.offsetAttribute));const g=h.eastHemisphereGeometry,p=h.westHemisphereGeometry;l(g)&&l(p)&&(l(g.boundingSphere)&&l(p.boundingSphere)&&(c[f]=fe.union(g.boundingSphere,p.boundingSphere)),l(g.boundingSphereCV)&&l(p.boundingSphereCV)&&(u[f]=fe.union(g.boundingSphereCV,p.boundingSphere
` ),l(e.rtcCenter)?(t=t.replace(/attribute \s +vec(?:3|4) \s +position3DHigh;/g,""),t=t.replace(/attribute \s +vec(?:3|4) \s +position3DLow;/g,""),o+= ` uniform mat4 u _modifiedModelView ;
` ,r+= ` attribute vec4 position ;
` ,s+= ` $ { c }
{
return u _modifiedModelView * position ;
}
` ,t=t.replace(/czm_modelViewRelativeToEye \s + \* \s +/g,""),t=t.replace(/czm_modelViewProjectionRelativeToEye/g,"czm_projection")):n?s+= ` $ { c }
{
return czm _translateRelativeToEye ( $ { a } 3 DHigh , $ { a } 3 DLow ) ;
}
` :(r+= ` attribute vec3 $ { a } 2 DHigh ;
attribute vec3 $ { a } 2 DLow ;
` ,s+= ` $ { c }
{
vec4 p ;
if ( czm _morphTime == 1.0 )
{
p = czm _translateRelativeToEye ( $ { a } 3 DHigh , $ { a } 3 DLow ) ;
}
else if ( czm _morphTime == 0.0 )
{
p = czm _translateRelativeToEye ( $ { a } 2 DHigh . zxy , $ { a } 2 DLow . zxy ) ;
}
else
{
p = czm _columbusViewMorph (
czm _translateRelativeToEye ( $ { a } 2 DHigh . zxy , $ { a } 2 DLow . zxy ) ,
czm _translateRelativeToEye ( $ { a } 3 DHigh , $ { a } 3 DLow ) ,
czm _morphTime ) ;
}
return p ;
}
` )}return[o,r,t,s].join( `
` )};Gt._appendShowToShader=function(e,t){return l(e._batchTableAttributeIndices.show)? ` $ { Ge . replaceMain ( t , "czm_non_show_main" ) }
void main ( )
{
czm _non _show _main ( ) ;
gl _Position *= czm _batchTable _show ( batchId ) ;
} ` :t};Gt._updateColorAttribute=function(e,t,n){if(!l(e._batchTableAttributeIndices.color)&&!l(e._batchTableAttributeIndices.depthFailColor)||t.search(/attribute \s +vec4 \s +color;/g)===-1)return t;if(n&&!l(e._batchTableAttributeIndices.depthFailColor))throw new E("A depthFailColor per-instance attribute is required when using a depth fail appearance that uses a color attribute.");let i=t;return i=i.replace(/attribute \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 D3(e){return ` $ { Ge . replaceMain ( e , "czm_non_pick_main" ) }
varying vec4 v _pickColor ;
void main ( )
{
czm _non _pick _main ( ) ;
v _pickColor = czm _batchTable _pickColor ( batchId ) ;
} ` }function I3(e){return ` varying vec4 v _pickColor ;
$ { e } ` }Gt._updatePickColorAttribute=function(e){let t=e.replace(/attribute \s +vec4 \s +pickColor;/g,"");return t=t.replace(/( \b )pickColor( \b )/g," $ 1czm_batchTable_pickColor(batchId) $ 2"),t};Gt._appendOffsetToShader=function(e,t){if(!l(e._batchTableAttributeIndices.offset))return t;let n= ` attribute float batchId ;
` ;n+="attribute float applyOffset;";let i=t.replace(/attribute \s +float \s +batchId;/g,n),o= ` vec4 $1 = czm _computePosition ( ) ;
` ;return o+= ` if ( czm _sceneMode == czm _sceneMode3D )
` ,o+= ` {
` ,o+=" $ 1 = $ 1 + vec4(czm_batchTable_offset(batchId) * applyOffset, 0.0);",o+= ` }
` ,o+= ` else
` ,o+= ` {
` ,o+=" $ 1 = $ 1 + vec4(czm_batchTable_offset2D(batchId) * applyOffset, 0.0);",o+= ` }
` ,i=i.replace(/vec4 \s +([A-Za-z0-9_]+) \s += \s +czm_computePosition \( \) ;/g,o),i};Gt._appendDistanceDisplayConditionToShader=function(e,t,n){if(!l(e._batchTableAttributeIndices.distanceDisplayCondition))return t;const i=Ge.replaceMain(t,"czm_non_distanceDisplayCondition_main");let o= ` void main ( )
{
czm _non _distanceDisplayCondition _main ( ) ;
vec2 distanceDisplayCondition = czm _batchTable _distanceDisplayCondition ( batchId ) ;
vec3 boundingSphereCenter3DHigh = czm _batchTable _boundingSphereCenter3DHigh ( batchId ) ;
vec3 boundingSphereCenter3DLow = czm _batchTable _boundingSphereCenter3DLow ( batchId ) ;
float boundingSphereRadius = czm _batchTable _boundingSphereRadius ( batchId ) ;
` ;return n?o+= ` vec4 centerRTE = czm _translateRelativeToEye ( boundingSphereCenter3DHigh , boundingSphereCenter3DLow ) ;
` :o+= ` vec3 boundingSphereCenter2DHigh = czm _batchTable _boundingSphereCenter2DHigh ( batchId ) ;
vec3 boundingSphereCenter2DLow = czm _batchTable _boundingSphereCenter2DLow ( batchId ) ;
vec4 centerRTE ;
if ( czm _morphTime == 1.0 )
{
centerRTE = czm _translateRelativeToEye ( boundingSphereCenter3DHigh , boundingSphereCenter3DLow ) ;
}
else if ( czm _morphTime == 0.0 )
{
centerRTE = czm _translateRelativeToEye ( boundingSphereCenter2DHigh . zxy , boundingSphereCenter2DLow . zxy ) ;
}
else
{
centerRTE = czm _columbusViewMorph (
czm _translateRelativeToEye ( boundingSphereCenter2DHigh . zxy , boundingSphereCenter2DLow . zxy ) ,
czm _translateRelativeToEye ( boundingSphereCenter3DHigh , boundingSphereCenter3DLow ) ,
czm _morphTime ) ;
}
` ,o+= ` float radiusSq = boundingSphereRadius * boundingSphereRadius ;
float distanceSq ;
if ( czm _sceneMode == czm _sceneMode2D )
{
distanceSq = czm _eyeHeight2D . y - radiusSq ;
}
else
{
distanceSq = dot ( centerRTE . xyz , centerRTE . xyz ) - radiusSq ;
}
distanceSq = max ( distanceSq , 0.0 ) ;
float nearSq = distanceDisplayCondition . x * distanceDisplayCondition . x ;
float farSq = distanceDisplayCondition . y * distanceDisplayCondition . y ;
float show = ( distanceSq >= nearSq && distanceSq <= farSq ) ? 1.0 : 0.0 ;
gl _Position *= show ;
} ` , ` $ { i }
$ { o } ` };function P3(e,t){if(!e.compressVertices)return t;const n=t.search(/attribute \s +vec3 \s +normal;/g)!==-1,i=t.search(/attribute \s +vec2 \s +st;/g)!==-1;if(!n&&!i)return t;const o=t.search(/attribute \s +vec3 \s +tangent;/g)!==-1,r=t.search(/attribute \s +vec3 \s +bitangent;/g)!==-1;let s=i&&n?2:1;s+=o||r?1:0;const a=s>1? ` vec$ { s } ` :"float",c="compressedAttributes",u= ` attribute $ { a } $ { c } ; ` ;let f="",h="";if(i){f+= ` vec2 st ;
` ;const p=s>1? ` $ { c } . x ` :c;h+= ` st = czm _decompressTextureCoordinates ( $ { p } ) ;
` }n&&o&&r?(f+= ` vec3 normal ;
vec3 tangent ;
vec3 bitangent ;
` ,h+= ` czm _octDecode ( $ { c } . $ { i ? "yz" : "xy" } , normal , tangent , bitangent ) ;
` ):(n&&(f+= ` vec3 normal ;
` ,h+= ` normal = czm _octDecode ( $ { c } $ { s > 1 ? ` . ${ i ? "y" : "x" } ` : "" } ) ;
` ),o&&(f+= ` vec3 tangent ;
` ,h+= ` tangent = czm _octDecode ( $ { c } . $ { i && n ? "z" : "y" } ) ;
` ),r&&(f+= ` vec3 bitangent ;
` ,h+= ` bitangent = czm _octDecode ( $ { c } . $ { i && n ? "z" : "y" } ) ;
` ));let _=t;_=_.replace(/attribute \s +vec3 \s +normal;/g,""),_=_.replace(/attribute \s +vec2 \s +st;/g,""),_=_.replace(/attribute \s +vec3 \s +tangent;/g,""),_=_.replace(/attribute \s +vec3 \s +bitangent;/g,""),_=Ge.replaceMain(_,"czm_non_compressed_main");const g= ` void main ( )
{
$ { h } czm _non _compressed _main ( ) ;
} ` ;return[u,f,_,g].join( `
` )}function M_e(e){let t=Ge.replaceMain(e,"czm_non_depth_clamp_main");return t+= ` void main ( ) {
czm _non _depth _clamp _main ( ) ;
gl _Position = czm _depthClamp ( gl _Position ) ; }
` ,t}function F_e(e){let t=Ge.replaceMain(e,"czm_non_depth_clamp_main");return t+= ` void main ( ) {
czm _non _depth _clamp _main ( ) ;
# if defined ( GL _EXT _frag _depth )
# if defined ( LOG _DEPTH )
czm _writeLogDepth ( ) ;
# else
czm _writeDepthClamp ( ) ;
# endif
# endif
}
` ,t= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
$ { t } ` ,t}function O3(e,t){const n=e.vertexAttributes;for(const i in n)if(n.hasOwnProperty(i)&&!l(t[i]))throw new E( ` Appearance / Geometry mismatch . The appearance requires vertex shader attribute input '${i}' , which was not computed as part of the Geometry . Use the appearance ' s vertexFormat property when constructing the geometry . ` )}function z_e(e,t){return function(){return e[t]}}const KD=Math.max(an.hardwareConcurrency-1,1);let vb;const U_e=new Ei("combineGeometry");function H_e(e,t){let n,i,o,r;const s=e._instanceIds;if(e._state===lr.READY){n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];const a=e._numberOfInstances=n.length,c=[];let u=[];for(o=0;o<a;++o){if(i=n[o].geometry,s.push(n[o].id),!l(i._workerName))throw new E("_workerName must be defined for asynchronous geometry.");u.push({moduleName:i._workerName,geometry:i})}if(!l(vb))for(vb=new Array(KD),o=0;o<KD;o++)vb[o]=new Ei("createGeometry");let f;for(u=o_e(u,KD),o=0;o<u.length;o++){let h=0;const _=u[o],g=_.length;for(r=0;r<g;++r)f=_[r],i=f.geometry,l(i.constructor.pack)&&(f.offset=h,h+=y(i.constructor.packedLength,i.packedLength));let p;if(h>0){const A=new Float64Array(h);for(p=[A.buffer],r=0;r<g;++r)f=_[r],i=f.geometry,l(i.constructor.pack)&&(i.constructor.pack(i,A,f.offset),f.geometry=A)}c.push(vb[o].scheduleTask({subTasks:u[o]},p))}e._state=lr.CREATING,Promise.all(c).then(function(h){e._createGeometryResults=h,e._state=lr.CREATED}).catch(function(h){wA(e,t,lr.FAILED,h)})}else if(e._state===lr.CREATED){const a=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];const c=t.scene3DOnly,u=t.mapProjection,f=U_e.scheduleTask(A1.packCombineGeometryParameters({createGeometryResults:e._createGeometryResults,instances:n,ellipsoid:u.ellipsoid,projection:u,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:c,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets},a),a);e._createGeometryResults=void 0,e._state=lr.COMBINING,Promise.resolve(f).then(function(h){const _=A1.unpackCombineGeometryResults(h);e._geometries=_.geometries,e._attributeLocations=_.attributeLocations,e.modelMatrix=B.clone(_.modelMatrix,e.modelMatrix),e._pickOffsets=_.pickOffsets,e._offsetInstanceExtend=_.offsetInstanceExtend,e._instanceBoundingSpheres=_.boundingSpheres,e._instanceBoundingSpheresCV=_.boundingSpheresCV,l(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=lr.COMBINED):wA(e,t,lr.FAILED,void 0)}).catch(function(h){wA(e,t,lr.FAILED,h)})}}function V_e(e,t){const n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances],i=e._numberOfInstances=n.length,o=new Array(i),r=e._instanceIds;let s,a,c=0;for(a=0;a<i;a++){s=n[a];const _=s.geometry;let g;l(_.attributes)&&l(_.primitiveType)?g=B_e(_):g=_.constructor.createGeometry(_),o[c++]=R_e(s,g),r.push(s.id)}o.length=c;const u=t.scene3DOnly,f=t.mapProjection,h=A1.combineGeometry({instances:o,ellipsoid:f.ellipsoid,projection:f,elementIndexUintSupported:t.context.elementIndexUint,scene3DOnly:u,vertexCacheOptimize:e.vertexCacheOptimize,compressVertices:e.compressVertices,modelMatrix:e.modelMatrix,createPickOffsets:e._createPickOffsets});e._geometries=h.geometries,e._attributeLocations=h.attributeLocations,e.modelMatrix=B.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=lr.COMBINED):wA(e,t,lr.FAILED,void 0)}function k_e(e,t){const n=e._batchTableAttributeIndices.offset;if(!e._recomputeBoundingSpheres||!l(n)){e._recomputeBoundingSpheres=!1;return}let i;const o=e._offsetInstanceExtend,r=e._instanceBoundingSpheres,s=r.length;let a=e._tempBoundingSpheres;if(!l(a)){for(a=new Array(s),i=0;i<s;i++)a[i]=new fe;e._tempBoundingSpheres=a}for(i=0;i<s;++i){let A=a[i];const C=e._batchTable.getBatchedAttribute(i,n,new d);A=r[i].clone
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec4 rampColor = texture2D ( image , vec2 ( materialInput . aspect / ( 2.0 * czm _pi ) , 0.5 ) ) ;
rampColor = czm _gammaCorrect ( rampColor ) ;
material . diffuse = rampColor . rgb ;
material . alpha = rampColor . a ;
return material ;
}
` ,_0e= ` uniform sampler2D image ;
uniform float strength ;
uniform vec2 repeat ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
vec2 centerPixel = fract ( repeat * st ) ;
float centerBump = texture2D ( image , centerPixel ) . channel ;
float imageWidth = float ( imageDimensions . x ) ;
vec2 rightPixel = fract ( repeat * ( st + vec2 ( 1.0 / imageWidth , 0.0 ) ) ) ;
float rightBump = texture2D ( image , rightPixel ) . channel ;
float imageHeight = float ( imageDimensions . y ) ;
vec2 leftPixel = fract ( repeat * ( st + vec2 ( 0.0 , 1.0 / imageHeight ) ) ) ;
float topBump = texture2D ( image , leftPixel ) . channel ;
vec3 normalTangentSpace = normalize ( vec3 ( centerBump - rightBump , centerBump - topBump , clamp ( 1.0 - strength , 0.1 , 1.0 ) ) ) ;
vec3 normalEC = materialInput . tangentToEyeMatrix * normalTangentSpace ;
material . normal = normalEC ;
material . diffuse = vec3 ( 0.01 ) ;
return material ;
}
` ,g0e= ` uniform vec4 lightColor ;
uniform vec4 darkColor ;
uniform vec2 repeat ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
// From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
float b = mod ( floor ( repeat . s * st . s ) + floor ( repeat . t * st . t ) , 2.0 ) ; // 0.0 or 1.0
// Find the distance from the closest separator (region between two colors)
float scaledWidth = fract ( repeat . s * st . s ) ;
scaledWidth = abs ( scaledWidth - floor ( scaledWidth + 0.5 ) ) ;
float scaledHeight = fract ( repeat . t * st . t ) ;
scaledHeight = abs ( scaledHeight - floor ( scaledHeight + 0.5 ) ) ;
float value = min ( scaledWidth , scaledHeight ) ;
vec4 currentColor = mix ( lightColor , darkColor , b ) ;
vec4 color = czm _antialias ( lightColor , darkColor , currentColor , value , 0.03 ) ;
color = czm _gammaCorrect ( color ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
return material ;
}
` ,y0e= ` uniform vec4 lightColor ;
uniform vec4 darkColor ;
uniform vec2 repeat ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
// From Stefan Gustavson's Procedural Textures in GLSL in OpenGL Insights
float b = smoothstep ( 0.3 , 0.32 , length ( fract ( repeat * materialInput . st ) - 0.5 ) ) ; // 0.0 or 1.0
vec4 color = mix ( lightColor , darkColor , b ) ;
color = czm _gammaCorrect ( color ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
return material ;
}
` ,A0e= ` uniform sampler2D heights ;
uniform sampler2D colors ;
// This material expects heights to be sorted from lowest to highest.
float getHeight ( int idx , float invTexSize )
{
vec2 uv = vec2 ( ( float ( idx ) + 0.5 ) * invTexSize , 0.5 ) ;
# ifdef OES _texture _float
return texture2D ( heights , uv ) . x ;
# else
return czm _unpackFloat ( texture2D ( heights , uv ) ) ;
# endif
}
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
float height = materialInput . height ;
float invTexSize = 1.0 / float ( heightsDimensions . x ) ;
float minHeight = getHeight ( 0 , invTexSize ) ;
float maxHeight = getHeight ( heightsDimensions . x - 1 , invTexSize ) ;
// early-out when outside the height range
if ( height < minHeight || height > maxHeight ) {
material . diffuse = vec3 ( 0.0 ) ;
material . alpha = 0.0 ;
return material ;
}
// Binary search to find heights above and below.
int idxBelow = 0 ;
int idxAbove = heightsDimensions . x ;
float heightBelow = minHeight ;
float heightAbove = maxHeight ;
// while loop not allowed, so use for loop with max iterations.
// maxIterations of 16 supports a texture size up to 65536 (2^16).
const int maxIterations = 16 ;
for ( int i = 0 ; i < maxIterations ; i ++ ) {
if ( idxBelow >= idxAbove - 1 ) {
break ;
}
int idxMid = ( idxBelow + idxAbove ) / 2 ;
float heightTex = getHeight ( idxMid , invTexSize ) ;
if ( height > heightTex ) {
idxBelow = idxMid ;
heightBelow = heightTex ;
} else {
idxAbove = idxMid ;
heightAbove = heightTex ;
}
}
float lerper = heightBelow == heightAbove ? 1.0 : ( height - heightBelow ) / ( heightAbove - heightBelow ) ;
vec2 colorUv = vec2 ( invTexSize * ( float ( idxBelow ) + 0.5 + lerper ) , 0.5 ) ;
vec4 color = texture2D ( colors , colorUv ) ;
// undo preumultiplied alpha
if ( color . a > 0.0 )
{
color . rgb /= color . a ;
}
color . rgb = czm _gammaCorrect ( color . rgb ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
return material ;
}
` ,C0e= ` # ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
uniform vec4 color ;
uniform float spacing ;
uniform float width ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
float distanceToContour = mod ( materialInput . height , spacing ) ;
# ifdef GL _OES _standard _derivatives
float dxc = abs ( dFdx ( materialInput . height ) ) ;
float dyc = abs ( dFdy ( materialInput . height ) ) ;
float dF = max ( dxc , dyc ) * czm _pixelRatio * width ;
float alpha = ( distanceToContour < dF ) ? 1.0 : 0.0 ;
# else
float alpha = ( distanceToContour < ( czm _pixelRatio * width ) ) ? 1.0 : 0.0 ;
# endif
vec4 outColor = czm _gammaCorrect ( vec4 ( color . rgb , alpha * color . a ) ) ;
material . diffuse = outColor . rgb ;
material . alpha = outColor . a ;
return material ;
}
` ,T0e= ` uniform sampler2D image ;
uniform float minimumHeight ;
uniform float maximumHeight ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
float scaledHeight = clamp ( ( materialInput . height - minimumHeight ) / ( maximumHeight - minimumHeight ) , 0.0 , 1.0 ) ;
vec4 rampColor = texture2D ( image , vec2 ( scaledHeight , 0.5 ) ) ;
rampColor = czm _gammaCorrect ( rampColor ) ;
material . diffuse = rampColor . rgb ;
material . alpha = rampColor . a ;
return material ;
}
` ,b0e= ` uniform vec4 fadeInColor ;
uniform vec4 fadeOutColor ;
uniform float maximumDistance ;
uniform bool repeat ;
uniform vec2 fadeDirection ;
uniform vec2 time ;
float getTime ( float t , float coord )
{
float scalar = 1.0 / maximumDistance ;
float q = distance ( t , coord ) * scalar ;
if ( repeat )
{
float r = distance ( t , coord + 1.0 ) * scalar ;
float s = distance ( t , coord - 1.0 ) * scalar ;
q = min ( min ( r , s ) , q ) ;
}
return clamp ( q , 0.0 , 1.0 ) ;
}
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
float s = getTime ( time . x , st . s ) * fadeDirection . s ;
float t = getTime ( time . y , st . t ) * fadeDirection . t ;
float u = length ( vec2 ( s , t ) ) ;
vec4 color = mix ( fadeInColor , fadeOutColor , u ) ;
color = czm _gammaCorrect ( color ) ;
material . emission = color . rgb ;
material . alpha = color . a ;
return material ;
}
` ,E0e= ` # ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
uniform vec4 color ;
uniform float cellAlpha ;
uniform vec2 lineCount ;
uniform vec2 lineThickness ;
uniform vec2 lineOffset ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
float scaledWidth = fract ( lineCount . s * st . s - lineOffset . s ) ;
scaledWidth = abs ( scaledWidth - floor ( scaledWidth + 0.5 ) ) ;
float scaledHeight = fract ( lineCount . t * st . t - lineOffset . t ) ;
scaledHeight = abs ( scaledHeight - floor ( scaledHeight + 0.5 ) ) ;
float value ;
# ifdef GL _OES _standard _derivatives
// Fuzz Factor - Controls blurriness of lines
const float fuzz = 1.2 ;
vec2 thickness = ( lineThickness * czm _pixelRatio ) - 1.0 ;
// From "3D Engine Design for Virtual Globes" by Cozzi and Ring, Listing 4.13.
vec2 dx = abs ( dFdx ( st ) ) ;
vec2 dy = abs ( dFdy ( st ) ) ;
vec2 dF = vec2 ( max ( dx . s , dy . s ) , max ( dx . t , dy . t ) ) * lineCount ;
value = min (
smoothstep ( dF . s * thickness . s , dF . s * ( fuzz + thickness . s ) , scaledWidth ) ,
smoothstep ( dF . t * thickness . t , dF . t * ( fuzz + thickness . t ) , scaledHeight ) ) ;
# else
// Fuzz Factor - Controls blurriness of lines
const float fuzz = 0.05 ;
vec2 range = 0.5 - ( lineThickness * 0.05 ) ;
value = min (
1.0 - smoothstep ( range . s , range . s + fuzz , scaledWidth ) ,
1.0 - smoothstep ( range . t , range . t + fuzz , scaledHeight ) ) ;
# endif
// Edges taken from RimLightingMaterial.glsl
// See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html
float dRim = 1.0 - abs ( dot ( materialInput . normalEC , normalize ( materialInput . positionToEyeEC ) ) ) ;
float sRim = smoothstep ( 0.8 , 1.0 , dRim ) ;
value *= ( 1.0 - sRim ) ;
vec4 halfColor ;
halfColor . rgb = color . rgb * 0.5 ;
halfColor . a = color . a * ( 1.0 - ( ( 1.0 - cellAlpha ) * value ) ) ;
halfColor = czm _gammaCorrect ( halfColor ) ;
material . diffuse = halfColor . rgb ;
material . emission = halfColor . rgb ;
material . alpha = halfColor . a ;
return material ;
}
` ,x0e= ` uniform sampler2D image ;
uniform float strength ;
uniform vec2 repeat ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec4 textureValue = texture2D ( image , fract ( repeat * materialInput . st ) ) ;
vec3 normalTangentSpace = textureValue . channels ;
normalTangentSpace . xy = normalTangentSpace . xy * 2.0 - 1.0 ;
normalTangentSpace . z = clamp ( 1.0 - strength , 0.1 , 1.0 ) ;
normalTangentSpace = normalize ( normalTangentSpace ) ;
vec3 normalEC = materialInput . tangentToEyeMatrix * normalTangentSpace ;
material . normal = normalEC ;
return material ;
}
` ,w0e= ` # ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
uniform vec4 color ;
float getPointOnLine ( vec2 p0 , vec2 p1 , float x )
{
float slope = ( p0 . y - p1 . y ) / ( p0 . x - p1 . x ) ;
return slope * ( x - p0 . x ) + p0 . y ;
}
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
# ifdef GL _OES _standard _derivatives
float base = 1.0 - abs ( fwidth ( st . s ) ) * 10.0 * czm _pixelRatio ;
# else
float base = 0.975 ; // 2.5% of the line will be the arrow head
# endif
vec2 center = vec2 ( 1.0 , 0.5 ) ;
float ptOnUpperLine = getPointOnLine ( vec2 ( base , 1.0 ) , center , st . s ) ;
float ptOnLowerLine = getPointOnLine ( vec2 ( base , 0.0 ) , center , st . s ) ;
float halfWidth = 0.15 ;
float s = step ( 0.5 - halfWidth , st . t ) ;
s *= 1.0 - step ( 0.5 + halfWidth , st . t ) ;
s *= 1.0 - step ( base , st . s ) ;
float t = step ( base , materialInput . st . s ) ;
t *= 1.0 - step ( ptOnUpperLine , st . t ) ;
t *= step ( ptOnLowerLine , st . t ) ;
// Find the distance from the closest separator (region between two colors)
float dist ;
if ( st . s < base )
{
float d1 = abs ( st . t - ( 0.5 - halfWidth ) ) ;
float d2 = abs ( st . t - ( 0.5 + halfWidth ) ) ;
dist = min ( d1 , d2 ) ;
}
else
{
float d1 = czm _infinity ;
if ( st . t < 0.5 - halfWidth && st . t > 0.5 + halfWidth )
{
d1 = abs ( st . s - base ) ;
}
float d2 = abs ( st . t - ptOnUpperLine ) ;
float d3 = abs ( st . t - ptOnLowerLine ) ;
dist = min ( min ( d1 , d2 ) , d3 ) ;
}
vec4 outsideColor = vec4 ( 0.0 ) ;
vec4 currentColor = mix ( outsideColor , color , clamp ( s + t , 0.0 , 1.0 ) ) ;
vec4 outColor = czm _antialias ( outsideColor , color , currentColor , dist ) ;
outColor = czm _gammaCorrect ( outColor ) ;
material . diffuse = outColor . rgb ;
material . alpha = outColor . a ;
return material ;
}
` ,S0e= ` uniform vec4 color ;
uniform vec4 gapColor ;
uniform float dashLength ;
uniform float dashPattern ;
varying float v _polylineAngle ;
const float maskLength = 16.0 ;
mat2 rotate ( float rad ) {
float c = cos ( rad ) ;
float s = sin ( rad ) ;
return mat2 (
c , s ,
- s , c
) ;
}
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 pos = rotate ( v _polylineAngle ) * gl _FragCoord . xy ;
// Get the relative position within the dash from 0 to 1
float dashPosition = fract ( pos . x / ( dashLength * czm _pixelRatio ) ) ;
// Figure out the mask index.
float maskIndex = floor ( dashPosition * maskLength ) ;
// Test the bit mask.
float maskTest = floor ( dashPattern / pow ( 2.0 , maskIndex ) ) ;
vec4 fragColor = ( mod ( maskTest , 2.0 ) < 1.0 ) ? gapColor : color ;
if ( fragColor . a < 0.005 ) { // matches 0/255 and 1/255
discard ;
}
fragColor = czm _gammaCorrect ( fragColor ) ;
material . emission = fragColor . rgb ;
material . alpha = fragColor . a ;
return material ;
}
` ,v0e= ` uniform vec4 color ;
uniform float glowPower ;
uniform float taperPower ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
float glow = glowPower / abs ( st . t - 0.5 ) - ( glowPower / 0.5 ) ;
if ( taperPower <= 0.99999 ) {
glow *= min ( 1.0 , taperPower / ( 0.5 - st . s * 0.5 ) - ( taperPower / 0.5 ) ) ;
}
vec4 fragColor ;
fragColor . rgb = max ( vec3 ( glow - 1.0 + color . rgb ) , color . rgb ) ;
fragColor . a = clamp ( 0.0 , 1.0 , glow ) * color . a ;
fragColor = czm _gammaCorrect ( fragColor ) ;
material . emission = fragColor . rgb ;
material . alpha = fragColor . a ;
return material ;
}
` ,D0e= ` uniform vec4 color ;
uniform vec4 outlineColor ;
uniform float outlineWidth ;
varying float v _width ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec2 st = materialInput . st ;
float halfInteriorWidth = 0.5 * ( v _width - outlineWidth ) / v _width ;
float b = step ( 0.5 - halfInteriorWidth , st . t ) ;
b *= 1.0 - step ( 0.5 + halfInteriorWidth , st . t ) ;
// Find the distance from the closest separator (region between two colors)
float d1 = abs ( st . t - ( 0.5 - halfInteriorWidth ) ) ;
float d2 = abs ( st . t - ( 0.5 + halfInteriorWidth ) ) ;
float dist = min ( d1 , d2 ) ;
vec4 currentColor = mix ( outlineColor , color , b ) ;
vec4 outColor = czm _antialias ( outlineColor , color , currentColor , dist ) ;
outColor = czm _gammaCorrect ( outColor ) ;
material . diffuse = outColor . rgb ;
material . alpha = outColor . a ;
return material ;
}
` ,I0e= ` uniform vec4 color ;
uniform vec4 rimColor ;
uniform float width ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
// See http://www.fundza.com/rman_shaders/surface/fake_rim/fake_rim1.html
float d = 1.0 - dot ( materialInput . normalEC , normalize ( materialInput . positionToEyeEC ) ) ;
float s = smoothstep ( 1.0 - width , 1.0 , d ) ;
vec4 outColor = czm _gammaCorrect ( color ) ;
vec4 outRimColor = czm _gammaCorrect ( rimColor ) ;
material . diffuse = outColor . rgb ;
material . emission = outRimColor . rgb * s ;
material . alpha = mix ( outColor . a , outRimColor . a , s ) ;
return material ;
}
` ,P0e= ` uniform sampler2D image ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
vec4 rampColor = texture2D ( image , vec2 ( materialInput . slope / ( czm _pi / 2.0 ) , 0.5 ) ) ;
rampColor = czm _gammaCorrect ( rampColor ) ;
material . diffuse = rampColor . rgb ;
material . alpha = rampColor . a ;
return material ;
}
` ,O0e= ` uniform vec4 evenColor ;
uniform vec4 oddColor ;
uniform float offset ;
uniform float repeat ;
uniform bool horizontal ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
// Based on the Stripes Fragment Shader in the Orange Book (11.1.2)
float coord = mix ( materialInput . st . s , materialInput . st . t , float ( horizontal ) ) ;
float value = fract ( ( coord - offset ) * ( repeat * 0.5 ) ) ;
float dist = min ( value , min ( abs ( value - 0.5 ) , 1.0 - value ) ) ;
vec4 currentColor = mix ( evenColor , oddColor , step ( 0.5 , value ) ) ;
vec4 color = czm _antialias ( evenColor , oddColor , currentColor , dist ) ;
color = czm _gammaCorrect ( color ) ;
material . diffuse = color . rgb ;
material . alpha = color . a ;
return material ;
}
` ,L0e= ` // Thanks for the contribution Jonas
// http://29a.ch/2012/7/19/webgl-terrain-rendering-water-fog
uniform sampler2D specularMap ;
uniform sampler2D normalMap ;
uniform vec4 baseWaterColor ;
uniform vec4 blendColor ;
uniform float frequency ;
uniform float animationSpeed ;
uniform float amplitude ;
uniform float specularIntensity ;
uniform float fadeFactor ;
czm _material czm _getMaterial ( czm _materialInput materialInput )
{
czm _material material = czm _getDefaultMaterial ( materialInput ) ;
float time = czm _frameNumber * animationSpeed ;
// fade is a function of the distance from the fragment and the frequency of the waves
float fade = max ( 1.0 , ( length ( materialInput . positionToEyeEC ) / 10000000000.0 ) * frequency * fadeFactor ) ;
float specularMapValue = texture2D ( specularMap , materialInput . st ) . r ;
// note: not using directional motion at this time, just set the angle to 0.0;
vec4 noise = czm _getWaterNoise ( normalMap , materialInput . st * frequency , time , 0.0 ) ;
vec3 normalTangentSpace = noise . xyz * vec3 ( 1.0 , 1.0 , ( 1.0 / amplitude ) ) ;
// fade out the normal perturbation as we move further from the water surface
normalTangentSpace . xy /= fade ;
// attempt to fade out the normal perturbation as we approach non water areas (low specular map value)
normalTangentSpace = mix ( vec3 ( 0.0 , 0.0 , 50.0 ) , normalTangentSpace , specularMapValue ) ;
normalTangentSpace = normalize ( normalTangentSpace ) ;
// get ratios for alignment of the new normal vector with a vector perpendicular to the tangent plane
float tsPerturbationRatio = clamp ( dot ( normalTangentSpace , vec3 ( 0.0 , 0.0 , 1.0 ) ) , 0.0 , 1.0 ) ;
// fade out water effect as specular map value decreases
material . alpha = mix ( blendColor . a , baseWaterColor . a , specularMapValue ) * specularMapValue ;
// base color is a blend of the water and non-water color based on the value from the specular map
// may need a uniform blend factor to better control this
material . diffuse = mix ( blendColor . rgb , baseWaterColor . rgb , specularMapValue ) ;
// diffuse highlights are based on how perturbed the normal is
material . diffuse += ( 0.1 * tsPerturbationRatio ) ;
material . diffuse = material . diffuse ;
material . normal = normalize ( materialInput . tangentToEyeMatrix * normalTangentSpace ) ;
material . specular = specularIntensity ;
material . shininess = 10.0 ;
return material ;
}
` ;function Fe(e){this.type=void 0,this.shaderSource=void 0,this.materials=void 0,this.uniforms=void 0,this._uniforms=void 0,this.translucent=void 0,this._minificationFilter=y(e.minificationFilter,_n.LINEAR),this._magnificationFilter=y(e.magnificationFilter,Pr.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,B0e(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),l(Fe._uniformList[this.type])||(Fe._uniformList[this.type]=Object.keys(this._uniforms))}Fe._uniformList={};Fe.fromType=function(e,t){if(!l(Fe._materialCache.getMaterial(e)))throw new E( ` material with type '${e}' does not exist . ` );const n=new Fe({fabric:{type:e}});if(l(t))for(const i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};Fe.prototype.isTranslucent=function(){if(l(this.translucent))return typeof this.translucent=="function"?this.translucent():this.translucent;let e=!0;const t=this._translucentFunctions,n=t.length;for(let i=0;i<n;++i){const o=t[i];if(typeof o=="function"?e=e&&o():e=e&&o,!e)break}return e};Fe.prototype.update=function(e){this._defaultTexture=e.defaultTexture;let t,n;const i=this._loadedImages;let o=i.length;for(t=0;t<o;++t){const c=i[t];n=c.id;let u=c.image,f;Array.isArray(u)&&(f=u.slice(1,u.length).map(function(A){return A.bufferView}),u=u[0]);const h=new jn({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter});let _;l(u.internalFormat)?_=new Ft({context:e,pixelFormat:u.internalFormat,width:u.width,height:u.height,source:{arrayBufferView:u.bufferView,mipLevels:f},sampler:h}):_=new Ft({context:e,source:u,sampler:h});const g=this._textures[n];l(g)&&g!==this._defaultTexture&&g.destroy(),this._textures[n]=_;const p= ` $ { n } Dimensions ` ;if(this.uniforms.hasOwnProperty(p)){const A=this.uniforms[p];A.x=_._width,A.y=_._height}}i.length=0;const r=this._loadedCubeMaps;for(o=r.length,t=0;t<o;++t){const c=r[t];n=c.id;const u=c.images,f=new kl({context:e,source:{positiveX:u[0],negativeX:u[1],positiveY:u[2],negativeY:u[3],positiveZ:u[4],negativeZ:u[5]},sampler:new jn({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter})});this._textures[n]=f}r.length=0;const s=this._updateFunctions;for(o=s.length,t=0;t<o;++t)s[t](this,e);const a=this.materials;for(const c in a)a.hasOwnProperty(c)&&a[c].update(e)};Fe.prototype.isDestroyed=function(){return!1};Fe.prototype.destroy=function(){const e=this._textures;for(const n in e)if(e.hasOwnProperty(n)){const i=e[n];i!==this._defaultTexture&&i.destroy()}const t=this.materials;for(const n in t)t.hasOwnProperty(n)&&t[n].destroy();return Ue(this)};function B0e(e,t){e=y(e,y.EMPTY_OBJECT),t._strict=y(e.strict,!1),t._count=y(e.count,0),t._template=lt(y(e.fabric,y.EMPTY_OBJECT)),t._template.uniforms=lt(y(t._template.uniforms,y.EMPTY_OBJECT)),t._template.materials=lt(y(t._template.materials,y.EMPTY_OBJECT)),t.type=l(t._template.type)?t._template.type:ds(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];let n;const i=Fe._materialCache.getMaterial(t.type);if(l(i)){const r=lt(i.fabric,!0);t._template=nn(t._template,r,!0),n=i.translucent}F0e(t),l(i)||Fe._materialCache.addMaterial(t.type,t),U0e(t),G0e(t),j0e(t);const o=t._translucentFunctions.length===0?!0:void 0;if(n=y(n,o),n=y(e.translucent,n),l(n))if(typeof n=="function"){const r=function(){return n(t)};t._translucentFunctions.push(r)}else t._translucentFunctions.push(n)}function rI(e,t,n,i){if(l(e)){for(const o in e)if(e.hasOwnProperty(o)){const r=t.indexOf(o)!==-1;(i&&!r||!i&&r)&&n(o,t)}}}function Az(e,t){let n= ` fabric : property name '${e}' is not valid . It should be ` ;for(let i=0;i<t.length;i++){const o= ` '${t[i]}' ` ;n+=i===t.length-1? ` or $ { o } . ` : ` $ { o } , ` }throw new E(n)}function R0e(e,t){const n= ` fabric : uniforms and materials cannot share the same property '${e}' ` ;throw new E(n)}const N0e=["type","materials","uniforms","components","source"],M0e=["diffuse","specular","shininess"
` ;else{if(e.shaderSource+= ` czm _material czm _getMaterial ( czm _materialInput materialInput )
{
` ,e.shaderSource+= ` czm _material material = czm _getDefaultMaterial ( materialInput ) ;
` ,l(t)){const i=Object.keys(e._template.materials).length>0;for(const o in t)if(t.hasOwnProperty(o))if(o==="diffuse"||o==="emission"){const s=i&&z0e(t[o],e)?t[o]: ` czm _gammaCorrect ( $ { t [ o ] } ) ` ;e.shaderSource+= ` material . $ { o } = $ { s } ;
` }else o==="alpha"?e.shaderSource+= ` material . alpha = $ { t . alpha } ;
` :e.shaderSource+= ` material . $ { o } = $ { t [ o ] } ;
` }e.shaderSource+= ` return material ;
}
` }}const Cz={mat2:at,mat3:J,mat4:B},H0e=/ \. ktx2 $ /i;function V0e(e){let t;return function(n,i){const o=n.uniforms,r=o[e],s=t!==r,a=!l(r)||r===Fe.DefaultImageId;t=r;let c=n._textures[e],u,f;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){const _=new jn({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new Ft({context:i,source:r,sampler:_}),n._textures[e]=c;return}c.copyFrom({source:r})}else l(c)||(n._textures[e]=i.defaultTexture);return}if(r instanceof Ft&&r!==c){n._texturePaths[e]=void 0;const _=n._textures[e];l(_)&&_!==n._defaultTexture&&_.destroy(),n._textures[e]=r,u= ` $ { e } Dimensions ` ,o.hasOwnProperty(u)&&(f=o[u],f.x=r._width,f.y=r._height);return}if(s&&l(c)&&a&&(c!==n._defaultTexture&&c.destroy(),c=void 0),l(c)||(n._texturePaths[e]=void 0,c=n._textures[e]=n._defaultTexture,u= ` $ { e } Dimensions ` ,o.hasOwnProperty(u)&&(f=o[u],f.x=c._width,f.y=c._height)),a)return;const h=r instanceof Re;if(!l(n._texturePaths[e])||h&&r.url!==n._texturePaths[e].url||!h&&r!==n._texturePaths[e]){if(typeof r=="string"||h){const _=h?r:Re.createIfNeeded(r);let g;H0e.test(_.url)?g=Xm(_.url):g=_.fetchImage(),Promise.resolve(g).then(function(p){n._loadedImages.push({id:e,image:p})}).catch(function(){l(c)&&c!==n._defaultTexture&&c.destroy(),n._textures[e]=n._defaultTexture})}else(r instanceof HTMLCanvasElement||r instanceof HTMLImageElement)&&n._loadedImages.push({id:e,image:r});n._texturePaths[e]=r}}}function k0e(e){return function(t,n){const i=t.uniforms[e];if(i instanceof kl){const r=t._textures[e];r!==t._defaultTexture&&r.destroy(),t._texturePaths[e]=void 0,t._textures[e]=i;return}if(l(t._textures[e])||(t._texturePaths[e]=void 0,t._textures[e]=n.defaultCubeMap),i===Fe.DefaultCubeMapId)return;const o=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(o!==t._texturePaths[e]){const r=[Re.createIfNeeded(i.positiveX).fetchImage(),Re.createIfNeeded(i.negativeX).fetchImage(),Re.createIfNeeded(i.positiveY).fetchImage(),Re.createIfNeeded(i.negativeY).fetchImage(),Re.createIfNeeded(i.positiveZ).fetchImage(),Re.createIfNeeded(i.negativeZ).fetchImage()];Promise.all(r).then(function(s){t._loadedCubeMaps.push({id:e,images:s})}),t._texturePaths[e]=o}}}function G0e(e){const t=e._template.uniforms;for(const n in t)t.hasOwnProperty(n)&&eW(e,n)}function eW(e,t){const n=e._strict,i=e._template.uniforms,o=i[t],r=W0e(o);if(!l(r))throw new E( ` fabric : uniform '${t}' has invalid type . ` );let s;if(r==="channels"){if(s=iC(e,t,o,!1),s===0&&n)throw new E( ` strict : shader source does not use channels '${t}' . ` )}else{if(r==="sampler2D"){const u= ` $ { t } Dimensions ` ;q0e(e,u)>0&&(i[u]={type:"ivec3",x:1,y:1},eW(e,u))}if(!new RegExp( ` uniform \ \ s + $ { r } \ \ s + $ { t } \ \ s * ; ` ).test(e.shaderSource)){const u= ` uniform $ { r } $ { t } ; ` ;e.shaderSource=u+e.shaderSource}const c= ` $ { t } _$ { e . _count ++ } ` ;if(s=iC(e,t,c),s===1&&n)throw new E( ` strict : shader source does not use uniform '${t}' . ` );if(e.uniforms[t]=o,r==="sampler2D")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(V0e(t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(k0e(t));else if(r.indexOf("mat")!==-1){const u=new Cz[r];e._uniforms[c]=function(){return Cz[r].fromColumnMajorArray(e.uniforms[t],u)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function W0e(e){let t=e.type;if(!l(t)){const n=typeof e;if(n==="number")t="float";else if(n==="boolean")t="bool";else if(n==="string"||e instanceof Re||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)/^([rgba]){1,4} $ /i.test(e)?t="channels":e===Fe.DefaultCubeMapId?t="samplerCube":t="sampler2D";else if(n==="object")if(Array.isArray(e))(e.length===4||e.length===9||e.length===16)&&(t= ` mat$ { Math . sqrt ( e . length ) } ` );else{let i=0;for(const o in e)e.hasOwnProperty(o)&&(i+=1);i>=2&&i<=4?t= ` vec$ { i } ` :i===6&&(t="samplerCube")}}return t}function j0e(e){const t=e._strict,n=e._template.materials;for(const i in n)if(n.hasOwnProperty(i)){const o=new Fe({strict:t,fabric:n[i],count:e._count
# extension GL _EXT _frag _depth : enable
# endif
` ;PS.prototype.update=function(e){if(!this.show||e.mode!==le.SCENE3D||!l(this.center)||!l(this.radii))return;if(!l(this.material))throw new E("this.material must be defined.");const t=e.context,n=this.material.isTranslucent(),i=this._translucent!==n;(!l(this._rs)||i)&&(this._translucent=n,this._rs=Qe.fromCache({cull:{enabled:!0,face:Eo.FRONT},depthTest:{enabled:this._depthTestEnabled},depthMask:!n&&t.fragmentDepth,blending:n?Si.ALPHA_BLEND:void 0})),l(this._va)||(this._va=Y0e(t));let o=!1;const r=this.radii;if(!d.equals(this._radii,r)){d.clone(r,this._radii);const A=this._oneOverEllipsoidRadiiSquared;A.x=1/(r.x*r.x),A.y=1/(r.y*r.y),A.z=1/(r.z*r.z),o=!0}(!B.equals(this.modelMatrix,this._modelMatrix)||!d.equals(this.center,this._center))&&(B.clone(this.modelMatrix,this._modelMatrix),d.clone(this.center,this._center),B.multiplyByTranslation(this.modelMatrix,this.center,this._computedModelMatrix),o=!0),o&&(d.clone(d.ZERO,this._boundingSphere.center),this._boundingSphere.radius=d.maximumComponent(r),fe.transform(this._boundingSphere,this._computedModelMatrix,this._boundingSphere));const s=this._material!==this.material;this._material=this.material,this._material.update(t);const a=this.onlySunLighting!==this._onlySunLighting;this._onlySunLighting=this.onlySunLighting;const c=e.useLogDepth,u=this._useLogDepth!==c;this._useLogDepth=c;const f=this._colorCommand;let h,_;(s||a||i||u)&&(h=new Ge({sources:[w2]}),_=new Ge({sources:[this.material.shaderSource,x2]}),this.onlySunLighting&&_.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&_.defines.push("WRITE_DEPTH"),this._useLogDepth&&(h.defines.push("LOG_DEPTH"),_.defines.push("LOG_DEPTH"),_.sources.push(Tz)),this._sp=un.replaceCache({context:t,shaderProgram:this._sp,vertexShaderSource:h,fragmentShaderSource:_,attributeLocations:P1}),f.vertexArray=this._va,f.renderState=this._rs,f.shaderProgram=this._sp,f.uniformMap=nn(this._uniforms,this.material._uniforms),f.executeInClosestFrustum=n);const g=e.commandList,p=e.passes;if(p.render&&(f.boundingVolume=this._boundingSphere,f.debugShowBoundingVolume=this.debugShowBoundingVolume,f.modelMatrix=this._computedModelMatrix,f.pass=n?Be.TRANSLUCENT:Be.OPAQUE,g.push(f)),p.pick){const A=this._pickCommand;(!l(this._pickId)||this._id!==this.id)&&(this._id=this.id,this._pickId=this._pickId&&this._pickId.destroy(),this._pickId=t.createPickId({primitive:this,id:this.id})),(s||a||!l(this._pickSP)||u)&&(h=new Ge({sources:[w2]}),_=new Ge({sources:[this.material.shaderSource,x2],pickColorQualifier:"uniform"}),this.onlySunLighting&&_.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&_.defines.push("WRITE_DEPTH"),this._useLogDepth&&(h.defines.push("LOG_DEPTH"),_.defines.push("LOG_DEPTH"),_.sources.push(Tz)),this._pickSP=un.replaceCache({context:t,shaderProgram:this._pickSP,vertexShaderSource:h,fragmentShaderSource:_,attributeLocations:P1}),A.vertexArray=this._va,A.renderState=this._rs,A.shaderProgram=this._pickSP,A.uniformMap=nn(nn(this._uniforms,this._pickUniforms),this.material._uniforms),A.executeInClosestFrustum=n),A.boundingVolume=this._boundingSphere,A.modelMatrix=this._computedModelMatrix,A.pass=n?Be.TRANSLUCENT:Be.OPAQUE,g.push(A)}};PS.prototype.isDestroyed=function(){return!1};PS.prototype.destroy=function(){return this._sp=this._sp&&this._sp.destroy(),this._pickSP=this._pickSP&&this._pickSP.destroy(),this._pickId=this._pickId&&this._pickId.destroy(),Ue(this)};function YC(e){e=y(e,y.EMPTY_OBJECT);let t=e.textureUrl;l(t)||(t=ln("Assets/Textures/moonSmall.jpg")),this.show=y(e.show,!0),this.textureUrl=t,this._ellipsoid=y(e.ellipsoid,pe.MOON),this.onlySunLighting=y(e.onlySunLighting,!0),this._ellipsoidPrimitive=new PS({radii:this.ellipsoid.radii,material:Fe.fromType(Fe.ImageType),depthTestEnabled:!1,_owner:this}),this._ellipsoidPrimitive.material.translucent=!1,this._axes=new K9}Object.defineProperties(YC.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});const Ub=new J,X0e=new J, $ 0e=new d,Hb=[];YC.prototype.update=function(e){if(!this.show)return;const t=this._ellipsoidPrimitive;t.material.uniforms.image=this.textureUrl,t.onlySu
` ,n}function kTe(){let e="";e+=gs(".cesium-credit-lightbox-overlay",{display:"none","z-index":"1",position:"absolute",top:"0",left:"0",width:"100%",height:"100%","background-color":"rgba(80, 80, 80, 0.8)"}),e+=gs(".cesium-credit-lightbox",{"background-color":"#303336",color:f0,position:"relative","min-height": ` $ { zTe } px ` ,margin:"auto"}),e+=gs(".cesium-credit-lightbox > ul > li a, .cesium-credit-lightbox > ul > li a:visited",{color:f0}),e+=gs(".cesium-credit-lightbox > ul > li a:hover",{color:pI}),e+=gs(".cesium-credit-lightbox.cesium-credit-lightbox-expanded",{border:"1px solid #444","border-radius":"5px","max-width":"370px"}),e+=gs(".cesium-credit-lightbox.cesium-credit-lightbox-mobile",{height:"100%",width:"100%"}),e+=gs(".cesium-credit-lightbox-title",{padding:"20px 20px 0 20px"}),e+=gs(".cesium-credit-lightbox-close",{"font-size":"18pt",cursor:"pointer",position:"absolute",top:"0",right:"6px",color:f0}),e+=gs(".cesium-credit-lightbox-close:hover",{color:pI}),e+=gs(".cesium-credit-lightbox > ul",{margin:"0",padding:"12px 20px 12px 40px","font-size":"13px"}),e+=gs(".cesium-credit-lightbox > ul > li",{"padding-bottom":"6px"}),e+=gs(".cesium-credit-lightbox > ul > li *",{padding:"0",margin:"0"}),e+=gs(".cesium-credit-expand-link",{"padding-left":"5px",cursor:"pointer","text-decoration":"underline",color:f0}),e+=gs(".cesium-credit-expand-link:hover",{color:pI}),e+=gs(".cesium-credit-text",{color:f0}),e+=gs(".cesium-credit-textContainer *, .cesium-credit-logoContainer *",{display:"inline"});const t=document.head,n=document.createElement("style");n.innerHTML=e,t.insertBefore(n,t.firstChild)}function xo(e,t,n){T.defined("container",e);const i=this;n=y(n,document.body);const o=document.createElement("div");o.className="cesium-credit-lightbox-overlay",n.appendChild(o);const r=document.createElement("div");r.className="cesium-credit-lightbox",o.appendChild(r);function s(p){r.contains(p.target)||i.hideLightbox()}o.addEventListener("click",s,!1);const a=document.createElement("div");a.className="cesium-credit-lightbox-title",a.textContent="Data provided by:",r.appendChild(a);const c=document.createElement("a");c.onclick=this.hideLightbox.bind(this),c.innerHTML="×",c.className="cesium-credit-lightbox-close",r.appendChild(c);const u=document.createElement("ul");r.appendChild(u);const f=document.createElement("div");f.className="cesium-credit-logoContainer",f.style.display="inline",e.appendChild(f);const h=document.createElement("div");h.className="cesium-credit-textContainer",h.style.display="inline",e.appendChild(h);const _=document.createElement("a");_.className="cesium-credit-expand-link",_.onclick=this.showLightbox.bind(this),_.textContent="Data attribution",e.appendChild(_),kTe();const g=Xn.clone(xo.cesiumCredit);this._delimiter=y(t," • "),this._screenContainer=h,this._cesiumCreditContainer=f,this._lastViewportHeight=void 0,this._lastViewportWidth=void 0,this._lightboxCredits=r,this._creditList=u,this._lightbox=o,this._hideLightbox=s,this._expandLink=_,this._expanded=!1,this._defaultCredits=[],this._cesiumCredit=g,this._previousCesiumCredit=void 0,this._currentCesiumCredit=g,this._creditDisplayElementPool=[],this._creditDisplayElementIndex=0,this._currentFrameCredits={screenCredits:new Et,lightboxCredits:new Et},this._defaultCredit=void 0,this.viewport=n,this.container=e}function RW(e,t,n,i){i=y(i,1);let o=t.get(n.id);if(l(o))o.count<Number.MAX_VALUE&&(o.count+=i);else{const r=e._creditDisplayElementPool,s=e._creditDisplayElementPoolIndex;s<r.length?(o=r[s],o.credit=n,o.count=i):(o=new LW(n,i),r.push(o)),++e._creditDisplayElementPoolIndex,t.set(n.id,o)}}xo.prototype.addCredit=function(e){if(T.defined("credit",e),e._isIon){l(this._defaultCredit)||(this._defaultCredit=Xn.clone(NW())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,RW(this,t,e)};xo.prototype.addDefaultCredit=function(e){T.defined("credit",e);const t=this._defaultCredits;UTe(t,e)||t.push(e)};xo.prototype.removeDefaultCredit=function(e){T.defined(
# extension GL _EXT _frag _depth : enable
# endif
` ;a.sources.push(c),a.defines.push("LOG_DEPTH"),s.defines.push("LOG_DEPTH")}this._sp=un.replaceCache({shaderProgram:this._sp,context:t,vertexShaderSource:s,fragmentShaderSource:a,attributeLocations:{position:0}}),this._command.shaderProgram=this._sp}const r=pbe(i,e);if(l(this._va))this._va.getAttribute(0).vertexBuffer.copyFromArrayView(r);else{const s=new vt({attributes:{position:new ze({componentDatatype:ee.FLOAT,componentsPerAttribute:3,values:r})},indices:[0,1,2,2,1,3],primitiveType:Je.TRIANGLES});this._va= $ i.fromGeometry({context:t,geometry:s,attributeLocations:{position:0},bufferUsage:Ze.DYNAMIC_DRAW}),this._command.vertexArray=this._va}};KC.prototype.execute=function(e,t){this._mode===le.SCENE3D&&this._command.execute(e,t)};KC.prototype.isDestroyed=function(){return!1};KC.prototype.destroy=function(){this._sp=this._sp&&this._sp.destroy(),this._va=this._va&&this._va.destroy()};function Ff(){}const mbe=/ \b gl_FragDepthEXT \b /,_be=/ \b discard \b /;function gbe(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"depthOnly");if(!l(n)){const i=t._attributeLocations;let o=t.fragmentShaderSource,r,s=!1;const a=o.sources;let c=a.length;for(r=0;r<c;++r)if(mbe.test(a[r])||_be.test(a[r])){s=!0;break}let u=!1;const f=o.defines;for(c=f.length,r=0;r<c;++r)if(f[r]==="LOG_DEPTH"){u=!0;break}let h;!s&&!u?(h= ` void main ( )
{
gl _FragColor = vec4 ( 1.0 ) ;
}
` ,o=new Ge({sources:[h]})):!s&&u&&(h= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
void main ( )
{
gl _FragColor = vec4 ( 1.0 ) ;
czm _writeLogDepth ( ) ;
}
` ,o=new Ge({defines:["LOG_DEPTH"],sources:[h]})),n=e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}function ybe(e,t){const n=e._depthOnlyRenderStateCache;let i=n[t.id];if(!l(i)){const o=Qe.getState(t);o.depthMask=!0,o.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i=Qe.fromCache(o),n[t.id]=i}return i}Ff.createDepthOnlyDerivedCommand=function(e,t,n,i){l(i)||(i={});let o,r;return l(i.depthOnlyCommand)&&(o=i.depthOnlyCommand.shaderProgram,r=i.depthOnlyCommand.renderState),i.depthOnlyCommand=ft.shallowClone(t,i.depthOnlyCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=gbe(n,t.shaderProgram),i.depthOnlyCommand.renderState=ybe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=o,i.depthOnlyCommand.renderState=r),i};const Abe=/ \s +czm_writeLogDepth \( /,Cbe=/ \s +czm_vertexLogDepth \( /,Tbe=/ \s *#extension \s +GL_EXT_frag_depth \s *: \s *enable/;function bbe(e,t){if(t.fragmentShaderSource.defines.indexOf("LOG_DEPTH_READ_ONLY")>=0)return t;let i=e.shaderCache.getDerivedShaderProgram(t,"logDepth");if(!l(i)){const 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,c,u=!1,f=r.sources,h=f.length;for(a=0;a<h;++a)if(Cbe.test(f[a])){u=!0;break}if(!u){for(a=0;a<h;++a)f[a]=Ge.replaceMain(f[a],"czm_log_depth_main");c= `
void main ( )
{
czm _log _depth _main ( ) ;
czm _vertexLogDepth ( ) ;
}
` ,f.push(c)}for(f=s.sources,h=f.length,u=!1,a=0;a<h;++a)Abe.test(f[a])&&(u=!0);s.defines.indexOf("LOG_DEPTH_WRITE")!==-1&&(u=!0);let _=!0;for(a=0;a<h;++a)Tbe.test(f[a])&&(_=!1);let g="";if(_&&(g+= ` # ifdef GL _EXT _frag _depth
# extension GL _EXT _frag _depth : enable
# endif
` ),!u){for(a=0;a<h;a++)f[a]=Ge.replaceMain(f[a],"czm_log_depth_main");g+= `
void main ( )
{
czm _log _depth _main ( ) ;
czm _writeLogDepth ( ) ;
}
` }f.push(g),i=e.shaderCache.createDerivedShaderProgram(t,"logDepth",{vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:o})}return i}Ff.createLogDepthCommand=function(e,t,n){l(n)||(n={});let i;return l(n.command)&&(i=n.command.shaderProgram),n.command=ft.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=bbe(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function Ebe(e,t,n){let i=e.shaderCache.getDerivedShaderProgram(t,"pick");if(!l(i)){const o=t._attributeLocations;let r=t.fragmentShaderSource;const s=r.sources,a=s.length,c= ` void main ( )
{
czm _non _pick _main ( ) ;
if ( gl _FragColor . a == 0.0 ) {
discard ;
}
gl _FragColor = $ { n } ;
}
` ,u=new Array(a+1);for(let f=0;f<a;++f)u[f]=Ge.replaceMain(s[f],"czm_non_pick_main");u[a]=c,r=new Ge({sources:u,defines:r.defines}),i=e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:r,attributeLocations:o})}return i}function xbe(e,t){const n=e.picking.pickRenderStateCache;let i=n[t.id];if(!l(i)){const o=Qe.getState(t);o.blending.enabled=!1,o.depthMask=!0,i=Qe.fromCache(o),n[t.id]=i}return i}Ff.createPickDerivedCommand=function(e,t,n,i){l(i)||(i={});let o,r;return l(i.pickCommand)&&(o=i.pickCommand.shaderProgram,r=i.pickCommand.renderState),i.pickCommand=ft.shallowClone(t,i.pickCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=Ebe(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=xbe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=o,i.pickCommand.renderState=r),i};function wbe(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"HDR");if(!l(n)){const i=t._attributeLocations,o=t.vertexShaderSource.clone(),r=t.fragmentShaderSource.clone();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"),n=e.shaderCache.createDerivedShaderProgram(t,"HDR",{vertexShaderSource:o,fragmentShaderSource:r,attributeLocations:i})}return n}Ff.createHdrCommand=function(e,t,n){l(n)||(n={});let i;return l(n.command)&&(i=n.command.shaderProgram),n.command=ft.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=wbe(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function NS(e){if(!l(e))throw new E("scene is required.");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;const t=this;function n(i){const o=i.alpha;if(!l(o)){t._alpha=void 0,t._beta=void 0,t._gamma=void 0;return}t._alpha=N.toRadians(o),t._beta=N.toRadians(i.beta),t._gamma=N.toRadians(i.gamma)}window.addEventListener("deviceorientation",n,!1),this._removeListener=function(){window.removeEventListener("deviceorientation",n,!1)}}const Sbe=new Ce,kz=new Ce,vbe=new J;function Dbe(e,t,n,i){const o=e.direction,r=e.right,s=e.up,a=Ce.fromAxisAngle(o,n,kz),c=Ce.fromAxisAngle(r,i,Sbe),u=Ce.multiply(c,a,c),f=Ce.fromAxisAngle(s,t,kz);Ce.multiply(f,u,u);const h=J.fromQuaternion(u,vbe);J.multiplyByVector(h,r,r),J.multiplyByVector(h,s,s),J.multiplyByVector(h,o,o)}NS.prototype.update=function(){if(!l(this._alpha))return;l(this._lastAlpha)||(this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma);const e=this._lastAlpha-this._alpha,t=this._lastBeta-this._beta,n=this._lastGamma-this._gamma;Dbe(this._scene.camera,-e,t,n),this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma};NS.prototype.isDestroyed=function(){return!1};NS.prototype.destroy=function(){return this._removeListener(),Ue(this)};function HW(){this.enabled=!0,this.renderable=!0,this.density=2e-4,this.screenSpaceErrorFactor=2,this.minimumBrightness=.03}const _x=[359.393,800.749,1275.6501,2151.1192,3141.7763,4777.5198,6281.2493,12364.307,15900.765,49889.0549,78026.8259,99260.7344,120036.3873,151011.0158,156091.1953,203849.3112,274866.9803,319916.3149,493552.0528,628733.5874],wu=[2e-5,2e-4,1e-4,7e-5,5e-5,4e-5,3e-5,19e-6,1e-5,85e-7,62e-7,58e-7,53e-7,52e-7,51e-7,42e-7,4e-6,34e-7,26e-7,22e-7];for(let e=0;e<wu.length;++e)wu[e]*=1e6;const VW=wu[1],M1=wu[wu.length-1];for(let e=0;e<wu.length;++e)wu[e]=(wu[e]-M1)/(VW-M1);let Rr=0;function Ibe(e){const t=_x,n=t.length;if(e<t[0])return Rr=0,Rr;if(e>t[n-1])return Rr=n-2,Rr;if(e>=t[Rr]){if(Rr+1<n&&e<t[Rr+1])return Rr;if(Rr+2<n&&e<t[Rr+2])return++Rr,Rr}else if(Rr-1>=0&&e>=t[Rr-1])return--Rr,Rr;let i;for(i=0;i<n-2&&!(e>=t[i]&&e<t[i+1]);++i);return Rr=i,Rr}const Pbe=new d;HW.prototype.update=function(e){if(!(e.fog.enabled=this.enabled))return;e.fog.renderable=this.renderable;const n=e.camera,i=n.positionCartographic;if(!l(i)||i.height>8e5||e.mode!==le.SCENE3D){e.fog.enabled=!1;retur
{
gl _FragColor = vec4 ( 1.0 ) ;
}
` ;t.sources=[n]}function IR(e,t){const n=t.sources,i=n.length;for(let r=0;r<i;++r)n[r]=Ge.replaceMain(n[r],"czm_globe_translucency_main");const o= `
uniform sampler2D u _classificationTexture ;
void main ( )
{
vec2 st = gl _FragCoord . xy / czm _viewport . zw ;
# ifdef MANUAL _DEPTH _TEST
float logDepthOrDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , st ) ) ;
if ( logDepthOrDepth != 0.0 )
{
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , logDepthOrDepth ) ;
float depthEC = eyeCoordinate . z / eyeCoordinate . w ;
if ( v _positionEC . z < depthEC )
{
discard ;
}
}
# endif
czm _globe _translucency _main ( ) ;
vec4 classificationColor = texture2D ( u _classificationTexture , st ) ;
if ( classificationColor . a > 0.0 )
{
// Reverse premultiplication process to get the correct composited result of the classification primitives
classificationColor . rgb /= classificationColor . a ;
}
gl _FragColor = classificationColor * vec4 ( classificationColor . aaa , 1.0 ) + gl _FragColor * ( 1.0 - classificationColor . a ) ;
}
` ;n.push(o)}function GW(e,t){IR(e,t),bc(e.defines,"GROUND_ATMOSPHERE"),bc(t.defines,"GROUND_ATMOSPHERE"),bc(e.defines,"FOG"),bc(t.defines,"FOG")}function Hbe(e,t){IR(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function Vbe(e,t){GW(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function qz(e,t){const n= ` uniform sampler2D u _classificationTexture ;
void main ( )
{
vec2 st = gl _FragCoord . xy / czm _viewport . zw ;
vec4 pickColor = texture2D ( u _classificationTexture , st ) ;
if ( pickColor == vec4 ( 0.0 ) )
{
discard ;
}
gl _FragColor = pickColor ;
}
` ;t.sources=[n]}function kbe(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)){const a=t._attributeLocations,c=t.vertexShaderSource.clone(),u=t.fragmentShaderSource.clone();c.defines=l(c.defines)?c.defines.slice(0):[],u.defines=l(u.defines)?u.defines.slice(0):[],o(c,u),s=e.shaderCache.createDerivedShaderProgram(t,r,{vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:a})}return s}function Gbe(e){e.cull.face=Eo.BACK,e.cull.enabled=!0}function Wbe(e){e.cull.face=Eo.FRONT,e.cull.enabled=!0}function jbe(e){e.cull.face=Eo.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function qbe(e){e.cull.face=Eo.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function Ybe(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function Yz(e){e.cull.face=Eo.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=Si.ALPHA_BLEND}function Xz(e){e.cull.face=Eo.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=Si.ALPHA_BLEND}function Xbe(e){e.cull.face=Eo.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function $ be(e){e.cull.face=Eo.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function Kbe(e,t,n,i,o){if(!l(i))return e;if(!n&&l(t))return t;let r=o[e.id];if(!l(r)){const s=Qe.getState(e);i(s),r=Qe.fromCache(s),o[e.id]=r}return r}function M_(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function Jbe(e,t,n,i,o){return l(o)?!i&&l(n)?n:nn(t,o(e),!1):t}function rl(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function Qbe(){return[new rl({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:zbe,getRenderStateFunction:Gbe,getUniformMapFunction:void 0}),new rl({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:Ube,getRenderStateFunction:Wbe,getUniformMapFunction:void 0}),new rl({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:yI,getRenderStateFunction:jbe,getUniformMapFunction:void 0}),new rl({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:yI,getRenderStateFunction:qbe,getUniformMapFunction:void 0}),new rl({pass:Be.GLOBE,pickOnly:!1,getShaderProgramFunction:yI,getRenderStateFunction:Ybe,getUniformMapFunction:void 0}),new rl({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:IR,getRenderStateFunction:Yz,getUniformMapFunction:M_}),new rl({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:GW,getRenderStateFunction:Xz,getUniformMapFunction:M_}),new rl({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Hbe,getRenderStateFunction:Yz,getUniformMapFunction:M_}),new rl({pass:Be.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:Vbe,getRenderStateFunction:Xz,getUniformMapFunction:M_}),new rl({pass:Be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:qz,getRenderStateFunction:Xbe,getUniformMapFunction:M_}),new rl({pass:Be.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:qz,getRenderStateFunction: $ be,getUniformMapFunction:M_})]}const $ z=new Array(am),Kz=new Array(am);i_.prototype.updateDerivedCommands=function(e,t){const n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let o=0;o<i;++o)Kz[o]=this._derivedCommandPacks[n[o]], $ z[o]=kW[n[o]];Zbe(this,e,i,n, $ z,Kz,t)}};function Zbe(e,t,n,i,o,r,s){let a=t.derivedCommands.globeTranslucency;const c=e._derivedCommandsDirty;if(t.dirty||!l(a)||c){t.dirty=!1,l(a)||(a={},t.derivedCommands.globeTranslucency=a);const u=s.frameNumber,f=y(a.uniformMapDirtyFrame,0),h=y(a.shaderProgramDirtyFrame,0),_=y(a.renderStateDirtyFrame,0),g=a.uniformMap!==t.uniformMap,p=a.shaderProgramId!==t.shaderProgram.id,A=a.renderStateId!==t.renderState.id;g&&(a.uniformMapDirtyFrame=u),p&&(a.shaderProgramDirtyFrame=u),A&&(a.renderStateDirtyFrame=u),a.uniformMap=t.uniformMap,a.shaderProgramId=t.shaderProgram.id,a.renderStateId=t.renderState.id;for(let C=0;C<n;++C){const b=r[C],x=i[C],w=o[C];let S=a[w],P,L,H;l(S)?(P=S.uniformMap,L=S.shad
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( colorTexture , v _textureCoordinates ) ;
}
` ,nEe={NEVER:se.NEVER,LESS:se.LESS,EQUAL:se.EQUAL,LESS_OR_EQUAL:se.LEQUAL,GREATER:se.GREATER,NOT_EQUAL:se.NOTEQUAL,GREATER_OR_EQUAL:se.GEQUAL,ALWAYS:se.ALWAYS},ii=Object.freeze(nEe),iEe={ZERO:se.ZERO,KEEP:se.KEEP,REPLACE:se.REPLACE,INCREMENT:se.INCR,DECREMENT:se.DECR,INVERT:se.INVERT,INCREMENT_WRAP:se.INCR_WRAP,DECREMENT_WRAP:se.DECR_WRAP},dt=Object.freeze(iEe),gx={CESIUM_3D_TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15};gx.setCesium3DTileBit=function(){return{enabled:!0,frontFunction:ii.ALWAYS,frontOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.REPLACE},backFunction:ii.ALWAYS,backOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.REPLACE},reference:gx.CESIUM_3D_TILE_MASK,mask:gx.CESIUM_3D_TILE_MASK}};const It=Object.freeze(gx);function Yl(){this._numSamples=1,this.previousFramebuffer=void 0,this._previousFramebuffer=void 0,this._depthStencilTexture=void 0,this._depthStencilRenderbuffer=void 0,this._fbo=new Cn({depthStencil:!0,createDepthAttachments:!1}),this._fboClassified=new Cn({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 ji({color:new F(0,0,0,0),owner:this}),this._clearCommand=new ji({color:new F(0,0,0,0),depth:1,stencil:0});const e=this;this._uniformMap={colorTexture:function(){return e._fbo.getColorTexture()},depthTexture:function(){return e._depthStencilTexture},classifiedTexture:function(){return e._fboClassified.getColorTexture()}}}Object.defineProperties(Yl.prototype,{unclassifiedCommand:{get:function(){return this._unclassifiedCommand}}});Yl.isTranslucencySupported=function(e){return e.depthTexture&&e.fragmentDepth};const oEe={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ii.EQUAL,frontOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.KEEP},backFunction:ii.NEVER,reference:0,mask:It.CLASSIFICATION_MASK},blending:Si.ALPHA_BLEND},rEe={depthMask:!1,stencilTest:{enabled:!0,frontFunction:ii.NOT_EQUAL,frontOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.KEEP},backFunction:ii.NEVER,reference:0,mask:It.CLASSIFICATION_MASK},blending:Si.ALPHA_BLEND},sEe={depthMask:!0,depthTest:{enabled:!0},stencilTest:It.setCesium3DTileBit(),stencilMask:It.CESIUM_3D_TILE_MASK,blending:Si.ALPHA_BLEND},aEe= ` # extension GL _EXT _frag _depth : enable
uniform sampler2D colorTexture ;
uniform sampler2D depthTexture ;
uniform sampler2D classifiedTexture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
if ( color . a == 0.0 )
{
discard ;
}
bool isClassified = all ( equal ( texture2D ( classifiedTexture , v _textureCoordinates ) , vec4 ( 0.0 ) ) ) ;
# ifdef UNCLASSIFIED
vec4 highlightColor = czm _invertClassificationColor ;
if ( isClassified )
{
discard ;
}
# else
vec4 highlightColor = vec4 ( 1.0 ) ;
if ( ! isClassified )
{
discard ;
}
# endif
gl _FragColor = color * highlightColor ;
gl _FragDepthEXT = texture2D ( depthTexture , v _textureCoordinates ) . r ;
}
` ,cEe= ` uniform sampler2D colorTexture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
if ( color . a == 0.0 )
{
discard ;
}
# ifdef UNCLASSIFIED
gl _FragColor = color * czm _invertClassificationColor ;
# else
gl _FragColor = color ;
# endif
}
` ;Yl.prototype.update=function(e,t,n){const i=this._fbo.getColorTexture(),o=this.previousFramebuffer!==this._previousFramebuffer;this._previousFramebuffer=this.previousFramebuffer;const 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 Ft({context:e,width:s,height:a,pixelFormat:nt.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new yl({context:e,width:s,height:a,format:Df.DEPTH24_STENCIL8,numSamples:t})))),!l(this._fbo.framebuffer)||c||o||r){this._fbo.destroy(),this._fboClassified.destroy();let u,f;l(this._previousFramebuffer)?(u=n.getDepthStencilTexture(),f=n.getDepthStencilRenderbuffer()):(u=this._depthStencilTexture,f=this._depthStencilRenderbuffer),this._fbo.setDepthStencilTexture(u),l(f)&&this._fbo.setDepthStencilRenderbuffer(f),this._fbo.update(e,s,a,t),l(this._previousFramebuffer)||(this._fboClassified.setDepthStencilTexture(u),this._fboClassified.update(e,s,a))}if(l(this._rsUnclassified)||(this._rsUnclassified=Qe.fromCache(oEe),this._rsClassified=Qe.fromCache(rEe),this._rsDefault=Qe.fromCache(sEe)),!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());const u=l(this._previousFramebuffer)?cEe:aEe,f=new Ge({defines:["UNCLASSIFIED"],sources:[u]}),h=new Ge({sources:[u]});this._unclassifiedCommand=e.createViewportQuadCommand(f,{renderState:l(this._previousFramebuffer)?this._rsUnclassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),this._classifiedCommand=e.createViewportQuadCommand(h,{renderState:l(this._previousFramebuffer)?this._rsClassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),l(this._translucentCommand)&&(this._translucentCommand.shaderProgram=this._translucentCommand.shaderProgram&&this._translucentCommand.shaderProgram.destroy()),l(this._previousFramebuffer)||(this._translucentCommand=e.createViewportQuadCommand(Om,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};Yl.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};Yl.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))};Yl.prototype.executeClassified=function(e,t){if(!l(this._previousFramebuffer)){const 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)};Yl.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};Yl.prototype.isDestroyed=function(){return!1};Yl.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()),Ue(this)};const lEe={TEXTURE:0,PROGRAM:1,BUFFER:2,NUMBER_OF_JOB_TYPES:3},dl=Object.freeze(lEe);function yx(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties(yx.prototype,{total:{get:function(){return this._total}}})
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = czm _packDepth ( texture2D ( u _texture , v _textureCoordinates ) . r ) ;
}
` ;e._copyDepthCommand=t.createViewportQuadCommand(i,{renderState:Qe.fromCache(),uniformMap:{u_texture:function(){return e._textureToCopy}},owner:e})}e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}o_.prototype.update=function(e,t){CEe(this,e,t),TEe(this,e,t)};const bEe=new oe,EEe=new oe(1,1/255,1/65025,1/16581375);o_.prototype.getDepth=function(e,t,n){if(!l(this.framebuffer))return;const i=e.readPixels({x:t,y:n,width:1,height:1,framebuffer:this.framebuffer}),o=oe.unpack(i,0,bEe);return oe.divideByScalar(o,255,o),oe.dot(o,EEe)};o_.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};o_.prototype.isDestroyed=function(){return!1};o_.prototype.destroy=function(){return this._framebuffer.destroy(),l(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=l(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),Ue(this)};function Do(e){e=y(e,y.EMPTY_OBJECT),this._primitives=[],this._guid=ds(),this._zIndex=void 0,this.show=y(e.show,!0),this.destroyPrimitives=y(e.destroyPrimitives,!0)}Object.defineProperties(Do.prototype,{length:{get:function(){return this._primitives.length}}});Do.prototype.add=function(e,t){const n=l(t);if(!l(e))throw new E("primitive is required.");if(n){if(t<0)throw new E("index must be greater than or equal to zero.");if(t>this._primitives.length)throw new E("index must be less than or equal to the number of primitives.")}const i=e._external=e._external||{},o=i._composites=i._composites||{};return o[this._guid]={collection:this},n?this._primitives.splice(t,0,e):this._primitives.push(e),e};Do.prototype.remove=function(e){if(this.contains(e)){const t=this._primitives.indexOf(e);if(t!==-1)return this._primitives.splice(t,1),delete e._external._composites[this._guid],this.destroyPrimitives&&e.destroy(),!0}return!1};Do.prototype.removeAndDestroy=function(e){const t=this.remove(e);return t&&!this.destroyPrimitives&&e.destroy(),t};Do.prototype.removeAll=function(){const e=this._primitives,t=e.length;for(let n=0;n<t;++n)delete e[n]._external._composites[this._guid],this.destroyPrimitives&&e[n].destroy();this._primitives=[]};Do.prototype.contains=function(e){return!!(l(e)&&e._external&&e._external._composites&&e._external._composites[this._guid])};function FS(e,t){if(!e.contains(t))throw new E("primitive is not in this collection.");return e._primitives.indexOf(t)}Do.prototype.raise=function(e){if(l(e)){const t=FS(this,e),n=this._primitives;if(t!==n.length-1){const i=n[t];n[t]=n[t+1],n[t+1]=i}}};Do.prototype.raiseToTop=function(e){if(l(e)){const t=FS(this,e),n=this._primitives;t!==n.length-1&&(n.splice(t,1),n.push(e))}};Do.prototype.lower=function(e){if(l(e)){const t=FS(this,e),n=this._primitives;if(t!==0){const i=n[t];n[t]=n[t-1],n[t-1]=i}}};Do.prototype.lowerToBottom=function(e){if(l(e)){const t=FS(this,e),n=this._primitives;t!==0&&(n.splice(t,1),n.unshift(e))}};Do.prototype.get=function(e){if(!l(e))throw new E("index is required.");return this._primitives[e]};Do.prototype.update=function(e){if(!this.show)return;const t=this._primitives;for(let n=0;n<t.length;++n)t[n].update(e)};Do.prototype.prePassesUpdate=function(e){const t=this._primitives;for(let n=0;n<t.length;++n){const i=t[n];l(i.prePassesUpdate)&&i.prePassesUpdate(e)}};Do.prototype.updateForPass=function(e,t){const n=this._primitives;for(let i=0;i<n.length;++i){const o=n[i];l(o.updateForPass)&&o.updateForPass(e,t)}};Do.prototype.postPassesUpdate=function(e){const t=this._primitives;for(let n=0;n<t.length;++n){const i=t[n];l(i.postPassesUpdate)&&i.postPassesUpdate(e)}};Do.prototype.isDestroyed=function(){return!1};Do.prototype.destroy=function(){return this.removeAll(),Ue(this)};const is={},xEe=new oe(0,0,0,1);let ys=new oe;const wEe=new qe,CI=new j,TI=new j;is.wgs84ToWindowCoordinates=function(e,t,n){return is.wgs84WithEyeOffsetToWindowCoordinates(e,t,d.ZERO,n)};const oU=new oe,rU=new d;function m0(e,t,n,i){const o=n.viewMatrix,r=B.multiplyByVector(o,oe.fromElements(e.x,e.y,e.z,1,oU),oU),s=d.multiplyComponents(t,d.normalize(r,rU),rU);return r.x+=t.x+s.x,r.y+=t.y+s.y,r.z+=s.z
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = czm _packDepth ( texture2D ( u _depthTexture , v _textureCoordinates ) . r ) ;
}
` ;function qu(){this._picking=!1,this._numSamples=1,this._tempCopyDepthTexture=void 0,this._pickColorFramebuffer=new Cn({depthStencil:!0,supportsDepthTexture:!0}),this._outputFramebuffer=new Cn({depthStencil:!0,supportsDepthTexture:!0}),this._copyDepthFramebuffer=new Cn,this._tempCopyDepthFramebuffer=new Cn,this._updateDepthFramebuffer=new Cn({createColorAttachments:!1,createDepthAttachments:!1,depthStencil:!0}),this._clearGlobeColorCommand=void 0,this._copyColorCommand=void 0,this._copyDepthCommand=void 0,this._tempCopyDepthCommand=void 0,this._updateDepthCommand=void 0,this._viewport=new qe,this._rs=void 0,this._rsBlend=void 0,this._rsUpdate=void 0,this._useScissorTest=!1,this._scissorRectangle=void 0,this._useHdr=void 0,this._clearGlobeDepth=void 0}Object.defineProperties(qu.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 LEe(e){e._pickColorFramebuffer.destroy(),e._outputFramebuffer.destroy(),e._copyDepthFramebuffer.destroy(),e._tempCopyDepthFramebuffer.destroy(),e._updateDepthFramebuffer.destroy()}function $ W(e,t,n,i,o){e._viewport.width=n,e._viewport.height=i;const r=!qe.equals(e._viewport,o.viewport);let s=r!==e._useScissorTest;e._useScissorTest=r,qe.equals(e._scissorRectangle,o.viewport)||(e._scissorRectangle=qe.clone(o.viewport,e._scissorRectangle),s=!0),(!l(e._rs)||!qe.equals(e._viewport,e._rs.viewport)||s)&&(e._rs=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:Si.ALPHA_BLEND}),e._rsUpdate=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ii.EQUAL,frontOperation:{fail:dt.KEEP,zFail:dt.KEEP,zPass:dt.KEEP},backFunction:ii.NEVER,reference:It.CESIUM_3D_TILE_MASK,mask:It.CESIUM_3D_TILE_MASK}})),l(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(F1,{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(Om,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,l(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(F1,{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(Om,{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 ji({color:new F(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}qu.prototype.update=function(e,t,n,i,o,r){const s=n.width,a=n.height,c=o?e.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.FLOAT:Ke.UNSIGNED_BYTE;this._numSamples=i,this.picking?this._pickColorFramebuffer.update(e,s,a):this._outputFramebuffer.update(e,s,a,i,c),this._copyDepthFramebuffer.update(e,s,a), $ W(this,e,s,a,t),e.uniformState.globeDepthTexture=void 0,this._useHdr=o,this._clearGlobeDepth=r};qu.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};qu.prototype.executeCopyDepth=function(e,t){l(this._copyDepthCommand)&&(
float ai = czm _gl _FragColor . a ;
float wzi = czm _alphaWeight ( ai ) ;
gl _FragData [ 0 ] = vec4 ( Ci * wzi , ai ) ;
gl _FragData [ 1 ] = vec4 ( ai * wzi ) ;
` ,jEe= ` vec3 Ci = czm _gl _FragColor . rgb * czm _gl _FragColor . a ;
float ai = czm _gl _FragColor . a ;
float wzi = czm _alphaWeight ( ai ) ;
gl _FragColor = vec4 ( Ci , ai ) * wzi ;
` ,qEe= ` float ai = czm _gl _FragColor . a ;
gl _FragColor = vec4 ( ai ) ;
` ;function LR(e,t,n,i){let o=e.shaderCache.getDerivedShaderProgram(t,n);if(!l(o)){const r=t._attributeLocations,s=t.fragmentShaderSource.clone();s.sources=s.sources.map(function(a){return a=Ge.replaceMain(a,"czm_translucent_main"),a=a.replace(/gl_FragColor/g,"czm_gl_FragColor"),a=a.replace(/ \b discard \b /g,"czm_discard = true"),a=a.replace(/czm_phong/g,"czm_translucentPhong"),a}),s.sources.splice(0,0, ` $ { i . indexOf ( "gl_FragData" ) !== - 1 ? ` #extension GL_EXT_draw_buffers : enable
` :""}vec4 czm_gl_FragColor;
bool czm _discard = false ;
` ),s.sources.push( ` void main ( )
{
czm _translucent _main ( ) ;
if ( czm _discard )
{
discard ;
}
$ { i } }
` ),o=e.shaderCache.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:s,attributeLocations:r})}return o}function YEe(e,t){return LR(e,t,"translucentMRT",WEe)}function XEe(e,t){return LR(e,t,"translucentMultipass",jEe)}function $ Ee(e,t){return LR(e,t,"alphaMultipass",qEe)}ld.prototype.createDerivedCommands=function(e,t,n){if(l(n)||(n={}),this._translucentMRTSupport){let i,o;l(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,o=n.translucentCommand.renderState),n.translucentCommand=ft.shallowClone(e,n.translucentCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=YEe(t,e.shaderProgram),n.translucentCommand.renderState=VEe(this,t,e.renderState),n.shaderProgramId=e.shaderProgram.id):(n.translucentCommand.shaderProgram=i,n.translucentCommand.renderState=o)}else{let i,o,r,s;l(n.translucentCommand)&&(i=n.translucentCommand.shaderProgram,o=n.translucentCommand.renderState,r=n.alphaCommand.shaderProgram,s=n.alphaCommand.renderState),n.translucentCommand=ft.shallowClone(e,n.translucentCommand),n.alphaCommand=ft.shallowClone(e,n.alphaCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=XEe(t,e.shaderProgram),n.translucentCommand.renderState=kEe(this,t,e.renderState),n.alphaCommand.shaderProgram= $ Ee(t,e.shaderProgram),n.alphaCommand.renderState=GEe(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)}return n};function KEe(e,t,n,i,o,r){let s,a,c;const u=t.context,f=t.frameState.useLogDepth,h=t._hdr,_=i.framebuffer,g=o.length,p=t.frameState.shadowState.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(u,i),i.framebuffer=e._adjustAlphaFBO.framebuffer,e._adjustAlphaCommand.execute(u,i);const A=e._opaqueFBO.framebuffer;for(i.framebuffer=e._translucentFBO.framebuffer,c=0;c<g;++c)s=o[c],s=f?s.derivedCommands.logDepth.command:s,s=h?s.derivedCommands.hdr.command:s,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.translucentCommand:s.derivedCommands.oit.translucentCommand,n(a,t,u,i,A);for(l(r)&&(s=r.unclassifiedCommand,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.translucentCommand:s.derivedCommands.oit.translucentCommand,n(a,t,u,i,A)),i.framebuffer=e._alphaFBO.framebuffer,c=0;c<g;++c)s=o[c],s=f?s.derivedCommands.logDepth.command:s,s=h?s.derivedCommands.hdr.command:s,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,u,i,A);l(r)&&(s=r.unclassifiedCommand,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,u,i,A)),i.framebuffer=_}function JEe(e,t,n,i,o,r){const s=t.context,a=t.frameState.useLogDepth,c=t._hdr,u=i.framebuffer,f=o.length,h=t.frameState.shadowState.lightShadowsEnabled;i.framebuffer=e._adjustTranslucentFBO.framebuffer,e._adjustTranslucentCommand.execute(s,i);const _=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;let g,p;for(let A=0;A<f;++A)g=o[A],g=a?g.derivedCommands.logDepth.command:g,g=c?g.derivedCommands.hdr.command:g,p=h&&g.receiveShadows?g.derivedCommands.oit.shadows.translucentCommand:g.derivedCommands.oit.translucentCommand,n(p,t,s,i,_);l(r)&&(g=r.unclassifiedCommand,p=h&&g.receiveShadows?g.derivedCommands.oit.shadows.translucentCommand:g.derivedCommands.oit.translucentCommand,n(p,t,s,i,_)),i.framebuffer=u}ld.prototype.executeCommands=function(e,t,n,i,o){if(this._translucentMRTSupport){JEe(this,e,t,n,i,o);return}KEe(this,e,t,n,i,o)};ld.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};ld.prototype.clear=function(e,t,n){const i=t.framebuffer;t.framebuffer=this._opaqueFBO.framebuffer,F.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._translucentMultipas
void main ( )
{
czm _shadow _cast _main ( ) ;
v _positionEC = ( czm _inverseProjection * gl _Position ) . xyz ;
} ` ;o.push(c)}return new Ge({defines:i,sources:o})};Rc.createShadowCastFragmentShader=function(e,t,n,i){const o=e.defines.slice(0),r=e.sources.slice(0);o.push("SHADOW_MAP");let s=Ge.findPositionVarying(e);const a=l(s);a||(s="v_positionEC");const c=r.length;for(let f=0;f<c;++f)r[f]=Ge.replaceMain(r[f],"czm_shadow_cast_main");let u="";return t&&(a||(u+= ` varying vec3 v _positionEC ;
` ),u+= ` uniform vec4 shadowMap _lightPositionEC ;
` ),i?u+= ` void main ( )
{
` :u+= ` void main ( )
{
czm _shadow _cast _main ( ) ;
if ( gl _FragColor . a == 0.0 )
{
discard ;
}
` ,t?u+= ` float distance = length ( $ { s } ) ;
if ( distance >= shadowMap _lightPositionEC . w )
{
discard ;
}
distance /= shadowMap _lightPositionEC . w ; // radius
gl _FragColor = czm _packDepth ( distance ) ;
` :n?u+= ` gl _FragColor = vec4 ( 1.0 ) ;
` :u+= ` gl _FragColor = czm _packDepth ( gl _FragCoord . z ) ;
` ,u+= ` }
` ,r.push(u),new Ge({defines:o,sources:r})};Rc.getShadowReceiveShaderKeyword=function(e,t,n,i){const o=e._usesDepthTexture,r=e._polygonOffsetSupported,s=e._isPointLight,a=e._isSpotLight,c=e._numberOfCascades>1,u=e.debugCascadeColors,f=e.softShadows;return ` receiveShadow $ { o } $ { r } $ { s } $ { a } $ { c } $ { u } $ { f } $ { t } $ { n } $ { i } ` };Rc.createShadowReceiveVertexShader=function(e,t,n){const 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 Ge({defines:i,sources:o})};Rc.createShadowReceiveFragmentShader=function(e,t,n,i,o){const r=Ge.findNormalVarying(e),s=!i&&l(r)||i&&o,a=Ge.findPositionVarying(e),c=l(a),u=t._usesDepthTexture,f=t._polygonOffsetSupported,h=t._isPointLight,_=t._isSpotLight,g=t._numberOfCascades>1,p=t.debugCascadeColors,A=t.softShadows,C=h?t._pointBias:i?t._terrainBias:t._primitiveBias,b=e.defines.slice(0),x=e.sources.slice(0),w=x.length;for(let L=0;L<w;++L)x[L]=Ge.replaceMain(x[L],"czm_shadow_receive_main");h?b.push("USE_CUBE_MAP_SHADOW"):u&&b.push("USE_SHADOW_DEPTH_TEXTURE"),A&&!h&&b.push("USE_SOFT_SHADOWS"),g&&n&&i&&(s?b.push("ENABLE_VERTEX_LIGHTING"):b.push("ENABLE_DAYNIGHT_SHADING")),n&&C.normalShading&&s&&(b.push("USE_NORMAL_SHADING"),C.normalShadingSmooth>0&&b.push("USE_NORMAL_SHADING_SMOOTH"));let S="";h?S+= ` uniform samplerCube shadowMap _textureCube ;
` :S+= ` uniform sampler2D shadowMap _texture ;
` ;let P;return c?P= ` return vec4 ( $ { a } , 1.0 ) ;
` :P= ` # ifndef LOG _DEPTH
return czm _windowToEyeCoordinates ( gl _FragCoord ) ;
# else
return vec4 ( v _logPositionEC , 1.0 ) ;
# endif
` ,S+= ` uniform mat4 shadowMap _matrix ;
uniform vec3 shadowMap _lightDirectionEC ;
uniform vec4 shadowMap _lightPositionEC ;
uniform vec4 shadowMap _normalOffsetScaleDistanceMaxDistanceAndDarkness ;
uniform vec4 shadowMap _texelSizeDepthBiasAndNormalShadingSmooth ;
# ifdef LOG _DEPTH
varying vec3 v _logPositionEC ;
# endif
vec4 getPositionEC ( )
{
$ { P } }
vec3 getNormalEC ( )
{
$ { s ? ` return normalize( ${ r } );
` : ` return vec3 ( 1.0 ) ;
` }}
void applyNormalOffset ( inout vec4 positionEC , vec3 normalEC , float nDotL )
{
$ { C . normalOffset && s ? ` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
float normalOffsetScale = 1.0 - nDotL ;
vec3 offset = normalOffset * normalOffsetScale * normalEC ;
positionEC . xyz += offset ;
` :""}}
` ,S+= ` void main ( )
{
czm _shadow _receive _main ( ) ;
vec4 positionEC = getPositionEC ( ) ;
vec3 normalEC = getNormalEC ( ) ;
float depth = - positionEC . z ;
` ,S+= ` czm _shadowParameters shadowParameters ;
shadowParameters . texelStepSize = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . xy ;
shadowParameters . depthBias = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . z ;
shadowParameters . normalShadingSmooth = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . w ;
shadowParameters . darkness = shadowMap _normalOffsetScaleDistanceMaxDistanceAndDarkness . w ;
` ,i?S+= ` shadowParameters . depthBias *= max ( depth * 0.01 , 1.0 ) ;
` :f||(S+= ` shadowParameters . depthBias *= mix ( 1.0 , 100.0 , depth * 0.0015 ) ;
` ),h?S+= ` vec3 directionEC = positionEC . xyz - shadowMap _lightPositionEC . xyz ;
float distance = length ( directionEC ) ;
directionEC = normalize ( directionEC ) ;
float radius = shadowMap _lightPositionEC . w ;
// Stop early if the fragment is beyond the point light radius
if ( distance > radius )
{
return ;
}
vec3 directionWC = czm _inverseViewRotation * directionEC ;
shadowParameters . depth = distance / radius ;
shadowParameters . nDotL = clamp ( dot ( normalEC , - directionEC ) , 0.0 , 1.0 ) ;
shadowParameters . texCoords = directionWC ;
float visibility = czm _shadowVisibility ( shadowMap _textureCube , shadowParameters ) ;
` :_?S+= ` vec3 directionEC = normalize ( positionEC . xyz - shadowMap _lightPositionEC . xyz ) ;
float nDotL = clamp ( dot ( normalEC , - directionEC ) , 0.0 , 1.0 ) ;
applyNormalOffset ( positionEC , normalEC , nDotL ) ;
vec4 shadowPosition = shadowMap _matrix * positionEC ;
// Spot light uses a perspective projection, so perform the perspective divide
shadowPosition /= shadowPosition . w ;
// Stop early if the fragment is not in the shadow bounds
if ( any ( lessThan ( shadowPosition . xyz , vec3 ( 0.0 ) ) ) || any ( greaterThan ( shadowPosition . xyz , vec3 ( 1.0 ) ) ) )
{
return ;
}
shadowParameters . texCoords = shadowPosition . xy ;
shadowParameters . depth = shadowPosition . z ;
shadowParameters . nDotL = nDotL ;
float visibility = czm _shadowVisibility ( shadowMap _texture , shadowParameters ) ;
` :g?S+= ` float maxDepth = shadowMap _cascadeSplits [ 1 ] . w ;
// Stop early if the eye depth exceeds the last cascade
if ( depth > maxDepth )
{
return ;
}
// Get the cascade based on the eye-space depth
vec4 weights = czm _cascadeWeights ( depth ) ;
// Apply normal offset
float nDotL = clamp ( dot ( normalEC , shadowMap _lightDirectionEC ) , 0.0 , 1.0 ) ;
applyNormalOffset ( positionEC , normalEC , nDotL ) ;
// Transform position into the cascade
vec4 shadowPosition = czm _cascadeMatrix ( weights ) * positionEC ;
// Get visibility
shadowParameters . texCoords = shadowPosition . xy ;
shadowParameters . depth = shadowPosition . z ;
shadowParameters . nDotL = nDotL ;
float visibility = czm _shadowVisibility ( shadowMap _texture , shadowParameters ) ;
// Fade out shadows that are far away
float shadowMapMaximumDistance = shadowMap _normalOffsetScaleDistanceMaxDistanceAndDarkness . z ;
float fade = max ( ( depth - shadowMapMaximumDistance * 0.8 ) / ( shadowMapMaximumDistance * 0.2 ) , 0.0 ) ;
visibility = mix ( visibility , 1.0 , fade ) ;
$ { p ? ` // Draw cascade colors for debugging
gl _FragColor *= czm _cascadeColor ( weights ) ;
` :""} ` : S += ` float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
applyNormalOffset ( positionEC , normalEC , nDotL ) ;
vec4 shadowPosition = shadowMap _matrix * positionEC ;
// Stop early if the fragment is not in the shadow bounds
if ( any ( lessThan ( shadowPosition . xyz , vec3 ( 0.0 ) ) ) || any ( greaterThan ( shadowPosition . xyz , vec3 ( 1.0 ) ) ) )
{
return ;
}
shadowParameters . texCoords = shadowPosition . xy ;
shadowParameters . depth = shadowPosition . z ;
shadowParameters . nDotL = nDotL ;
float visibility = czm _shadowVisibility ( shadowMap _texture , shadowParameters ) ;
` ,S+= ` gl _FragColor . rgb *= visibility ;
}
` ,x.push(S),new Ge({defines:b,sources:x})};function ic(e){e=y(e,y.EMPTY_OBJECT);const t=e.context;if(!l(t))throw new E("context is required.");if(!l(e.lightCamera))throw new E("lightCamera is required.");if(l(e.numberOfCascades)&&e.numberOfCascades!==1&&e.numberOfCascades!==4)throw new E("Only one or four cascades are supported.");this._enabled=y(e.enabled,!0),this._softShadows=y(e.softShadows,!1),this._normalOffset=y(e.normalOffset,!0),this.dirty=!0,this.fromLightSource=y(e.fromLightSource,!0),this.darkness=y(e.darkness,.3),this._darkness=this.darkness,this.fadingEnabled=y(e.fadingEnabled,!0),this.maximumDistance=y(e.maximumDistance,5e3),this._outOfView=!1,this._outOfViewPrevious=!1,this._needsUpdate=!0;let n=!0;(an.isInternetExplorer()||an.isEdge()||(an.isChrome()||an.isFirefox())&&an.isWindows()&&!t.depthTexture)&&(n=!1),this._polygonOffsetSupported=n,this._terrainBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.5,normalShading:!0,normalShadingSmooth:.3,depthBias:1e-4},this._primitiveBias={polygonOffset:n,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:.1,normalShading:!0,normalShadingSmooth:.05,depthBias:2e-5},this._pointBias={polygonOffset:!1,polygonOffsetFactor:1.1,polygonOffsetUnits:4,normalOffset:this._normalOffset,normalOffsetScale:0,normalShading:!0,normalShadingSmooth:.1,depthBias:5e-4},this._depthAttachment=void 0,this._colorAttachment=void 0,this._shadowMapMatrix=new B,this._shadowMapTexture=void 0,this._lightDirectionEC=new d,this._lightPositionEC=new oe,this._distance=0,this._lightCamera=e.lightCamera,this._shadowMapCamera=new zS,this._shadowMapCullingVolume=void 0,this._sceneCamera=void 0,this._boundingSphere=new fe,this._isPointLight=y(e.isPointLight,!1),this._pointLightRadius=y(e.pointLightRadius,100),this._cascadesEnabled=this._isPointLight?!1:y(e.cascadesEnabled,!0),this._numberOfCascades=this._cascadesEnabled?y(e.numberOfCascades,4):0,this._fitNearFar=!0,this._maximumCascadeDistances=[25,150,700,Number.MAX_VALUE],this._textureSize=new j,this._isSpotLight=!1,this._cascadesEnabled?this._shadowMapCamera.frustum=new So:l(this._lightCamera.frustum.fov)&&(this._isSpotLight=!0),this._cascadeSplits=[new oe,new oe],this._cascadeMatrices=[new B,new B,new B,new B],this._cascadeDistances=new oe;let i;this._isPointLight?i=6:this._cascadesEnabled?i=this._numberOfCascades:i=1,this._passes=new Array(i);for(let o=0;o<i;++o)this._passes[o]=new txe(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,BR(this),this._clearCommand=new ji({depth:1,color:new F}),this._clearPassState=new $ m(t),this._size=y(e.size,2048),this.size=this._size}ic.MAXIMUM_DISTANCE=2e4;function txe(e){this.camera=new zS,this.passState=new $ m(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function bI(e,t){return Qe.fromCache({cull:{enabled:!0,face:Eo.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 BR(e){const t=!e._usesDepthTexture;e._primitiveRenderState=bI(t,e._primitiveBias),e._terrainRenderState=bI(t,e._terrainBias),e._pointRenderState=bI(t,e._pointBias)}ic.prototype.debugCreateRenderStates=function(){BR(this)};Object.defineProperties(ic.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._poin
varying vec2 v _textureCoordinates ;
void main ( )
{
vec2 uv = v _textureCoordinates ;
vec3 dir ;
if ( uv . y < 0.5 )
{
if ( uv . x < 0.333 )
{
dir . x = - 1.0 ;
dir . y = uv . x * 6.0 - 1.0 ;
dir . z = uv . y * 4.0 - 1.0 ;
}
else if ( uv . x < 0.666 )
{
dir . y = - 1.0 ;
dir . x = uv . x * 6.0 - 3.0 ;
dir . z = uv . y * 4.0 - 1.0 ;
}
else
{
dir . z = - 1.0 ;
dir . x = uv . x * 6.0 - 5.0 ;
dir . y = uv . y * 4.0 - 1.0 ;
}
}
else
{
if ( uv . x < 0.333 )
{
dir . x = 1.0 ;
dir . y = uv . x * 6.0 - 1.0 ;
dir . z = uv . y * 4.0 - 3.0 ;
}
else if ( uv . x < 0.666 )
{
dir . y = 1.0 ;
dir . x = uv . x * 6.0 - 3.0 ;
dir . z = uv . y * 4.0 - 3.0 ;
}
else
{
dir . z = 1.0 ;
dir . x = uv . x * 6.0 - 5.0 ;
dir . y = uv . y * 4.0 - 3.0 ;
}
}
float shadow = czm _unpackDepth ( textureCube ( shadowMap _textureCube , dir ) ) ;
gl _FragColor = vec4 ( vec3 ( shadow ) , 1.0 ) ;
}
` :n= ` uniform sampler2D shadowMap _texture ;
varying vec2 v _textureCoordinates ;
void main ( )
{
$ { e . _usesDepthTexture ? ` float shadow = texture2D(shadowMap_texture, v_textureCoordinates).r;
` : ` float shadow = czm _unpackDepth ( texture2D ( shadowMap _texture , v _textureCoordinates ) ) ;
` } gl_FragColor = vec4(vec3(shadow), 1.0);
}
` ;const i=t.createViewportQuadCommand(n,{uniformMap:{shadowMap_texture:function(){return e._shadowMapTexture},shadowMap_textureCube:function(){return e._shadowMapTexture}}});return i.pass=Be.OVERLAY,i}function uxe(e,t){const n=t.context,i=t.context.drawingBufferWidth,o=t.context.drawingBufferHeight,r=Math.min(i,o)*.3,s=cxe;s.x=i-r,s.y=0,s.width=r,s.height=r;let a=e._debugShadowViewCommand;l(a)||(a=lxe(e,n),e._debugShadowViewCommand=a),(!l(a.renderState)||!qe.equals(a.renderState.viewport,s))&&(a.renderState=Qe.fromCache({viewport:qe.clone(s)})),t.commandList.push(e._debugShadowViewCommand)}const Xu=new Array(8);Xu[0]=new oe(-1,-1,-1,1);Xu[1]=new oe(1,-1,-1,1);Xu[2]=new oe(1,1,-1,1);Xu[3]=new oe(-1,1,-1,1);Xu[4]=new oe(-1,-1,1,1);Xu[5]=new oe(1,-1,1,1);Xu[6]=new oe(1,1,1,1);Xu[7]=new oe(-1,1,1,1);const dh=new B,NR=new Array(8);for(let e=0;e<8;++e)NR[e]=new oe;function fxe(e,t){const n=new Zt({geometry:new Xa({minimum:new d(-.5,-.5,-.5),maximum:new d(.5,.5,.5)}),attributes:{color:on.fromColor(t)}}),i=new Zt({geometry:new Fh({radius:.5}),attributes:{color:on.fromColor(t)}});return new Gt({geometryInstances:[n,i],appearance:new hn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}const dxe=[F.RED,F.GREEN,F.BLUE,F.MAGENTA],hxe=new d;function pxe(e,t){uxe(e,t);const n=e.debugFreezeFrame&&!e._debugFreezeFrame;if(e._debugFreezeFrame=e.debugFreezeFrame,e.debugFreezeFrame&&(n&&(e._debugCameraFrustum=e._debugCameraFrustum&&e._debugCameraFrustum.destroy(),e._debugCameraFrustum=new fh({camera:e._sceneCamera,color:F.CYAN,updateOnChange:!1})),e._debugCameraFrustum.update(t)),e._cascadesEnabled){if(e.debugFreezeFrame){n&&(e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=new fh({camera:e._shadowMapCamera,color:F.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 fh({camera:e._passes[i].camera,color:dxe[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!l(e._debugLightFrustum)||e._needsUpdate){const i=e._shadowMapCamera.positionWC,o=Ce.IDENTITY,r=e._pointLightRadius*2,s=d.fromElements(r,r,r,hxe),a=B.fromTranslationQuaternionRotationScale(i,o,s,dh);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=fxe(a,F.YELLOW)}e._debugLightFrustum.update(t)}else(!l(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new fh({camera:e._shadowMapCamera,color:F.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function zS(){this.viewMatrix=new B,this.inverseViewMatrix=new B,this.frustum=void 0,this.positionCartographic=new Ae,this.positionWC=new d,this.directionWC=d.clone(d.UNIT_Z),this.upWC=d.clone(d.UNIT_Y),this.rightWC=d.clone(d.UNIT_X),this.viewProjectionMatrix=new B}zS.prototype.clone=function(e){B.clone(e.viewMatrix,this.viewMatrix),B.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),Ae.clone(e.positionCartographic,this.positionCartographic),d.clone(e.positionWC,this.positionWC),d.clone(e.directionWC,this.directionWC),d.clone(e.upWC,this.upWC),d.clone(e.rightWC,this.rightWC)};const mxe=new B(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);zS.prototype.getViewProjection=function(){const e=this.viewMatrix,t=this.frustum.projectionMatrix;return B.multiply(t,e,this.viewProjectionMatrix),B.multiply(mxe,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};const _xe=new Array(5),gxe=new Fn,yxe=new Array(4),ej=new d,tj=new d;function Axe(e,t){const n=e._shadowMapCamera,i=e._sceneCamera,o=i.frustum.near,r=i.frustum.far,s=e._numberOfCascades;let a;const c=r-o,u=r/o;let f=.9,h=!1;t.shadowState.closestObjectSize<200&&(h=!0,f=.9);const _=yxe,g=_xe;for(g[0]=o,g[s]=r,a=0;a<s;++a){const U=(a+1)/s,v=o*Math.pow(u,U),I=o+c*U,m=N.lerp(I,v,f);g[a+1]=m,_[a]=m-g[a]}if(h){for(a=0;a<s;++a)_[a]=Math.min(_[a],e._maximumCascadeDistances[a]);let U=g[0];for(a=0;a<s-1;++a)U+=_[a],g[a+1]=U}oe.unpa
# ifdef DEBUG _SHOW _DEPTH
uniform sampler2D u _packedTranslucentDepth ;
# endif
varying vec2 v _textureCoordinates ;
void main ( )
{
# ifdef DEBUG _SHOW _DEPTH
if ( v _textureCoordinates . x < 0.5 )
{
gl _FragColor . rgb = vec3 ( czm _unpackDepth ( texture2D ( u _packedTranslucentDepth , v _textureCoordinates ) ) ) ;
gl _FragColor . a = 1.0 ;
}
# else
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
# ifdef PICK
if ( color == vec4 ( 0.0 ) )
{
discard ;
}
# else
// Reverse premultiplication process to get the correct composited result of the classification primitives
color . rgb /= color . a ;
# endif
gl _FragColor = color ;
# endif
}
` ;function rp(e){this._drawClassificationFBO=new Cn({createDepthAttachments:!1}),this._accumulationFBO=new Cn({createDepthAttachments:!1}),this._packFBO=new Cn,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 ji({color:new F(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new ji({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new qe,this._rsDepth=void 0,this._rsAccumulate=void 0,this._rsComp=void 0,this._useScissorTest=void 0,this._scissorRectangle=void 0,this._hasTranslucentDepth=!1,this._frustumsDrawn=0}Object.defineProperties(rp.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function oj(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function rj(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function Rxe(e,t,n,i){oj(e),e._translucentDepthStencilTexture=new Ft({context:t,width:n,height:i,pixelFormat:nt.DEPTH_STENCIL,pixelDatatype:Ke.UNSIGNED_INT_24_8,sampler:jn.NEAREST})}function Nxe(e,t,n,i){rj(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 Mxe(e,t,n,i){if(!e.isSupported())return;e._opaqueDepthStencilTexture=i;const o=e._opaqueDepthStencilTexture.width,r=e._opaqueDepthStencilTexture.height;e._drawClassificationFBO.isDirty(o,r)&&(Rxe(e,t,o,r),Nxe(e,t,o,r));let s,a;if(l(e._packDepthCommand)||(s=new Ge({sources:[Sue]}),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 Ge({sources:[EI]}),a={colorTexture:function(){return e._textureToComposite}},e._compositeCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e});const f=e._compositeCommand,h=f.shaderProgram,_=t.shaderCache.createDerivedShaderProgram(h,"pick",{vertexShaderSource:h.vertexShaderSource,fragmentShaderSource:new Ge({sources:s.sources,defines:["PICK"]}),attributeLocations:h._attributeLocations}),g=ft.shallowClone(f);g.shaderProgram=_,f.derivedCommands.pick=g}l(e._copyCommand)||(s=new Ge({sources:[EI]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),l(e._accumulateCommand)||(s=new Ge({sources:[EI]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._accumulateCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),e._viewport.width=o,e._viewport.height=r;const c=!qe.equals(e._viewport,n.viewport);let u=c!==e._useScissorTest;e._useScissorTest=c,qe.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle=qe.clone(n.viewport,e._scissorRectangle),u=!0),(!l(e._rsDepth)||!qe.equals(e._viewport,e._rsDepth.viewport)||u)&&(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)||!qe.equals(e._viewport,e._rsAccumulate.viewport)||u)&&(e._rsAccumulate=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:ii.EQUAL,reference:It.CESIUM_3D_TILE_MASK}})),l(e._accumulateCommand)&&(e._accumulateCommand.renderState=e._rsAccumulate),(!l(e._rsComp)||!qe.equals(e._viewport,e._rsComp.viewport)||u)&&(e._rsComp=Qe.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blendin
varying vec2 v _textureCoordinates ;
# ifdef AUTO _EXPOSURE
uniform sampler2D autoExposure ;
# endif
void main ( )
{
vec4 fragmentColor = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 color = fragmentColor . rgb ;
# ifdef AUTO _EXPOSURE
color /= texture2D ( autoExposure , vec2 ( 0.5 ) ) . r ;
# endif
color = czm _acesTonemapping ( color ) ;
color = czm _inverseGamma ( color ) ;
gl _FragColor = vec4 ( color , fragmentColor . a ) ;
}
` ,gwe= ` uniform sampler2D randomTexture ;
uniform sampler2D depthTexture ;
uniform float intensity ;
uniform float bias ;
uniform float lengthCap ;
uniform float stepSize ;
uniform float frustumLength ;
varying vec2 v _textureCoordinates ;
vec4 clipToEye ( vec2 uv , float depth )
{
vec2 xy = vec2 ( ( uv . x * 2.0 - 1.0 ) , ( ( 1.0 - uv . y ) * 2.0 - 1.0 ) ) ;
vec4 posEC = czm _inverseProjection * vec4 ( xy , depth , 1.0 ) ;
posEC = posEC / posEC . w ;
return posEC ;
}
//Reconstruct Normal Without Edge Removation
vec3 getNormalXEdge ( vec3 posInCamera , float depthU , float depthD , float depthL , float depthR , vec2 pixelSize )
{
vec4 posInCameraUp = clipToEye ( v _textureCoordinates - vec2 ( 0.0 , pixelSize . y ) , depthU ) ;
vec4 posInCameraDown = clipToEye ( v _textureCoordinates + vec2 ( 0.0 , pixelSize . y ) , depthD ) ;
vec4 posInCameraLeft = clipToEye ( v _textureCoordinates - vec2 ( pixelSize . x , 0.0 ) , depthL ) ;
vec4 posInCameraRight = clipToEye ( v _textureCoordinates + vec2 ( pixelSize . x , 0.0 ) , depthR ) ;
vec3 up = posInCamera . xyz - posInCameraUp . xyz ;
vec3 down = posInCameraDown . xyz - posInCamera . xyz ;
vec3 left = posInCamera . xyz - posInCameraLeft . xyz ;
vec3 right = posInCameraRight . xyz - posInCamera . xyz ;
vec3 DX = length ( left ) < length ( right ) ? left : right ;
vec3 DY = length ( up ) < length ( down ) ? up : down ;
return normalize ( cross ( DY , DX ) ) ;
}
void main ( void )
{
float depth = czm _readDepth ( depthTexture , v _textureCoordinates ) ;
vec4 posInCamera = clipToEye ( v _textureCoordinates , depth ) ;
if ( posInCamera . z > frustumLength )
{
gl _FragColor = vec4 ( 1.0 ) ;
return ;
}
vec2 pixelSize = czm _pixelRatio / czm _viewport . zw ;
float depthU = czm _readDepth ( depthTexture , v _textureCoordinates - vec2 ( 0.0 , pixelSize . y ) ) ;
float depthD = czm _readDepth ( depthTexture , v _textureCoordinates + vec2 ( 0.0 , pixelSize . y ) ) ;
float depthL = czm _readDepth ( depthTexture , v _textureCoordinates - vec2 ( pixelSize . x , 0.0 ) ) ;
float depthR = czm _readDepth ( depthTexture , v _textureCoordinates + vec2 ( pixelSize . x , 0.0 ) ) ;
vec3 normalInCamera = getNormalXEdge ( posInCamera . xyz , depthU , depthD , depthL , depthR , pixelSize ) ;
float ao = 0.0 ;
vec2 sampleDirection = vec2 ( 1.0 , 0.0 ) ;
float gapAngle = 90.0 * czm _radiansPerDegree ;
// RandomNoise
float randomVal = texture2D ( randomTexture , v _textureCoordinates ) . x ;
//Loop for each direction
for ( int i = 0 ; i < 4 ; i ++ )
{
float newGapAngle = gapAngle * ( float ( i ) + randomVal ) ;
float cosVal = cos ( newGapAngle ) ;
float sinVal = sin ( newGapAngle ) ;
//Rotate Sampling Direction
vec2 rotatedSampleDirection = vec2 ( cosVal * sampleDirection . x - sinVal * sampleDirection . y , sinVal * sampleDirection . x + cosVal * sampleDirection . y ) ;
float localAO = 0.0 ;
float localStepSize = stepSize ;
//Loop for each step
for ( int j = 0 ; j < 6 ; j ++ )
{
vec2 newCoords = v _textureCoordinates + rotatedSampleDirection * localStepSize * pixelSize ;
//Exception Handling
if ( newCoords . x > 1.0 || newCoords . y > 1.0 || newCoords . x < 0.0 || newCoords . y < 0.0 )
{
break ;
}
float stepDepthInfo = czm _readDepth ( depthTexture , newCoords ) ;
vec4 stepPosInCamera = clipToEye ( newCoords , stepDepthInfo ) ;
vec3 diffVec = stepPosInCamera . xyz - posInCamera . xyz ;
float len = length ( diffVec ) ;
if ( len > lengthCap )
{
break ;
}
float dotVal = clamp ( dot ( normalInCamera , normalize ( diffVec ) ) , 0.0 , 1.0 ) ;
float weight = len / lengthCap ;
weight = 1.0 - weight * weight ;
if ( dotVal < bias )
{
dotVal = 0.0 ;
}
localAO = max ( localAO , dotVal * weight ) ;
localStepSize += stepSize ;
}
ao += localAO ;
}
ao /= 4.0 ;
ao = 1.0 - clamp ( ao , 0.0 , 1.0 ) ;
ao = pow ( ao , intensity ) ;
gl _FragColor = vec4 ( vec3 ( ao ) , 1.0 ) ;
}
` ,ywe= ` uniform sampler2D colorTexture ;
uniform sampler2D ambientOcclusionTexture ;
uniform bool ambientOcclusionOnly ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec3 color = texture2D ( colorTexture , v _textureCoordinates ) . rgb ;
vec3 ao = texture2D ( ambientOcclusionTexture , v _textureCoordinates ) . rgb ;
gl _FragColor . rgb = ambientOcclusionOnly ? ao : ao * color ;
}
` ,Awe= ` uniform sampler2D colorTexture ;
uniform float gradations ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec3 rgb = texture2D ( colorTexture , v _textureCoordinates ) . rgb ;
# ifdef CZM _SELECTED _FEATURE
if ( czm _selected ( ) ) {
gl _FragColor = vec4 ( rgb , 1.0 ) ;
return ;
}
# endif
float luminance = czm _luminance ( rgb ) ;
float darkness = luminance * gradations ;
darkness = ( darkness - fract ( darkness ) ) / gradations ;
gl _FragColor = vec4 ( vec3 ( darkness ) , 1.0 ) ;
}
` ,Cwe= ` uniform sampler2D colorTexture ;
uniform sampler2D bloomTexture ;
uniform bool glowOnly ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
# ifdef CZM _SELECTED _FEATURE
if ( czm _selected ( ) ) {
gl _FragColor = color ;
return ;
}
# endif
vec4 bloom = texture2D ( bloomTexture , v _textureCoordinates ) ;
gl _FragColor = glowOnly ? bloom : bloom + color ;
}
` ,Twe= ` uniform sampler2D colorTexture ;
uniform float brightness ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec3 rgb = texture2D ( colorTexture , v _textureCoordinates ) . rgb ;
vec3 target = vec3 ( 0.0 ) ;
gl _FragColor = vec4 ( mix ( target , rgb , brightness ) , 1.0 ) ;
}
` ,bwe= ` uniform sampler2D colorTexture ;
uniform float contrast ;
uniform float brightness ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec3 sceneColor = texture2D ( colorTexture , v _textureCoordinates ) . xyz ;
sceneColor = czm _RGBToHSB ( sceneColor ) ;
sceneColor . z += brightness ;
sceneColor = czm _HSBToRGB ( sceneColor ) ;
float factor = ( 259.0 * ( contrast + 255.0 ) ) / ( 255.0 * ( 259.0 - contrast ) ) ;
sceneColor = factor * ( sceneColor - vec3 ( 0.5 ) ) + vec3 ( 0.5 ) ;
gl _FragColor = vec4 ( sceneColor , 1.0 ) ;
}
` ,Ewe= ` uniform sampler2D colorTexture ;
uniform sampler2D blurTexture ;
uniform sampler2D depthTexture ;
uniform float focalDistance ;
varying vec2 v _textureCoordinates ;
vec4 toEye ( vec2 uv , float depth )
{
vec2 xy = vec2 ( ( uv . x * 2.0 - 1.0 ) , ( ( 1.0 - uv . y ) * 2.0 - 1.0 ) ) ;
vec4 posInCamera = czm _inverseProjection * vec4 ( xy , depth , 1.0 ) ;
posInCamera = posInCamera / posInCamera . w ;
return posInCamera ;
}
float computeDepthBlur ( float depth )
{
float f ;
if ( depth < focalDistance )
{
f = ( focalDistance - depth ) / ( focalDistance - czm _currentFrustum . x ) ;
}
else
{
f = ( depth - focalDistance ) / ( czm _currentFrustum . y - focalDistance ) ;
f = pow ( f , 0.1 ) ;
}
f *= f ;
f = clamp ( f , 0.0 , 1.0 ) ;
return pow ( f , 0.5 ) ;
}
void main ( void )
{
float depth = czm _readDepth ( depthTexture , v _textureCoordinates ) ;
vec4 posInCamera = toEye ( v _textureCoordinates , depth ) ;
float d = computeDepthBlur ( - posInCamera . z ) ;
gl _FragColor = mix ( texture2D ( colorTexture , v _textureCoordinates ) , texture2D ( blurTexture , v _textureCoordinates ) , d ) ;
}
` ,xwe= ` uniform sampler2D depthTexture ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
float depth = czm _readDepth ( depthTexture , v _textureCoordinates ) ;
gl _FragColor = vec4 ( vec3 ( depth ) , 1.0 ) ;
}
` ,wwe= ` uniform sampler2D depthTexture ;
uniform float length ;
uniform vec4 color ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
float directions [ 3 ] ;
directions [ 0 ] = - 1.0 ;
directions [ 1 ] = 0.0 ;
directions [ 2 ] = 1.0 ;
float scalars [ 3 ] ;
scalars [ 0 ] = 3.0 ;
scalars [ 1 ] = 10.0 ;
scalars [ 2 ] = 3.0 ;
float padx = czm _pixelRatio / czm _viewport . z ;
float pady = czm _pixelRatio / czm _viewport . w ;
# ifdef CZM _SELECTED _FEATURE
bool selected = false ;
for ( int i = 0 ; i < 3 ; ++ i )
{
float dir = directions [ i ] ;
selected = selected || czm _selected ( vec2 ( - padx , dir * pady ) ) ;
selected = selected || czm _selected ( vec2 ( padx , dir * pady ) ) ;
selected = selected || czm _selected ( vec2 ( dir * padx , - pady ) ) ;
selected = selected || czm _selected ( vec2 ( dir * padx , pady ) ) ;
if ( selected )
{
break ;
}
}
if ( ! selected )
{
gl _FragColor = vec4 ( color . rgb , 0.0 ) ;
return ;
}
# endif
float horizEdge = 0.0 ;
float vertEdge = 0.0 ;
for ( int i = 0 ; i < 3 ; ++ i )
{
float dir = directions [ i ] ;
float scale = scalars [ i ] ;
horizEdge -= texture2D ( depthTexture , v _textureCoordinates + vec2 ( - padx , dir * pady ) ) . x * scale ;
horizEdge += texture2D ( depthTexture , v _textureCoordinates + vec2 ( padx , dir * pady ) ) . x * scale ;
vertEdge -= texture2D ( depthTexture , v _textureCoordinates + vec2 ( dir * padx , - pady ) ) . x * scale ;
vertEdge += texture2D ( depthTexture , v _textureCoordinates + vec2 ( dir * padx , pady ) ) . x * scale ;
}
float len = sqrt ( horizEdge * horizEdge + vertEdge * vertEdge ) ;
gl _FragColor = vec4 ( color . rgb , len > length ? color . a : 0.0 ) ;
}
` ,Swe= ` uniform sampler2D colorTexture ;
varying vec2 v _textureCoordinates ;
# ifdef AUTO _EXPOSURE
uniform sampler2D autoExposure ;
# endif
// See slides 142 and 143:
// http://www.gdcvault.com/play/1012459/Uncharted_2__HDR_Lighting
void main ( )
{
vec4 fragmentColor = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 color = fragmentColor . rgb ;
# ifdef AUTO _EXPOSURE
float exposure = texture2D ( autoExposure , vec2 ( 0.5 ) ) . r ;
color /= exposure ;
# endif
const float A = 0.22 ; // shoulder strength
const float B = 0.30 ; // linear strength
const float C = 0.10 ; // linear angle
const float D = 0.20 ; // toe strength
const float E = 0.01 ; // toe numerator
const float F = 0.30 ; // toe denominator
const float white = 11.2 ; // linear white point value
vec3 c = ( ( color * ( A * color + C * B ) + D * E ) / ( color * ( A * color + B ) + D * F ) ) - E / F ;
float w = ( ( white * ( A * white + C * B ) + D * E ) / ( white * ( A * white + B ) + D * F ) ) - E / F ;
c = czm _inverseGamma ( c / w ) ;
gl _FragColor = vec4 ( c , fragmentColor . a ) ;
}
` ,vwe= ` varying vec2 v _textureCoordinates ;
uniform sampler2D colorTexture ;
const float fxaaQualitySubpix = 0.5 ;
const float fxaaQualityEdgeThreshold = 0.125 ;
const float fxaaQualityEdgeThresholdMin = 0.0833 ;
void main ( )
{
vec2 fxaaQualityRcpFrame = vec2 ( 1.0 ) / czm _viewport . zw ;
vec4 color = FxaaPixelShader (
v _textureCoordinates ,
colorTexture ,
fxaaQualityRcpFrame ,
fxaaQualitySubpix ,
fxaaQualityEdgeThreshold ,
fxaaQualityEdgeThresholdMin ) ;
float alpha = texture2D ( colorTexture , v _textureCoordinates ) . a ;
gl _FragColor = vec4 ( color . rgb , alpha ) ;
}
` ,U1= ` # define SAMPLES 8
uniform float delta ;
uniform float sigma ;
uniform float direction ; // 0.0 for x direction, 1.0 for y direction
uniform sampler2D colorTexture ;
# ifdef USE _STEP _SIZE
uniform float stepSize ;
# else
uniform vec2 step ;
# endif
varying vec2 v _textureCoordinates ;
// Incremental Computation of the Gaussian:
// https://developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch40.html
void main ( )
{
vec2 st = v _textureCoordinates ;
vec2 dir = vec2 ( 1.0 - direction , direction ) ;
# ifdef USE _STEP _SIZE
vec2 step = vec2 ( stepSize * ( czm _pixelRatio / czm _viewport . zw ) ) ;
# else
vec2 step = step ;
# endif
vec3 g ;
g . x = 1.0 / ( sqrt ( czm _twoPi ) * sigma ) ;
g . y = exp ( ( - 0.5 * delta * delta ) / ( sigma * sigma ) ) ;
g . z = g . y * g . y ;
vec4 result = texture2D ( colorTexture , st ) * g . x ;
for ( int i = 1 ; i < SAMPLES ; ++ i )
{
g . xy *= g . yz ;
vec2 offset = float ( i ) * dir * step ;
result += texture2D ( colorTexture , st - offset ) * g . x ;
result += texture2D ( colorTexture , st + offset ) * g . x ;
}
gl _FragColor = result ;
}
` ,Dwe= ` uniform sampler2D colorTexture ;
uniform sampler2D dirtTexture ;
uniform sampler2D starTexture ;
uniform vec2 dirtTextureDimensions ;
uniform float distortion ;
uniform float ghostDispersal ;
uniform float haloWidth ;
uniform float dirtAmount ;
uniform float earthRadius ;
uniform float intensity ;
varying vec2 v _textureCoordinates ;
// whether it is in space or not
// 6500000.0 is empirical value
# define DISTANCE _TO _SPACE 6500000.0
// return ndc from world coordinate biased earthRadius
vec4 getNDCFromWC ( vec3 WC , float earthRadius )
{
vec4 positionEC = czm _view * vec4 ( WC , 1.0 ) ;
positionEC = vec4 ( positionEC . x + earthRadius , positionEC . y , positionEC . z , 1.0 ) ;
vec4 positionWC = czm _eyeToWindowCoordinates ( positionEC ) ;
return czm _viewportOrthographic * vec4 ( positionWC . xy , - positionWC . z , 1.0 ) ;
}
// Check if current pixel is included Earth
// if then mask it gradually
float isInEarth ( vec2 texcoord , vec2 sceneSize )
{
vec2 NDC = texcoord * 2.0 - 1.0 ;
vec4 earthPosSC = getNDCFromWC ( vec3 ( 0.0 ) , 0.0 ) ;
vec4 earthPosSCEdge = getNDCFromWC ( vec3 ( 0.0 ) , earthRadius * 1.5 ) ;
NDC . xy -= earthPosSC . xy ;
float X = abs ( NDC . x ) * sceneSize . x ;
float Y = abs ( NDC . y ) * sceneSize . y ;
return clamp ( 0.0 , 1.0 , max ( sqrt ( X * X + Y * Y ) / max ( abs ( earthPosSCEdge . x * sceneSize . x ) , 1.0 ) - 0.8 , 0.0 ) ) ;
}
// For Chromatic effect
vec4 textureDistorted ( sampler2D tex , vec2 texcoord , vec2 direction , vec3 distortion , bool isSpace )
{
vec2 sceneSize = czm _viewport . zw ;
vec3 color ;
if ( isSpace )
{
color . r = isInEarth ( texcoord + direction * distortion . r , sceneSize ) * texture2D ( tex , texcoord + direction * distortion . r ) . r ;
color . g = isInEarth ( texcoord + direction * distortion . g , sceneSize ) * texture2D ( tex , texcoord + direction * distortion . g ) . g ;
color . b = isInEarth ( texcoord + direction * distortion . b , sceneSize ) * texture2D ( tex , texcoord + direction * distortion . b ) . b ;
}
else
{
color . r = texture2D ( tex , texcoord + direction * distortion . r ) . r ;
color . g = texture2D ( tex , texcoord + direction * distortion . g ) . g ;
color . b = texture2D ( tex , texcoord + direction * distortion . b ) . b ;
}
return vec4 ( clamp ( color , 0.0 , 1.0 ) , 0.0 ) ;
}
void main ( void )
{
vec4 originalColor = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 rgb = originalColor . rgb ;
bool isSpace = length ( czm _viewerPositionWC . xyz ) > DISTANCE _TO _SPACE ;
// Sun position
vec4 sunPos = czm _morphTime == 1.0 ? vec4 ( czm _sunPositionWC , 1.0 ) : vec4 ( czm _sunPositionColumbusView . zxy , 1.0 ) ;
vec4 sunPositionEC = czm _view * sunPos ;
vec4 sunPositionWC = czm _eyeToWindowCoordinates ( sunPositionEC ) ;
sunPos = czm _viewportOrthographic * vec4 ( sunPositionWC . xy , - sunPositionWC . z , 1.0 ) ;
// If sun is not in the screen space, use original color.
if ( ! isSpace || ! ( ( sunPos . x >= - 1.1 && sunPos . x <= 1.1 ) && ( sunPos . y >= - 1.1 && sunPos . y <= 1.1 ) ) )
{
// Lens flare is disabled when not in space until #5932 is fixed.
// https://github.com/CesiumGS/cesium/issues/5932
gl _FragColor = originalColor ;
return ;
}
vec2 texcoord = vec2 ( 1.0 ) - v _textureCoordinates ;
vec2 pixelSize = czm _pixelRatio / czm _viewport . zw ;
vec2 invPixelSize = 1.0 / pixelSize ;
vec3 distortionVec = pixelSize . x * vec3 ( - distortion , 0.0 , distortion ) ;
// ghost vector to image centre:
vec2 ghostVec = ( vec2 ( 0.5 ) - texcoord ) * ghostDispersal ;
vec3 direction = normalize ( vec3 ( ghostVec , 0.0 ) ) ;
// sample ghosts:
vec4 result = vec4 ( 0.0 ) ;
vec4 ghost = vec4 ( 0.0 ) ;
for ( int i = 0 ; i < 4 ; ++ i )
{
vec2 offset = fract ( texcoord + ghostVec * float ( i ) ) ;
// Only bright spots from the centre of the source image
ghost += textureDistorted ( colorTexture , offset , direction . xy , distortionVec , isSpace ) ;
}
result += ghost ;
// sample halo
vec2 haloVec = normalize ( ghostVec ) * haloWidth ;
float weightForHalo = length ( vec2 ( 0.5 ) - fract ( texcoord + haloVec ) ) / length ( vec2 ( 0.5 ) ) ;
weightForHalo = pow ( 1.0 - weightForHalo , 5.0 ) ;
result += textureDistorted ( colorTexture , texcoord + haloVec , direction . xy , distortionVec , isSpace ) * weightForHalo * 1.5 ;
// dirt on lens
vec2 dirtTexCoords = ( v _textureCoordinates * invPixelSize ) / dirtTextureDimensions ;
if ( dirtTexCoords . x > 1.0 )
{
dirtTexCoords . x = mod ( floor ( dirtTexCoords . x ) , 2.0 ) == 1.0 ? 1.0 - fract ( dirtTexCoords . x ) : fract ( dirtTexCoords . x ) ;
}
if ( dirtTexCoords . y > 1.0 )
{
dirtTexCoords . y = mod ( floor ( dirtTexCoords . y ) , 2.0 ) == 1.0 ? 1.0 - fract ( dirtTexCoords . y ) : fract ( dirtTexCoords . y ) ;
}
result += dirtAmount * texture2D ( dirtTexture , dirtTexCoords ) ;
// Rotating starburst texture's coordinate
// dot(czm_view[0].xyz, vec3(0.0, 0.0, 1.0)) + dot(czm_view[1].xyz, vec3(0.0, 1.0, 0.0))
float camrot = czm _view [ 0 ] . z + czm _view [ 1 ] . y ;
float cosValue = cos ( camrot ) ;
float sinValue = sin ( camrot ) ;
mat3 rotation = mat3 (
cosValue , - sinValue , 0.0 ,
sinValue , cosValue , 0.0 ,
0.0 , 0.0 , 1.0
) ;
vec3 st1 = vec3 ( v _textureCoordinates * 2.0 - vec2 ( 1.0 ) , 1.0 ) ;
vec3 st2 = vec3 ( ( rotation * st1 ) . xy , 1.0 ) ;
vec3 st3 = st2 * 0.5 + vec3 ( 0.5 ) ;
vec2 lensStarTexcoord = st3 . xy ;
float weightForLensFlare = length ( vec3 ( sunPos . xy , 0.0 ) ) ;
float oneMinusWeightForLensFlare = max ( 1.0 - weightForLensFlare , 0.0 ) ;
if ( ! isSpace )
{
result *= oneMinusWeightForLensFlare * intensity * 0.2 ;
}
else
{
result *= oneMinusWeightForLensFlare * intensity ;
result *= texture2D ( starTexture , lensStarTexcoord ) * pow ( weightForLensFlare , 1.0 ) * max ( ( 1.0 - length ( vec3 ( st1 . xy , 0.0 ) ) ) , 0.0 ) * 2.0 ;
}
result += texture2D ( colorTexture , v _textureCoordinates ) ;
gl _FragColor = result ;
}
` ,Iwe= ` uniform sampler2D colorTexture ;
uniform vec3 white ;
varying vec2 v _textureCoordinates ;
# ifdef AUTO _EXPOSURE
uniform sampler2D autoExposure ;
# endif
// See equation 4:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
void main ( )
{
vec4 fragmentColor = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 color = fragmentColor . rgb ;
# ifdef AUTO _EXPOSURE
float exposure = texture2D ( autoExposure , vec2 ( 0.5 ) ) . r ;
color /= exposure ;
# endif
color = ( color * ( 1.0 + color / white ) ) / ( 1.0 + color ) ;
color = czm _inverseGamma ( color ) ;
gl _FragColor = vec4 ( color , fragmentColor . a ) ;
}
` ,Pwe= ` uniform sampler2D colorTexture ;
varying vec2 v _textureCoordinates ;
float rand ( vec2 co )
{
return fract ( sin ( dot ( co . xy , vec2 ( 12.9898 , 78.233 ) ) ) * 43758.5453 ) ;
}
void main ( void )
{
float noiseValue = rand ( v _textureCoordinates + sin ( czm _frameNumber ) ) * 0.1 ;
vec3 rgb = texture2D ( colorTexture , v _textureCoordinates ) . rgb ;
vec3 green = vec3 ( 0.0 , 1.0 , 0.0 ) ;
gl _FragColor = vec4 ( ( noiseValue + rgb ) * green , 1.0 ) ;
}
` ,Owe= ` uniform sampler2D colorTexture ;
varying vec2 v _textureCoordinates ;
# ifdef AUTO _EXPOSURE
uniform sampler2D autoExposure ;
# endif
// See equation 3:
// http://www.cs.utah.edu/~reinhard/cdrom/tonemap.pdf
void main ( )
{
vec4 fragmentColor = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 color = fragmentColor . rgb ;
# ifdef AUTO _EXPOSURE
float exposure = texture2D ( autoExposure , vec2 ( 0.5 ) ) . r ;
color /= exposure ;
# endif
color = color / ( 1.0 + color ) ;
color = czm _inverseGamma ( color ) ;
gl _FragColor = vec4 ( color , fragmentColor . a ) ;
}
` ,Lwe= ` uniform sampler2D colorTexture ;
uniform sampler2D silhouetteTexture ;
varying vec2 v _textureCoordinates ;
void main ( void )
{
vec4 silhouetteColor = texture2D ( silhouetteTexture , v _textureCoordinates ) ;
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
gl _FragColor = mix ( color , silhouetteColor , silhouetteColor . a ) ;
}
` ;function s_(){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 Cn,this._commands=void 0,this._clearCommand=void 0,this._minMaxLuminance=new j,this.enabled=!0,this._enabled=!0,this.minimumLuminance=.1,this.maximumLuminance=10}Object.defineProperties(s_.prototype,{ready:{get:function(){return this._ready}},name:{get:function(){return this._name}},outputTexture:{get:function(){const e=this._framebuffers;if(l(e))return e[e.length-1].getColorTexture(0)}}});function gj(e){const t=e._framebuffers;if(!l(t))return;const 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 Bwe(e,t){gj(e);let n=e._width,i=e._height;const o=t.halfFloatingPointTexture?Ke.HALF_FLOAT:Ke.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 Cn,s[c].update(t,n,i,1,o);const a=s[r-1].getColorTexture(0);e._previousLuminance.update(t,a.width,a.height,1,o),e._framebuffers=s}function yj(e){const t=e._commands;if(!l(t))return;const n=t.length;for(let i=0;i<n;++i)t[i].shaderProgram.destroy();e._commands=void 0}function Rwe(e,t){let n;if(t===0)n={colorTexture:function(){return e._colorTexture},colorTextureDimensions:function(){return e._colorTexture.dimensions}};else{const 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 Nwe(e,t){let n= ` uniform sampler2D colorTexture ;
varying vec2 v _textureCoordinates ;
float sampleTexture ( vec2 offset ) {
` ;return e===0?n+= ` vec4 color = texture2D ( colorTexture , v _textureCoordinates + offset ) ;
return czm _luminance ( color . rgb ) ;
` :n+= ` return texture2D ( colorTexture , v _textureCoordinates + offset ) . r ;
` ,n+= ` }
` ,n+= ` uniform vec2 colorTextureDimensions ;
uniform vec2 minMaxLuminance ;
uniform sampler2D previousLuminance ;
void main ( ) {
float color = 0.0 ;
float xStep = 1.0 / colorTextureDimensions . x ;
float yStep = 1.0 / colorTextureDimensions . y ;
int count = 0 ;
for ( int i = 0 ; i < 3 ; ++ i ) {
for ( int j = 0 ; j < 3 ; ++ j ) {
vec2 offset ;
offset . x = - xStep + float ( i ) * xStep ;
offset . y = - yStep + float ( j ) * yStep ;
if ( offset . x < 0.0 || offset . x > 1.0 || offset . y < 0.0 || offset . y > 1.0 ) {
continue ;
}
color += sampleTexture ( offset ) ;
++ count ;
}
}
if ( count > 0 ) {
color /= float ( count ) ;
}
` ,e===t-1&&(n+= ` float previous = texture2D ( previousLuminance , vec2 ( 0.5 ) ) . r ;
color = clamp ( color , minMaxLuminance . x , minMaxLuminance . y ) ;
color = previous + ( color - previous ) / ( 60.0 * 1.5 ) ;
color = clamp ( color , minMaxLuminance . x , minMaxLuminance . y ) ;
` ),n+= ` gl _FragColor = vec4 ( color ) ;
}
` ,n}function Mwe(e,t){yj(e);const n=e._framebuffers,i=n.length,o=new Array(i);for(let r=0;r<i;++r)o[r]=t.createViewportQuadCommand(Nwe(r,i),{framebuffer:n[r].framebuffer,uniformMap:Rwe(e,r)});e._commands=o}s_.prototype.clear=function(e){const t=this._framebuffers;if(!l(t))return;let n=this._clearCommand;l(n)||(n=this._clearCommand=new ji({color:new F(0,0,0,0),framebuffer:void 0}));const i=t.length;for(let o=0;o<i;++o)t[o].clear(e,n)};s_.prototype.update=function(e){const t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,Bwe(this,e),Mwe(this,e),this._ready||(this._ready=!0)),this._minMaxLuminance.x=this.minimumLuminance,this._minMaxLuminance.y=this.maximumLuminance;const 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};s_.prototype.execute=function(e,t){this._colorTexture=t;const n=this._commands;if(!l(n))return;const i=n.length;for(let o=0;o<i;++o)n[o].execute(e)};s_.prototype.isDestroyed=function(){return!1};s_.prototype.destroy=function(){return gj(this),yj(this),Ue(this)};const Fwe={NEAREST:0,LINEAR:1},Lm=Fwe;function gi(e){e=y(e,y.EMPTY_OBJECT);const t=e.fragmentShader,n=y(e.textureScale,1),i=y(e.pixelFormat,nt.RGBA);if(T.typeOf.string("options.fragmentShader",t),T.typeOf.number.greaterThan("options.textureScale",n,0),T.typeOf.number.lessThanOrEquals("options.textureScale",n,1),!nt.isColorFormat(i))throw new E("options.pixelFormat must be a color format.");this._fragmentShader=t,this._uniforms=e.uniforms,this._textureScale=n,this._forcePowerOfTwo=y(e.forcePowerOfTwo,!1),this._sampleMode=y(e.sampleMode,Lm.NEAREST),this._pixelFormat=i,this._pixelDatatype=y(e.pixelDatatype,Ke.UNSIGNED_BYTE),this._clearColor=y(e.clearColor,F.BLACK),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;const o=new $ m;o.scissorTest={enabled:!0,rectangle:l(e.scissorRectangle)?qe.clone(e.scissorRectangle):new qe},this._passState=o,this._ready=!1;let r=e.name;l(r)||(r=ds()),this._name=r,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(gi.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)){const 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}}});const zwe=/uniform \s +sampler2D \s +depthTexture/g;gi.prototype._isSupported=function(e){return!zwe.test(this._fragmentShader)||e.depthTexture};function Uwe(e,t,n){const 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){const
uniform sampler2D czm _idTexture ;
uniform sampler2D czm _selectedIdTexture ;
uniform float czm _selectedIdTextureStep ;
varying vec2 v _textureCoordinates ;
bool czm _selected ( vec2 offset )
{
bool selected = false ;
vec4 id = texture2D ( czm _idTexture , v _textureCoordinates + offset ) ;
for ( int i = 0 ; i < $ { o } ; ++ i )
{
vec4 selectedId = texture2D ( czm _selectedIdTexture , vec2 ( ( float ( i ) + 0.5 ) * czm _selectedIdTextureStep , 0.5 ) ) ;
if ( all ( equal ( id , selectedId ) ) )
{
return true ;
}
}
return false ;
}
bool czm _selected ( )
{
return czm _selected ( vec2 ( 0.0 ) ) ;
}
$ { n } ` }const i=new Ge({defines:[e._useLogDepth?"LOG_DEPTH":""],sources:[n]});e._command=t.createViewportQuadCommand(i,{uniformMap:e._uniformMap,owner:e})}function Wwe(e){const t=e._sampleMode;let n,i;t===Lm.LINEAR?(n=_n.LINEAR,i=Pr.LINEAR):(n=_n.NEAREST,i=Pr.NEAREST);const o=e._sampler;(!l(o)||o.minificationFilter!==n||o.magnificationFilter!==i)&&(e._sampler=new jn({wrapS:Ci.CLAMP_TO_EDGE,wrapT:Ci.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function jwe(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function qwe(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function Ywe(e,t){let n,i,o;const r=e._texturesToRelease;let s=r.length;for(n=0;n<s;++n)i=r[n],i=i&&i.destroy();r.length=0;const a=e._texturesToCreate;for(s=a.length,n=0;n<s;++n){const h=a[n];o=h.name;const _=h.source;e._actualUniforms[o]=new Ft({context:t,source:_})}a.length=0;const c=e._dirtyUniforms;if(c.length===0&&!l(e._texturePromise)){e._ready=!0;return}if(c.length===0||l(e._texturePromise))return;s=c.length;const u=e._uniforms,f=[];for(n=0;n<s;++n){o=c[n];const h=u[o],_=e._textureCache.getStageByName(h);if(l(_))e._actualUniforms[o]=qwe(e,h);else if(typeof h=="string"){const g=new Re({url:h});f.push(g.fetchImage().then(jwe(e,o)))}else e._texturesToCreate.push({name:o,source:h})}c.length=0,f.length>0?(e._ready=!1,e._texturePromise=Promise.all(f).then(function(){e._ready=!0,e._texturePromise=void 0})):e._ready=!0}function Aj(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();const t=e._textureCache;if(!l(t))return;const n=e._uniforms,i=e._actualUniforms;for(const o in i)i.hasOwnProperty(o)&&i[o]instanceof Ft&&(l(t.getStageByName(n[o]))||i[o].destroy(),e._dirtyUniforms.push(o))}function Xwe(e){let t=l(e._selected)?e._selected.length:0;const n=l(e._parentSelected)?e._parentSelected:0;let i=e._selected!==e._selectedShadow||t!==e._selectedLength;if(i=i||e._parentSelected!==e._parentSelectedShadow||n!==e._parentSelectedLength,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;t=e._combinedSelected.length;for(let o=0;o<t;++o)if(e._combinedSelected[o]!==e._combinedSelectedShadow[o])return!0}return i}function $ we(e,t){if(!e._selectedDirty)return;e._selectedIdTexture=e._selectedIdTexture&&e._selectedIdTexture.destroy(),e._selectedIdTexture=void 0;const n=e._combinedSelected;if(!l(n))return;let i,o,r=0;const s=n.length;for(i=0;i<s;++i)o=n[i],l(o.pickIds)?r+=o.pickIds.length:l(o.pickId)&&++r;if(s===0||r===0){const f=new Uint8Array(4);f[0]=255,f[1]=255,f[2]=255,f[3]=255,e._selectedIdTexture=new Ft({context:t,pixelFormat:nt.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:f,width:1,height:1},sampler:jn.NEAREST});return}let a,c=0;const u=new Uint8Array(r*4);for(i=0;i<s;++i)if(o=n[i],l(o.pickIds)){const f=o.pickIds,h=f.length;for(let _=0;_<h;++_)a=f[_].color,u[c]=F.floatToByte(a.red),u[c+1]=F.floatToByte(a.green),u[c+2]=F.floatToByte(a.blue),u[c+3]=F.floatToByte(a.alpha),c+=4}else l(o.pickId)&&(a=o.pickId.color,u[c]=F.floatToByte(a.red),u[c+1]=F.floatToByte(a.green),u[c+2]=F.floatToByte(a.blue),u[c+3]=F.floatToByte(a.alpha),c+=4);e._selectedIdTexture=new Ft({context:t,pixelFormat:nt.RGBA,pixelDatatype:Ke.UNSIGNED_BYTE,source:{arrayBufferView:u,width:r,height:1},sampler:jn.NEAREST})}gi.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&Aj(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=Xwe(this),this._selectedShadow=this._selected,this._parentSelectedShadow=this._parentSelected,this._combinedSelectedShadow=this._combinedSelected,this._selectedLength=l(this._selected)?this._selected.length:0,this._parentSelectedLength=l(this._parentSelected)?this._parent
$ { U1 } ` ,r=new gi({name: ` $ { e } _x _direction ` ,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:Lm.LINEAR}),s=new gi({name: ` $ { e } _y _direction ` ,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:Lm.LINEAR}),a={};return Object.defineProperties(a,{delta:{get:function(){return r.uniforms.delta},set:function(c){const u=r.uniforms,f=s.uniforms;u.delta=f.delta=c}},sigma:{get:function(){return r.uniforms.sigma},set:function(c){const u=r.uniforms,f=s.uniforms;u.sigma=f.sigma=c}},stepSize:{get:function(){return r.uniforms.stepSize},set:function(c){const u=r.uniforms,f=s.uniforms;u.stepSize=f.stepSize=c}}}),new Vs({name:e,stages:[r,s],uniforms:a})}zo.createBlurStage=function(){return VS("czm_blur")};zo.createDepthOfFieldStage=function(){const e=VS("czm_depth_of_field_blur"),t=new gi({name:"czm_depth_of_field_composite",fragmentShader:Ewe,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 Vs({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};zo.isDepthOfFieldSupported=function(e){return e.context.depthTexture};zo.createEdgeDetectionStage=function(){const e=ds();return new gi({name: ` czm _edge _detection _$ { e } ` ,fragmentShader:wwe,uniforms:{length:.25,color:F.clone(F.BLACK)}})};zo.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function Jwe(e){if(!l(e))return zo.createEdgeDetectionStage();const t=new Vs({name:"czm_edge_detection_multiple",stages:e,inputPreviousStageTexture:!1}),n={};let i="",o="";for(let a=0;a<e.length;++a)i+= ` uniform sampler2D edgeTexture$ { a } ;
` ,o+= ` vec4 edge$ { a } = texture2D ( edgeTexture$ { a } , v _textureCoordinates ) ;
if ( edge$ { a } . a > 0.0 )
{
color = edge$ { a } ;
break ;
}
` ,n[ ` edgeTexture$ { a } ` ]=e[a].name;const r= ` $ { i } varying vec2 v _textureCoordinates ;
void main ( ) {
vec4 color = vec4 ( 0.0 ) ;
for ( int i = 0 ; i < $ { e . length } ; i ++ )
{
$ { o } }
gl _FragColor = color ;
}
` ,s=new gi({name:"czm_edge_detection_combine",fragmentShader:r,uniforms:n});return new Vs({name:"czm_edge_detection_composite",stages:[t,s]})}zo.createSilhouetteStage=function(e){const t=Jwe(e),n=new gi({name:"czm_silhouette_color_edges",fragmentShader:Lwe,uniforms:{silhouetteTexture:t.name}});return new Vs({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};zo.isSilhouetteSupported=function(e){return e.context.depthTexture};zo.createBloomStage=function(){const e=new gi({name:"czm_bloom_contrast_bias",fragmentShader:bwe,uniforms:{contrast:128,brightness:-.3}}),t=VS("czm_bloom_blur"),n=new Vs({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new gi({name:"czm_bloom_generate_composite",fragmentShader:Cwe,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 Vs({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};zo.createAmbientOcclusionStage=function(){const e=new gi({name:"czm_ambient_occlusion_generate",fragmentShader:gwe,uniforms:{intensity:3,bias:.1,lengthCap:.26,stepSize:1.95,frustumLength:1e3,randomTexture:void 0}}),t=VS("czm_ambient_occlusion_blur");t.uniforms.stepSize=.86;const n=new Vs({name:"czm_ambient_occlusion_generate_blur",stages:[e,t]}),i=new gi({name:"czm_ambient_occlusion_composite",fragmentShader:ywe,uniforms:{ambientOcclusionOnly:!1,ambientOcclusionTexture:n.name}}),o={};return Object.defineProperties(o,{intensity:{get:function(){return e.uniforms.intensity},set:function(r){e.uniforms.intensity=r}},bias:{get:function(){return e.uniforms.bias},set:function(r){e.uniforms.bias=r}},lengthCap:{get:function(){return e.uniforms.lengthCap},set:function(r){e.uniforms.lengthCap=r}},stepSize:{get:function(){return e.uniforms.stepSize},set:function(r){e.uniforms.stepSize=r}},frustumLength:{get:function(){return e.uniforms.frustumLength},set:function(r){e.uniforms.frustumLength=r}},randomTexture:{get:function(){return e.uniforms.randomTexture},set:function(r){e.uniforms.randomTexture=r}},delta:{get:function(){return t.uniforms.delta},set:function(r){t.uniforms.delta=r}},sigma:{get:function(){return t.uniforms.sigma},set:function(r){t.uniforms.sigma=r}},blurStepSize:{get:function(){return t.uniforms.stepSize},set:function(r){t.uniforms.stepSize=r}},ambientOcclusionOnly:{get:function(){return i.uniforms.ambientOcclusionOnly},set:function(r){i.uniforms.ambientOcclusionOnly=r}}}),new Vs({name:"czm_ambient_occlusion",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};zo.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};const Qwe= ` # define FXAA _QUALITY _PRESET 39
$ { Pue }
$ { vwe } ` ;zo.createFXAAStage=function(){return new gi({name:"czm_FXAA",fragmentShader:Qwe,sampleMode:Lm.LINEAR})};zo.createAcesTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=_we,new gi({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0}})};zo.createFilmicTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=Swe,new gi({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0}})};zo.createReinhardTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=Owe,new gi({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0}})};zo.createModifiedReinhardTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=Iwe,new gi({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:F.WHITE,autoExposure:void 0}})};zo.createAutoExposureStage=function(){return new s_};zo.createBlackAndWhiteStage=function(){return new gi({name:"czm_black_and_white",fragmentShader:Awe,uniforms:{gradations:5}})};zo.createBrightnessStage=function(){return new gi({name:"czm_brightness",fragmentShader:Twe,uniforms:{brightness:.5}})};zo.createNightVisionStage=function(){return new gi({name:"czm_night_vision",fragmentShader:Pwe})};zo.createDepthViewStage=function(){return new gi({name:"czm_depth_view",fragmentShader:xwe})};zo.createLensFlareStage=function(){return new gi({name:"czm_lens_flare",fragmentShader:Dwe,uniforms:{dirtTexture:ln("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:ln("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:pe.WGS84.maximumRadius}})};const hh=zo;function $ u(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function PA(e){for(;l(e.length);)e=e.get(e.length-1);return e.name}function H1(e,t,n,i,o){if(!i.enabled||!i._isSupported(t))return o;const r=n[i.name]={};if(l(o)){const a=e.getStageByName(o);r[PA(a)]=!0}const s=i.uniforms;if(l(s)){const a=Object.getOwnPropertyNames(s),c=a.length;for(let u=0;u<c;++u){const f=s[a[u]];if(typeof f=="string"){const h=e.getStageByName(f);l(h)&&(r[PA(h)]=!0)}}}return i.name}function eA(e,t,n,i,o){if(l(i.enabled)&&!i.enabled||l(i._isSupported)&&!i._isSupported(t))return o;const r=o,s=!l(i.inputPreviousStageTexture)||i.inputPreviousStageTexture;let a=o;const c=i.length;for(let h=0;h<c;++h){const _=i.get(h);l(_.length)?a=eA(e,t,n,_,o):a=H1(e,t,n,_,o),s&&(o=a)}let u,f;if(s)for(u=1;u<c;++u)f=PA(i.get(u)),l(n[f])||(n[f]={}),n[f][r]=!0;else for(u=1;u<c;++u){f=PA(i.get(u));const h=n[f];for(let _=0;_<u;++_)h[PA(i.get(_))]=!0}return a}function Zwe(e,t){const n={};if(l(e.ambientOcclusion)){const i=e.ambientOcclusion,o=e.bloom,r=e._tonemapping,s=e.fxaa;let a=eA(e,t,n,i,void 0);a=eA(e,t,n,o,a),a=H1(e,t,n,r,a),a=eA(e,t,n,e,a),H1(e,t,n,s,a)}else eA(e,t,n,e,void 0);return n}function eSe(e,t,n){const o=e._collection.getStageByName(t),r=o._textureScale,s=o._forcePowerOfTwo,a=o._pixelFormat,c=o._pixelDatatype,u=o._clearColor;let f,h;const _=e._framebuffers,g=_.length;for(f=0;f<g;++f){if(h=_[f],r!==h.textureScale||s!==h.forcePowerOfTwo||a!==h.pixelFormat||c!==h.pixelDatatype||!F.equals(u,h.clearColor))continue;const p=h.stages,A=p.length;let C=!1;for(let b=0;b<A;++b)if(n[p[b]]){C=!0;break}if(!C)break}return l(h)&&f<g?(h.stages.push(t),h):(h={textureScale:r,forcePowerOfTwo:s,pixelFormat:a,pixelDatatype:c,clearColor:u,stages:[t],buffer:new Cn({pixelFormat:a,pixelDatatype:c}),clear:void 0},_.push(h),h)}function tSe(e,t){const n=Zwe(e._collection,t);for(const i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=eSe(e,i,n[i]))}function V1(e){const t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function nSe(e,t){const n=e._width,i=e._height,o=e._framebuffers,r=o.length;for(let s=0;s<r;++s){const a=o[s],c=a.textureScale;let u=Math.ceil(n*c),f=Math.ceil(i*c),h=Math.min(u,f);a.forcePowerOfTwo&&(N.isPowerOfTwo(h)||(h=N.nextPowerOfTwo(h)),u=h,f=h),a.buffer.update(t,u,f),a.clear=new ji({color:a.clearColor,framebuffer:a.buffer.framebuffer})}} $ u.prototype.updateDependencies=function(){this._updateDependencies=!0}; $ u.prototype.update=function(e){const 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)&&(V1(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!a)return;this._framebuffers.length===0&&t
uniform sampler2D colorTexture2 ;
uniform vec2 center ;
uniform float radius ;
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 color0 = texture2D ( colorTexture , v _textureCoordinates ) ;
vec4 color1 = texture2D ( colorTexture2 , v _textureCoordinates ) ;
float x = length ( gl _FragCoord . xy - center ) / radius ;
float t = smoothstep ( 0.5 , 0.8 , x ) ;
gl _FragColor = mix ( color0 + color1 , color1 , t ) ;
}
` ,HDe= ` uniform sampler2D colorTexture ;
uniform float avgLuminance ;
uniform float threshold ;
uniform float offset ;
varying vec2 v _textureCoordinates ;
float key ( float avg )
{
float guess = 1.5 - ( 1.5 / ( avg * 0.1 + 1.0 ) ) ;
return max ( 0.0 , guess ) + 0.1 ;
}
// See section 9. "The bright-pass filter" of Realtime HDR Rendering
// http://www.cg.tuwien.ac.at/research/publications/2007/Luksch_2007_RHR/Luksch_2007_RHR-RealtimeHDR%20.pdf
void main ( )
{
vec4 color = texture2D ( colorTexture , v _textureCoordinates ) ;
vec3 xyz = czm _RGBToXYZ ( color . rgb ) ;
float luminance = xyz . r ;
float scaledLum = key ( avgLuminance ) * luminance / avgLuminance ;
float brightLum = max ( scaledLum - threshold , 0.0 ) ;
float brightness = brightLum / ( offset + brightLum ) ;
xyz . r = brightness ;
gl _FragColor = vec4 ( czm _XYZToRGB ( xyz ) , 1.0 ) ;
}
` ;function ud(){this._sceneFramebuffer=new Yu;const e=.125,t=new Array(6);t[0]=new gi({fragmentShader:Om,textureScale:e,forcePowerOfTwo:!0,sampleMode:Lm.LINEAR});const n=t[1]=new gi({fragmentShader:HDe,uniforms:{avgLuminance:.5,threshold:.25,offset:.1},textureScale:e,forcePowerOfTwo:!0}),i=this;this._delta=1,this._sigma=2,this._blurStep=new j,t[2]=new gi({fragmentShader:U1,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 gi({fragmentShader:U1,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 gi({fragmentShader:Om,sampleMode:Lm.LINEAR}),this._uCenter=new j,this._uRadius=void 0,t[5]=new gi({fragmentShader:UDe,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new Vs({stages:t});const o=new $ u(this),r=t.length;for(let s=0;s<r;++s)t[s]._textureCache=o;this._textureCache=o,this.length=t.length}ud.prototype.get=function(e){return this._stages.get(e)};ud.prototype.getStageByName=function(e){const t=this._stages.length;for(let n=0;n<t;++n){const i=this._stages.get(n);if(i.name===e)return i}};const VDe=new oe,HU=new j,kDe=new j,VU=new B;function GDe(e,t,n){const i=t.uniformState,o=i.sunPositionWC,r=i.view,s=i.viewProjection,a=i.projection;let c=B.computeViewportTransformation(n,0,1,VU);const u=B.multiplyByPoint(r,o,VDe);let f=Qt.pointToGLWindowCoordinates(s,c,o,HU);u.x+=N.SOLAR_RADIUS;const h=Qt.pointToGLWindowCoordinates(a,c,u,u),_=j.magnitude(j.subtract(h,f,h))*30*2,g=kDe;g.x=_,g.y=_,e._uCenter=j.clone(f,e._uCenter),e._uRadius=Math.max(g.x,g.y)*.15;const p=t.drawingBufferWidth,A=t.drawingBufferHeight,C=e._stages,b=C.get(0),x=b.outputTexture.width,w=b.outputTexture.height,S=new qe;S.width=x,S.height=w,c=B.computeViewportTransformation(S,0,1,VU),f=Qt.pointToGLWindowCoordinates(s,c,o,HU),g.x*=x/p,g.y*=w/A;const P=b.scissorRectangle;P.x=Math.max(f.x-g.x*.5,0),P.y=Math.max(f.y-g.y*.5,0),P.width=Math.min(g.x,p),P.height=Math.min(g.y,A);for(let L=1;L<4;++L)qe.clone(P,C.get(L).scissorRectangle)}ud.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)};ud.prototype.update=function(e){const t=e.context,n=e.viewport,i=this._sceneFramebuffer;i.update(t,n);const o=i.framebuffer;return this._textureCache.update(t),this._stages.update(t,!1),GDe(this,t,n),o};ud.prototype.execute=function(e){const 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)};ud.prototype.copy=function(e,t){if(!l(this._copyColorCommand)){const n=this;this._copyColorCommand=e.createViewportQuadCommand(Om,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)};ud.prototype.isDestroyed=function(){return!1};ud.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),Ue(this)};function Qj(){this._cachedShowFrustumsShaders={}}function WDe(e){const t={},n=e.vertexAttributes;for(const i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function jDe(e,t){const n=e.context,i=t,o=i.fragmentShaderSource.clone(),r=[];o.sources=o.sources.map(function(f){f=Ge.replaceMain(f,"czm_Debug_main");const h=/gl_FragData \[ ( \d +) \] /g;let _;for(;(_=h.exec(f))!==null;)r.indexOf(_[1])===-1&&r.push(_[1]);return f});const s=r.length;let a="";a+= ` uniform vec3 debugShowCommandsColor ;
` ,a+= ` uniform vec3 debugShowFrustumsColor ;
` ,a+= ` void main ( )
{
czm _Debug _main ( ) ;
` ;let c;if(s>0)for(c=0;c<s;++c)a+= ` gl _FragData [ $ { r [ c ] } ] . rgb *= debugShowCommandsColor ;
` ,a+= ` gl _FragData [ $ { r [ c ] } ] . rgb *= debugShowFrustumsColor ;
` ;else a+= ` gl _FragColor . rgb *= debugShowCommandsColor ;
` ,a+= ` gl _FragColor . rgb *= debugShowFrustumsColor ;
` ;a+="}",o.sources.push(a);const u=WDe(i);return un.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:o,attributeLocations:u})}const y0=new F;function qDe(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=F.fromRandom()),t._debugColor):F.WHITE},n.debugShowFrustumsColor=function(){return e.debugShowFrustums?(y0.red=t.debugOverlappingFrustums&1<<0?1:0,y0.green=t.debugOverlappingFrustums&1<<1?1:0,y0.blue=t.debugOverlappingFrustums&1<<2?1:0,y0.alpha=1,y0):F.WHITE}),n}const YDe=new ft;Qj.prototype.executeDebugShowFrustumsCommand=function(e,t,n){const i=t.shaderProgram.id;let o=this._cachedShowFrustumsShaders[i];l(o)||(o=jDe(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=o);const r=ft.shallowClone(t,YDe);r.shaderProgram=o,r.uniformMap=qDe(e,t),r.execute(e.context,n)};const yw=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function li(e){e=y(e,y.EMPTY_OBJECT);const t=e.canvas;let n=e.creditContainer,i=e.creditViewport;const o=lt(e.contextOptions);if(!l(t))throw new E("options and options.canvas are required.");const r=l(n),s=new wa(t,o);r||(n=document.createElement("div"),n.style.position="absolute",n.style.bottom="0",n.style["text-shadow"]="0 0 2px #000000",n.style.color="#ffffff",n.style["font-size"]="10px",n.style["padding-right"]="5px",t.parentNode.appendChild(n)),l(i)||(i=t.parentNode),this._id=ds(),this._jobScheduler=new wh,this._frameState=new Obe(s,new xo(n," • ",i),this._jobScheduler),this._frameState.scene3DOnly=y(e.scene3DOnly,!1),this._removeCreditContainer=!r,this._creditContainer=n,this._canvas=t,this._context=s,this._computeEngine=new mS(s),this._globe=void 0,this._globeTranslucencyState=new i_,this._primitives=new Do,this._groundPrimitives=new Do,this._globeHeight=void 0,this._cameraUnderground=!1,this._logDepthBuffer=s.fragmentDepth,this._logDepthBufferDirty=!0,this._tweens=new Jc,this._shaderFrameCount=0,this._sunPostProcess=void 0,this._computeCommandList=[],this._overlayCommandList=[],this._useOIT=y(e.orderIndependentTranslucency,!0),this._executeOITFunction=void 0,this._depthPlane=new KC(e.depthPlaneEllipsoidOffset),this._clearColorCommand=new ji({color:new F,stencil:0,owner:this}),this._depthClearCommand=new ji({depth:1,owner:this}),this._stencilClearCommand=new ji({stencil:0}),this._classificationStencilClearCommand=new ji({stencil:0,renderState:Qe.fromCache({stencilMask:It.CLASSIFICATION_MASK})}),this._depthOnlyRenderStateCache={},this._transitioner=new c_(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 Qj,this._msaaSamples=y(e.msaaSamples,1),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=F.clone(F.BLACK),this._mode=le.SCENE3D,this._mapProjection=l(e.mapProjection)?e.mapProjection:new Fo,this.morphTime=1,this.farToNearRatio=1e3,this.logarithmicDepthFarToNearRatio=1e9,this.nearToFarDistance2D=175e4,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.fog=new HW,this._shadowMapCamera=new ot(this),this.shadowMap=new ic({context:s,lightCamera:this._shadowMapCamera,enabled:y(e.shadows,!1)}),this.invertClassification=!1,this.invertClassificationColor=F.clone(F.WHITE),this._actualInvertClassificationColor=F.clone(this._invertClassificationColor),this._invertClassification=new Yl,this.focalLength=void 0,this.eyeSeparation=void 0,this.postProcessStages=new fa,this.
$ { t }
$ { p } ` );const A=document.createElement("div");A.className="cesium-widget-errorPanel-message-details collapsed";const C=document.createElement("span");C.className="cesium-widget-errorPanel-more-details",C.appendChild(document.createTextNode("See more...")),A.appendChild(C),A.onclick=function(b){A.removeChild(C),A.appendChild(document.createTextNode(p)),A.className="cesium-widget-errorPanel-message-details",r.className="cesium-widget-errorPanel-content expanded",A.onclick=void 0},a.appendChild(A)}g.innerHTML= ` < p > $ { t } < / p > ` } c o n s t h = d o c u m e n t . c r e a t e E l e m e n t ( " d i v " ) ; h . c l a s s N a m e = " c e s i u m - w i d g e t - e r r o r P a n e l - b u t t o n P a n e l " , r . a p p e n d C h i l d ( h ) ; c o n s t _ = d o c u m e n t . c r e a t e E l e m e n t ( " b u t t o n " ) ; _ . s e t A t t r i b u t e ( " t y p e " , " b u t t o n " ) , _ . c l a s s N a m e = " c e s i u m - b u t t o n " , _ . a p p e n d C h i l d ( d o c u m e n t . c r e a t e T e x t N o d e ( " O K " ) ) , _ . o n c l i c k = f u n c t i o n ( ) { l ( c ) & & l ( w i n d o w . r e m o v e E v e n t L i s t e n e r ) & & w i n d o w . r e m o v e E v e n t L i s t e n e r ( " r e s i z e " , c , ! 1 ) , i . r e m o v e C h i l d ( o ) } , h . a p p e n d C h i l d ( _ ) , i . a p p e n d C h i l d ( o ) } ; l _ . p r o t o t y p e . i s D e s t r o y e d = f u n c t i o n ( ) { r e t u r n ! 1 } ; l _ . p r o t o t y p e . d e s t r o y = f u n c t i o n ( ) { l ( t h i s . _ s c e n e ) & & ( t h i s . _ s c e n e . r e n d e r E r r o r . r e m o v e E v e n t L i s t e n e r ( t h i s . _ o n R e n d e r E r r o r ) , t h i s . _ s c e n e = t h i s . _ s c e n e . d e s t r o y ( ) ) , t h i s . _ c o n t a i n e r . r e m o v e C h i l d ( t h i s . _ e l e m e n t ) , t h i s . _ c r e d i t C o n t a i n e r . r e m o v e C h i l d ( t h i s . _ i n n e r C r e d i t C o n t a i n e r ) , U e ( t h i s ) } ; l _ . p r o t o t y p e . r e s i z e = f u n c t i o n ( ) { c o n s t e = t h i s . _ c a n v a s ; ! t h i s . _ f o r c e R e s i z e & & t h i s . _ c a n v a s C l i e n t W i d t h = = = e . c l i e n t W i d t h & & t h i s . _ c a n v a s C l i e n t H e i g h t = = = e . c l i e n t H e i g h t & & t h i s . _ l a s t D e v i c e P i x e l R a t i o = = = w i n d o w . d e v i c e P i x e l R a t i o | | ( t h i s . _ f o r c e R e s i z e = ! 1 , r q ( t h i s ) , s q ( t h i s ) , t h i s . _ s c e n e . r e q u e s t R e n d e r ( ) ) } ; l _ . p r o t o t y p e . r e n d e r = f u n c t i o n ( ) { i f ( t h i s . _ c a n R e n d e r ) { t h i s . _ s c e n e . i n i t i a l i z e F r a m e ( ) ; c o n s t e = t h i s . _ c l o c k . t i c k ( ) ; t h i s . _ s c e n e . r e n d e r ( e ) } e l s e t h i s . _ c l o c k . t i c k ( ) } ; f u n c t i o n M o ( e ) { t h i s . _ v a l u e = v o i d 0 , t h i s . _ h a s C l o n e = ! 1 , t h i s . _ h a s E q u a l s = ! 1 , t h i s . _ d e f i n i t i o n C h a n g e d = n e w X e , t h i s . s e t V a l u e ( e ) } O b j e c t . d e f i n e P r o p e r t i e s ( M o . p r o t o t y p e , { i s C o n s t a n t : { v a l u e : ! 0 } , d e f i n i t i o n C h a n g e d : { g e t : f u n c t i o n ( ) { r e t u r n t h i s . _ d e f i n i t i o n C h a n g e d } } } ) ; M o . p r o t o t y p e . g e t V a l u e = f u n c t i o n ( e , t ) { r e t u r n t h i s . _ h a s C l o n e ? t h i s . _ v a l u e . c l o n e ( t ) : t h i s . _ v a l u e } ; M o . p r o t o t y p e . s e t V a l u e = f u n c t i o n ( e ) { c o n s t t = t h i s . _ v a l u e ; i f ( t ! = = e ) { c o n s t n = l ( e ) , i = n & & t y p e o f e . c l o n e = = " f u n c t i o n " , o = n & & t y p e o f e . e q u a l s = = " f u n c t i o n " ; ( ! o | | ! e . e q u a l s ( t ) ) & & ( t h i s . _ h a s C l o n e = i , t h i s . _ h a s E q u a l s = o , t h i s . _ v a l u e = i ? e . c l o n e ( t h i s . _ v a l u e ) : e , t h i s . _ d e f i n i t i o n C h a n g e d . r a i s e E v e n t ( t h i s ) ) } } ; M o . p r o t o t y p e . e q u a l s = f u n c t i o n ( e ) { r e t u r n t h i s = = = e | | e i n s t a n c e o f M o & & ( ! t h i s . _ h a s E q u a l s & & t h i s . _ v a l u e = = = e . _ v a l u e | | t h i s . _ h a s E q u a l s & & t h i s . _ v a l u e . e q u a l s ( e . _ v a l u e ) ) } ; M o . p r o t o t y p e . v a l u e O f = f u n c t i o n ( ) { r e t u r n t h i s . _ v a l u e } ; M o . p r o t o t y p e . t o S t r i n g = f u n c t i o n ( ) { r e t u r n S t r i n g ( t h i s . _ v a l u e ) } ; f u n c t i o n U I e ( e , t , n , i , o ) { r e t u r n { c o n f i g u r a b l e : i , g e t : f u n c t i o n ( ) { r e t u r n t h i s [ t ] } , s e t : f u n c t i o n ( r ) { c o n s t s = t h i s [ t ] , a = t h i s [ n ] ; l ( a ) & & ( a ( ) , t h i s [ n ] = v o i d 0 ) , r ! = = v o i d 0 & & ( ! l ( r ) | | ! l ( r . g e t V a l u e ) ) & & l ( o ) & & ( r = o ( r ) ) , s ! = = r & & ( t h i s [ t ] = r , t h i s . _ d e f i n i t i o n C h a n g e d . r a i s e E v e n t ( t h i s , e , r , s ) ) , l ( r ) & & l ( r . d e f i n i t i o n C h a n g e d ) & & ( t h i s [ n ] = r . d e f i n i t i o n C h a n g e d . a d d E v e n t L i s t e n e r ( f u n c t i o n ( ) { t h i s . _ d e f i n i t i o n C h a n g e d . r a i s e E v e n t ( t h i s , e , r , r ) } , t h i s ) ) } } } f u n c t i o n H I e ( e ) { r e t u r n n e w M o ( e ) } f u n c t i o n g e ( e , t , n ) { r e t u r n U I e ( e , ` _ $ { e . t o S t r i n g ( ) } ` , ` _ $ { e . t o S t r i n g ( ) } S u b s c r i p t i o n ` , y ( t , ! 1 ) , y ( n , H I e ) ) } f u n c t i o n c C ( e ) { t h i s . _ d e f i n i t i o n C h a n g e d = n e w X e , t h i s . _ s h o w = v o i d 0 , t h i s . _ s h o w S u b s c r i p t i o n = v o i d 0 , t h i s . _ i m a g e = v o i d 0 , t h i s . _ i m a g e S u b s c r i p t i o n = v o i d 0 , t h i s . _ s c a l e = v o i d 0 , t h i s . _ s c a l e S u b s c r i p t i o n = v o i d 0 , t h i s . _ p i x e l O f f s e t = v o i d 0 , t h i s . _ p i x e l O f f s e t S u b s c r i p t i o n = v o i d 0 , t h i s . _ e y e O f f s e t = v o i d 0 , t h i s . _ e y e O f f s e t S u b s c r i p t i o n = v o i d 0 , t h i s . _ h o r i z o n t a l O r i g i n = v o i d 0 , t h i s . _ h o r i z o n t a l O r i g i n S u b s c r i p t i o n = v o i d 0 , t h i s . _ v e r t i c a l O r i g i n = v o i d 0 , t h i s . _ v e r t i c a l O r i g i n S u b s c r i p t i o n = v o i d 0 , t h i s . _ h e i g h t R e f e r e n c e = v o i d 0 , t h i s . _ h e i g h t R e f e r e n c e S u b s c r i p t i o n = v o i d 0 , t h i s . _ c o l o r = v o i d 0 , t h i s . _ c o l o r S u b s c r i p t i o n = v o i d 0 , t h i s . _ r o t a t i o n = v o i d 0 , t h i s . _ r o t a t i o n S u b s c r i p t i o n = v o i d 0 , t h i s . _ a l i g n e d A x i s = v o i d 0 , t h i s . _ a l i g n e d A x i s S u b s c r i p t i o n = v o i d 0 , t h i s . _ s i z e I n M e t e r s = v o i d 0 , t h i s . _ s i z e I n M e t e r s S u b s c r i p t i o n = v o i d 0 , t h i s . _ w i d t h = v o i d 0 , t h i s . _ w i d t h S u b s c r i p t i o n = v o i d 0 , t h i s . _ h e i g h t = v o i d 0 , t h i s . _ h e i g h t S u b s c r i p t i o n = v o i d 0 , t h i s . _ s c a l e B y D i s t a n c e = v o i d 0 , t h i s . _ s c a l e B y D i s t a n c e S u b s c r i p t i o n = v o i d 0 , t h i s . _ t r a n s l u c e n c y B y D i s t a n c e = v o i d 0 , t h i s . _ t r a n s l u c e n c y B y D i s t a n
varying vec3 v _normalEC ;
varying vec3 v _tangentEC ;
varying vec3 v _bitangentEC ;
varying vec2 v _st ;
void main ( )
{
vec3 positionToEyeEC = - v _positionEC ;
mat3 tangentToEyeMatrix = czm _tangentToEyeSpaceMatrix ( v _normalEC , v _tangentEC , v _bitangentEC ) ;
vec3 normalEC = normalize ( v _normalEC ) ;
# ifdef FACE _FORWARD
normalEC = faceforward ( normalEC , vec3 ( 0.0 , 0.0 , 1.0 ) , - normalEC ) ;
# endif
czm _materialInput materialInput ;
materialInput . normalEC = normalEC ;
materialInput . tangentToEyeMatrix = tangentToEyeMatrix ;
materialInput . positionToEyeEC = positionToEyeEC ;
materialInput . st = v _st ;
czm _material material = czm _getMaterial ( materialInput ) ;
# ifdef FLAT
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# else
gl _FragColor = czm _phong ( normalize ( positionToEyeEC ) , material , czm _lightDirectionEC ) ;
# endif
}
` ,hPe= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 normal ;
attribute vec3 tangent ;
attribute vec3 bitangent ;
attribute vec2 st ;
attribute float batchId ;
varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
varying vec3 v _tangentEC ;
varying vec3 v _bitangentEC ;
varying vec2 v _st ;
void main ( )
{
vec4 p = czm _computePosition ( ) ;
v _positionEC = ( czm _modelViewRelativeToEye * p ) . xyz ; // position in eye coordinates
v _normalEC = czm _normal * normal ; // normal in eye coordinates
v _tangentEC = czm _normal * tangent ; // tangent in eye coordinates
v _bitangentEC = czm _normal * bitangent ; // bitangent in eye coordinates
v _st = st ;
gl _Position = czm _modelViewProjectionRelativeToEye * p ;
}
` ,pPe= ` varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
void main ( )
{
vec3 positionToEyeEC = - v _positionEC ;
vec3 normalEC = normalize ( v _normalEC ) ;
# ifdef FACE _FORWARD
normalEC = faceforward ( normalEC , vec3 ( 0.0 , 0.0 , 1.0 ) , - normalEC ) ;
# endif
czm _materialInput materialInput ;
materialInput . normalEC = normalEC ;
materialInput . positionToEyeEC = positionToEyeEC ;
czm _material material = czm _getMaterial ( materialInput ) ;
# ifdef FLAT
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# else
gl _FragColor = czm _phong ( normalize ( positionToEyeEC ) , material , czm _lightDirectionEC ) ;
# endif
}
` ,mPe= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 normal ;
attribute float batchId ;
varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
void main ( )
{
vec4 p = czm _computePosition ( ) ;
v _positionEC = ( czm _modelViewRelativeToEye * p ) . xyz ; // position in eye coordinates
v _normalEC = czm _normal * normal ; // normal in eye coordinates
gl _Position = czm _modelViewProjectionRelativeToEye * p ;
}
` ,_Pe= ` varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
varying vec2 v _st ;
void main ( )
{
vec3 positionToEyeEC = - v _positionEC ;
vec3 normalEC = normalize ( v _normalEC ) ;
# ifdef FACE _FORWARD
normalEC = faceforward ( normalEC , vec3 ( 0.0 , 0.0 , 1.0 ) , - normalEC ) ;
# endif
czm _materialInput materialInput ;
materialInput . normalEC = normalEC ;
materialInput . positionToEyeEC = positionToEyeEC ;
materialInput . st = v _st ;
czm _material material = czm _getMaterial ( materialInput ) ;
# ifdef FLAT
gl _FragColor = vec4 ( material . diffuse + material . emission , material . alpha ) ;
# else
gl _FragColor = czm _phong ( normalize ( positionToEyeEC ) , material , czm _lightDirectionEC ) ;
# endif
}
` ,gPe= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 normal ;
attribute vec2 st ;
attribute float batchId ;
varying vec3 v _positionEC ;
varying vec3 v _normalEC ;
varying vec2 v _st ;
void main ( )
{
vec4 p = czm _computePosition ( ) ;
v _positionEC = ( czm _modelViewRelativeToEye * p ) . xyz ; // position in eye coordinates
v _normalEC = czm _normal * normal ; // normal in eye coordinates
v _st = st ;
gl _Position = czm _modelViewProjectionRelativeToEye * p ;
}
` ;function Bo(e){e=y(e,y.EMPTY_OBJECT);const t=y(e.translucent,!0),n=y(e.closed,!1),i=y(e.materialSupport,Bo.MaterialSupport.TEXTURED);this.material=l(e.material)?e.material:Fe.fromType(Fe.ColorType),this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,i.vertexShaderSource),this._fragmentShaderSource=y(e.fragmentShaderSource,i.fragmentShaderSource),this._renderState=ir.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._materialSupport=i,this._vertexFormat=i.vertexFormat,this._flat=y(e.flat,!1),this._faceForward=y(e.faceForward,!n)}Object.defineProperties(Bo.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}},materialSupport:{get:function(){return this._materialSupport}},vertexFormat:{get:function(){return this._vertexFormat}},flat:{get:function(){return this._flat}},faceForward:{get:function(){return this._faceForward}}});Bo.prototype.getFragmentShaderSource=ir.prototype.getFragmentShaderSource;Bo.prototype.isTranslucent=ir.prototype.isTranslucent;Bo.prototype.getRenderState=ir.prototype.getRenderState;Bo.MaterialSupport={BASIC:Object.freeze({vertexFormat:Ne.POSITION_AND_NORMAL,vertexShaderSource:mPe,fragmentShaderSource:pPe}),TEXTURED:Object.freeze({vertexFormat:Ne.POSITION_NORMAL_AND_ST,vertexShaderSource:gPe,fragmentShaderSource:_Pe}),ALL:Object.freeze({vertexFormat:Ne.ALL,vertexShaderSource:hPe,fragmentShaderSource:dPe})};function Xt(e){this._definitionChanged=new Xe,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(Xt.prototype,{isConstant:{get:function(){return Z.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:ge("color")});Xt.prototype.getType=function(e){return"Color"};Xt.prototype.getValue=function(e,t){return l(t)||(t={}),t.color=Z.getValueOrClonedDefault(this._color,e,F.WHITE,t.color),t};Xt.prototype.equals=function(e){return this===e||e instanceof Xt&&Z.equals(this._color,e._color)};const lq={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};lq.NUMBER_OF_CLASSIFICATION_TYPES=3;const co=Object.freeze(lq);function Al(e){if(e=y(e,y.EMPTY_OBJECT),!l(e.componentDatatype))throw new E("options.componentDatatype is required.");if(!l(e.componentsPerAttribute))throw new E("options.componentsPerAttribute is required.");if(e.componentsPerAttribute<1||e.componentsPerAttribute>4)throw new E("options.componentsPerAttribute must be between 1 and 4.");if(!l(e.value))throw new E("options.value is required.");this.componentDatatype=e.componentDatatype,this.componentsPerAttribute=e.componentsPerAttribute,this.normalize=y(e.normalize,!1),this.value=e.value}function Xr(e,t,n){T.typeOf.bool("extentsCulling",e),T.typeOf.bool("planarExtents",t),T.typeOf.object("appearance",n),this._projectionExtentDefines={eastMostYhighDefine:"",eastMostYlowDefine:"",westMostYhighDefine:"",westMostYlowDefine:""};const i=new $ 1;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;const o=new $ 1;if(o.requiresTextureCoordinates=e,n instanceof hn)i.requiresNormalEC=!n.flat;else{const r= ` $ { n . material . shaderSource }
$ { n . fragmentShaderSource } ` ;i.normalEC=r.indexOf("materialInput.normalEC")!==-1||r.indexOf("czm_getDefaultMaterial")!==-1,i.positionToEyeEC=r.indexOf("materialInput.positionToEyeEC")!==-1,i.tangentToEyeMatrix=r.indexOf("materialInput.tangentToEyeMatrix")!==-1,i.st=r.indexOf("materialInput.st")!==-1}this._colorShaderDependencies=i,this._pickShaderDependencies=o,this._appearance=n,this._extentsCulling=e,this._planarExtents=t}Xr.prototype.createFragmentShader=function(e){T.typeOf.bool("columbusView2D",e);const 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 hn&&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 hn||(o=t.material.shaderSource),new Ge({defines:i,sources:[o,f6]})};Xr.prototype.createPickFragmentShader=function(e){T.typeOf.bool("columbusView2D",e);const 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 Ge({defines:n,sources:[f6],pickColorQualifier:"varying"})};Xr.prototype.createVertexShader=function(e,t,n,i){return T.defined("defines",e),T.typeOf.string("vertexShaderSource",t),T.typeOf.bool("columbusView2D",n),T.defined("mapProjection",i),uq(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};Xr.prototype.createPickVertexShader=function(e,t,n,i){return T.defined("defines",e),T.typeOf.string("vertexShaderSource",t),T.typeOf.bool("columbusView2D",n),T.defined("mapProjection",i),uq(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};const qU=new d,YU=new Ae,XU={high:0,low:0};function uq(e,t,n,i,o,r,s,a){const c=i.slice();if(a.eastMostYhighDefine===""){const u=YU;u.longitude=N.PI,u.latitude=0,u.height=0;const f=s.project(u,qU);let h=En.encode(f.x,XU);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 ) } ` ;const _=YU;_.longitude=-N.PI,_.latitude=0,_.height=0;const g=s.project(_,qU);h=En.encode(g.x,XU),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 hn&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new Ge({defines:c,sources:[o]})}function $ 1(){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( $ 1.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},
` ,r= ` extrudeDirection = czm _octDecode ( $ { n } , 65535.0 ) ;
` ;let s=t;s=s.replace(/attribute \s +vec3 \s +extrudeDirection;/g,""),s=Ge.replaceMain(s,"czm_non_compressed_main");const a= ` void main ( )
{
$ { r } czm _non _compressed _main ( ) ;
} ` ;return[i,o,s,a].join( `
` )}}function RPe(e,t){const n=t.context,i=e._primitive;let o=Wue;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=Gt._appendDistanceDisplayConditionToShader(i,o),o=Gt._modifyShaderPosition(e,o,t.scene3DOnly),o=Gt._updateColorAttribute(i,o);const r=e._hasPlanarExtentsAttributes,s=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=BPe(i,o));const a=e._extruded?"EXTRUDED_GEOMETRY":"";let c=new Ge({defines:[a],sources:[o]});const u=new Ge({sources:[r1]}),f=e._primitive._attributeLocations,h=new Xr(s,r,e.appearance);if(e._spStencil=un.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f}),e._primitive.allowPicking){let p=Ge.createPickVertexShaderSource(o);p=Gt._appendShowToShader(i,p),p=Gt._updatePickColorAttribute(p);const A=h.createPickFragmentShader(!1),C=h.createPickVertexShader([a],p,!1,t.mapProjection);if(e._spPick=un.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:C,fragmentShaderSource:A,attributeLocations:f}),s){let b=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!l(b)){const x=h.createPickFragmentShader(!0),w=h.createPickVertexShader([a],p,!0,t.mapProjection);b=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:w,fragmentShaderSource:x,attributeLocations:f})}e._spPick2D=b}}else e._spPick=un.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});o=Gt._appendShowToShader(i,o),c=new Ge({defines:[a],sources:[o]}),e._sp=un.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});const _=h.createFragmentShader(!1),g=h.createVertexShader([a],o,!1,t.mapProjection);if(e._spColor=un.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:g,fragmentShaderSource:_,attributeLocations:f}),s){let p=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!l(p)){const A=h.createFragmentShader(!0),C=h.createVertexShader([a],o,!0,t.mapProjection);p=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:C,fragmentShaderSource:A,attributeLocations:f})}e._spColor2D=p}}function NPe(e,t){const n=e._primitive;let i=n._va.length*2;t.length=i;let o,r,s,a=0,c=n._batchTable.getUniformMapCallback()(e._uniformMap);const u=e._needs2DShader;for(o=0;o<i;o+=2){const g=n._va[a++];r=t[o],l(r)||(r=t[o]=new ft({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsStencilDepthPass,r.shaderProgram=e._sp,r.uniformMap=c,r.pass=Be.TERRAIN_CLASSIFICATION,s=ft.shallowClone(r,r.derivedCommands.tileset),s.renderState=e._rsStencilDepthPass3DTiles,s.pass=Be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,r=t[o+1],l(r)||(r=t[o+1]=new ft({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsColorPass,r.shaderProgram=e._spColor,r.pass=Be.TERRAIN_CLASSIFICATION;const A=e.appearance.material;if(l(A)&&(c=nn(c,A._uniforms)),r.uniformMap=c,s=ft.shallowClone(r,r.derivedCommands.tileset),s.pass=Be.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,u){let C=ft.shallowClone(r,r.derivedCommands.appearance2D);C.shaderProgram=e._spColor2D,r.derivedCommands.appearance2D=C,C=ft.shallowClone(s,s.derivedCommands.appearance2D),C.shaderProgram=e._spColor2D,s.derivedCommands.appearance2D=C}}const f=e._commandsIgnoreShow,h=e._spStencil;let _=0;i=f.length=i/2;for(let g=0;g<i;++g){const p=f[g]=ft.shallowClone(t[_],f[g]);p.shaderProgram=h,p.pass=Be.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,_+=2}}function MPe(e,t){const n=e._usePickOffsets,i=e._primitive;let o=i._va.length*2,r,s=0,a;n&&(r=i._pickOffsets,o=r.length*2),t.length=o;let c,u,f,h=0;const _=i._batchTable.getUniformMapCallback()(e._uniformMap),g=e._needs2DShader;for(c=0;c<o;c+=2){let p=i._va[h++];if(n&&(a=r[s++],p=i._va[a.index]),u=t[c],l(u)||(u=t[c]=new ft({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),u.vertexArray=p,u.renderState=e._rsStencilDepthPass,u.shaderProgram=e._sp,u.uniformMap=_,u.pass=Be.TERRAIN_CLASSIFICATION,n&&(u.offset=a.offset,u.count=a.count),f=ft.shallowClone(u,u.derivedCommands
attribute vec3 position3DLow ;
attribute vec3 prevPosition3DHigh ;
attribute vec3 prevPosition3DLow ;
attribute vec3 nextPosition3DHigh ;
attribute vec3 nextPosition3DLow ;
attribute vec2 expandAndWidth ;
attribute vec4 color ;
attribute float batchId ;
varying vec4 v _color ;
void main ( )
{
float expandDir = expandAndWidth . x ;
float width = abs ( expandAndWidth . y ) + 0.5 ;
bool usePrev = expandAndWidth . y < 0.0 ;
vec4 p = czm _computePosition ( ) ;
vec4 prev = czm _computePrevPosition ( ) ;
vec4 next = czm _computeNextPosition ( ) ;
float angle ;
vec4 positionWC = getPolylineWindowCoordinates ( p , prev , next , expandDir , width , usePrev , angle ) ;
gl _Position = czm _viewportOrthographic * positionWC ;
v _color = color ;
}
` ;let Q1= ` $ { kC }
$ { FOe } ` ;const zOe=d9;an.isInternetExplorer()||(Q1= ` # define CLIP _POLYLINE
$ { Q1 } ` );function Ps(e){e=y(e,y.EMPTY_OBJECT);const t=y(e.translucent,!0),n=!1,i=Ps.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,Q1),this._fragmentShaderSource=y(e.fragmentShaderSource,zOe),this._renderState=ir.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Ps.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}}});Ps.VERTEX_FORMAT=Ne.POSITION_ONLY;Ps.prototype.getFragmentShaderSource=ir.prototype.getFragmentShaderSource;Ps.prototype.isTranslucent=ir.prototype.isTranslucent;Ps.prototype.getRenderState=ir.prototype.getRenderState;const UOe= ` attribute vec3 position3DHigh ;
attribute vec3 position3DLow ;
attribute vec3 prevPosition3DHigh ;
attribute vec3 prevPosition3DLow ;
attribute vec3 nextPosition3DHigh ;
attribute vec3 nextPosition3DLow ;
attribute vec2 expandAndWidth ;
attribute vec2 st ;
attribute float batchId ;
varying float v _width ;
varying vec2 v _st ;
varying float v _polylineAngle ;
void main ( )
{
float expandDir = expandAndWidth . x ;
float width = abs ( expandAndWidth . y ) + 0.5 ;
bool usePrev = expandAndWidth . y < 0.0 ;
vec4 p = czm _computePosition ( ) ;
vec4 prev = czm _computePrevPosition ( ) ;
vec4 next = czm _computeNextPosition ( ) ;
float angle ;
vec4 positionWC = getPolylineWindowCoordinates ( p , prev , next , expandDir , width , usePrev , angle ) ;
gl _Position = czm _viewportOrthographic * positionWC ;
v _width = width ;
v _st . s = st . s ;
v _st . t = czm _writeNonPerspective ( st . t , gl _Position . w ) ;
v _polylineAngle = angle ;
}
` ;let Z1= ` $ { kC }
$ { UOe } ` ;const HOe=u6;an.isInternetExplorer()||(Z1= ` # define CLIP _POLYLINE
$ { Z1 } ` );function os(e){e=y(e,y.EMPTY_OBJECT);const t=y(e.translucent,!0),n=!1,i=os.VERTEX_FORMAT;this.material=l(e.material)?e.material:Fe.fromType(Fe.ColorType),this.translucent=t,this._vertexShaderSource=y(e.vertexShaderSource,Z1),this._fragmentShaderSource=y(e.fragmentShaderSource,HOe),this._renderState=ir.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(os.prototype,{vertexShaderSource:{get:function(){let e=this._vertexShaderSource;return this.material.shaderSource.search(/varying \s +float \s +v_polylineAngle;/g)!==-1&&(e= ` # define POLYLINE _DASH
$ { e } ` ),e}},fragmentShaderSource:{get:function(){return this._fragmentShaderSource}},renderState:{get:function(){return this._renderState}},closed:{get:function(){return this._closed}},vertexFormat:{get:function(){return this._vertexFormat}}});os.VERTEX_FORMAT=Ne.POSITION_AND_ST;os.prototype.getFragmentShaderSource=ir.prototype.getFragmentShaderSource;os.prototype.isTranslucent=ir.prototype.isTranslucent;os.prototype.getRenderState=ir.prototype.getRenderState;function kc(e){e=y(e,y.EMPTY_OBJECT),this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;l(t)||(t=new os),this.appearance=t,this.show=y(e.show,!0),this.classificationType=y(e.classificationType,co.BOTH),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this._debugShowShadowVolume=y(e.debugShowShadowVolume,!1),this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:!1,interleave:y(e.interleave,!1),releaseGeometryInstances:y(e.releaseGeometryInstances,!0),allowPicking:y(e.allowPicking,!0),asynchronous:y(e.asynchronous,!0),compressVertices:!1,_createShaderProgramFunction:void 0,_createCommandsFunction:void 0,_updateAndQueueCommandsFunction:void 0},this._zIndex=void 0,this._ready=!1;const n=this;this._readyPromise=new Promise((i,o)=>{n._completeLoad=()=>{this._ready=!0,this.releaseGeometryInstances&&(this.geometryInstances=void 0);const r=this._error;l(r)?o(r):i(this)}}),this._primitive=void 0,this._sp=void 0,this._sp2D=void 0,this._spMorph=void 0,this._renderState=xH(!1),this._renderState3DTiles=xH(!0),this._renderStateMorph=Qe.fromCache({cull:{enabled:!0,face:Eo.FRONT},depthTest:{enabled:!0},blending:Si.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(kc.prototype,{interleave:{get:function(){return this._primitiveOptions.interleave}},releaseGeometryInstances:{get:function(){return this._primitiveOptions.releaseGeometryInstances}},allowPicking:{get:function(){return this._primitiveOptions.allowPicking}},asynchronous:{get:function(){return this._primitiveOptions.asynchronous}},ready:{get:function(){return this._ready}},readyPromise:{get:function(){return this._readyPromise}},debugShowShadowVolume:{get:function(){return this._debugShowShadowVolume}}});kc.initializeTerrainHeights=function(){return qi.initialize()};function VOe(e,t,n){const i=t.context,o=e._primitive,r=o._attributeLocations;let s=o._batchTable.getVertexShaderCallback()(Hue);s=Gt._appendShowToShader(o,s),s=Gt._appendDistanceDisplayConditionToShader(o,s),s=Gt._modifyShaderPosition(e,s,t.scene3DOnly);let a=o._batchTable.getVertexShaderCallback()(Uue);a=Gt._appendShowToShader(o,a),a=Gt._appendDistanceDisplayConditionToShader(o,a),a=Gt._modifyShaderPosition(e,a,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(Fue);const u=[ ` GLOBE _MINIMUM _ALTITUDE $ { t . mapProjection . ellipsoid . minimumRadius . toFixed ( 1 ) } ` ];let f="",h="";l(n.material)?(h=l(n.material)?n.material.shaderSource:"",h.search(/varying \s +float \s +v_polylineAngle;/g)!==-1&&u.push("ANGLE_VARYING"),h.search(/varying \s +float \s +v_width;/g)!==-1&&u.push("WIDTH_VARYING")):f="PER_INSTANCE_COLOR",u.push(f);const _=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",f]:[f],g=new Ge({defines:u,sources:[s]}),p=new Ge({defines:_,sources:[h,c]});e._sp=un.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:g,fragmentShaderSource:p,attributeLocations:r});let A=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!l(A)){const b=new Ge({defines:u.concat(["COLUMBUS_VIEW_2D"]),sources:[s]});A=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:b,fragmentShaderSource:p,attributeLocations:r})}e._sp2D=A;let C=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!l(C)){const b=new Ge({defines:u.concat([ ` MAX _TERRAIN _HEIGHT $ { qi . _defaultMaxTerrainHeight . toFixed ( 1 ) } ` ]),sources:[a]});c=o._batchTable.getVertexShaderCallback()(zue);const x=new Ge({defines:_,sources:[h,c]});C=i.shaderCache.createDerivedShaderProgram(e._sp,"MorphColor",{context:i,shaderProgram:e._spMorph,vertexShaderSource:b,fragmentShaderSo
vec2 computeSt ( float batchId )
{
float stepX = tile _textureStep . x ;
float centerX = tile _textureStep . y ;
return vec2 ( centerX + ( batchId * stepX ) , 0.5 ) ;
}
` : ` uniform vec4 tile _textureStep ;
uniform vec2 tile _textureDimensions ;
vec2 computeSt ( float batchId )
{
float stepX = tile _textureStep . x ;
float centerX = tile _textureStep . y ;
float stepY = tile _textureStep . z ;
float centerY = tile _textureStep . w ;
float xId = mod ( batchId , tile _textureDimensions . x ) ;
float yId = floor ( batchId / tile _textureDimensions . x ) ;
return vec2 ( centerX + ( xId * stepX ) , centerY + ( yId * stepY ) ) ;
}
` }pi.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;const i=this;return function(o){const r=Mq(o,n,!1);let s;return xt.maximumVertexTextureImageUnits>0?(s="",e&&(s+= ` uniform bool tile _translucentCommand ;
` ),s+= ` uniform sampler2D tile _batchTexture ;
varying vec4 tile _featureColor ;
varying vec2 tile _featureSt ;
void main ( )
{
vec2 st = computeSt ( $ { t } ) ;
vec4 featureProperties = texture2D ( tile _batchTexture , st ) ;
tile _color ( featureProperties ) ;
float show = ceil ( featureProperties . a ) ;
gl _Position *= show ;
` ,e&&(s+= ` bool isStyleTranslucent = ( featureProperties . a != 1.0 ) ;
if ( czm _pass == czm _passTranslucent )
{
if ( ! isStyleTranslucent && ! tile _translucentCommand )
{
gl _Position *= 0.0 ;
}
}
else
{
if ( isStyleTranslucent )
{
gl _Position *= 0.0 ;
}
}
` ),s+= ` tile _featureColor = featureProperties ;
tile _featureSt = st ;
} ` ):s= ` varying vec2 tile _featureSt ;
void main ( )
{
tile _color ( vec4 ( 1.0 ) ) ;
tile _featureSt = computeSt ( $ { t } ) ;
} ` , ` $ { r }
$ { q1e ( i ) } $ { s } ` }};function SH(e,t){return e=Ge.replaceMain(e,"tile_main"),t? ` $ { e } uniform float tile _colorBlend ;
void tile _color ( vec4 tile _featureColor )
{
tile _main ( ) ;
tile _featureColor = czm _gammaCorrect ( tile _featureColor ) ;
gl _FragColor . a *= tile _featureColor . a ;
float highlight = ceil ( tile _colorBlend ) ;
gl _FragColor . rgb *= mix ( tile _featureColor . rgb , vec3 ( 1.0 ) , highlight ) ;
}
` : ` $ { e } void tile _color ( vec4 tile _featureColor )
{
tile _main ( ) ;
}
` }function Y1e(e,t){const n= ` texture2D ( $ { t } ` ;let i=0,o=e.indexOf(n,i),r;for(;o>-1;){let s=0;for(let u=o;u<e.length;++u){const f=e.charAt(u);if(f==="(")++s;else if(f===")"&&(--s,s===0)){r=u+1;break}}const 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 Mq(e,t,n){if(!l(t))return SH(e,n);let i=new RegExp( ` ( uniform | attribute | in ) \ \ s + ( vec [ 34 ] | sampler2D ) \ \ s + $ { t } ; ` );const o=e.match(i);if(!l(o))return SH(e,n);const r=o[0],s=o[2];e=Ge.replaceMain(e,"tile_main"),e=e.replace(r,"");const a= ` bool isWhite ( vec3 color )
{
return all ( greaterThan ( color , vec3 ( 1.0 - czm _epsilon3 ) ) ) ;
}
vec4 tile _diffuse _final ( vec4 sourceDiffuse , vec4 tileDiffuse )
{
vec4 blendDiffuse = mix ( sourceDiffuse , tileDiffuse , tile _colorBlend ) ;
vec4 diffuse = isWhite ( tileDiffuse . rgb ) ? sourceDiffuse : blendDiffuse ;
return vec4 ( diffuse . rgb , sourceDiffuse . a ) ;
}
` ,c= ` tile _featureColor = czm _gammaCorrect ( tile _featureColor ) ;
gl _FragColor . a *= tile _featureColor . a ;
float highlight = ceil ( tile _colorBlend ) ;
gl _FragColor . rgb *= mix ( tile _featureColor . rgb , vec3 ( 1.0 ) , highlight ) ;
` ;let u;if(s==="vec3"||s==="vec4"){const f=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),u= ` vec4 source = $ { f } ;
tile _diffuse = tile _diffuse _final ( source , tile _featureColor ) ;
tile _main ( ) ;
` }else s==="sampler2D"&&(e=Y1e(e,t),u= ` tile _diffuse = tile _featureColor ;
tile _main ( ) ;
` );return e= ` uniform float tile _colorBlend ;
vec4 tile _diffuse = vec4 ( 1.0 ) ;
$ { a } $ { r }
$ { e }
void tile _color ( vec4 tile _featureColor )
{
$ { u } ` ,n&&(e+=c),e+= ` }
` ,e}pi.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=Mq(i,t,!0),xt.maximumVertexTextureImageUnits>0?(i+= ` uniform sampler2D tile _pickTexture ;
varying vec2 tile _featureSt ;
varying vec4 tile _featureColor ;
void main ( )
{
tile _color ( tile _featureColor ) ;
` ,n&&(i+= ` gl _FragColor . rgb *= gl _FragColor . a ;
` ),i+="}"):(e&&(i+= ` uniform bool tile _translucentCommand ;
` ),i+= ` uniform sampler2D tile _pickTexture ;
uniform sampler2D tile _batchTexture ;
varying vec2 tile _featureSt ;
void main ( )
{
vec4 featureProperties = texture2D ( tile _batchTexture , tile _featureSt ) ;
if ( featureProperties . a == 0.0 ) {
discard ;
}
` ,e&&(i+= ` bool isStyleTranslucent = ( featureProperties . a != 1.0 ) ;
if ( czm _pass == czm _passTranslucent )
{
if ( ! isStyleTranslucent && ! tile _translucentCommand )
{
discard ;
}
}
else
{
if ( isStyleTranslucent )
{
discard ;
}
}
` ),i+= ` tile _color ( featureProperties ) ;
` ,n&&(i+= ` gl _FragColor . rgb *= gl _FragColor . a ;
` ),i+= ` }
` ),i}};pi.prototype.getClassificationFragmentShaderCallback=function(){if(this.featuresLength!==0)return function(e){return e=Ge.replaceMain(e,"tile_main"),xt.maximumVertexTextureImageUnits>0?e+= ` uniform sampler2D tile _pickTexture ;
varying vec2 tile _featureSt ;
varying vec4 tile _featureColor ;
void main ( )
{
tile _main ( ) ;
gl _FragColor = tile _featureColor ;
gl _FragColor . rgb *= gl _FragColor . a ;
} ` :e+= ` uniform sampler2D tile _batchTexture ;
uniform sampler2D tile _pickTexture ;
varying vec2 tile _featureSt ;
void main ( )
{
tile _main ( ) ;
vec4 featureProperties = texture2D ( tile _batchTexture , tile _featureSt ) ;
if ( featureProperties . a == 0.0 ) {
discard ;
}
gl _FragColor = featureProperties ;
gl _FragColor . rgb *= gl _FragColor . a ;
}
` ,e}};function X1e(e){const t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n===wx.HIGHLIGHT)return 0;if(n===wx.REPLACE)return 1;if(n===wx.MIX)return N.clamp(i,N.EPSILON4,1);throw new E( ` Invalid color blend mode "${n}" . ` )}pi.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;const e=this;return function(t){return nn(t,{tile_batchTexture:function(){return y(e._batchTexture.batchTexture,e._batchTexture.defaultTexture)},tile_textureDimensions:function(){return e._batchTexture.textureDimensions},tile_textureStep:function(){return e._batchTexture.textureStep},tile_colorBlend:function(){return X1e(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};pi.prototype.getPickId=function(){return"texture2D(tile_pickTexture, tile_featureSt)"};const ch={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};pi.prototype.addDerivedCommands=function(e,t){const n=e.commandList,i=n.length,o=this._content._tile,r=o._finalResolution,s=o.tileset,a=s._skipLevelOfDetail&&s._hasMixedContent&&e.context.stencilBuffer,c= $ 1e(this);for(let u=t;u<i;++u){const f=n[u];if(f.pass===Be.COMPUTE)continue;let h=f.derivedCommands.tileset;(!l(h)||f.dirty)&&(h={},f.derivedCommands.tileset=h,h.originalCommand=K1e(f),f.dirty=!1);const _=h.originalCommand;c!==ch.ALL_OPAQUE&&f.pass!==Be.TRANSLUCENT&&(l(h.translucent)||(h.translucent=J1e(_))),c!==ch.ALL_TRANSLUCENT&&f.pass!==Be.TRANSLUCENT&&(l(h.opaque)||(h.opaque=Q1e(_)),a&&(r||(l(h.zback)||(h.zback=eLe(e.context,_)),s._backfaceCommands.push(h.zback)),(!l(h.stencil)||o._selectionDepth!==nLe(h.stencil))&&(f.renderState.depthMask?h.stencil=tLe(_,o._selectionDepth):h.stencil=h.opaque)));const g=a?h.stencil:h.opaque,p=h.translucent;f.pass!==Be.TRANSLUCENT?(c===ch.ALL_OPAQUE&&(n[u]=g),c===ch.ALL_TRANSLUCENT&&(n[u]=p),c===ch.OPAQUE_AND_TRANSLUCENT&&(n[u]=g,n.push(p))):n[u]=_}};function $ 1e(e){const t=e._batchTexture.translucentFeaturesLength;return t===0?ch.ALL_OPAQUE:t===e.featuresLength?ch.ALL_TRANSLUCENT:ch.OPAQUE_AND_TRANSLUCENT}function K1e(e){const t=ft.shallowClone(e),n=t.pass===Be.TRANSLUCENT;return t.uniformMap=l(t.uniformMap)?t.uniformMap:{},t.uniformMap.tile_translucentCommand=function(){return n},t}function J1e(e){const t=ft.shallowClone(e);return t.pass=Be.TRANSLUCENT,t.renderState=iLe(e.renderState),t}function Q1e(e){const t=ft.shallowClone(e);return t.renderState=oLe(e.renderState),t}function Z1e(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"zBackfaceLogDepth");if(!l(n)){const i=t.fragmentShaderSource.clone();i.defines=l(i.defines)?i.defines.slice(0):[],i.defines.push("POLYGON_OFFSET"),i.sources.unshift( ` # ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
` ),n=e.shaderCache.createDerivedShaderProgram(t,"zBackfaceLogDepth",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}return n}function eLe(e,t){const n=ft.shallowClone(t),i=lt(n.renderState,!0);i.cull.enabled=!0,i.cull.face=Eo.FRONT,i.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i.polygonOffset={enabled:!0,factor:5,units:5},i.stencilTest=It.setCesium3DTileBit(),i.stencilMask=It.CESIUM_3D_TILE_MASK,n.renderState=Qe.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=lt(t.uniformMap);const o=new j(5,5);return n.uniformMap.u_polygonOffset=function(){return o},n.shaderProgram=Z1e(e,t.shaderProgram),n}function tLe(e,t){const n=ft.shallowClone(e),i=lt(n.renderState,!0);return i.stencilTest.enabled=!0,i.stencilTest.mask=It.SKIP_LOD_MASK,i.stencilTest.reference=It.CESIUM_3D_TILE_MASK|t<<It.SKIP_LOD_BIT_SHIFT,i.stencilTest.frontFunction=ii.GREATER_OR_EQUAL,i.stencilTest.frontOperation.zPass=dt.REPLACE,i.stencilTest.backFunction=ii.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=dt.REPLACE,i.stencilMask=It.CESIUM_3D_TILE_MASK|It.SKIP_LOD_MASK,n.renderState=Qe.fromCache(i),n}function nLe(e){return(e.renderState.stencilTest.reference&It.SKIP_LOD_MASK)>>>It.SKIP_LOD_BIT_SHIFT}function iLe(e){const t=lt(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=Si.ALPHA_BLEND,t.stencilTest=It.setCesium3DTileBit(),t.stencilMask=It.CESIUM_3D_TILE_MASK,Qe.fromCache(t)}function oLe(e){const t=lt(e,!0);return t.stencilTest=It.setCesium3DTileBit(),t.stencilMask=It.CESIUM_3D_TILE_MASK,Qe.fromCache(t)}pi.prototype.update=function(e,t){this._batchTexture.update(e,t)};pi.prototype.isDestroyed=function(){return!1};pi.prototype.destroy=function(){return this._batchTexture=this._batchTexture&&this._batchTexture.destroy(),Ue(this)};function Cw(e){this.offset=e.offset,this.count=e.count,this.color=e.color,this.batchIds=e.batchIds}class rLe{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)})}}class sLe{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)})}}class He{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+He.version}static addUnaryOp(t){return He.max_unop_len=Math.max(t.length,He.max_unop_len),He.unary_ops[t]=1,He}static addBinaryOp(t,n,i){return He.max_binop_len=Math.max(t.length,He.max_binop_len),He.binary_ops[t]=n,i?He.right_associative.add(t):He.right_associative.delete(t),He}static addIdentifierChar(t){return He.additional_identifier_chars.add(t),He}static addLiteral(t,n){return He.literals[t]=n,He}static removeUnaryOp(t){return delete He.unary_ops[t],t.length===He.max_unop_len&&(He.max_unop_len=He.getMaxKeyLen(He.unary_ops)),He}static removeAllUnaryOps(){return He.unary_ops={},He.max_unop_len=0,He}static removeIdentifierChar(t){return He.additional_identifier_chars.delete(t),He}static removeBinaryOp(t){return delete He.binary_ops[t],t.length===He.max_binop_len&&(He.max_binop_len=He.getMaxKeyLen(He.binary_ops)),He.right_associative.delete(t),He}static removeAllBinaryOps(){return He.binary_ops={},He.max_binop_len=0,He}static removeLiteral(t){return delete He.literals[t],He}static removeAllLiterals(){return He.literals={},He}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new He(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(n=>n.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return He.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!He.binary_ops[Strin
` ;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:He.LITERAL,value:t,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let t=this.code,n=this.index;for(He.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,He.isIdentifierPart(t));)this.index++;return{type:He.IDENTIFIER,name:this.expr.slice(n,this.index)}}gobbleArguments(t){const n=[];let i=!1,o=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let r=this.code;if(r===t){i=!0,this.index++,t===He.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(r===He.COMMA_CODE){if(this.index++,o++,o!==n.length){if(t===He.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===He.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{const s=this.gobbleExpression();(!s||s.type===He.COMPOUND)&&this.throwError("Expected comma"),n.push(s)}}return i||this.throwError("Expected "+String.fromCharCode(t)),n}gobbleGroup(){this.index++;let t=this.gobbleExpressions(He.CPAREN_CODE);if(this.code===He.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:He.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:He.ARRAY_EXP,elements:this.gobbleArguments(He.CBRACK_CODE)}}}const aLe=new rLe;Object.assign(He,{hooks:aLe,plugins:new sLe(He),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"});He.max_unop_len=He.getMaxKeyLen(He.unary_ops);He.max_binop_len=He.getMaxKeyLen(He.binary_ops);const ym=e=>new He(e).parse(),cLe=Object.getOwnPropertyNames(He);cLe.forEach(e=>{ym[e]===void 0&&e!=="prototype"&&(ym[e]=He[e])});ym.Jsep=He;const lLe="ConditionalExpression";var uLe={name:"ternary",init(e){e.hooks.add("after-expression",function(n){if(n.node&&this.code===e.QUMARK_CODE){this.index++;const i=n.node,o=this.gobbleExpression();if(o||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;const r=this.gobbleExpression();if(r||this.throwError("Expected expression"),n.node={type:lLe,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 :")}})}};ym.plugins.register(uLe);const fLe={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},st=Object.freeze(fLe);function Ml(e,t){T.typeOf.string("expression",e),this._expression=e,e=xLe(e,t),e=SLe(wLe(e)),ym.addBinaryOp("=~",0),ym.addBinaryOp("!~",0);let n;try{n=ym(e)}catch(i){throw new Se(i)}this._runtimeAst=Vn(this,n)}Object.defineProperties(Ml.prototype,{expression:{get:function(){return this._expression}}});const $ t={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new j],cartesian3Array:[new d],cartesian4Array:[new oe],reset:function(){this.arrayIndex=0
{
return $ { o } ;
}
` ,o};Ml.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};Ml.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};const dLe=["!","-","+"],vH=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],Tw=/ \$ {(.*?)}/g,hLe=/ \\ /g,pLe="@#%",mLe=/@#%/g,YS=new F,XS={abs:Tr(Math.abs),sqrt:Tr(Math.sqrt),cos:Tr(Math.cos),sin:Tr(Math.sin),tan:Tr(Math.tan),acos:Tr(Math.acos),asin:Tr(Math.asin),atan:Tr(Math.atan),radians:Tr(N.toRadians),degrees:Tr(N.toDegrees),sign:Tr(N.sign),floor:Tr(Math.floor),ceil:Tr(Math.ceil),round:Tr(Math.round),exp:Tr(Math.exp),exp2:Tr(gLe),log:Tr(Math.log),log2:Tr(yLe),fract:Tr(_Le),length:ALe,normalize:CLe}, $ S={atan2:oE(Math.atan2,!1),pow:oE(Math.pow,!1),min:oE(Math.min,!0),max:oE(Math.max,!0),distance:TLe,dot:bLe,cross:ELe},tN={clamp:DH(N.clamp,!0),mix:DH(N.lerp,!0)};function _Le(e){return e-Math.floor(e)}function gLe(e){return Math.pow(2,e)}function yLe(e){return N.log2(e)}function Tr(e){return function(t,n){if(typeof n=="number")return e(n);if(n instanceof j)return j.fromElements(e(n.x),e(n.y), $ t.getCartesian2());if(n instanceof d)return d.fromElements(e(n.x),e(n.y),e(n.z), $ t.getCartesian3());if(n instanceof oe)return oe.fromElements(e(n.x),e(n.y),e(n.z),e(n.w), $ t.getCartesian4());throw new Se( ` Function "${t}" requires a vector or number argument . Argument is $ { n } . ` )}}function oE(e,t){return function(n,i,o){if(t&&typeof o=="number"){if(typeof i=="number")return e(i,o);if(i instanceof j)return j.fromElements(e(i.x,o),e(i.y,o), $ t.getCartesian2());if(i instanceof d)return d.fromElements(e(i.x,o),e(i.y,o),e(i.z,o), $ t.getCartesian3());if(i instanceof oe)return oe.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),e(i.w,o), $ t.getCartesian4())}if(typeof i=="number"&&typeof o=="number")return e(i,o);if(i instanceof j&&o instanceof j)return j.fromElements(e(i.x,o.x),e(i.y,o.y), $ t.getCartesian2());if(i instanceof d&&o instanceof d)return d.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z), $ t.getCartesian3());if(i instanceof oe&&o instanceof oe)return oe.fromElements(e(i.x,o.x),e(i.y,o.y),e(i.z,o.z),e(i.w,o.w), $ t.getCartesian4());throw new Se( ` Function "${n}" requires vector or number arguments of matching types . Arguments are $ { i } and $ { o } . ` )}}function DH(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 j&&o instanceof j)return j.fromElements(e(i.x,o.x,r),e(i.y,o.y,r), $ t.getCartesian2());if(i instanceof d&&o instanceof d)return d.fromElements(e(i.x,o.x,r),e(i.y,o.y,r),e(i.z,o.z,r), $ t.getCartesian3());if(i instanceof oe&&o instanceof oe)return oe.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), $ t.getCartesian4())}if(typeof i=="number"&&typeof o=="number"&&typeof r=="number")return e(i,o,r);if(i instanceof j&&o instanceof j&&r instanceof j)return j.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y), $ t.getCartesian2());if(i instanceof d&&o instanceof d&&r instanceof d)return d.fromElements(e(i.x,o.x,r.x),e(i.y,o.y,r.y),e(i.z,o.z,r.z), $ t.getCartesian3());if(i instanceof oe&&o instanceof oe&&r instanceof oe)return oe.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), $ t.getCartesian4());throw new Se( ` Function "${n}" requires vector or number arguments of matching types . Arguments are $ { i } , $ { o } , and $ { r } . ` )}}function ALe(e,t){if(typeof t=="number")return Math.abs(t);if(t instanceof j)return j.magnitude(t);if(t instanceof d)return d.magnitude(t);if(t instanceof oe)return oe.magnitude(t);throw new Se( ` Function "${e}" requires a vector or number argument . Argument is $ { t } . ` )}function CLe(e,t){if(typeof t=="number")return 1;if(t instanceof j)return j.normalize(t, $ t.getCartesian2());if(t instanceof d)return d.normalize(t, $ t.getCartesian3());if(t instanceof oe)return oe.normalize(t, $ t.getCartesian4());throw new Se( ` Function "${e}" requires a vector or number argument . Argument is $ { t } . ` )}function TLe(e,t,n){if(typeof t=="number"&&typeof n=="number")return Math.abs(t-n);if(t instanceof j&&
{
czm _non _pick _main ( ) ;
gl _FragColor = $ { o } ;
}
` ,e._spPick=un.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:i});return}const a=n.getVertexShaderCallback(!1,"a_batchId",void 0)(D2);let c=n.getFragmentShaderCallback(!1,void 0,!0)(r1);o=n.getPickId();let u=new Ge({sources:[a]}),f=new Ge({defines:["VECTOR_TILE"],sources:[c]});e._sp=un.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),u=new Ge({sources:[D2]}),f=new Ge({defines:["VECTOR_TILE"],sources:[r1]}),e._spStencil=un.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),c=Ge.replaceMain(c,"czm_non_pick_main"),c= ` $ { c }
void main ( )
{
czm _non _pick _main ( ) ;
gl _FragColor = $ { o } ;
}
` ;const h=new Ge({sources:[a]}),_=new Ge({defines:["VECTOR_TILE"],sources:[c]});e._spPick=un.fromCache({context:t,vertexShaderSource:h,fragmentShaderSource:_,attributeLocations:i})}function BH(e){const t=e?ii.EQUAL:ii.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:t,frontOperation:{fail:dt.KEEP,zFail:dt.DECREMENT_WRAP,zPass:dt.KEEP},backFunction:t,backOperation:{fail:dt.KEEP,zFail:dt.INCREMENT_WRAP,zPass:dt.KEEP},reference:It.CESIUM_3D_TILE_MASK,mask:It.CESIUM_3D_TILE_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Sm.LESS_OR_EQUAL},depthMask:!1}}const jLe={stencilTest:{enabled:!0,frontFunction:ii.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:ii.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:It.CLASSIFICATION_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:Si.PRE_MULTIPLIED_ALPHA_BLEND},qLe={stencilTest:{enabled:!0,frontFunction:ii.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:ii.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:It.CLASSIFICATION_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function YLe(e){l(e._rsStencilDepthPass)||(e._rsStencilDepthPass=Qe.fromCache(BH(!1)),e._rsStencilDepthPass3DTiles=Qe.fromCache(BH(!0)),e._rsColorPass=Qe.fromCache(jLe),e._rsPickPass=Qe.fromCache(qLe))}const Pp=new B,RH=new d;function XLe(e,t){if(l(e._uniformMap))return;const n={u_modifiedModelViewProjection:function(){const i=t.uniformState.view,o=t.uniformState.projection;return B.clone(i,Pp),B.multiplyByPoint(Pp,e._center,RH),B.setTranslation(Pp,RH,Pp),B.multiply(o,Pp,Pp),Pp},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function QI(e,t,n,i,o,r,s){const a=e.constructor.BYTES_PER_ELEMENT,c=r.length;for(let u=0;u<c;++u){const f=r[u],h=s[f],_=i[h],g=o[h],p=new e.constructor(e.buffer,a*_,g);t.set(p,n),i[h]=n,n+=g}return n}function $ Le(e,t){const n=e._indices,i=e._indexOffsets,o=e._indexCounts,r=e._batchIdLookUp,s=new n.constructor(n.length);let a=t.pop();const c=[a];let u=QI(n,s,0,i,o,a.batchIds,r);for(a.offset=0,a.count=u;t.length>0;){const f=t.pop();if(F.equals(f.color,a.color))u=QI(n,s,u,i,o,f.batchIds,r),a.batchIds=a.batchIds.concat(f.batchIds),a.count=u-a.offset;else{const h=u;u=QI(n,s,u,i,o,f.batchIds,r),f.offset=h,f.count=u-h,c.push(f),a=f}}e._va.indexBuffer.copyFromArrayView(s),e._indices=s,e._batchedIndices=c}function ZI(e,t,n,i,o,r,s){const a=e.bytesPerIndex,c=r.length;for(let u=0;u<c;++u){const f=r[u],h=s[f],_=i[h],g=o[h];t.copyFromBuffer(e,_*a,n*a,g*a),i[h]=n,n+=g}return n}function KLe(e,t){const n=e._indexOffsets,i=e._indexCounts,o=e._batchIdLookUp;let r=t.pop();const s=[r],a=e._va.indexBuffer,c=e._vaSwap.indexBuffer;let u=ZI(a,c,0,n,i,r.batchIds,o);for(r.offset=0,r.count=u;t.length>0;){const h=t.pop();if(F.equals(h.color,r.color))u=ZI(a,c,u,n,i,h.batchIds,o),r.batchIds=r.batchIds.concat(h.batchIds),r.count=u-r.offset;else{const _=u;u=ZI(a,c,u,n,i,h.batchIds,o),h.offset=_,h.count=u-_,s.push(h),r=h}}const f=e._va;e._va=e._vaSwap,e._vaSwap=f,e._batchedIndices=s}function JLe(e,t){return t.color.toRgba()-e.color.toRgba()}function QLe(e,t){if(!e._batchDirty)return!1;const n=e._batchedIndices,i=n.length;let o=!1;const r={};for(let s=0;s<i;++s){const 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(JLe),t.webgl2?KLe(e,n): $ Le(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function ZLe(e,t){const n=QLe(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;const a=e._va,c=e._sp,u=y(e._modelMatrix,B.IDENTITY),f=e._uniformMap,h=e._boundingVolume;for(let _=0;_<r;++_){const g=o[_].offset,p=o[_].count;let A=i[_*2];l(A)||(A=i[_*2]=new ft({owner:e})),A.vertexArr
$ { t . message } ` );const n=new Se(e);return l(t)&&(n.stack= ` Original stack :
$ { t . stack }
Handler stack :
$ { n . stack } ` ),n};Ko.prototype.isDestroyed=function(){return!1};Ko.prototype.destroy=function(){return this.unload(),Ue(this)};const iRe={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,FAILED:4},Ot=Object.freeze(iRe);function Sl(e){e=y(e,y.EMPTY_OBJECT);const t=e.typedArray,n=e.resource,i=e.cacheKey;if(l(t)===l(n))throw new E("One of options.typedArray and options.resource must be defined.");this._typedArray=t,this._resource=n,this._cacheKey=i,this._state=Ot.UNLOADED,this._promise=void 0}l(Object.create)&&(Sl.prototype=Object.create(Ko.prototype),Sl.prototype.constructor=Sl);Object.defineProperties(Sl.prototype,{promise:{get:function(){return this._promise}},cacheKey:{get:function(){return this._cacheKey}},typedArray:{get:function(){return this._typedArray}}});Sl.prototype.load=function(){return l(this._typedArray)?this._promise=Promise.resolve(this):this._promise=oRe(this),this._promise};function oRe(e){const t=e._resource;return e._state=Ot.LOADING,Sl._fetchArrayBuffer(t).then(function(n){if(!e.isDestroyed())return e._typedArray=new Uint8Array(n),e._state=Ot.READY,e}).catch(function(n){if(e.isDestroyed())return;e._state=Ot.FAILED;const i= ` Failed to load external buffer : $ { t . url } ` ;return Promise.reject(e.getError(i,n))})}Sl._fetchArrayBuffer=function(e){return e.fetchArrayBuffer()};Sl.prototype.unload=function(){this._typedArray=void 0};(function(){var e="B9h79tEBBBENQ9gEUEU9gEUB9gBB9gVUUUUUEU9gDUUEU9gLUUUUEU9gVUUUUUB9gLUUUUB9gIUUUEU9gD99UE99I8ayDILEVLEVLOOOOORRVBWWBEdddLVE9wEIIVIEBEOWEUEC+g/KEKR/QIhO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwvBE8f9tw79o9v9wT9fw9u9j9v9kw9WwvTw949C919m9mwv9C9v919u9kBDe9tw79o9v9wT9fw9u9j9v9kw9WwvTw949Wwv79p9v9uBIy9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwvBL8e9tw79o9v9wT9fw9u9j9v9kw69u9kw949C919m9mwv9C9v919u9kBV8a9tw79o9v9wT9fw9u9j9v9kw69u9kw949Wwv79p9v9uBOe9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jwBRA9tw79o9v9wT9fw9u9j9v9kw69u9kw949Twg91w9u9jw9C9v919u9kBWl9tw79o9v9wT9fw9u9j9v9kws9p2Twv9P9jTBdk9tw79o9v9wT9fw9u9j9v9kws9p2Twv9R919hTBQl9tw79o9v9wT9fw9u9j9v9kws9p2Twvt949wBKe9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9owBpA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94j9h9j9ow9TTv9p9wBSA9tw79o9v9wT9f9v9wT9p9t9p96w9WwvTw94swT9j9o9Sw9t9h9wBZL79iv9rBhdWEBCEKDxcQ+1tyDBK/hKEyU8jJJJJBCJO9rGV8kJJJJBCBHODNALCEFAE0MBABCBrB+Q+KJJBC+gEv86BBAVCJDFCBCJDZ+TJJJB8aDNAItMBAVCJDFADALZmJJJB8aKABAEFHRABCEFHWAVALFCBCBCJDAL9rALCfE0eZ+TJJJB8aAVAVCJDFALZmJJJBHdCJ/ABAL9uHEDNDNALtMBAEC/wfBgGECJDAECJD6eHQCBHKINAKAI9PMEAdCJLFCBCJDZ+TJJJB8aAQAIAK9rAKAQFAI6eGXCSFGECL4CIFCD4HMADAKAL2FHpDNDNDNDNDNAEC9wgGStMBCBHZCEHhApHoAWHaXEKDNAXtMBCBHaCEHhApHcINAdAaFrBBHxAcHECBHOINAdCJLFAOFAErBBGqAx9rGxCETAxCkTCk91CR4786BBAEALFHEAqHxAOCEFGOAX9HMBKARAW9rAM6MIAWCBAMZ+TJJJBGEtMIAEAMFHWAcCEFHcAaCEFGaAL6HhAaAL9HMBXVKKARAW9rAM6MOAWCBAMZ+TJJJB8aCEHEINAWGxAMFHWALAEGOsMLDNARAW9rAM6MBAOCEFHEAWCBAMZ+TJJJB8aAxMEKKCBHWAOAL6MOXIKINDNAXtMBAdAZFrBBHxCBHEAoHOINAdCJLFAEFAOrBBGqAx9rGxCETAxCkTCk91CR4786BBAOALFHOAqHxAECEFGEAX9HMBKKARAa9rAM6MEARAaCBAMZ+TJJJBGlAMFGW9rCk6MDCBHkAdCJLFHcINAdCJLFAkFHyCWH8aCZHaCEHqINDNDNAqCE9HMBCUHOAyrBBMECBHODNINAOGECSsMEAECEFHOAcAEFCEFrBBtMBKKCUCBAECS6eHOXEKAqCETC/+fffEgHOCUAqTCU7CfEgHxCBHEINAOAxAcAEFrBB9NFHOAECEFGECZ9HMBKKAOAaAOAa6GEeHaAqA8aAEeH8aAqCETGqCW6MBKDNDNDNDNA8aCUFpDIEBKAlAkCO4FGEAErBBCDCIA8aCLseAkCI4COgTv86BBA8aCW9HMEAWAy8pBB83BBAWCWFAyCWF8pBB83BBAWCZFHWXDKAlAkCO4FGEAErBBCEAkCI4COgTv86BBKDNCWA8a9tGeMBINAWCB86BBAWCEFHWXBKKCUA8aTCU7HqCBH3AcH5INA5HEAeHxCBHOINAErBBGaAqAaAqCfEgGy6eAOCfEgA8aTvHOAECEFHEAxCUFGxMBKAWAO86BBA5AeFH5AWCEFHWA3AeFG3CZ6MBKCBHEINDNAcAEFrBBGOAy6MBAWAO86BBAWCEFHWKAECEFGECZ9HMBKKDNAkCZFGkAS9PMBAcCZFHcARAW9rCl0MEKKAkAS6MEAWtMEAoCEFHoAZCEFGZAL6HhAWHaAZALsMIXBKKCBHWAhCEgtMEXLKCBHWAhCEgMIKAdApAXCUFAL2FALZmJJJB8aAXAKFHKAWMBKCBHOXDKCBHOARAW9rCAALALCA6e6MEDNALC8f0MBAWCBCAAL9rGEZ+TJJJBAEFHWKAWAdCJDFALZmJJJBALFAB9rHOXEKCBHOKAVCJOF8kJJJJBAOK9HEEUAECAAECA0eABCJ/ABAE9uC/wfBgGDCJDADCJD6eGDFCUFAD9uAE2ADCL4CIFCD4ADv2FCEFKMBCBABbD+Q+KJJBK/YSE3U8jJJJJBC/AE9rGL8kJJJJBCBHVDNAICI9uGOChFAE0MBABCBYDn+KJJBGVC/gEv86BBALC/ABFCfECJEZ+TJJJB8aALCuFGR9CU83IBALC8wFGW9CU83IBALCYFGd9CU83IBALCAFGQ9CU83IBALCkFGK9CU83IBA
$ { i . message } ` );const r=new Se(o);return l(i)&&(r.stack= ` Original stack :
$ { i . stack }
Handler stack :
$ { r . stack } ` ),Promise.reject(r)}};qt.getNodeTransform=function(e){return l(e.matrix)?e.matrix:B.fromTranslationQuaternionRotationScale(l(e.translation)?e.translation:d.ZERO,l(e.rotation)?e.rotation:Ce.IDENTITY,l(e.scale)?e.scale:d.ONE)};qt.getAttributeBySemantic=function(e,t,n){const i=e.attributes,o=i.length;for(let r=0;r<o;++r){const s=i[r],a=l(n)?s.setIndex===n:!0;if(s.semantic===t&&a)return s}};qt.getAttributeByName=function(e,t){const n=e.attributes,i=n.length;for(let o=0;o<i;++o){const r=n[o];if(r.name===t)return r}};qt.getFeatureIdsByLabel=function(e,t){for(let n=0;n<e.length;n++){const i=e[n];if(i.positionalLabel===t||i.label===t)return i}};qt.hasQuantizedAttributes=function(e){if(!l(e))return!1;for(let t=0;t<e.length;t++){const n=e[t];if(l(n.quantization))return!0}return!1};qt.getAttributeInfo=function(e){const t=e.semantic,n=e.setIndex;let i,o=!1;l(t)?(i=Tt.getVariableName(t,n),o=!0):(i=e.name,i=i.replace(/^_/,""),i=i.toLowerCase());const r=/^color_ \d + $ /.test(i),s=e.type;let a=sn.getGlslType(s);r&&(a="vec4");const c=l(e.quantization);let u;return c&&(u=r?"vec4":sn.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:o,glslType:a,quantizedGlslType:u}};const oFe=new d,rFe=new d;qt.getPositionMinMax=function(e,t,n){const i=qt.getAttributeBySemantic(e,"POSITION");let o=i.max,r=i.min;return l(n)&&l(t)&&(r=d.add(r,t,rFe),o=d.add(o,n,oFe)),{min:r,max:o}};qt.getAxisCorrectionMatrix=function(e,t,n){return n=B.clone(B.IDENTITY,n),e===kr.Y?n=B.clone(kr.Y_UP_TO_Z_UP,n):e===kr.X&&(n=B.clone(kr.X_UP_TO_Z_UP,n)),t===kr.Z&&(n=B.multiplyTransformation(n,kr.Z_UP_TO_X_UP,n)),n};const sFe=new J;qt.getCullFace=function(e,t){if(!Je.isTriangles(t))return Eo.BACK;const n=B.getMatrix3(e,sFe);return J.determinant(n)<0?Eo.FRONT:Eo.BACK};qt.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^ \d /.test(t)&&(t= ` _$ { t } ` ),t};qt.supportedExtensions={AGI_articulations:!0,CESIUM_primitive_outline:!0,CESIUM_RTC:!0,EXT_feature_metadata:!0,EXT_instance_features:!0,EXT_mesh_features:!0,EXT_mesh_gpu_instancing:!0,EXT_meshopt_compression:!0,EXT_structural_metadata:!0,EXT_texture_webp:!0,KHR_blend:!0,KHR_draco_mesh_compression:!0,KHR_techniques_webgl:!0,KHR_materials_common:!0,KHR_materials_pbrSpecularGlossiness:!0,KHR_materials_unlit:!0,KHR_mesh_quantization:!0,KHR_texture_basisu:!0,KHR_texture_transform:!0,WEB3D_quantized_attributes:!0};qt.checkSupportedExtensions=function(e){const t=e.length;for(let n=0;n<t;n++){const i=e[n];if(!qt.supportedExtensions[i])throw new Se( ` Unsupported glTF Extension : $ { i } ` )}};const sg={TRANSLATION:"TRANSLATION",ROTATION:"ROTATION",SCALE:"SCALE",FEATURE_ID:"_FEATURE_ID"};sg.fromGltfSemantic=function(e){T.typeOf.string("gltfSemantic",e);let t=e;const i=/^( \w +)_ \d + $ /.exec(e);switch(i!==null&&(t=i[1]),t){case"TRANSLATION":return sg.TRANSLATION;case"ROTATION":return sg.ROTATION;case"SCALE":return sg.SCALE;case"_FEATURE_ID":return sg.FEATURE_ID}};const Os=Object.freeze(sg),aFe=65534,cFe=255;function dT(e){e=y(e,y.EMPTY_OBJECT);const t=e.triangleIndices,n=e.outlineIndices,i=e.originalVertexCount;T.typeOf.object("options.triangleIndices",t),T.typeOf.object("options.outlineIndices",n),T.typeOf.number("options.originalVertexCount",i),this._triangleIndices=t,this._originalVertexCount=i,this._edges=new S7(n,i),this._outlineCoordinatesTypedArray=void 0,this._extraVertices=[],lFe(this)}Object.defineProperties(dT.prototype,{updatedTriangleIndices:{get:function(){return this._triangleIndices}},outlineCoordinates:{get:function(){return this._outlineCoordinatesTypedArray}}});function lFe(e){let t=e._triangleIndices;const n=e._edges,i=[],o=e._extraVertices,r=e._originalVertexCount,s={};for(let a=0;a<t.length;a+=3){let c=t[a],u=t[a+1],f=t[a+2];const h=n.hasEdge(c,u),_=n.hasEdge(u,f),g=n.hasEdge(f,c);let p=JH(i,c,u,f,h,_,g);for(;l(p);){let A=s[p];if(!l(A)){A=r+o.length;let C=p;for(;C>=r;)C=o[C-r];o.push(C),s[p]=A}A>aFe&&(t instanceof Uint16Array||t instanceof Uint8Array)?t=new Uint32Array(t):A>cFe&&t instanceof Uint8Array&&(t=new Uint16Array(t)),p===c?(c
Unsupported glTF version : $ { s } ` )}const a=t.extensionsRequired;l(a)&&(qt.checkSupportedExtensions(a),e._hasKhrMeshQuantization=a.includes("KHR_mesh_quantization"));const c=y(t.extensions,y.EMPTY_OBJECT),u=c.EXT_structural_metadata,f=c.EXT_feature_metadata,h=c.CESIUM_RTC;if(l(f)){const P=f.featureTables,L=f.featureTextures,H=l(P)?P:[],R=l(L)?L:[];e._sortedPropertyTableIds=Object.keys(H).sort(),e._sortedFeatureTextureIds=Object.keys(R).sort()}const _=g2e(e,t,n,i),g=A2e(e,t,_),p=w2e(e,t,_),A=D2e(t),C=P2e(t,_),b=new BFe,x=new OFe,w=t.asset.copyright;if(l(w)){const P=w.split(";").map(function(L){return new Xn(L.trim())});x.credits=P}if(b.asset=x,b.scene=C,b.nodes=_,b.skins=g,b.animations=p,b.articulations=A,b.upAxis=e._upAxis,b.forwardAxis=e._forwardAxis,l(h)){const P=d.fromArray(h.center,0,O2e);b.transform=B.fromTranslation(P,b.transform)}if(e._components=b,l(u)||l(f)){const L=C2e(e,t,u,f,n,i).promise.then(function(H){e.isDestroyed()||(b.structuralMetadata=H.structuralMetadata)});e._loaderPromises.push(L)}const S=[];S.push.apply(S,e._loaderPromises),e._incrementallyLoadTextures||S.push.apply(S,e._texturesPromises),Promise.all(S).then(function(){e.isDestroyed()||(e._state=io.POST_PROCESSING)}).catch(o),Promise.all(e._texturesPromises).then(function(){e.isDestroyed()||(e._textureState=io.PROCESSED)}).catch(r)}function B2e(e){const t=e._textureLoaders,n=t.length;for(let i=0;i<n;++i)pt.unload(t[i]);e._textureLoaders.length=0}function U7(e){const t=e._bufferViewLoaders,n=t.length;for(let i=0;i<n;++i)pt.unload(t[i]);e._bufferViewLoaders.length=0}function R2e(e){const t=e._geometryLoaders,n=t.length;for(let i=0;i<n;++i)pt.unload(t[i]);e._geometryLoaders.length=0}function N2e(e){const t=e._postProcessBuffers,n=t.length;for(let i=0;i<n;i++){const o=t[i];o.isDestroyed()||o.destroy()}t.length=0}function M2e(e){l(e._structuralMetadataLoader)&&(e._structuralMetadataLoader.destroy(),e._structuralMetadataLoader=void 0)}vl.prototype.isUnloaded=function(){return this._state===io.UNLOADED};vl.prototype.unload=function(){l(this._gltfJsonLoader)&&pt.unload(this._gltfJsonLoader),this._gltfJsonLoader=void 0,B2e(this),U7(this),R2e(this),N2e(this),M2e(this),this._components=void 0,this._typedArray=void 0,this._state=io.UNLOADED};const F2e= ` # extension GL _EXT _frag _depth : enable
uniform sampler2D u _pointCloud _colorGBuffer ;
uniform sampler2D u _pointCloud _depthGBuffer ;
uniform vec2 u _distanceAndEdlStrength ;
varying vec2 v _textureCoordinates ;
vec2 neighborContribution ( float log2Depth , vec2 offset )
{
float dist = u _distanceAndEdlStrength . x ;
vec2 texCoordOrig = v _textureCoordinates + offset * dist ;
vec2 texCoord0 = v _textureCoordinates + offset * floor ( dist ) ;
vec2 texCoord1 = v _textureCoordinates + offset * ceil ( dist ) ;
float depthOrLogDepth0 = czm _unpackDepth ( texture2D ( u _pointCloud _depthGBuffer , texCoord0 ) ) ;
float depthOrLogDepth1 = czm _unpackDepth ( texture2D ( u _pointCloud _depthGBuffer , texCoord1 ) ) ;
// ignore depth values that are the clear depth
if ( depthOrLogDepth0 == 0.0 || depthOrLogDepth1 == 0.0 ) {
return vec2 ( 0.0 ) ;
}
// interpolate the two adjacent depth values
float depthMix = mix ( depthOrLogDepth0 , depthOrLogDepth1 , fract ( dist ) ) ;
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( texCoordOrig , depthMix ) ;
return vec2 ( max ( 0.0 , log2Depth - log2 ( - eyeCoordinate . z / eyeCoordinate . w ) ) , 1.0 ) ;
}
void main ( )
{
float depthOrLogDepth = czm _unpackDepth ( texture2D ( u _pointCloud _depthGBuffer , v _textureCoordinates ) ) ;
vec4 eyeCoordinate = czm _windowToEyeCoordinates ( gl _FragCoord . xy , depthOrLogDepth ) ;
eyeCoordinate /= eyeCoordinate . w ;
float log2Depth = log2 ( - eyeCoordinate . z ) ;
if ( depthOrLogDepth == 0.0 ) // 0.0 is the clear value for the gbuffer
{
discard ;
}
vec4 color = texture2D ( u _pointCloud _colorGBuffer , v _textureCoordinates ) ;
// sample from neighbors left, right, down, up
vec2 texelSize = 1.0 / czm _viewport . zw ;
vec2 responseAndCount = vec2 ( 0.0 ) ;
responseAndCount += neighborContribution ( log2Depth , vec2 ( - texelSize . x , 0.0 ) ) ;
responseAndCount += neighborContribution ( log2Depth , vec2 ( + texelSize . x , 0.0 ) ) ;
responseAndCount += neighborContribution ( log2Depth , vec2 ( 0.0 , - texelSize . y ) ) ;
responseAndCount += neighborContribution ( log2Depth , vec2 ( 0.0 , + texelSize . y ) ) ;
float response = responseAndCount . x / responseAndCount . y ;
float strength = u _distanceAndEdlStrength . y ;
float shade = exp ( - response * 300.0 * strength ) ;
color . rgb *= shade ;
gl _FragColor = vec4 ( color ) ;
// Input and output depth are the same.
gl _FragDepthEXT = depthOrLogDepth ;
}
` ;function up(){this._framebuffer=new Cn({colorAttachmentsLength:2,depth:!0,supportsDepthTexture:!0}),this._drawCommand=void 0,this._clearCommand=void 0,this._strength=1,this._radius=1}Object.defineProperties(up.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 z2e(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}const sP=new j;function U2e(e,t){const n=new Ge({defines:["LOG_DEPTH_WRITE"],sources:[F2e]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return sP.x=e._radius,sP.y=e._strength,sP}},o=Qe.fromCache({blending:Si.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:It.setCesium3DTileBit(),stencilMask:It.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:o,pass:Be.CESIUM_3D_TILE,owner:e}),e._clearCommand=new ji({framebuffer:e.framebuffer,color:new F(0,0,0,0),depth:1,renderState:Qe.fromCache(),pass:Be.CESIUM_3D_TILE,owner:e})}function H2e(e,t){const n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),U2e(e,t)}function H7(e){return e.drawBuffers&&e.fragmentDepth}up.isSupported=H7;function V2e(e,t){let n=e.shaderCache.getDerivedShaderProgram(t,"EC");if(!l(n)){const i=t._attributeLocations,o=t.fragmentShaderSource.clone();o.sources=o.sources.map(function(r){return r=Ge.replaceMain(r,"czm_point_cloud_post_process_main"),r=r.replace(/gl_FragColor/g,"gl_FragData[0]"),r}),o.sources.unshift( ` # extension GL _EXT _draw _buffers : enable
` ),o.sources.push( ` void main ( )
{
czm _point _cloud _post _process _main ( ) ;
# ifdef LOG _DEPTH
czm _writeLogDepth ( ) ;
gl _FragData [ 1 ] = czm _packDepth ( gl _FragDepthEXT ) ;
# else
gl _FragData [ 1 ] = czm _packDepth ( gl _FragCoord . z ) ;
# endif
} ` ),n=e.shaderCache.createDerivedShaderProgram(t,"EC",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}up.prototype.update=function(e,t,n,i){if(!H7(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,H2e(this,e.context);let o;const r=e.commandList,s=r.length;for(o=t;o<s;++o){const u=r[o];if(u.primitiveType!==Je.POINTS||u.pass===Be.TRANSLUCENT)continue;let f,h,_=u.derivedCommands.pointCloudProcessor;l(_)&&(f=_.command,h=_.originalShaderProgram),(!l(f)||u.dirty||h!==u.shaderProgram||f.framebuffer!==this.framebuffer)&&(f=ft.shallowClone(u,f),f.framebuffer=this.framebuffer,f.shaderProgram=V2e(e.context,u.shaderProgram),f.castShadows=!1,f.receiveShadows=!1,l(_)||(_={command:f,originalShaderProgram:u.shaderProgram},u.derivedCommands.pointCloudProcessor=_),_.originalShaderProgram=u.shaderProgram),r[o]=f}const a=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,r.push(c),r.push(a)};up.prototype.isDestroyed=function(){return!1};up.prototype.destroy=function(){return z2e(this),Ue(this)};function hT(e){const t=y(e,{});this.attenuation=y(t.attenuation,!1),this.geometricErrorScale=y(t.geometricErrorScale,1),this.maximumAttenuation=t.maximumAttenuation,this.baseResolution=t.baseResolution,this.eyeDomeLighting=y(t.eyeDomeLighting,!0),this.eyeDomeLightingStrength=y(t.eyeDomeLightingStrength,1),this.eyeDomeLightingRadius=y(t.eyeDomeLightingRadius,1),this.backFaceCulling=y(t.backFaceCulling,!1),this.normalShading=y(t.normalShading,!0)}hT.isSupported=function(e){return up.isSupported(e.context)};const xg={};xg._deprecationWarning=ep;const mf=Uint32Array.BYTES_PER_ELEMENT;xg.parse=function(e,t){const n=y(t,0);T.defined("arrayBuffer",e),t=n;const i=new Uint8Array(e),o=new DataView(e);t+=mf;const r=o.getUint32(t,!0);if(r!==1)throw new Se( ` Only Batched 3 D Model version 1 is supported . Version $ { r } is not . ` );t+=mf;const s=o.getUint32(t,!0);t+=mf;let a=o.getUint32(t,!0);t+=mf;let c=o.getUint32(t,!0);t+=mf;let u=o.getUint32(t,!0);t+=mf;let f=o.getUint32(t,!0);t+=mf;let h;u>=570425344?(t-=mf*2,h=a,u=c,f=0,a=0,c=0,xg._deprecationWarning("b3dm-legacy-header","This b3dm header is using the legacy format [batchLength] [batchTableByteLength]. The new format is [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength] from https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel.")):f>=570425344&&(t-=mf,h=u,u=a,f=c,a=0,c=0,xg._deprecationWarning("b3dm-legacy-header","This b3dm header is using the legacy format [batchTableJsonByteLength] [batchTableBinaryByteLength] [batchLength]. The new format is [featureTableJsonByteLength] [featureTableBinaryByteLength] [batchTableJsonByteLength] [batchTableBinaryByteLength] from https://github.com/CesiumGS/3d-tiles/tree/main/specification/TileFormats/Batched3DModel."));let _;a===0?_={BATCH_LENGTH:y(h,0)}:(_=Ea(i,t,a),t+=a);const g=new Uint8Array(e,t,c);t+=c;let p,A;u>0&&(p=Ea(i,t,u),t+=u,f>0&&(A=new Uint8Array(e,t,f),A=new Uint8Array(A),t+=f));const C=n+s-t;if(C===0)throw new Se("glTF byte length must be greater than 0.");let b;return t%4===0?b=new Uint8Array(e,t,C):(xg._deprecationWarning("b3dm-glb-unaligned","The embedded glb is not aligned to a 4-byte boundary."),b=new Uint8Array(i.subarray(t,t+C))),{batchLength:h,featureTableJson:_,featureTableBinary:g,batchTableJson:p,batchTableBinary:A,gltf:b}};const k2e=xg;function fp(e,t){this.json=e,this.buffer=t,this._cachedTypedArrays={},this.featuresLength=0}function V7(e,t,n,i,o,r){const s=e._cachedTypedArrays;let a=s[t];return l(a)||(a=ee.createArrayBufferView(n,e.buffer.buffer,e.buffer.byteOffset+r,o*i),s[t]=a),a}function G2e(e,t,n,i){const o=e._cachedTypedArrays;let r=o[t];return l(r)||(r=ee.createTypedArray(n,i),o[t]=r),r}fp.prototype.getGlobalProperty=function(e,t,n){const i=this.json[e];if(l(i))return l(i.byteOffset)?(t=y(t,ee.UNSIGNED_INT),n=y(n,1),V7(this,e,t,n,1,i.byteOffset)):i};fp.prototype.hasProperty=function(e){return l(this.json[e])};fp.prototype.getProper
# ifdef GL _OES _standard _derivatives
# extension GL _OES _standard _derivatives : enable
# endif
# endif
czm _modelMaterial defaultModelMaterial ( )
{
czm _modelMaterial material ;
material . diffuse = vec3 ( 0.0 ) ;
material . specular = vec3 ( 1.0 ) ;
material . roughness = 1.0 ;
material . occlusion = 1.0 ;
material . normalEC = vec3 ( 0.0 , 0.0 , 1.0 ) ;
material . emissive = vec3 ( 0.0 ) ;
material . alpha = 1.0 ;
return material ;
}
vec4 handleAlpha ( vec3 color , float alpha )
{
# ifdef ALPHA _MODE _MASK
if ( alpha < u _alphaCutoff ) {
discard ;
}
# endif
return vec4 ( color , alpha ) ;
}
SelectedFeature selectedFeature ;
void main ( )
{
# ifdef HAS _MODEL _SPLITTER
modelSplitterStage ( ) ;
# endif
czm _modelMaterial material = defaultModelMaterial ( ) ;
ProcessedAttributes attributes ;
geometryStage ( attributes ) ;
FeatureIds featureIds ;
featureIdStage ( featureIds , attributes ) ;
Metadata metadata ;
MetadataClass metadataClass ;
MetadataStatistics metadataStatistics ;
metadataStage ( metadata , metadataClass , metadataStatistics , attributes ) ;
# ifdef HAS _SELECTED _FEATURE _ID
selectedFeatureIdStage ( selectedFeature , featureIds ) ;
# endif
# ifndef CUSTOM _SHADER _REPLACE _MATERIAL
materialStage ( material , attributes , selectedFeature ) ;
# endif
# ifdef HAS _CUSTOM _FRAGMENT _SHADER
customShaderStage ( material , attributes , featureIds , metadata , metadataClass , metadataStatistics ) ;
# endif
lightingStage ( material , attributes ) ;
# ifdef HAS _SELECTED _FEATURE _ID
cpuStylingStage ( material , selectedFeature ) ;
# endif
# ifdef HAS _MODEL _COLOR
modelColorStage ( material ) ;
# endif
# ifdef HAS _PRIMITIVE _OUTLINE
primitiveOutlineStage ( material ) ;
# endif
vec4 color = handleAlpha ( material . diffuse , material . alpha ) ;
# ifdef HAS _CLIPPING _PLANES
modelClippingPlanesStage ( color ) ;
# endif
# if defined ( HAS _SILHOUETTE ) && defined ( HAS _NORMALS )
silhouetteStage ( color ) ;
# endif
gl _FragColor = color ;
}
` ,R3e= ` precision highp float ;
czm _modelVertexOutput defaultVertexOutput ( vec3 positionMC ) {
czm _modelVertexOutput vsOutput ;
vsOutput . positionMC = positionMC ;
vsOutput . pointSize = 1.0 ;
return vsOutput ;
}
void main ( )
{
// Initialize the attributes struct with all
// attributes except quantized ones.
ProcessedAttributes attributes ;
initializeAttributes ( attributes ) ;
// Dequantize the quantized ones and add them to the
// attributes struct.
# ifdef USE _DEQUANTIZATION
dequantizationStage ( attributes ) ;
# endif
# ifdef HAS _MORPH _TARGETS
morphTargetsStage ( attributes ) ;
# endif
# ifdef HAS _SKINNING
skinningStage ( attributes ) ;
# endif
# ifdef HAS _PRIMITIVE _OUTLINE
primitiveOutlineStage ( ) ;
# endif
// Compute the bitangent according to the formula in the glTF spec.
// Normal and tangents can be affected by morphing and skinning, so
// the bitangent should not be computed until their values are finalized.
# ifdef HAS _BITANGENTS
attributes . bitangentMC = normalize ( cross ( attributes . normalMC , attributes . tangentMC ) * attributes . tangentSignMC ) ;
# endif
FeatureIds featureIds ;
featureIdStage ( featureIds , attributes ) ;
# ifdef HAS _SELECTED _FEATURE _ID
SelectedFeature feature ;
selectedFeatureIdStage ( feature , featureIds ) ;
// Handle any show properties that come from the style.
cpuStylingStage ( attributes . positionMC , feature ) ;
# endif
# if defined ( USE _2D _POSITIONS ) || defined ( USE _2D _INSTANCING )
// The scene mode 2D pipeline stage and instancing stage add a different
// model view matrix to accurately project the model to 2D. However, the
// output positions and normals should be transformed by the 3D matrices
// to keep the data the same for the fragment shader.
mat4 modelView = czm _modelView3D ;
mat3 normal = czm _normal3D ;
# else
// These are used for individual model projection because they will
// automatically change based on the scene mode.
mat4 modelView = czm _modelView ;
mat3 normal = czm _normal ;
# endif
// Update the position for this instance in place
# ifdef HAS _INSTANCING
// The legacy instance stage is used when rendering i3dm models that
// encode instances transforms in world space, as opposed to glTF models
// that use EXT_mesh_gpu_instancing, where instance transforms are encoded
// in object space.
# ifdef USE _LEGACY _INSTANCING
mat4 instanceModelView ;
mat3 instanceModelViewInverseTranspose ;
legacyInstancingStage ( attributes , instanceModelView , instanceModelViewInverseTranspose ) ;
modelView = instanceModelView ;
normal = instanceModelViewInverseTranspose ;
# else
instancingStage ( attributes ) ;
# endif
# ifdef USE _PICKING
v _pickColor = a _pickColor ;
# endif
# endif
Metadata metadata ;
MetadataClass metadataClass ;
MetadataStatistics metadataStatistics ;
metadataStage ( metadata , metadataClass , metadataStatistics , attributes ) ;
# ifdef HAS _CUSTOM _VERTEX _SHADER
czm _modelVertexOutput vsOutput = defaultVertexOutput ( attributes . positionMC ) ;
customShaderStage ( vsOutput , attributes , featureIds , metadata , metadataClass , metadataStatistics ) ;
# endif
// Compute the final position in each coordinate system needed.
// This returns the value that will be assigned to gl_Position.
vec4 positionClip = geometryStage ( attributes , modelView , normal ) ;
# ifdef HAS _SILHOUETTE
silhouetteStage ( attributes , positionClip ) ;
# endif
# ifdef HAS _POINT _CLOUD _SHOW _STYLE
float show = pointCloudShowStylingStage ( attributes , metadata ) ;
# else
float show = 1.0 ;
# endif
# ifdef HAS _POINT _CLOUD _BACK _FACE _CULLING
show *= pointCloudBackFaceCullingStage ( ) ;
# endif
# ifdef HAS _POINT _CLOUD _COLOR _STYLE
v _pointCloudColor = pointCloudColorStylingStage ( attributes , metadata ) ;
# endif
# ifdef PRIMITIVE _TYPE _POINTS
# ifdef HAS _CUSTOM _VERTEX _SHADER
gl _PointSize = vsOutput . pointSize ;
# elif defined ( HAS _POINT _CLOUD _POINT _SIZE _STYLE ) || defined ( HAS _POINT _CLOUD _ATTENUATION )
gl _PointSize = pointCloudPointSizeStylingStage ( attributes , metadata ) ;
# else
gl _PointSize = 1.0 ;
# endif
gl _PointSize *= show ;
# endif
gl _Position = show * positionClip ;
}
` ;function AN(e){e=y(e,y.EMPTY_OBJECT);const t=e.command,n=e.primitiveRenderResources;T.typeOf.object("options.command",t),T.typeOf.object("options.primitiveRenderResources",n);const 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;const o=i.classificationType;this._classificationType=o,this._classifiesTerrain=o!==co.CESIUM_3D_TILE,this._classifies3DTiles=o!==co.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[],z3e(this)}function N3e(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:dt.KEEP,zFail:dt.DECREMENT_WRAP,zPass:dt.KEEP},backFunction:e,backOperation:{fail:dt.KEEP,zFail:dt.INCREMENT_WRAP,zPass:dt.KEEP},reference:It.CESIUM_3D_TILE_MASK,mask:It.CESIUM_3D_TILE_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:Sm.LESS_OR_EQUAL},depthMask:!1}}const M3e={stencilTest:{enabled:!0,frontFunction:ii.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:ii.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:It.CLASSIFICATION_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:Si.PRE_MULTIPLIED_ALPHA_BLEND},F3e={stencilTest:{enabled:!0,frontFunction:ii.NOT_EQUAL,frontOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},backFunction:ii.NOT_EQUAL,backOperation:{fail:dt.ZERO,zFail:dt.ZERO,zPass:dt.ZERO},reference:0,mask:It.CLASSIFICATION_MASK},stencilMask:It.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},Z7=[];function z3e(e){const t=e._command,n=Z7;if(e._useDebugWireframe){t.pass=Be.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=LA(e,n,e._commandListDebugWireframe);const r=e._commandListDebugWireframe,s=r.length;for(let a=0;a<s;a++){const c=r[a];c.count*=2,c.offset*=2}return}const o=e.model.allowPicking;if(e._classifiesTerrain){const r=Be.TERRAIN_CLASSIFICATION,s=dL(t,r),a=nV(t,r);n.length=0,n.push(s,a),e._commandListTerrain=LA(e,n,e._commandListTerrain),o&&(e._commandListTerrainPicking=iV(e,n,e._commandListTerrainPicking))}if(e._classifies3DTiles){const r=Be.CESIUM_3D_TILE_CLASSIFICATION,s=dL(t,r),a=nV(t,r);n.length=0,n.push(s,a),e._commandList3DTiles=LA(e,n,e._commandList3DTiles),o&&(e._commandList3DTilesPicking=iV(e,n,e._commandList3DTilesPicking))}}function LA(e,t,n){const i=e._runtimePrimitive,o=i.batchLengths,r=i.batchOffsets,s=o.length,a=t.length;for(let c=0;c<s;c++){const u=o[c],f=r[c];for(let h=0;h<a;h++){const _=t[h],g=ft.shallowClone(_);g.count=u,g.offset=f,n.push(g)}}return n}function dL(e,t){const n=ft.shallowClone(e);n.cull=!1,n.pass=t;const i=t===Be.TERRAIN_CLASSIFICATION?ii.ALWAYS:ii.EQUAL,o=N3e(i);return n.renderState=Qe.fromCache(o),n}function nV(e,t){const n=ft.shallowClone(e);return n.cull=!1,n.pass=t,n.renderState=Qe.fromCache(M3e),n}const U3e=[];function iV(e,t,n){const i=Qe.fromCache(F3e),o=t[0],r=t[1],s=ft.shallowClone(o);s.cull=!0,s.pickOnly=!0;const a=ft.shallowClone(r);a.cull=!0,a.pickOnly=!0,a.renderState=i,a.pickId=e._pickId;const c=U3e;return c.length=0,c.push(s,a),LA(e,c,n)}Object.defineProperties(AN.prototype,{command:{get:function(){return this._command}},runtimePrimitive:{get:function(){return this._runtimePrimitive}},batchLengths:{get:function(){return this._runtimePrimitive.batchLengths}},batchOffsets:{get:function(){return this._runtimePrimitive.batchOffsets}},model:{get:function(){return this._model}},classificationType:{get:function(){return this._classificationType}},modelMatrix:{get:function(){return this._modelMatrix},set:function(e){this._modelMatrix=B.clone(e,this._modelMatrix);const t=this._runtimePrimitive.boundingSphere;this._boundingVolume=fe.transform(t,this._modelMatrix,this._boundingVolume)}},boundingVolume:{get
vec3 positionEC ,
vec3 normalEC ,
vec3 lightDirectionEC ,
vec3 lightColorHdr ,
czm _pbrParameters pbrParameters
) {
vec3 v = - positionEC ;
vec3 positionWC = vec3 ( czm _inverseView * vec4 ( positionEC , 1.0 ) ) ;
vec3 vWC = - normalize ( positionWC ) ;
vec3 l = normalize ( lightDirectionEC ) ;
vec3 n = normalEC ;
vec3 r = normalize ( czm _inverseViewRotation * normalize ( reflect ( v , n ) ) ) ;
float NdotL = clamp ( dot ( n , l ) , 0.001 , 1.0 ) ;
float NdotV = abs ( dot ( n , v ) ) + 0.001 ;
// Figure out if the reflection vector hits the ellipsoid
float vertexRadius = length ( positionWC ) ;
float horizonDotNadir = 1.0 - min ( 1.0 , czm _ellipsoidRadii . x / vertexRadius ) ;
float reflectionDotNadir = dot ( r , normalize ( positionWC ) ) ;
// Flipping the X vector is a cheap way to get the inverse of czm_temeToPseudoFixed, since that's a rotation about Z.
r . x = - r . x ;
r = - normalize ( czm _temeToPseudoFixed * r ) ;
r . x = - r . x ;
vec3 diffuseColor = pbrParameters . diffuseColor ;
float roughness = pbrParameters . roughness ;
vec3 specularColor = pbrParameters . f0 ;
float inverseRoughness = 1.04 - roughness ;
inverseRoughness *= inverseRoughness ;
vec3 sceneSkyBox = textureCube ( czm _environmentMap , r ) . rgb * inverseRoughness ;
float atmosphereHeight = 0.05 ;
float blendRegionSize = 0.1 * ( ( 1.0 - inverseRoughness ) * 8.0 + 1.1 - horizonDotNadir ) ;
float blendRegionOffset = roughness * - 1.0 ;
float farAboveHorizon = clamp ( horizonDotNadir - blendRegionSize * 0.5 + blendRegionOffset , 1.0 e - 10 - blendRegionSize , 0.99999 ) ;
float aroundHorizon = clamp ( horizonDotNadir + blendRegionSize * 0.5 , 1.0 e - 10 - blendRegionSize , 0.99999 ) ;
float farBelowHorizon = clamp ( horizonDotNadir + blendRegionSize * 1.5 , 1.0 e - 10 - blendRegionSize , 0.99999 ) ;
float smoothstepHeight = smoothstep ( 0.0 , atmosphereHeight , horizonDotNadir ) ;
vec3 belowHorizonColor = mix ( vec3 ( 0.1 , 0.15 , 0.25 ) , vec3 ( 0.4 , 0.7 , 0.9 ) , smoothstepHeight ) ;
vec3 nadirColor = belowHorizonColor * 0.5 ;
vec3 aboveHorizonColor = mix ( vec3 ( 0.9 , 1.0 , 1.2 ) , belowHorizonColor , roughness * 0.5 ) ;
vec3 blueSkyColor = mix ( vec3 ( 0.18 , 0.26 , 0.48 ) , aboveHorizonColor , reflectionDotNadir * inverseRoughness * 0.5 + 0.75 ) ;
vec3 zenithColor = mix ( blueSkyColor , sceneSkyBox , smoothstepHeight ) ;
vec3 blueSkyDiffuseColor = vec3 ( 0.7 , 0.85 , 0.9 ) ;
float diffuseIrradianceFromEarth = ( 1.0 - horizonDotNadir ) * ( reflectionDotNadir * 0.25 + 0.75 ) * smoothstepHeight ;
float diffuseIrradianceFromSky = ( 1.0 - smoothstepHeight ) * ( 1.0 - ( reflectionDotNadir * 0.25 + 0.25 ) ) ;
vec3 diffuseIrradiance = blueSkyDiffuseColor * clamp ( diffuseIrradianceFromEarth + diffuseIrradianceFromSky , 0.0 , 1.0 ) ;
float notDistantRough = ( 1.0 - horizonDotNadir * roughness * 0.8 ) ;
vec3 specularIrradiance = mix ( zenithColor , aboveHorizonColor , smoothstep ( farAboveHorizon , aroundHorizon , reflectionDotNadir ) * notDistantRough ) ;
specularIrradiance = mix ( specularIrradiance , belowHorizonColor , smoothstep ( aroundHorizon , farBelowHorizon , reflectionDotNadir ) * inverseRoughness ) ;
specularIrradiance = mix ( specularIrradiance , nadirColor , smoothstep ( farBelowHorizon , 1.0 , reflectionDotNadir ) * inverseRoughness ) ;
// Luminance model from page 40 of http://silviojemma.com/public/papers/lighting/spherical-harmonic-lighting.pdf
# ifdef USE _SUN _LUMINANCE
// Angle between sun and zenith
float LdotZenith = clamp ( dot ( normalize ( czm _inverseViewRotation * l ) , vWC ) , 0.001 , 1.0 ) ;
float S = acos ( LdotZenith ) ;
// Angle between zenith and current pixel
float NdotZenith = clamp ( dot ( normalize ( czm _inverseViewRotation * n ) , vWC ) , 0.001 , 1.0 ) ;
// Angle between sun and current pixel
float gamma = acos ( NdotL ) ;
float numerator = ( ( 0.91 + 10.0 * exp ( - 3.0 * gamma ) + 0.45 * pow ( NdotL , 2.0 ) ) * ( 1.0 - exp ( - 0.32 / NdotZenith ) ) ) ;
float denominator = ( 0.91 + 10.0 * exp ( - 3.0 * S ) + 0.45 * pow ( LdotZenith , 2.0 ) ) * ( 1.0 - exp ( - 0.32 ) ) ;
float luminance = model _luminanceAtZenith * ( numerator / denominator ) ;
# endif
vec2 brdfLut = texture2D ( czm _brdfLut , vec2 ( NdotV , roughness ) ) . rg ;
vec3 iblColor = ( diffuseIrradiance * diffuseColor * model _iblFactor . x ) + ( specularIrradiance * czm _srgbToLinear ( specularColor * brdfLut . x + brdfLut . y ) * model _iblFactor . y ) ;
float maximumComponent = max ( max ( lightColorHdr . x , lightColorHdr . y ) , lightColorHdr . z ) ;
vec3 lightColor = lightColorHdr / max ( maximumComponent , 1.0 ) ;
iblColor *= lightColor ;
# ifdef USE _SUN _LUMINANCE
iblColor *= luminance ;
# endif
return iblColor ;
}
# if defined ( DIFFUSE _IBL ) || defined ( SPECULAR _IBL )
vec3 textureIBL (
vec3 positionEC ,
vec3 normalEC ,
vec3 lightDirectionEC ,
czm _pbrParameters pbrParameters
) {
vec3 diffuseColor = pbrParameters . diffuseColor ;
float roughness = pbrParameters . roughness ;
vec3 specularColor = pbrParameters . f0 ;
vec3 v = - positionEC ;
vec3 n = normalEC ;
vec3 l = normalize ( lightDirectionEC ) ;
vec3 h = normalize ( v + l ) ;
float NdotV = abs ( dot ( n , v ) ) + 0.001 ;
float VdotH = clamp ( dot ( v , h ) , 0.0 , 1.0 ) ;
const mat3 yUpToZUp = mat3 (
- 1.0 , 0.0 , 0.0 ,
0.0 , 0.0 , - 1.0 ,
0.0 , 1.0 , 0.0
) ;
vec3 cubeDir = normalize ( yUpToZUp * model _iblReferenceFrameMatrix * normalize ( reflect ( - v , n ) ) ) ;
# ifdef DIFFUSE _IBL
# ifdef CUSTOM _SPHERICAL _HARMONICS
vec3 diffuseIrradiance = czm _sphericalHarmonics ( cubeDir , model _sphericalHarmonicCoefficients ) ;
# else
vec3 diffuseIrradiance = czm _sphericalHarmonics ( cubeDir , czm _sphericalHarmonicCoefficients ) ;
# endif
# else
vec3 diffuseIrradiance = vec3 ( 0.0 ) ;
# endif
# ifdef SPECULAR _IBL
vec3 r0 = specularColor . rgb ;
float reflectance = max ( max ( r0 . r , r0 . g ) , r0 . b ) ;
vec3 r90 = vec3 ( clamp ( reflectance * 25.0 , 0.0 , 1.0 ) ) ;
vec3 F = fresnelSchlick2 ( r0 , r90 , VdotH ) ;
vec2 brdfLut = texture2D ( czm _brdfLut , vec2 ( NdotV , roughness ) ) . rg ;
# ifdef CUSTOM _SPECULAR _IBL
vec3 specularIBL = czm _sampleOctahedralProjection ( model _specularEnvironmentMaps , model _specularEnvironmentMapsSize , cubeDir , roughness * model _specularEnvironmentMapsMaximumLOD , model _specularEnvironmentMapsMaximumLOD ) ;
# else
vec3 specularIBL = czm _sampleOctahedralProjection ( czm _specularEnvironmentMaps , czm _specularEnvironmentMapSize , cubeDir , roughness * czm _specularEnvironmentMapsMaximumLOD , czm _specularEnvironmentMapsMaximumLOD ) ;
# endif
specularIBL *= F * brdfLut . x + brdfLut . y ;
# else
vec3 specularIBL = vec3 ( 0.0 ) ;
# endif
return diffuseColor * diffuseIrradiance + specularColor * specularIBL ;
}
# endif
vec3 imageBasedLightingStage (
vec3 positionEC ,
vec3 normalEC ,
vec3 lightDirectionEC ,
vec3 lightColorHdr ,
czm _pbrParameters pbrParameters
) {
# if defined ( DIFFUSE _IBL ) || defined ( SPECULAR _IBL )
// Environment maps were provided, use them for IBL
return textureIBL (
positionEC ,
normalEC ,
lightDirectionEC ,
pbrParameters
) ;
# else
// Use the procedural IBL if there are no environment maps
return proceduralIBL (
positionEC ,
normalEC ,
lightDirectionEC ,
lightColorHdr ,
pbrParameters
) ;
# endif
} ` ,nY={name:"ImageBasedLightingPipelineStage"};nY.process=function(e,t,n){const i=t.imageBasedLighting,o=e.shaderBuilder;o.addDefine("USE_IBL_LIGHTING",void 0,we.FRAGMENT),o.addUniform("vec2","model_iblFactor",we.FRAGMENT),Nl.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&o.addUniform("mat3","model_iblReferenceFrameMatrix",we.FRAGMENT),l(i.sphericalHarmonicCoefficients)?(o.addDefine("DIFFUSE_IBL",void 0,we.FRAGMENT),o.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,we.FRAGMENT),o.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",we.FRAGMENT)):i.useDefaultSphericalHarmonics&&o.addDefine("DIFFUSE_IBL",void 0,we.FRAGMENT),l(i.specularEnvironmentMapAtlas)&&i.specularEnvironmentMapAtlas.ready?(o.addDefine("SPECULAR_IBL",void 0,we.FRAGMENT),o.addDefine("CUSTOM_SPECULAR_IBL",void 0,we.FRAGMENT),o.addUniform("sampler2D","model_specularEnvironmentMaps",we.FRAGMENT),o.addUniform("vec2","model_specularEnvironmentMapsSize",we.FRAGMENT),o.addUniform("float","model_specularEnvironmentMapsMaximumLOD",we.FRAGMENT)):t.useDefaultSpecularMaps&&o.addDefine("SPECULAR_IBL",void 0,we.FRAGMENT)),l(i.luminanceAtZenith)&&(o.addDefine("USE_SUN_LUMINANCE",void 0,we.FRAGMENT),o.addUniform("float","model_luminanceAtZenith",we.FRAGMENT)),o.addFragmentLines(oze);const r={model_iblFactor:function(){return i.imageBasedLightingFactor},model_iblReferenceFrameMatrix:function(){return t._iblReferenceFrameMatrix},model_luminanceAtZenith:function(){return i.luminanceAtZenith},model_sphericalHarmonicCoefficients:function(){return i.sphericalHarmonicCoefficients},model_specularEnvironmentMaps:function(){return i.specularEnvironmentMapAtlas.texture},model_specularEnvironmentMapsSize:function(){return i.specularEnvironmentMapAtlas.texture.dimensions},model_specularEnvironmentMapsMaximumLOD:function(){return i.specularEnvironmentMapAtlas.maximumMipmapLevel}};e.uniformMap=nn(r,e.uniformMap)};const rze=nY,sze=N.EPSILON16;function CN(e){e=y(e,y.EMPTY_OBJECT);const t=e.stage,n=e.runtimeArticulation;T.typeOf.object("options.stage",t),T.typeOf.object("options.runtimeArticulation",n),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(CN.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){T.typeOf.number("value",e),e=N.clamp(e,this.minimumValue,this.maximumValue),N.equalsEpsilon(this._currentValue,e,sze)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});const aze=new d,aP=new J;CN.prototype.applyStageToMatrix=function(e){T.typeOf.object("result",e);const t=this.type,n=this.currentValue,i=aze;let o;switch(t){case ll.XROTATE:o=J.fromRotationX(N.toRadians(n),aP),e=B.multiplyByMatrix3(e,o,e);break;case ll.YROTATE:o=J.fromRotationY(N.toRadians(n),aP),e=B.multiplyByMatrix3(e,o,e);break;case ll.ZROTATE:o=J.fromRotationZ(N.toRadians(n),aP),e=B.multiplyByMatrix3(e,o,e);break;case ll.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case ll.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case ll.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=B.multiplyByTranslation(e,i,e);break;case ll.XSCALE:i.x=n,i.y=1,i.z=1,e=B.multiplyByScale(e,i,e);break;case ll.YSCALE:i.x=1,i.y=n,i.z=1,e=B.multiplyByScale(e,i,e);break;case ll.ZSCALE:i.x=1,i.y=1,i.z=n,e=B.multiplyByScale(e,i,e);break;case ll.UNIFORMSCALE:e=B.multiplyByUniformScale(e,n,e);break}return e};function iv(e){e=y(e,y.EMPTY_OBJECT);const t=e.articulation,n=e.sceneGraph;T.typeOf.object("options.articulation",t),T.typeOf.object("options.sceneGraph",n),this._articulation=t,this._sceneGraph=n,this._name=t.name,this._runtimeStages=[],this._runtimeStagesByName={},this._r
{
material . diffuse = mix ( material . diffuse , model _color . rgb , model _colorBlend ) ;
float highlight = ceil ( model _colorBlend ) ;
material . diffuse *= mix ( model _color . rgb , vec3 ( 1.0 ) , highlight ) ;
material . alpha *= model _color . a ;
} ` ,lg={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};lg.process=function(e,t,n){const i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,we.FRAGMENT),i.addFragmentLines(fze);const o={},r=t.color;r.alpha===0&&!t.hasSilhouette(n)&&(e.renderStateOptions.colorMask={red:!1,green:!1,blue:!1,alpha:!1}),r.alpha<1&&(e.alphaOptions.pass=Be.TRANSLUCENT),i.addUniform("vec4",lg.COLOR_UNIFORM_NAME,we.FRAGMENT),o[lg.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",lg.COLOR_BLEND_UNIFORM_NAME,we.FRAGMENT),o[lg.COLOR_BLEND_UNIFORM_NAME]=function(){return ZS.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=nn(o,e.uniformMap)};const hL=lg,dze= ` # ifdef USE _CLIPPING _PLANES _FLOAT _TEXTURE
vec4 getClippingPlane (
highp sampler2D packedClippingPlanes ,
int clippingPlaneNumber ,
mat4 transform
) {
int pixY = clippingPlaneNumber / CLIPPING _PLANES _TEXTURE _WIDTH ;
int pixX = clippingPlaneNumber - ( pixY * CLIPPING _PLANES _TEXTURE _WIDTH ) ;
float pixelWidth = 1.0 / float ( CLIPPING _PLANES _TEXTURE _WIDTH ) ;
float pixelHeight = 1.0 / float ( CLIPPING _PLANES _TEXTURE _HEIGHT ) ;
float u = ( float ( pixX ) + 0.5 ) * pixelWidth ; // sample from center of pixel
float v = ( float ( pixY ) + 0.5 ) * pixelHeight ;
vec4 plane = texture2D ( packedClippingPlanes , vec2 ( u , v ) ) ;
return czm _transformPlane ( plane , transform ) ;
}
# else
// Handle uint8 clipping texture instead
vec4 getClippingPlane (
highp sampler2D packedClippingPlanes ,
int clippingPlaneNumber ,
mat4 transform
) {
int clippingPlaneStartIndex = clippingPlaneNumber * 2 ; // clipping planes are two pixels each
int pixY = clippingPlaneStartIndex / CLIPPING _PLANES _TEXTURE _WIDTH ;
int pixX = clippingPlaneStartIndex - ( pixY * CLIPPING _PLANES _TEXTURE _WIDTH ) ;
float pixelWidth = 1.0 / float ( CLIPPING _PLANES _TEXTURE _WIDTH ) ;
float pixelHeight = 1.0 / float ( CLIPPING _PLANES _TEXTURE _HEIGHT ) ;
float u = ( float ( pixX ) + 0.5 ) * pixelWidth ; // sample from center of pixel
float v = ( float ( pixY ) + 0.5 ) * pixelHeight ;
vec4 oct32 = texture2D ( packedClippingPlanes , vec2 ( u , v ) ) * 255.0 ;
vec2 oct = vec2 ( oct32 . x * 256.0 + oct32 . y , oct32 . z * 256.0 + oct32 . w ) ;
vec4 plane ;
plane . xyz = czm _octDecode ( oct , 65535.0 ) ;
plane . w = czm _unpackFloat ( texture2D ( packedClippingPlanes , vec2 ( u + pixelWidth , v ) ) ) ;
return czm _transformPlane ( plane , transform ) ;
}
# endif
float clip ( vec4 fragCoord , sampler2D clippingPlanes , mat4 clippingPlanesMatrix ) {
vec4 position = czm _windowToEyeCoordinates ( fragCoord ) ;
vec3 clipNormal = vec3 ( 0.0 ) ;
vec3 clipPosition = vec3 ( 0.0 ) ;
float pixelWidth = czm _metersPerPixel ( position ) ;
# ifdef UNION _CLIPPING _REGIONS
float clipAmount ; // For union planes, we want to get the min distance. So we set the initial value to the first plane distance in the loop below.
# else
float clipAmount = 0.0 ;
bool clipped = true ;
# endif
for ( int i = 0 ; i < CLIPPING _PLANES _LENGTH ; ++ i ) {
vec4 clippingPlane = getClippingPlane ( clippingPlanes , i , clippingPlanesMatrix ) ;
clipNormal = clippingPlane . xyz ;
clipPosition = - clippingPlane . w * clipNormal ;
float amount = dot ( clipNormal , ( position . xyz - clipPosition ) ) / pixelWidth ;
# ifdef UNION _CLIPPING _REGIONS
clipAmount = czm _branchFreeTernary ( i == 0 , amount , min ( amount , clipAmount ) ) ;
if ( amount <= 0.0 ) {
discard ;
}
# else
clipAmount = max ( amount , clipAmount ) ;
clipped = clipped && ( amount <= 0.0 ) ;
# endif
}
# ifndef UNION _CLIPPING _REGIONS
if ( clipped ) {
discard ;
}
# endif
return clipAmount ;
}
void modelClippingPlanesStage ( inout vec4 color )
{
float clipDistance = clip ( gl _FragCoord , model _clippingPlanes , model _clippingPlanesMatrix ) ;
vec4 clippingPlanesEdgeColor = vec4 ( 1.0 ) ;
clippingPlanesEdgeColor . rgb = model _clippingPlanesEdgeStyle . rgb ;
float clippingPlanesEdgeWidth = model _clippingPlanesEdgeStyle . a ;
if ( clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth ) {
color = clippingPlanesEdgeColor ;
}
}
` ,iY={name:"ModelClippingPlanesPipelineStage"},hze=new j;iY.process=function(e,t,n){const i=t.clippingPlanes,o=n.context,r=e.shaderBuilder;r.addDefine("HAS_CLIPPING_PLANES",void 0,we.FRAGMENT),r.addDefine("CLIPPING_PLANES_LENGTH",i.length,we.FRAGMENT),i.unionClippingRegions&&r.addDefine("UNION_CLIPPING_REGIONS",void 0,we.FRAGMENT),uo.useFloatTexture(o)&&r.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,we.FRAGMENT);const s=uo.getTextureResolution(i,o,hze);r.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",s.x,we.FRAGMENT),r.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",s.y,we.FRAGMENT),r.addUniform("sampler2D","model_clippingPlanes",we.FRAGMENT),r.addUniform("vec4","model_clippingPlanesEdgeStyle",we.FRAGMENT),r.addUniform("mat4","model_clippingPlanesMatrix",we.FRAGMENT),r.addFragmentLines(dze);const a={model_clippingPlanes:function(){return i.texture},model_clippingPlanesEdgeStyle:function(){const c=F.clone(i.edgeColor);return c.alpha=i.edgeWidth,c},model_clippingPlanesMatrix:function(){return t._clippingPlanesMatrix}};e.uniformMap=nn(a,e.uniformMap)};const pze=iY;function oY(e,t){T.typeOf.object("model",e),T.typeOf.object("runtimeNode",t),this._model=e,this._runtimeNode=t}Object.defineProperties(oY.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}}});const mze= ` mat4 getInstancingTransform ( )
{
mat4 instancingTransform ;
# ifdef HAS _INSTANCE _MATRICES
instancingTransform = mat4 (
a _instancingTransformRow0 . x , a _instancingTransformRow1 . x , a _instancingTransformRow2 . x , 0.0 , // Column 1
a _instancingTransformRow0 . y , a _instancingTransformRow1 . y , a _instancingTransformRow2 . y , 0.0 , // Column 2
a _instancingTransformRow0 . z , a _instancingTransformRow1 . z , a _instancingTransformRow2 . z , 0.0 , // Column 3
a _instancingTransformRow0 . w , a _instancingTransformRow1 . w , a _instancingTransformRow2 . w , 1.0 // Column 4
) ;
# else
vec3 translation = vec3 ( 0.0 , 0.0 , 0.0 ) ;
vec3 scale = vec3 ( 1.0 , 1.0 , 1.0 ) ;
# ifdef HAS _INSTANCE _TRANSLATION
translation = a _instanceTranslation ;
# endif
# ifdef HAS _INSTANCE _SCALE
scale = a _instanceScale ;
# endif
instancingTransform = mat4 (
scale . x , 0.0 , 0.0 , 0.0 ,
0.0 , scale . y , 0.0 , 0.0 ,
0.0 , 0.0 , scale . z , 0.0 ,
translation . x , translation . y , translation . z , 1.0
) ;
# endif
return instancingTransform ;
}
# ifdef USE _2D _INSTANCING
mat4 getInstancingTransform2D ( )
{
mat4 instancingTransform2D ;
# ifdef HAS _INSTANCE _MATRICES
instancingTransform2D = mat4 (
a _instancingTransform2DRow0 . x , a _instancingTransform2DRow1 . x , a _instancingTransform2DRow2 . x , 0.0 , // Column 1
a _instancingTransform2DRow0 . y , a _instancingTransform2DRow1 . y , a _instancingTransform2DRow2 . y , 0.0 , // Column 2
a _instancingTransform2DRow0 . z , a _instancingTransform2DRow1 . z , a _instancingTransform2DRow2 . z , 0.0 , // Column 3
a _instancingTransform2DRow0 . w , a _instancingTransform2DRow1 . w , a _instancingTransform2DRow2 . w , 1.0 // Column 4
) ;
# else
vec3 translation2D = vec3 ( 0.0 , 0.0 , 0.0 ) ;
vec3 scale = vec3 ( 1.0 , 1.0 , 1.0 ) ;
# ifdef HAS _INSTANCE _TRANSLATION
translation2D = a _instanceTranslation2D ;
# endif
# ifdef HAS _INSTANCE _SCALE
scale = a _instanceScale ;
# endif
instancingTransform2D = mat4 (
scale . x , 0.0 , 0.0 , 0.0 ,
0.0 , scale . y , 0.0 , 0.0 ,
0.0 , 0.0 , scale . z , 0.0 ,
translation2D . x , translation2D . y , translation2D . z , 1.0
) ;
# endif
return instancingTransform2D ;
}
# endif
` ,_ze= ` void instancingStage ( inout ProcessedAttributes attributes )
{
vec3 positionMC = attributes . positionMC ;
mat4 instancingTransform = getInstancingTransform ( ) ;
attributes . positionMC = ( instancingTransform * vec4 ( positionMC , 1.0 ) ) . xyz ;
# ifdef HAS _NORMALS
vec3 normalMC = attributes . normalMC ;
attributes . normalMC = ( instancingTransform * vec4 ( normalMC , 0.0 ) ) . xyz ;
# endif
# ifdef USE _2D _INSTANCING
mat4 instancingTransform2D = getInstancingTransform2D ( ) ;
attributes . position2D = ( instancingTransform2D * vec4 ( positionMC , 1.0 ) ) . xyz ;
# endif
}
` ,gze= ` void legacyInstancingStage (
inout ProcessedAttributes attributes ,
out mat4 instanceModelView ,
out mat3 instanceModelViewInverseTranspose )
{
vec3 positionMC = attributes . positionMC ;
mat4 instancingTransform = getInstancingTransform ( ) ;
mat4 instanceModel = instancingTransform * u _instance _nodeTransform ;
instanceModelView = u _instance _modifiedModelView ;
instanceModelViewInverseTranspose = mat3 ( u _instance _modifiedModelView * instanceModel ) ;
attributes . positionMC = ( instanceModel * vec4 ( positionMC , 1.0 ) ) . xyz ;
# ifdef USE _2D _INSTANCING
mat4 instancingTransform2D = getInstancingTransform2D ( ) ;
attributes . position2D = ( instancingTransform2D * vec4 ( positionMC , 1.0 ) ) . xyz ;
# endif
}
` ,pE=new B,yze=new B,Aze=new B,rY={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:uY,_transformsToTypedArray:pL};rY.process=function(e,t,n){const i=t.instances,o=i.attributes[0].count,r=e.shaderBuilder;r.addDefine("HAS_INSTANCING"),r.addVertexLines(mze);const s=e.model,a=s.sceneGraph,c=e.runtimeNode,u=n.mode!==le.SCENE3D&&!n.scene3DOnly&&s._projectTo2D,f=[];Oze(e,n,i,f,u),Rze(e,n,i,f);const h={};if(i.transformInWorldSpace?(r.addDefine("USE_LEGACY_INSTANCING",void 0,we.VERTEX),r.addUniform("mat4","u_instance_modifiedModelView",we.VERTEX),r.addUniform("mat4","u_instance_nodeTransform",we.VERTEX),h.u_instance_modifiedModelView=function(){let _=B.multiplyTransformation(s.modelMatrix,a.components.transform,pE);return u?B.multiplyTransformation(n.context.uniformState.view3D,_,pE):(n.mode!==le.SCENE3D&&(_=Qt.basisTo2D(n.mapProjection,_,pE)),B.multiplyTransformation(n.context.uniformState.view,_,pE))},h.u_instance_nodeTransform=function(){return B.multiplyTransformation(a.axisCorrectionMatrix,c.computedTransform,yze)},r.addVertexLines(gze)):r.addVertexLines(_ze),u){r.addDefine("USE_2D_INSTANCING",void 0,we.VERTEX),r.addUniform("mat4","u_modelView2D",we.VERTEX);const _=n.context,g=B.fromTranslation(c.instancingReferencePoint2D,new B);h.u_modelView2D=function(){return B.multiplyTransformation(_.uniformState.view,g,Aze)}}e.uniformMap=nn(h,e.uniformMap),e.instanceCount=o,e.attributes.push.apply(e.attributes,f)};const BA=new B,Cze=new d;function Tze(e,t,n,i,o){let r=B.multiplyTransformation(t,e,BA);return r=B.multiplyTransformation(r,n,BA),o=Qt.basisTo2D(i.mapProjection,r,o),o}function bze(e,t,n,i,o){const r=B.fromTranslation(e,BA);let s=B.multiplyTransformation(t,r,BA);s=B.multiplyTransformation(s,n,BA);const a=B.getTranslation(s,Cze);return o=tr.computeActualWgs84Position(i,a,o),o}function sY(e,t,n){const i=e.model,o=i.sceneGraph;e.runtimeNode.node.instances.transformInWorldSpace?(t=B.multiplyTransformation(i.modelMatrix,o.components.transform,t),n=B.multiplyTransformation(o.axisCorrectionMatrix,e.runtimeNode.computedTransform,n)):(t=B.clone(o.computedModelMatrix,t),t=B.multiplyTransformation(t,e.runtimeNode.computedTransform,t),n=B.clone(B.IDENTITY,n))}const aY=new B,cY=new B,Eze=new B,xze=new d;function wze(e,t,n,i){const o=aY,r=cY;sY(t,o,r);const a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){const f=e[u],h=Tze(f,o,r,n,Eze),_=B.getTranslation(h,xze),g=d.subtract(_,a,_);i[u]=B.setTranslation(h,g,i[u])}return i}function Sze(e,t,n,i){const o=aY,r=cY;sY(t,o,r);const a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){const f=e[u],h=bze(f,o,r,n,f);i[u]=d.subtract(h,a,i[u])}return i}const vze=new d,Dze=new d;function lY(e,t){const n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,o=B.multiplyByPoint(i,n.instancingTranslationMin,vze),r=tr.computeActualWgs84Position(t,o,o),s=B.multiplyByPoint(i,n.instancingTranslationMax,Dze),a=tr.computeActualWgs84Position(t,s,s);n.instancingReferencePoint2D=d.lerp(r,a,.5,new d)}function pL(e){const n=e.length,i=new Float32Array(n*12);for(let o=0;o<n;o++){const 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 Ize(e){const n=e.length,i=new Float32Array(n*3);for(let o=0;o<n;o++){const r=e[o],s=3*o;i[s+0]=r[0],i[s+1]=r[4],i[s+2]=r[8]}return i}new d;new Ce;new d;function uY(e,t,n){const i=new Array(t),o=qt.getAttributeBySemantic(e,Os.TRANSLATION),r=qt.getAttributeBySemantic(e,Os.ROTATION),s=qt.getAttributeBySemantic(e,Os.SCALE),a=new d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=new d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),u=l(o),f=l(r),h=l(s),_=u?o.typedArray:new Float32Array(t*3);let g=f?r.typedArray:new Float32Array(t*4);f&&r.normalized&&(g=ni.dequantize(g,r.componentDatatype,r.type,t));let p;h?p=s.typedArray:(p=new Float32Array(t*3),p.fill(1));for(let C=0;C<t;C++){const b=new d(_[C*3],_[C*3+1],_[C*3+2]);d.maximumByComponent(a,b,a),d.minimumByComponent(c,b,c);const x=new C
{
bool styleTranslucent = ( featureColor . a != 1.0 ) ;
// Only render translucent features in the translucent pass (if the style or the original command has translucency).
if ( czm _pass == czm _passTranslucent && ! styleTranslucent && ! model _commandTranslucent )
{
// If the model has a translucent silhouette, it needs to render during the silhouette color command,
// (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
# ifdef HAS _SILHOUETTE
positionMC *= float ( model _silhouettePass ) ;
# else
positionMC *= 0.0 ;
# endif
}
// If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
else if ( czm _pass != czm _passTranslucent && styleTranslucent )
{
positionMC *= 0.0 ;
}
}
void cpuStylingStage ( inout vec3 positionMC , inout SelectedFeature feature )
{
float show = ceil ( feature . color . a ) ;
positionMC *= show ;
# if defined ( HAS _SELECTED _FEATURE _ID _ATTRIBUTE ) && ! defined ( HAS _CLASSIFICATION )
filterByPassType ( positionMC , feature . color ) ;
# endif
}
` ,Wze= ` void filterByPassType ( vec4 featureColor )
{
bool styleTranslucent = ( featureColor . a != 1.0 ) ;
// Only render translucent features in the translucent pass (if the style or the original command has translucency).
if ( czm _pass == czm _passTranslucent && ! styleTranslucent && ! model _commandTranslucent )
{
// If the model has a translucent silhouette, it needs to render during the silhouette color command,
// (i.e. the command where model_silhouettePass = true), even if the model isn't translucent.
# ifdef HAS _SILHOUETTE
if ( ! model _silhouettePass ) {
discard ;
}
# else
discard ;
# endif
}
// If the current pass is not the translucent pass and the style is not translucent, don't render the feature.
else if ( czm _pass != czm _passTranslucent && styleTranslucent )
{
discard ;
}
}
void cpuStylingStage ( inout czm _modelMaterial material , SelectedFeature feature )
{
vec4 featureColor = feature . color ;
if ( featureColor . a == 0.0 )
{
discard ;
}
// If a feature ID vertex attribute is used, the pass type filter is applied in the vertex shader.
// So, we only apply in in the fragment shader if the feature ID texture is used.
# if defined ( HAS _SELECTED _FEATURE _ID _TEXTURE ) && ! defined ( HAS _CLASSIFICATION )
filterByPassType ( featureColor ) ;
# endif
featureColor = czm _gammaCorrect ( featureColor ) ;
// Classification models compute the diffuse differently.
# ifdef HAS _CLASSIFICATION
material . diffuse = featureColor . rgb * featureColor . a ;
# else
float highlight = ceil ( model _colorBlend ) ;
material . diffuse *= mix ( featureColor . rgb , vec3 ( 1.0 ) , highlight ) ;
# endif
material . alpha *= featureColor . a ;
}
` ,yY={name:"CPUStylingPipelineStage"};yY.process=function(e,t,n){const i=e.model,o=e.shaderBuilder;o.addVertexLines(Gze),o.addFragmentLines(Wze),o.addDefine("USE_CPU_STYLING",void 0,we.BOTH),l(i.color)||(o.addUniform("float",hL.COLOR_BLEND_UNIFORM_NAME,we.FRAGMENT),e.uniformMap[hL.COLOR_BLEND_UNIFORM_NAME]=function(){return ZS.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),o.addUniform("bool","model_commandTranslucent",we.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===Be.TRANSLUCENT}};const jze=yY,AY={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};AY.getDefineName=function(e){return ` CUSTOM _SHADER _$ { e } ` };const bN=Object.freeze(AY),qze= ` void customShaderStage (
inout czm _modelVertexOutput vsOutput ,
inout ProcessedAttributes attributes ,
FeatureIds featureIds ,
Metadata metadata ,
MetadataClass metadataClass ,
MetadataStatistics metadataStatistics
) {
// VertexInput and initializeInputStruct() are dynamically generated in JS,
// see CustomShaderPipelineStage.js
VertexInput vsInput ;
initializeInputStruct ( vsInput , attributes ) ;
vsInput . featureIds = featureIds ;
vsInput . metadata = metadata ;
vsInput . metadataClass = metadataClass ;
vsInput . metadataStatistics = metadataStatistics ;
vertexMain ( vsInput , vsOutput ) ;
attributes . positionMC = vsOutput . positionMC ;
}
` ,Yze= ` void customShaderStage (
inout czm _modelMaterial material ,
ProcessedAttributes attributes ,
FeatureIds featureIds ,
Metadata metadata ,
MetadataClass metadataClass ,
MetadataStatistics metadataStatistics
) {
// FragmentInput and initializeInputStruct() are dynamically generated in JS,
// see CustomShaderPipelineStage.js
FragmentInput fsInput ;
initializeInputStruct ( fsInput , attributes ) ;
fsInput . featureIds = featureIds ;
fsInput . metadata = metadata ;
fsInput . metadataClass = metadataClass ;
fsInput . metadataStatistics = metadataStatistics ;
fragmentMain ( fsInput , material ) ;
}
` ,Xze= ` void featureIdStage ( out FeatureIds featureIds , ProcessedAttributes attributes ) {
initializeFeatureIds ( featureIds , attributes ) ;
initializeFeatureIdAliases ( featureIds ) ;
}
` , $ ze= ` void featureIdStage ( out FeatureIds featureIds , ProcessedAttributes attributes )
{
initializeFeatureIds ( featureIds , attributes ) ;
initializeFeatureIdAliases ( featureIds ) ;
setFeatureIdVaryings ( ) ;
}
` ,Kn={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()"};Kn.process=function(e,t,n){const i=e.shaderBuilder;Kze(i);const o=e.runtimeNode.node.instances;l(o)&&Jze(e,o,n),Qze(e,t,n),i.addVertexLines( $ ze),i.addFragmentLines(Xze)};function Kze(e){e.addStruct(Kn.STRUCT_ID_FEATURE_IDS_VS,Kn.STRUCT_NAME_FEATURE_IDS,we.VERTEX),e.addStruct(Kn.STRUCT_ID_FEATURE_IDS_FS,Kn.STRUCT_NAME_FEATURE_IDS,we.FRAGMENT),e.addFunction(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,Kn.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,we.VERTEX),e.addFunction(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,Kn.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,we.FRAGMENT),e.addFunction(Kn.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,Kn.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,we.VERTEX),e.addFunction(Kn.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,Kn.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,we.FRAGMENT),e.addFunction(Kn.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,Kn.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,we.VERTEX)}function Jze(e,t,n){const i=t.featureIds,o=t.attributes[0].count;for(let r=0;r<i.length;r++){const s=i[r],a=s.positionalLabel;s instanceof St.FeatureIdAttribute?Zze(e,s,a):CY(e,s,a,o,1,n);const c=s.label;l(c)&&TY(e,a,c,we.BOTH)}}function Qze(e,t,n){const i=t.featureIds,r=qt.getAttributeBySemantic(t,Tt.POSITION).count;for(let s=0;s<i.length;s++){const a=i[s],c=a.positionalLabel;let u=we.BOTH;a instanceof St.FeatureIdAttribute?eUe(e,a,c):a instanceof St.FeatureIdImplicitRange?CY(e,a,c,r,void 0,n):(tUe(e,a,c,s,n),u=we.FRAGMENT);const f=a.label;l(f)&&TY(e,c,f,u)}}function Zze(e,t,n){const i=e.shaderBuilder;i.addStructField(Kn.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(Kn.STRUCT_ID_FEATURE_IDS_FS,"int",n);const o=t.setIndex,r=n.replace(/_ \d + $ /,"_"),s= ` a _$ { r } $ { o } ` ,a= ` v _$ { r } $ { o } ` ,c= ` featureIds . $ { n } = int ( czm _round ( $ { s } ) ) ; ` ,u= ` featureIds . $ { n } = int ( czm _round ( $ { a } ) ) ; ` ;i.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[u]),i.addVarying("float",a),i.addFunctionLines(Kn.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[ ` $ { a } = $ { s } ; ` ])}function eUe(e,t,n){const i=e.shaderBuilder;i.addStructField(Kn.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(Kn.STRUCT_ID_FEATURE_IDS_FS,"int",n);const o=t.setIndex,r=n.replace(/_ \d + $ /,"_"),s=[ ` featureIds . $ { n } = int ( czm _round ( attributes . $ { r } $ { o } ) ) ; ` ];i.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,s),i.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,s)}function CY(e,t,n,i,o,r){nUe(e,t,i,o,r);const s=e.shaderBuilder,a= ` a _implicit _$ { n } ` ;s.addAttribute("float",a);const c= ` v _implicit _$ { n } ` ;s.addVarying("float",c),s.addStructField(Kn.STRUCT_ID_FEATURE_IDS_VS,"int",n),s.addStructField(Kn.STRUCT_ID_FEATURE_IDS_FS,"int",n),s.addFunctionLines(Kn.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[ ` $ { c } = $ { a } ; ` ]),s.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[ ` featureIds . $ { n } = int ( czm _round ( $ { a } ) ) ; ` ]),s.addFunctionLines(Kn.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[ ` featureIds . $ { n } = int ( czm _round ( $ { c } ) ) ; ` ])}function tUe(e,t,n,i,o){const r= ` u _featureIdTexture _$ { i } ` ,s=e.uniformMap,a=t.textureReader;s[r]=function(){return y(a.texture,o.context.defaultTexture)};const c=a.channels,u=e.shaderBuilder;u.addStructField(Kn.STRUCT_ID_FEATURE_IDS_FS,"int",n),u.addUniform("sampler2D",r,we.FRAGMENT);const f= ` v _texCoord _$ { a . texCo
out Metadata metadata ,
out MetadataClass metadataClass ,
out MetadataStatistics metadataStatistics ,
ProcessedAttributes attributes
)
{
initializeMetadata ( metadata , metadataClass , metadataStatistics , attributes ) ;
}
` ,rUe= ` void metadataStage (
out Metadata metadata ,
out MetadataClass metadataClass ,
out MetadataStatistics metadataStatistics ,
ProcessedAttributes attributes
)
{
initializeMetadata ( metadata , metadataClass , metadataStatistics , attributes ) ;
setMetadataVaryings ( ) ;
}
` ,Gn={name:"MetadataPipelineStage",STRUCT_ID_METADATA_VS:"MetadataVS",STRUCT_ID_METADATA_FS:"MetadataFS",STRUCT_NAME_METADATA:"Metadata",STRUCT_ID_METADATA_CLASS_VS:"MetadataClassVS",STRUCT_ID_METADATA_CLASS_FS:"MetadataClassFS",STRUCT_NAME_METADATA_CLASS:"MetadataClass",STRUCT_ID_METADATA_STATISTICS_VS:"MetadataStatisticsVS",STRUCT_ID_METADATA_STATISTICS_FS:"MetadataStatisticsFS",STRUCT_NAME_METADATA_STATISTICS:"MetadataStatistics",FUNCTION_ID_INITIALIZE_METADATA_VS:"initializeMetadataVS",FUNCTION_ID_INITIALIZE_METADATA_FS:"initializeMetadataFS",FUNCTION_SIGNATURE_INITIALIZE_METADATA:"void initializeMetadata(out Metadata metadata, out MetadataClass metadataClass, out MetadataStatistics metadataStatistics, ProcessedAttributes attributes)",FUNCTION_ID_SET_METADATA_VARYINGS:"setMetadataVaryings",FUNCTION_SIGNATURE_SET_METADATA_VARYINGS:"void setMetadataVaryings()",METADATA_CLASS_FIELDS:[{specName:"noData",shaderName:"noData"},{specName:"default",shaderName:"defaultValue"},{specName:"min",shaderName:"minValue"},{specName:"max",shaderName:"maxValue"}],METADATA_STATISTICS_FIELDS:[{specName:"min",shaderName:"minValue"},{specName:"max",shaderName:"maxValue"},{specName:"mean",shaderName:"mean",type:"float"},{specName:"median",shaderName:"median"},{specName:"standardDeviation",shaderName:"standardDeviation",type:"float"},{specName:"variance",shaderName:"variance",type:"float"},{specName:"sum",shaderName:"sum"}]};Gn.process=function(e,t,n){var h;const{shaderBuilder:i,model:o}=e,{structuralMetadata:r={},content:s}=o,a=(h=s==null?void 0:s.tileset.metadataExtension)==null?void 0:h.statistics,c=sUe(r.propertyAttributes,t,a),u=cUe(r.propertyTextures,a),f=c.concat(u);uUe(i,f),hUe(i),i.addVertexLines(rUe),i.addFragmentLines(oUe);for(let _=0;_<c.length;_++){const g=c[_];pUe(e,g)}for(let _=0;_<u.length;_++){const g=u[_];_Ue(e,g)}};function sUe(e,t,n){return l(e)?e.flatMap(i=>aUe(i,t,n)):[]}function aUe(e,t,n){const{getAttributeByName:i,getAttributeInfo:o,sanitizeGlslIdentifier:r}=qt,s=e.class.id,a=n==null?void 0:n.classes[s],c=Object.entries(e.properties),u=new Array(c.length);for(let f=0;f<c.length;f++){const[h,_]=c[f],g=i(t,_.attribute),{glslType:p,variableName:A}=o(g);u[f]={metadataVariable:r(h),property:_,type:_.classProperty.type,glslType:p,variableName:A,propertyStatistics:a==null?void 0:a.properties[h],shaderDestination:we.BOTH}}return u}function cUe(e,t){return l(e)?e.flatMap(n=>lUe(n,t)):[]}function lUe(e,t){const{sanitizeGlslIdentifier:n}=qt,i=e.class.id,o=t==null?void 0:t.classes[i],r=Object.entries(e.properties).filter(([a,c])=>c.isGpuCompatible()),s=new Array(r.length);for(let a=0;a<r.length;a++){const[c,u]=r[a];s[a]={metadataVariable:n(c),property:u,type:u.classProperty.type,glslType:u.getGlslType(),propertyStatistics:o==null?void 0:o.properties[c],shaderDestination:we.FRAGMENT}}return s}function uUe(e,t){const n=new Set,i=new Set;for(let a=0;a<t.length;a++){const{type:c,glslType:u,propertyStatistics:f}=t[a];n.add(u),l(f)&&c!==Dt.ENUM&&i.add(u)}const o=Gn.METADATA_CLASS_FIELDS;for(const a of n){const c= ` $ { a } MetadataClass ` ;s(c,a,o)}const r=Gn.METADATA_STATISTICS_FIELDS;for(const a of i){const c= ` $ { a } MetadataStatistics ` ;s(c,a,r)}function s(a,c,u){e.addStruct(a,a,we.BOTH);for(let f=0;f<u.length;f++){const{shaderName:h}=u[f],_=u[f].type==="float"?dUe(c):c;e.addStructField(a,_,h)}}}const fUe={int:"float",ivec2:"vec2",ivec3:"vec3",ivec4:"vec4"};function dUe(e){const t=fUe[e];return l(t)?t:e}function hUe(e){e.addStruct(Gn.STRUCT_ID_METADATA_VS,Gn.STRUCT_NAME_METADATA,we.VERTEX),e.addStruct(Gn.STRUCT_ID_METADATA_FS,Gn.STRUCT_NAME_METADATA,we.FRAGMENT),e.addStruct(Gn.STRUCT_ID_METADATA_CLASS_VS,Gn.STRUCT_NAME_METADATA_CLASS,we.VERTEX),e.addStruct(Gn.STRUCT_ID_METADATA_CLASS_FS,Gn.STRUCT_NAME_METADATA_CLASS,we.FRAGMENT),e.addStruct(Gn.STRUCT_ID_METADATA_STATISTICS_VS,Gn.STRUCT_NAME_METADATA_STATISTICS,we.VERTEX),e.addStruct(Gn.STRUCT_ID_METADATA_STATISTICS_FS,Gn.STRUCT_NAME_METADATA_STATISTICS,we.FRAGMENT),e.addFunction(Gn.FUNCTION_ID_INITIALIZE_METADATA_VS,Gn.FUNCTION_SIGNATURE_INITIALIZE_METADATA,we.VERTEX),e.addFunction(Gn.FUNCTION
{
attributes . positionMC = v _positionMC ;
attributes . positionEC = v _positionEC ;
# ifdef COMPUTE _POSITION _WC _CUSTOM _SHADER
attributes . positionWC = v _positionWC ;
# endif
# ifdef HAS _NORMALS
// renormalize after interpolation
attributes . normalEC = normalize ( v _normalEC ) ;
# endif
# ifdef HAS _TANGENTS
attributes . tangentEC = normalize ( v _tangentEC ) ;
# endif
# ifdef HAS _BITANGENTS
attributes . bitangentEC = normalize ( v _bitangentEC ) ;
# endif
// Everything else is dynamically generated in GeometryPipelineStage
setDynamicVaryings ( attributes ) ;
}
` ,zUe= ` vec4 geometryStage ( inout ProcessedAttributes attributes , mat4 modelView , mat3 normal )
{
vec4 computedPosition ;
// Compute positions in different coordinate systems
vec3 positionMC = attributes . positionMC ;
v _positionMC = positionMC ;
v _positionEC = ( modelView * vec4 ( positionMC , 1.0 ) ) . xyz ;
# if defined ( USE _2D _POSITIONS ) || defined ( USE _2D _INSTANCING )
vec3 position2D = attributes . position2D ;
vec3 positionEC = ( u _modelView2D * vec4 ( position2D , 1.0 ) ) . xyz ;
computedPosition = czm _projection * vec4 ( positionEC , 1.0 ) ;
# else
computedPosition = czm _projection * vec4 ( v _positionEC , 1.0 ) ;
# endif
// Sometimes the custom shader and/or style needs this
# if defined ( COMPUTE _POSITION _WC _CUSTOM _SHADER ) || defined ( COMPUTE _POSITION _WC _STYLE )
// Note that this is a 32-bit position which may result in jitter on small
// scales.
v _positionWC = ( czm _model * vec4 ( positionMC , 1.0 ) ) . xyz ;
# endif
# ifdef HAS _NORMALS
v _normalEC = normalize ( normal * attributes . normalMC ) ;
# endif
# ifdef HAS _TANGENTS
v _tangentEC = normalize ( normal * attributes . tangentMC ) ;
# endif
# ifdef HAS _BITANGENTS
v _bitangentEC = normalize ( normal * attributes . bitangentMC ) ;
# endif
// All other varyings need to be dynamically generated in
// GeometryPipelineStage
setDynamicVaryings ( attributes ) ;
return computedPosition ;
}
` ,sV= ` vec2 computeSt ( float featureId )
{
float stepX = model _textureStep . x ;
float centerX = model _textureStep . y ;
# ifdef MULTILINE _BATCH _TEXTURE
float stepY = model _textureStep . z ;
float centerY = model _textureStep . w ;
float xId = mod ( featureId , model _textureDimensions . x ) ;
float yId = floor ( featureId / model _textureDimensions . x ) ;
return vec2 ( centerX + ( xId * stepX ) , centerY + ( yId * stepY ) ) ;
# else
return vec2 ( centerX + ( featureId * stepX ) , 0.5 ) ;
# endif
}
void selectedFeatureIdStage ( out SelectedFeature feature , FeatureIds featureIds )
{
int featureId = featureIds . SELECTED _FEATURE _ID ;
if ( featureId < model _featuresLength )
{
vec2 featureSt = computeSt ( float ( featureId ) ) ;
feature . id = featureId ;
feature . st = featureSt ;
feature . color = texture2D ( model _batchTexture , featureSt ) ;
}
// Floating point comparisons can be unreliable in GLSL, so we
// increment the feature ID to make sure it's always greater
// then the model_featuresLength - a condition we check for in the
// pick ID, to avoid sampling the pick texture if the feature ID is
// greater than the number of features.
else
{
feature . id = model _featuresLength + 1 ;
feature . st = vec2 ( 0.0 ) ;
feature . color = vec4 ( 1.0 ) ;
}
# ifdef HAS _NULL _FEATURE _ID
if ( featureId == model _nullFeatureId ) {
feature . id = featureId ;
feature . st = vec2 ( 0.0 ) ;
feature . color = vec4 ( 1.0 ) ;
}
# endif
}
` ,NA={name:"SelectedFeatureIdPipelineStage",STRUCT_ID_SELECTED_FEATURE:"SelectedFeature",STRUCT_NAME_SELECTED_FEATURE:"SelectedFeature",FUNCTION_ID_FEATURE_VARYINGS_VS:"updateFeatureStructVS",FUNCTION_ID_FEATURE_VARYINGS_FS:"updateFeatureStructFS",FUNCTION_SIGNATURE_UPDATE_FEATURE:"void updateFeatureStruct(inout SelectedFeature feature)"};NA.process=function(e,t,n){const i=e.shaderBuilder;e.hasPropertyTable=!0;const o=e.model,r=e.runtimeNode.node,s=UUe(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),HUe(i);const c=s.featureIds.nullFeatureId,u=e.uniformMap;l(c)&&(i.addDefine("HAS_NULL_FEATURE_ID",void 0,a),i.addUniform("int","model_nullFeatureId",a),u.model_nullFeatureId=function(){return c}),s.shaderDestination===we.BOTH&&i.addVertexLines(sV),i.addFragmentLines(sV)};function aV(e){return e instanceof St.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function cV(e){return e instanceof St.FeatureIdTexture?we.FRAGMENT:we.BOTH}function UUe(e,t,n){let i,o;return l(t.instances)&&(o=qt.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),l(o))?(i=y(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:cV(o),featureIdDefine:aV(o)}):(o=qt.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=y(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:cV(o),featureIdDefine:aV(o)})}function HUe(e){e.addStructField(NA.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(NA.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(NA.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}const gL=NA,Er={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)"};Er.process=function(e,t,n){const i=e.shaderBuilder,o=e.model;i.addStruct(Er.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",we.VERTEX),i.addStruct(Er.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",we.FRAGMENT),i.addStruct(gL.STRUCT_ID_SELECTED_FEATURE,gL.STRUCT_NAME_SELECTED_FEATURE,we.BOTH),i.addFunction(Er.FUNCTION_ID_INITIALIZE_ATTRIBUTES,Er.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,we.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(Er.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(Er.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(Er.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,Er.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,we.VERTEX),i.addFunction(Er.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,Er.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,we.FRAGMENT),o.type===Ws.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,we.FRAGMENT);const s=n.mode!==le.SCENE3D&&!n.scene3DOnly&&o._projectTo2D,a=l(e.runtimeNode.node.instances),c=s&&!a,u=t.attributes.length;for(let f=0;f<u;f++){const h=t.attributes[f],_=sn.getAttributeLocationCount(h.type);if(!l(h.buffer)&&!l(h.constant))throw new E("Attributes must be provided as a Buffer or constant value");const g=h.semantic===Tt.POSITION;let p;_>1?(p=e.attributeIndex,e.attributeIndex+=_):g&&!c?p=0:p=e.attributeIndex++,VUe(e,h,p,_,s,a)}KUe(i,t.attributes),t.primitiveType===Je.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines(zUe),i.addFragmentLines(FUe)};function VUe(e,t,n,i,o,r){const s=e.shaderBuilder,a=qt.getAttributeInfo(t),c=o&&!r;i>1?WUe(e,t,n,i):GUe(e,t,n,c),qUe(s,a,c),jUe(s,a),l(t.semantic)&&kUe(s,t),YUe(s,a,o),XUe(s,a,c), $ Ue(s,a)}function kUe(e,t){const n=t.semantic,i=t.setIndex;switch(n){case Tt.NORMAL:e.addDefine("HAS_NORMAL
vec3 computePbrLighting ( czm _modelMaterial inputMaterial , ProcessedAttributes attributes )
{
czm _pbrParameters pbrParameters ;
pbrParameters . diffuseColor = inputMaterial . diffuse ;
pbrParameters . f0 = inputMaterial . specular ;
pbrParameters . roughness = inputMaterial . roughness ;
# ifdef USE _CUSTOM _LIGHT _COLOR
vec3 lightColorHdr = model _lightColorHdr ;
# else
vec3 lightColorHdr = czm _lightColorHdr ;
# endif
vec3 color = inputMaterial . diffuse ;
# ifdef HAS _NORMALS
color = czm _pbrLighting (
attributes . positionEC ,
inputMaterial . normalEC ,
czm _lightDirectionEC ,
lightColorHdr ,
pbrParameters
) ;
# ifdef USE _IBL _LIGHTING
color += imageBasedLightingStage (
attributes . positionEC ,
inputMaterial . normalEC ,
czm _lightDirectionEC ,
lightColorHdr ,
pbrParameters
) ;
# endif
# endif
color *= inputMaterial . occlusion ;
color += inputMaterial . emissive ;
// In HDR mode, the frame buffer is in linear color space. The
// post-processing stages (see PostProcessStageCollection) will handle
// tonemapping. However, if HDR is not enabled, we must tonemap else large
// values may be clamped to 1.0
# ifndef HDR
color = czm _acesTonemapping ( color ) ;
# endif
return color ;
}
# endif
void lightingStage ( inout czm _modelMaterial material , ProcessedAttributes attributes )
{
// Even though the lighting will only set the diffuse color,
// pass all other properties so further stages have access to them.
vec3 color = vec3 ( 0.0 ) ;
# ifdef LIGHTING _PBR
color = computePbrLighting ( material , attributes ) ;
# else // unlit
color = material . diffuse ;
# endif
# ifdef HAS _POINT _CLOUD _COLOR _STYLE
// The colors resulting from point cloud styles are adjusted differently.
color = czm _gammaCorrect ( color ) ;
# elif ! defined ( HDR )
// If HDR is not enabled, the frame buffer stores sRGB colors rather than
// linear colors so the linear value must be converted.
color = czm _linearToSrgb ( color ) ;
# endif
material . diffuse = color ;
}
` ,ZUe={UNLIT:0,PBR:1},Lw=Object.freeze(ZUe),DY={name:"LightingPipelineStage"};DY.process=function(e,t){const n=e.model,i=e.lightingOptions,o=e.shaderBuilder;if(l(n.lightColor)){o.addDefine("USE_CUSTOM_LIGHT_COLOR",void 0,we.FRAGMENT),o.addUniform("vec3","model_lightColorHdr",we.FRAGMENT);const s=e.uniformMap;s.model_lightColorHdr=function(){return n.lightColor}}i.lightingModel===Lw.PBR?o.addDefine("LIGHTING_PBR",void 0,we.FRAGMENT):o.addDefine("LIGHTING_UNLIT",void 0,we.FRAGMENT),o.addFragmentLines(QUe)};const eHe=DY,tHe= ` // If the style color is white, it implies the feature has not been styled.
bool isDefaultStyleColor ( vec3 color )
{
return all ( greaterThan ( color , vec3 ( 1.0 - czm _epsilon3 ) ) ) ;
}
vec3 blend ( vec3 sourceColor , vec3 styleColor , float styleColorBlend )
{
vec3 blendColor = mix ( sourceColor , styleColor , styleColorBlend ) ;
vec3 color = isDefaultStyleColor ( styleColor . rgb ) ? sourceColor : blendColor ;
return color ;
}
vec2 computeTextureTransform ( vec2 texCoord , mat3 textureTransform )
{
return vec2 ( textureTransform * vec3 ( texCoord , 1.0 ) ) ;
}
# ifdef HAS _NORMALS
vec3 computeNormal ( ProcessedAttributes attributes )
{
// Geometry normal. This is already normalized
vec3 ng = attributes . normalEC ;
vec3 normal = ng ;
# if defined ( HAS _NORMAL _TEXTURE ) && ! defined ( HAS _WIREFRAME )
vec2 normalTexCoords = TEXCOORD _NORMAL ;
# ifdef HAS _NORMAL _TEXTURE _TRANSFORM
normalTexCoords = computeTextureTransform ( normalTexCoords , u _normalTextureTransform ) ;
# endif
// If HAS_BITANGENTS is set, then HAS_TANGENTS is also set
# ifdef HAS _BITANGENTS
vec3 t = attributes . tangentEC ;
vec3 b = attributes . bitangentEC ;
mat3 tbn = mat3 ( t , b , ng ) ;
vec3 n = texture2D ( u _normalTexture , normalTexCoords ) . rgb ;
normal = normalize ( tbn * ( 2.0 * n - 1.0 ) ) ;
# elif defined ( GL _OES _standard _derivatives )
// Compute tangents
vec3 positionEC = attributes . positionEC ;
vec3 pos _dx = dFdx ( positionEC ) ;
vec3 pos _dy = dFdy ( positionEC ) ;
vec3 tex _dx = dFdx ( vec3 ( normalTexCoords , 0.0 ) ) ;
vec3 tex _dy = dFdy ( vec3 ( normalTexCoords , 0.0 ) ) ;
vec3 t = ( tex _dy . t * pos _dx - tex _dx . t * pos _dy ) / ( tex _dx . s * tex _dy . t - tex _dy . s * tex _dx . t ) ;
t = normalize ( t - ng * dot ( ng , t ) ) ;
vec3 b = normalize ( cross ( ng , t ) ) ;
mat3 tbn = mat3 ( t , b , ng ) ;
vec3 n = texture2D ( u _normalTexture , normalTexCoords ) . rgb ;
normal = normalize ( tbn * ( 2.0 * n - 1.0 ) ) ;
# endif
# endif
# ifdef HAS _DOUBLE _SIDED _MATERIAL
if ( czm _backFacing ( ) ) {
normal = - normal ;
}
# endif
return normal ;
}
# endif
void materialStage ( inout czm _modelMaterial material , ProcessedAttributes attributes , SelectedFeature feature )
{
# ifdef HAS _NORMALS
material . normalEC = computeNormal ( attributes ) ;
# endif
vec4 baseColorWithAlpha = vec4 ( 1.0 ) ;
// Regardless of whether we use PBR, set a base color
# ifdef HAS _BASE _COLOR _TEXTURE
vec2 baseColorTexCoords = TEXCOORD _BASE _COLOR ;
# ifdef HAS _BASE _COLOR _TEXTURE _TRANSFORM
baseColorTexCoords = computeTextureTransform ( baseColorTexCoords , u _baseColorTextureTransform ) ;
# endif
baseColorWithAlpha = czm _srgbToLinear ( texture2D ( u _baseColorTexture , baseColorTexCoords ) ) ;
# ifdef HAS _BASE _COLOR _FACTOR
baseColorWithAlpha *= u _baseColorFactor ;
# endif
# elif defined ( HAS _BASE _COLOR _FACTOR )
baseColorWithAlpha = u _baseColorFactor ;
# endif
# ifdef HAS _POINT _CLOUD _COLOR _STYLE
baseColorWithAlpha = v _pointCloudColor ;
# elif defined ( HAS _COLOR _0 )
vec4 color = attributes . color _0 ;
// .pnts files store colors in the sRGB color space
# ifdef HAS _SRGB _COLOR
color = czm _srgbToLinear ( color ) ;
# endif
baseColorWithAlpha *= color ;
# endif
material . diffuse = baseColorWithAlpha . rgb ;
material . alpha = baseColorWithAlpha . a ;
# ifdef USE _CPU _STYLING
material . diffuse = blend ( material . diffuse , feature . color . rgb , model _colorBlend ) ;
# endif
# ifdef HAS _OCCLUSION _TEXTURE
vec2 occlusionTexCoords = TEXCOORD _OCCLUSION ;
# ifdef HAS _OCCLUSION _TEXTURE _TRANSFORM
occlusionTexCoords = computeTextureTransform ( occlusionTexCoords , u _occlusionTextureTransform ) ;
# endif
material . occlusion = texture2D ( u _occlusionTexture , occlusionTexCoords ) . r ;
# endif
# ifdef HAS _EMISSIVE _TEXTURE
vec2 emissiveTexCoords = TEXCOORD _EMISSIVE ;
# ifdef HAS _EMISSIVE _TEXTURE _TRANSFORM
emissiveTexCoords = computeTextureTransform ( emissiveTexCoords , u _emissiveTextureTransform ) ;
# endif
vec3 emissive = czm _srgbToLinear ( texture2D ( u _emissiveTexture , emissiveTexCoords ) . rgb ) ;
# ifdef HAS _EMISSIVE _FACTOR
emissive *= u _emissiveFactor ;
# endif
material . emissive = emissive ;
# elif defined ( HAS _EMISSIVE _FACTOR )
material . emissive = u _emissiveFactor ;
# endif
# if defined ( LIGHTING _PBR ) && defined ( USE _SPECULAR _GLOSSINESS )
# ifdef HAS _SPECULAR _GLOSSINESS _TEXTURE
vec2 specularGlossinessTexCoords = TEXCOORD _SPECULAR _GLOSSINESS ;
# ifdef HAS _SPECULAR _GLOSSINESS _TEXTURE _TRANSFORM
specularGlossinessTexCoords = computeTextureTransform ( specularGlossinessTexCoords , u _specularGlossinessTextureTransform ) ;
# endif
vec4 specularGlossiness = czm _srgbToLinear ( texture2D ( u _specularGlossinessTexture , specularGlossinessTexCoords ) ) ;
vec3 specular = specularGlossiness . rgb ;
float glossiness = specularGlossiness . a ;
# ifdef HAS _SPECULAR _FACTOR
specular *= u _specularFactor ;
# endif
# ifdef HAS _GLOSSINESS _FACTOR
glossiness *= u _glossinessFactor ;
# endif
# else
# ifdef HAS _SPECULAR _FACTOR
vec3 specular = clamp ( u _specularFactor , vec3 ( 0.0 ) , vec3 ( 1.0 ) ) ;
# else
vec3 specular = vec3 ( 1.0 ) ;
# endif
# ifdef HAS _GLOSSINESS _FACTOR
float glossiness = clamp ( u _glossinessFactor , 0.0 , 1.0 ) ;
# else
float glossiness = 1.0 ;
# endif
# endif
# ifdef HAS _DIFFUSE _TEXTURE
vec2 diffuseTexCoords = TEXCOORD _DIFFUSE ;
# ifdef HAS _DIFFUSE _TEXTURE _TRANSFORM
diffuseTexCoords = computeTextureTransform ( diffuseTexCoords , u _diffuseTextureTransform ) ;
# endif
vec4 diffuse = czm _srgbToLinear ( texture2D ( u _diffuseTexture , diffuseTexCoords ) ) ;
# ifdef HAS _DIFFUSE _FACTOR
diffuse *= u _diffuseFactor ;
# endif
# elif defined ( HAS _DIFFUSE _FACTOR )
vec4 diffuse = clamp ( u _diffuseFactor , vec4 ( 0.0 ) , vec4 ( 1.0 ) ) ;
# else
vec4 diffuse = vec4 ( 1.0 ) ;
# endif
czm _pbrParameters parameters = czm _pbrSpecularGlossinessMaterial (
diffuse . rgb ,
specular ,
glossiness
) ;
material . diffuse = parameters . diffuseColor ;
// the specular glossiness extension's alpha overrides anything set
// by the base material.
material . alpha = diffuse . a ;
material . specular = parameters . f0 ;
material . roughness = parameters . roughness ;
# elif defined ( LIGHTING _PBR )
# ifdef HAS _METALLIC _ROUGHNESS _TEXTURE
vec2 metallicRoughnessTexCoords = TEXCOORD _METALLIC _ROUGHNESS ;
# ifdef HAS _METALLIC _ROUGHNESS _TEXTURE _TRANSFORM
metallicRoughnessTexCoords = computeTextureTransform ( metallicRoughnessTexCoords , u _metallicRoughnessTextureTransform ) ;
# endif
vec3 metallicRoughness = texture2D ( u _metallicRoughnessTexture , metallicRoughnessTexCoords ) . rgb ;
float metalness = clamp ( metallicRoughness . b , 0.0 , 1.0 ) ;
float roughness = clamp ( metallicRoughness . g , 0.04 , 1.0 ) ;
# ifdef HAS _METALLIC _FACTOR
metalness *= u _metallicFactor ;
# endif
# ifdef HAS _ROUGHNESS _FACTOR
roughness *= u _roughnessFactor ;
# endif
# else
# ifdef HAS _METALLIC _FACTOR
float metalness = clamp ( u _metallicFactor , 0.0 , 1.0 ) ;
# else
float metalness = 1.0 ;
# endif
# ifdef HAS _ROUGHNESS _FACTOR
float roughness = clamp ( u _roughnessFactor , 0.04 , 1.0 ) ;
# else
float roughness = 1.0 ;
# endif
# endif
czm _pbrParameters parameters = czm _pbrMetallicRoughnessMaterial (
material . diffuse ,
metalness ,
roughness
) ;
material . diffuse = parameters . diffuseColor ;
material . specular = parameters . f0 ;
material . roughness = parameters . roughness ;
# endif
}
` ,nHe=St.Material,uP=St.MetallicRoughness,fP=St.SpecularGlossiness,IY={name:"MaterialPipelineStage",_processTexture:Oh,_processTextureTransform:PY};IY.process=function(e,t,n){const i=t.material,o=e.model,r=l(o.classificationType),s=r,a=e.uniformMap,c=e.shaderBuilder,u=n.context.defaultTexture,f=n.context.defaultNormalTexture,h=n.context.defaultEmissiveTexture;iHe(i,a,c,u,f,h,s),l(i.specularGlossiness)?oHe(i,a,c,u,s):rHe(i,a,c,u,s);const _=qt.getAttributeBySemantic(t,Tt.NORMAL),g=e.lightingOptions;i.unlit||!_||r?g.lightingModel=Lw.UNLIT:g.lightingModel=Lw.PBR;const p=o.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=p;const A=e.alphaOptions;i.alphaMode===ww.BLEND?A.pass=Be.TRANSLUCENT:i.alphaMode===ww.MASK&&(A.alphaCutoff=i.alphaCutoff),c.addFragmentLines(tHe),i.doubleSided&&c.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,we.BOTH)};function PY(e,t,n,i,o){const r= ` HAS _$ { o } _TEXTURE _TRANSFORM ` ;e.addDefine(r,void 0,we.FRAGMENT);const s= ` $ { i } Transform ` ;e.addUniform("mat3",s,we.FRAGMENT),t[s]=function(){return n.transform}}function Oh(e,t,n,i,o,r){e.addUniform("sampler2D",i,we.FRAGMENT),t[i]=function(){return y(n.texture,r)};const s= ` HAS _$ { o } _TEXTURE ` ;e.addDefine(s,void 0,we.FRAGMENT);const c= ` v _texCoord _$ { n . texCoord } ` ,u= ` TEXCOORD _$ { o } ` ;e.addDefine(u,c,we.FRAGMENT);const f=n.transform;l(f)&&!J.equals(f,J.IDENTITY)&&PY(e,t,n,i,o)}function iHe(e,t,n,i,o,r,s){const a=e.emissiveTexture;l(a)&&!s&&Oh(n,t,a,"u_emissiveTexture","EMISSIVE",r);const c=e.emissiveFactor;l(c)&&!d.equals(c,nHe.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",we.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,we.FRAGMENT));const u=e.normalTexture;l(u)&&!s&&Oh(n,t,u,"u_normalTexture","NORMAL",o);const f=e.occlusionTexture;l(f)&&!s&&Oh(n,t,f,"u_occlusionTexture","OCCLUSION",i)}function oHe(e,t,n,i,o){const r=e.specularGlossiness;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,we.FRAGMENT);const s=r.diffuseTexture;l(s)&&!o&&Oh(n,t,s,"u_diffuseTexture","DIFFUSE",i);const a=r.diffuseFactor;l(a)&&!oe.equals(a,fP.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",we.FRAGMENT),t.u_diffuseFactor=function(){return r.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,we.FRAGMENT));const c=r.specularGlossinessTexture;l(c)&&!o&&Oh(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i);const u=r.specularFactor;l(u)&&!d.equals(u,fP.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_specularFactor",we.FRAGMENT),t.u_specularFactor=function(){return r.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,we.FRAGMENT));const f=r.glossinessFactor;l(f)&&f!==fP.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",we.FRAGMENT),t.u_glossinessFactor=function(){return r.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,we.FRAGMENT))}function rHe(e,t,n,i,o){const r=e.metallicRoughness;n.addDefine("USE_METALLIC_ROUGHNESS",void 0,we.FRAGMENT);const s=r.baseColorTexture;l(s)&&!o&&Oh(n,t,s,"u_baseColorTexture","BASE_COLOR",i);const a=r.baseColorFactor;l(a)&&!oe.equals(a,uP.DEFAULT_BASE_COLOR_FACTOR)&&(n.addUniform("vec4","u_baseColorFactor",we.FRAGMENT),t.u_baseColorFactor=function(){return r.baseColorFactor},n.addDefine("HAS_BASE_COLOR_FACTOR",void 0,we.FRAGMENT));const c=r.metallicRoughnessTexture;l(c)&&!o&&Oh(n,t,c,"u_metallicRoughnessTexture","METALLIC_ROUGHNESS",i);const u=r.metallicFactor;l(u)&&u!==uP.DEFAULT_METALLIC_FACTOR&&(n.addUniform("float","u_metallicFactor",we.FRAGMENT),t.u_metallicFactor=function(){return r.metallicFactor},n.addDefine("HAS_METALLIC_FACTOR",void 0,we.FRAGMENT));const f=r.roughnessFactor;l(f)&&f!==uP.DEFAULT_ROUGHNESS_FACTOR&&(n.addUniform("float","u_roughnessFactor",we.FRAGMENT),t.u_roughnessFactor=function(){return r.roughnessFactor},n.addDefine("HAS_ROUGHNESS_FACTOR",void 0,we.FRAGMENT))}const sHe=IY,aHe= ` void morphTargetsStage ( inout ProcessedAttributes attributes )
{
vec3 positionMC = attributes . positionMC ;
attributes . positionMC = getMorphedPosition ( positionMC ) ;
# ifdef HAS _NORMALS
vec3 normalMC = attributes . normalMC ;
attributes . normalMC = getMorphedNormal ( normalMC ) ;
# endif
# ifdef HAS _TANGENTS
vec3 tangentMC = attributes . tangentMC ;
attributes . tangentMC = getMorphedTangent ( tangentMC ) ;
# endif
} ` ,ts={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)"};ts.process=function(e,t){const n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,we.VERTEX),hHe(n);const i=t.morphTargets.length;for(let a=0;a<i;a++){const c=t.morphTargets[a].attributes,u=c.length;for(let f=0;f<u;f++){const h=c[f],_=h.semantic;_!==Tt.POSITION&&_!==Tt.NORMAL&&_!==Tt.TANGENT||(lHe(e,h,e.attributeIndex,a),e.attributeIndex++)}}pHe(n);const r=e.runtimeNode.morphWeights.length;n.addUniform("float", ` u _morphWeights [ $ { r } ] ` ,we.VERTEX),n.addVertexLines(aHe);const s={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=nn(s,e.uniformMap)};const cHe={attributeString:void 0,functionId:void 0};function lHe(e,t,n,i){const o=e.shaderBuilder;uHe(e,t,n);const r=fHe(t,cHe);dHe(o,r,i)}function uHe(e,t,n){const i={index:n,value:l(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:sn.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function fHe(e,t){switch(e.semantic){case Tt.POSITION:t.attributeString="Position",t.functionId=ts.FUNCTION_ID_GET_MORPHED_POSITION;break;case Tt.NORMAL:t.attributeString="Normal",t.functionId=ts.FUNCTION_ID_GET_MORPHED_NORMAL;break;case Tt.TANGENT:t.attributeString="Tangent",t.functionId=ts.FUNCTION_ID_GET_MORPHED_TANGENT;break}return t}function dHe(e,t,n){const 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 hHe(e){e.addFunction(ts.FUNCTION_ID_GET_MORPHED_POSITION,ts.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,we.VERTEX);const t="vec3 morphedPosition = position;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_POSITION,[t]),e.addFunction(ts.FUNCTION_ID_GET_MORPHED_NORMAL,ts.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,we.VERTEX);const n="vec3 morphedNormal = normal;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_NORMAL,[n]),e.addFunction(ts.FUNCTION_ID_GET_MORPHED_TANGENT,ts.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,we.VERTEX);const i="vec3 morphedTangent = tangent;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}function pHe(e){const t="return morphedPosition;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_POSITION,[t]);const n="return morphedNormal;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_NORMAL,[n]);const i="return morphedTangent;";e.addFunctionLines(ts.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}const mHe=ts,OY={name:"PickingPipelineStage"};OY.process=function(e,t,n){const i=n.context,o=e.runtimeNode,r=e.shaderBuilder,s=e.model,a=o.node.instances;if(e.hasPropertyTable)_He(e,t,a);else if(l(a))gHe(e,i);else{const c=LY(e),u=i.createPickId(c);s._pipelineResources.push(u),s._pickIds.push(u),r.addUniform("vec4","czm_pickColor",we.FRAGMENT);const f=e.uniformMap;f.czm_pickColor=function(){return u.color},e.pickId="czm_pickColor"}};function LY(e,t){const n=e.model;if(l(n.pickObject))return n.pickObject;const i={model:n,node:e.runtimeNode,primitive:e.runtimePrimitive};let o;if(Ws.is3DTiles(n.type)){const 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 _He(e,t,n){const i=e.model;let o,r;const s=i.featureIdLabel,a=i.instanceFeatureIdLabel;l(i.featureTableId)?o=i.featureTableId:l(n)?(r=qt.getFeatureIdsByLabel(n.featureIds,a),o=r.propertyTableId):(r=qt.getFeatureIdsByLabel(t.featureIds,s),o=r.propertyTableId);const c=i.featureTables[o];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",we.FRAGMENT);const f=c.batchTexture;e.uniformMap.model_pickTexture=function(){return y(f.pickTexture,f.default
// Variables are packed into a single vector to minimize gl.uniformXXX() calls
float pointSize = model _pointCloudParameters . x ;
float geometricError = model _pointCloudParameters . y ;
float depthMultiplier = model _pointCloudParameters . z ;
float depth = - positionEC . z ;
return min ( ( geometricError / depth ) * depthMultiplier , pointSize ) ;
}
# ifdef HAS _POINT _CLOUD _SHOW _STYLE
float pointCloudShowStylingStage ( in ProcessedAttributes attributes , in Metadata metadata ) {
float tiles3d _tileset _time = model _pointCloudParameters . w ;
return float ( getShowFromStyle ( attributes , metadata , tiles3d _tileset _time ) ) ;
}
# endif
# ifdef HAS _POINT _CLOUD _COLOR _STYLE
vec4 pointCloudColorStylingStage ( in ProcessedAttributes attributes , in Metadata metadata ) {
float tiles3d _tileset _time = model _pointCloudParameters . w ;
return getColorFromStyle ( attributes , metadata , tiles3d _tileset _time ) ;
}
# endif
# ifdef HAS _POINT _CLOUD _POINT _SIZE _STYLE
float pointCloudPointSizeStylingStage ( in ProcessedAttributes attributes , in Metadata metadata ) {
float tiles3d _tileset _time = model _pointCloudParameters . w ;
return float ( getPointSizeFromStyle ( attributes , metadata , tiles3d _tileset _time ) ) ;
}
# elif defined ( HAS _POINT _CLOUD _ATTENUATION )
float pointCloudPointSizeStylingStage ( in ProcessedAttributes attributes , in Metadata metadata ) {
return getPointSizeFromAttenuation ( v _positionEC ) ;
}
# endif
# ifdef HAS _POINT _CLOUD _BACK _FACE _CULLING
float pointCloudBackFaceCullingStage ( ) {
# if defined ( HAS _NORMALS ) && ! defined ( HAS _DOUBLE _SIDED _MATERIAL )
// This needs to be computed in eye coordinates so we can't use attributes.normalMC
return step ( - v _normalEC . z , 0.0 ) ;
# else
return 1.0 ;
# endif
}
# endif ` ,CHe=new oe,BY={name:"PointCloudStylingPipelineStage"};BY.process=function(e,t,n){const 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,u=!l(a)&&c;if(l(r)&&!u){const A=xHe(a),C=wHe(r,A);SHe(i,C);const x=vHe(C).indexOf("normalMC")>=0,w=qt.getAttributeBySemantic(t,Tt.NORMAL);if(x&&!w)throw new Se("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,we.VERTEX),C.styleTranslucent&&(e.alphaOptions.pass=Be.TRANSLUCENT)}const f=o.pointCloudShading;f.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,we.VERTEX),f.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,we.VERTEX);let h,_,g;Ws.is3DTiles(o.type)&&(_=!0,h=o.content,g=h.tile.refine===sa.ADD),i.addUniform("vec4","model_pointCloudParameters",we.VERTEX),i.addVertexLines(AHe);const p=e.uniformMap;p.model_pointCloudParameters=function(){const A=CHe;let C=1;_&&(C=g?5:h.tileset.maximumScreenSpaceError),A.x=y(f.maximumAttenuation,C),A.x*=n.pixelRatio;const b=THe(e,t,f,h);A.y=b*f.geometricErrorScale;const x=n.context,w=n.camera.frustum;let S;return n.mode===le.SCENE2D||w instanceof Mt?S=Number.POSITIVE_INFINITY:S=x.drawingBufferHeight/n.camera.frustum.sseDenominator,A.z=S,_&&(A.w=h.tileset.timeSinceLoad),A}};const lV=new d;function THe(e,t,n,i){if(l(i)){const f=i.tile.geometricError;if(f>0)return f}if(l(n.baseResolution))return n.baseResolution;const o=qt.getAttributeBySemantic(t,Tt.POSITION),r=o.count,s=e.runtimeNode.transform;let a=d.subtract(o.max,o.min,lV);a=B.multiplyByPointAsVector(s,a,lV);const c=a.x*a.y*a.z;return N.cbrt(c/r)}const bHe={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},EHe={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function xHe(e){const t=lt(EHe);if(!l(e))return t;for(let n=0;n<e.length;n++){const o=e[n].properties;for(const r in o)o.hasOwnProperty(r)&&(t[r]= ` metadata . $ { r } ` )}return t}const dP="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function wHe(e,t){const n=bHe,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction( ` getColorFromStyle ( $ { dP } ) ` ,t,i),n.showStyleFunction=e.getShowShaderFunction( ` getShowFromStyle ( $ { dP } ) ` ,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction( ` getPointSizeFromStyle ( $ { dP } ) ` ,t,i),n.styleTranslucent=l(n.colorStyleFunction)&&i.translucent,n}function SHe(e,t){const n=t.colorStyleFunction;l(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,we.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));const i=t.showStyleFunction;l(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,we.VERTEX),e.addVertexLines(i));const o=t.pointSizeStyleFunction;l(o)&&(e.addDefine("HAS_POINT_CLOUD_POINT_SIZE_STYLE",void 0,we.VERTEX),e.addVertexLines(o))}function hP(e,t){const n=/attributes \. ( \w +)/g;let i=n.exec(e);for(;i!==null;){const o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function vHe(e){const t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,o=[];return l(t)&&hP(t,o),l(n)&&hP(n,o),l(i)&&hP(i,o),o}const DHe=BY,IHe= ` void primitiveOutlineStage ( ) {
v _outlineCoordinates = a _outlineCoordinates ;
}
` ,PHe= ` void primitiveOutlineStage ( inout czm _modelMaterial material ) {
if ( ! model _showOutline ) {
return ;
}
float outlineX =
texture2D ( model _outlineTexture , vec2 ( v _outlineCoordinates . x , 0.5 ) ) . r ;
float outlineY =
texture2D ( model _outlineTexture , vec2 ( v _outlineCoordinates . y , 0.5 ) ) . r ;
float outlineZ =
texture2D ( model _outlineTexture , vec2 ( v _outlineCoordinates . z , 0.5 ) ) . r ;
float outlineness = max ( outlineX , max ( outlineY , outlineZ ) ) ;
material . diffuse = mix ( material . diffuse , model _outlineColor . rgb , model _outlineColor . a * outlineness ) ;
}
` ,RY={name:"PrimitiveOutlinePipelineStage"};RY.process=function(e,t,n){const i=e.shaderBuilder,o=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,we.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");const r=t.outlineCoordinates,s={index:e.attributeIndex++,vertexBuffer:r.buffer,componentsPerAttribute:sn.getNumberOfComponents(r.type),componentDatatype:r.componentDatatype,offsetInBytes:r.byteOffset,strideInBytes:r.byteStride,normalize:r.normalized};e.attributes.push(s),i.addUniform("sampler2D","model_outlineTexture",we.FRAGMENT);const a=dT.createTexture(n.context);o.model_outlineTexture=function(){return a};const c=e.model;i.addUniform("vec4","model_outlineColor",we.FRAGMENT),o.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",we.FRAGMENT),o.model_showOutline=function(){return c.showOutline},i.addVertexLines(IHe),i.addFragmentLines(PHe)};const OHe=RY,NY={name:"PrimitiveStatisticsPipelineStage",_countGeometry:MY,_count2DPositions:FY,_countMorphTargetAttributes:zY,_countMaterialTextures:UY,_countFeatureIdTextures:HY,_countBinaryMetadata:VY};NY.process=function(e,t,n){const i=e.model,o=i.statistics;MY(o,t),FY(o,e.runtimePrimitive),zY(o,t),UY(o,t.material),HY(o,t.featureIds),VY(o,i)};function MY(e,t){const n=l(t.indices)?t.indices.count:qt.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===Je.POINTS?e.pointsLength+=n:Je.isTriangles(i)&&(e.trianglesLength+=LHe(i,n));const o=t.attributes,r=o.length;for(let c=0;c<r;c++){const u=o[c];if(l(u.buffer)){const f=l(u.typedArray);e.addBuffer(u.buffer,f)}}const s=t.outlineCoordinates;l(s)&&l(s.buffer)&&e.addBuffer(s.buffer,!1);const a=t.indices;if(l(a)&&l(a.buffer)){const c=l(a.typedArray);e.addBuffer(a.buffer,c)}}function LHe(e,t){switch(e){case Je.TRIANGLES:return t/3;case Je.TRIANGLE_STRIP:case Je.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function FY(e,t){const n=t.positionBuffer2D;l(n)&&e.addBuffer(n,!0)}function zY(e,t){const n=t.morphTargets;if(!l(n))return;const i=!1,o=n.length;for(let r=0;r<o;r++){const s=n[r].attributes,a=s.length;for(let c=0;c<a;c++){const u=s[c];l(u.buffer)&&e.addBuffer(u.buffer,i)}}}function UY(e,t){const n=BHe(t),i=n.length;for(let o=0;o<i;o++){const r=n[o];l(r)&&l(r.texture)&&e.addTexture(r.texture)}}function BHe(e){const 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 HY(e,t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];if(o instanceof St.FeatureIdTexture){const r=o.textureReader;l(r.texture)&&e.addTexture(r.texture)}}}function VY(e,t){const n=t.structuralMetadata;l(n)&&(RHe(e,n),e.propertyTablesByteLength+=n.propertyTablesByteLength);const i=t.featureTables;if(!l(i))return;const o=i.length;for(let r=0;r<o;r++){const s=i[r];e.addBatchTexture(s.batchTexture)}}function RHe(e,t){const n=t.propertyTextures;if(!l(n))return;const i=n.length;for(let o=0;o<i;o++){const s=n[o].properties;for(const a in s)if(s.hasOwnProperty(a)){const u=s[a].textureReader;l(u.texture)&&e.addTexture(u.texture)}}}const NHe=NY,MHe=new B,FHe=new B,kY={name:"SceneMode2DPipelineStage"};kY.process=function(e,t,n){const i=qt.getAttributeBySemantic(t,Tt.POSITION),o=e.shaderBuilder,r=e.model,s=r.sceneGraph.computedModelMatrix,a=e.runtimeNode.computedTransform,c=B.multiplyTransformation(s,a,MHe),u=HHe(e,c,n),f=e.runtimePrimitive;f.boundingSphere2D=u;const h=e.runtimeNode.node.instances;if(l(h))return;if(l(i.typedArray)){const A=GHe(i,c,u,n);f.positionBuffer2D=A,r._modelResources.push(A),i.typedArray=void 0}o.addDefine("USE_2D_POSITIONS",void 0,we.VERTEX),o.addUniform("mat4","u_modelView2D",we.VERTEX);const _=B.fromTranslation(u.center,new B),g=n.context,p={u_modelView2D:function(){return B.multiplyTransformation(g.uniformState.view,_,FHe)}};e.uniformMap=nn(p,e.uniformMap)};const zHe=new d,UHe=new d;function HHe(e,t,n){const i=B.multiplyByPoint(t,e.positionMin,zHe),o=tr.computeActualWgs
{
mat4 skinningMatrix = getSkinningMatrix ( ) ;
mat3 skinningMatrixMat3 = mat3 ( skinningMatrix ) ;
vec4 positionMC = vec4 ( attributes . positionMC , 1.0 ) ;
attributes . positionMC = vec3 ( skinningMatrix * positionMC ) ;
# ifdef HAS _NORMALS
vec3 normalMC = attributes . normalMC ;
attributes . normalMC = skinningMatrixMat3 * normalMC ;
# endif
# ifdef HAS _TANGENTS
vec3 tangentMC = attributes . tangentMC ;
attributes . tangentMC = skinningMatrixMat3 * tangentMC ;
# endif
} ` ,im={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};im.process=function(e,t){const n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,we.VERTEX),YHe(n,t);const i=e.runtimeNode,o=i.computedJointMatrices;n.addUniform("mat4", ` u _jointMatrices [ $ { o . length } ] ` ,we.VERTEX),n.addVertexLines(jHe);const r={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=nn(r,e.uniformMap)};function qHe(e){let t=-1;const n=e.attributes,i=n.length;for(let o=0;o<i;o++){const r=n[o];(r.semantic===Tt.JOINTS||r.semantic===Tt.WEIGHTS)&&(t=Math.max(t,r.setIndex))}return t}function YHe(e,t){e.addFunction(im.FUNCTION_ID_GET_SKINNING_MATRIX,im.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,we.VERTEX);const n="mat4 skinnedMatrix = mat4(0);";e.addFunctionLines(im.FUNCTION_ID_GET_SKINNING_MATRIX,[n]);let i,o;const r=["x","y","z","w"],s=qHe(t);for(i=0;i<=s;i++)for(o=0;o<=3;o++){const c=r[o],u= ` skinnedMatrix += a _weights _$ { i } . $ { c } * u _jointMatrices [ int ( a _joints _$ { i } . $ { c } ) ] ; ` ;e.addFunctionLines(im.FUNCTION_ID_GET_SKINNING_MATRIX,[u])}const a="return skinnedMatrix;";e.addFunctionLines(im.FUNCTION_ID_GET_SKINNING_MATRIX,[a])}const XHe=im,xN={};function $ He(e){const t=it.createTypedArray(e,e*2),n=e;let 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 KHe(e,t){const n=t.length,i=it.createTypedArray(e,n*2);let o=0;for(let r=0;r<n;r+=3){const 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 JHe(e){const t=e-2,n=2+t*4,i=it.createTypedArray(e,n);let 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 QHe(e,t){const i=t.length-2,o=2+i*4,r=it.createTypedArray(e,o);let s=0;r[s++]=t[0],r[s++]=t[1];for(let a=0;a<i;a++){const c=t[a],u=t[a+1],f=t[a+2];r[s++]=u,r[s++]=f,r[s++]=f,r[s++]=c}return r}function ZHe(e){const t=e-2,n=2+t*4,i=it.createTypedArray(e,n);let 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 eVe(e,t){const i=t.length-2,o=2+i*4,r=it.createTypedArray(e,o);let s=0;const a=t[0];r[s++]=a,r[s++]=t[1];for(let c=0;c<i;c++){const u=t[c+1],f=t[c+2];r[s++]=u,r[s++]=f,r[s++]=f,r[s++]=a}return r}xN.createWireframeIndices=function(e,t,n){const i=l(n);if(e===Je.TRIANGLES)return i?KHe(t,n): $ He(t);if(e===Je.TRIANGLE_STRIP)return i?QHe(t,n):JHe(t);if(e===Je.TRIANGLE_FAN)return i?eVe(t,n):ZHe(t)};xN.getWireframeIndicesCount=function(e,t){return e===Je.TRIANGLES?t*2:e===Je.TRIANGLE_STRIP||e===Je.TRIANGLE_FAN?2+(t-2)*4:t};const WY=xN,jY={name:"WireframePipelineStage"};jY.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,we.FRAGMENT);const o=e.model,r=tVe(t,e.indices,n);o._pipelineResources.push(r),e.wireframeIndexBuffer=r;const s=!1;o.statistics.addBuffer(r,s);const a=e.primitiveType,c=e.count;e.primitiveType=Je.LINES,e.count=WY.getWireframeIndicesCount(a,c)};function tVe(e,t,n){const o=qt.getAttributeBySemantic(e,Tt.POSITION).count,r=n.context.webgl2;let s;if(l(t)){const f=t.buffer,h=t.count;l(f)&&r?(s=f.sizeInBytes===h?new Uint8Array(h):it.createTypedArray(o,h),f.getBufferData(s)):s=t.typedArray}const a=e.primitiveType,c=WY.createWireframeIndices(a,o,s),u=it.fromSizeInBytes(c.BYTES_PER_ELEMENT);return yt.createIndexBuffer({context:n.context,typedArray:c,usage:Ze.STATIC_DRAW,indexDatatype:u})}const nVe=jY;function qY(e){e=y(e,y.EMPTY_OBJECT);const t=e.primitive,n=e.node,i=e.model;T.typeOf.object("options.primitive",t),T.typeOf.object("options.node",n),T.typeOf.object("options.model",i),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=[]}qY.prototype.configurePipeline=function(e){const t=this.pipelineStages;t.length=0;const n=this.primitive,i=this.node,o=this.model,r=o.customShader,s=o.style,a=e.context.webgl2,u=e.mode!==le.SCENE3D&&!e.scene3DOnly&&o
if ( model _silhouettePass ) {
color = czm _gammaCorrect ( model _silhouetteColor ) ;
}
} ` ,cVe= ` void silhouetteStage ( in ProcessedAttributes attributes , inout vec4 positionClip ) {
# ifdef HAS _NORMALS
if ( model _silhouettePass ) {
vec3 normal = normalize ( czm _normal3D * attributes . normalMC ) ;
normal . x *= czm _projection [ 0 ] [ 0 ] ;
normal . y *= czm _projection [ 1 ] [ 1 ] ;
positionClip . xy += normal . xy * positionClip . w * model _silhouetteSize * czm _pixelRatio / czm _viewport . z ;
}
# endif
}
` ,Bw={name:"ModelSilhouettePipelineStage"};Bw.silhouettesLength=0;Bw.process=function(e,t,n){l(t._silhouetteId)||(t._silhouetteId=++Bw.silhouettesLength);const i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,we.BOTH),i.addVertexLines(cVe),i.addFragmentLines(aVe),i.addUniform("vec4","model_silhouetteColor",we.FRAGMENT),i.addUniform("float","model_silhouetteSize",we.VERTEX),i.addUniform("bool","model_silhouettePass",we.BOTH);const o={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=nn(o,e.uniformMap),e.hasSilhouette=!0};const lVe=Bw,uVe= ` void modelSplitterStage ( )
{
// Don't split when rendering the shadow map, because it is rendered from
// the perspective of a totally different camera.
# ifndef SHADOW _MAP
if ( model _splitDirection < 0.0 && gl _FragCoord . x > czm _splitPosition ) discard ;
if ( model _splitDirection > 0.0 && gl _FragCoord . x < czm _splitPosition ) discard ;
# endif
}
` ,Ix={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};Ix.process=function(e,t,n){const i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,we.FRAGMENT),i.addFragmentLines(uVe);const o={};i.addUniform("float",Ix.SPLIT_DIRECTION_UNIFORM_NAME,we.FRAGMENT),o[Ix.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=nn(o,e.uniformMap)};const fVe=Ix;function dVe(e,t){T.typeOf.object("modelRenderResources",e),T.typeOf.object("runtimeNode",t),this.model=e.model,this.shaderBuilder=e.shaderBuilder.clone(),this.uniformMap=lt(e.uniformMap),this.alphaOptions=lt(e.alphaOptions),this.renderStateOptions=lt(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}function hVe(e){e=y(e,y.EMPTY_OBJECT),this.lightingModel=y(e.lightingModel,Lw.UNLIT)}function pVe(e,t){T.typeOf.object("nodeRenderResources",e),T.typeOf.object("runtimePrimitive",t),this.model=e.model,this.runtimeNode=e.runtimeNode,this.attributes=e.attributes.slice(),this.attributeIndex=e.attributeIndex,this.featureIdVertexAttributeSetIndex=e.featureIdVertexAttributeSetIndex,this.uniformMap=lt(e.uniformMap),this.alphaOptions=lt(e.alphaOptions),this.renderStateOptions=lt(e.renderStateOptions,!0),this.hasSilhouette=e.hasSilhouette,this.hasSkipLevelOfDetail=e.hasSkipLevelOfDetail,this.shaderBuilder=e.shaderBuilder.clone(),this.instanceCount=e.instanceCount,this.runtimePrimitive=t;const n=t.primitive;this.count=l(n.indices)?n.indices.count:qt.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;const i=qt.getPositionMinMax(n,this.runtimeNode.instancingTranslationMin,this.runtimeNode.instancingTranslationMax);this.positionMin=d.clone(i.min,new d),this.positionMax=d.clone(i.max,new d),this.boundingSphere=fe.fromCornerPoints(this.positionMin,this.positionMax,new fe),this.lightingOptions=new hVe,this.pickId=void 0}function rc(e){e=y(e,y.EMPTY_OBJECT);const t=e.modelComponents;T.typeOf.object("options.model",e.model),T.typeOf.object("options.modelComponents",t),this._model=e.model,this._components=t,this._pipelineStages=[],this._updateStages=[],this._runtimeNodes=[],this._rootNodes=[],this._skinnedNodes=[],this._runtimeSkins=[],this.modelPipelineStages=[],this._boundingSphere=void 0,this._boundingSphere2D=void 0,this._computedModelMatrix=B.clone(B.IDENTITY),this._computedModelMatrix2D=B.clone(B.IDENTITY),this._axisCorrectionMatrix=qt.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new B),this._runtimeArticulations={},mVe(this)}Object.defineProperties(rc.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 mVe(e){const t=e._components,n=t.scene,o=e._model.modelMatrix;XY(e,o);const r=t.articulations,s=r.length,a=e._runtimeArticulations;for(let x=0;x<s;x++){const w=r[x],S=new iv({articulation:w,sceneGraph:e}),P=S.name;a[P]=S}const c=t.nodes,u=c.length;e._runtimeNodes=new Array(u);const h=n.nodes.length,_=B.IDENTITY;for(let x=0;x<h;x++){const w=n.nodes[x],S= $ Y(e,w,_);e._rootNodes.push(S)}const g=t.skins,p=e._runtimeSkins,A=g.length;for(let x=0;x<A;x++){const w=g[x];p.push(new wN({skin:w,sceneGraph:e}))}const C=e._skinnedNodes,b=C.length;for(let x=0;x<b;x++){const w=C[x],S=e._runtimeNodes[w],L=c[w].skin.index;S._runtimeSkin=p[L],S.updateJointMatrices()}e.applyArticulations()}function XY(e,t){const n=e._components,i=e._model;e._computedModelMatrix=B.multiplyTransformation(t,n.transform,e._computedModelMatrix),e._computedModelMatrix=B.multiplyTransformation(e._computedModelMatrix,e._axisCorrectionMatrix,e._computedModelMatrix),e._computedModelMatrix=B.multiplyByUniformScale(e._computedModelMatrix,i.computedScale,e._computedModelM
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( billboard _texture , v _textureCoordinates ) ;
}
` ,i=t.createViewportQuadCommand(n,{uniformMap:{billboard_texture:function(){return e._textureAtlas.texture}}});return i.pass=Be.OVERLAY,i}const C4e=[];js.prototype.update=function(e){if(vN(this),!this.show)return;let t=this._billboards,n=t.length;const i=e.context;this._instanced=i.instancedArrays,Li=this._instanced?s4e:r4e,mP=this._instanced?c4e:a4e;let o=this._textureAtlas;if(!l(o)){o=this._textureAtlas=new Fu({context:i});for(let R=0;R<n;++R)t[R]._loadImage()}const r=o.textureCoordinates;if(r.length===0)return;g4e(this,e),t=this._billboards,n=t.length;const s=this._billboardsToUpdate,a=this._billboardsToUpdateIndex,c=this._propertiesChanged,u=o.guid,f=this._createVertexArray||this._textureAtlasGUID!==u;this._textureAtlasGUID=u;let h;const _=e.passes,g=_.pick;if(f||!g&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let R=0;R<SN;++R)c[R]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),n>0){this._vaf=u4e(i,n,this._buffersUsage,this._instanced,this._batchTable,this._sdf),h=this._vaf.writers;for(let R=0;R<n;++R){const z=this._billboards[R];z._dirty=!1,_4e(this,e,r,h,z)}this._vaf.commit(mP(i))}this._billboardsToUpdateIndex=0}else if(a>0){const R=C4e;R.length=0,(c[MA]||c[t4e]||c[e4e])&&R.push(_X),(c[x0]||c[aX]||c[Qke]||c[Zke]||c[Jke])&&(R.push(bX),this._instanced&&R.push(CL)),(c[x0]||c[n4e]||c[fX])&&(R.push(EX),R.push(AL)),(c[x0]||c[lX])&&R.push(AL),c[cX]&&R.push(CL),c[uX]&&R.push(xX),c[dX]&&R.push(wX),(c[hX]||c[i4e]||c[x0]||c[MA])&&R.push(SX),(c[x0]||c[MA])&&R.push(vX),c[pX]&&R.push(DX);const z=R.length;if(h=this._vaf.writers,a/n>.1){for(let U=0;U<a;++U){const v=s[U];v._dirty=!1;for(let I=0;I<z;++I)R[I](this,e,r,h,v)}this._vaf.commit(mP(i))}else{for(let U=0;U<a;++U){const v=s[U];v._dirty=!1;for(let I=0;I<z;++I)R[I](this,e,r,h,v);this._instanced?this._vaf.subCommit(v._index,1):this._vaf.subCommit(v._index*4,4)}this._vaf.endSubCommits()}this._billboardsToUpdateIndex=0}if(a>n*1.5&&(s.length=n),!l(this._vaf)||!l(this._vaf.va))return;this._boundingVolumeDirty&&(this._boundingVolumeDirty=!1,fe.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let p,A=B.IDENTITY;e.mode===le.SCENE3D?(A=this.modelMatrix,p=fe.clone(this._baseVolumeWC,this._boundingVolume)):p=fe.clone(this._baseVolume2D,this._boundingVolume),y4e(this,e,p);const C=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,C){this._blendOption===Oo.OPAQUE||this._blendOption===Oo.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=Qe.fromCache({depthTest:{enabled:!0,func:se.LESS},depthMask:!0}):this._rsOpaque=void 0;const R=this._blendOption===Oo.TRANSLUCENT;this._blendOption===Oo.TRANSLUCENT||this._blendOption===Oo.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=Qe.fromCache({depthTest:{enabled:!0,func:R?se.LEQUAL:se.LESS},depthMask:R,blending:Si.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let b,x,w,S,P;const L=xt.maximumVertexTextureImageUnits>0;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){b=xue,x=Eue,P=[],l(this._batchTable)&&(P.push("VECTOR_TILE"),b=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(b),x=this._batchTable.getFragmentShaderCallback(!1,void 0)(x)),w=new Ge({defines:P,sources:[b]}),this._instanced&&w.defines.push("INSTANCED"),this._shaderRotation&&w.defines.push("ROTATION"),this._shaderAlignedAxis&&w.defines.push("ALIGNED_AXIS"),this._shaderScaleByDistance&&w.defines.push("EYE_DISTANCE_SCALING"),this._shaderTranslucencyByDistance&&w.defines.push("EYE_DISTANCE_T
` );let n="";for(let i=0;i<t.length;i++){const o=t[i],r=bV.test(o.charAt(0)),s=P4e(o,bV);let a=0,c="";for(let u=0;u<s.length;++u){const f=s[u],h=f.Type===Qo.BRACKETS?L4e(f.Word):O4e(f.Word);r?f.Type===Qo.RTL?(c=h+c,a=0):f.Type===Qo.LTR?(c=v0(c,a,f.Word),a+=f.Word.length):(f.Type===Qo.WEAK||f.Type===Qo.BRACKETS)&&(f.Type===Qo.WEAK&&s[u-1].Type===Qo.BRACKETS?c=h+c:s[u-1].Type===Qo.RTL?(c=h+c,a=0):s.length>u+1?s[u+1].Type===Qo.RTL?(c=h+c,a=0):(c=v0(c,a,f.Word),a+=f.Word.length):c=v0(c,0,h)):f.Type===Qo.RTL?c=v0(c,a,h):f.Type===Qo.LTR?(c+=f.Word,a=c.length):(f.Type===Qo.WEAK||f.Type===Qo.BRACKETS)&&(u>0&&s[u-1].Type===Qo.RTL?s.length>u+1?s[u+1].Type===Qo.RTL?c=v0(c,a,h):(c+=f.Word,a=c.length):c+=f.Word:(c+=f.Word,a=c.length))}n+=c,i<t.length-1&&(n+= `
` )}return n}var TL={},M4e={get exports(){return TL},set exports(e){TL=e}};(function(e){function t(){var n=0,i=1,o=2,r=3,s=4,a=5,c=6,u=7,f=8,h=9,_=10,g=11,p=12,A=13,C=14,b=15,x=16,w=17,S=0,P=1,L=2,H=3,R=4;function z(m,D){return 55296<=m.charCodeAt(D)&&m.charCodeAt(D)<=56319&&56320<=m.charCodeAt(D+1)&&m.charCodeAt(D+1)<=57343}function U(m,D){D===void 0&&(D=0);var O=m.charCodeAt(D);if(55296<=O&&O<=56319&&D<m.length-1){var M=O,V=m.charCodeAt(D+1);return 56320<=V&&V<=57343?(M-55296)*1024+(V-56320)+65536:M}if(56320<=O&&O<=57343&&D>=1){var M=m.charCodeAt(D-1),V=O;return 55296<=M&&M<=56319?(M-55296)*1024+(V-56320)+65536:V}return O}function v(m,D,O){var M=[m].concat(D).concat([O]),V=M[M.length-2],k=O,W=M.lastIndexOf(C);if(W>1&&M.slice(1,W).every(function(q){return q==r})&&[r,A,w].indexOf(m)==-1)return L;var G=M.lastIndexOf(s);if(G>0&&M.slice(1,G).every(function(q){return q==s})&&[p,s].indexOf(V)==-1)return M.filter(function(q){return q==s}).length%2==1?H:R;if(V==n&&k==i)return S;if(V==o||V==n||V==i)return k==C&&D.every(function(q){return q==r})?L:P;if(k==o||k==n||k==i)return P;if(V==c&&(k==c||k==u||k==h||k==_))return S;if((V==h||V==u)&&(k==u||k==f))return S;if((V==_||V==f)&&k==f)return S;if(k==r||k==b)return S;if(k==a)return S;if(V==p)return S;var K=M.indexOf(r)!=-1?M.lastIndexOf(r)-1:M.length-2;return[A,w].indexOf(M[K])!=-1&&M.slice(K+1,-1).every(function(q){return q==r})&&k==C||V==b&&[x,w].indexOf(k)!=-1?S:D.indexOf(s)!=-1?L:V==s&&k==s?S:P}this.nextBreak=function(m,D){if(D===void 0&&(D=0),D<0)return 0;if(D>=m.length-1)return m.length;for(var O=I(U(m,D)),M=[],V=D+1;V<m.length;V++)if(!z(m,V-1)){var k=I(U(m,V));if(v(O,M,k))return V;M.push(k)}return m.length},this.splitGraphemes=function(m){for(var D=[],O=0,M;(M=this.nextBreak(m,O))<m.length;)D.push(m.slice(O,M)),O=M;return O<m.length&&D.push(m.slice(O)),D},this.iterateGraphemes=function(m){var D=0,O={next:function(){var M,V;return(V=this.nextBreak(m,D))<m.length?(M=m.slice(D,V),D=V,{value:M,done:!1}):D<m.length?(M=m.slice(D),D=m.length,{value:M,done:!1}):{value:void 0,done:!0}}.bind(this)};return typeof Symbol<"u"&&Symbol.iterator&&(O[Symbol.iterator]=function(){return O}),O},this.countGraphemes=function(m){for(var D=0,O=0,M;(M=this.nextBreak(m,O))<m.length;)O=M,D++;return O<m.length&&D++,D};function I(m){return 1536<=m&&m<=1541||m==1757||m==1807||m==2274||m==3406||m==69821||70082<=m&&m<=70083||m==72250||72326<=m&&m<=72329||m==73030?p:m==13?n:m==10?i:0<=m&&m<=9||11<=m&&m<=12||14<=m&&m<=31||127<=m&&m<=159||m==173||m==1564||m==6158||m==8203||8206<=m&&m<=8207||m==8232||m==8233||8234<=m&&m<=8238||8288<=m&&m<=8292||m==8293||8294<=m&&m<=8303||55296<=m&&m<=57343||m==65279||65520<=m&&m<=65528||65529<=m&&m<=65531||113824<=m&&m<=113827||119155<=m&&m<=119162||m==917504||m==917505||917506<=m&&m<=917535||917632<=m&&m<=917759||918e3<=m&&m<=921599?o:768<=m&&m<=879||1155<=m&&m<=1159||1160<=m&&m<=1161||1425<=m&&m<=1469||m==1471||1473<=m&&m<=1474||1476<=m&&m<=1477||m==1479||1552<=m&&m<=1562||1611<=m&&m<=1631||m==1648||1750<=m&&m<=1756||1759<=m&&m<=1764||1767<=m&&m<=1768||1770<=m&&m<=1773||m==1809||1840<=m&&m<=1866||1958<=m&&m<=1968||2027<=m&&m<=2035||2070<=m&&m<=2073||2075<=m&&m<=2083||2085<=m&&m<=2087||2089<=m&&m<=2093||2137<=m&&m<=2139||2260<=m&&m<=2273||2275<=m&&m<=2306||m==2362||m==2364||2369<=m&&m<=2376||m==2381||2385<=m&&m<=2391||2402<=m&&m<=2403||m==2433||m==2492||m==2494||2497<=m&&m<=2500||m==2509||m==2519||2530<=m&&m<=2531||2561<=m&&m<=2562||m==2620||2625<=m&&m<=2626||2631<=m&&m<=2632||2635<=m&&m<=2637||m==2641||2672<=m&&m<=2673||m==2677||2689<=m&&m<=2690||m==2748||2753<=m&&m<=2757||2759<=m&&m<=2760||m==2765||2786<=m&&m<=2787||2810<=m&&m<=2815||m==2817||m==2876||m==2878||m==2879||2881<=m&&m<=2884||m==2893||m==2902||m==2903||2914<=m&&m<=2915||m==2946||m==3006||m==3008||m==3021||m==3031||m==3072||3134<=m&&m<=3136||3142<=m&&m<=3144||3146<=m&&m<=3149||3157<=m&&m<=3158||3170<=m&&m<=3171||m==3201||m==3260||m==3263||m==3266||m==3270||3276<=m&&m<=3277||3285<=m&&m<=3286||3298<=m&&m<=3299||3328<=m&&m<=3329||3387<=m&&m<=3388||m==3390||3393<=m&&m<=3396||m==3405||m==3415||3426<=m&&m<=3427||m==3530||m=
` ).join("").length>0;let h=t._backgroundBillboard;const _=e._backgroundBillboardCollection;f?(l(h)||(h=_.add({collection:e,image:OX,imageSubRegion:V4e}),t._backgroundBillboard=h),h.color=t._backgroundColor,h.show=t._show,h.position=t._position,h.eyeOffset=t._eyeOffset,h.pixelOffset=t._pixelOffset,h.horizontalOrigin=ca.LEFT,h.verticalOrigin=t._verticalOrigin,h.heightReference=t._heightReference,h.scale=t.totalScale,h.pickPrimitive=t,h.id=t._id,h.translucencyByDistance=t._translucencyByDistance,h.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,h.scaleByDistance=t._scaleByDistance,h.distanceDisplayCondition=t._distanceDisplayCondition,h.disableDepthTestDistance=t._disableDepthTestDistance):l(h)&&(_.remove(h),t._backgroundBillboard=h=void 0);const g=e._glyphTextureCache;for(u=0;u<o;++u){const p=i[u],A=t._verticalOrigin,C=JSON.stringify([p,t._fontFamily,t._fontStyle,t._fontWeight,+A]);let b=g[C];if(!l(b)){const x= ` $ { t . _fontStyle } $ { t . _fontWeight } $ { Fa . FONT _SIZE } px $ { t . _fontFamily } ` ,w=G4e(p,x,F.WHITE,F.WHITE,0,bl.FILL,A);if(b=new U4e(e,-1,w.dimensions),g[C]=b,w.width>0&&w.height>0){const S=x4e(w,{cutoff:Fa.CUTOFF,radius:Fa.RADIUS}),P=w.getContext("2d"),L=w.width,H=w.height,R=P.getImageData(0,0,L,H);for(let z=0;z<L;z++)for(let U=0;U<H;U++){const v=U*L+z,I=S[v]*255,m=v*4;R.data[m+0]=I,R.data[m+1]=I,R.data[m+2]=I,R.data[m+3]=I}P.putImageData(R,0,0),p!==" "&&W4e(e._textureAtlas,C,w,b)}}if(a=r[u],l(a)?b.index===-1?EL(e,a):l(a.textureInfo)&&(a.textureInfo=void 0):(a=new z4e,r[u]=a),a.textureInfo=b,a.dimensions=b.dimensions,b.index!==-1){let x=a.billboard;const w=e._spareBillboards;l(x)||(w.length>0?x=w.pop():(x=e._billboardCollection.add({collection:e}),x._labelDimensions=new j,x._labelTranslate=new j),a.billboard=x),x.show=t._show,x.position=t._position,x.eyeOffset=t._eyeOffset,x.pixelOffset=t._pixelOffset,x.horizontalOrigin=ca.LEFT,x.verticalOrigin=t._verticalOrigin,x.heightReference=t._heightReference,x.scale=t.totalScale,x.pickPrimitive=t,x.id=t._id,x.image=C,x.translucencyByDistance=t._translucencyByDistance,x.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,x.scaleByDistance=t._scaleByDistance,x.distanceDisplayCondition=t._distanceDisplayCondition,x.disableDepthTestDistance=t._disableDepthTestDistance,x._batchIndex=t._batchIndex,x.outlineColor=t.outlineColor,t.style===bl.FILL_AND_OUTLINE?(x.color=t._fillColor,x.outlineWidth=t.outlineWidth):t.style===bl.FILL?(x.color=t._fillColor,x.outlineWidth=0):t.style===bl.OUTLINE&&(x.color=F.TRANSPARENT,x.outlineWidth=t.outlineWidth)}}t._repositionAllGlyphs=!0}function EV(e,t,n){return t===ca.CENTER?-e/2:t===ca.RIGHT?-(e+n.x):n.x}const no=new j,Y4e=new j;function X4e(e){const t=e._glyphs,n=e._renderedText;let i,o,r=0,s=0;const a=[];let c=Number.NEGATIVE_INFINITY,u=0,f=1,h;const _=t.length,g=e._backgroundBillboard,p=j.clone(l(g)?e._backgroundPadding:j.ZERO,Y4e);for(p.x/=e._relativeSize,p.y/=e._relativeSize,h=0;h<_;++h)n.charAt(h)=== `
` ?(a.push(r),++f,r=0):(i=t[h],o=i.dimensions,u=Math.max(u,o.height-o.descent),c=Math.max(c,o.descent),r+=o.width-o.minx,h<_-1&&(r+=t[h+1].dimensions.minx),s=Math.max(s,r));a.push(r);const A=u+c,C=e.totalScale,b=e._horizontalOrigin,x=e._verticalOrigin;let w=0,S=a[w],P=EV(S,b,p);const L=(l(e._lineHeight)?e._lineHeight:H4e*e._fontSize)/e._relativeSize,H=L*(f-1);let R=s,z=A+H;l(g)&&(R+=p.x*2,z+=p.y*2,g._labelHorizontalOrigin=b),no.x=P*C,no.y=0;let U=!0,v=0;for(h=0;h<_;++h)if(n.charAt(h)=== `
` )++w,v+=L,S=a[w],P=EV(S,b,p),no.x=P*C,U=!0;else if(i=t[h],o=i.dimensions,x===zi.TOP?(no.y=o.height-u-p.y,no.y+=Fa.PADDING):x===zi.CENTER?no.y=(H+o.height-u)/2:x===zi.BASELINE?(no.y=H,no.y-=Fa.PADDING):(no.y=H+c+p.y,no.y-=Fa.PADDING),no.y=(no.y-o.descent-v)*C,U&&(no.x-=Fa.PADDING*C,U=!1),l(i.billboard)&&(i.billboard._setTranslate(no),i.billboard._labelDimensions.x=R,i.billboard._labelDimensions.y=z,i.billboard._labelHorizontalOrigin=b),h<_-1){const I=t[h+1];no.x+=(o.width-o.minx+I.dimensions.minx)*C}if(l(g)&&n.split( `
` ).join("").length>0&&(b===ca.CENTER?P=-s/2-p.x:b===ca.RIGHT?P=-(s+p.x*2):P=0,no.x=P*C,x===zi.TOP?no.y=A-u-c:x===zi.CENTER?no.y=(A-u)/2-c:x===zi.BASELINE?no.y=-p.y-c:no.y=0,no.y=no.y*C,g.width=R,g.height=z,g._setTranslate(no),g._labelTranslate=j.clone(no,g._labelTranslate)),e.heightReference===bt.CLAMP_TO_GROUND)for(h=0;h<_;++h){i=t[h];const I=i.billboard;l(I)&&(I._labelTranslate=j.clone(no,I._labelTranslate))}}function LX(e,t){const n=t._glyphs;for(let i=0,o=n.length;i<o;++i)EL(e,n[i]);l(t._backgroundBillboard)&&(e._backgroundBillboardCollection.remove(t._backgroundBillboard),t._backgroundBillboard=void 0),t._labelCollection=void 0,l(t._removeCallbackFunc)&&t._removeCallbackFunc(),Ue(t)}function sc(e){e=y(e,y.EMPTY_OBJECT),this._scene=e.scene,this._batchTable=e.batchTable,this._textureAtlas=void 0,this._backgroundTextureAtlas=void 0,this._backgroundBillboardCollection=new js({scene:this._scene}),this._backgroundBillboardCollection.destroyTextureAtlas=!1,this._billboardCollection=new js({scene:this._scene,batchTable:this._batchTable}),this._billboardCollection.destroyTextureAtlas=!1,this._billboardCollection._sdf=!0,this._spareBillboards=[],this._glyphTextureCache={},this._labels=[],this._labelsToUpdate=[],this._totalGlyphCount=0,this._highlightColor=F.clone(F.WHITE),this.show=y(e.show,!0),this.modelMatrix=B.clone(y(e.modelMatrix,B.IDENTITY)),this.debugShowBoundingVolume=y(e.debugShowBoundingVolume,!1),this.blendOption=y(e.blendOption,Oo.OPAQUE_AND_TRANSLUCENT)}Object.defineProperties(sc.prototype,{length:{get:function(){return this._labels.length}}});sc.prototype.add=function(e){const t=new Fl(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};sc.prototype.remove=function(e){if(l(e)&&e._labelCollection===this){const t=this._labels.indexOf(e);if(t!==-1)return this._labels.splice(t,1),LX(this,e),!0}return!1};sc.prototype.removeAll=function(){const e=this._labels;for(let t=0,n=e.length;t<n;++t)LX(this,e[t]);e.length=0};sc.prototype.contains=function(e){return l(e)&&e._labelCollection===this};sc.prototype.get=function(e){if(!l(e))throw new E("index is required.");return this._labels[e]};sc.prototype.update=function(e){if(!this.show)return;const t=this._billboardCollection,n=this._backgroundBillboardCollection;t.modelMatrix=this.modelMatrix,t.debugShowBoundingVolume=this.debugShowBoundingVolume,n.modelMatrix=this.modelMatrix,n.debugShowBoundingVolume=this.debugShowBoundingVolume;const i=e.context;l(this._textureAtlas)||(this._textureAtlas=new Fu({context:i}),t.textureAtlas=this._textureAtlas),l(this._backgroundTextureAtlas)||(this._backgroundTextureAtlas=new Fu({context:i,initialSize:bL}),n.textureAtlas=this._backgroundTextureAtlas,k4e(this._backgroundTextureAtlas));const o=this._labelsToUpdate.length;for(let s=0;s<o;++s){const a=this._labelsToUpdate[s];if(a.isDestroyed())continue;const c=a._glyphs.length;a._rebindAllGlyphs&&(q4e(this,a),a._rebindAllGlyphs=!1),a._repositionAllGlyphs&&(X4e(a),a._repositionAllGlyphs=!1);const u=a._glyphs.length-c;this._totalGlyphCount+=u}const r=n.length>0?Oo.TRANSLUCENT:this.blendOption;t.blendOption=r,n.blendOption=r,t._highlightColor=this._highlightColor,n._highlightColor=this._highlightColor,this._labelsToUpdate.length=0,n.update(e),t.update(e)};sc.prototype.isDestroyed=function(){return!1};sc.prototype.destroy=function(){return this.removeAll(),this._billboardCollection=this._billboardCollection.destroy(),this._textureAtlas=this._textureAtlas&&this._textureAtlas.destroy(),this._backgroundBillboardCollection=this._backgroundBillboardCollection.destroy(),this._backgroundTextureAtlas=this._backgroundTextureAtlas&&this._backgroundTextureAtlas.destroy(),Ue(this)};const la={};la.numberOfPoints=function(e,t,n){const i=d.distance(e,t);return Math.ceil(i/n)};la.numberOfPointsRhumbLine=function(e,t,n){const 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))))};const $ 4e=new Ae;la.extractHeights=function(e,t){const n=e.length,i=new Array(n);for(let o=0;o<n;o++){const r=e[o];i[o]=t.cartesianToCartographic(r, $ 4e).hei
` ,this.material.shaderSource,u6]}),r=t.getVertexShaderCallback()(Vue),s=new Ge({defines:i,sources:[kC,r]});this.shaderProgram=un.fromCache({context:e,vertexShaderSource:s,fragmentShaderSource:o,attributeLocations:ya})};function kX(e){return d.dot(d.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(wt.ORIGIN_ZX_PLANE)===dn.INTERSECTING}nf.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===le.SCENE3D||!kX(e))return t=e._actualPositions.length,t*4-4;let n=0;const i=e._segments.lengths;t=i.length;for(let o=0;o<t;++o)n+=i[o]*4-4;return n};const ar=new d,Ec=new d,xc=new d,Nw=new d,TGe=new oe,bGe=new j;nf.prototype.write=function(e,t,n,i,o,r,s,a){const c=this.mode,u=a.ellipsoid.maximumRadius*N.PI,f=this.polylines,h=f.length;for(let _=0;_<h;++_){const g=f[_],p=g.width,A=g.show&&p>0,C=g._index,b=this.getSegments(g,a),x=b.positions,w=b.lengths,S=x.length,P=g.getPickId(s).color;let L=0,H=0,R;for(let V=0;V<S;++V){V===0?g._loop?R=x[S-2]:(R=Nw,d.subtract(x[0],x[1],R),d.add(x[0],R,R)):R=x[V-1],d.clone(R,Ec),d.clone(x[V],ar),V===S-1?g._loop?R=x[1]:(R=Nw,d.subtract(x[S-1],x[S-2],R),d.add(x[S-1],R,R)):R=x[V+1],d.clone(R,xc);const k=w[L];V===H+k&&(H+=k,++L);const W=V-H===0,G=V===H+w[L]-1;c===le.SCENE2D&&(Ec.z=0,ar.z=0,xc.z=0),(c===le.SCENE2D||c===le.MORPHING)&&(W||G)&&u-Math.abs(ar.x)<1&&((ar.x<0&&Ec.x>0||ar.x>0&&Ec.x<0)&&d.clone(ar,Ec),(ar.x<0&&xc.x>0||ar.x>0&&xc.x<0)&&d.clone(ar,xc));const K=W?2:0,q=G?2:4;for(let te=K;te<q;++te){En.writeElements(ar,e,n),En.writeElements(Ec,e,n+6),En.writeElements(xc,e,n+12);const X=te-2<0?-1:1;t[o]=V/(S-1),t[o+1]=2*(te%2)-1,t[o+2]=X,t[o+3]=C,n+=6*3,o+=4}}const z=TGe;z.x=F.floatToByte(P.red),z.y=F.floatToByte(P.green),z.z=F.floatToByte(P.blue),z.w=F.floatToByte(P.alpha);const U=bGe;U.x=p,U.y=A?1:0;const v=c===le.SCENE2D?g._boundingVolume2D:g._boundingVolumeWC,I=En.fromCartesian(v.center,FX),m=I.high,D=oe.fromElements(I.low.x,I.low.y,I.low.z,v.radius,zX),O=UX;O.x=0,O.y=Number.MAX_VALUE;const M=g.distanceDisplayCondition;l(M)&&(O.x=M.near,O.y=M.far),r.setBatchedAttribute(C,0,U),r.setBatchedAttribute(C,1,z),r.attributes.length>2&&(r.setBatchedAttribute(C,2,m),r.setBatchedAttribute(C,3,D),r.setBatchedAttribute(C,4,O))}};const EGe=new d,xGe=new d,wGe=new d,OV=new d;nf.prototype.writeForMorph=function(e,t){const n=this.modelMatrix,i=this.polylines,o=i.length;for(let r=0;r<o;++r){const s=i[r],a=s._segments.positions,c=s._segments.lengths,u=a.length;let f=0,h=0;for(let _=0;_<u;++_){let g;_===0?s._loop?g=a[u-2]:(g=OV,d.subtract(a[0],a[1],g),d.add(a[0],g,g)):g=a[_-1],g=B.multiplyByPoint(n,g,xGe);const p=B.multiplyByPoint(n,a[_],EGe);let A;_===u-1?s._loop?A=a[1]:(A=OV,d.subtract(a[u-1],a[u-2],A),d.add(a[u-1],A,A)):A=a[_+1],A=B.multiplyByPoint(n,A,wGe);const C=c[f];_===h+C&&(h+=C,++f);const b=_-h===0,x=_===h+c[f]-1,w=b?2:0,S=x?2:4;for(let P=w;P<S;++P)En.writeElements(p,e,t),En.writeElements(g,e,t+6),En.writeElements(A,e,t+12),t+=6*3}}};const SGe=new Array(1);nf.prototype.updateIndices=function(e,t,n,i){let o=n.length-1,r=new CP(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);const u=this.polylines,f=u.length;for(let h=0;h<f;++h){const _=u[h];_._locatorBuckets=[];let g;if(this.mode===le.SCENE3D){g=SGe;const A=_._actualPositions.length;if(A>0)g[0]=A;else continue}else g=_._segments.lengths;const p=g.length;if(p>0){let A=0;for(let C=0;C<p;++C){const b=g[C]-1;for(let x=0;x<b;++x)c+4>N.SIXTY_FOUR_KILOBYTES&&(_._locatorBuckets.push({locator:r,count:A}),A=0,t.push(4),a=[],e.push(a),c=0,r.count=s,s=0,i=0,r=new CP(0,0,this),n[++o]=[r]),a.push(c,c+2,c+1),a.push(c+1,c+2,c+3),A+=6,s+=6,i+=6,c+=4}_._locatorBuckets.push({locator:r,count:A}),c+4>N.SIXTY_FOUR_KILOBYTES&&(t.push(0),a=[],e.push(a),c=0,r.count=s,i=0,s=0,r=new CP(0,0,this),n[++o]=[r])}_._clean()}return r.count=s,i};nf.prototype.getPolylineStartIndex=function(e){const t=this.polylines;let n=0;const i=t.length;for(let o=0;o<i;++o){const r=t[o];if(r===e)break;n+=r._actualLength}return n};const k_={positions:void 0,lengths:void 0},LV=new Array(1),vGe=new d,DGe=new Ae;nf.prototype.getSegments=function(
void main ( )
{
gl _FragColor = u _highlightColor ;
}
` ;function t5e(e,t){if(l(e._sp))return;const n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(efe),o=n.getFragmentShaderCallback(!1,void 0,!1)(e5e),r=new Ge({defines:["VECTOR_TILE",an.isInternetExplorer()?"":"CLIP_POLYLINE"],sources:[kC,i]}),s=new Ge({defines:["VECTOR_TILE"],sources:[o]});e._sp=un.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:fg})}function n5e(e,t){if(!l(e._command)){const n=e._batchTable.getUniformMapCallback()(e._uniformMap);e._command=new ft({owner:e,vertexArray:e._va,renderState:e._rs,shaderProgram:e._sp,uniformMap:n,boundingVolume:e._boundingVolume,pass:Be.TRANSLUCENT,pickId:e._batchTable.getPickId()})}t.commandList.push(e._command)}Gc.getPolylinePositions=function(e,t){const n=e._batchIds,i=e._decodedPositions,o=e._decodedPositionOffsets;if(!l(n)||!l(i))return;let r,s;const a=n.length;let c=0,u=0;for(r=0;r<a;++r)n[r]===t&&(c+=o[r+1]-o[r]);if(c===0)return;const f=new Float64Array(c*3);for(r=0;r<a;++r)if(n[r]===t){const h=o[r],_=o[r+1]-h;for(s=0;s<_;++s){const g=(h+s)*3;f[u++]=i[g],f[u++]=i[g+1],f[u++]=i[g+2]}}return f};Gc.prototype.getPositions=function(e){return Gc.getPolylinePositions(this,e)};Gc.prototype.createFeatures=function(e,t){const n=this._batchIds,i=n.length;for(let o=0;o<i;++o){const r=n[o];t[r]=new Jr(e,r)}};Gc.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function i5e(e,t){const n=e._batchIds,i=n.length;for(let o=0;o<i;++o){const r=n[o],s=t[r];s.show=!0,s.color=F.WHITE}}const o5e=new F,r5e=F.WHITE,s5e=!0;Gc.prototype.applyStyle=function(e,t){if(!l(e)){i5e(this,t);return}const n=this._batchIds,i=n.length;for(let o=0;o<i;++o){const r=n[o],s=t[r];s.color=l(e.color)?e.color.evaluateColor(s,o5e):r5e,s.show=l(e.show)?e.show.evaluate(s):s5e}};function a5e(e){return new Promise(function(t,n){e._update=function(i,o){const r=o.context,s=KGe(i);if(QGe(i,r),t5e(i,r),ZGe(i),i._ready){const a=o.passes;(a.render||a.pick)&&n5e(i,o)}l(s)&&s.then(function(){JGe(i,r),t()}).catch(function(a){n(a)})}})}Gc.prototype.update=function(e){this._update(this,e)};Gc.prototype.isDestroyed=function(){return!1};Gc.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),Ue(this)};function gd(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=y(e.ellipsoid,pe.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 j(qi._defaultMinTerrainHeight,qi._defaultMaxTerrainHeight),this._boundingVolume=Lt.fromRectangle(e.rectangle,qi._defaultMinTerrainHeight,qi._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=F.clone(F.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._update=function(t,n){},this._readyPromise=T5e(this),this._verticesPromise=void 0}Object.defineProperties(gd.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},readyPromise:{get:function(){return this._readyPromise}}});function c5e(e,t,n){const i=qi.getMinimumMaximumHeights(t,n),o=i.minimumTerrainHeight,r=i.maximumTerrainHeight,s=e._minimumMaximumVectorHeights;s.x=o,s.y=r;const a=e._boundingVolume,c=e._rectangle;Lt.fromRectangle(c,o,r,n,a)}function l5e(e){c
Geometric error : $ { e . geometricError } ` ,o++),t.debugShowRenderingStatistics&&(i+= `
Commands : $ { e . commandsLength } ` ,o++,e.content.pointsLength>0&&(i+= `
Points : $ { e . content . pointsLength } ` ,o++),e.content.trianglesLength>0&&(i+= `
Triangles : $ { e . content . trianglesLength } ` ,o++),i+= `
Features : $ { e . content . featuresLength } ` ,o++),t.debugShowMemoryUsage&&(i+= `
Texture Memory : $ { XV ( e . content . texturesByteLength ) } ` ,i+= `
Geometry Memory : $ { XV ( e . content . geometryByteLength ) } ` ,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+= `
Urls : ` ;const s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+= `
- $ { s [ a ] } ` ;o+=s.length}else i+= `
Url : $ { e . _contentHeader . uri } ` ,o++;const 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 l6e(e,t){let n,i;const o=e._selectedTiles,r=o.length,s=e._emptyTiles,a=s.length;if(e._tileDebugLabels.removeAll(),e.debugPickedTileLabelOnly){if(l(e.debugPickedTile)){const c=l(e.debugPickPosition)?e.debugPickPosition:UP(e.debugPickedTile),u=HP(e.debugPickedTile,e,c);u.pixelOffset=new j(15,-15)}}else{for(n=0;n<r;++n)i=o[n],HP(i,e,UP(i));for(n=0;n<a;++n)i=s[n],(i.hasTilesetContent||i.hasImplicitContent)&&HP(i,e,UP(i))}e._tileDebugLabels.update(t)}function u6e(e,t,n){e._styleEngine.applyStyle(e),e._styleApplied=!0;const i=n.isRender,o=e._statistics,r=t.commandList,s=r.length,a=e._selectedTiles,c=a.length,u=e._emptyTiles,f=u.length,h=e.tileVisible;let _,g;const p=e._skipLevelOfDetail&&e._hasMixedContent&&t.context.stencilBuffer&&c>0;e._backfaceCommands.length=0,p&&(l(e._stencilClearCommand)||(e._stencilClearCommand=new ji({stencil:0,pass:Be.CESIUM_3D_TILE,renderState:Qe.fromCache({stencilMask:It.SKIP_LOD_MASK})})),r.push(e._stencilClearCommand));const A=r.length;for(_=0;_<c;++_)g=a[_],i&&h.raiseEvent(g),g.update(e,t,n),o.incrementSelectionCounts(g.content),++o.selected;for(_=0;_<f;++_)g=u[_],g.update(e,t,n);let C=r.length-A;if(e._backfaceCommands.trim(),p){const b=e._backfaceCommands.values,x=b.length;for(r.length+=x,_=C-1;_>=0;--_)r[A+x+_]=r[A+_];for(_=0;_<x;++_)r[A+_]=b[_]}C=r.length-s,o.numberOfCommands=C,i&&e.pointCloudShading.attenuation&&e.pointCloudShading.eyeDomeLighting&&C>0&&e._pointCloudEyeDomeLighting.update(t,s,e.pointCloudShading,e.boundingSphere),i&&(e.debugShowGeometricError||e.debugShowRenderingStatistics||e.debugShowMemoryUsage||e.debugShowUrl?(l(e._tileDebugLabels)||(e._tileDebugLabels=new sc),l6e(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}const f $ =[];function f6e(e,t){const n=t,i=f $ ;for(i.push(t);i.length>0;){t=i.pop();const o=t.children,r=o.length;for(let s=0;s<r;++s)i.push(o[s]);t!==n&&(d6e(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function d $ (e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function d6e(e,t){e._cache.unloadTile(e,t,d $ ),t.destroy()}_r.prototype.trimLoadedTiles=function(){this._cache.trim()};function h6e(e,t){const n=e._statistics,i=e._statisticsLast,o=n.numberOfPendingRequests,r=n.numberOfTilesProcessing,s=i.numberOfPendingRequests,a=i.numberOfTilesProcessing;Du.clone(n,i);const 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 p6e(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 m6e(e,t){(t.frameNumber!==e._updatedModelMatrixFrame||!l(e._previousModelMatrix))&&(e._updatedModelMatrixFrame=t.frameNumber,e._modelMatrixChanged=!B.equals(e.modelMatrix,e._previousModelMatrix),e._modelMatrixChanged&&(e._previousModelMatrix=B.clone(e.modelMatrix,e._previousModelMatrix)))}function _6e(e,t,n,i){if(t.mode===le.MORPHING||!e.ready)return!1;const o=e._statistics;o.clear();const r=i.isRender;++e._updatedVisibilityFrame,p6e(e),m6e(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;const s=i.traversal.selectTiles(e,t);if(i.requestTiles&&n6e(e),u6e(e,t,i),Du.clone(o,n)
vec4 clippingPlanesEdgeColor = vec4 ( 1.0 ) ;
clippingPlanesEdgeColor . rgb = $ { n } . rgb ;
float clippingPlanesEdgeWidth = $ { n } . a ;
if ( clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth )
{
gl _FragColor = clippingPlanesEdgeColor ;
}
` }const aXe={modifyFragmentShader:function(t){return t=Ge.replaceMain(t,"czm_splitter_main"),t+= ` uniform float czm _splitDirection ;
void main ( )
{
# ifndef SHADOW _MAP
if ( czm _splitDirection < 0.0 && gl _FragCoord . x > czm _splitPosition ) discard ;
if ( czm _splitDirection > 0.0 && gl _FragCoord . x < czm _splitPosition ) discard ;
# endif
czm _splitter _main ( ) ;
}
` ,t},addUniforms:function(t,n){n.czm_splitDirection=function(){return t.splitDirection}}},EJ=aXe,om={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function ST(e){T.typeOf.object("options",e),T.typeOf.object("options.arrayBuffer",e.arrayBuffer),this._parsedContent=void 0,this._drawCommand=void 0,this._isTranslucent=!1,this._styleTranslucent=!1,this._constantColor=F.clone(F.DARKGRAY),this._highlightColor=F.clone(F.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=om.READY,this._dequantizeInShader=!0,this._isQuantizedDraco=!1,this._isOctEncodedDraco=!1,this._quantizedRange=0,this._octEncodedRange=0,this.backFaceCulling=!1,this._backFaceCulling=!1,this.normalShading=!0,this._normalShading=!0,this._opaqueRenderState=void 0,this._translucentRenderState=void 0,this._mode=void 0,this._ready=!1,this._pointsLength=0,this._geometryByteLength=0,this._vertexShaderLoaded=e.vertexShaderLoaded,this._fragmentShaderLoaded=e.fragmentShaderLoaded,this._uniformMapLoaded=e.uniformMapLoaded,this._batchTableLoaded=e.batchTableLoaded,this._pickIdLoaded=e.pickIdLoaded,this._opaquePass=y(e.opaquePass,Be.OPAQUE),this._cull=y(e.cull,!0),this.style=void 0,this._style=void 0,this.styleDirty=!1,this.modelMatrix=B.clone(B.IDENTITY),this._modelMatrix=B.clone(B.IDENTITY),this.time=0,this.shadows=fo.ENABLED,this._boundingSphere=void 0,this.clippingPlanes=void 0,this.isClipped=!1,this.clippingPlanesDirty=!1,this.clippingPlanesOriginMatrix=void 0,this.attenuation=!1,this._attenuation=!1,this.geometricError=0,this.geometricErrorScale=1,this.maximumAttenuation=this._pointSize,this.splitDirection=y(e.splitDirection,Qm.NONE),this._splittingEnabled=!1,this._resolveReadyPromise=void 0,this._rejectReadyPromise=void 0,this._readyPromise=cXe(this,e)}Object.defineProperties(ST.prototype,{pointsLength:{get:function(){return this._pointsLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},ready:{get:function(){return this._ready}},readyPromise:{get:function(){return this._readyPromise}},color:{get:function(){return F.clone(this._highlightColor)},set:function(e){this._highlightColor=F.clone(e,this._highlightColor)}},boundingSphere:{get:function(){if(l(this._drawCommand))return this._drawCommand.boundingVolume},set:function(e){this._boundingSphere=fe.clone(e,this._boundingSphere)}}});function cXe(e,t){const n=ZY.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=pi.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),l(n.draco)){const a=n.draco;e._decodingState=om.NEEDS_DECODE,a.dequantizeInShader=e._dequantizeInShader}const i=n.positions;l(i)&&(e._isQuantized=i.isQuantized,e._quantizedVolumeScale=i.quantizedVolumeScale,e._quantizedVolumeOffset=i.quantizedVolumeOffset,e._quantizedRange=i.quantizedRange);const o=n.normals;l(o)&&(e._isOctEncoded16P=o.octEncoded);const r=n.colors;l(r)&&(l(r.constantColor)&&(e._constantColor=F.clone(r.constantColor,e._constantColor),e._hasColors=!1),e._isRGB565=r.isRGB565);const s=n.batchIds;return 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,new Promise(function(a,c){e._resolveReadyPromise=function(){e._ready=!0,a(e)},e._rejectReadyPromise=c})}const lXe=new d,uXe=new d,fXe=new d;let w4,VE;function dXe(e){if(!l(VE)){w4=new hS(0),VE=new Array(e);for(let t=0;t<e;++t)VE[t]=w4.random()}return VE}function hXe(e){const n=e.length/3,i=Math.min(n,20),o=dXe(20),r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=d.fromElements(r,r,r,lXe),c=d.fromElements(s,s,s,uXe);for(let f=0;f<i;++f){const h=Math.floor(o[f]*n),_=d.unpack(e,h*
` ));const n=/czm_3dtiles_builtin_property_( \w +)/g;let i=n.exec(e);for(;i!==null;){const o=i[1];t.indexOf(o)===-1&&t.push(o),i=n.exec(e)}}function yO(e,t){const n=e.numberOfAttributes;for(let i=0;i<n;++i){const o=e.getAttribute(i);if(o.index===t)return o}}const TXe={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 bXe(e,t,n){let i,o,r;const s=t.context,a=l(n),c=e._isQuantized,u=e._isQuantizedDraco,f=e._isOctEncoded16P,h=e._isOctEncodedDraco,_=e._isRGB565,g=e._isTranslucent,p=e._hasColors,A=e._hasNormals,C=e._hasBatchIds,b=e._backFaceCulling,x=e._normalShading,w=e._drawCommand.vertexArray,S=e.clippingPlanes,P=e._attenuation;let L,H,R,z=g;const U=lt(TXe),v={},I=e._styleableShaderAttributes;for(o in I)I.hasOwnProperty(o)&&(r=I[o],U[o]= ` czm _3dtiles _property _$ { r . location } ` ,v[r.location]=r);if(a){const re={translucent:!1},he="(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)";L=n.getColorShaderFunction( ` getColorFromStyle$ { he } ` ,U,re),H=n.getShowShaderFunction( ` getShowFromStyle$ { he } ` ,U,re),R=n.getPointSizeShaderFunction( ` getPointSizeFromStyle$ { he } ` ,U,re),l(L)&&re.translucent&&(z=!0)}e._styleTranslucent=z;const m=l(L),D=l(H),O=l(R),M=e.isClipped,V=[],k=[];m&&(_O(L,V),gO(L,k)),D&&(_O(H,V),gO(H,k)),O&&(_O(R,V),gO(R,k));const W=k.indexOf("COLOR")>=0,G=k.indexOf("NORMAL")>=0;if(G&&!A)throw new Se("Style references the NORMAL semantic but the point cloud does not have normals");for(o in I)if(I.hasOwnProperty(o)){r=I[o];const re=V.indexOf(r.location)>=0,he=yO(w,r.location);he.enabled=re}const K=p&&(!m||W);if(p){const re=yO(w,Ww);re.enabled=K}const q=A&&(x||b||G);if(A){const re=yO(w,kL);re.enabled=q}const te={a_position:xJ};K&&(te.a_color=Ww),q&&(te.a_normal=kL),C&&(te.a_batchId=wJ);let X="";const $ =V.length;for(i=0;i< $ ;++i){const re=V[i];r=v[re];const he=r.componentCount,ce= ` czm _3dtiles _property _$ { re } ` ;let Q;he===1?Q="float":Q= ` vec$ { he } ` ,X+= ` attribute $ { Q } $ { ce } ;
` ,te[ce]=r.location}CXe(e,t);let Y= ` attribute vec3 a _position ;
varying vec4 v _color ;
uniform vec4 u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier ;
uniform vec4 u _constantColor ;
uniform vec4 u _highlightColor ;
` ;Y+= ` float u _pointSize ;
float tiles3d _tileset _time ;
` ,P&&(Y+= ` float u _geometricError ;
float u _depthMultiplier ;
` ),Y+=X,K&&(g?Y+= ` attribute vec4 a _color ;
` :_?Y+= ` attribute float a _color ;
const float SHIFT _RIGHT _11 = 1.0 / 2048.0 ;
const float SHIFT _RIGHT _5 = 1.0 / 32.0 ;
const float SHIFT _LEFT _11 = 2048.0 ;
const float SHIFT _LEFT _5 = 32.0 ;
const float NORMALIZE _6 = 1.0 / 64.0 ;
const float NORMALIZE _5 = 1.0 / 32.0 ;
` :Y+= ` attribute vec3 a _color ;
` ),q&&(f||h?Y+= ` attribute vec2 a _normal ;
` :Y+= ` attribute vec3 a _normal ;
` ),C&&(Y+= ` attribute float a _batchId ;
` ),(c||u||h)&&(Y+= ` uniform vec4 u _quantizedVolumeScaleAndOctEncodedRange ;
` ),m&&(Y+=L),D&&(Y+=H),O&&(Y+=R),Y+= ` void main ( )
{
u _pointSize = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . x ;
tiles3d _tileset _time = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . y ;
` ,P&&(Y+= ` u _geometricError = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . z ;
u _depthMultiplier = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . w ;
` ),K?g?Y+= ` vec4 color = a _color ;
` :_?Y+= ` float compressed = a _color ;
float r = floor ( compressed * SHIFT _RIGHT _11 ) ;
compressed -= r * SHIFT _LEFT _11 ;
float g = floor ( compressed * SHIFT _RIGHT _5 ) ;
compressed -= g * SHIFT _LEFT _5 ;
float b = compressed ;
vec3 rgb = vec3 ( r * NORMALIZE _5 , g * NORMALIZE _6 , b * NORMALIZE _5 ) ;
vec4 color = vec4 ( rgb , 1.0 ) ;
` :Y+= ` vec4 color = vec4 ( a _color , 1.0 ) ;
` :Y+= ` vec4 color = u _constantColor ;
` ,c||u?Y+= ` vec3 position = a _position * u _quantizedVolumeScaleAndOctEncodedRange . xyz ;
` :Y+= ` vec3 position = a _position ;
` ,Y+= ` vec3 position _absolute = vec3 ( czm _model * vec4 ( position , 1.0 ) ) ;
` ,q?(f?Y+= ` vec3 normal = czm _octDecode ( a _normal ) ;
` :h?Y+= ` vec3 normal = czm _octDecode ( a _normal , u _quantizedVolumeScaleAndOctEncodedRange . w ) . zxy ;
` :Y+= ` vec3 normal = a _normal ;
` ,Y+= ` vec3 normalEC = czm _normal * normal ;
` ):Y+= ` vec3 normal = vec3 ( 1.0 ) ;
` ,m&&(Y+= ` color = getColorFromStyle ( position , position _absolute , color , normal ) ;
` ),D&&(Y+= ` float show = float ( getShowFromStyle ( position , position _absolute , color , normal ) ) ;
` ),O?Y+= ` gl _PointSize = getPointSizeFromStyle ( position , position _absolute , color , normal ) * czm _pixelRatio ;
` :P?Y+= ` vec4 positionEC = czm _modelView * vec4 ( position , 1.0 ) ;
float depth = - positionEC . z ;
gl _PointSize = min ( ( u _geometricError / depth ) * u _depthMultiplier , u _pointSize ) ;
` :Y+= ` gl _PointSize = u _pointSize ;
` ,Y+= ` color = color * u _highlightColor ;
` ,q&&x&&(Y+= ` float diffuseStrength = czm _getLambertDiffuse ( czm _lightDirectionEC , normalEC ) ;
diffuseStrength = max ( diffuseStrength , 0.4 ) ;
color . xyz *= diffuseStrength * czm _lightColor ;
` ),Y+= ` v _color = color ;
gl _Position = czm _modelViewProjection * vec4 ( position , 1.0 ) ;
` ,q&&b&&(Y+= ` float visible = step ( - normalEC . z , 0.0 ) ;
gl _Position *= visible ;
gl _PointSize *= visible ;
` ),D&&(Y+= ` gl _Position . w *= float ( show ) ;
gl _PointSize *= float ( show ) ;
` ),Y+= ` }
` ;let ae= ` varying vec4 v _color ;
` ;M&&(ae+= ` uniform highp sampler2D u _clippingPlanes ;
uniform mat4 u _clippingPlanesMatrix ;
uniform vec4 u _clippingPlanesEdgeStyle ;
` ,ae+= `
` ,ae+=dR(S,s),ae+= `
` ),ae+= ` void main ( )
{
gl _FragColor = czm _gammaCorrect ( v _color ) ;
` ,M&&(ae+=sXe("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),ae+= ` }
` ,e.splitDirection!==Qm.NONE&&(ae=EJ.modifyFragmentShader(ae)),l(e._vertexShaderLoaded)&&(Y=e._vertexShaderLoaded(Y)),l(e._fragmentShaderLoaded)&&(ae=e._fragmentShaderLoaded(ae));const ue=e._drawCommand;l(ue.shaderProgram)&&ue.shaderProgram.destroy(),ue.shaderProgram=un.fromCache({context:s,vertexShaderSource:Y,fragmentShaderSource:ae,attributeLocations:te});try{ue.shaderProgram._bind()}catch{throw new Se("Error generating style shader: this may be caused by a type mismatch, index out-of-bounds, or other syntax error.")}}function EXe(e,t){if(e._decodingState===om.READY)return!1;if(e._decodingState===om.NEEDS_DECODE){const n=e._parsedContent,i=n.draco,o=Gr.decodePointCloud(i,t);l(o)&&(e._decodingState=om.DECODING,o.then(function(r){e._decodingState=om.READY;const 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,u=l(r.NORMAL)?r.NORMAL.array:void 0,f=l(r.BATCH_ID)?r.BATCH_ID.array:void 0,h=l(s)&&l(r.POSITION.data.quantization),_=l(u)&&l(r.NORMAL.data.quantization);if(h){const C=r.POSITION.data.quantization,b=C.range;e._quantizedVolumeScale=d.fromElements(b,b,b),e._quantizedVolumeOffset=d.unpack(C.minValues),e._quantizedRange=(1<<C.quantizationBits)-1,e._isQuantizedDraco=!0}_&&(e._octEncodedRange=(1<<r.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let g=n.styleableProperties;const p=i.batchTableProperties;for(const C in p)if(p.hasOwnProperty(C)){const b=r[C];l(g)||(g={}),g[C]={typedArray:b.array,componentCount:b.data.componentsPerAttribute}}l(s)&&(n.positions={typedArray:s});const A=y(c,a);l(A)&&(n.colors={typedArray:A}),l(u)&&(n.normals={typedArray:u}),l(f)&&(n.batchIds={typedArray:f}),n.styleableProperties=g}).catch(function(r){e._decodingState=om.FAILED,e._rejectReadyPromise(r)}))}return!0}const xXe=new oe,wXe=new d;ST.prototype.update=function(e){const t=e.context;if(EXe(this,t))return;let i=!1,o=!B.equals(this._modelMatrix,this.modelMatrix);if(this._mode!==e.mode&&(this._mode=e.mode,o=!0),l(this._drawCommand)||(AXe(this,e),o=!0,i=!0,this._resolveReadyPromise(),this._parsedContent=void 0),o){B.clone(this.modelMatrix,this._modelMatrix);const u=this._drawCommand.modelMatrix;if(B.clone(this._modelMatrix,u),l(this._rtcCenter)&&B.multiplyByTranslation(u,this._rtcCenter,u),l(this._quantizedVolumeOffset)&&B.multiplyByTranslation(u,this._quantizedVolumeOffset,u),e.mode!==le.SCENE3D){const h=e.mapProjection,_=B.getColumn(u,3,xXe);oe.equals(_,oe.UNIT_W)||Qt.basisTo2D(h,u,u)}const f=this._drawCommand.boundingVolume;if(fe.clone(this._boundingSphere,f),this._cull){const h=f.center;B.multiplyByPoint(u,h,h);const _=B.getScale(u,wXe);f.radius*=d.maximumComponent(_)}}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);const r=this.splitDirection!==Qm.NONE;this._splittingEnabled!==r&&(this._splittingEnabled=r,i=!0),i&&bXe(this,e,this._style),this._drawCommand.castShadows=fo.castShadows(this.shadows),this._drawCommand.receiveShadows=fo.receiveShadows(this.shadows);const s=this._highlightColor.alpha<1||this._constantColor.alpha<1||this._styleTranslucent;this._drawCommand.renderState=s?this._translucentRenderState:this._opaqueRenderState,this._drawCommand.pass=s?Be.TRANSLUCENT:this._opaquePass;const a=e.commandList,c=e.passes;(c.render||c.pick)&&a.push(this._drawCommand)};ST.prototype.isDestroyed=function(){return!1};ST.prototype.destroy=function(){const e=this._drawCommand;return l(e)&&(e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy()),Ue(this)};function el(e,t,n,i,o,r,s){this.children=void 0,this.parent=o,this.level=e,this.x=t,this.y=n,this.z=i,this.keyframeNodes=[],this.renderableKeyframeNodes=[],this.renderableKeyframeNodeLerp=0,this.rende
$ { e } ` }function DXe(e){return function(t){return nn(t,{czm_pickColor:function(){return e._pickId.color}})}}function IXe(){return"czm_pickColor"}pp.prototype.makeStyleDirty=function(){this._styleDirty=!0};pp.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};const PXe=new ne;function sM(e){const t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function Gm(e,t){return e._intervals.indexOf(t.start)}function OXe(e,t){const n=e._intervals,i=e._clock,o=sM(e);if(o===0)return;const r=e._getAverageLoadTime(),s=ne.addSeconds(i.currentTime,r*o,PXe);let a=n.indexOf(s);const c=Gm(e,t);return a===c&&(o>=0?++a:--a),n.get(a)}function LXe(e){const t=e._intervals,i=e._clock.currentTime,o=t.indexOf(i);return t.get(o)}function BXe(e,t,n){const i=sM(e),o=Gm(e,t),r=Gm(e,n);return i>=0?o>=r:o<=r}function RXe(e,t){return function(n){const 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 NXe(e,t,n){const i=Gm(e,t),o=e._frames;let r=o[i];if(!l(r)){const s=t.data.transform,a=l(s)?B.fromArray(s):void 0,c=t.data.uri;r={pointCloud:void 0,transform:a,timestamp:Yo(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber},o[i]=r,Re.fetchArrayBuffer({url:c}).then(function(u){return r.pointCloud=new ST({arrayBuffer:u,cull:!0,fragmentShaderLoaded:vXe,uniformMapLoaded:DXe(e),pickIdLoaded:IXe}),r.pointCloud.readyPromise}).catch(RXe(e,c))}return r}function MXe(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 FXe(e,t,n,i){t.touchedFrameNumber<i.frameNumber-1&&(t.sequential=!1);const o=t.pointCloud;if(l(o)&&!t.ready){const r=i.commandList,s=r.length;if(SJ(e,t,n,i),o.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=o.geometryByteLength,r.length=s,t.sequential)){const a=(Yo()-t.timestamp)/1e3;MXe(e,a)}}t.touchedFrameNumber=i.frameNumber}const zXe=new B;function UXe(e,t){const n=e.shading;return l(n)&&l(n.baseResolution)?n.baseResolution:l(t.boundingSphere)?N.cbrt(t.boundingSphere.volume()/t.pointsLength):0}function HXe(e){const t=e.shading;return l(t)&&l(t.maximumAttenuation)?t.maximumAttenuation:10}const VXe=new hT;function SJ(e,t,n,i){const o=y(e.shading,VXe),r=t.pointCloud,s=y(t.transform,B.IDENTITY);r.modelMatrix=B.multiplyTransformation(e.modelMatrix,s,zXe),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=UXe(e,r),r.geometricErrorScale=o.geometricErrorScale,r.maximumAttenuation=HXe(e),r.update(i),t.touchedFrameNumber=i.frameNumber}function GL(e,t,n,i){const o=NXe(e,t,i);FXe(e,o,n,i)}function kXe(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function vJ(e,t){const n=e._frames,i=n.length;for(let o=0;o<i;++o){const r=n[o];if(l(r)&&(!l(t)||t(r))){const 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 GXe(e,t){const n=Gm(e,t),i=e._frames[n];if(l(i)&&i.ready)return i}function D4(e,t,n,i,o){return l(n)?n.ready?!0:(GL(e,t,i,o),n.ready):!1}function WXe(e,t,n,i,o){let r,s,a;const c=e._intervals,u=e._frames,f=Gm(e,n),h=Gm(e,t);if(f>=h){for(r=f;r>=h;--r)if(s=c.get(r),a=u[r],D4(e,s,a,i,o))return s}else for(r=f;r<=h;++r)if(s=c.get(r),a=u[r],D4(e,s,a,i,o))return s;return t}function jXe(e,t,n){const i=e._frames,o=i.length;for(let r=0;r<o;++r){const s=i[r];l(s)&&l(s.pointCloud)&&(s.pointCloud.clippingPlanesDirty=t,s.pointCloud.styleDirty=n)}}const tg={timeSinceLoad:0,isClipped:!1,clippingPlanesDirty:!1};pp.prototype.update=function(e){if(e.mode===le.MORPHING||!this.show)return;l(this._pickId)||(thi
// See IntersectionUtils.glsl for the definition of nextIntersection
// See convertUvToBox.glsl, convertUvToCylinder.glsl, or convertUvToEllipsoid.glsl
// for the definition of convertUvToShapeUvSpace. The appropriate function is
// selected based on the VoxelPrimitive shape type, and added to the shader in
// Scene/VoxelRenderResources.js.
// See Octree.glsl for the definitions of TraversalData, SampleData,
// traverseOctreeFromBeginning, and traverseOctreeFromExisting
// See Megatexture.glsl for the definition of accumulatePropertiesFromMegatexture
# define STEP _COUNT _MAX 1000 // Harcoded value because GLSL doesn't like variable length loops
# define ALPHA _ACCUM _MAX 0.98 // Must be > 0.0 and <= 1.0
uniform mat3 u _transformDirectionViewToLocal ;
uniform vec3 u _cameraPositionUv ;
# if defined ( PICKING )
uniform vec4 u _pickColor ;
# endif
# if defined ( JITTER )
float hash ( vec2 p )
{
vec3 p3 = fract ( vec3 ( p . xyx ) * 50.0 ) ; // magic number = hashscale
p3 += dot ( p3 , p3 . yzx + 19.19 ) ;
return fract ( ( p3 . x + p3 . y ) * p3 . z ) ;
}
# endif
void main ( )
{
vec4 fragCoord = gl _FragCoord ;
vec2 screenCoord = ( fragCoord . xy - czm _viewport . xy ) / czm _viewport . zw ; // [0,1]
vec3 eyeDirection = normalize ( czm _windowToEyeCoordinates ( fragCoord ) . xyz ) ;
vec3 viewDirWorld = normalize ( czm _inverseViewRotation * eyeDirection ) ; // normalize again just in case
vec3 viewDirUv = normalize ( u _transformDirectionViewToLocal * eyeDirection ) ; // normalize again just in case
vec3 viewPosUv = u _cameraPositionUv ;
Intersections ix ;
vec2 entryExitT = intersectScene ( screenCoord , viewPosUv , viewDirUv , ix ) ;
// Exit early if the scene was completely missed.
if ( entryExitT . x == NO _HIT ) {
discard ;
}
float currT = entryExitT . x ;
float endT = entryExitT . y ;
vec3 positionUv = viewPosUv + currT * viewDirUv ;
// TODO: is it possible for this to be out of bounds, and does it matter?
vec3 positionUvShapeSpace = convertUvToShapeUvSpace ( positionUv ) ;
// Traverse the tree from the start position
TraversalData traversalData ;
SampleData sampleDatas [ SAMPLE _COUNT ] ;
traverseOctreeFromBeginning ( positionUvShapeSpace , traversalData , sampleDatas ) ;
// TODO:
// - jitter doesn't affect the first traversal?
// - jitter is always > 0?
// - jitter is only applied at one step?
# if defined ( JITTER )
float noise = hash ( screenCoord ) ; // [0,1]
currT += noise * traversalData . stepT ;
positionUv += noise * traversalData . stepT * viewDirUv ;
# endif
FragmentInput fragmentInput ;
# if defined ( STATISTICS )
setStatistics ( fragmentInput . metadata . statistics ) ;
# endif
vec4 colorAccum = vec4 ( 0.0 ) ;
for ( int stepCount = 0 ; stepCount < STEP _COUNT _MAX ; ++ stepCount ) {
// Read properties from the megatexture based on the traversal state
Properties properties = accumulatePropertiesFromMegatexture ( sampleDatas ) ;
// Prepare the custom shader inputs
copyPropertiesToMetadata ( properties , fragmentInput . metadata ) ;
fragmentInput . voxel . positionUv = positionUv ;
fragmentInput . voxel . positionShapeUv = positionUvShapeSpace ;
fragmentInput . voxel . positionUvLocal = sampleDatas [ 0 ] . tileUv ;
fragmentInput . voxel . viewDirUv = viewDirUv ;
fragmentInput . voxel . viewDirWorld = viewDirWorld ;
fragmentInput . voxel . travelDistance = traversalData . stepT ;
// Run the custom shader
czm _modelMaterial materialOutput ;
fragmentMain ( fragmentInput , materialOutput ) ;
// Sanitize the custom shader output
vec4 color = vec4 ( materialOutput . diffuse , materialOutput . alpha ) ;
color . rgb = max ( color . rgb , vec3 ( 0.0 ) ) ;
color . a = clamp ( color . a , 0.0 , 1.0 ) ;
// Pre-multiplied alpha blend
colorAccum += ( 1.0 - colorAccum . a ) * vec4 ( color . rgb * color . a , color . a ) ;
// Stop traversing if the alpha has been fully saturated
if ( colorAccum . a > ALPHA _ACCUM _MAX ) {
colorAccum . a = ALPHA _ACCUM _MAX ;
break ;
}
if ( traversalData . stepT == 0.0 ) {
// Shape is infinitely thin, no need to traverse further
break ;
}
// Keep raymarching
currT += traversalData . stepT ;
positionUv += traversalData . stepT * viewDirUv ;
// Check if there's more intersections.
if ( currT > endT ) {
# if ( INTERSECTION _COUNT == 1 )
break ;
# else
vec2 entryExitT = nextIntersection ( ix ) ;
if ( entryExitT . x == NO _HIT ) {
break ;
} else {
// Found another intersection. Resume raymarching there
currT = entryExitT . x ;
endT = entryExitT . y ;
positionUv = viewPosUv + currT * viewDirUv ;
}
# endif
}
// Traverse the tree from the current ray position.
// This is similar to traverseOctree but is faster when the ray is in the same tile as the previous step.
positionUvShapeSpace = convertUvToShapeUvSpace ( positionUv ) ;
traverseOctreeFromExisting ( positionUvShapeSpace , traversalData , sampleDatas ) ;
}
// Convert the alpha from [0,ALPHA_ACCUM_MAX] to [0,1]
colorAccum . a /= ALPHA _ACCUM _MAX ;
# if defined ( PICKING )
// If alpha is 0.0 there is nothing to pick
if ( colorAccum . a == 0.0 ) {
discard ;
}
gl _FragColor = u _pickColor ;
# else
gl _FragColor = colorAccum ;
# endif
}
` ,YXe= ` attribute vec2 position ;
uniform vec4 u _ndcSpaceAxisAlignedBoundingBox ;
void main ( ) {
vec2 aabbMin = u _ndcSpaceAxisAlignedBoundingBox . xy ;
vec2 aabbMax = u _ndcSpaceAxisAlignedBoundingBox . zw ;
vec2 translation = 0.5 * ( aabbMax + aabbMin ) ;
vec2 scale = 0.5 * ( aabbMax - aabbMin ) ;
gl _Position = vec4 ( position * scale + translation , 0.0 , 1.0 ) ;
}
` ,XXe= ` / * Intersection defines
# define INTERSECTION _COUNT # # #
* /
# define NO _HIT ( - czm _infinity )
# define INF _HIT ( czm _infinity * 0.5 )
struct Ray {
vec3 pos ;
vec3 dir ;
} ;
struct Intersections {
// Don't access these member variables directly - call the functions instead.
# if ( INTERSECTION _COUNT > 1 )
// Store an array of intersections. Each intersection is composed of:
// x for the T value
// y for the shape type - which encodes positive vs negative and entering vs exiting
// For example:
// y = 0: positive shape entry
// y = 1: positive shape exit
// y = 2: negative shape entry
// y = 3: negative shape exit
vec2 intersections [ INTERSECTION _COUNT * 2 ] ;
// Maintain state for future nextIntersection calls
int index ;
int surroundCount ;
bool surroundIsPositive ;
# else
// When there's only one positive shape intersection none of the extra stuff is needed.
float intersections [ 2 ] ;
# endif
} ;
// Using a define instead of a real function because WebGL1 cannot access array with non-constant index.
# if ( INTERSECTION _COUNT > 1 )
# define getIntersection ( /*inout Intersections*/ ix , /*int*/ index ) ( ix ) . intersections [ ( index ) ] . x
# else
# define getIntersection ( /*inout Intersections*/ ix , /*int*/ index ) ( ix ) . intersections [ ( index ) ]
# endif
// Using a define instead of a real function because WebGL1 cannot access array with non-constant index.
# define getIntersectionPair ( /*inout Intersections*/ ix , /*int*/ index ) vec2 ( getIntersection ( ( ix ) , ( index ) * 2 + 0 ) , getIntersection ( ( ix ) , ( index ) * 2 + 1 ) )
// Using a define instead of a real function because WebGL1 cannot access array with non-constant index.
# if ( INTERSECTION _COUNT > 1 )
# define setIntersection ( /*inout Intersections*/ ix , /*int*/ index , /*float*/ t , /*bool*/ positive , /*enter*/ enter ) ( ix ) . intersections [ ( index ) ] = vec2 ( ( t ) , float ( ! positive ) * 2.0 + float ( ! enter ) )
# else
# define setIntersection ( /*inout Intersections*/ ix , /*int*/ index , /*float*/ t , /*bool*/ positive , /*enter*/ enter ) ( ix ) . intersections [ ( index ) ] = ( t )
# endif
// Using a define instead of a real function because WebGL1 cannot access array with non-constant index.
# if ( INTERSECTION _COUNT > 1 )
# define setIntersectionPair ( /*inout Intersections*/ ix , /*int*/ index , /*vec2*/ entryExit ) ( ix ) . intersections [ ( index ) * 2 + 0 ] = vec2 ( ( entryExit ) . x , float ( ( index ) > 0 ) * 2.0 + 0.0 ) ; ( ix ) . intersections [ ( index ) * 2 + 1 ] = vec2 ( ( entryExit ) . y , float ( ( index ) > 0 ) * 2.0 + 1.0 )
# else
# define setIntersectionPair ( /*inout Intersections*/ ix , /*int*/ index , /*vec2*/ entryExit ) ( ix ) . intersections [ ( index ) * 2 + 0 ] = ( entryExit ) . x ; ( ix ) . intersections [ ( index ) * 2 + 1 ] = ( entryExit ) . y
# endif
# if ( INTERSECTION _COUNT > 1 )
void initializeIntersections ( inout Intersections ix ) {
// Sort the intersections from min T to max T with bubble sort.
// Note: If this sorting function changes, some of the intersection test may
// need to be updated. Search for "bubble sort" to find those areas.
const int sortPasses = INTERSECTION _COUNT * 2 - 1 ;
for ( int n = sortPasses ; n > 0 ; -- n ) {
for ( int i = 0 ; i < sortPasses ; ++ i ) {
// The loop should be: for (i = 0; i < n; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to break early instead
if ( i >= n ) { break ; }
vec2 intersect0 = ix . intersections [ i + 0 ] ;
vec2 intersect1 = ix . intersections [ i + 1 ] ;
float t0 = intersect0 . x ;
float t1 = intersect1 . x ;
float b0 = intersect0 . y ;
float b1 = intersect1 . y ;
float tmin = min ( t0 , t1 ) ;
float tmax = max ( t0 , t1 ) ;
float bmin = tmin == t0 ? b0 : b1 ;
float bmax = tmin == t0 ? b1 : b0 ;
ix . intersections [ i + 0 ] = vec2 ( tmin , bmin ) ;
ix . intersections [ i + 1 ] = vec2 ( tmax , bmax ) ;
}
}
// Prepare initial state for nextIntersection
ix . index = 0 ;
ix . surroundCount = 0 ;
ix . surroundIsPositive = false ;
}
# endif
# if ( INTERSECTION _COUNT > 1 )
vec2 nextIntersection ( inout Intersections ix ) {
vec2 entryExitT = vec2 ( NO _HIT ) ;
const int passCount = INTERSECTION _COUNT * 2 ;
if ( ix . index == passCount ) {
return entryExitT ;
}
for ( int i = 0 ; i < passCount ; ++ i ) {
// The loop should be: for (i = ix.index; i < passCount; ++i) {...} but WebGL1 cannot
// loop with non-constant condition, so it has to continue instead.
if ( i < ix . index ) {
continue ;
}
ix . index = i + 1 ;
vec2 intersect = ix . intersections [ i ] ;
float t = intersect . x ;
bool currShapeIsPositive = intersect . y < 2.0 ;
bool enter = mod ( intersect . y , 2.0 ) == 0.0 ;
ix . surroundCount += enter ? + 1 : - 1 ;
ix . surroundIsPositive = currShapeIsPositive ? enter : ix . surroundIsPositive ;
// entering positive or exiting negative
if ( ix . surroundCount == 1 && ix . surroundIsPositive && enter == currShapeIsPositive ) {
entryExitT . x = t ;
}
// exiting positive or entering negative after being inside positive
// TODO: Can this be simplified?
bool exitPositive = ! enter && currShapeIsPositive && ix . surroundCount == 0 ;
bool enterNegativeFromPositive = enter && ! currShapeIsPositive && ix . surroundCount == 2 && ix . surroundIsPositive ;
if ( exitPositive || enterNegativeFromPositive ) {
entryExitT . y = t ;
// entry and exit have been found, so the loop can stop
if ( exitPositive ) {
// After exiting positive shape there is nothing left to intersect, so jump to the end index.
ix . index = passCount ;
}
break ;
}
}
return entryExitT ;
}
# endif
// NOTE: initializeIntersections, nextIntersection aren't even declared unless INTERSECTION_COUNT > 1
// export { NO_HIT, INF_HIT, Ray, Intersections, getIntersectionPair, setIntersectionPair, initializeIntersections, nextIntersection };
` , $ Xe= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections,
// setIntersectionPair, INF_HIT, NO_HIT
/ * i n t e r s e c t D e p t h d e f i n e s ( s e t i n S c e n e / V o x e l R e n d e r R e s o u r c e s . j s )
# define DEPTH _INTERSECTION _INDEX # # #
* /
uniform mat4 u _transformPositionViewToUv ;
void intersectDepth ( vec2 screenCoord , Ray ray , inout Intersections ix ) {
float logDepthOrDepth = czm _unpackDepth ( texture2D ( czm _globeDepthTexture , screenCoord ) ) ;
if ( logDepthOrDepth != 0.0 ) {
// Calculate how far the ray must travel before it hits the depth buffer.
vec4 eyeCoordinateDepth = czm _screenToEyeCoordinates ( screenCoord , logDepthOrDepth ) ;
eyeCoordinateDepth /= eyeCoordinateDepth . w ;
vec3 depthPositionUv = vec3 ( u _transformPositionViewToUv * eyeCoordinateDepth ) ;
float t = dot ( depthPositionUv - ray . pos , ray . dir ) ;
setIntersectionPair ( ix , DEPTH _INTERSECTION _INDEX , vec2 ( t , + INF _HIT ) ) ;
} else {
// There's no depth at this location.
setIntersectionPair ( ix , DEPTH _INTERSECTION _INDEX , vec2 ( NO _HIT ) ) ;
}
}
` ,KXe= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,
// NO_HIT, setIntersectionPair
/ * C l i p p i n g p l a n e d e f i n e s ( s e t i n S c e n e / V o x e l R e n d e r R e s o u r c e s . j s )
# define CLIPPING _PLANES _UNION
# define CLIPPING _PLANES _COUNT
# define CLIPPING _PLANES _INTERSECTION _INDEX
* /
uniform sampler2D u _clippingPlanesTexture ;
uniform mat4 u _clippingPlanesMatrix ;
// Plane is in Hessian Normal Form
vec2 intersectPlane ( Ray ray , vec4 plane ) {
vec3 o = ray . pos ;
vec3 d = ray . dir ;
vec3 n = plane . xyz ; // normal
float w = plane . w ; // -dot(pointOnPlane, normal)
float a = dot ( o , n ) ;
float b = dot ( d , n ) ;
float t = - ( w + a ) / b ;
if ( dot ( d , n ) > 0.0 ) {
return vec2 ( t , + INF _HIT ) ;
} else {
return vec2 ( - INF _HIT , t ) ;
}
}
void intersectClippingPlanes ( Ray ray , inout Intersections ix ) {
# if ( CLIPPING _PLANES _COUNT == 1 )
// Union and intersection are the same when there's one clipping plane, and the code
// is more simplified.
vec4 planeUv = getClippingPlane ( u _clippingPlanesTexture , 0 , u _clippingPlanesMatrix ) ;
vec2 intersection = intersectPlane ( ray , planeUv ) ;
setIntersectionPair ( ix , CLIPPING _PLANES _INTERSECTION _INDEX , intersection ) ;
# elif defined ( CLIPPING _PLANES _UNION )
float minPositiveT = + INF _HIT ;
float maxNegativeT = - INF _HIT ;
for ( int i = 0 ; i < CLIPPING _PLANES _COUNT ; i ++ ) {
vec4 planeUv = getClippingPlane ( u _clippingPlanesTexture , i , u _clippingPlanesMatrix ) ;
vec2 intersection = intersectPlane ( ray , planeUv ) ;
if ( intersection . y == + INF _HIT ) {
minPositiveT = min ( minPositiveT , intersection . x ) ;
} else {
maxNegativeT = max ( maxNegativeT , intersection . y ) ;
}
}
setIntersectionPair ( ix , CLIPPING _PLANES _INTERSECTION _INDEX + 0 , vec2 ( - INF _HIT , maxNegativeT ) ) ;
setIntersectionPair ( ix , CLIPPING _PLANES _INTERSECTION _INDEX + 1 , vec2 ( minPositiveT , + INF _HIT ) ) ;
# else // intersection
float maxPositiveT = - INF _HIT ;
float minNegativeT = + INF _HIT ;
for ( int i = 0 ; i < CLIPPING _PLANES _COUNT ; i ++ ) {
vec4 planeUv = getClippingPlane ( u _clippingPlanesTexture , i , u _clippingPlanesMatrix ) ;
vec2 intersection = intersectPlane ( ray , planeUv ) ;
if ( intersection . y == + INF _HIT ) {
maxPositiveT = max ( maxPositiveT , intersection . x ) ;
} else {
minNegativeT = min ( minNegativeT , intersection . y ) ;
}
}
if ( maxPositiveT < minNegativeT ) {
setIntersectionPair ( ix , CLIPPING _PLANES _INTERSECTION _INDEX , vec2 ( maxPositiveT , minNegativeT ) ) ;
} else {
setIntersectionPair ( ix , CLIPPING _PLANES _INTERSECTION _INDEX , vec2 ( NO _HIT ) ) ;
}
# endif
}
` ,JXe= ` // See IntersectionUtils.glsl for the definitions of Ray and NO_HIT
/ * B o x d e f i n e s ( s e t i n S c e n e / V o x e l B o x S h a p e . j s )
# define BOX _INTERSECTION _INDEX # # # // always 0
# define BOX _HAS _RENDER _BOUNDS
# define BOX _IS _2D
* /
# if defined ( BOX _HAS _RENDER _BOUNDS )
# if defined ( BOX _IS _2D )
// This matrix bakes in an axis conversion so that the math works for XY plane.
uniform mat4 u _boxUvToRenderBoundsTransform ;
# else
// Similar to u_boxTransformUvToBounds but fewer instructions needed.
uniform vec3 u _boxUvToRenderBoundsScale ;
uniform vec3 u _boxUvToRenderBoundsTranslate ;
# endif
# endif
vec2 intersectUnitCube ( Ray ray ) // Unit cube from [-1, +1]
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
vec3 dInv = 1.0 / d ;
vec3 od = - o * dInv ;
vec3 t0 = od - dInv ;
vec3 t1 = od + dInv ;
vec3 m0 = min ( t0 , t1 ) ;
vec3 m1 = max ( t0 , t1 ) ;
float tMin = max ( max ( m0 . x , m0 . y ) , m0 . z ) ;
float tMax = min ( min ( m1 . x , m1 . y ) , m1 . z ) ;
if ( tMin >= tMax ) {
return vec2 ( NO _HIT ) ;
}
return vec2 ( tMin , tMax ) ;
}
vec2 intersectUnitSquare ( Ray ray ) // Unit square from [-1, +1]
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float t = - o . z / d . z ;
vec2 planePos = o . xy + d . xy * t ;
if ( any ( greaterThan ( abs ( planePos ) , vec2 ( 1.0 ) ) ) ) {
return vec2 ( NO _HIT ) ;
}
return vec2 ( t , t ) ;
}
void intersectShape ( Ray ray , inout Intersections ix )
{
# if defined ( BOX _HAS _RENDER _BOUNDS )
# if defined ( BOX _IS _2D )
// Transform the ray into unit square space on Z plane
// This matrix bakes in an axis conversion so that the math works for XY plane.
ray . pos = vec3 ( u _boxUvToRenderBoundsTransform * vec4 ( ray . pos , 1.0 ) ) ;
ray . dir = vec3 ( u _boxUvToRenderBoundsTransform * vec4 ( ray . dir , 0.0 ) ) ;
vec2 entryExit = intersectUnitSquare ( ray ) ;
# else
// Transform the ray into unit cube space
ray . pos = ray . pos * u _boxUvToRenderBoundsScale + u _boxUvToRenderBoundsTranslate ;
ray . dir *= u _boxUvToRenderBoundsScale ;
vec2 entryExit = intersectUnitCube ( ray ) ;
# endif
# else
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
// Direction is scaled as well to be in sync with position.
ray . pos = ray . pos * 2.0 - 1.0 ;
ray . dir = ray . dir * 2.0 ;
vec2 entryExit = intersectUnitCube ( ray ) ;
# endif
setIntersectionPair ( ix , BOX _INTERSECTION _INDEX , entryExit ) ;
}
` ,QXe= ` // See IntersectionUtils.glsl for the definitions of Ray, setIntersection,
// setIntersectionPair
/ * C y l i n d e r d e f i n e s ( s e t i n S c e n e / V o x e l C y l i n d e r S h a p e . j s )
# define CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MIN
# define CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MAX
# define CYLINDER _HAS _RENDER _BOUNDS _RADIUS _FLAT
# define CYLINDER _HAS _RENDER _BOUNDS _HEIGHT
# define CYLINDER _HAS _RENDER _BOUNDS _HEIGHT _FLAT
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _UNDER _HALF
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _OVER _HALF
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _HALF
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _ZERO
# define CYLINDER _HAS _SHAPE _BOUNDS _RADIUS
# define CYLINDER _HAS _SHAPE _BOUNDS _RADIUS _FLAT
# define CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT
# define CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT _FLAT
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _RANGE _EQUAL _ZERO
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _DISCONTINUITY
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MAX _DISCONTINUITY
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _MAX _REVERSED
# define CYLINDER _INTERSECTION _INDEX _RADIUS _MAX
# define CYLINDER _INTERSECTION _INDEX _RADIUS _MIN
# define CYLINDER _INTERSECTION _INDEX _ANGLE
* /
// Cylinder uniforms
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MAX ) || defined ( CYLINDER _HAS _RENDER _BOUNDS _HEIGHT )
uniform vec3 u _cylinderUvToRenderBoundsScale ;
uniform vec3 u _cylinderUvToRenderBoundsTranslate ;
# endif
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MIN ) && ! defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _FLAT )
uniform float u _cylinderUvToRenderRadiusMin ;
# endif
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE )
uniform vec2 u _cylinderRenderAngleMinMax ;
# endif
vec4 intersectHalfPlane ( Ray ray , float angle ) {
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 planeDirection = vec2 ( cos ( angle ) , sin ( angle ) ) ;
vec2 planeNormal = vec2 ( planeDirection . y , - planeDirection . x ) ;
float a = dot ( o , planeNormal ) ;
float b = dot ( d , planeNormal ) ;
float t = - a / b ;
vec2 p = o + t * d ;
bool outside = dot ( p , planeDirection ) < 0.0 ;
if ( outside ) return vec4 ( - INF _HIT , + INF _HIT , NO _HIT , NO _HIT ) ;
return vec4 ( - INF _HIT , t , t , + INF _HIT ) ;
}
# define POSITIVE _HIT vec2 ( t , + INF _HIT ) ;
# define NEGATIVE _HIT vec2 ( - INF _HIT , t ) ;
vec2 intersectHalfSpace ( Ray ray , float angle )
{
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 n = vec2 ( sin ( angle ) , - cos ( angle ) ) ;
float a = dot ( o , n ) ;
float b = dot ( d , n ) ;
float t = - a / b ;
float s = sign ( a ) ;
// Half space cuts right through the camera, pick the side to intersect
if ( a == 0.0 ) {
if ( b >= 0.0 ) {
return POSITIVE _HIT ;
} else {
return NEGATIVE _HIT ;
}
}
if ( t >= 0.0 != s >= 0.0 ) {
return POSITIVE _HIT ;
} else {
return NEGATIVE _HIT ;
}
}
vec2 intersectRegularWedge ( Ray ray , float minAngle , float maxAngle )
{
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 n1 = vec2 ( sin ( minAngle ) , - cos ( minAngle ) ) ;
vec2 n2 = vec2 ( - sin ( maxAngle ) , cos ( maxAngle ) ) ;
float a1 = dot ( o , n1 ) ;
float a2 = dot ( o , n2 ) ;
float b1 = dot ( d , n1 ) ;
float b2 = dot ( d , n2 ) ;
float t1 = - a1 / b1 ;
float t2 = - a2 / b2 ;
float s1 = sign ( a1 ) ;
float s2 = sign ( a2 ) ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
float smin = tmin == t1 ? s1 : s2 ;
float smax = tmin == t1 ? s2 : s1 ;
bool e = tmin >= 0.0 ;
bool f = tmax >= 0.0 ;
bool g = smin >= 0.0 ;
bool h = smax >= 0.0 ;
if ( e != g && f == h ) return vec2 ( tmin , tmax ) ;
else if ( e == g && f == h ) return vec2 ( - INF _HIT , tmin ) ;
else if ( e != g && f != h ) return vec2 ( tmax , + INF _HIT ) ;
else return vec2 ( NO _HIT ) ;
}
vec4 intersectFlippedWedge ( Ray ray , float minAngle , float maxAngle )
{
vec2 planeIntersectMin = intersectHalfSpace ( ray , minAngle ) ;
vec2 planeIntersectMax = intersectHalfSpace ( ray , maxAngle + czm _pi ) ;
return vec4 ( planeIntersectMin , planeIntersectMax ) ;
}
vec2 intersectUnitCylinder ( Ray ray )
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float a = dot ( d . xy , d . xy ) ;
float b = dot ( o . xy , d . xy ) ;
float c = dot ( o . xy , o . xy ) - 1.0 ;
float det = b * b - a * c ;
if ( det < 0.0 ) {
return vec2 ( NO _HIT ) ;
}
det = sqrt ( det ) ;
float ta = ( - b - det ) / a ;
float tb = ( - b + det ) / a ;
float t1 = min ( ta , tb ) ;
float t2 = max ( ta , tb ) ;
float z1 = o . z + t1 * d . z ;
float z2 = o . z + t2 * d . z ;
if ( abs ( z1 ) >= 1.0 )
{
float tCap = ( sign ( z1 ) - o . z ) / d . z ;
t1 = abs ( b + a * tCap ) < det ? tCap : NO _HIT ;
}
if ( abs ( z2 ) >= 1.0 )
{
float tCap = ( sign ( z2 ) - o . z ) / d . z ;
t2 = abs ( b + a * tCap ) < det ? tCap : NO _HIT ;
}
return vec2 ( t1 , t2 ) ;
}
vec2 intersectUnitCircle ( Ray ray ) {
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float t = - o . z / d . z ;
vec2 zPlanePos = o . xy + d . xy * t ;
float distSqr = dot ( zPlanePos , zPlanePos ) ;
if ( distSqr > 1.0 ) {
return vec2 ( NO _HIT ) ;
}
return vec2 ( t , t ) ;
}
vec2 intersectInfiniteUnitCylinder ( Ray ray )
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float a = dot ( d . xy , d . xy ) ;
float b = dot ( o . xy , d . xy ) ;
float c = dot ( o . xy , o . xy ) - 1.0 ;
float det = b * b - a * c ;
if ( det < 0.0 ) {
return vec2 ( NO _HIT ) ;
}
det = sqrt ( det ) ;
float t1 = ( - b - det ) / a ;
float t2 = ( - b + det ) / a ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
return vec2 ( tmin , tmax ) ;
}
void intersectShape ( Ray ray , inout Intersections ix )
{
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MAX ) || defined ( CYLINDER _HAS _RENDER _BOUNDS _HEIGHT )
ray . pos = ray . pos * u _cylinderUvToRenderBoundsScale + u _cylinderUvToRenderBoundsTranslate ;
ray . dir *= u _cylinderUvToRenderBoundsScale ;
# else
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
// Direction is scaled as well to be in sync with position.
ray . pos = ray . pos * 2.0 - 1.0 ;
ray . dir *= 2.0 ;
# endif
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _HEIGHT _FLAT )
vec2 outerIntersect = intersectUnitCircle ( ray ) ;
# else
vec2 outerIntersect = intersectUnitCylinder ( ray ) ;
# endif
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _RADIUS _MAX , outerIntersect ) ;
if ( outerIntersect . x == NO _HIT ) {
return ;
}
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _FLAT )
// When the cylinder is perfectly thin it's necessary to sandwich the
// inner cylinder intersection inside the outer cylinder intersection.
// Without this special case,
// [outerMin, outerMax, innerMin, innerMax] will bubble sort to
// [outerMin, innerMin, outerMax, innerMax] which will cause the back
// side of the cylinder to be invisible because it will think the ray
// is still inside the inner (negative) cylinder after exiting the
// outer (positive) cylinder.
// With this special case,
// [outerMin, innerMin, innerMax, outerMax] will bubble sort to
// [outerMin, innerMin, innerMax, outerMax] which will work correctly.
// Note: If initializeIntersections() changes its sorting function
// from bubble sort to something else, this code may need to change.
vec2 innerIntersect = intersectInfiniteUnitCylinder ( ray ) ;
setIntersection ( ix , 0 , outerIntersect . x , true , true ) ; // positive, enter
setIntersection ( ix , 1 , innerIntersect . x , false , true ) ; // negative, enter
setIntersection ( ix , 2 , innerIntersect . y , false , false ) ; // negative, exit
setIntersection ( ix , 3 , outerIntersect . y , true , false ) ; // positive, exit
# elif defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _MIN )
Ray innerRay = Ray ( ray . pos * u _cylinderUvToRenderRadiusMin , ray . dir * u _cylinderUvToRenderRadiusMin ) ;
vec2 innerIntersect = intersectInfiniteUnitCylinder ( innerRay ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _RADIUS _MIN , innerIntersect ) ;
# endif
# if defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _UNDER _HALF )
vec2 wedgeIntersect = intersectRegularWedge ( ray , u _cylinderRenderAngleMinMax . x , u _cylinderRenderAngleMinMax . y ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE , wedgeIntersect ) ;
# elif defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _OVER _HALF )
vec4 wedgeIntersect = intersectFlippedWedge ( ray , u _cylinderRenderAngleMinMax . x , u _cylinderRenderAngleMinMax . y ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE + 0 , wedgeIntersect . xy ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE + 1 , wedgeIntersect . zw ) ;
# elif defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _HALF )
vec2 wedgeIntersect = intersectHalfSpace ( ray , u _cylinderRenderAngleMinMax . x ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE , wedgeIntersect ) ;
# elif defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _ZERO )
vec4 wedgeIntersect = intersectHalfPlane ( ray , u _cylinderRenderAngleMinMax . x ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE + 0 , wedgeIntersect . xy ) ;
setIntersectionPair ( ix , CYLINDER _INTERSECTION _INDEX _ANGLE + 1 , wedgeIntersect . zw ) ;
# endif
}
` ,ZXe= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections,
// setIntersection, setIntersectionPair, INF_HIT, NO_HIT
/ * E l l i p s o i d d e f i n e s ( s e t i n S c e n e / V o x e l E l l i p s o i d S h a p e . j s )
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _UNDER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _OVER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _UNDER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _EQUAL _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _OVER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _UNDER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _EQUAL _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _OVER _HALF
# define ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _MIN
# define ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _FLAT
# define ELLIPSOID _INTERSECTION _INDEX _LONGITUDE
# define ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MAX
# define ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MIN
# define ELLIPSOID _INTERSECTION _INDEX _HEIGHT _MAX
# define ELLIPSOID _INTERSECTION _INDEX _HEIGHT _MIN
* /
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE )
uniform vec2 u _ellipsoidRenderLongitudeMinMax ;
# endif
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _UNDER _HALF ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _OVER _HALF ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _UNDER _HALF ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _OVER _HALF )
uniform vec2 u _ellipsoidRenderLatitudeCosSqrHalfMinMax ;
# endif
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _MIN )
uniform float u _ellipsoidInverseInnerScaleUv ;
# endif
vec2 intersectZPlane ( Ray ray )
{
float o = ray . pos . z ;
float d = ray . dir . z ;
float t = - o / d ;
float s = sign ( o ) ;
if ( t >= 0.0 != s >= 0.0 ) return vec2 ( t , + INF _HIT ) ;
else return vec2 ( - INF _HIT , t ) ;
}
vec4 intersectHalfPlane ( Ray ray , float angle ) {
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 planeDirection = vec2 ( cos ( angle ) , sin ( angle ) ) ;
vec2 planeNormal = vec2 ( planeDirection . y , - planeDirection . x ) ;
float a = dot ( o , planeNormal ) ;
float b = dot ( d , planeNormal ) ;
float t = - a / b ;
vec2 p = o + t * d ;
bool outside = dot ( p , planeDirection ) < 0.0 ;
if ( outside ) return vec4 ( - INF _HIT , + INF _HIT , NO _HIT , NO _HIT ) ;
return vec4 ( - INF _HIT , t , t , + INF _HIT ) ;
}
vec2 intersectHalfSpace ( Ray ray , float angle )
{
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 n = vec2 ( sin ( angle ) , - cos ( angle ) ) ;
float a = dot ( o , n ) ;
float b = dot ( d , n ) ;
float t = - a / b ;
float s = sign ( a ) ;
if ( t >= 0.0 != s >= 0.0 ) return vec2 ( t , + INF _HIT ) ;
else return vec2 ( - INF _HIT , t ) ;
}
vec2 intersectRegularWedge ( Ray ray , float minAngle , float maxAngle )
{
vec2 o = ray . pos . xy ;
vec2 d = ray . dir . xy ;
vec2 n1 = vec2 ( sin ( minAngle ) , - cos ( minAngle ) ) ;
vec2 n2 = vec2 ( - sin ( maxAngle ) , cos ( maxAngle ) ) ;
float a1 = dot ( o , n1 ) ;
float a2 = dot ( o , n2 ) ;
float b1 = dot ( d , n1 ) ;
float b2 = dot ( d , n2 ) ;
float t1 = - a1 / b1 ;
float t2 = - a2 / b2 ;
float s1 = sign ( a1 ) ;
float s2 = sign ( a2 ) ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
float smin = tmin == t1 ? s1 : s2 ;
float smax = tmin == t1 ? s2 : s1 ;
bool e = tmin >= 0.0 ;
bool f = tmax >= 0.0 ;
bool g = smin >= 0.0 ;
bool h = smax >= 0.0 ;
if ( e != g && f == h ) return vec2 ( tmin , tmax ) ;
else if ( e == g && f == h ) return vec2 ( - INF _HIT , tmin ) ;
else if ( e != g && f != h ) return vec2 ( tmax , + INF _HIT ) ;
else return vec2 ( NO _HIT ) ;
}
vec4 intersectFlippedWedge ( Ray ray , float minAngle , float maxAngle )
{
vec2 planeIntersectMin = intersectHalfSpace ( ray , minAngle ) ;
vec2 planeIntersectMax = intersectHalfSpace ( ray , maxAngle + czm _pi ) ;
return vec4 ( planeIntersectMin , planeIntersectMax ) ;
}
vec2 intersectUnitSphere ( Ray ray )
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float b = dot ( d , o ) ;
float c = dot ( o , o ) - 1.0 ;
float det = b * b - c ;
if ( det < 0.0 ) {
return vec2 ( NO _HIT ) ;
}
det = sqrt ( det ) ;
float t1 = - b - det ;
float t2 = - b + det ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
return vec2 ( tmin , tmax ) ;
}
vec2 intersectUnitSphereUnnormalizedDirection ( Ray ray )
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float a = dot ( d , d ) ;
float b = dot ( d , o ) ;
float c = dot ( o , o ) - 1.0 ;
float det = b * b - a * c ;
if ( det < 0.0 ) {
return vec2 ( NO _HIT ) ;
}
det = sqrt ( det ) ;
float t1 = ( - b - det ) / a ;
float t2 = ( - b + det ) / a ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
return vec2 ( tmin , tmax ) ;
}
vec2 intersectDoubleEndedCone ( Ray ray , float cosSqrHalfAngle )
{
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float a = d . z * d . z - dot ( d , d ) * cosSqrHalfAngle ;
float b = d . z * o . z - dot ( o , d ) * cosSqrHalfAngle ;
float c = o . z * o . z - dot ( o , o ) * cosSqrHalfAngle ;
float det = b * b - a * c ;
if ( det < 0.0 ) {
return vec2 ( NO _HIT ) ;
}
det = sqrt ( det ) ;
float t1 = ( - b - det ) / a ;
float t2 = ( - b + det ) / a ;
float tmin = min ( t1 , t2 ) ;
float tmax = max ( t1 , t2 ) ;
return vec2 ( tmin , tmax ) ;
}
vec4 intersectFlippedCone ( Ray ray , float cosSqrHalfAngle ) {
vec2 intersect = intersectDoubleEndedCone ( ray , cosSqrHalfAngle ) ;
if ( intersect . x == NO _HIT ) {
return vec4 ( - INF _HIT , + INF _HIT , NO _HIT , NO _HIT ) ;
}
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float tmin = intersect . x ;
float tmax = intersect . y ;
float zmin = o . z + tmin * d . z ;
float zmax = o . z + tmax * d . z ;
// One interval
if ( zmin < 0.0 && zmax < 0.0 ) return vec4 ( - INF _HIT , + INF _HIT , NO _HIT , NO _HIT ) ;
else if ( zmin < 0.0 ) return vec4 ( - INF _HIT , tmax , NO _HIT , NO _HIT ) ;
else if ( zmax < 0.0 ) return vec4 ( tmin , + INF _HIT , NO _HIT , NO _HIT ) ;
// Two intervals
else return vec4 ( - INF _HIT , tmin , tmax , + INF _HIT ) ;
}
vec2 intersectRegularCone ( Ray ray , float cosSqrHalfAngle ) {
vec2 intersect = intersectDoubleEndedCone ( ray , cosSqrHalfAngle ) ;
if ( intersect . x == NO _HIT ) {
return vec2 ( NO _HIT ) ;
}
vec3 o = ray . pos ;
vec3 d = ray . dir ;
float tmin = intersect . x ;
float tmax = intersect . y ;
float zmin = o . z + tmin * d . z ;
float zmax = o . z + tmax * d . z ;
if ( zmin < 0.0 && zmax < 0.0 ) return vec2 ( NO _HIT ) ;
else if ( zmin < 0.0 ) return vec2 ( tmax , + INF _HIT ) ;
else if ( zmax < 0.0 ) return vec2 ( - INF _HIT , tmin ) ;
else return vec2 ( tmin , tmax ) ;
}
void intersectShape ( in Ray ray , inout Intersections ix ) {
// Position is converted from [0,1] to [-1,+1] because shape intersections assume unit space is [-1,+1].
// Direction is scaled as well to be in sync with position.
ray . pos = ray . pos * 2.0 - 1.0 ;
ray . dir *= 2.0 ;
// Outer ellipsoid
vec2 outerIntersect = intersectUnitSphereUnnormalizedDirection ( ray ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _HEIGHT _MAX , outerIntersect ) ;
// Exit early if the outer ellipsoid was missed.
if ( outerIntersect . x == NO _HIT ) {
return ;
}
// Inner ellipsoid
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _FLAT )
// When the ellipsoid is perfectly thin it's necessary to sandwich the
// inner ellipsoid intersection inside the outer ellipsoid intersection.
// Without this special case,
// [outerMin, outerMax, innerMin, innerMax] will bubble sort to
// [outerMin, innerMin, outerMax, innerMax] which will cause the back
// side of the ellipsoid to be invisible because it will think the ray
// is still inside the inner (negative) ellipsoid after exiting the
// outer (positive) ellipsoid.
// With this special case,
// [outerMin, innerMin, innerMax, outerMax] will bubble sort to
// [outerMin, innerMin, innerMax, outerMax] which will work correctly.
// Note: If initializeIntersections() changes its sorting function
// from bubble sort to something else, this code may need to change.
setIntersection ( ix , 0 , outerIntersect . x , true , true ) ; // positive, enter
setIntersection ( ix , 1 , outerIntersect . x , false , true ) ; // negative, enter
setIntersection ( ix , 2 , outerIntersect . y , false , false ) ; // negative, exit
setIntersection ( ix , 3 , outerIntersect . y , true , false ) ; // positive, exit
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _MIN )
Ray innerRay = Ray ( ray . pos * u _ellipsoidInverseInnerScaleUv , ray . dir * u _ellipsoidInverseInnerScaleUv ) ;
vec2 innerIntersect = intersectUnitSphereUnnormalizedDirection ( innerRay ) ;
if ( innerIntersect == vec2 ( NO _HIT ) ) {
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _HEIGHT _MIN , innerIntersect ) ;
} else {
// When the ellipsoid is very large and thin it's possible for floating
// point math to cause the ray to intersect the inner ellipsoid before
// the outer ellipsoid. To prevent this from happening, clamp innerIntersect
// to outerIntersect and sandwhich the intersections like described above.
//
// In theory a similar fix is needed for cylinders, however it's more
// complicated to implement because the inner shape is allowed to be
// intersected first.
innerIntersect . x = max ( innerIntersect . x , outerIntersect . x ) ;
innerIntersect . y = min ( innerIntersect . y , outerIntersect . y ) ;
setIntersection ( ix , 0 , outerIntersect . x , true , true ) ; // positive, enter
setIntersection ( ix , 1 , innerIntersect . x , false , true ) ; // negative, enter
setIntersection ( ix , 2 , innerIntersect . y , false , false ) ; // negative, exit
setIntersection ( ix , 3 , outerIntersect . y , true , false ) ; // positive, exit
}
# endif
// Flip the ray because the intersection function expects a cone growing towards +Z.
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _UNDER _HALF ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _EQUAL _HALF ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _UNDER _HALF )
Ray flippedRay = ray ;
flippedRay . dir . z *= - 1.0 ;
flippedRay . pos . z *= - 1.0 ;
# endif
// Bottom cone
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _UNDER _HALF )
vec2 bottomConeIntersection = intersectRegularCone ( flippedRay , u _ellipsoidRenderLatitudeCosSqrHalfMinMax . x ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MIN , bottomConeIntersection ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _EQUAL _HALF )
vec2 bottomConeIntersection = intersectZPlane ( flippedRay ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MIN , bottomConeIntersection ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MIN _OVER _HALF )
vec4 bottomConeIntersection = intersectFlippedCone ( ray , u _ellipsoidRenderLatitudeCosSqrHalfMinMax . x ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MIN + 0 , bottomConeIntersection . xy ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MIN + 1 , bottomConeIntersection . zw ) ;
# endif
// Top cone
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _UNDER _HALF )
vec4 topConeIntersection = intersectFlippedCone ( flippedRay , u _ellipsoidRenderLatitudeCosSqrHalfMinMax . y ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MAX + 0 , topConeIntersection . xy ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MAX + 1 , topConeIntersection . zw ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _EQUAL _HALF )
vec2 topConeIntersection = intersectZPlane ( ray ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MAX , topConeIntersection ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _MAX _OVER _HALF )
vec2 topConeIntersection = intersectRegularCone ( ray , u _ellipsoidRenderLatitudeCosSqrHalfMinMax . y ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LATITUDE _MAX , topConeIntersection ) ;
# endif
// Wedge
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO )
vec4 wedgeIntersect = intersectHalfPlane ( ray , u _ellipsoidRenderLongitudeMinMax . x ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE + 0 , wedgeIntersect . xy ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE + 1 , wedgeIntersect . zw ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _UNDER _HALF )
vec2 wedgeIntersect = intersectRegularWedge ( ray , u _ellipsoidRenderLongitudeMinMax . x , u _ellipsoidRenderLongitudeMinMax . y ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE , wedgeIntersect ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _HALF )
vec2 wedgeIntersect = intersectHalfSpace ( ray , u _ellipsoidRenderLongitudeMinMax . x ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE , wedgeIntersect ) ;
# elif defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _OVER _HALF )
vec4 wedgeIntersect = intersectFlippedWedge ( ray , u _ellipsoidRenderLongitudeMinMax . x , u _ellipsoidRenderLongitudeMinMax . y ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE + 0 , wedgeIntersect . xy ) ;
setIntersectionPair ( ix , ELLIPSOID _INTERSECTION _INDEX _LONGITUDE + 1 , wedgeIntersect . zw ) ;
# endif
}
` ,AO= ` // Main intersection function for Voxel scenes.
// See IntersectBox.glsl, IntersectCylinder.glsl, or IntersectEllipsoid.glsl
// for the definition of intersectShape. The appropriate function is selected
// based on the VoxelPrimitive shape type, and added to the shader in
// Scene/VoxelRenderResources.js.
// See also IntersectClippingPlane.glsl and IntersectDepth.glsl.
// See IntersectionUtils.glsl for the definitions of Ray, NO_HIT,
// getIntersectionPair, initializeIntersections, nextIntersection.
/ * I n t e r s e c t i o n d e f i n e s ( s e t i n S c e n e / V o x e l R e n d e r R e s o u r c e s . j s )
# define INTERSECTION _COUNT # # #
* /
vec2 intersectScene ( vec2 screenCoord , vec3 positionUv , vec3 directionUv , out Intersections ix ) {
Ray ray = Ray ( positionUv , directionUv ) ;
// Do a ray-shape intersection to find the exact starting and ending points.
intersectShape ( ray , ix ) ;
// Exit early if the positive shape was completely missed or behind the ray.
vec2 entryExitT = getIntersectionPair ( ix , 0 ) ;
if ( entryExitT . x == NO _HIT ) {
// Positive shape was completely missed - so exit early.
return vec2 ( NO _HIT ) ;
}
// Clipping planes
# if defined ( CLIPPING _PLANES )
intersectClippingPlanes ( ray , ix ) ;
# endif
// Depth
# if defined ( DEPTH _TEST )
intersectDepth ( screenCoord , ray , ix ) ;
# endif
// Find the first intersection that's in front of the ray
# if ( INTERSECTION _COUNT > 1 )
initializeIntersections ( ix ) ;
for ( int i = 0 ; i < INTERSECTION _COUNT ; ++ i ) {
entryExitT = nextIntersection ( ix ) ;
if ( entryExitT . y > 0.0 ) {
// Set start to 0.0 when ray is inside the shape.
entryExitT . x = max ( entryExitT . x , 0.0 ) ;
break ;
}
}
# else
// Set start to 0.0 when ray is inside the shape.
entryExitT . x = max ( entryExitT . x , 0.0 ) ;
# endif
return entryExitT ;
}
` ,e $ e= ` / * Box defines ( set in Scene / VoxelBoxShape . js )
# define BOX _HAS _SHAPE _BOUNDS
* /
# if defined ( BOX _HAS _SHAPE _BOUNDS )
uniform vec3 u _boxUvToShapeUvScale ;
uniform vec3 u _boxUvToShapeUvTranslate ;
# endif
vec3 convertUvToShapeUvSpace ( in vec3 positionUv ) {
# if defined ( BOX _HAS _SHAPE _BOUNDS )
return positionUv * u _boxUvToShapeUvScale + u _boxUvToShapeUvTranslate ;
# else
return positionUv ;
# endif
}
` ,t $ e= ` / * Cylinder defines ( set in Scene / VoxelCylinderShape . js )
# define CYLINDER _HAS _RENDER _BOUNDS _RADIUS _FLAT
# define CYLINDER _HAS _RENDER _BOUNDS _HEIGHT _FLAT
# define CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _ZERO
# define CYLINDER _HAS _SHAPE _BOUNDS _RADIUS
# define CYLINDER _HAS _SHAPE _BOUNDS _RADIUS _FLAT
# define CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT
# define CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT _FLAT
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _RANGE _EQUAL _ZERO
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _DISCONTINUITY
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MAX _DISCONTINUITY
# define CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _MAX _REVERSED
* /
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _RADIUS )
uniform vec2 u _cylinderUvToShapeUvRadius ; // x = scale, y = offset
# endif
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT )
uniform vec2 u _cylinderUvToShapeUvHeight ; // x = scale, y = offset
# endif
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE )
uniform vec2 u _cylinderUvToShapeUvAngle ; // x = scale, y = offset
# endif
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _DISCONTINUITY ) || defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MAX _DISCONTINUITY )
uniform vec2 u _cylinderShapeUvAngleMinMax ;
# endif
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _DISCONTINUITY ) || defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MAX _DISCONTINUITY ) || defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _MAX _REVERSED )
uniform float u _cylinderShapeUvAngleRangeZeroMid ;
# endif
vec3 convertUvToShapeUvSpace ( in vec3 positionUv ) {
vec3 positionLocal = positionUv * 2.0 - 1.0 ; // [-1,+1]
// Compute radius
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _RADIUS _FLAT ) || defined ( CYLINDER _HAS _RENDER _BOUNDS _RADIUS _FLAT )
float radius = length ( positionLocal . xy ) ; // [0,1]
# else
float radius = length ( positionLocal . xy ) ; // [0,1]
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _RADIUS )
radius = radius * u _cylinderUvToShapeUvRadius . x + u _cylinderUvToShapeUvRadius . y ; // x = scale, y = offset
# endif
# endif
// Compute height
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT _FLAT ) || defined ( CYLINDER _HAS _RENDER _BOUNDS _HEIGHT _FLAT )
float height = positionUv . z ; // [0,1]
# else
float height = positionUv . z ; // [0,1]
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _HEIGHT )
height = height * u _cylinderUvToShapeUvHeight . x + u _cylinderUvToShapeUvHeight . y ; // x = scale, y = offset
# endif
# endif
// Compute angle
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _RANGE _EQUAL _ZERO ) || defined ( CYLINDER _HAS _RENDER _BOUNDS _ANGLE _RANGE _EQUAL _ZERO )
float angle = 1.0 ;
# else
float angle = ( atan ( positionLocal . y , positionLocal . x ) + czm _pi ) / czm _twoPi ; // [0,1]
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE )
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _MAX _REVERSED )
// Comparing against u_cylinderShapeUvAngleMinMax has precision problems. u_cylinderShapeUvAngleRangeZeroMid is more conservative.
angle += float ( angle < u _cylinderShapeUvAngleRangeZeroMid ) ;
# endif
// Avoid flickering from reading voxels from both sides of the -pi/+pi discontinuity.
# if defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MIN _DISCONTINUITY )
angle = angle > u _cylinderShapeUvAngleRangeZeroMid ? u _cylinderShapeUvAngleMinMax . x : angle ;
# elif defined ( CYLINDER _HAS _SHAPE _BOUNDS _ANGLE _MAX _DISCONTINUITY )
angle = angle < u _cylinderShapeUvAngleRangeZeroMid ? u _cylinderShapeUvAngleMinMax . y : angle ;
# endif
angle = angle * u _cylinderUvToShapeUvAngle . x + u _cylinderUvToShapeUvAngle . y ; // x = scale, y = offset
# endif
# endif
return vec3 ( radius , height , angle ) ;
}
` ,n $ e= ` / * Ellipsoid defines ( set in Scene / VoxelEllipsoidShape . js )
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MIN _DISCONTINUITY
# define ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MAX _DISCONTINUITY
# define ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE
# define ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO
# define ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE _MIN _MAX _REVERSED
# define ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _RANGE _EQUAL _ZERO
# define ELLIPSOID _HAS _SHAPE _BOUNDS _LATITUDE
# define ELLIPSOID _HAS _SHAPE _BOUNDS _LATITUDE _RANGE _EQUAL _ZERO
# define ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _FLAT
# define ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _MIN
# define ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _FLAT
# define ELLIPSOID _IS _SPHERE
* /
uniform vec3 u _ellipsoidRadiiUv ; // [0,1]
# if ! defined ( ELLIPSOID _IS _SPHERE )
uniform vec3 u _ellipsoidInverseRadiiSquaredUv ;
# endif
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MIN _DISCONTINUITY ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MAX _DISCONTINUITY ) || defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE _MIN _MAX _REVERSED )
uniform vec3 u _ellipsoidShapeUvLongitudeMinMaxMid ;
# endif
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE )
uniform vec2 u _ellipsoidUvToShapeUvLongitude ; // x = scale, y = offset
# endif
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LATITUDE )
uniform vec2 u _ellipsoidUvToShapeUvLatitude ; // x = scale, y = offset
# endif
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _MIN ) && ! defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _FLAT )
uniform float u _ellipsoidInverseHeightDifferenceUv ;
uniform vec2 u _ellipseInnerRadiiUv ; // [0,1]
# endif
// robust iterative solution without trig functions
// https://github.com/0xfaded/ellipse_demo/issues/1
// https://stackoverflow.com/questions/22959698/distance-from-given-point-to-given-ellipse
// Pro: Good when radii.x ~= radii.y
// Con: Breaks at pos.x ~= 0.0, especially inside the ellipse
// Con: Inaccurate with exterior points and thin ellipses
float ellipseDistanceIterative ( vec2 pos , vec2 radii ) {
vec2 p = abs ( pos ) ;
vec2 invRadii = 1.0 / radii ;
vec2 a = vec2 ( 1.0 , - 1.0 ) * ( radii . x * radii . x - radii . y * radii . y ) * invRadii ;
vec2 t = vec2 ( 0.70710678118 ) ; // sqrt(2) / 2
vec2 v = radii * t ;
const int iterations = 3 ;
for ( int i = 0 ; i < iterations ; ++ i ) {
vec2 e = a * pow ( t , vec2 ( 3.0 ) ) ;
vec2 q = normalize ( p - e ) * length ( v - e ) ;
t = normalize ( ( q + e ) * invRadii ) ;
v = radii * t ;
}
return length ( v * sign ( pos ) - pos ) * sign ( p . y - v . y ) ;
}
vec3 convertUvToShapeUvSpace ( in vec3 positionUv ) {
// Compute position and normal.
// Convert positionUv [0,1] to local space [-1,+1] to "normalized" cartesian space [-a,+a] where a = (radii + height) / (max(radii) + height).
// A point on the largest ellipsoid axis would be [-1,+1] and everything else would be smaller.
vec3 positionLocal = positionUv * 2.0 - 1.0 ;
# if defined ( ELLIPSOID _IS _SPHERE )
vec3 posEllipsoid = positionLocal * u _ellipsoidRadiiUv . x ;
vec3 normal = normalize ( posEllipsoid ) ;
# else
vec3 posEllipsoid = positionLocal * u _ellipsoidRadiiUv ;
vec3 normal = normalize ( posEllipsoid * u _ellipsoidInverseRadiiSquaredUv ) ; // geodetic surface normal
# endif
// Compute longitude
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _RANGE _EQUAL _ZERO )
float longitude = 1.0 ;
# else
float longitude = ( atan ( normal . y , normal . x ) + czm _pi ) / czm _twoPi ;
// Correct the angle when max < min
// Technically this should compare against min longitude - but it has precision problems so compare against the middle of empty space.
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE _MIN _MAX _REVERSED )
longitude += float ( longitude < u _ellipsoidShapeUvLongitudeMinMaxMid . z ) ;
# endif
// Avoid flickering from reading voxels from both sides of the -pi/+pi discontinuity.
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MIN _DISCONTINUITY )
longitude = longitude > u _ellipsoidShapeUvLongitudeMinMaxMid . z ? u _ellipsoidShapeUvLongitudeMinMaxMid . x : longitude ;
# endif
# if defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LONGITUDE _MAX _DISCONTINUITY )
longitude = longitude < u _ellipsoidShapeUvLongitudeMinMaxMid . z ? u _ellipsoidShapeUvLongitudeMinMaxMid . y : longitude ;
# endif
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LONGITUDE )
longitude = longitude * u _ellipsoidUvToShapeUvLongitude . x + u _ellipsoidUvToShapeUvLongitude . y ;
# endif
# endif
// Compute latitude
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LATITUDE _RANGE _EQUAL _ZERO ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _LATITUDE _RANGE _EQUAL _ZERO )
float latitude = 1.0 ;
# else
float latitude = ( asin ( normal . z ) + czm _piOverTwo ) / czm _pi ;
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _LATITUDE )
latitude = latitude * u _ellipsoidUvToShapeUvLatitude . x + u _ellipsoidUvToShapeUvLatitude . y ;
# endif
# endif
// Compute height
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _FLAT ) || defined ( ELLIPSOID _HAS _RENDER _BOUNDS _HEIGHT _FLAT )
// TODO: This breaks down when minBounds == maxBounds. To fix it, this
// function would have to know if ray is intersecting the front or back of the shape
// and set the shape space position to 1 (front) or 0 (back) accordingly.
float height = 1.0 ;
# else
# if defined ( ELLIPSOID _IS _SPHERE )
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _MIN )
float height = ( length ( posEllipsoid ) - u _ellipseInnerRadiiUv . x ) * u _ellipsoidInverseHeightDifferenceUv ;
# else
float height = length ( posEllipsoid ) ;
# endif
# else
# if defined ( ELLIPSOID _HAS _SHAPE _BOUNDS _HEIGHT _MIN )
// Convert the 3D position to a 2D position relative to the ellipse (radii.x, radii.z) (assuming radii.x == radii.y which is true for WGS84).
// This is an optimization so that math can be done with ellipses instead of ellipsoids.
vec2 posEllipse = vec2 ( length ( posEllipsoid . xy ) , posEllipsoid . z ) ;
float height = ellipseDistanceIterative ( posEllipse , u _ellipseInnerRadiiUv ) * u _ellipsoidInverseHeightDifferenceUv ;
# else
// TODO: this is probably not correct
float height = length ( posEllipsoid ) ;
# endif
# endif
# endif
return vec3 ( longitude , latitude , height ) ;
}
` ,i $ e= ` // These octree flags must be in sync with GpuOctreeFlag in VoxelTraversal.js
# define OCTREE _FLAG _INTERNAL 0
# define OCTREE _FLAG _LEAF 1
# define OCTREE _FLAG _PACKED _LEAF _FROM _PARENT 2
# define OCTREE _MAX _LEVELS 32 // Harcoded value because GLSL doesn't like variable length loops
uniform sampler2D u _octreeInternalNodeTexture ;
uniform vec2 u _octreeInternalNodeTexelSizeUv ;
uniform int u _octreeInternalNodeTilesPerRow ;
uniform sampler2D u _octreeLeafNodeTexture ;
uniform vec2 u _octreeLeafNodeTexelSizeUv ;
uniform int u _octreeLeafNodeTilesPerRow ;
uniform float u _stepSize ;
struct OctreeNodeData {
int data ;
int flag ;
} ;
struct TraversalData {
float stepT ;
ivec4 octreeCoords ;
int parentOctreeIndex ;
} ;
struct SampleData {
int megatextureIndex ;
bool usingParentMegatextureIndex ;
vec3 tileUv ;
# if ( SAMPLE _COUNT > 1 )
float weight ;
# endif
} ;
// Integer mod: For WebGL1 only
int intMod ( in int a , in int b ) {
return a - ( b * ( a / b ) ) ;
}
int normU8 _toInt ( in float value ) {
return int ( value * 255.0 ) ;
}
int normU8x2 _toInt ( in vec2 value ) {
return int ( value . x * 255.0 ) + 256 * int ( value . y * 255.0 ) ;
}
float normU8x2 _toFloat ( in vec2 value ) {
return float ( normU8x2 _toInt ( value ) ) / 65535.0 ;
}
OctreeNodeData getOctreeNodeData ( in vec2 octreeUv ) {
vec4 texData = texture2D ( u _octreeInternalNodeTexture , octreeUv ) ;
OctreeNodeData data ;
data . data = normU8x2 _toInt ( texData . xy ) ;
data . flag = normU8x2 _toInt ( texData . zw ) ;
return data ;
}
OctreeNodeData getOctreeChildData ( in int parentOctreeIndex , in ivec3 childCoord ) {
int childIndex = childCoord . z * 4 + childCoord . y * 2 + childCoord . x ;
int octreeCoordX = intMod ( parentOctreeIndex , u _octreeInternalNodeTilesPerRow ) * 9 + 1 + childIndex ;
int octreeCoordY = parentOctreeIndex / u _octreeInternalNodeTilesPerRow ;
vec2 octreeUv = u _octreeInternalNodeTexelSizeUv * vec2 ( float ( octreeCoordX ) + 0.5 , float ( octreeCoordY ) + 0.5 ) ;
return getOctreeNodeData ( octreeUv ) ;
}
int getOctreeParentIndex ( in int octreeIndex ) {
int octreeCoordX = intMod ( octreeIndex , u _octreeInternalNodeTilesPerRow ) * 9 ;
int octreeCoordY = octreeIndex / u _octreeInternalNodeTilesPerRow ;
vec2 octreeUv = u _octreeInternalNodeTexelSizeUv * vec2 ( float ( octreeCoordX ) + 0.5 , float ( octreeCoordY ) + 0.5 ) ;
vec4 parentData = texture2D ( u _octreeInternalNodeTexture , octreeUv ) ;
int parentOctreeIndex = normU8x2 _toInt ( parentData . xy ) ;
return parentOctreeIndex ;
}
/ * *
* Convert a position in the uv - space of the tileset bounding shape
* into the uv - space of a tile within the tileset
* /
vec3 getTileUv ( in vec3 shapePosition , in ivec4 octreeCoords ) {
// TODO: use bit-shifting (only in WebGL2)
float dimAtLevel = pow ( 2.0 , float ( octreeCoords . w ) ) ;
return shapePosition * dimAtLevel - vec3 ( octreeCoords . xyz ) ;
}
void setSampleUv ( in vec3 shapePosition , in ivec4 octreeCoords , inout SampleData sampleData ) {
ivec4 sampleCoords = sampleData . usingParentMegatextureIndex
? ivec4 ( octreeCoords . xyz / 2 , octreeCoords . w - 1 )
: octreeCoords ;
sampleData . tileUv = getTileUv ( shapePosition , sampleCoords ) ;
}
void getOctreeLeafSampleData ( in OctreeNodeData data , out SampleData sampleData ) {
sampleData . megatextureIndex = data . data ;
sampleData . usingParentMegatextureIndex = data . flag == OCTREE _FLAG _PACKED _LEAF _FROM _PARENT ;
}
# if ( SAMPLE _COUNT > 1 )
void getOctreeLeafSampleDatas ( in OctreeNodeData data , out SampleData sampleData0 , out SampleData sampleData1 ) {
int leafIndex = data . data ;
int leafNodeTexelCount = 2 ;
// Adding 0.5 moves to the center of the texel
float leafCoordXStart = float ( intMod ( leafIndex , u _octreeLeafNodeTilesPerRow ) * leafNodeTexelCount ) + 0.5 ;
float leafCoordY = float ( leafIndex / u _octreeLeafNodeTilesPerRow ) + 0.5 ;
vec2 leafUv0 = u _octreeLeafNodeTexelSizeUv * vec2 ( leafCoordXStart + 0.0 , leafCoordY ) ;
vec2 leafUv1 = u _octreeLeafNodeTexelSizeUv * vec2 ( leafCoordXStart + 1.0 , leafCoordY ) ;
vec4 leafData0 = texture2D ( u _octreeLeafNodeTexture , leafUv0 ) ;
vec4 leafData1 = texture2D ( u _octreeLeafNodeTexture , leafUv1 ) ;
float lerp = normU8x2 _toFloat ( leafData0 . xy ) ;
sampleData0 . megatextureIndex = normU8x2 _toInt ( leafData1 . xy ) ;
sampleData1 . megatextureIndex = normU8x2 _toInt ( leafData1 . zw ) ;
// TODO: this looks wrong? Should be comparing to OCTREE_FLAG_PACKED_LEAF_FROM_PARENT
sampleData0 . usingParentMegatextureIndex = normU8 _toInt ( leafData0 . z ) == 1 ;
sampleData1 . usingParentMegatextureIndex = normU8 _toInt ( leafData0 . w ) == 1 ;
sampleData0 . weight = 1.0 - lerp ;
sampleData1 . weight = lerp ;
}
# endif
void traverseOctreeDownwards ( in vec3 shapePosition , inout TraversalData traversalData , out SampleData sampleDatas [ SAMPLE _COUNT ] ) {
float sizeAtLevel = 1.0 / pow ( 2.0 , float ( traversalData . octreeCoords . w ) ) ;
vec3 start = vec3 ( traversalData . octreeCoords . xyz ) * sizeAtLevel ;
vec3 end = start + vec3 ( sizeAtLevel ) ;
for ( int i = 0 ; i < OCTREE _MAX _LEVELS ; ++ i ) {
// Find out which octree child contains the position
// 0 if before center, 1 if after
vec3 center = 0.5 * ( start + end ) ;
vec3 childCoord = step ( center , shapePosition ) ;
OctreeNodeData childData = getOctreeChildData ( traversalData . parentOctreeIndex , ivec3 ( childCoord ) ) ;
// Get octree coords for the next level down
ivec4 octreeCoords = traversalData . octreeCoords ;
traversalData . octreeCoords = ivec4 ( octreeCoords . xyz * 2 + ivec3 ( childCoord ) , octreeCoords . w + 1 ) ;
if ( childData . flag == OCTREE _FLAG _INTERNAL ) {
// interior tile - keep going deeper
start = mix ( start , center , childCoord ) ;
end = mix ( center , end , childCoord ) ;
traversalData . parentOctreeIndex = childData . data ;
} else {
// leaf tile - stop traversing
float dimAtLevel = pow ( 2.0 , float ( traversalData . octreeCoords . w ) ) ;
traversalData . stepT = u _stepSize / dimAtLevel ;
# if ( SAMPLE _COUNT == 1 )
getOctreeLeafSampleData ( childData , sampleDatas [ 0 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 0 ] ) ;
# else
getOctreeLeafSampleDatas ( childData , sampleDatas [ 0 ] , sampleDatas [ 1 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 0 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 1 ] ) ;
# endif
return ;
}
}
}
/ * *
* Transform a given position to an octree tile coordinate and a position within that tile ,
* and find the corresponding megatexture index and texture coordinates
* /
void traverseOctreeFromBeginning ( in vec3 shapePosition , out TraversalData traversalData , out SampleData sampleDatas [ SAMPLE _COUNT ] ) {
traversalData . octreeCoords = ivec4 ( 0 ) ;
traversalData . parentOctreeIndex = 0 ;
OctreeNodeData rootData = getOctreeNodeData ( vec2 ( 0.0 ) ) ;
if ( rootData . flag == OCTREE _FLAG _LEAF ) {
// No child data, only the root tile has data
traversalData . stepT = u _stepSize ;
# if ( SAMPLE _COUNT == 1 )
getOctreeLeafSampleData ( rootData , sampleDatas [ 0 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 0 ] ) ;
# else
getOctreeLeafSampleDatas ( rootData , sampleDatas [ 0 ] , sampleDatas [ 1 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 0 ] ) ;
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ 1 ] ) ;
# endif
} else {
traverseOctreeDownwards ( shapePosition , traversalData , sampleDatas ) ;
}
}
bool inRange ( in vec3 v , in vec3 minVal , in vec3 maxVal ) {
return clamp ( v , minVal , maxVal ) == v ;
}
bool insideTile ( in vec3 shapePosition , in ivec4 octreeCoords ) {
vec3 tileUv = getTileUv ( shapePosition , octreeCoords ) ;
bool inside = inRange ( tileUv , vec3 ( 0.0 ) , vec3 ( 1.0 ) ) ;
// Assume (!) the position is always inside the root tile.
return inside || octreeCoords . w == 0 ;
}
void traverseOctreeFromExisting ( in vec3 shapePosition , inout TraversalData traversalData , inout SampleData sampleDatas [ SAMPLE _COUNT ] ) {
if ( insideTile ( shapePosition , traversalData . octreeCoords ) ) {
for ( int i = 0 ; i < SAMPLE _COUNT ; i ++ ) {
setSampleUv ( shapePosition , traversalData . octreeCoords , sampleDatas [ i ] ) ;
}
} else {
// Go up tree
for ( int i = 0 ; i < OCTREE _MAX _LEVELS ; ++ i )
{
traversalData . octreeCoords . xyz /= 2 ;
traversalData . octreeCoords . w -= 1 ;
if ( ! insideTile ( shapePosition , traversalData . octreeCoords ) ) {
traversalData . parentOctreeIndex = getOctreeParentIndex ( traversalData . parentOctreeIndex ) ;
} else {
break ;
}
}
// Go down tree
traverseOctreeDownwards ( shapePosition , traversalData , sampleDatas ) ;
}
}
` ,o $ e= ` // See Octree.glsl for the definitions of SampleData and intMod
/ * M e g a t e x t u r e d e f i n e s ( s e t i n S c e n e / V o x e l R e n d e r R e s o u r c e s . j s )
# define SAMPLE _COUNT # # #
# define NEAREST _SAMPLING
# define PADDING
* /
uniform ivec2 u _megatextureSliceDimensions ; // number of slices per tile, in two dimensions
uniform ivec2 u _megatextureTileDimensions ; // number of tiles per megatexture, in two dimensions
uniform vec2 u _megatextureVoxelSizeUv ;
uniform vec2 u _megatextureSliceSizeUv ;
uniform vec2 u _megatextureTileSizeUv ;
uniform ivec3 u _dimensions ; // does not include padding
# if defined ( PADDING )
uniform ivec3 u _paddingBefore ;
uniform ivec3 u _paddingAfter ;
# endif
// Integer min, max, clamp: For WebGL1 only
int intMin ( int a , int b ) {
return a <= b ? a : b ;
}
int intMax ( int a , int b ) {
return a >= b ? a : b ;
}
int intClamp ( int v , int minVal , int maxVal ) {
return intMin ( intMax ( v , minVal ) , maxVal ) ;
}
vec2 index1DTo2DTexcoord ( int index , ivec2 dimensions , vec2 uvScale )
{
int indexX = intMod ( index , dimensions . x ) ;
int indexY = index / dimensions . x ;
return vec2 ( indexX , indexY ) * uvScale ;
}
/ *
How is 3 D data stored in a 2 D megatexture ?
In this example there is only one loaded tile and it has 2 x2x2 voxels ( 8 voxels total ) .
The data is sliced by Z . The data at Z = 0 is placed in texels ( 0 , 0 ) , ( 0 , 1 ) , ( 1 , 0 ) , ( 1 , 1 ) and
the data at Z = 1 is placed in texels ( 2 , 0 ) , ( 2 , 1 ) , ( 3 , 0 ) , ( 3 , 1 ) .
Note that there could be empty space in the megatexture because it ' s a power of two .
0 1 2 3
+ -- - + -- - + -- - + -- - +
| | | | | 3
+ -- - + -- - + -- - + -- - +
| | | | | 2
+ -- -- -- - + -- -- -- - +
| 010 | 110 | 011 | 111 | 1
| -- - -- - | -- - -- - |
| 000 | 100 | 001 | 101 | 0
+ -- -- -- - + -- -- -- - +
When doing linear interpolation the megatexture needs to be sampled twice : once for
the Z slice above the voxel coordinate and once for the slice below . The two slices
are interpolated with fract ( coord . z - 0.5 ) . For example , a Z coordinate of 1.0 is
halfway between two Z slices so the interpolation factor is 0.5 . Below is a side view
of the 3 D voxel grid with voxel coordinates on the left side .
2 + -- - +
| 001 |
1 + - z - +
| 000 |
0 + -- - +
When doing nearest neighbor the megatexture only needs to be sampled once at the closest Z slice .
* /
Properties getPropertiesFromMegatexture ( in SampleData sampleData ) {
vec3 tileUv = clamp ( sampleData . tileUv , vec3 ( 0.0 ) , vec3 ( 1.0 ) ) ; // TODO is the clamp necessary?
int tileIndex = sampleData . megatextureIndex ;
vec3 voxelCoord = tileUv * vec3 ( u _dimensions ) ;
ivec3 voxelDimensions = u _dimensions ;
# if defined ( PADDING )
voxelDimensions += u _paddingBefore + u _paddingAfter ;
voxelCoord += vec3 ( u _paddingBefore ) ;
# endif
# if defined ( NEAREST _SAMPLING )
// Round to the center of the nearest voxel
voxelCoord = floor ( voxelCoord + vec3 ( 0.5 ) ) ;
# endif
// Tile location
vec2 tileUvOffset = index1DTo2DTexcoord ( tileIndex , u _megatextureTileDimensions , u _megatextureTileSizeUv ) ;
// Slice location
float slice = voxelCoord . z - 0.5 ;
int sliceIndex = int ( floor ( slice ) ) ;
int sliceIndex0 = intClamp ( sliceIndex , 0 , voxelDimensions . z - 1 ) ;
vec2 sliceUvOffset0 = index1DTo2DTexcoord ( sliceIndex0 , u _megatextureSliceDimensions , u _megatextureSliceSizeUv ) ;
// Voxel location
vec2 voxelUvOffset = clamp ( voxelCoord . xy , vec2 ( 0.5 ) , vec2 ( voxelDimensions . xy ) - vec2 ( 0.5 ) ) * u _megatextureVoxelSizeUv ;
// Final location in the megatexture
vec2 uv0 = tileUvOffset + sliceUvOffset0 + voxelUvOffset ;
# if defined ( NEAREST _SAMPLING )
return getPropertiesFromMegatextureAtUv ( uv0 ) ;
# else
float sliceLerp = fract ( slice ) ;
int sliceIndex1 = intMin ( sliceIndex + 1 , voxelDimensions . z - 1 ) ;
vec2 sliceUvOffset1 = index1DTo2DTexcoord ( sliceIndex1 , u _megatextureSliceDimensions , u _megatextureSliceSizeUv ) ;
vec2 uv1 = tileUvOffset + sliceUvOffset1 + voxelUvOffset ;
Properties properties0 = getPropertiesFromMegatextureAtUv ( uv0 ) ;
Properties properties1 = getPropertiesFromMegatextureAtUv ( uv1 ) ;
return mixProperties ( properties0 , properties1 , sliceLerp ) ;
# endif
}
// Convert an array of sample datas to a final weighted properties.
Properties accumulatePropertiesFromMegatexture ( in SampleData sampleDatas [ SAMPLE _COUNT ] ) {
# if ( SAMPLE _COUNT == 1 )
return getPropertiesFromMegatexture ( sampleDatas [ 0 ] ) ;
# else
// When more than one sample is taken the accumulator needs to start at 0
Properties properties = clearProperties ( ) ;
for ( int i = 0 ; i < SAMPLE _COUNT ; ++ i ) {
float weight = sampleDatas [ i ] . weight ;
// Avoid reading the megatexture when the weight is 0 as it can be costly.
if ( weight > 0.0 ) {
Properties tempProperties = getPropertiesFromMegatexture ( sampleDatas [ i ] ) ;
tempProperties = scaleProperties ( tempProperties , weight ) ;
properties = sumProperties ( properties , tempProperties ) ;
}
}
return properties ;
# endif
}
` ;function r $ e(e){const t=new Ys;this.shaderBuilder=t;const n=e._customShader,i=nn(e._uniformMap,n.uniformMap);e._uniformMap=i;const o=n.uniforms;for(const _ in o)if(o.hasOwnProperty(_)){const g=o[_];t.addUniform(g.type,_,we.FRAGMENT)}t.addUniform("sampler2D","u_megatextureTextures[METADATA_COUNT]",we.FRAGMENT),this.uniformMap=i;const r=e._clippingPlanes,s=l(r)&&r.enabled?r.length:0;this.clippingPlanes=r,this.clippingPlanesLength=s,t.addVertexLines([YXe]),t.addFragmentLines([n.fragmentShaderText,"#line 0",XXe]),s>0&&(t.addDefine("CLIPPING_PLANES",void 0,we.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",s,we.FRAGMENT),r.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,we.FRAGMENT),t.addFragmentLines([KXe])),e._depthTest&&(t.addDefine("DEPTH_TEST",void 0,we.FRAGMENT),t.addFragmentLines([ $ Xe]));const a=e._provider.shape;a==="BOX"?t.addFragmentLines([JXe,AO,e $ e]):a==="CYLINDER"?t.addFragmentLines([QXe,AO,t $ e]):a==="ELLIPSOID"&&t.addFragmentLines([ZXe,AO,n $ e]),t.addFragmentLines([i $ e,o $ e,qXe]);const c=e._shape,u=c.shaderDefines;for(const _ in u)if(u.hasOwnProperty(_)){let g=u[_];l(g)&&(g=g===!0?void 0:g,t.addDefine(_,g,we.FRAGMENT))}let f=c.shaderMaximumIntersectionsLength;s>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",f,we.FRAGMENT),s===1?f+=1:r.unionClippingRegions?f+=2:f+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",f,we.FRAGMENT),f+=1),t.addDefine("INTERSECTION_COUNT",f,we.FRAGMENT),(!d.equals(e.paddingBefore,d.ZERO)||!d.equals(e.paddingAfter,d.ZERO))&&t.addDefine("PADDING",void 0,we.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,we.FRAGMENT),e._jitter&&t.addDefine("JITTER",void 0,we.FRAGMENT),e._nearestSampling&&t.addDefine("NEAREST_SAMPLING",void 0,we.FRAGMENT);const h=e._traversal;t.addDefine("SAMPLE_COUNT", ` $ { h . _sampleCount } ` ,we.FRAGMENT)}function s $ e(e,t){const{shaderBuilder:n}=e,{names:i,types:o,componentTypes:r,minimumValues:s,maximumValues:a}=t._provider,c=o.length,u=l(s)&&l(a);n.addDefine("METADATA_COUNT",c,we.FRAGMENT),u&&n.addDefine("STATISTICS",void 0,we.FRAGMENT);for(let R=0;R<c;R++){const z=i[R],U=o[R],v= ` PropertyStatistics _$ { z } ` ,I= ` PropertyStatistics _$ { z } ` ;n.addStruct(v,I,we.FRAGMENT);const m=kE(U);n.addStructField(v,m,"min"),n.addStructField(v,m,"max")}const f="Statistics",h="Statistics",_="statistics";n.addStruct(f,h,we.FRAGMENT);for(let R=0;R<c;R++){const z=i[R],U= ` PropertyStatistics _$ { z } ` ,v=z;n.addStructField(f,U,v)}const g="Metadata",p="Metadata",A="metadata";n.addStruct(g,p,we.FRAGMENT),n.addStructField(g,h,_);for(let R=0;R<c;R++){const z=i[R],U=o[R],v=kE(U);n.addStructField(g,v,z)}for(let R=0;R<c;R++){const z=i[R],U=o[R],v=c $ e(U),I= ` VoxelProperty _$ { z } ` ,m= ` VoxelProperty _$ { z } ` ;n.addStruct(I,m,we.FRAGMENT),n.addStructField(I,v,"partialDerivativeLocal"),n.addStructField(I,v,"partialDerivativeWorld"),n.addStructField(I,v,"partialDerivativeView"),n.addStructField(I,v,"partialDerivativeValid")}const C="Voxel",b="Voxel",x="voxel";n.addStruct(C,b,we.FRAGMENT);for(let R=0;R<c;R++){const z=i[R],U= ` VoxelProperty _$ { z } ` ;n.addStructField(C,U,z)}n.addStructField(C,"vec3","positionEC"),n.addStructField(C,"vec3","positionUv"),n.addStructField(C,"vec3","positionShapeUv"),n.addStructField(C,"vec3","positionUvLocal"),n.addStructField(C,"vec3","viewDirUv"),n.addStructField(C,"vec3","viewDirWorld"),n.addStructField(C,"float","travelDistance");const w="FragmentInput",S="FragmentInput";n.addStruct(w,S,we.FRAGMENT),n.addStructField(w,p,A),n.addStructField(w,b,x);const P="Properties",L="Properties",H="properties";n.addStruct(P,L,we.FRAGMENT);for(let R=0;R<c;R++){const z=i[R],U=o[R],v=kE(U);n.addStructField(P,v,z)}{const R="clearProperties";n.addFunction(R, ` $ { L } clearProperties ( ) ` ,we.FRAGMENT),n.addFunctionLines(R,[ ` $ { L } $ { H } ; ` ]);for(let z=0;z<c;z++){const U=i[z],v=o[z];r[z];const I=kE(v);n.addFunctionLines(R,[ ` $ { H } . $ { U } = $ { I } ( 0.0 ) ; ` ])}n.addFunctionLines(R,[ ` return $ { H } ; ` ])}{const R="sumProperties";n.addFunction(R, ` $ { L } sumProperties ( $ { L } propertiesA , $ { L } propertiesB ) ` ,we.FRAGMENT),n.addFunctionLines(R,[ ` $ { L } $ { H } ; ` ]);for(let z=0;z<c;z++){const U=i[z];n.addFunctionLines(
{
material . diffuse = vec3 ( 1.0 ) ;
material . alpha = 1.0 ;
} ` });function BJ(){this.ready=!0,this.readyPromise=Promise.resolve(this),this.shape=_g.BOX,this.dimensions=new d(1,1,1),this.names=["data"],this.types=[Dt.SCALAR],this.componentTypes=[Ht.FLOAT32],this.maximumTileCount=1}BJ.prototype.requestData=function(e){if(!((l(e)?y(e.tileLevel,0):0)>=1))return Promise.resolve([new Float32Array(1)])};Vl.DefaultProvider=new BJ;function pv(e,t){const n=t.terrainProvider,i=t.mapProjection,o=i.ellipsoid;let r;const s=t.camera.getRectangleCameraCoordinates(e);return t.mode===le.SCENE3D?r=o.cartesianToCartographic(s):r=i.unproject(s),l(n)?n.readyPromise.then(function(){const a=n.availability;if(!l(a)||t.mode===le.SCENE2D)return r;const c=[_e.center(e),_e.southeast(e),_e.southwest(e),_e.northeast(e),_e.northwest(e)];return pv._sampleTerrainMostDetailed(n,c).then(function(u){const f=u.reduce(function(_,g){return Math.max(g.height,_)},-Number.MAX_VALUE),h=r;return h.height+=f,h})}):Promise.resolve(r)}pv._sampleTerrainMostDetailed=dv;var dA;typeof ko<"u"&&(dA=ko);(function(){/*!
* Knockout JavaScript library v3 . 5.1
* ( c ) The Knockout . js team - http : //knockoutjs.com/
* License : MIT ( http : //www.opensource.org/licenses/mit-license.php)
* /(function(){(function(e){var t=this||(0,eval)("this"),n=t.document,i=t.navigator,o=t.jQuery,r=t.JSON;o||typeof jQuery>"u"||(o=jQuery),function(s){s(t.ko={})}(function(s,a){function c(v,I){return v===null||typeof v in A?v===I:!1}function u(v,I){var m;return function(){m||(m=p.a.setTimeout(function(){m=e,v()},I))}}function f(v,I){var m;return function(){clearTimeout(m),m=p.a.setTimeout(v,I)}}function h(v,I){I&&I!=="change"?I==="beforeChange"?this.pc(v):this.gb(v,I):this.qc(v)}function _(v,I){I!==null&&I.s&&I.s()}function g(v,I){var m=this.qd,D=m[S];D.ra||(this.Qb&&this.mb[I]?(m.uc(I,v,this.mb[I]),this.mb[I]=null,--this.Qb):D.I[I]||m.uc(I,v,D.J?{da:v}:m.$c(v)),v.Ja&&v.gd())}var p=typeof s<"u"?s:{};p.b=function(v,I){for(var m=v.split("."),D=p,O=0;O<m.length-1;O++)D=D[m[O]];D[m[m.length-1]]=I},p.L=function(v,I,m){v[I]=m},p.version="3.5.1",p.b("version",p.version),p.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},p.a=function(){function v(X,$){for(var Y in X)O.call(X,Y)&&$(Y,X[Y])}function I(X,$){if($)for(var Y in $)O.call($,Y)&&(X[Y]=$[Y]);return X}function m(X,$){return X.__proto__=$,X}function D(X,$,Y,ae){var ue=X[$].match(q)||[];p.a.D(Y.match(q),function(re){p.a.Na(ue,re,ae)}),X[$]=ue.join(" ")}var O=Object.prototype.hasOwnProperty,M={__proto__:[]}instanceof Array,V=typeof Symbol=="function",k={},W={};k[i&&/Firefox\/2/i.test(i.userAgent)?"KeyboardEvent":"UIEvents"]=["keyup","keydown","keypress"],k.MouseEvents="click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave".split(" "),v(k,function(X,$){if($.length)for(var Y=0,ae=$.length;Y<ae;Y++)W[$[Y]]=X});var G={propertychange:!0},K=n&&function(){for(var X=3,$=n.createElement("div"),Y=$.getElementsByTagName("i");$.innerHTML="<!--[if gt IE "+ ++X+"]><i></i > < ! [ endif ] -- > ",Y[0];);return 4<X?X:e}(),q=/\S+/g,te;return{Jc:[" authenticity _token ",/^__RequestVerificationToken(_.*)?$/],D:function(X,$,Y){for(var ae=0,ue=X.length;ae<ue;ae++)$.call(Y,X[ae],ae,X)},A:typeof Array.prototype.indexOf==" function "?function(X,$){return Array.prototype.indexOf.call(X,$)}:function(X,$){for(var Y=0,ae=X.length;Y<ae;Y++)if(X[Y]===$)return Y;return-1},Lb:function(X,$,Y){for(var ae=0,ue=X.length;ae<ue;ae++)if($.call(Y,X[ae],ae,X))return X[ae];return e},Pa:function(X,$){var Y=p.a.A(X,$);0<Y?X.splice(Y,1):Y===0&&X.shift()},wc:function(X){var $=[];return X&&p.a.D(X,function(Y){0>p.a.A($,Y)&&$.push(Y)}),$},Mb:function(X,$,Y){var ae=[];if(X)for(var ue=0,re=X.length;ue<re;ue++)ae.push($.call(Y,X[ue],ue));return ae},jb:function(X,$,Y){var ae=[];if(X)for(var ue=0,re=X.length;ue<re;ue++)$.call(Y,X[ue],ue)&&ae.push(X[ue]);return ae},Nb:function(X,$){if($ instanceof Array)X.push.apply(X,$);else for(var Y=0,ae=$.length;Y<ae;Y++)X.push($[Y]);return X},Na:function(X,$,Y){var ae=p.a.A(p.a.bc(X),$);0>ae?Y&&X.push($):Y||X.splice(ae,1)},Ba:M,extend:I,setPrototypeOf:m,Ab:M?m:I,P:v,Ga:function(X,$,Y){if(!X)return X;var ae={},ue;for(ue in X)O.call(X,ue)&&(ae[ue]=$.call(Y,X[ue],ue,X));return ae},Tb:function(X){for(;X.firstChild;)p.removeNode(X.firstChild)},Yb:function(X){X=p.a.la(X);for(var $=(X[0]&&X[0].ownerDocument||n).createElement(" div "),Y=0,ae=X.length;Y<ae;Y++)$.appendChild(p.oa(X[Y]));return $},Ca:function(X,$){for(var Y=0,ae=X.length,ue=[];Y<ae;Y++){var re=X[Y].cloneNode(!0);ue.push($?p.oa(re):re)}return ue},va:function(X,$){if(p.a.Tb(X),$)for(var Y=0,ae=$.length;Y<ae;Y++)X.appendChild($[Y])},Xc:function(X,$){var Y=X.nodeType?[X]:X;if(0<Y.length){for(var ae=Y[0],ue=ae.parentNode,re=0,he=$.length;re<he;re++)ue.insertBefore($[re],ae);for(re=0,he=Y.length;re<he;re++)p.removeNode(Y[re])}},Ua:function(X,$){if(X.length){for($=$.nodeType===8&&$.parentNode||$;X.length&&X[0].parentNode!==$;)X.splice(0,1);for(;1<X.length&&X[X.length-1].parentNode!==$;)X.length--;if(1<X.length){var Y=X[0],ae=X[X.length-1];for(X.length=0;Y!==ae;)X.push(Y),Y=Y.nextSibling;X.push(ae)}}return X},Zc:function(X,$){7>K?X.setAttribute(" selected ",$):X.selected=$},Db:function(X){return X===null||X===e?" ":X.trim?X.trim():X.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g," " ) } , Ud : function ( X , $ ) { return X = X ||
, ` ;var W=[],G=k.match(D),K,q=[],te=0;if(1<G.length){for(var X=0, $ ; $ =G[X];++X){var Y= $ .charCodeAt(0);if(Y===44){if(0>=te){W.push(K&&q.length?{key:K,value:q.join("")}:{unknown:K||q.join("")}),K=te=0,q=[];continue}}else if(Y===58){if(!te&&!K&&q.length===1){K=q.pop();continue}}else{if(Y===47&&1< $ .length&&( $ .charCodeAt(1)===47|| $ .charCodeAt(1)===42))continue;Y===47&&X&&1< $ .length?(Y=G[X-1].match(O))&&!M[Y[0]]&&(k=k.substr(k.indexOf( $ )+1),G=k.match(D),X=-1, $ ="/"):Y===40||Y===123||Y===91?++te:Y===41||Y===125||Y===93?--te:K||q.length||Y!==34&&Y!==39||( $ = $ .slice(1,-1))}q.push( $ )}if(0<te)throw Error("Unbalanced parentheses, braces, or brackets")}return W}var I=["true","false","null","undefined"],m=/^(?:[ $ _a-z][ $ \w ]*|(.+)( \. \s *[ $ _a-z][ $ \w ]*| \[ .+ \] )) $ /i,D=RegExp( ` "(?:\\\\.|[^" ] ) * " | '(?:\\\\.|[^' ] ) * ' | \ ` (?: \\ \\ .|[^ \` ])* \` |/ \\ *(?:[^*]| \\ *+[^*/])* \\ *+/|//.*
| / ( ? : \ \ \ \ . | [ ^ / ] ) + / w * | [ ^ \ \ s : , / ] [ ^ , " ' \ ` { } ( ) / : [ \ \ ] ] * [ ^ \ \ s , " ' \ ` { } ( ) / : [ \ \ ] ] | [ ^ \ \ s ] ` , " g " ) , O = / [ \ ] ) " ' A - Z a - z 0 - 9 _ $ ] + $ / , M = { i n : 1 , r e t u r n : 1 , t y p e o f : 1 } , V = { } ; r e t u r n { R a : [ ] , w a : V , a c : v , v b : f u n c t i o n ( k , W ) { f u n c t i o n G ( Y , a e ) { v a r u e ; i f ( ! X ) { v a r r e = p . g e t B i n d i n g H a n d l e r ( Y ) ; i f ( r e & & r e . p r e p r o c e s s & & ! ( a e = r e . p r e p r o c e s s ( a e , Y , G ) ) ) r e t u r n ; ( r e = V [ Y ] ) & & ( u e = a e , 0 < = p . a . A ( I , u e ) ? u e = ! 1 : ( r e = u e . m a t c h ( m ) , u e = r e = = = n u l l ? ! 1 : r e [ 1 ] ? " O b j e c t ( " + r e [ 1 ] + " ) " + r e [ 2 ] : u e ) , r e = u e ) , r e & & q . p u s h ( " ' " + ( t y p e o f V [ Y ] = = " s t r i n g " ? V [ Y ] : Y ) + " ' : f u n c t i o n ( _ z ) { " + u e + " = _ z } " ) } t e & & ( a e = " f u n c t i o n ( ) { r e t u r n " + a e + " } " ) , K . p u s h ( " ' " + Y + " ' : " + a e ) } W = W | | { } ; v a r K = [ ] , q = [ ] , t e = W . v a l u e A c c e s s o r s , X = W . b i n d i n g P a r a m s , $ = t y p e o f k = = " s t r i n g " ? v ( k ) : k ; r e t u r n p . a . D ( $ , f u n c t i o n ( Y ) { G ( Y . k e y | | Y . u n k n o w n , Y . v a l u e ) } ) , q . l e n g t h & & G ( " _ k o _ p r o p e r t y _ w r i t e r s " , " { " + q . j o i n ( " , " ) + " } " ) , K . j o i n ( " , " ) } , I d : f u n c t i o n ( k , W ) { f o r ( v a r G = 0 ; G < k . l e n g t h ; G + + ) i f ( k [ G ] . k e y = = W ) r e t u r n ! 0 ; r e t u r n ! 1 } , e b : f u n c t i o n ( k , W , G , K , q ) { k & & p . O ( k ) ? ! p . Z a ( k ) | | q & & k . v ( ) = = = K | | k ( K ) : ( k = W . g e t ( " _ k o _ p r o p e r t y _ w r i t e r s " ) ) & & k [ G ] & & k [ G ] ( K ) } } } ( ) , p . b ( " e x p r e s s i o n R e w r i t i n g " , p . m ) , p . b ( " e x p r e s s i o n R e w r i t i n g . b i n d i n g R e w r i t e V a l i d a t o r s " , p . m . R a ) , p . b ( " e x p r e s s i o n R e w r i t i n g . p a r s e O b j e c t L i t e r a l " , p . m . a c ) , p . b ( " e x p r e s s i o n R e w r i t i n g . p r e P r o c e s s B i n d i n g s " , p . m . v b ) , p . b ( " e x p r e s s i o n R e w r i t i n g . _ t w o W a y B i n d i n g s " , p . m . w a ) , p . b ( " j s o n E x p r e s s i o n R e w r i t i n g " , p . m ) , p . b ( " j s o n E x p r e s s i o n R e w r i t i n g . i n s e r t P r o p e r t y A c c e s s o r s I n t o J s o n " , p . m . v b ) , f u n c t i o n ( ) { f u n c t i o n v ( G ) { r e t u r n G . n o d e T y p e = = 8 & & M . t e s t ( O ? G . t e x t : G . n o d e V a l u e ) } f u n c t i o n I ( G ) { r e t u r n G . n o d e T y p e = = 8 & & V . t e s t ( O ? G . t e x t : G . n o d e V a l u e ) } f u n c t i o n m ( G , K ) { f o r ( v a r q = G , t e = 1 , X = [ ] ; q = q . n e x t S i b l i n g ; ) { i f ( I ( q ) & & ( p . a . g . s e t ( q , W , ! 0 ) , t e - - , t e = = = 0 ) ) r e t u r n X ; X . p u s h ( q ) , v ( q ) & & t e + + } i f ( ! K ) t h r o w E r r o r ( " C a n n o t f i n d c l o s i n g c o m m e n t t a g t o m a t c h : " + G . n o d e V a l u e ) ; r e t u r n n u l l } f u n c t i o n D ( G , K ) { v a r q = m ( G , K ) ; r e t u r n q ? 0 < q . l e n g t h ? q [ q . l e n g t h - 1 ] . n e x t S i b l i n g : G . n e x t S i b l i n g : n u l l } v a r O = n & & n . c r e a t e C o m m e n t ( " t e s t " ) . t e x t = = = " < ! - - t e s t - - > " , M = O ? / ^ \ x 3 c ! - - \ s * k o ( ? : \ s + ( [ \ s \ S ] + ) ) ? \ s * - - \ x 3 e $ / : / ^ \ s * k o ( ? : \ s + ( [ \ s \ S ] + ) ) ? \ s * $ / , V = O ? / ^ \ x 3 c ! - - \ s * \ / k o \ s * - - \ x 3 e $ / : / ^ \ s * \ / k o \ s * $ / , k = { u l : ! 0 , o l : ! 0 } , W = " _ _ k o _ m a t c h e d E n d C o m m e n t _ _ " ; p . h = { e a : { } , c h i l d N o d e s : f u n c t i o n ( G ) { r e t u r n v ( G ) ? m ( G ) : G . c h i l d N o d e s } , E a : f u n c t i o n ( G ) { i f ( v ( G ) ) { G = p . h . c h i l d N o d e s ( G ) ; f o r ( v a r K = 0 , q = G . l e n g t h ; K < q ; K + + ) p . r e m o v e N o d e ( G [ K ] ) } e l s e p . a . T b ( G ) } , v a : f u n c t i o n ( G , K ) { i f ( v ( G ) ) { p . h . E a ( G ) ; f o r ( v a r q = G . n e x t S i b l i n g , t e = 0 , X = K . l e n g t h ; t e < X ; t e + + ) q . p a r e n t N o d e . i n s e r t B e f o r e ( K [ t e ] , q ) } e l s e p . a . v a ( G , K ) } , V c : f u n c t i o n ( G , K ) { v a r q ; v ( G ) ? ( q = G . n e x t S i b l i n g , G = G . p a r e n t N o d e ) : q = G . f i r s t C h i l d , q ? K ! = = q & & G . i n s e r t B e f o r e ( K , q ) : G . a p p e n d C h i l d ( K ) } , W b : f u n c t i o n ( G , K , q ) { q ? ( q = q . n e x t S i b l i n g , v ( G ) & & ( G = G . p a r e n t N o d e ) , q ? K ! = = q & & G . i n s e r t B e f o r e ( K , q ) : G . a p p e n d C h i l d ( K ) ) : p . h . V c ( G , K ) } , f i r s t C h i l d : f u n c t i o n ( G ) { i f ( v ( G ) ) r e t u r n ! G . n e x t S i b l i n g | | I ( G . n e x t S i b l i n g ) ? n u l l : G . n e x t S i b l i n g ; i f ( G . f i r s t C h i l d & & I ( G . f i r s t C h i l d ) ) t h r o w E r r o r ( " F o u n d i n v a l i d e n d c o m m e n t , a s t h e f i r s t c h i l d o f " + G ) ; r e t u r n G . f i r s t C h i l d } , n e x t S i b l i n g : f u n c t i o n ( G ) { i f ( v ( G ) & & ( G = D ( G ) ) , G . n e x t S i b l i n g & & I ( G . n e x t S i b l i n g ) ) { v a r K = G . n e x t S i b l i n g ; i f ( I ( K ) & & ! p . a . g . g e t ( K , W ) ) t h r o w E r r o r ( " F o u n d e n d c o m m e n t w i t h o u t a m a t c h i n g o p e n i n g c o m m e n t , a s c h i l d o f " + G ) ; r e t u r n n u l l } r e t u r n G . n e x t S i b l i n g } , C d : v , V d : f u n c t i o n ( G ) { r e t u r n ( G = ( O ? G . t e x t : G . n o d e V a l u e ) . m a t c h ( M ) ) ? G [ 1 ] : n u l l } , S c : f u n c t i o n ( G ) { i f ( k [ p . a . R ( G ) ] ) { v a r K = G . f i r s t C h i l d ; i f ( K ) d o i f ( K . n o d e T y p e = = = 1 ) { v a r q ; q = K . f i r s t C h i l d ; v a r t e = n u l l ; i f ( q ) d o i f ( t e ) t e . p u s h ( q ) ; e l s e i f ( v ( q ) ) { v a r X = D ( q , ! 0 ) ; X ? q = X : t e = [ q ] } e l s e I ( q ) & & ( t e = [ q ] ) ; w h i l e ( q = q . n e x t S i b l i n g ) ; i f ( q = t e ) f o r ( t e = K . n e x t S i b l i n g , X = 0 ; X < q . l e n g t h ; X + + ) t e ? G . i n s e r t B e f o r e ( q [ X ] , t e ) : G . a p p e n d C h i l d ( q [ X ] ) } w h i l e ( K = K . n e x t S i b l i n g ) } } } } ( ) , p . b ( " v i r t u a l E l e m e n t s " , p . h ) , p . b ( " v i r t u a l E l e m e n t s . a l l o w e d B i n d i n g s " , p . h . e a ) , p . b ( " v i r t u a l E l e m e n t s . e m p t y N o d e " , p . h . E a ) , p . b ( " v i r t u a l E l e m e n t s . i n s e r t A f t e r " , p . h . W b ) , p . b ( " v i r t u a l E l e m e n t s . p r e p e n d " , p . h . V c ) , p . b ( " v i r t u a l E l e m e n t s . s e t D o m N o d e C h i l d r e n " , p . h . v a ) , f u n c t i o n ( ) { p . g a = f u n c t i o n ( ) { t h i s . n d = { } } , p . a . e x t e n d ( p . g a . p r o t o t y p e , { n o d e H a s B i n d i n g s : f u n c t i o n ( v ) { s w i t c h ( v . n o d e T y p e ) { c a s e 1 : r e t u r n v . g e t A t t r i b u t e ( " d a t a - b i n d " ) ! = n u l l | | p . j . g e t C o m p o n e n t N a m e F o r N o d e ( v ) ; c a s e 8 : r e t u r n p . h . C d ( v ) ; d e f a u l t : r e t u r n ! 1 } } , g e t B i n d i n g s : f u n c t i o n ( v , I ) { v a r m = t h i s . g e t B i n d i n g s S t r i n g ( v , I ) , m = m ? t h i s . p a r s e B i n d i n g s S t r i n g ( m , I , v ) : n u l l ; r e t u r n p . j . t c ( m , v , I , ! 1 ) } , g e t B i n d i n g A c c e s s o r s : f u n c t i o n ( v , I ) { v a r m = t h i s . g e t B i n d i n g s S t r i n g ( v , I ) , m = m ? t h i s . p a r s e B i n d i n
Bindings value : ` +v+ `
Message : ` +G.message,G}}}),p.ga.instance=new p.ga}(),p.b("bindingProvider",p.ga),function(){function v(re){var he=(re=p.a.g.get(re,ue))&&re.N;he&&(re.N=null,he.Tc())}function I(re,he,ce){this.node=re,this.yc=he,this.kb=[],this.H=!1,he.N||p.a.K.za(re,v),ce&&ce.N&&(ce.N.kb.push(re),this.Kb=ce)}function m(re){return function(){return re}}function D(re){return re()}function O(re){return p.a.Ga(p.u.G(re),function(he,ce){return function(){return re()[ce]}})}function M(re,he,ce){return typeof re=="function"?O(re.bind(null,he,ce)):p.a.Ga(re,m)}function V(re,he){return O(this.getBindings.bind(this,re,he))}function k(re,he){var ce=p.h.firstChild(he);if(ce){var Q,ie=p.ga.instance,de=ie.preprocessNode;if(de){for(;Q=ce;)ce=p.h.nextSibling(Q),de.call(ie,Q);ce=p.h.firstChild(he)}for(;Q=ce;)ce=p.h.nextSibling(Q),W(re,Q)}p.i.ma(he,p.i.H)}function W(re,he){var ce=re,Q=he.nodeType===1;Q&&p.h.Sc(he),(Q||p.ga.instance.nodeHasBindings(he))&&(ce=K(he,null,re).bindingContextForDescendants),ce&&!Y[p.a.R(he)]&&k(ce,he)}function G(re){var he=[],ce={},Q=[];return p.a.P(re,function ie(de){if(!ce[de]){var me=p.getBindingHandler(de);me&&(me.after&&(Q.push(de),p.a.D(me.after,function(Ee){if(re[Ee]){if(p.a.A(Q,Ee)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+Q.join(", "));ie(Ee)}}),Q.length--),he.push({key:de,Mc:me})),ce[de]=!0}}),he}function K(re,he,ce){var Q=p.a.g.Ub(re,ue,{}),ie=Q.hd;if(!he){if(ie)throw Error("You cannot apply bindings multiple times to the same element.");Q.hd=!0}ie||(Q.context=ce),Q.Zb||(Q.Zb={});var de;if(he&&typeof he!="function")de=he;else{var me=p.ga.instance,Ee=me.getBindingAccessors||V,xe=p. $ (function(){return(de=he?he(ce,re):Ee.call(me,re,ce))&&(ce[te]&&ce[te](),ce[ $ ]&&ce[ $ ]()),de},null,{l:re});de&&xe.ja()||(xe=null)}var Pe=ce,Te;if(de){var Oe=function(){return p.a.Ga(xe?xe():de,D)},De=xe?function(Me){return function(){return D(xe()[Me])}}:function(Me){return de[Me]};Oe.get=function(Me){return de[Me]&&D(De(Me))},Oe.has=function(Me){return Me in de},p.i.H in de&&p.i.subscribe(re,p.i.H,function(){var Me=(0,de[p.i.H])();if(Me){var ve=p.h.childNodes(re);ve.length&&Me(ve,p.Ec(ve[0]))}}),p.i.pa in de&&(Pe=p.i.Cb(re,ce),p.i.subscribe(re,p.i.pa,function(){var Me=(0,de[p.i.pa])();Me&&p.h.firstChild(re)&&Me(re)})),Q=G(de),p.a.D(Q,function(Me){var ve=Me.Mc.init,Ie=Me.Mc.update,Ve=Me.key;if(re.nodeType===8&&!p.h.ea[Ve])throw Error("The binding '"+Ve+"' cannot be used with virtual elements");try{typeof ve=="function"&&p.u.G(function(){var Le=ve(re,De(Ve),Oe,Pe. $ data,Pe);if(Le&&Le.controlsDescendantBindings){if(Te!==e)throw Error("Multiple bindings ("+Te+" and "+Ve+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");Te=Ve}}),typeof Ie=="function"&&p. $ (function(){Ie(re,De(Ve),Oe,Pe. $ data,Pe)},null,{l:re})}catch(Le){throw Le.message='Unable to process binding "'+Ve+": "+de[Ve]+ ` "
Message : ` +Le.message,Le}})}return Q=Te===e,{shouldBindDescendants:Q,bindingContextForDescendants:Q&&Pe}}function q(re,he){return re&&re instanceof p.fa?re:new p.fa(re,e,e,he)}var te=p.a.Da("_subscribable"),X=p.a.Da("_ancestorBindingInfo"), $ =p.a.Da("_dataDependency");p.c={};var Y={script:!0,textarea:!0,template:!0};p.getBindingHandler=function(re){return p.c[re]};var ae={};p.fa=function(re,he,ce,Q,ie){function de(){var De=Pe?xe():xe,Me=p.a.f(De);return he?(p.a.extend(me,he),X in he&&(me[X]=he[X])):(me. $ parents=[],me. $ root=Me,me.ko=p),me[te]=Te,Ee?Me=me. $ data:(me. $ rawData=De,me. $ data=Me),ce&&(me[ce]=Me),Q&&Q(me,he,Me),he&&he[te]&&!p.S.o().Vb(he[te])&&he[te](),Oe&&(me[ $ ]=Oe),me. $ data}var me=this,Ee=re===ae,xe=Ee?e:re,Pe=typeof xe=="function"&&!p.O(xe),Te,Oe=ie&&ie.dataDependency;ie&&ie.exportDependencies?de():(Te=p.xb(de),Te.v(),Te.ja()?Te.equalityComparer=null:me[te]=e)},p.fa.prototype.createChildContext=function(re,he,ce,Q){if(!Q&&he&&typeof he=="object"&&(Q=he,he=Q.as,ce=Q.extend),he&&Q&&Q.noChildContext){var ie=typeof re=="function"&&!p.O(re);return new p.fa(ae,this,null,function(de){ce&&ce(de),de[he]=ie?re():re},Q)}return new p.fa(re,this,he,function(de,me){de. $ parentContext=me,de. $ parent=me. $ data,de. $ parents=(me. $ parents||[]).slice(0),de. $ parents.unshift(de. $ parent),ce&&ce(de)},Q)},p.fa.prototype.extend=function(re,he){return new p.fa(ae,this,null,function(ce){p.a.extend(ce,typeof re=="function"?re(ce):re)},he)};var ue=p.a.g.Z();I.prototype.Tc=function(){this.Kb&&this.Kb.N&&this.Kb.N.sd(this.node)},I.prototype.sd=function(re){p.a.Pa(this.kb,re),!this.kb.length&&this.H&&this.Cc()},I.prototype.Cc=function(){this.H=!0,this.yc.N&&!this.kb.length&&(this.yc.N=null,p.a.K.yb(this.node,v),p.i.ma(this.node,p.i.pa),this.Tc())},p.i={H:"childrenComplete",pa:"descendantsComplete",subscribe:function(re,he,ce,Q,ie){var de=p.a.g.Ub(re,ue,{});return de.Fa||(de.Fa=new p.T),ie&&ie.notifyImmediately&&de.Zb[he]&&p.u.G(ce,Q,[re]),de.Fa.subscribe(ce,Q,he)},ma:function(re,he){var ce=p.a.g.get(re,ue);if(ce&&(ce.Zb[he]=!0,ce.Fa&&ce.Fa.notifySubscribers(re,he),he==p.i.H)){if(ce.N)ce.N.Cc();else if(ce.N===e&&ce.Fa&&ce.Fa.Wa(p.i.pa))throw Error("descendantsComplete event not supported for bindings on this node")}},Cb:function(re,he){var ce=p.a.g.Ub(re,ue,{});return ce.N||(ce.N=new I(re,ce,he[X])),he[X]==ce?he:he.extend(function(Q){Q[X]=ce})}},p.Td=function(re){return(re=p.a.g.get(re,ue))&&re.context},p.ib=function(re,he,ce){return re.nodeType===1&&p.h.Sc(re),K(re,he,q(ce))},p.ld=function(re,he,ce){return ce=q(ce),p.ib(re,M(he,ce,re),ce)},p.Oa=function(re,he){he.nodeType!==1&&he.nodeType!==8||k(q(re),he)},p.vc=function(re,he,ce){if(!o&&t.jQuery&&(o=t.jQuery),2>arguments.length){if(he=n.body,!he)throw Error("ko.applyBindings: could not find document.body; has the document been loaded?")}else if(!he||he.nodeType!==1&&he.nodeType!==8)throw Error("ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node");W(q(re,ce),he)},p.Dc=function(re){return!re||re.nodeType!==1&&re.nodeType!==8?e:p.Td(re)},p.Ec=function(re){return(re=p.Dc(re))?re. $ data:e},p.b("bindingHandlers",p.c),p.b("bindingEvent",p.i),p.b("bindingEvent.subscribe",p.i.subscribe),p.b("bindingEvent.startPossiblyAsyncContentBinding",p.i.Cb),p.b("applyBindings",p.vc),p.b("applyBindingsToDescendants",p.Oa),p.b("applyBindingAccessorsToNode",p.ib),p.b("applyBindingsToNode",p.ld),p.b("contextFor",p.Dc),p.b("dataFor",p.Ec)}(),function(v){function I(V,k){var W=Object.prototype.hasOwnProperty.call(O,V)?O[V]:v,G;W?W.subscribe(k):(W=O[V]=new p.T,W.subscribe(k),m(V,function(K,q){var te=!(!q||!q.synchronous);M[V]={definition:K,Gd:te},delete O[V],G||te?W.notifySubscribers(K):p.na.zb(function(){W.notifySubscribers(K)})}),G=!0)}function m(V,k){D("getConfig",[V],function(W){W?D("loadComponent",[V,W],function(G){k(G,W)}):k(null,null)})}function D(V,k,W,G){G||(G=p.j.loaders.slice(0));var K=G.shift();if(K){var q=K[V];if(q){var te=!1;if(q.apply(K,k.concat(function(X){te?W(null):X!==null?W(X):D(V,k,W,G)}))!==v&&(te=!0,!K.suppressLoaderExceptions))throw Error("Component loader
* @ license
* Knockout ES5 plugin - https : //github.com/SteveSanderson/knockout-es5
* Copyright ( c ) Steve Sanderson
* MIT license
* /var jL="__knockoutObservables",qL="__knockoutSubscribable";function RJ(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=NJ(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(o){if(!(o===jL||o===qL)&&!(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&&iKe(n,a)}}),e}function NJ(e,t){var n=e[jL];return!n&&t&&(n={},Object.defineProperty(e,jL,{value:n})),n}function nKe(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),RJ.call(i,e,[t]),e}function iKe(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=oKe(e,t,i))})}function oKe(e,t,n){var i=rKe(e,n);return i.subscribe(t)}function rKe(e,t){var n=t[qL];if(!n){n=new e.subscribable,Object.defineProperty(t,qL,{value:n});var i={};sKe(t,n,i),aKe(e,t,n,i)}return n}function sKe(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 aKe(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 MJ(e,t){if(!e)return null;var n=NJ(e,!1);return n&&n[t]||null}function cKe(e,t){var n=MJ(e,t);n&&n.valueHasMutated()}function lKe(e){e.track=RJ,e.getObservable=MJ,e.valueHasMutated=cKe,e.defineProperty=nKe}const uKe={attachToKo:lKe},L4="http:/ / www . w3 . org / 2000 / svg ",B4=" cesium - svgPath - svg ",fKe={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){const i=document.createElementNS(L4," svg : svg ");i.setAttribute(" class ",B4);const o=document.createElementNS(L4," path ");return i.appendChild(o),e.virtualElements.setDomNodeChildren(t,[i]),e.computed({read:function(){const r=e.unwrap(n());o.setAttribute(" d ",e.unwrap(r.path));const 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 " , ` ${ B4 } ${ e . unwrap ( r . css ) } ` ) } , disposeWhenNodeIsRemoved : t } ) , { controlsDescendantBindings : ! 0 } } } , e . virtualElements . allowedBindings . cesiumSvgPath = ! 0 } } , dKe = fKe ; uKe . attachToKo ( et ) ; dKe . register ( et ) ; function DT ( e ) { l ( e ) || ( e = new qC ) , this . _clock = e , this . _eventHelper = new rf , this . _eventHelper . add ( e . onTick , this . synchronize , this ) , this . systemTime = et . observable ( ne . now ( ) ) , this . systemTime . equalityComparer = ne . equals , this . startTime = et . observable ( e . startTime ) , this . startTime . equalityComparer = ne . equals , this . startTime . subscribe ( function ( t ) { e . startTime = t , this . synchronize ( ) } , this ) , this . stopTime = et . observable ( e . stopTime ) , this . stopTime . equalityComparer = ne . equals , this . stopTime . subscribe ( function ( t ) { e . stopTime = t , this . synchronize ( ) } , this ) , this . currentTime = et . observable ( e . currentTime ) , this . currentTime . equalityComparer = ne . equals , this . currentTime . subscribe ( function ( t ) { e . currentTime = t , this . synchronize ( ) } , this ) , this . multiplier = et . observable ( e . multiplier ) , this . multiplier . subscribe ( function ( t ) { e . multiplier = t , this . synchronize ( ) } , this ) , this . clockStep = et . observable ( e . clockStep ) , this . clockStep . subscribe ( function ( t ) { e . clockStep = t , this . synchronize ( ) } , this ) , this . clockRange = et . observable ( e . clockRange ) , this . clockRange . subscribe ( function ( t ) { e . clockRange = t , this . synchronize ( ) } , this ) , this . canAnimate = et . observable ( e . canAnimate ) , this . canAnimate . subscribe ( function ( t ) { e . canAnimate = t , th
$ { p } ` :l(g)?g:p}),this.buttonImageUrl=void 0,et.defineProperty(this,"buttonImageUrl",function(){const h=this.selectedImagery;if(l(h))return h.iconUrl}),this.selectedImagery=void 0;const c=et.observable();this._currentImageryProviders=[],et.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(h){if(c()===h){this.dropDownVisible=!1;return}let _;const g=this._currentImageryProviders,p=g.length,A=this._globe.imageryLayers;let C=!1;for(_=0;_<p;_++){const b=A.length;for(let x=0;x<b;x++){const w=A.get(x);if(w.imageryProvider===g[_]){A.remove(w),C=!0;break}}}if(l(h)){const b=h.creationCommand();if(Array.isArray(b)){const x=b.length;for(_=x-1;_>=0;_--)A.addImageryProvider(b[_],0);this._currentImageryProviders=b.slice(0)}else if(this._currentImageryProviders=[b],C)A.addImageryProvider(b,0);else{const x=A.get(0);l(x)&&A.remove(x),A.addImageryProvider(b,0)}}c(h),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;const u=et.observable();et.defineProperty(this,"selectedTerrain",{get:function(){return u()},set:function(h){if(u()===h){this.dropDownVisible=!1;return}let _;l(h)&&(_=h.creationCommand()),this._globe.depthTestAgainstTerrain=!(_ instanceof op),this._globe.terrainProvider=_,u(h),this.dropDownVisible=!1}});const f=this;this._toggleDropDown=Vo(function(){f.dropDownVisible=!f.dropDownVisible}),this.selectedImagery=y(e.selectedImageryProviderViewModel,n[0]),this.selectedTerrain=y(e.selectedTerrainProviderViewModel,i[0])}Object.defineProperties(UJ.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});function mv(e,t){if(!l(e))throw new E("container is required.");e=er(e);const n=new UJ(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);const 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);const r=document.createElement("div");r.className="cesium-baseLayerPicker-dropDown",r.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-dropDown-visible" : dropDownVisible }'),e.appendChild(r);const s=document.createElement("div");s.className="cesium-baseLayerPicker-sectionTitle",s.setAttribute("data-bind","visible: imageryProviderViewModels.length > 0"),s.innerHTML="Imagery",r.appendChild(s);const a=document.createElement("div");a.className="cesium-baseLayerPicker-section",a.setAttribute("data-bind","foreach: _imageryProviders"),r.appendChild(a);const c=document.createElement("div");c.className="cesium-baseLayerPicker-category",a.appendChild(c);const u=document.createElement("div");u.className="cesium-baseLayerPicker-categoryTitle",u.setAttribute("data-bind","text: name"),c.appendChild(u);const f=document.createElement("div");f.className="cesium-baseLayerPicker-choices",f.setAttribute("data-bind","foreach: providers"),c.appendChild(f);const h=document.createElement("div");h.className="cesium-baseLayerPicker-item",h.setAttribute("data-bind",'css: { "cesium-baseLayerPicker-selectedItem" : $ data === $ parents[1].selectedImagery },attr: { title: tooltip },visible: creationCommand.canExecute,click: function( $ data) { $ parents[1].selectedImagery = $ data; }'),f.appendChild(h);const _=document.createElement("img");_.className="cesium-baseLayerPicker-itemIcon",_.setAttribute("data-bind","attr: { src: iconUrl }"),_.setAttribute("draggable","false"),h.appendChild(_);const g=document.createElement("div");g.className="cesium-baseLayerPicker-itemLabel",g.setAttribute("data-bind","text: name"),h.appendChild(g);const p=document.createElement("div");p.className="cesium-baseLayerPicker-sectionTitle",p.setAttribute("data-bind","visible: terrainProviderViewModels.length > 0"),p.innerHTML="Terrain",r.appendChild(p);const A=document.createElement("div");A.className="cesium-baseLayerPicker-section",A.setAttribute("data-bind","foreach: _terrainProviders"),r
http : //www.esri.com`,category:"Other",creationFunction:function(){return new bh({url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",enablePickFeatures:!1})}})),e.push(new Ts({name:"ESRI World Street Map",iconUrl:ln("Widgets/Images/ImageryProviders/esriWorldStreetMap.png"),tooltip:`This worldwide street map presents highway-level data for the world. Street-level data includes the United States; much of Canada; Japan; most countries in Europe; Australia and New Zealand; India; parts of South America including Argentina, Brazil, Chile, Colombia, and Venezuela; Ghana; and parts of southern Africa including Botswana, Lesotho, Namibia, South Africa, and Swaziland.
http : //www.esri.com`,category:"Other",creationFunction:function(){return new bh({url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",enablePickFeatures:!1})}})),e.push(new Ts({name:"ESRI National Geographic",iconUrl:ln("Widgets/Images/ImageryProviders/esriNationalGeographic.png"),tooltip:`This web map contains the National Geographic World Map service. This map service is designed to be used as a general reference map for informational and educational purposes as well as a basemap by GIS professionals and other users for creating web maps and web mapping applications.
http : //www.esri.com`,category:"Other",creationFunction:function(){return new bh({url:"https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/",enablePickFeatures:!1})}})),e.push(new Ts({name:"Open Street Map",iconUrl:ln("Widgets/Images/ImageryProviders/openStreetMap.png"),tooltip:`OpenStreetMap (OSM) is a collaborative project to create a free editable map of the world.
http : //www.openstreetmap.org`,category:"Other",creationFunction:function(){return new Xg({url:"https://a.tile.openstreetmap.org/"})}})),e.push(new Ts({name:"Stamen Watercolor",iconUrl:ln("Widgets/Images/ImageryProviders/stamenWatercolor.png"),tooltip:`Reminiscent of hand drawn maps, Stamen watercolor maps apply raster effect area washes and organic edges over a paper texture to add warm pop to any map.
http : //maps.stamen.com`,category:"Other",creationFunction:function(){return new Xg({url:"https://stamen-tiles.a.ssl.fastly.net/watercolor/",credit:"Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA."})}})),e.push(new Ts({name:"Stamen Toner",iconUrl:ln("Widgets/Images/ImageryProviders/stamenToner.png"),tooltip:`A high contrast black and white map.
http : //maps.stamen.com`,category:"Other",creationFunction:function(){return new Xg({url:"https://stamen-tiles.a.ssl.fastly.net/toner/",credit:"Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA."})}})),e.push(new Ts({name:"Sentinel-2",iconUrl:ln("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 new wl({assetId:3954})}})),e.push(new Ts({name:"Blue Marble",iconUrl:ln("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return new wl({assetId:3845})}})),e.push(new Ts({name:"Earth at night",iconUrl:ln("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 new wl({assetId:3812})}})),e.push(new Ts({name:"Natural Earth II",iconUrl:ln("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.
http : //www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return new Nf({url:ln("Assets/Textures/NaturalEarthII")})}})),e}function bKe(){const e=[];return e.push(new Ts({name:"WGS84 Ellipsoid",iconUrl:ln("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new op}})),e.push(new Ts({name:"Cesium World Terrain",iconUrl:ln("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 mYe({requestWaterMask:!0,requestVertexNormals:!0})}})),e}function _v(e,t){l(t)||(t=document.body),t=er(t);const n=this,i=et.observable(zr.fullscreen),o=et.observable(zr.enabled),r=t.ownerDocument;this.isFullscreen=void 0,et.defineProperty(this,"isFullscreen",{get:function(){return i()}}),this.isFullscreenEnabled=void 0,et.defineProperty(this,"isFullscreenEnabled",{get:function(){return o()},set:function(s){o(s&&zr.enabled)}}),this.tooltip=void 0,et.defineProperty(this,"tooltip",function(){return this.isFullscreenEnabled?i()?"Exit full screen":"Full screen":"Full screen unavailable"}),this._command=Vo(function(){zr.fullscreen?zr.exitFullscreen():zr.requestFullscreen(n._fullscreenElement)},et.getObservable(this,"isFullscreenEnabled")),this._fullscreenElement=y(er(e),r.body),this._callback=function(){i(zr.fullscreen)},r.addEventListener(zr.changeEventName,this._callback)}Object.defineProperties(_v.prototype,{fullscreenElement:{get:function(){return this._fullscreenElement},set:function(e){if(!(e instanceof Element))throw new E("value must be a valid Element.");this._fullscreenElement=e}},command:{get:function(){return this._command}}});_v.prototype.isDestroyed=function(){return!1};_v.prototype.destroy=function(){document.removeEventListener(zr.changeEventName,this._callback),Ue(this)};const EKe="M 83.96875 17.5625 L 83.96875 17.59375 L 76.65625 24.875 L 97.09375 24.96875 L 76.09375 45.96875 L 81.9375 51.8125 L 102.78125 30.9375 L 102.875 51.15625 L 110.15625 43.875 L 110.1875 17.59375 L 83.96875 17.5625 z M 44.125 17.59375 L 17.90625 17.625 L 17.9375 43.90625 L 25.21875 51.1875 L 25.3125 30.96875 L 46.15625 51.8125 L 52 45.96875 L 31 25 L 51.4375 24.90625 L 44.125 17.59375 z M 46.0625 76.03125 L 25.1875 96.875 L 25.09375 76.65625 L 17.8125 83.9375 L 17.8125 110.21875 L 44 110.25 L 51.3125 102.9375 L 30.90625 102.84375 L 51.875 81.875 L 46.0625 76.03125 z M 82 76.15625 L 76.15625 82 L 97.15625 103 L 76.71875 103.0625 L 84.03125 110.375 L 110.25 110.34375 L 110.21875 84.0625 L 102.9375 76.8125 L 102.84375 97 L 82 76.15625 z",xKe="M 104.34375 17.5625 L 83.5 38.4375 L 83.40625 18.21875 L 76.125 25.5 L 76.09375 51.78125 L 102.3125 51.8125 L 102.3125 51.78125 L 109.625 44.5 L 89.1875 44.40625 L 110.1875 23.40625 L 104.34375 17.5625 z M 23.75 17.59375 L 17.90625 23.4375 L 38.90625 44.4375 L 18.5 44.53125 L 25.78125 51.8125 L 52 51.78125 L 51.96875 25.53125 L 44.6875 18.25 L 44.625 38.46875 L 23.75 17.59375 z M 25.6875 76.03125 L 18.375 83.3125 L 38.78125 83.40625 L 17.8125 104.40625 L 23.625 110.25 L 44.5 89.375 L 44.59375 109.59375 L 51.875 102.3125 L 51.875 76.0625 L 25.6875 76.03125 z M 102.375 76.15625 L 76.15625 76.1875 L 76.1875 102.4375 L 83.46875 109.71875 L 83.5625 89.53125 L 104.40625 110.375 L 110.25 104.53125 L 89.25 83.53125 L 109.6875 83.46875 L 102.375 76.15625 z";function gv(e,t){if(!l(e))throw new E("container is required.");e=er(e);const n=new _v(t,e);n._exitFullScreenPath=xKe,n._enterFullScreenPath=EKe;const i=document.createElement("button");i.type="button",i.className="cesium-button cesium-fullscreenButton",i.setAttribute("data-bind","attr: { title: tooltip },click: command,enable: isFullscreenEnabled,cesiumSvgPath: { path: isFullscreen ? _exitFullScreenPath : _enterFullScreenPath, width: 128, height: 128 }"),e.appendChild(i),et.applyBindings(n,i),this._container=e,this._viewModel=n,this._element=i}Object.defineProperties(gv.prototype,{con
NoSleep enabled for older iOS devices . This can interrupt
active or long - running network requests from completing successfully .
See https : //github.com/richtr/NoSleep.js/issues/15 for more details.
` ),this.noSleepTimer=window.setInterval(()=>{document.hidden||(window.location.href=window.location.href.split("#")[0],window.setTimeout(window.stop,0))},15e3),this.enabled=!0,Promise.resolve()):this.noSleepVideo.play().then(n=>(this.enabled=!0,n)).catch(n=>{throw this.enabled=!1,n})}disable(){vO()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):SO()?this.noSleepTimer&&(console.warn( `
NoSleep now disabled for older iOS devices .
` ),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}var eJe=ZKe;function tJe(e){let t=!1;const n=window.screen;return l(n)&&(l(n.lockOrientation)?t=n.lockOrientation(e):l(n.mozLockOrientation)?t=n.mozLockOrientation(e):l(n.msLockOrientation)?t=n.msLockOrientation(e):l(n.orientation&&n.orientation.lock)&&(t=n.orientation.lock(e))),t}function jJ(){const e=window.screen;l(e)&&(l(e.unlockOrientation)?e.unlockOrientation():l(e.mozUnlockOrientation)?e.mozUnlockOrientation():l(e.msUnlockOrientation)?e.msUnlockOrientation():l(e.orientation&&e.orientation.unlock)&&e.orientation.unlock())}function nJe(e,t,n,i){i()||(n()?(t.useWebVR=!1,e._locked&&(jJ(),e._locked=!1),e._noSleep.disable(),zr.exitFullscreen(),n(!1)):(zr.fullscreen||zr.requestFullscreen(e._vrElement),e._noSleep.enable(),e._locked||(e._locked=tJe("landscape")),t.useWebVR=!0,n(!0)))}function vv(e,t){if(!l(e))throw new E("scene is required.");const n=this,i=et.observable(zr.enabled),o=et.observable(!1);this.isVRMode=void 0,et.defineProperty(this,"isVRMode",{get:function(){return o()}}),this.isVREnabled=void 0,et.defineProperty(this,"isVREnabled",{get:function(){return i()},set:function(s){i(s&&zr.enabled)}}),this.tooltip=void 0,et.defineProperty(this,"tooltip",function(){return i()?o()?"Exit VR mode":"Enter VR mode":"VR mode is unavailable"});const r=et.observable(!1);this._isOrthographic=void 0,et.defineProperty(this,"_isOrthographic",{get:function(){return r()}}),this._eventHelper=new rf,this._eventHelper.add(e.preRender,function(){r(e.camera.frustum instanceof Mt)}),this._locked=!1,this._noSleep=new eJe,this._command=Vo(function(){nJe(n,e,o,r)},et.getObservable(this,"isVREnabled")),this._vrElement=y(er(t),document.body),this._callback=function(){!zr.fullscreen&&o()&&(e.useWebVR=!1,n._locked&&(jJ(),n._locked=!1),n._noSleep.disable(),o(!1))},document.addEventListener(zr.changeEventName,this._callback)}Object.defineProperties(vv.prototype,{vrElement:{get:function(){return this._vrElement},set:function(e){if(!(e instanceof Element))throw new E("value must be a valid Element.");this._vrElement=e}},command:{get:function(){return this._command}}});vv.prototype.isDestroyed=function(){return!1};vv.prototype.destroy=function(){this._eventHelper.removeAll(),document.removeEventListener(zr.changeEventName,this._callback),Ue(this)};const iJe="M 5.3125 6.375 C 4.008126 6.375 2.96875 7.4141499 2.96875 8.71875 L 2.96875 19.5 C 2.96875 20.8043 4.008126 21.875 5.3125 21.875 L 13.65625 21.875 C 13.71832 20.0547 14.845166 18.59375 16.21875 18.59375 C 17.592088 18.59375 18.71881 20.0552 18.78125 21.875 L 27.09375 21.875 C 28.398125 21.875 29.4375 20.8043 29.4375 19.5 L 29.4375 8.71875 C 29.4375 7.4141499 28.398125 6.375 27.09375 6.375 L 5.3125 6.375 z M 9.625 10.4375 C 11.55989 10.4375 13.125 12.03385 13.125 13.96875 C 13.125 15.90365 11.55989 17.46875 9.625 17.46875 C 7.69011 17.46875 6.125 15.90365 6.125 13.96875 C 6.125 12.03385 7.69011 10.4375 9.625 10.4375 z M 22.46875 10.4375 C 24.40364 10.4375 25.96875 12.03385 25.96875 13.96875 C 25.96875 15.90365 24.40364 17.46875 22.46875 17.46875 C 20.53386 17.46875 18.96875 15.90365 18.96875 13.96875 C 18.96875 12.03385 20.53386 10.4375 22.46875 10.4375 z",oJe="M 25.770585,2.4552065 C 15.72282,13.962707 10.699956,19.704407 8.1768352,22.580207 c -1.261561,1.4379 -1.902282,2.1427 -2.21875,2.5 -0.141624,0.1599 -0.208984,0.2355 -0.25,0.2813 l 0.6875,0.75 c 10e-5,-10e-5 0.679191,0.727 0.6875,0.7187 0.01662,-0.016 0.02451,-0.024 0.03125,-0.031 0.01348,-0.014 0.04013,-0.038 0.0625,-0.062 0.04474,-0.05 0.120921,-0.1315 0.28125,-0.3126 0.320657,-0.3619 0.956139,-1.0921 2.2187499,-2.5312 2.5252219,-2.8781 7.5454589,-8.6169 17.5937499,-20.1250005 l -1.5,-1.3125 z m -20.5624998,3.9063 c -1.304375,0 -2.34375,1.0391 -2.34375,2.3437 l 0,10.8125005 c 0,1.3043 1.039375,2.375 2.34375,2.375 l 2.25,0 c 1.9518039,-2.2246 7.4710958,-8.5584 13.5624998,-15.5312005 l -15.8124998,0 z m 21.1249998,0 c -1.855467,2.1245 -2.114296,2.4005 -3.59375,4.0936995 1.767282,0.1815 3.15625,1.685301 3.15625,3.500001 0,
` ).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),i=s.substring(o+1).trim(),!(!n||t[n]&&RZe[n])&&(n==="set-cookie"?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)}),t},tG=Symbol("internals");function q0(e){return e&&String(e).trim().toLowerCase()}function Ux(e){return e===!1||e==null?e:We.isArray(e)?e.map(Ux):String(e)}function MZe(e){const t=Object.create(null),n=/([^ \s ,;=]+) \s *(?:= \s *([^,;]+))?/g;let i;for(;i=n.exec(e);)t[i[1]]=i[2];return t}function FZe(e){return/^[-_a-zA-Z]+ $ /.test(e.trim())}function nG(e,t,n,i){if(We.isFunction(i))return i.call(this,t,n);if(We.isString(t)){if(We.isString(i))return t.indexOf(i)!==-1;if(We.isRegExp(i))return i.test(t)}}function zZe(e){return e.trim().toLowerCase().replace(/([a-z \d ])( \w *)/g,(t,n,i)=>n.toUpperCase()+i)}function UZe(e,t){const n=We.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(e,i+n,{value:function(o,r,s){return this[i].call(this,t,o,r,s)},configurable:!0})})}class Bv{constructor(t){t&&this.set(t)}set(t,n,i){const o=this;function r(a,c,u){const f=q0(c);if(!f)throw new Error("header name must be a non-empty string");const h=We.findKey(o,f);(!h||o[h]===void 0||u===!0||u===void 0&&o[h]!==!1)&&(o[h||c]=Ux(a))}const s=(a,c)=>We.forEach(a,(u,f)=>r(u,f,c));return We.isPlainObject(t)||t instanceof this.constructor?s(t,n):We.isString(t)&&(t=t.trim())&&!FZe(t)?s(NZe(t),n):t!=null&&r(n,t,i),this}get(t,n){if(t=q0(t),t){const i=We.findKey(this,t);if(i){const o=this[i];if(!n)return o;if(n===!0)return MZe(o);if(We.isFunction(n))return n.call(this,o,i);if(We.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=q0(t),t){const i=We.findKey(this,t);return!!(i&&(!n||nG(this,this[i],i,n)))}return!1}delete(t,n){const i=this;let o=!1;function r(s){if(s=q0(s),s){const a=We.findKey(i,s);a&&(!n||nG(i,i[a],a,n))&&(delete i[a],o=!0)}}return We.isArray(t)?t.forEach(r):r(t),o}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(t){const n=this,i={};return We.forEach(this,(o,r)=>{const s=We.findKey(i,r);if(s){n[s]=Ux(o),delete n[r];return}const a=t?zZe(r):String(r).trim();a!==r&&delete n[r],n[a]=Ux(o),i[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return We.forEach(this,(i,o)=>{i!=null&&i!==!1&&(n[o]=t&&We.isArray(i)?i.join(", "):i)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join( `
` )}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const i=new this(t);return n.forEach(o=>i.set(o)),i}static accessor(t){const i=(this[tG]=this[tG]={accessors:{}}).accessors,o=this.prototype;function r(s){const a=q0(s);i[a]||(UZe(o,s),i[a]=!0)}return We.isArray(t)?t.forEach(r):r(t),this}}Bv.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]);We.freezeMethods(Bv.prototype);We.freezeMethods(Bv);const qf=Bv;function DO(e,t){const n=this||gM,i=t||n,o=qf.from(i.headers);let r=i.data;return We.forEach(e,function(a){r=a.call(n,r,o.normalize(),t?t.status:void 0)}),o.normalize(),r}function EQ(e){return!!(e&&e.__CANCEL__)}function BT(e,t,n){fi.call(this,e??"canceled",fi.ERR_CANCELED,t,n),this.name="CanceledError"}We.inherits(BT,fi,{__CANCEL__:!0});const HZe=null;function VZe(e,t,n){const i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):t(new fi("Request failed with status code "+n.status,[fi.ERR_BAD_REQUEST,fi.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const kZe=bu.isStandardBrowserEnv?function(){return{write:function(n,i,o,r,s,a){const c=[];c.push(n+"="+encodeURIComponent(i)),We.isNumber(o)&&c.push("expires="+new Date(o).toGMTString()),We.isString(r)&&c.push("path="+r),We.isString(s)&&c.push("domain="+s),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(n){const i=document.cookie.match(new RegExp("(^|; \\ s*)("+n+")=([^;]*)"));return i?decodeURIComponent(i[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function GZe(e){return/^([a-z][a-z \d + \- .]*:)? \/ \/ /i.test(e)}function WZe(e,t){return t?e.replace(/ \/ + $ /,"")+"/"+t.replace(/^ \/ +/,""):e}function xQ(e,t){return e&&!GZe(t)?WZe(e,t):t}const jZe=bu.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let i;function o(r){let s=r;return t&&(n.setAttribute("href",s),s=n.href),n.setAttribute("href",s),{href:n.href,protocol:n.protocol?n.protocol.replace(/: $ /,""):"",host:n.host,search:n.search?n.search.replace(/^ \? /,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return i=o(window.location.href),function(s){const a=We.isString(s)?o(s):s;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}();function qZe(e){const t=/^([-+ \w ]{1,25})(:? \/ \/ |:)/.exec(e);return t&&t[1]||""}function YZe(e,t){e=e||10;const n=new Array(e),i=new Array(e);let o=0,r=0,s;return t=t!==void 0?t:1e3,function(c){const u=Date.now(),f=i[r];s||(s=u),n[o]=c,i[o]=u;let h=r,_=0;for(;h!==o;)_+=n[h++],h=h%e;if(o=(o+1)%e,o===r&&(r=(r+1)%e),u-s<t)return;const g=f&&u-f;return g?Math.round(_*1e3/g):void 0}}function iG(e,t){let n=0;const i=YZe(50,250);return o=>{const r=o.loaded,s=o.lengthComputable?o.total:void 0,a=r-n,c=i(a),u=r<=s;n=r;const f={loaded:r,total:s,progress:s?r/s:void 0,bytes:a,rate:c||void 0,estimated:c&&s&&u?(s-r)/c:void 0,event:o};f[t?"download":"upload"]=!0,e(f)}}const XZe=typeof XMLHttpRequest<"u", $ Ze=XZe&&function(e){return new Promise(function(n,i){let o=e.data;const r=qf.from(e.headers).normalize(),s=e.responseType;let a;function c(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}We.isFormData(o)&&(bu.isStandardBrowserEnv||bu.isStandardBrowserWebWorkerEnv)&&r.setContentType(!1);let u=new XMLHttpRequest;if(e.auth){const g=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";r.set("Authorization","Basic "+btoa(g+":"+p))}const f=xQ(e.baseURL,e.url);u.open(e.method.toUpperCase(),CQ(f,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function h(){if(!u)return;const g=qf.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),A={data:!s||s==="text"||s==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:g,config:e,request:u};VZe(function(b){n(b),c
* satellite - js v4 . 1.4
* ( c ) 2013 Shashwat Kandadai and UCSC
* https : //github.com/shashwatak/satellite-js
* License : MIT
* / v a r i d = M a t h . P I , j o = i d * 2 , p A = i d / 1 8 0 , s e t = 1 4 4 0 , a e t = 3 9 8 6 0 0 . 5 , R a = 6 3 7 8 . 1 3 7 , L f = 6 0 / M a t h . s q r t ( R a * R a * R a / a e t ) , P O = R a * L f / 6 0 , c e t = 1 / L f , u m = . 0 0 1 0 8 2 6 2 9 9 8 9 0 5 , u e t = - 2 5 3 2 1 5 3 0 6 e - 1 4 , f e t = - 1 6 1 0 9 8 7 6 1 e - 1 4 , f m = u e t / u m , M C = 2 / 3 ; f u n c t i o n d e t ( e , t ) { f o r ( v a r n = [ 3 1 , e % 4 = = = 0 ? 2 9 : 2 8 , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 , 3 1 , 3 0 , 3 1 , 3 0 , 3 1 ] , i = M a t h . f l o o r ( t ) , o = 1 , r = 0 ; i > r + n [ o - 1 ] & & o < 1 2 ; ) r + = n [ o - 1 ] , o + = 1 ; v a r s = o , a = i - r , c = ( t - i ) * 2 4 , u = M a t h . f l o o r ( c ) ; c = ( c - u ) * 6 0 ; v a r f = M a t h . f l o o r ( c ) , h = ( c - f ) * 6 0 ; r e t u r n { m o n : s , d a y : a , h r : u , m i n u t e : f , s e c : h } } f u n c t i o n a G ( e , t , n , i , o , r ) { v a r s = a r g u m e n t s . l e n g t h > 6 & & a r g u m e n t s [ 6 ] ! = = v o i d 0 ? a r g u m e n t s [ 6 ] : 0 ; r e t u r n 3 6 7 * e - M a t h . f l o o r ( 7 * ( e + M a t h . f l o o r ( ( t + 9 ) / 1 2 ) ) * . 2 5 ) + M a t h . f l o o r ( 2 7 5 * t / 9 ) + n + 1 7 2 1 0 1 3 5 e - 1 + ( ( s / 6 e 4 + r / 6 0 + o ) / 6 0 + i ) / 2 4 } f u n c t i o n C M ( e , t , n , i , o , r , s ) { i f ( e i n s t a n c e o f D a t e ) { v a r a = e ; r e t u r n a G ( a . g e t U T C F u l l Y e a r ( ) , a . g e t U T C M o n t h ( ) + 1 , a . g e t U T C D a t e ( ) , a . g e t U T C H o u r s ( ) , a . g e t U T C M i n u t e s ( ) , a . g e t U T C S e c o n d s ( ) , a . g e t U T C M i l l i s e c o n d s ( ) ) } r e t u r n a G ( e , t , n , i , o , r , s ) } f u n c t i o n v Q ( e , t ) { v a r n = e . e 3 , i = e . e e 2 , o = e . p e o , r = e . p g h o , s = e . p h o , a = e . p i n c o , c = e . p l o , u = e . s e 2 , f = e . s e 3 , h = e . s g h 2 , _ = e . s g h 3 , g = e . s g h 4 , p = e . s h 2 , A = e . s h 3 , C = e . s i 2 , b = e . s i 3 , x = e . s l 2 , w = e . s l 3 , S = e . s l 4 , P = e . t , L = e . x g h 2 , H = e . x g h 3 , R = e . x g h 4 , z = e . x h 2 , U = e . x h 3 , v = e . x i 2 , I = e . x i 3 , m = e . x l 2 , D = e . x l 3 , O = e . x l 4 , M = e . z m o l , V = e . z m o s , k = t . i n i t , W = t . o p s m o d e , G = t . e p , K = t . i n c l p , q = t . n o d e p , t e = t . a r g p p , X = t . m p , $ , Y , a e , u e , r e , h e , c e , Q , i e , d e , m e , E e , x e , P e , T e , O e , D e , M e , v e , I e , V e , L e = 1 1 9 4 5 9 e - 1 0 , m t = . 0 1 6 7 5 , C t = . 0 0 0 1 5 8 3 5 2 1 8 , P t = . 0 5 4 9 ; V e = V + L e * P , k = = = " y " & & ( V e = V ) , I e = V e + 2 * m t * M a t h . s i n ( V e ) , D e = M a t h . s i n ( I e ) , d e = . 5 * D e * D e - . 2 5 , m e = - . 5 * D e * M a t h . c o s ( I e ) ; v a r y n = u * d e + f * m e , x n = C * d e + b * m e , p n = x * d e + w * m e + S * D e , e n = h * d e + _ * m e + g * D e , R t = p * d e + A * m e ; V e = M + C t * P , k = = = " y " & & ( V e = M ) , I e = V e + 2 * P t * M a t h . s i n ( V e ) , D e = M a t h . s i n ( I e ) , d e = . 5 * D e * D e - . 2 5 , m e = - . 5 * D e * M a t h . c o s ( I e ) ; v a r m n = i * d e + n * m e , g n = v * d e + I * m e , U t = m * d e + D * m e + O * D e , Y t = L * d e + H * m e + R * D e , R n = z * d e + U * m e ; r e t u r n E e = y n + m n , T e = x n + g n , O e = p n + U t , x e = e n + Y t , P e = R t + R n , k = = = " n " & & ( E e - = o , T e - = a , O e - = c , x e - = r , P e - = s , K + = T e , G + = E e , u e = M a t h . s i n ( K ) , a e = M a t h . c o s ( K ) , K > = . 2 ? ( P e / = u e , x e - = a e * P e , t e + = x e , q + = P e , X + = O e ) : ( h e = M a t h . s i n ( q ) , r e = M a t h . c o s ( q ) , $ = u e * h e , Y = u e * r e , c e = P e * r e + T e * a e * h e , Q = - P e * h e + T e * a e * r e , $ + = c e , Y + = Q , q % = j o , q < 0 & & W = = = " a " & & ( q + = j o ) , M e = X + t e + a e * q , i e = O e + x e - T e * q * u e , M e + = i e , v e = q , q = M a t h . a t a n 2 ( $ , Y ) , q < 0 & & W = = = " a " & & ( q + = j o ) , M a t h . a b s ( v e - q ) > i d & & ( q < v e ? q + = j o : q - = j o ) , X + = O e , t e = M e - X - a e * q ) ) , { e p : G , i n c l p : K , n o d e p : q , a r g p p : t e , m p : X } } f u n c t i o n h e t ( e ) { v a r t = e . e p o c h , n = e . e p , i = e . a r g p p , o = e . t c , r = e . i n c l p , s = e . n o d e p , a = e . n p , c , u , f , h , _ , g , p , A , C , b , x , w , S , P , L , H , R , z , U , v , I , m , D , O , M , V , k , W , G , K , q , t e , X , $ , Y , a e , u e , r e , h e , c e , Q , i e , d e , m e , E e , x e , P e , T e , O e , D e , M e , v e , I e , V e , L e , m t , C t , P t , y n , x n , p n , e n , R t , m n = . 0 1 6 7 5 , g n = . 0 5 4 9 , U t = 2 9 8 6 4 7 9 7 e - 1 3 , Y t = 4 7 9 6 8 0 6 5 e - 1 4 , R n = . 3 9 7 8 5 4 1 6 , Z n = . 9 1 7 4 4 8 6 7 , J t = . 1 9 4 5 9 0 5 , T i = - . 9 8 0 8 8 4 5 8 , V i = a , v i = n , $ n = M a t h . s i n ( s ) , r n = M a t h . c o s ( s ) , U n = M a t h . s i n ( i ) , I n = M a t h . c o s ( i ) , t n = M a t h . s i n ( r ) , _ t = M a t h . c o s ( r ) , k e = v i * v i , w n = 1 - k e , f n = M a t h . s q r t ( w n ) , N i = 0 , S n = 0 , D i = 0 , p o = 0 , K i = 0 , A r = t + 1 8 2 6 1 . 5 + o / 1 4 4 0 , M i = ( 4 . 5 2 3 6 0 2 - . 0 0 0 9 2 4 2 2 0 2 9 * A r ) % j o , I i = M a t h . s i n ( M i ) , C r = M a t h . c o s ( M i ) , J s = . 9 1 3 7 5 1 6 4 - . 0 3 5 6 8 0 9 6 * C r , g t = M a t h . s q r t ( 1 - J s * J s ) , b e = . 0 8 9 6 8 3 5 1 1 * I i / g t , j e = M a t h . s q r t ( 1 - b e * b e ) , t t = 5 . 8 3 5 1 5 1 4 + . 0 0 1 9 4 4 3 6 8 * A r , H n = . 3 9 7 8 5 4 1 6 * I i / g t , B r = j e * C r + . 9 1 7 4 4 8 6 7 * b e * I i ; H n = M a t h . a t a n 2 ( H n , B r ) , H n + = t t - M i ; v a r r r = M a t h . c o s ( H n ) , J o = M a t h . s i n ( H n ) ; v = J t , I = T i , O = Z n , M = R n , m = r n , D = $ n , x = U t ; f o r ( v a r w d = 1 / V i , m o = 0 ; m o < 2 ; ) m o + = 1 , c = v * m + I * O * D , f = - I * m + v * O * D , p = - v * D + I * O * m , A = I * M , C = I * D + v * O * m , b = v * M , u = _ t * p + t n * A , h = _ t * C + t n * b , _ = - t n * p + _ t * A , g = - t n * C + _ t * b , w = c * I n + u * U n , S = f * I n + h * U n , P = - c * U n + u * I n , L = - f * U n + h * I n , H = _ * U n , R = g * U n , z = _ * I n , U = g * I n , p n = 1 2 * w * w - 3 * P * P , e n = 2 4 * w * S - 6 * P * L , R t = 1 2 * S * S - 3 * L * L , v e = 3 * ( c * c + u * u ) + p n * k e , I e = 6 * ( c * f + u * h ) + e n * k e , V e = 3 * ( f * f + h * h ) + R t * k e , L e = - 6 * c * _ + k e * ( - 2 4 * w * z - 6 * P * H ) , m t = - 6 * ( c * g + f * _ ) + k e * ( - 2 4 * ( S * z + w * U ) + - 6 * ( P * R + L * H ) ) , C t = - 6 * f * g + k e * ( - 2 4 * S * U - 6 * L * R ) , P t = 6 * u * _ + k e * ( 2 4 * w * H - 6 * P * z ) , y n = 6 * ( h * _ + u * g ) + k e * ( 2 4 * ( S * H + w * R ) - 6 * ( L * z + P * U ) ) , x n = 6 * h * g + k e * ( 2 4 * S * R - 6 * L * U ) , v e = v e + v e + w n * p n , I e = I e + I e + w n * e n , V e = V e + V e + w n * R t , P e = x * w d , x e = - . 5 * P e / f n , T e = P e * f n , E e = - 1 5 * v i * T e , O e = w * P + S * L , D e = S * P + w * L , M e = S * L - w * P , m o = = = 1 & & ( V = E e , k = x e , W = P e , G = T e , K = O e , q = D e , t e = M e , X = v e , $ = I e , Y = V e , a e = L e , u e = m t , r e = C t , h e = P t , c e = y n , Q = x n , i e = p n , d e = e n , m e = R t , v = r r , I = J o , O = J s , M = g t , m = j e * r n + b e * $ n , D = $ n * j e - r n * b e , x = Y t ) ; v a r a f = ( 4 . 7 1 9 9 6 7 2 + ( . 2 2 9 9 7 1 5 * A r - t t ) ) % j o , y _ = ( 6 . 2 5 6 5 8 3 7 + . 0 1 7 2 0 1 9 7 7 * A r ) % j o , R T = 2 * V * q , m p = 2 * V * t e , _ p = 2 * k * u e , R v = 2 * k * ( r e - a e ) , N v = - 2 * W * $ , M v = - 2 * W * ( Y - X ) , F v = - 2 * W * ( - 2 1 - 9 * k e ) * m n , A _ = 2 * G * d e , z v = 2 * G * ( m e - i e ) , U v = - 1 8 * G * m n , G y = - 2 * k * c e , N T = - 2 * k * ( Q - h e ) , W y = 2 * E e * D e , H v = 2 * E e
In order to be iterable , non - array objects must have a [ Symbol . iterator ] ( ) method . ` )}function wet(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var i=t[0],o=Array.prototype.slice.call(t,1),r=CM.apply(void 0,Cet(o)),s=(r-i.jdsatepoch)*set;return DQ(i,s)}class vet{constructor(t="",n={}){const[i,o,r]=this._checkTle(t);this.name=i,this.tleLine1=o.trim(),this.tleLine2=r.trim(),this.satrec=Aet(this.tleLine1,this.tleLine2),this.totalSeconds=864e3,this.stepSeconds=300,this.leadTime=5822,this.trailTime=0}_checkTle(t){let n=t.split( `
2023-02-01 02:54:58 +00:00
` );if(n.length!==3)throw new Error("tle data error");return n}getPositionEci(t){return wet(this.satrec,t).position}_getPositionProperty(){const t=ne.fromIso8601(new Date().toISOString()),n=new tc(Gs.INERTIAL);let i=Date.now();for(let o=0;o<this.totalSeconds/this.stepSeconds;o++){let r=new Date(i+o*this.stepSeconds*1e3),s=this.getPositionEci(r);const a=ne.addSeconds(t,o*this.stepSeconds,new ne),c={x:s.x*1e3,y:s.y*1e3,z:s.z*1e3};n.addSample(a,c)}return n}createSatelliteEntity(){const t=ne.fromIso8601(new Date().toISOString()),n=ne.addSeconds(t,this.totalSeconds,new ne);return{name:this.name,description:this.name,availability:new ho([new Kt({start:t,stop:n})]),position:this._getPositionProperty(),point:{pixelSize:6,color:F.RED},path:new fy({width:.5,show:!1,leadTime:this.leadTime,trailTime:this.trailTime,material:F.LIME})}}}const Det={id:"cesiumContainer"},Iet={__name:"SatelliteTrack",setup(e){console.log("production"),window.CESIUM_BASE_URL="/satellite-track/cesium";let t;const n=864e3;_m.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiYjZmMWM4Ny01YzQ4LTQ3MzUtYTI5Mi1hNTgyNjdhMmFiMmMiLCJpZCI6NjIwMjgsImlhdCI6MTYyNjY3MTMxNX0.5SelYUyzXWRoMyjjFvmFIAoPtWlJPQMjsVl2e_jQe-c";function i(){Ks.prototype.makeLabel=function(u){let f=0-new Date().getTimezoneOffset(),h=ne.addMinutes(u,f,new ne);return ne.toIso8601(h).slice(0,19)};let a=new Jm({mapId:"mapbox.satellite",accessToken:"pk.eyJ1Ijoiamlhbmd0ZW5nIiwiYSI6ImNqbGhhcDhzMjAxdncza294c2ZqcHFxNGIifQ.rjSmtZ5QzE2sJ-qDANh3WQ"});t=new qn("cesiumContainer",{imageryProvider:a,baseLayerPicker:!1,geocoder:!1,navigationHelpButton:!1,infoBox:!1});let c=0-new Date().getTimezoneOffset();t.animation.viewModel.timeFormatter=function(u,f){let h=ne.addMinutes(u,c,new ne);return ne.toIso8601(h).slice(11,19)},t.animation.viewModel.dateFormatter=function(u,f){let h=ne.addMinutes(u,c,new ne);return ne.toIso8601(h).slice(0,10)},ot.DEFAULT_VIEW_RECTANGLE=_e.fromDegrees(75,10,140,60)}function o(){const a=ne.fromIso8601(new Date().toISOString()),c=ne.addSeconds(a,n,new ne);t.clock.startTime=a.clone(),t.clock.stopTime=c.clone(),t.clock.currentTime=a.clone(),t.timeline.zoomTo(a,c),t.clock.multiplier=1,t.clock.shouldAnimate=!0,t.clock.clockRange=Eh.LOOP_STOP}function r(a=""){if(a.length===0)return;let c=a.split( ` \ r
2023-02-01 01:46:39 +00:00
` ),u=[],f=0,h=[];return c.forEach(_=>{f++,h.push(_),f===3&&(u.push(h.join( ` \ r
2023-02-01 02:29:19 +00:00
` )),h=[],f=0)}),u}function s(){let a=t.screenSpaceEventHandler.getInputAction(On.LEFT_CLICK);t.screenSpaceEventHandler.setInputAction(function(u){a(u)},On.LEFT_CLICK)}return zC(async()=>{i(),o(),s();let a=await ret();r(a).forEach(u=>{let f=new vet(u);t.entities.add(f.createSatelliteEntity())})}),(a,c)=>(Ur(),Ou("div",Det))}},Pet=mne({history:Lte("/satellite-track/"),routes:[{path:"/",name:"home",component:Iet}]});const TM=ute(Ane);TM.use(pte());TM.use(Pet);TM.mount("#app");