2023-02-13 02:05:23 +00:00
var Ine = ( e , t ) => ( ) => ( t || e ( ( t = { exports : { } } ) . exports , t ) , t . exports ) ; var Adt = Ine ( ( ld , ud ) => { ( 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 KR ( 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 Ta ( e ) { if ( qt ( e ) ) { const t = { } ; for ( let n = 0 ; n < e . length ; n ++ ) { const i = e [ n ] , o = vi ( i ) ? Bne ( i ) : Ta ( i ) ; if ( o ) for ( const r in o ) t [ r ] = o [ r ] } return t } else { if ( vi ( e ) ) return e ; if ( Fi ( e ) ) return e } } const Pne = /;(?![^(]*\))/g , One = /:([^]+)/ , Lne = / \ / \ * . * ? \ * \ / / g s ; f u n c t i o n B n e ( e ) { c o n s t t = { } ; r e t u r n e . r e p l a c e ( L n e , " " ) . s p l i t ( P n e ) . f o r E a c h ( n = > { i f ( n ) { c o n s t i = n . s p l i t ( O n e ) ; 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 y t ( e ) { l e t t = " " ; i f ( v i ( e ) ) t = e ; e l s e i f ( q t ( e ) ) f o r ( l e t n = 0 ; n < e . l e n g t h ; n + + ) { c o n s t i = y t ( e [ n ] ) ; i & & ( t + = i + " " ) } e l s e i f ( F i ( 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 R n e = " 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 " , N n e = K R ( R n e ) ; f u n c t i o n h 6 ( e ) { r e t u r n ! ! e | | e = = = " " } f u n c t i o n M n e ( e , t ) { i f ( e . l e n g t h ! = = t . l e n g t h ) r e t u r n ! 1 ; l e t n = ! 0 ; f o r ( l e t i = 0 ; n & & i < e . l e n g t h ; i + + ) n = x v ( e [ i ] , t [ i ] ) ; r e t u r n n } f u n c t i o n x v ( e , t ) { i f ( e = = = t ) r e t u r n ! 0 ; l e t n = B F ( e ) , i = B F ( t ) ; i f ( n | | i ) r e t u r n n & & i ? e . g e t T i m e ( ) = = = t . g e t T i m e ( ) : ! 1 ; i f ( n = $ b ( e ) , i = $ b ( t ) , n | | i ) r e t u r n e = = = t ; i f ( n = q t ( e ) , i = q t ( t ) , n | | i ) r e t u r n n & & i ? M n e ( e , t ) : ! 1 ; i f ( n = F i ( e ) , i = F i ( t ) , n | | i ) { i f ( ! n | | ! i ) r e t u r n ! 1 ; c o n s t o = O b j e c t . k e y s ( e ) . l e n g t h , r = O b j e c t . k e y s ( t ) . l e n g t h ; i f ( o ! = = r ) r e t u r n ! 1 ; f o r ( c o n s t s i n e ) { c o n s t a = e . h a s O w n P r o p e r t y ( s ) , c = t . h a s O w n P r o p e r t y ( s ) ; i f ( a & & ! c | | ! a & & c | | ! x v ( e [ s ] , t [ s ] ) ) r e t u r n ! 1 } } r e t u r n S t r i n g ( e ) = = = S t r i n g ( t ) } f u n c t i o n p 6 ( e , t ) { r e t u r n e . f i n d I n d e x ( n = > x v ( n , t ) ) } c o n s t v a = e = > v i ( e ) ? e : e = = n u l l ? " " : q t ( e ) | | F i ( e ) & & ( e . t o S t r i n g = = = g 6 | | ! D n ( e . t o S t r i n g ) ) ? J S O N . s t r i n g i f y ( e , m 6 , 2 ) : S t r i n g ( e ) , m 6 = ( e , t ) = > t & & t . _ _ v _ i s R e f ? m 6 ( e , t . v a l u e ) : E y ( 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 ) , { } ) } : S v ( t ) ? { [ ` S e t ( $ { t . s i z e } ) ` ] : [ . . . t . v a l u e s ( ) ] } : F i ( t ) & & ! q t ( t ) & & ! y 6 ( t ) ? S t r i n g ( t ) : t , E o = { } , T y = [ ] , L i = ( ) = > { } , F n e = ( ) = > ! 1 , z n e = / ^ o n [ ^ a - z ] / , w v = e = > z n e . t e s t ( e ) , J R = e = > e . s t a r t s W i t h ( " o n U p d a t e : " ) , p s = O b j e c t . a s s i g n , Q R = ( 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 ) } , U n e = 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 , p i = ( e , t ) = > U n e . c a l l ( e , t ) , q t = A r r a y . i s A r r a y , E y = e = > $ C ( e ) = = = " [ o b j e c t M a p ] " , S v = e = > $ C ( e ) = = = " [ o b j e c t S e t ] " , B F = e = > $ C ( e ) = = = " [ o b j e c t D a t e ] " , D n = e = > t y p e o f e = = " f u n c t i o n " , v i = e = > t y p e o f e = = " s t r i n g " , $ b = e = > t y p e o f e = = " s y m b o l " , F i = e = > e ! = = n u l l & & t y p e o f e = = " o b j e c t " , _ 6 = e = > F i ( e ) & & D n ( e . t h e n ) & & D n ( e . c a t c h ) , g 6 = O b j e c t . p r o t o t y p e . t o S t r i n g , $ C = e = > g 6 . c a l l ( e ) , H n e = e = > $ C ( e ) . s l i c e ( 8 , - 1 ) , y 6 = e = > $ C ( e ) = = = " [ o b j e c t O b j e c t ] " , Z R = e = > v i ( e ) & & e ! = = " N a N " & & e [ 0 ] ! = = " - " & & " " + p a r s e I n t ( e , 1 0 ) = = = e , p w = K R ( " , 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 " ) , v v = 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 ) ) } , V n e = / - ( \ w ) / g , r u = v v ( e = > e . r e p l a c e ( V n e , ( t , n ) = > n ? n . t o U p p e r C a s e ( ) : " " ) ) , k n e = / \ B ( [ A - Z ] ) / g , F _ = v v ( e = > e . r e p l a c e ( k n e , " - $ 1 " ) . t o L o w e r C a s e ( ) ) , D v = v v ( 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 ) ) , b I = v v ( e = > e ? ` o n $ { D v ( e ) } ` : " " ) , Y b = ( e , t ) = > ! O b j e c t . i s ( e , t ) , m w = ( e , t ) = > { f o r ( l e t n = 0 ; n < e . l e n g t h ; n + + ) e [ n ] ( t ) } , u S = ( 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 } ) } , e N = 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 R F ; c o n s t G n e = ( ) = > R F | | ( R F = 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 Z a ; c l a s s A 6 { 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 = Z a , ! t & & Z a & & ( t h i s . i n d e x = ( Z a . s c o p e s | | ( Z a .
2023-02-06 08:55:59 +00:00
* pinia v2 . 0.28
* ( c ) 2022 Eduardo San Martin Morote
* @ license MIT
2023-02-13 02:05:23 +00:00
* /const are=Symbol();var y3;(function(e){e.direct="direct",e.patchObject="patch object",e.patchFunction="patch function"})(y3||(y3={}));function cre(){const e=Wne(!0),t=e.run(()=>Fn({}));let n=[],i=[];const o=aN({install(r){o._a=r,r.provide(are,o),r.config.globalProperties.$pinia=o,i.forEach(s=>n.push(s)),i=[]},use(r){return!this._a&&!sre?i.push(r):n.push(r),this},_p:n,_a:null,_e:e,_s:new Map,state:t});return o}/ * !
2023-02-06 08:55:59 +00:00
* vue - router v4 . 1.6
* ( c ) 2022 Eduardo San Martin Morote
* @ license MIT
2023-02-13 02:05:23 +00:00
* /const Jg=typeof window<"u";function lre(e){return e.__esModule||e[Symbol.toStringTag]==="Module"}const eo=Object.assign;function DI(e,t){const n={};for(const i in t){const o=t[i];n[i]=su(o)?o.map(e):e(o)}return n}const Tb=()=>{},su=Array.isArray,ure=/ \ / $ / , fre = e => e . replace ( ure , "" ) ; function II ( 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 = mre ( i ? ? t , n ) , { fullPath : i + ( r && "?" ) + r + s , path : i , query : o , hash : s } } function dre ( e , t ) { const n = t . query ? e ( t . query ) : "" ; return t . path + ( n && "?" ) + n + ( t . hash || "" ) } function A3 ( e , t ) { return ! t || ! e . toLowerCase ( ) . startsWith ( t . toLowerCase ( ) ) ? e : e . slice ( t . length ) || "/" } function hre ( e , t , n ) { const i = t . matched . length - 1 , o = n . matched . length - 1 ; return i > - 1 && i === o && Ky ( t . matched [ i ] , n . matched [ o ] ) && v9 ( t . params , n . params ) && e ( t . query ) === e ( n . query ) && t . hash === n . hash } function Ky ( e , t ) { return ( e . aliasOf || e ) === ( t . aliasOf || t ) } function v9 ( e , t ) { if ( Object . keys ( e ) . length !== Object . keys ( t ) . length ) return ! 1 ; for ( const n in e ) if ( ! pre ( e [ n ] , t [ n ] ) ) return ! 1 ; return ! 0 } function pre ( e , t ) { return su ( e ) ? b3 ( e , t ) : su ( t ) ? b3 ( t , e ) : e === t } function b3 ( e , t ) { return su ( t ) ? e . length === t . length && e . every ( ( n , i ) => n === t [ i ] ) : e . length === 1 && e [ 0 ] === t } function mre ( 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 nC ; ( function ( e ) { e . pop = "pop" , e . push = "push" } ) ( nC || ( nC = { } ) ) ; var Eb ; ( function ( e ) { e . back = "back" , e . forward = "forward" , e . unknown = "" } ) ( Eb || ( Eb = { } ) ) ; function _re ( e ) { if ( ! e ) if ( Jg ) { const t = document . querySelector ( "base" ) ; e = t && t . getAttribute ( "href" ) || "/" , e = e . replace ( /^\w+:\/\/[^\/]+/ , "" ) } else e = "/" ; return e [ 0 ] !== "/" && e [ 0 ] !== "#" && ( e = "/" + e ) , fre ( e ) } const gre = /^[^#]+#/ ; function yre ( e , t ) { return e . replace ( gre , "#" ) + t } function Are ( 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 zv = ( ) => ( { left : window . pageXOffset , top : window . pageYOffset } ) ; function bre ( 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 = Are ( 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 C3 ( e , t ) { return ( history . state ? history . state . position - t : - 1 ) + e } const DL = new Map ; function Cre ( e , t ) { DL . set ( e , t ) } function Tre ( e ) { const t = DL . get ( e ) ; return DL . delete ( e ) , t } let Ere = ( ) => location . protocol + "//" + location . host ; function D9 ( 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 ) , A3 ( c , "" ) } return A3 ( n , e ) + i + o } function xre ( e , t , n , i ) { let o = [ ] , r = [ ] , s = null ; const a = ( { state : m } ) => { const g = D9 ( e , location ) , p = n . value , y = t . value ; let b = 0 ; if ( m ) { if ( n . value = g , t . value = m , s && s === p ) { s = null ; return } b = y ? m . position - y . position : 0 } else i ( g ) ; o . forEach ( C => { C ( n . value , p , { delta : b , type : nC . pop , direction : b ? b > 0 ? Eb . forward : Eb . back : Eb . unknown } ) } ) } ; function c ( ) { s = n . value } function u ( m ) { o . push ( m ) ; const g = ( ) => { const p = o . indexOf ( m ) ; p > - 1 && o . splice ( p , 1 ) } ; return r . push ( g ) , g } function f ( ) { const { history : m } = window ; m . state && m . replaceState ( eo ( { } , m . state , { scroll : zv ( ) } ) , "" ) } function h ( ) { for ( const m of r ) m ( ) ; 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 T3 ( e , t , n , i = ! 1 , o = ! 1 ) { return { back : e , current : t , forward : n , replaced : i , position : window . history . length , scroll : o ? zv ( ) : null } } function wre ( e ) { const { history : t , location : n } = window , i = { value : D9 ( 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
2023-02-07 08:44:46 +00:00
height : 0 ! important ;
visibility : hidden ! important ;
overflow : hidden ! important ;
position : absolute ! important ;
z - index : - 1000 ! important ;
top : 0 ! important ;
right : 0 ! important ;
2023-02-13 02:05:23 +00:00
` ,Ode=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing"];function Lde(e){const t=window.getComputedStyle(e),n=t.getPropertyValue("box-sizing"),i=Number.parseFloat(t.getPropertyValue("padding-bottom"))+Number.parseFloat(t.getPropertyValue("padding-top")),o=Number.parseFloat(t.getPropertyValue("border-bottom-width"))+Number.parseFloat(t.getPropertyValue("border-top-width"));return{contextStyle:Ode.map(s=> ` $ { s } : $ { t . getPropertyValue ( s ) } ` ).join(";"),paddingSize:i,borderSize:o,boxSizing:n}}function _z(e,t=1,n){var i;vl||(vl=document.createElement("textarea"),document.body.appendChild(vl));const{paddingSize:o,borderSize:r,boxSizing:s,contextStyle:a}=Lde(e);vl.setAttribute("style", ` $ { a } ; $ { Pde } ` ),vl.value=e.value||e.placeholder||"";let c=vl.scrollHeight;const u={};s==="border-box"?c=c+r:s==="content-box"&&(c=c-o),vl.value="";const f=vl.scrollHeight-o;if(Tp(t)){let h=f*t;s==="border-box"&&(h=h+o+r),c=Math.max(h,c),u.minHeight= ` $ { h } px ` }if(Tp(n)){let h=f*n;s==="border-box"&&(h=h+o+r),c=Math.min(h,c)}return u.height= ` $ { c } px ` ,(i=vl.parentNode)==null||i.removeChild(vl),vl=void 0,u}const Bde=gs({id:{type:String,default:void 0},size:JC,disabled:Boolean,modelValue:{type:Jn([String,Number,Object]),default:""},type:{type:String,default:"text"},resize:{type:String,values:["none","both","horizontal","vertical"]},autosize:{type:Jn([Boolean,Object]),default:!1},autocomplete:{type:String,default:"off"},formatter:{type:Function},parser:{type:Function},placeholder:{type:String},form:{type:String},readonly:{type:Boolean,default:!1},clearable:{type:Boolean,default:!1},showPassword:{type:Boolean,default:!1},showWordLimit:{type:Boolean,default:!1},suffixIcon:{type:Zy},prefixIcon:{type:Zy},containerRole:{type:String,default:void 0},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},validateEvent:{type:Boolean,default:!0},inputStyle:{type:Jn([Object,Array,String]),default:()=>rC({})}}),Rde={[vd]:e=>vi(e),input:e=>vi(e),change:e=>vi(e),focus:e=>e instanceof FocusEvent,blur:e=>e instanceof FocusEvent,clear:()=>!0,mouseleave:e=>e instanceof MouseEvent,mouseenter:e=>e instanceof MouseEvent,keydown:e=>e instanceof Event,compositionstart:e=>e instanceof CompositionEvent,compositionupdate:e=>e instanceof CompositionEvent,compositionend:e=>e instanceof CompositionEvent},Nde=["role"],Mde=["id","type","disabled","formatter","parser","readonly","autocomplete","tabindex","aria-label","placeholder","form"],Fde=["id","tabindex","disabled","readonly","autocomplete","aria-label","placeholder","form"],zde=fi({name:"ElInput",inheritAttrs:!1}),Ude=fi({...zde,props:Bde,emits:Rde,setup(e,{expose:t,emit:n}){const i=e,o=xoe(),r=XC(),s=it(()=>{const Ae={};return i.containerRole==="combobox"&&(Ae["aria-haspopup"]=o["aria-haspopup"],Ae["aria-owns"]=o["aria-owns"],Ae["aria-expanded"]=o["aria-expanded"]),Ae}),a=it(()=>[i.type==="textarea"?b.b():y.b(),y.m(g.value),y.is("disabled",p.value),y.is("exceed",K.value),{[y.b("group")]:r.prepend||r.append,[y.bm("group","append")]:r.append,[y.bm("group","prepend")]:r.prepend,[y.m("prefix")]:r.prefix||i.prefixIcon,[y.m("suffix")]:r.suffix||i.suffixIcon||i.clearable||i.showPassword,[y.bm("suffix","password-clear")]:V.value&&k.value},o.class]),c=it(()=>[y.e("wrapper"),y.is("focus",w.value)]),u=fde({excludeKeys:it(()=>Object.keys(s.value))}),{form:f,formItem:h}=QC(),{inputId:m}=MN(i,{formItemContext:h}),g=TS(),p=kp(),y=yr("input"),b=yr("textarea"),C=i_(),E=i_(),w=Fn(!1),S=Fn(!1),P=Fn(!1),L=Fn(!1),z=Fn(),R=i_(i.inputStyle),F=it(()=>C.value||E.value),U=it(()=>{var Ae;return(Ae=f==null?void 0:f.statusIcon)!=null?Ae:!1}),v=it(()=>(h==null?void 0:h.validateState)||""),I=it(()=>v.value&&rde[v.value]),_=it(()=>L.value?jfe:xfe),D=it(()=>[o.style,i.inputStyle]),O=it(()=>[i.inputStyle,R.value,{resize:i.resize}]),N=it(()=>kv(i.modelValue)?"":String(i.modelValue)),V=it(()=>i.clearable&&!p.value&&!i.readonly&&!!N.value&&(w.value||S.value)),k=it(()=>i.showPassword&&!p
M 50 50
m 0 $ { S ? "" : "-" } $ { w }
a $ { w } $ { w } 0 1 1 0 $ { S ? "-" : "" } $ { w * 2 }
a $ { w } $ { w } 0 1 1 0 $ { S ? "" : "-" } $ { w * 2 }
` }),c=it(()=>2*Math.PI*s.value),u=it(()=>t.type==="dashboard"?.75:1),f=it(()=> ` $ { - 1 * c . value * ( 1 - u . value ) / 2 } px ` ),h=it(()=>({strokeDasharray: ` $ { c . value * u . value } px , $ { c . value } px ` ,strokeDashoffset:f.value})),m=it(()=>({strokeDasharray: ` $ { c . value * u . value * ( t . percentage / 100 ) } px , $ { c . value } px ` ,strokeDashoffset:f.value,transition:"stroke-dasharray 0.6s ease 0s, stroke 0.6s ease, opacity ease 0.6s"})),g=it(()=>{let w;return t.color?w=E(t.percentage):w=n[t.status]||n.default,w}),p=it(()=>t.status==="warning"?ON:t.type==="line"?t.status==="success"?IN:PN:t.status==="success"?oW:Wv),y=it(()=>t.type==="line"?12+t.strokeWidth*.4:t.width*.111111+2),b=it(()=>t.format(t.percentage));function C(w){const S=100/w.length;return w.map((L,z)=>vi(L)?{color:L,percentage:(z+1)*S}:L).sort((L,z)=>L.percentage-z.percentage)}const E=w=>{var S;const{color:P}=t;if(Dn(P))return P(w);if(vi(P))return P;{const L=C(P);for(const z of L)if(z.percentage>w)return z.color;return(S=L[L.length-1])==null?void 0:S.color}};return(w,S)=>(et(),Pt("div",{class:yt([pe(i).b(),pe(i).m(w.type),pe(i).is(w.status),{[pe(i).m("without-text")]:!w.showText,[pe(i).m("text-inside")]:w.textInside}]),role:"progressbar","aria-valuenow":w.percentage,"aria-valuemin":"0","aria-valuemax":"100"},[w.type==="line"?(et(),Pt("div",{key:0,class:yt(pe(i).b("bar"))},[gn("div",{class:yt(pe(i).be("bar","outer")),style:Ta({height: ` $ { w . strokeWidth } px ` })},[gn("div",{class:yt([pe(i).be("bar","inner"),{[pe(i).bem("bar","inner","indeterminate")]:w.indeterminate}]),style:Ta(pe(o))},[(w.showText||w. $ slots.default)&&w.textInside?(et(),Pt("div",{key:0,class:yt(pe(i).be("bar","innerText"))},[ni(w. $ slots,"default",{percentage:w.percentage},()=>[gn("span",null,va(pe(b)),1)])],2)):Yt("v-if",!0)],6)],6)],2)):(et(),Pt("div",{key:1,class:yt(pe(i).b("circle")),style:Ta({height: ` $ { w . width } px ` ,width: ` $ { w . width } px ` })},[(et(),Pt("svg",Cpe,[gn("path",{class:yt(pe(i).be("circle","track")),d:pe(a),stroke: ` var ( $ { pe ( i ) . cssVarName ( "fill-color-light" ) } , # e5e9f2 ) ` ,"stroke-width":pe(r),fill:"none",style:Ta(pe(h))},null,14,Tpe),gn("path",{class:yt(pe(i).be("circle","path")),d:pe(a),stroke:pe(g),fill:"none",opacity:w.percentage?1:0,"stroke-linecap":w.strokeLinecap,"stroke-width":pe(r),style:Ta(pe(m))},null,14,Epe)]))],6)),(w.showText||w. $ slots.default)&&!w.textInside?(et(),Pt("div",{key:2,class:yt(pe(i).e("text")),style:Ta({fontSize: ` $ { pe ( y ) } px ` })},[ni(w. $ slots,"default",{percentage:w.percentage},()=>[w.status?(et(),ti(pe(xs),{key:1},{default:wn(()=>[(et(),ti(Wl(pe(p))))]),_:1})):(et(),Pt("span",xpe,va(pe(b)),1))])],6)):Yt("v-if",!0)],10,bpe))}});var vpe=Ls(Spe,[["__file","/home/runner/work/element-plus/element-plus/packages/components/progress/src/progress.vue"]]);const Dpe=kd(vpe),Ipe=["start","center","end","space-around","space-between","space-evenly"],Ppe=["top","middle","bottom"],Ope=gs({tag:{type:String,default:"div"},gutter:{type:Number,default:0},justify:{type:String,values:Ipe,default:"start"},align:{type:String,values:Ppe,default:"top"}}),Lpe=fi({name:"ElRow"}),Bpe=fi({...Lpe,props:Ope,setup(e){const t=e,n=yr("row"),i=it(()=>t.gutter);Zu(dde,{gutter:i});const o=it(()=>{const s={};return t.gutter&&(s.marginRight=s.marginLeft= ` - $ { t . gutter / 2 } px ` ),s}),r=it(()=>[n.b(),n.is( ` justify - $ { t . justify } ` ,t.justify!=="start"),n.is( ` align - $ { t . align } ` ,t.align!=="top")]);return(s,a)=>(et(),ti(Wl(s.tag),{class:yt(pe(r)),style:Ta(pe(o))},{default:wn(()=>[ni(s. $ slots,"default")]),_:3},8,["class","style"]))}});var Rpe=Ls(Bpe,[["__file","/home/runner/work/element-plus/element-plus/packages/components/row/src/row.vue"]]);const Npe=kd(Rpe),Mpe="ElUpload";class Fpe extends Error{constructor(t,n,i,o){super(t),this.name="UploadAjaxError",this.status=n,this.method=i,this.url=o}}function Dz(e,t,n){let i;return n.response?i= ` $ { n . response . error || n . response } ` :n.responseText?i= ` $ { n . responseText } ` :i= ` fail to $ { t . method } $ { e } $ { n . status } ` ,new Fpe(i,n.status,t.method,e)}function zpe(e){const t=e.responseText||e.response;if(!t)return t;try{return JSON.parse(t)}catch{return t}}const Upe=e=>{typeof XMLHttpRequest>"u"&&Gv(Mpe,"XMLHttpRequest is undefi
$ { this . stack . toString ( ) } ` ),e};x.throwInstantiationError=function(){throw new x("This function defines an interface and should not be called directly.")};const Lr={};Lr.typeOf={};function Ime(e){return ` $ { e } is required , actual value was undefined ` }function x0(e,t,n){return ` Expected $ { n } to be typeof $ { t } , actual typeof was $ { e } ` }Lr.defined=function(e,t){if(!l(t))throw new x(Ime(e))};Lr.typeOf.func=function(e,t){if(typeof t!="function")throw new x(x0(typeof t,"function",e))};Lr.typeOf.string=function(e,t){if(typeof t!="string")throw new x(x0(typeof t,"string",e))};Lr.typeOf.number=function(e,t){if(typeof t!="number")throw new x(x0(typeof t,"number",e))};Lr.typeOf.number.lessThan=function(e,t,n){if(Lr.typeOf.number(e,t),t>=n)throw new x( ` Expected $ { e } to be less than $ { n } , actual value was $ { t } ` )};Lr.typeOf.number.lessThanOrEquals=function(e,t,n){if(Lr.typeOf.number(e,t),t>n)throw new x( ` Expected $ { e } to be less than or equal to $ { n } , actual value was $ { t } ` )};Lr.typeOf.number.greaterThan=function(e,t,n){if(Lr.typeOf.number(e,t),t<=n)throw new x( ` Expected $ { e } to be greater than $ { n } , actual value was $ { t } ` )};Lr.typeOf.number.greaterThanOrEquals=function(e,t,n){if(Lr.typeOf.number(e,t),t<n)throw new x( ` Expected $ { e } to be greater than or equal to $ { n } , actual value was $ { t } ` )};Lr.typeOf.object=function(e,t){if(typeof t!="object")throw new x(x0(typeof t,"object",e))};Lr.typeOf.bool=function(e,t){if(typeof t!="boolean")throw new x(x0(typeof t,"boolean",e))};Lr.typeOf.bigint=function(e,t){if(typeof t!="bigint")throw new x(x0(typeof t,"bigint",e))};Lr.typeOf.number.equals=function(e,t,n,i){if(Lr.typeOf.number(e,n),Lr.typeOf.number(t,i),n!==i)throw new x( ` $ { e } must be equal to $ { t } , the actual values are $ { n } and $ { i } ` )};const T=Lr;function A(e,t){return e??t}A.EMPTY_OBJECT=Object.freeze({});var Gd=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)};Gd.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}};Gd.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};Gd.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};Gd.prototype.random_int31=function(){return this.random_int()>>>1};Gd.prototype.random_incl=function(){return this.random_int()*(1/4294967295)};Gd.prototype.random=function(){return this.random_int()*(1/4294967296)};Gd.prototype.random_excl=function(){return(this.random_int()+.5)*(1/4294967296)};Gd.prototype.random_long=function(){var e=this.random_int()>>>5,t=this.random_int()>>>6;return(e*67108864+t)*(1/9007199254740992)};var qv=Gd;const Ye={};Ye.EPSILON1=.1;Ye.EPSILON2=.01;Ye.EPSILON3=.001;Ye.EPSILON4=1e-4;Ye.EPSILON5=1e-5;Ye.EPSILON6=1e-6;Ye.EPSILON7=1e-7;Ye.EPSILON8=1e-8;Ye.EP
2023-02-06 08:55:59 +00:00
( $ { this [ 1 ] } , $ { this [ 4 ] } , $ { this [ 7 ] } )
2023-02-13 02:05:23 +00:00
( $ { this [ 2 ] } , $ { this [ 5 ] } , $ { this [ 8 ] } ) ` };function Ie(e){this.name="RuntimeError",this.message=e;let t;try{throw new Error}catch(n){t=n.stack}this.stack=t}l(Object.create)&&(Ie.prototype=Object.create(Error.prototype),Ie.prototype.constructor=Ie);Ie.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,m,g,p,y){this[0]=A(e,0),this[1]=A(o,0),this[2]=A(c,0),this[3]=A(m,0),this[4]=A(t,0),this[5]=A(r,0),this[6]=A(u,0),this[7]=A(g,0),this[8]=A(n,0),this[9]=A(s,0),this[10]=A(f,0),this[11]=A(p,0),this[12]=A(i,0),this[13]=A(a,0),this[14]=A(h,0),this[15]=A(y,0)}B.packedLength=16;B.pack=function(e,t,n){return T.typeOf.object("value",e),T.defined("array",t),n=A(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=A(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 x("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 x("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=A(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,m=t.y*t.z,g=t.y*t.w,p=t.z*t.z,y=t.z*t.w,b=t.w*t.w,C=a-h-p+b,E=2*(c-y),w=2*(u+g),S=2*(c+y),P=-a+h-p+b,L=2*(m-f),z=2*(u-g),R=2*(m+f),F=-a-h+p+b;return i[0]=C*o,i[1]=S*o,i[2]=z*o,i[3]=0,i[4]=E*r,i[5]=P*r,i[6]=R*r,i[7]=0,i[8]=w*s,i[9]=L*s,i[10]=F*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
2023-02-06 08:55:59 +00:00
( $ { this [ 1 ] } , $ { this [ 5 ] } , $ { this [ 9 ] } , $ { this [ 13 ] } )
( $ { this [ 2 ] } , $ { this [ 6 ] } , $ { this [ 10 ] } , $ { this [ 14 ] } )
2023-02-13 02:05:23 +00:00
( $ { this [ 3 ] } , $ { this [ 7 ] } , $ { this [ 11 ] } , $ { this [ 15 ] } ) ` };const Qme={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
2023-02-06 08:55:59 +00:00
attribute vec2 textureCoordinates ;
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _Position = position ;
v _textureCoordinates = textureCoordinates ;
}
2023-02-13 02:05:23 +00:00
` ,Bo={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 pt(e){e=A(e,A.EMPTY_OBJECT),this._boundingVolume=e.boundingVolume,this._orientedBoundingBox=e.orientedBoundingBox,this._modelMatrix=e.modelMatrix,this._primitiveType=A(e.primitiveType,Qe.TRIANGLES),this._vertexArray=e.vertexArray,this._count=e.count,this._offset=A(e.offset,0),this._instanceCount=A(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=A(e.cull,!0),this.occlude=A(e.occlude,!0),this.executeInClosestFrustum=A(e.executeInClosestFrustum,!1),this.debugShowBoundingVolume=A(e.debugShowBoundingVolume,!1),this.castShadows=A(e.castShadows,!1),this.receiveShadows=A(e.receiveShadows,!1),this.pickOnly=A(e.pickOnly,!1),this.depthForTranslucentClassification=A(e.depthForTranslucentClassification,!1),this.dirty=!0,this.lastDirtyTime=0,this.derivedCommands={}}function Ms(e,t){return(e._flags&t)===t}function ph(e,t,n){n?e._flags|=t:e._flags&=~t}Object.defineProperties(pt.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,Bo.CULL)},set:function(e){Ms(this,Bo.CULL)!==e&&(ph(this,Bo.CULL,e),this.dirty=!0)}},occlude:{get:function(){return Ms(this,Bo.OCCLUDE)},set:function(e){Ms(this,Bo.OCCLUDE)!==e&&(ph(this,Bo.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,Bo.CAST_SHADOWS)},set:function(e){Ms(this,Bo.CAST_SHADOWS)!==e&&(ph(this,Bo.CAST_SHADOWS,e),this.dirty=!0)}},receiveShadows:{get:function(){return Ms(this,Bo.RECEIVE_SHADOWS)},set:function(e){Ms(this,Bo.RECEIVE_SHADOWS)!==e&&(ph(this,Bo.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,Bo.EXECUTE_IN_CLOSEST_FRUSTUM)},set:function(e){Ms(this,Bo.EXECUTE_IN_CLOSEST_FRUSTUM)!==e&&(ph(this,Bo.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,Bo.DEBUG_SHOW_BOUNDING_VOLUME)},set:function(e){Ms(this,Bo.DEBUG_SHOW_BOUNDING_VOLUME)!==e&&(ph(this,Bo.DEBUG_SHOW_BOUNDING_VOLUME,e),this.dirty=!0)}},debugOverlappingFrustums:{g
( $ { this [ 1 ] } , $ { this [ 3 ] } ) ` };function Y_e(e,t,n,i){switch(t.type){case e.FLOAT:return new sj(e,t,n,i);case e.FLOAT_VEC2:return new aj(e,t,n,i);case e.FLOAT_VEC3:return new cj(e,t,n,i);case e.FLOAT_VEC4:return new lj(e,t,n,i);case e.SAMPLER_2D:case e.SAMPLER_CUBE:return new GN(e,t,n,i);case e.INT:case e.BOOL:return new uj(e,t,n,i);case e.INT_VEC2:case e.BOOL_VEC2:return new fj(e,t,n,i);case e.INT_VEC3:case e.BOOL_VEC3:return new dj(e,t,n,i);case e.INT_VEC4:case e.BOOL_VEC4:return new hj(e,t,n,i);case e.FLOAT_MAT2:return new pj(e,t,n,i);case e.FLOAT_MAT3:return new mj(e,t,n,i);case e.FLOAT_MAT4:return new _j(e,t,n,i);default:throw new Ie( ` Unrecognized uniform type : $ { t . type } for uniform "${n}" . ` )}}function sj(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}sj.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1f(this._location,this.value))};function aj(e,t,n,i){this.name=n,this.value=void 0,this._value=new j,this._gl=e,this._location=i}aj.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 cj(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}cj.prototype.set=function(){const e=this.value;if(l(e.red))H.equals(e,this._value)||(this._value=H.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 x( ` Invalid vec3 value for uniform "${this.name}" . ` )};function lj(e,t,n,i){this.name=n,this.value=void 0,this._value=void 0,this._gl=e,this._location=i}lj.prototype.set=function(){const e=this.value;if(l(e.red))H.equals(e,this._value)||(this._value=H.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 x( ` Invalid vec4 value for uniform "${this.name}" . ` )};function GN(e,t,n,i){this.name=n,this.value=void 0,this._gl=e,this._location=i,this.textureUnitIndex=void 0}GN.prototype.set=function(){const e=this._gl;e.activeTexture(e.TEXTURE0+this.textureUnitIndex);const t=this.value;e.bindTexture(t._target,t._texture)};GN.prototype._setSampler=function(e){return this.textureUnitIndex=e,this._gl.uniform1i(this._location,e),e+1};function uj(e,t,n,i){this.name=n,this.value=void 0,this._value=0,this._gl=e,this._location=i}uj.prototype.set=function(){this.value!==this._value&&(this._value=this.value,this._gl.uniform1i(this._location,this.value))};function fj(e,t,n,i){this.name=n,this.value=void 0,this._value=new j,this._gl=e,this._location=i}fj.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 dj(e,t,n,i){this.name=n,this.value=void 0,this._value=new d,this._gl=e,this._location=i}dj.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 hj(e,t,n,i){this.name=n,this.value=void 0,this._value=new oe,this._gl=e,this._location=i}hj.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 X_e=new Float32Array(4);function pj(e,t,n,i){this.name=n,this.value=void 0,this._value=new ut,this._gl=e,this._location=i}pj.prototype.set=function(){if(!ut.equalsArray(this.value,this._value,0)){ut.clone(this.value,this._value);const e=ut.toArray(this.value,X_e);this._gl.uniformMatrix2fv(this._location,!1,e)}};const K_e=new Float32Array(9);function mj(e,t,n,i){this.name=n,this.value=void 0,this._value=new J,this._gl=e,this._location=i}mj.prototype.set=function(){if(!J.equalsArray(this.value,this._value,0)){J.clone(this.value,this._value);const e=J.toArray(this.value,K_e);this._gl.uniformMatrix3fv(this._location,!1,e)}};const J_e=new Float32Array(16);funct
$ { n } ` ),u= ` Vertex shader failed to compile . Compile log : $ { c } ` ):(c=e.getShaderInfoLog(r),console.error( ` $ { Bu } Fragment shader compile log : $ { c } ` ),console.error( ` $ { Bu } Fragment shader source :
$ { i } ` ),u= ` Fragment shader failed to compile . Compile log : $ { c } ` ),e.deleteShader(o),e.deleteShader(r),e.deleteProgram(s),new Ie(u);function h(m,g){if(!l(f))return;const p=f.getTranslatedShaderSource(m);if(p===""){console.error( ` $ { Bu } $ { g } shader translation failed . ` );return}console.error( ` $ { Bu } Translated $ { g } shaderSource :
$ { p } ` )}}function nge(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 ige(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=Y_e(e,a,u,f);n[u]=h,i.push(h),h._setSampler&&o.push(h)}}else{let f,h,m,g;const p=u.indexOf("[");if(p>=0){if(f=n[u.slice(0,p)],!l(f))continue;h=f._locations,h.length<=1&&(m=f.value,g=e.getUniformLocation(t,u),g!==null&&(h.push(g),m.push(e.getUniform(t,g))))}else{h=[];for(let y=0;y<a.size;++y)g=e.getUniformLocation(t, ` $ { u } [ $ { y } ] ` ),g!==null&&h.push(g);f=Q_e(e,a,u,h),n[u]=f,i.push(f),f._setSampler&&o.push(f)}}}return{uniformsByName:n,uniforms:i,samplerUniforms:o}}function oge(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=yw[s];l(c)?n.push({uniform:r,automaticUniform:c}):i.push(r)}return{automaticUniforms:n,manualUniforms:i}}function rge(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 Cw(e){l(e._program)||Dj(e)}function Dj(e){const t=e._program,n=e._gl,i=tge(n,e,e._debugShaders),o=n.getProgramParameter(i,n.ACTIVE_ATTRIBUTES),r=ige(n,i),s=oge(e,r.uniformsByName);e._program=i,e._numberOfVertexAttributes=o,e._vertexAttributes=nge(n,i,o),e._uniformsByName=r.uniformsByName,e._uniforms=r.uniforms,e._automaticUniforms=s.automaticUniforms,e._manualUniforms=s.manualUniforms,e.maximumTextureUnitIndex=rge(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,m=e._fragmentShaderText,g=/ ! = /g;e._vertexShaderText=a.replace(g," != "),e._fragmentShaderText=c.replace(g," != ");try{Dj(e),u(e._program)}catch(p){e._vertexShaderText=h,e._fragmentShaderText=m;const b=/(?:Compile|Link) error: ([^]*)/.exec(p.message);f(b?b[1]:p.message)}})}yn.prototype._bind=function(){Cw(this),this._gl.useProgram(this._program)};yn.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 x( ` Program validation failed . Program info log : $ { a . getProgramInfoLog ( c ) } ` )}};yn.prototype.isDestroyed=function(){return!1};yn.prototype.destroy=function(){this._cachedShader.cache.releaseShaderProgram(this)};yn.prototype.finalDestroy=function(){return this._gl.deleteProgram(this._program),He(this)};function Yv(e){this._context=e}let Z0;const sge=new pt({primitiveType:Qe.TRIANGLES}),age=new ao({color:new H(0,0,0,0)});function cge(e,t){return new $ r({context:e,colorTextures:[t],destroyAttachments:!1})}function lge(e,t){return yn.fromCache({context:e,vertexShaderSource:WW,fragmentShaderSource:t,attributeLocations:{position:0,textureCoordinates:1}})}function uge(e,t){return(!l(Z0)||Z0.viewport.width!==e||Z0.viewport.height!==t)&&(Z0=Ze.fromCache({viewport:new $ e(0,0,e,t)})),Z0}Yv.prototype.execute=function(e){if(T.defined("computeCommand",e),l(e.preExecute)&&e.preExecute(e),!l(e.fragmentShaderSource)&&!l(e.shaderProgram))throw new x("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:lge(o,e.fragmentShaderSource),a=cge(o,t),c=uge(n,i),u=e.uniformMap,f=age;f.framebuffer=a,f.ren
2023-02-06 08:55:59 +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
*
2023-02-13 02:05:23 +00:00
* /var tU;function Bge(){return tU||(tU=1,function(e){(function(t,n){e.exports?e.exports=n():t.IPv6=n(t)})(Sy,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,m=0;m<u;m++){h=a[m].split("");for(var g=0;g<3&&(h[0]==="0"&&h.length>1);g++)h.splice(0,1);a[m]=h.join("")}var p=-1,y=0,b=0,C=-1,E=!1;for(m=0;m<u;m++)E?a[m]==="0"?b+=1:(E=!1,b>y&&(p=C,y=b)):a[m]==="0"&&(E=!0,C=m,b=1);b>y&&(p=C,y=b),y>1&&a.splice(p,y,""),c=a.length;var w="";for(a[0]===""&&(w=":"),m=0;m<c&&(w+=a[m],m!==c-1);m++)w+=":";return a[c-1]===""&&(w+=":"),w}function o(){return t.IPv6===this&&(t.IPv6=n),this}return{best:i,noConflict:o}})}(Lge)),IS}var PS={},Rge={get exports(){return PS},set exports(e){PS=e}};/ * !
2023-02-06 08:55:59 +00:00
* 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
*
2023-02-13 02:05:23 +00:00
* / v a r n U ; f u n c t i o n N g e ( ) { r e t u r n n U | | ( n U = 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 ) } ) ( S y , 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
2023-02-06 08:55:59 +00:00
* 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
*
2023-02-13 02:05:23 +00:00
* /(function(e){(function(t,n){e.exports?e.exports=n(Oge(),Bge(),Nge()):t.URI=n(t.punycode,t.IPv6,t.SecondLevelDomains,t)})(Sy,function(t,n,i,o){var r=o&&o.URI;function s(_,D){var O=arguments.length>=1,N=arguments.length>=2;if(!(this instanceof s))return O?N?new s(_,D):new s(_):new s;if(_===void 0){if(O)throw new TypeError("undefined is not a valid argument for URI");typeof location<"u"?_=location.href+"":_=""}if(_===null&&O)throw new TypeError("null is not a valid argument for URI");return this.href(_),D!==void 0?this.absoluteTo(D):this}function a(_){return/ ^ [ 0 - 9 ] + $ / . test ( _ ) } s . version = "1.19.11" ; var c = s . prototype , u = Object . prototype . hasOwnProperty ; function f ( _ ) { return _ . replace ( /([.*+?^=!:${}()|[\]\/\\])/g , "\\$1" ) } function h ( _ ) { return _ === void 0 ? "Undefined" : String ( Object . prototype . toString . call ( _ ) ) . slice ( 8 , - 1 ) } function m ( _ ) { return h ( _ ) === "Array" } function g ( _ , D ) { var O = { } , N , V ; if ( h ( D ) === "RegExp" ) O = null ; else if ( m ( D ) ) for ( N = 0 , V = D . length ; N < V ; N ++ ) O [ D [ N ] ] = ! 0 ; else O [ D ] = ! 0 ; for ( N = 0 , V = _ . length ; N < V ; N ++ ) { var k = O && O [ _ [ N ] ] !== void 0 || ! O && D . test ( _ [ N ] ) ; k && ( _ . splice ( N , 1 ) , V -- , N -- ) } return _ } function p ( _ , D ) { var O , N ; if ( m ( D ) ) { for ( O = 0 , N = D . length ; O < N ; O ++ ) if ( ! p ( _ , D [ O ] ) ) return ! 1 ; return ! 0 } var V = h ( D ) ; for ( O = 0 , N = _ . length ; O < N ; O ++ ) if ( V === "RegExp" ) { if ( typeof _ [ O ] == "string" && _ [ O ] . match ( D ) ) return ! 0 } else if ( _ [ O ] === D ) return ! 0 ; return ! 1 } function y ( _ , D ) { if ( ! m ( _ ) || ! m ( D ) || _ . length !== D . length ) return ! 1 ; _ . sort ( ) , D . sort ( ) ; for ( var O = 0 , N = _ . length ; O < N ; O ++ ) if ( _ [ O ] !== D [ O ] ) return ! 1 ; return ! 0 } function b ( _ ) { var D = /^\/+|\/+$/g ; return _ . 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 n0(e,t,n){this.statusCode=e,this.response=t,this.responseHeaders=n,typeof this.responseHeaders=="string"&&(this.responseHeaders=qge(this.responseHeaders))}n0.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 $ ge(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( $ ge),e=0;e<i;e++){const r=o[e];t.splice(r,1),n.splice(r,1)}o.length=0}this._insideRaiseEvent=!1};function k_(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(k_.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 KN(e,t,n){const i=e[t];e[t]=e[n],e[n]=i}k_.prototype.reserve=function(e){e=A(e,this._length),this._array.length=e};k_.prototype.heapify=function(e){e=A(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?(KN(i,o,e),e=o):r=!1}};k_.prototype.resort=function(){const e=this._length;for(let t=Math.ceil(e/2);t>=0;--t)this.heapify(t)};k_.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)KN(t,o,s),o=s;else break}let r;return l(i)&&this._length>i&&(r=t[i],this._length=i),r};k_.prototype.pop=function(e){if(e=A(e,0),this._length===0)return;T.typeOf.number.lessThan("index",e,this._length);const t=this._array,n=t[e];return KN(t,e,--this._length),this.heapify(e),t[this._length]=void 0,n};function Yge(e,t){return e.priority-t.priority}const xi={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0};let vy=20;const Ks=new k_({comparator:Yge});Ks.maximumLength=vy;Ks.reserve(vy);const Yu=[];let Dd={};const Xge=typeof document<"u"?new Ps(document.location.href):new Ps,Kv=new Xe;function Ai(){}Ai.maximumRequests=50;Ai.maximumRequestsPerServer=6;Ai.requestsByServer={"api.cesium.com:443":18,"assets.cesium.com:443":18};Ai.throttleRequests=!0;Ai.debugShowStatistics=!1;Ai.requestCompletedEvent=Kv;Object.defineProperties(Ai,{statistics:{get:function(){return xi}},priorityHeapLength:{get:function(){return vy},set:function(e){if(e<vy)for(;Ks.length>e;){const t=Ks.pop();r_(t)}vy=e,Ks.maximumLength=e,Ks.reserve(e)}}});function Bj(e){l(e.priorityFunction)&&(e.priority=e.priorityFunction())}Ai.serverHasOpenSlots=function(e,t){t=A(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 x("Could not find a #define OUTPUT_DECLARATION!");const a=[];for(r=0;r<10;r++){const y= ` gl _FragData \ \ [ $ { r } \ \ ] ` ,b= ` czm _out$ { r } ` ;new RegExp(y,"g").test(e)&&(fU(b,a),zu(y,b,i),i.splice(o,0, ` layout ( location = $ { r } ) out vec4 $ { b } ; ` ),o+=1)}const c="czm_fragColor";Kye("gl_FragColor",i)&&(fU(c,a),zu("gl_FragColor",c,i),i.splice(o,0,"layout(location = 0) out vec4 czm_fragColor;"),o+=1);const u=Qye(a,i),f={};for(r=0;r<i.length;r++){s=i[r];for(const y in u)u.hasOwnProperty(y)&&new RegExp( ` ( layout ) [ ^ ] + ( out ) [ ^ ] + ( $ { y } ) [ ^ ] + ` ,"g").test(s)&&(f[s]=y)}for(const y in f)if(f.hasOwnProperty(y)){const b=f[y];let C=i.indexOf(y);const E=u[b],w=E.length;for(let S=0;S<w;S++)i.splice(C,0,E[S]);C+=w+1;for(let S=w-1;S>=0;S--)i.splice(C,0, ` # endif //${E[S]}`)}const h="WEBGL_2",m=`#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,m),o1("EXT_draw_buffers",h,i),o1("EXT_frag_depth",h,i),o1("OES_standard_derivatives",h,i),zu("texture2D","texture",i),zu("texture3D","texture",i),zu("textureCube","texture",i),zu("gl_FragDepthEXT","gl_FragDepth",i),t?zu("varying","in",i):(zu("attribute","in",i),zu("varying","out",i)),Jye(i)}function zu(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 Xye(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 Kye(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 Jye(e){let t="";const n=e.length;for(let i=0;i<n;++i)t+=`${e[i]}
` ;return t}function fU(e,t){t.indexOf(e)===-1&&t.push(e)}function Qye(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(m){return o.indexOf(m)>=0}):n[h]=o.slice())}}return n}function o1(e,t,n){const i= ` # extension \ \ s + GL _$ { e } \ \ s + : \ \ s + [ a - zA - Z0 - 9 ] + \ \ s * $ ` ;Xye(new RegExp(i,"g"),"",n),zu( ` GL _$ { e } ` ,t,n)}const Zye= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,e0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
2023-02-13 02:05:23 +00:00
` ,t0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.1
*
* @ name czm _epsilon1
* @ glslConstant
* /
const float czm _epsilon1 = 0.1 ;
2023-02-13 02:05:23 +00:00
` ,n0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.01
*
* @ name czm _epsilon2
* @ glslConstant
* /
const float czm _epsilon2 = 0.01 ;
2023-02-13 02:05:23 +00:00
` ,i0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.001
*
* @ name czm _epsilon3
* @ glslConstant
* /
const float czm _epsilon3 = 0.001 ;
2023-02-13 02:05:23 +00:00
` ,o0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.0001
*
* @ name czm _epsilon4
* @ glslConstant
* /
const float czm _epsilon4 = 0.0001 ;
2023-02-13 02:05:23 +00:00
` ,r0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.00001
*
* @ name czm _epsilon5
* @ glslConstant
* /
const float czm _epsilon5 = 0.00001 ;
2023-02-13 02:05:23 +00:00
` ,s0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.000001
*
* @ name czm _epsilon6
* @ glslConstant
* /
const float czm _epsilon6 = 0.000001 ;
2023-02-13 02:05:23 +00:00
` ,a0e= ` / * *
2023-02-06 08:55:59 +00:00
* 0.0000001
*
* @ name czm _epsilon7
* @ glslConstant
* /
const float czm _epsilon7 = 0.0000001 ;
2023-02-13 02:05:23 +00:00
` ,c0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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?
2023-02-13 02:05:23 +00:00
` ,l0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,u0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,f0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # CESIUM _3D _TILE }
*
* @ name czm _passCesium3DTile
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCesium3DTile = 4.0 ;
2023-02-13 02:05:23 +00:00
` ,d0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # CESIUM _3D _TILE _CLASSIFICATION }
*
* @ name czm _passCesium3DTileClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCesium3DTileClassification = 5.0 ;
2023-02-13 02:05:23 +00:00
` ,h0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,p0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # CLASSIFICATION }
*
* @ name czm _passClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passClassification = 7.0 ;
2023-02-13 02:05:23 +00:00
` ,m0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # COMPUTE }
*
* @ name czm _passCompute
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passCompute = 1.0 ;
2023-02-13 02:05:23 +00:00
` ,_0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # ENVIRONMENT }
*
* @ name czm _passEnvironment
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passEnvironment = 0.0 ;
2023-02-13 02:05:23 +00:00
` ,g0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # GLOBE }
*
* @ name czm _passGlobe
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passGlobe = 2.0 ;
2023-02-13 02:05:23 +00:00
` ,y0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # OPAQUE }
*
* @ name czm _passOpaque
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passOpaque = 7.0 ;
2023-02-13 02:05:23 +00:00
` ,A0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # OVERLAY }
*
* @ name czm _passOverlay
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passOverlay = 10.0 ;
2023-02-13 02:05:23 +00:00
` ,b0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # TERRAIN _CLASSIFICATION }
*
* @ name czm _passTerrainClassification
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passTerrainClassification = 3.0 ;
2023-02-13 02:05:23 +00:00
` ,C0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # TRANSLUCENT }
*
* @ name czm _passTranslucent
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passTranslucent = 8.0 ;
2023-02-13 02:05:23 +00:00
` ,T0e= ` / * *
2023-02-06 08:55:59 +00:00
* The automatic GLSL constant for { @ link Pass # VOXELS }
*
* @ name czm _passVoxels
* @ glslConstant
*
* @ see czm _pass
* /
const float czm _passVoxels = 9.0 ;
2023-02-13 02:05:23 +00:00
` ,E0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,x0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,w0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,S0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,v0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,D0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,I0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,P0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,O0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,L0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,B0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,R0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,N0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,M0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
2023-02-13 02:05:23 +00:00
` ,F0e= ` / * *
2023-02-06 08:55:59 +00:00
* @ name czm _depthRangeStruct
* @ glslStruct
* /
struct czm _depthRangeStruct
{
float near ;
float far ;
} ;
2023-02-13 02:05:23 +00:00
` ,z0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
} ;
2023-02-13 02:05:23 +00:00
` ,U0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
} ;
2023-02-13 02:05:23 +00:00
` ,H0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
} ;
2023-02-13 02:05:23 +00:00
` ,V0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
} ;
2023-02-13 02:05:23 +00:00
` ,k0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
} ;
2023-02-13 02:05:23 +00:00
` ,G0e= ` / * *
2023-02-06 08:55:59 +00:00
* DOC _TBA
*
* @ name czm _ray
* @ glslStruct
* /
struct czm _ray
{
vec3 origin ;
vec3 direction ;
} ;
2023-02-13 02:05:23 +00:00
` ,W0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
2023-02-13 02:05:23 +00:00
` ,j0e= ` struct czm _shadowParameters
2023-02-06 08:55:59 +00:00
{
# ifdef USE _CUBE _MAP _SHADOW
vec3 texCoords ;
# else
vec2 texCoords ;
# endif
float depthBias ;
float depth ;
float nDotL ;
vec2 texelStepSize ;
float normalShadingSmooth ;
float darkness ;
} ;
2023-02-13 02:05:23 +00:00
` ,q0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` , $ 0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,Y0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,X0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,K0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,J0e= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,Q0e= ` // See:
2023-02-06 08:55:59 +00:00
// 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 ;
}
2023-02-13 02:05:23 +00:00
` ,Z0e= ` / * *
2023-02-06 08:55:59 +00:00
* @ 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 ) ) ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,eAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,tAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,nAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,iAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,oAe= `
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,rAe= `
2023-02-06 08:55:59 +00:00
uniform vec4 shadowMap _cascadeDistances ;
float czm _cascadeDistance ( vec4 weights )
{
return dot ( shadowMap _cascadeDistances , weights ) ;
}
2023-02-13 02:05:23 +00:00
` ,sAe= `
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,aAe= `
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,cAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,lAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ( ) ;
2023-02-13 02:05:23 +00:00
` ,uAe= ` / * *
2023-02-06 08:55:59 +00:00
* @ 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 ) ;
}
}
2023-02-13 02:05:23 +00:00
` ,fAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,dAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,hAe= ` // emulated noperspective
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,pAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,mAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,_Ae= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,gAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,yAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,AAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,bAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,CAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,TAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,EAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,xAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,wAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,SAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,vAe= ` / * *
2023-02-06 08:55:59 +00:00
* @ 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 ;
}
2023-02-13 02:05:23 +00:00
` ,DAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,IAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,PAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,OAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,LAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,BAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,RAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,NAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,MAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,FAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,zAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,UAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,HAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,VAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,kAe= ` vec3 lambertianDiffuse ( vec3 diffuseColor )
2023-02-06 08:55:59 +00:00
{
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 ;
}
2023-02-13 02:05:23 +00:00
` ,GAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,WAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,jAe= ` float czm _private _getLambertDiffuseOfMaterial ( vec3 lightDirectionEC , czm _material material )
2023-02-06 08:55:59 +00:00
{
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,qAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` , $ Ae= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,YAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
}
}
2023-02-13 02:05:23 +00:00
` ,XAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,KAe= ` float czm _readDepth ( sampler2D depthTexture , vec2 texCoords )
2023-02-06 08:55:59 +00:00
{
return czm _reverseLogDepth ( texture2D ( depthTexture , texCoords ) . r ) ;
}
2023-02-13 02:05:23 +00:00
` ,JAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,QAe= ` float czm _reverseLogDepth ( float logZ )
2023-02-06 08:55:59 +00:00
{
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,ZAe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,ebe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,tbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,nbe= `
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,ibe= `
2023-02-06 08:55:59 +00:00
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
2023-02-13 02:05:23 +00:00
` ,obe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,rbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,sbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,abe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,cbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,lbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,ube= ` / * *
2023-02-06 08:55:59 +00:00
* @ 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,fbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ] ) ;
}
2023-02-13 02:05:23 +00:00
` ,dbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,hbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,pbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ) ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,mbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,_be= ` # ifdef LOG _DEPTH
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
` ,gbe= ` vec4 czm _screenToEyeCoordinates ( vec4 screenCoordinate )
2023-02-06 08:55:59 +00:00
{
// 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,ybe= ` // emulated noperspective
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,Abe= ` # ifdef LOG _DEPTH
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,bbe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
2023-02-13 02:05:23 +00:00
` ,r1={czm_degreesPerRadian:Zye,czm_depthRange:e0e,czm_epsilon1:t0e,czm_epsilon2:n0e,czm_epsilon3:i0e,czm_epsilon4:o0e,czm_epsilon5:r0e,czm_epsilon6:s0e,czm_epsilon7:a0e,czm_infinity:c0e,czm_oneOverPi:l0e,czm_oneOverTwoPi:u0e,czm_passCesium3DTile:f0e,czm_passCesium3DTileClassification:d0e,czm_passCesium3DTileClassificationIgnoreShow:h0e,czm_passClassification:p0e,czm_passCompute:m0e,czm_passEnvironment:_0e,czm_passGlobe:g0e,czm_passOpaque:y0e,czm_passOverlay:A0e,czm_passTerrainClassification:b0e,czm_passTranslucent:C0e,czm_passVoxels:T0e,czm_pi:E0e,czm_piOverFour:x0e,czm_piOverSix:w0e,czm_piOverThree:S0e,czm_piOverTwo:v0e,czm_radiansPerDegree:D0e,czm_sceneMode2D:I0e,czm_sceneMode3D:P0e,czm_sceneModeColumbusView:O0e,czm_sceneModeMorphing:L0e,czm_solarRadius:B0e,czm_threePiOver2:R0e,czm_twoPi:N0e,czm_webMercatorMaxLatitude:M0e,czm_depthRangeStruct:F0e,czm_material:z0e,czm_materialInput:U0e,czm_modelMaterial:H0e,czm_modelVertexOutput:V0e,czm_pbrParameters:k0e,czm_ray:G0e,czm_raySegment:W0e,czm_shadowParameters:j0e,czm_HSBToRGB:q0e,czm_HSLToRGB: $ 0e,czm_RGBToHSB:Y0e,czm_RGBToHSL:X0e,czm_RGBToXYZ:K0e,czm_XYZToRGB:J0e,czm_acesTonemapping:Q0e,czm_alphaWeight:Z0e,czm_antialias:eAe,czm_approximateSphericalCoordinates:tAe,czm_backFacing:nAe,czm_branchFreeTernary:iAe,czm_cascadeColor:oAe,czm_cascadeDistance:rAe,czm_cascadeMatrix:sAe,czm_cascadeWeights:aAe,czm_columbusViewMorph:cAe,czm_computePosition:lAe,czm_cosineAndSine:uAe,czm_decompressTextureCoordinates:fAe,czm_defaultPbrMaterial:dAe,czm_depthClamp:hAe,czm_eastNorthUpToEyeCoordinates:pAe,czm_ellipsoidContainsPoint:mAe,czm_ellipsoidWgs84TextureCoordinates:_Ae,czm_equalsEpsilon:gAe,czm_eyeOffset:yAe,czm_eyeToWindowCoordinates:AAe,czm_fastApproximateAtan:bAe,czm_fog:CAe,czm_gammaCorrect:TAe,czm_geodeticSurfaceNormal:EAe,czm_getDefaultMaterial:xAe,czm_getLambertDiffuse:wAe,czm_getSpecular:SAe,czm_getWaterNoise:vAe,czm_hue:DAe,czm_inverseGamma:IAe,czm_isEmpty:PAe,czm_isFull:OAe,czm_latitudeToWebMercatorFraction:LAe,czm_lineDistance:BAe,czm_linearToSrgb:RAe,czm_luminance:NAe,czm_metersPerPixel:MAe,czm_modelToWindowCoordinates:FAe,czm_multiplyWithColorBalance:zAe,czm_nearFarScalar:UAe,czm_octDecode:HAe,czm_packDepth:VAe,czm_pbrLighting:kAe,czm_pbrMetallicRoughnessMaterial:GAe,czm_pbrSpecularGlossinessMaterial:WAe,czm_phong:jAe,czm_planeDistance:qAe,czm_pointAlongRay: $ Ae,czm_rayEllipsoidIntersectionInterval:YAe,czm_raySphereIntersectionInterval:XAe,czm_readDepth:KAe,czm_readNonPerspective:JAe,czm_reverseLogDepth:QAe,czm_round:ZAe,czm_sampleOctahedralProjection:ebe,czm_saturation:tbe,czm_shadowDepthCompare:nbe,czm_shadowVisibility:ibe,czm_signNotZero:obe,czm_sphericalHarmonics:rbe,czm_srgbToLinear:sbe,czm_tangentToEyeSpaceMatrix:abe,czm_transformPlane:cbe,czm_translateRelativeToEye:lbe,czm_translucentPhong:ube,czm_transpose:fbe,czm_unpackDepth:dbe,czm_unpackFloat:hbe,czm_unpackUint:pbe,czm_valueTransform:mbe,czm_vertexLogDepth:_be,czm_windowToEyeCoordinates:gbe,czm_writeDepthClamp:ybe,czm_writeLogDepth:Abe,czm_writeNonPerspective:bbe};function Zj(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 eq(e,t,n){let i;for(let o=0;o<n.length;++o)n[o].name===e&&(i=n[o]);return l(i)||(t=Zj(t),i={name:e,glslSource:t,dependsOn:[],requiredBy:[],evaluated:!1},n.push(i)),i}function tq(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&&We._czmBuiltinsAndUniforms.hasOwnProperty(i)){const o=eq(i,We._czmBuiltinsAndUniforms[i],t);e.dependsOn.push(o),o.requiredBy.push(e),tq(o,t)}}))}function Cbe(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 :
2023-02-06 08:55:59 +00:00
` ;for(let r=0;r<i.length;++r)o= ` $ { o + i [ r ] . name }
2023-02-13 02:05:23 +00:00
` ;throw new x(o)}}function Tbe(e){const t=[],n=eq("main",e,t);tq(n,t),Cbe(t);let i="";for(let o=t.length-1;o>=0;--o)i= ` $ { i + t [ o ] . glslSource }
` ;return i.replace(n.glslSource,"")}function nq(e,t,n){let i,o,r="";const s=e.sources;if(l(s))for(i=0,o=s.length;i<o;++i)r+= `
2023-02-06 08:55:59 +00:00
# line 0
2023-02-13 02:05:23 +00:00
$ { s [ i ] } ` ;r=Zj(r);let a;r=r.replace(/#version \s +(.*?) \n /gm,function(g,p){if(l(a)&&a!==p)throw new x( ` inconsistent versions found : $ { a } and $ { p } ` );return a=p, `
2023-02-06 08:55:59 +00:00
` });const c=[];r=r.replace(/#extension.* \n /gm,function(g){return c.push(g), `
2023-02-07 08:44:46 +00:00
` }),r=r.replace(/precision \s (lowp|mediump|highp) \s (float|int);/,"");const u=e.pickColorQualifier;l(u)&&(r=We.createPickFragmentShaderSource(r,u));let f="";l(a)&&(f= ` # version $ { a }
2023-02-06 08:55:59 +00:00
` );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
2023-02-13 02:05:23 +00:00
` );const m=e.defines;if(l(m))for(i=0,o=m.length;i<o;++i){const g=m[i];g.length!==0&&(f+= ` # define $ { g }
2023-02-06 08:55:59 +00:00
` )}return n.webgl2&&(f+= ` # define OUTPUT _DECLARATION
` ),n.textureFloatLinear&&(f+= ` # define OES _texture _float _linear
` ),n.floatingPointTexture&&(f+= ` # define OES _texture _float
2023-02-13 02:05:23 +00:00
` ),e.includeBuiltIns&&(f+=Tbe(r)),f+= `
2023-02-06 08:55:59 +00:00
# line 0
2023-02-13 02:05:23 +00:00
` ,f+=r,n.webgl2&&(f=Yye(f,t)),f}function We(e){e=A(e,A.EMPTY_OBJECT);const t=e.pickColorQualifier;if(l(t)&&t!=="uniform"&&t!=="varying")throw new x("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=A(e.includeBuiltIns,!0)}We.prototype.clone=function(){return new We({sources:this.sources,defines:this.defines,pickColorQualifier:this.pickColorQualifier,includeBuiltIns:this.includeBuiltIns})};We.replaceMain=function(e,t){return t= ` void $ { t } ( ) ` ,e.replace(/void \s +main \s * \( \s *(?:void)? \s * \) /g,t)};We.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 } ` };We.prototype.createCombinedVertexShader=function(e){return nq(this,!1,e)};We.prototype.createCombinedFragmentShader=function(e){return nq(this,!0,e)};We._czmBuiltinsAndUniforms={};for(const e in r1)r1.hasOwnProperty(e)&&(We._czmBuiltinsAndUniforms[e]=r1[e]);for(const e in yw)if(yw.hasOwnProperty(e)){const t=yw[e];typeof t.getDeclaration=="function"&&(We._czmBuiltinsAndUniforms[e]=t.getDeclaration(e))}We.createPickVertexShaderSource=function(e){return ` $ { We . replaceMain ( e , "czm_old_main" ) }
2023-02-06 08:55:59 +00:00
attribute vec4 pickColor ;
varying vec4 czm _pickColor ;
void main ( )
{
czm _old _main ( ) ;
czm _pickColor = pickColor ;
2023-02-07 08:44:46 +00:00
} ` };We.createPickFragmentShaderSource=function(e,t){const n=We.replaceMain(e,"czm_old_main"),i= ` $ { t } vec4 czm _pickColor ;
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _old _main ( ) ;
if ( gl _FragColor . a == 0.0 ) {
discard ;
}
gl _FragColor = czm _pickColor ;
} ` ;return ` $ { n }
2023-02-13 02:05:23 +00:00
$ { i } ` };function Ebe(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 iq(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 oq(e,t){const n=t.length;for(let i=0;i<n;++i){const o=t[i];if(iq(e,o))return o}}const xbe=["v_normalEC","v_normal"];We.findNormalVarying=function(e){return iq(e,"#ifdef HAS_NORMALS")?Ebe(e,"HAS_NORMALS")?"v_normalEC":void 0:oq(e,xbe)};const wbe=["v_positionEC"];We.findPositionVarying=function(e){return oq(e,wbe)};function yu(e){this._context=e,this._shaders={},this._numberOfShaders=0,this._shadersToRelease={}}Object.defineProperties(yu.prototype,{numberOfShaders:{get:function(){return this._numberOfShaders}}});yu.prototype.replaceShaderProgram=function(e){return l(e.shaderProgram)&&e.shaderProgram.destroy(),this.getShaderProgram(e)};function Sbe(e){const t=Object.keys(e).sort();return JSON.stringify(e,t)}yu.prototype.getShaderProgram=function(e){let t=e.vertexShaderSource,n=e.fragmentShaderSource;const i=e.attributeLocations;typeof t=="string"&&(t=new We({sources:[t]})),typeof n=="string"&&(n=new We({sources:[n]}));const o=t.getCacheKey(),r=n.getCacheKey(),s=l(i)?Sbe(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),m=new yn({gl:u._gl,logShaderCompilation:u.logShaderCompilation,debugShaders:u.debugShaders,vertexShaderSource:t,vertexShaderText:f,fragmentShaderSource:n,fragmentShaderText:h,attributeLocations:i});c={cache:this,shaderProgram:m,keyword:a,derivedKeywords:[],count:0},m._cachedShader=c,this._shaders[a]=c,++this._numberOfShaders}return++c.count,c.shaderProgram};yu.prototype.replaceDerivedShaderProgram=function(e,t,n){const i=e._cachedShader,o=t+i.keyword,r=this._shaders[o];if(l(r)){eM(this,r);const s=i.derivedKeywords.indexOf(t);s>-1&&i.derivedKeywords.splice(s,1)}return this.createDerivedShaderProgram(e,t,n)};yu.prototype.getDerivedShaderProgram=function(e,t){const n=e._cachedShader,i=t+n.keyword,o=this._shaders[i];if(l(o))return o.shaderProgram};yu.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 We({sources:[r]})),typeof s=="string"&&(s=new We({sources:[s]}));const c=this._context,u=r.createCombinedVertexShader(c),f=s.createCombinedFragmentShader(c),h=new yn({gl:c._gl,logShaderCompilation:c.logShaderCompilation,debugShaders:c.debugShaders,vertexShaderSource:r,vertexShaderText:u,fragmentShaderSource:s,fragmentShaderText:f,attributeLocations:a}),m={cache:this,shaderProgram:h,keyword:o,derivedKeywords:[],count:0};return i.derivedKeywords.push(t),h._cachedShader=m,this._shaders[o]=m,h};function eM(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];eM(e,s)}delete e._shaders[t.keyword],t.shaderProgram.finalDestroy()}yu.prototype.destroyReleasedShaderPrograms=function(){const e=this._shadersToRelease;for(const t in e)if(e.hasOwnProperty(t)){const n=e[t];eM(this,n),--this._numberOfShaders}this._shadersToRelease={}};yu.prototype.releaseShaderProgram=function(e){if(l(e)){const t=e._cachedShader;t&&--t.count===0&&(this._shadersToRelease[t.keyword]=t)}};yu.prototype.isDestroyed=function(){return!1};yu.prototype.destroy=function(){const e=this._shaders;for(const t in e)e.hasOwnProperty(t)&&e[t].shaderProgram.finalDestroy();return He(this)};function kt(e){e=A(e,A.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=A(o.videoWidth,o.width)),l(i)||(i=A(o.videoHeight,o.height)));const r=A(e.pixelFormat,rt.RGBA),s=A(e.pixelDatatype,Je.UNSIGNED_BYTE),a=rt.toInternalFormat(r,s,t),c=rt.isCompressedFormat(a);if(!l(n)||!l(i))throw new x("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
2023-02-07 08:44:46 +00:00
` ),r=new We({defines:this._vertexShaderParts.defineLines,sources:[o]}),s=this._fragmentShaderParts.uniformLines.concat(this._fragmentShaderParts.varyingLines,n.fragmentLines,i.fragmentLines,this._fragmentShaderParts.shaderLines).join( `
2023-02-13 02:05:23 +00:00
` ),a=new We({defines:this._fragmentShaderParts.defineLines,sources:[s]});return yn.fromCache({context:e,vertexShaderSource:r,fragmentShaderSource:a,attributeLocations:this._attributeLocations})};ha.prototype.clone=function(){return dt(this,!0)};function wTe(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 STe(e){switch(e){case"mat2":return 2;case"mat3":return 3;case"mat4":return 4;default:return 1}}function vTe(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 Br(e,t,n,i){if(T.defined("context",e),!t||t.length===0)throw new x("At least one attribute is required.");const o=Br._verifyAttributes(t);n=A(n,0);const r=[],s={};let a,c;const u=o.length;for(let h=0;h<u;++h){const m=o[h];if(m.vertexBuffer){r.push(m);continue}c=m.usage,a=s[c],l(a)||(a=s[c]=[]),a.push(m)}function f(h,m){return ee.getSizeInBytes(m.componentDatatype)-ee.getSizeInBytes(h.componentDatatype)}this._allBuffers=[];for(c in s)if(s.hasOwnProperty(c)){a=s[c],a.sort(f);const h=Br._vertexSizeInBytes(a),m=a[0].usage,g={vertexSizeInBytes:h,vertexBuffer:void 0,usage:m,needsCommit:!1,arrayBuffer:void 0,arrayViews:Br._createArrayViews(a,h)};this._allBuffers.push(g)}this._size=0,this._instanced=A(i,!1),this._precreated=r,this._context=e,this.writers=void 0,this.va=void 0,this.resize(n)}Br._verifyAttributes=function(e){const t=[];for(let i=0;i<e.length;++i){const o=e[i],r={index:A(o.index,i),enabled:A(o.enabled,!0),componentsPerAttribute:o.componentsPerAttribute,componentDatatype:A(o.componentDatatype,ee.FLOAT),normalize:A(o.normalize,!1),vertexBuffer:o.vertexBuffer,usage:A(o.usage,tt.STATIC_DRAW)};if(t.push(r),r.componentsPerAttribute!==1&&r.componentsPerAttribute!==2&&r.componentsPerAttribute!==3&&r.componentsPerAttribute!==4)throw new x("attribute.componentsPerAttribute must be in the range [1, 4].");const s=r.componentDatatype;if(!ee.validate(s))throw new x("Attribute must have a valid componentDatatype or not specify it.");if(!tt.validate(r.usage))throw new x("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 x( ` Index $ { r } is used by more than one attribute . ` );n[r]=!0}return t};Br._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};Br._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};Br.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];Br._resize(o,this._size),Br._appendWriters(this.writers,o)}aM(this)};Br._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 DTe=[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
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,RS= ` uniform vec3 u _radiiAndDynamicAtmosphereColor ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,LTe= ` # ifdef GL _OES _standard _derivatives
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,BTe= ` # ifdef INSTANCED
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,RTe= ` varying vec2 v _textureCoordinates ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,NTe= ` uniform sampler2D u _opaqueDepthTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,MTe= ` / * *
2023-02-06 08:55:59 +00:00
* 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 ;
}
}
2023-02-13 02:05:23 +00:00
` ,FTe= ` varying vec4 positionEC ;
2023-02-06 08:55:59 +00:00
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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,zTe= ` attribute vec4 position ;
2023-02-06 08:55:59 +00:00
varying vec4 positionEC ;
void main ( )
{
positionEC = czm _modelView * position ;
gl _Position = czm _projection * positionEC ;
czm _vertexLogDepth ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,FU= ` # ifdef WRITE _DEPTH
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,zU= ` attribute vec3 position ;
2023-02-06 08:55:59 +00:00
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 .
2023-02-13 02:05:23 +00:00
* /const UTe=`/ * *
2023-02-06 08:55:59 +00:00
* @ 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,HTe= ` uniform vec4 u _initialColor ;
2023-02-06 08:55:59 +00:00
# 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
2023-02-13 02:05:23 +00:00
` ,VTe= ` # ifdef QUANTIZATION _BITS12
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,UU= ` void computeAtmosphereScattering ( vec3 positionWC , vec3 lightDirection , out vec3 rayleighColor , out vec3 mieColor , out float opacity ) {
2023-02-06 08:55:59 +00:00
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
) ;
}
2023-02-13 02:05:23 +00:00
` ,kTe= ` varying vec2 v _textureCoordinates ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
}
2023-02-13 02:05:23 +00:00
` ,GTe= ` varying vec3 v _cubeMapCoordinates ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,WTe= ` attribute vec4 position ;
2023-02-06 08:55:59 +00:00
attribute vec3 cubeMapCoordinates ;
varying vec3 v _cubeMapCoordinates ;
void main ( )
{
gl _Position = position ;
v _cubeMapCoordinates = cubeMapCoordinates ;
}
2023-02-13 02:05:23 +00:00
` ,DE= ` varying vec4 v _color ;
2023-02-06 08:55:59 +00:00
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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,jTe= ` uniform float u _maxTotalPointSize ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,nT= ` void clipLineSegmentToNearPlane (
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,pq= ` # ifdef VECTOR _TILE
2023-02-06 08:55:59 +00:00
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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,qTe= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# 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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` , $ Te= ` varying vec3 v _forwardDirectionEC ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,YTe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,XTe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,KTe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,JTe= ` uniform sampler2D u _texture ;
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( u _texture , v _textureCoordinates ) ;
}
2023-02-13 02:05:23 +00:00
` ,QTe= ` attribute vec4 position ;
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,mq= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,ZTe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,iB= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# 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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,HU= ` float interpolateByDistance ( vec4 nearFarScalar , float distance )
2023-02-06 08:55:59 +00:00
{
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,eEe= ` varying vec3 v _outerPositionWC ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,tEe= ` attribute vec4 position ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,nEe= ` uniform samplerCube u _cubeMap ;
2023-02-06 08:55:59 +00:00
varying vec3 v _texCoord ;
void main ( )
{
vec4 color = textureCube ( u _cubeMap , normalize ( v _texCoord ) ) ;
gl _FragColor = vec4 ( czm _gammaCorrect ( color ) . rgb , czm _morphTime ) ;
}
2023-02-13 02:05:23 +00:00
` ,iEe= ` attribute vec3 position ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,oEe= ` uniform sampler2D u _texture ;
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
vec4 color = texture2D ( u _texture , v _textureCoordinates ) ;
gl _FragColor = czm _gammaCorrect ( color ) ;
}
2023-02-13 02:05:23 +00:00
` ,rEe= ` uniform float u _radiusTS ;
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ,sEe= ` attribute vec2 direction ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,aEe= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# 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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,cEe= ` attribute vec3 startEllipsoidNormal ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,lEe= ` attribute vec4 currentPosition ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,VU= ` attribute vec3 position ;
2023-02-06 08:55:59 +00:00
attribute float a _batchId ;
uniform mat4 u _modifiedModelViewProjection ;
void main ( )
{
gl _Position = czm _depthClamp ( u _modifiedModelViewProjection * vec4 ( position , 1.0 ) ) ;
}
2023-02-13 02:05:23 +00:00
` ;/*! @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 jh(e){return jh=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},jh(e)}function oB(e,t){return oB=Object.setPrototypeOf||function(i,o){return i.__proto__=o,i},oB(e,t)}function uEe(){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 vw(e,t,n){return uEe()?vw=Reflect.construct:vw=function(o,r,s){var a=[null];a.push.apply(a,r);var c=Function.bind.apply(o,a),u=new c;return s&&oB(u,s.prototype),u},vw.apply(null,arguments)}function Ml(e){return fEe(e)||dEe(e)||hEe(e)||pEe()}function fEe(e){if(Array.isArray(e))return rB(e)}function dEe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function hEe(e,t){if(e){if(typeof e=="string")return rB(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 rB(e,t)}}function rB(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 pEe(){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 mEe=Object.hasOwnProperty,kU=Object.setPrototypeOf,_Ee=Object.isFrozen,gEe=Object.getPrototypeOf,yEe=Object.getOwnPropertyDescriptor,Pa=Object.freeze,au=Object.seal,AEe=Object.create,_q=typeof Reflect<"u"&&Reflect,NS=_q.apply,sB=_q.construct;NS||(NS=function(t,n,i){return t.apply(n,i)});Pa||(Pa=function(t){return t});au||(au=function(t){return t});sB||(sB=function(t,n){return vw(t,Ml(n))});var bEe=dl(Array.prototype.forEach),GU=dl(Array.prototype.pop),oA=dl(Array.prototype.push),Dw=dl(String.prototype.toLowerCase),l1=dl(String.prototype.toString),CEe=dl(String.prototype.match),Il=dl(String.prototype.replace),TEe=dl(String.prototype.indexOf),EEe=dl(String.prototype.trim),ya=dl(RegExp.prototype.test),u1=xEe(TypeError);function dl(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 NS(e,t,i)}}function xEe(e){return function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return sB(e,n)}}function jn(e,t,n){n=n||Dw,kU&&kU(e,null);for(var i=t.length;i--;){var o=t[i];if(typeof o=="string"){var r=n(o);r!==o&&(_Ee(t)||(t[i]=r),o=r)}e[o]=!0}return e}function um(e){var t=AEe(null),n;for(n in e)NS(mEe,e,[n])&&(t[n]=e[n]);return t}function IE(e,t){for(;e!==null;){var n=yEe(e,t);if(n){if(n.get)return dl(n.get);if(typeof n.value=="function")return dl(n.value)}e=gEe(e)}function i(o){return console.warn("fallback value for",o),null}return i}var WU=Pa(["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"]),f1=Pa(["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"]),d1=Pa(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),wEe=Pa(["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"]),h1=Pa(["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"]),SEe=Pa(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),jU=Pa(["#text"]),qU=Pa(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked",
` +Lo),Q&&(Lo=Il(Lo,D," "),Lo=Il(Lo,O," "),Lo=Il(Lo,N," ")),S&&Le?S.createHTML(Lo):Lo},t.setConfig=function(Ct){ai(Ct),fe=!0},t.clearConfig=function(){zi=null,fe=!1},t.isValidAttribute=function(Ct,we,qe){zi||ai({});var ot=rn(Ct),Kn=rn(we);return Zi(ot,Kn,qe)},t.addHook=function(Ct,we){typeof we=="function"&&(_[Ct]=_[Ct]||[],oA(_[Ct],we))},t.removeHook=function(Ct){if(_[Ct])return GU(_[Ct])},t.removeHooks=function(Ct){_[Ct]&&(_[Ct]=[])},t.removeAllHooks=function(){_={}},t}var zEe=gq();let UEe=0;const m1={};function si(e,t){T.typeOf.string("html",e);let n;const i=e;l(m1[i])?n=m1[i]:(n=UEe++,m1[i]=n),t=A(t,!1),this._id=n,this._html=e,this._showOnScreen=t,this._element=void 0}Object.defineProperties(si.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=zEe.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}}});si.equals=function(e,t){return e===t||l(e)&&l(t)&&e._id===t._id&&e._showOnScreen===t._showOnScreen};si.prototype.equals=function(e){return si.equals(this,e)};si.getIonCredit=function(e){const t=l(e.collapsible)&&!e.collapsible,n=new si(e.html,t);return n._isIon=n.html.indexOf("ion-credit.png")!==-1,n};si.clone=function(e){if(l(e))return new si(e.html,e.showOnScreen)};let _1;const yq="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyZTlhMmUzMS1iZjI3LTRhMmQtYjFkZi02MDhlMDZjZDlmNDIiLCJpZCI6MjU5LCJpYXQiOjE2NzI2ODQyMDR9.GfS2oIjtP-hkhYm4g_Y6Vvpdp954z30qPWJnlNBF-co",Qv={};Qv.defaultAccessToken=yq;Qv.defaultServer=new Me({url:"https://api.cesium.com/"});Qv.getDefaultTokenCredit=function(e){if(e===yq){if(!l(_1)){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>`;_1=new si(t,!0)}return _1}};const a_=Qv;function us(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:HEe};else if(i===" 3 DTILES "||i===" STK _TERRAIN _SERVER ")n={url:e.options.url};else throw new Ie(" Ion . createResource does not support external imagery assets ; use IonImageryProvider instead . " ) ; Me . call ( this , n ) , this . _ionEndpoint = e , this . _ionEndpointDomain = o ? void 0 : new Ps ( e . url ) . authority ( ) , this . _ionEndpointResource = t , this . _ionRoot = void 0 , this . _pendingPromise = void 0 , this . _credits = void 0 , this . _isExternal = o } l ( Object . create ) && ( us . prototype = Object . create ( Me . prototype ) , us . prototype . constructor = us ) ; us . fromAssetId = function ( e , t ) { const n = us . _createEndpointResource ( e , t ) ; return n . fetchJson ( ) . then ( function ( i ) { return new us ( i , n ) } ) } ; Object . defineProperties ( us . prototype , { credits : { get : function ( ) { return l ( this . _ionRoot ) ? this . _ionRoot . credits : l ( this . _credits ) ? this . _credits : ( this . _credits = us . getCreditsFromEndpoint ( this . _ionEndpoint , this . _ionEndpointResource ) , this . _credits ) } } } ) ; us . getCreditsFromEndpoint = function ( e , t ) { const n = e . attributions . map ( si . getIonCredit ) , i = a _ . getDefaultTokenCredit ( t . queryParameters . access _token ) ; return l ( i ) && n . push ( si . clone ( i ) ) , n } ; us . prototype . clone = function ( e ) { const t = A ( this . _ionRoot , this ) ; return l ( e ) || ( e = new us ( t . _ionEndpoint , t . _ionEndpointResource ) ) , e = Me . prototype . clone . call ( this , e ) , e . _ionRoot = t , e . _isExternal = this . _isExternal , e } ; us . prototype . fetchImage = function ( e ) { if ( ! this . _isExternal ) { const t = e ; e = { preferBlob : ! 0 } , l ( t ) && ( e . flipY = t . flipY , e . preferImageBitmap = t . preferImageBitmap ) } return Me . prototype . fetchImage . call ( this , e ) } ; us . prototype . _makeRequest = function ( e ) { return this . _isExternal || new Ps ( this . url ) . authority ( ) !== this . _ionEndpointDomain ? Me . prototype . _makeRequest . call ( this , e ) : ( l ( e . headers ) || ( e . headers = { } ) , e . headers . Author
$ { o } ` ),t}function so(e,t,n,i,o,r,s){this.provider=e,this.message=t,this.x=n,this.y=i,this.level=o,this.timesRetried=A(r,0),this.retry=!1,this.error=s}so.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 so(t,i,o,r,s,0,a),n.numberOfListeners>0?n.raiseEvent(c):console.log( ` An error occurred in "${t.constructor.name}" : $ { aB ( i ) } ` ),c};so.reportSuccess=function(e){l(e)&&(e.timesRetried=-1)};function li(e){this._ellipsoid=A(e,me.WGS84),this._semimajorAxis=this._ellipsoid.maximumRadius,this._oneOverSemimajorAxis=1/this._semimajorAxis}Object.defineProperties(li.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});li.mercatorAngleToGeodeticLatitude=function(e){return M.PI_OVER_TWO-2*Math.atan(Math.exp(-e))};li.geodeticLatitudeToMercatorAngle=function(e){e>li.MaximumLatitude?e=li.MaximumLatitude:e<-li.MaximumLatitude&&(e=-li.MaximumLatitude);const t=Math.sin(e);return .5*Math.log((1+t)/(1-t))};li.MaximumLatitude=li.mercatorAngleToGeodeticLatitude(Math.PI);li.prototype.project=function(e,t){const n=this._semimajorAxis,i=e.longitude*n,o=li.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)};li.prototype.unproject=function(e,t){if(!l(e))throw new x("cartesian is required");const n=this._oneOverSemimajorAxis,i=e.x*n,o=li.mercatorAngleToGeodeticLatitude(e.y*n),r=e.z;return l(t)?(t.longitude=i,t.latitude=o,t.height=r,t):new Ce(i,o,r)};function pa(e){if(e=A(e,A.EMPTY_OBJECT),this._ellipsoid=A(e.ellipsoid,me.WGS84),this._numberOfLevelZeroTilesX=A(e.numberOfLevelZeroTilesX,1),this._numberOfLevelZeroTilesY=A(e.numberOfLevelZeroTilesY,1),this._projection=new li(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 ge(t.longitude,t.latitude,n.longitude,n.latitude)}Object.defineProperties(pa.prototype,{ellipsoid:{get:function(){return this._ellipsoid}},rectangle:{get:function(){return this._rectangle}},projection:{get:function(){return this._projection}}});pa.prototype.getNumberOfXTilesAtLevel=function(e){return this._numberOfLevelZeroTilesX<<e};pa.prototype.getNumberOfYTilesAtLevel=function(e){return this._numberOfLevelZeroTilesY<<e};pa.prototype.rectangleToNativeRectangle=function(e,t){const n=this._projection,i=n.project(ge.southwest(e)),o=n.project(ge.northeast(e));return l(t)?(t.west=i.x,t.south=i.y,t.east=o.x,t.north=o.y,t):new ge(i.x,i.y,o.x,o.y)};pa.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 ge(a,h,c,f)};pa.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};pa.prototype.positionToTileXY=function(e,t,n){const i=this._rectangle;if(!ge.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),m=h.x-this._rectangleSouthwestInMeters.x,g=this._rectangle
` ,c+=n?YSe(i):XSe(i),c}function YSe(e){return ` float clip ( vec4 fragCoord , sampler2D clippingPlanes , mat4 clippingPlanesMatrix )
2023-02-06 08:55:59 +00:00
{
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 ;
}
2023-02-13 02:05:23 +00:00
` }function XSe(e){return ` float clip ( vec4 fragCoord , sampler2D clippingPlanes , mat4 clippingPlanesMatrix )
2023-02-06 08:55:59 +00:00
{
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 ;
}
2023-02-13 02:05:23 +00:00
` }function KSe(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 )
2023-02-06 08:55:59 +00:00
{
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 ) ;
}
2023-02-13 02:05:23 +00:00
` }function JSe(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 )
2023-02-06 08:55:59 +00:00
{
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 ) ;
}
2023-02-13 02:05:23 +00:00
` }function QSe(e,t,n,i,o){this.numberOfDayTextures=e,this.flags=t,this.material=n,this.shaderProgram=i,this.clippingShaderState=o}function DM(){this.baseVertexShaderSource=void 0,this.baseFragmentShaderSource=void 0,this._shadersByTexturesFlags=[],this.material=void 0}function ZSe(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 eve(e){return e?"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DMercatorYPositionFraction(textureCoordinates); }":"float get2DYPositionFraction(vec2 textureCoordinates) { return get2DGeographicYPositionFraction(textureCoordinates); }"}DM.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,m=e.showReflectiveOcean,g=e.showOceanWaves,p=e.enableLighting,y=e.dynamicAtmosphereLighting,b=e.dynamicAtmosphereLightingFromSun,C=e.showGroundAtmosphere,E=e.perFragmentGroundAtmosphere,w=e.hasVertexNormals,S=e.useWebMercatorProjection,P=e.enableFog,L=e.enableClippingPlanes,z=e.clippingPlanes,R=e.clippedByBoundaries,F=e.hasImageryLayerCutout,U=e.colorCorrect,v=e.highlightFillTile,I=e.colorToAlpha,_=e.hasGeodeticSurfaceNormals,D=e.hasExaggeration,O=e.showUndergroundColor,N=e.translucent;let V=0,k="";const W=n.renderedMesh.encoding;W.quantization===uc.BITS12&&(V=1,k="QUANTIZATION_BITS12");let q=0,te="";R&&(q=1,te="TILE_LIMIT_RECTANGLE");let Y=0,X="";F&&(Y=1,X="APPLY_IMAGERY_CUTOUT");const $ =t.mode,se= $ |o<<2|r<<3|s<<4|a<<5|c<<6|u<<7|m<<8|g<<9|p<<10|y<<11|b<<12|C<<13|E<<14|w<<15|S<<16|P<<17|V<<18|h<<19|L<<20|q<<21|Y<<22|U<<23|v<<24|I<<25|_<<26|D<<27|O<<28|N<<29|f<<30;let ue=0;l(z)&&z.length>0&&(ue=L?z.clippingPlanesState:0);let re=n.surfaceShader;if(l(re)&&re.numberOfDayTextures===i&&re.flags===se&&re.material===this.material&&re.clippingShaderState===ue)return re.shaderProgram;let he=this._shadersByTexturesFlags[i];if(l(he)||(he=this._shadersByTexturesFlags[i]=[]),re=he[se],!l(re)||re.material!==this.material||re.clippingShaderState!==ue){const ce=this.baseVertexShaderSource.clone(),Q=this.baseFragmentShaderSource.clone();ue!==0&&Q.sources.unshift(vM(z,t.context)),ce.defines.push(k),Q.defines.push( ` TEXTURE _UNITS $ { i } ` ,te,X),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"),m&&(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")),N&&(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"))),y&&(ce.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),Q.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING"),b&&(ce.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"),Q.defines.push("DYNAMIC_ATMOSPHERE_LIGHTING_FROM_SUN"))),C&&(ce.defines.push("GROUND_ATMOSPHERE"),Q.defines.push("GROUND_ATMOSPHERE"),E&&(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
2023-02-06 08:55:59 +00:00
{
vec4 color = initialColor ;
2023-02-08 07:58:46 +00:00
` ;F&&(ne+= ` vec4 cutoutAndColorResult ;
2023-02-06 08:55:59 +00:00
bool texelUnclipped ;
2023-02-13 02:05:23 +00:00
` );for(let _e=0;_e<i;++_e)F?ne+= ` cutoutAndColorResult = u _dayTextureCutoutRectangles [ $ { _e } ] ;
2023-02-06 08:55:59 +00:00
texelUnclipped = v _textureCoordinates . x < cutoutAndColorResult . x || cutoutAndColorResult . z < v _textureCoordinates . x || v _textureCoordinates . y < cutoutAndColorResult . y || cutoutAndColorResult . w < v _textureCoordinates . y ;
cutoutAndColorResult = sampleAndBlend (
2023-02-07 08:44:46 +00:00
` :ne+= ` color = sampleAndBlend (
` ,ne+= ` color ,
2023-02-13 02:05:23 +00:00
u _dayTextures [ $ { _e } ] ,
u _dayTextureUseWebMercatorT [ $ { _e } ] ? textureCoordinates . xz : textureCoordinates . xy ,
u _dayTextureTexCoordsRectangle [ $ { _e } ] ,
u _dayTextureTranslationAndScale [ $ { _e } ] ,
$ { u ? ` u_dayTextureAlpha[ ${ _e } ] ` : "1.0" } ,
$ { f ? ` u_dayTextureNightAlpha[ ${ _e } ] ` : "1.0" } ,
$ { f ? ` u_dayTextureDayAlpha[ ${ _e } ] ` : "1.0" } ,
$ { o ? ` u_dayTextureBrightness[ ${ _e } ] ` : "0.0" } ,
$ { r ? ` u_dayTextureContrast[ ${ _e } ] ` : "0.0" } ,
$ { s ? ` u_dayTextureHue[ ${ _e } ] ` : "0.0" } ,
$ { a ? ` u_dayTextureSaturation[ ${ _e } ] ` : "0.0" } ,
$ { c ? ` u_dayTextureOneOverGamma[ ${ _e } ] ` : "0.0" } ,
$ { h ? ` u_dayTextureSplit[ ${ _e } ] ` : "0.0" } ,
$ { I ? ` u_colorsToAlpha[ ${ _e } ] ` : "vec4(0.0)" } ,
2023-02-06 08:55:59 +00:00
nightBlend ) ;
2023-02-08 07:58:46 +00:00
` ,F&&(ne+= ` color = czm _branchFreeTernary ( texelUnclipped , cutoutAndColorResult , color ) ;
2023-02-07 08:44:46 +00:00
` );ne+= ` return color ;
2023-02-13 02:05:23 +00:00
} ` ,Q.sources.push(ne),ce.sources.push(ZSe( $ )),ce.sources.push(eve(S));const fe=yn.fromCache({context:t.context,vertexShaderSource:ce,fragmentShaderSource:Q,attributeLocations:W.getAttributeLocations()});re=he[se]=new QSe(i,se,this.material,fe,ue)}return n.surfaceShader=re,re.shaderProgram};DM.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 He(this)};function Ji(e){e=A(e,A.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 tve={NONE:0,TOP:1,ALL:2},mn=Object.freeze(tve),nve=new d;function Ac(e){e=A(e,A.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===mn.TOP)throw new x("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"}Ac.fromDimensions=function(e){e=A(e,A.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 Ac({minimum:d.negate(n,new d),maximum:n,offsetAttribute:e.offsetAttribute})};Ac.fromAxisAlignedBoundingBox=function(e){return T.typeOf.object("boundindBox",e),new Ac({minimum:e.minimum,maximum:e.maximum})};Ac.packedLength=2*d.packedLength+1;Ac.pack=function(e,t,n){return T.typeOf.object("value",e),T.defined("array",t),n=A(n,0),d.pack(e._min,t,n),d.pack(e._max,t,n+d.packedLength),t[n+d.packedLength*2]=A(e._offsetAttribute,-1),t};const o7=new d,r7=new d,b4={minimum:o7,maximum:r7,offsetAttribute:void 0};Ac.unpack=function(e,t,n){T.defined("array",e),t=A(t,0);const i=d.unpack(e,t,o7),o=d.unpack(e,t+d.packedLength,r7),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):(b4.offsetAttribute=r===-1?void 0:r,new Ac(b4))};Ac.createGeometry=function(e){const t=e._min,n=e._max;if(d.equals(t,n))return;const i=new Ji,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 Ue({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,nve),a=d.magnitude(s)*.5;if(l(e._offsetAttribute)){const c=r.length,u=e._offsetAttribute===mn.NONE?0:1,f=new Uint8Array(c/3).fill(u);i.applyOffset=new Ue({componentDatatype:ee.UNSIGNED_BYTE,componentsPerAttribute:1,values:f})}return new Lt({attributes:i,indices:o,primitiveType:Qe.LINES,boundingSphere:new de(d.ZERO,a),offsetAttribute:e._offsetAttribute})};function fn(e,t,n,i){e=A(e,1),t=A(t,1),n=A(n,1),i=A(i,1),this.value=new Uint8Array([H.floatToByte(e),H.floatToByte(t),H.floatToByte(n),H.floatToByte(i)])}Object.defineProperties(fn.prototype,{componentDatatype:{get:function(){return ee.UNSIGNED_BYTE}},componentsPerAttribute:{get:function(){return 4}},normalize:{get:function(){return!0}}});fn.fromColor=function(e){if(!l(e))throw new x("color is required.");return new fn(e.red,e.green,e.blue,e.alpha)};fn.toValue=function(e,t){if(!l(e))throw new x("color is required.");return l(t)?e.toBytes(t):new Uint8Array(e.toBytes())};fn.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 an(e){if(e=A(e,A.EMPTY_OBJECT),!l(e.geometry))throw new x(
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,uDe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,_7= ` varying vec4 v _color ;
2023-02-06 08:55:59 +00:00
void main ( )
{
gl _FragColor = czm _gammaCorrect ( v _color ) ;
}
2023-02-13 02:05:23 +00:00
` ,fDe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,dDe={FRONT:ae.FRONT,BACK:ae.BACK,FRONT_AND_BACK:ae.FRONT_AND_BACK},Ho=Object.freeze(dDe);function Tr(e){e=A(e,A.EMPTY_OBJECT),this.material=e.material,this.translucent=A(e.translucent,!0),this._vertexShaderSource=e.vertexShaderSource,this._fragmentShaderSource=e.fragmentShaderSource,this._renderState=e.renderState,this._closed=A(e.closed,!1)}Object.defineProperties(Tr.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}}});Tr.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( `
` )};Tr.prototype.isTranslucent=function(){return l(this.material)&&this.material.isTranslucent()||!l(this.material)&&this.translucent};Tr.prototype.getRenderState=function(){const e=this.isTranslucent(),t=dt(this.renderState,!1);return e?(t.depthMask=!1,t.blending=Gi.ALPHA_BLEND):t.depthMask=!0,t};Tr.getDefaultRenderState=function(e,t,n){let i={depthTest:{enabled:!0}};return e&&(i.depthMask=!1,i.blending=Gi.ALPHA_BLEND),t&&(i.cull={enabled:!0,face:Ho.BACK}),l(n)&&(i=un(n,i,!0)),i};function Tn(e){e=A(e,A.EMPTY_OBJECT);const t=A(e.translucent,!0),n=A(e.closed,!1),i=A(e.flat,!1),o=i?fDe:uDe,r=i?_7:lDe,s=i?Tn.FLAT_VERTEX_FORMAT:Tn.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=A(e.vertexShaderSource,o),this._fragmentShaderSource=A(e.fragmentShaderSource,r),this._renderState=Tr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=s,this._flat=i,this._faceForward=A(e.faceForward,!n)}Object.defineProperties(Tn.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}}});Tn.VERTEX_FORMAT=Fe.POSITION_AND_NORMAL;Tn.FLAT_VERTEX_FORMAT=Fe.POSITION_ONLY;Tn.prototype.getFragmentShaderSource=Tr.prototype.getFragmentShaderSource;Tn.prototype.isTranslucent=Tr.prototype.isTranslucent;Tn.prototype.getRenderState=Tr.prototype.getRenderState;function hDe(e,t){if(!l(e))throw new x("array is required.");if(!l(t)||t<1)throw new x("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 Af(e,t,n){if(!l(e))throw new x("context is required");if(!l(t))throw new x("attributes is required");if(!l(n))throw new x("numberOfInstances is required");if(this._attributes=t,this._numberOfInstances=n,t.length===0)return;const i=pDe(t),o=e.floatingPointTexture,r=i===Je.FLOAT&&!o,s=mDe(t,r),a=_De(s,t,r),c=Math.floor(Dt.maximumTextureSize/a),u=Math.min(n,c),f=a*u,h=Math.ceil(n/u),m=1/f,g=m*.5,p=1/h,y=p*.5;this._textureDimensions=new j(f,h),this._textureStep=new oe(m,g,p,y),this._pixelDatatype=r?Je.UNSIGNED_BYTE:i,this._packFloats=r,this._offsets=s,this._stride=a,this._texture=void 0;const b=4*f*h;this._batchValues=i===Je.FLOAT&&!r?new Float32Array(b):new Uint8Array(b),this._batchValuesDirty=!1}Object.defineProperties(Af.prototype,{attributes:{get:function(){return this._attributes}},numberOfInstances:{get:function(){return this._numberOfInstances}}});function pDe(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?Je.FLOAT:Je.UNSIGNED_BYTE}function g7(e,t){const n=e[t].componentsPerAttribute;return n===2?j:n===3?d:n===4?oe:Number}function mDe(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 _De(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 JA=new oe;function gDe(e,t,n){let i=oe.unpack(e,t,JA);const o=oe.unpackFloat(i);i=oe.unpack(e,t+4,JA);const r=oe.unpackFloat(i);i=oe.unpack(e,t+8,JA);const s=oe.unpackFloat(i);i=oe.unpack(e,t+12,JA);const a=oe.unpackFloat(i);return oe.fromElements(o,r,s,a,n)}function yDe(e,t,n){let i=oe.packFloat(e.x,JA);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 z4=new oe;Af.prototype.getBatchedAttribute=function(e,t,n){if(e<0||e>=this._numberOfInstances)throw new x("instanceIndex is out of range.");if(t<0||t>=this._attributes.length)throw new x("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!==Je.UNSIGNED_BYTE?a=gDe(this._ba
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` }function xDe(e){return e===1?"float": ` vec$ { e } ` }function wDe(e){return e===1?".x":e===2?".xy":e===3?".xyz":""}function SDe(e,t){const i=e._attributes[t],o=i.componentsPerAttribute,r=i.functionName,s=xDe(o),a=wDe(o),c=e._offsets[t];let u= ` $ { s } $ { r } ( float batchId )
2023-02-06 08:55:59 +00:00
{
vec2 st = computeSt ( batchId ) ;
st . x += batchTextureStep . x * float ( $ { c } ) ;
` ;return e._packFloats&&i.componentDatatype!==Je.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===Je.UNSIGNED_BYTE&&i.componentDatatype===ee.UNSIGNED_BYTE&&!i.normalize?u+= ` value *= 255.0 ;
` :e._pixelDatatype===Je.FLOAT&&i.componentDatatype===ee.UNSIGNED_BYTE&&i.normalize&&(u+= ` value /= 255.0 ;
` ),u+= ` return value ;
}
2023-02-13 02:05:23 +00:00
` ,u}Af.prototype.getVertexShaderCallback=function(){const e=this._attributes;if(e.length===0)return function(i){return i};let t= ` uniform highp sampler2D batchTexture ;
` ;t+= ` $ { EDe ( this ) }
` ;const n=e.length;for(let i=0;i<n;++i)t+=SDe(this,i);return function(i){const o=i.indexOf("void main"),r=i.substring(0,o),s=i.substring(o);return ` $ { r }
2023-02-06 08:55:59 +00:00
$ { t }
2023-02-13 02:05:23 +00:00
$ { s } ` }};Af.prototype.isDestroyed=function(){return!1};Af.prototype.destroy=function(){return this._texture=this._texture&&this._texture.destroy(),He(this)};function jo(e,t,n){e=A(e,0),t=A(t,0),n=A(n,0),this.value=new Float32Array([e,t,n])}Object.defineProperties(jo.prototype,{componentDatatype:{get:function(){return ee.FLOAT}},componentsPerAttribute:{get:function(){return 3}},normalize:{get:function(){return!1}}});jo.fromCartesian3=function(e){return T.defined("offset",e),new jo(e.x,e.y,e.z)};jo.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 vDe(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)&&Yi.transformToWorldCoordinates(e[r]);else B.multiplyTransformation(t,e[0].modelMatrix,t)}function B1(e,t){const n=e.attributes,i=n.position,o=i.values.length/i.componentsPerAttribute;n.batchId=new Ue({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 DDe(e){const t=e.length;for(let n=0;n<t;++n){const i=e[n];l(i.geometry)?B1(i.geometry,n):l(i.westHemisphereGeometry)&&l(i.eastHemisphereGeometry)&&(B1(i.westHemisphereGeometry,n),B1(i.eastHemisphereGeometry,n))}}function IDe(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 x("All instance geometries must have the same primitiveType.");if(vDe(t,a,o),!o)for(c=0;c<h;++c)l(t[c].geometry)&&Yi.splitLongitude(t[c]);if(DDe(t),r)for(c=0;c<h;++c){const g=t[c];l(g.geometry)?(Yi.reorderForPostVertexCache(g.geometry),Yi.reorderForPreVertexCache(g.geometry)):l(g.westHemisphereGeometry)&&l(g.eastHemisphereGeometry)&&(Yi.reorderForPostVertexCache(g.westHemisphereGeometry),Yi.reorderForPreVertexCache(g.westHemisphereGeometry),Yi.reorderForPostVertexCache(g.eastHemisphereGeometry),Yi.reorderForPreVertexCache(g.eastHemisphereGeometry))}let m=Yi.combineInstances(t);for(h=m.length,c=0;c<h;++c){u=m[c];const g=u.attributes;if(o)for(const p in g)g.hasOwnProperty(p)&&g[p].componentDatatype===ee.DOUBLE&&Yi.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 y= ` $ { p } 3 D ` ,b= ` $ { p } 2 D ` ;Yi.projectTo2D(u,p,y,b,n),l(u.boundingSphere)&&p==="position"&&(u.boundingSphereCV=de.fromVertices(u.attributes.position2D.values)),Yi.encodeAttribute(u,y, ` $ { y } High ` , ` $ { y } Low ` ),Yi.encodeAttribute(u,b, ` $ { b } High ` , ` $ { b } Low ` )}s&&Yi.compressVertices(u)}if(!i){let g=[];for(h=m.length,c=0;c<h;++c)u=m[c],g=g.concat(Yi.fitToUnsignedShortIndices(u));m=g}return m}function R1(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 m=h.indices.length;o+m>r&&(o=0,r=n[++s].indices.length),i.push({index:s,offset:o,count:m}),o+=m}}function PDe(e,t){const n=[];return R1(e,"geometry",t,n),R1(e,"westHemisphereGeometry",t,n),R1(e,"eastHemisphereGeometry",t,n),n}const Id={};Id.combineGeometry=function(e){let t,n;const i=e.instances,o=i.length;let r,s,a=!1;o>0&&(t=IDe(e),t.length>0&&(n=Yi.createAttributeLocations(t[0]),e.createPickOffsets&&(r=PDe(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],m=h.geometry;l(m)&&(c[f]=m.boundingSphere,u[f]=m.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]=de.union(g.boundingSphere,p.boundingSphere)),l(g.boundingSphereCV)&&l(p.boundingSphereCV)&&(u[f]=de.union(g.boundingSphereCV,p.boundingSphere
2023-02-06 08:55:59 +00:00
` ),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( `
2023-02-13 02:05:23 +00:00
` )};Kt._appendShowToShader=function(e,t){return l(e._batchTableAttributeIndices.show)? ` $ { We . replaceMain ( t , "czm_non_show_main" ) }
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _non _show _main ( ) ;
gl _Position *= czm _batchTable _show ( batchId ) ;
2023-02-13 02:05:23 +00:00
} ` :t};Kt._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 x("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 V4(e){return ` $ { We . replaceMain ( e , "czm_non_pick_main" ) }
2023-02-06 08:55:59 +00:00
varying vec4 v _pickColor ;
void main ( )
{
czm _non _pick _main ( ) ;
v _pickColor = czm _batchTable _pickColor ( batchId ) ;
2023-02-13 02:05:23 +00:00
} ` }function k4(e){return ` varying vec4 v _pickColor ;
$ { e } ` }Kt._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};Kt._appendOffsetToShader=function(e,t){if(!l(e._batchTableAttributeIndices.offset))return t;let n= ` attribute float batchId ;
2023-02-06 08:55:59 +00:00
` ;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+= ` }
2023-02-13 02:05:23 +00:00
` ,i=i.replace(/vec4 \s +([A-Za-z0-9_]+) \s += \s +czm_computePosition \( \) ;/g,o),i};Kt._appendDistanceDisplayConditionToShader=function(e,t,n){if(!l(e._batchTableAttributeIndices.distanceDisplayCondition))return t;const i=We.replaceMain(t,"czm_non_distanceDisplayCondition_main");let o= ` void main ( )
2023-02-06 08:55:59 +00:00
{
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 }
2023-02-13 02:05:23 +00:00
$ { o } ` };function G4(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 ;
2023-02-06 08:55:59 +00:00
` ;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" } ) ;
2023-02-13 02:05:23 +00:00
` ));let m=t;m=m.replace(/attribute \s +vec3 \s +normal;/g,""),m=m.replace(/attribute \s +vec2 \s +st;/g,""),m=m.replace(/attribute \s +vec3 \s +tangent;/g,""),m=m.replace(/attribute \s +vec3 \s +bitangent;/g,""),m=We.replaceMain(m,"czm_non_compressed_main");const g= ` void main ( )
2023-02-06 08:55:59 +00:00
{
$ { h } czm _non _compressed _main ( ) ;
2023-02-13 02:05:23 +00:00
} ` ;return[u,f,m,g].join( `
` )}function jDe(e){let t=We.replaceMain(e,"czm_non_depth_clamp_main");return t+= ` void main ( ) {
2023-02-06 08:55:59 +00:00
czm _non _depth _clamp _main ( ) ;
gl _Position = czm _depthClamp ( gl _Position ) ; }
2023-02-13 02:05:23 +00:00
` ,t}function qDe(e){let t=We.replaceMain(e,"czm_non_depth_clamp_main");return t+= ` void main ( ) {
2023-02-06 08:55:59 +00:00
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
2023-02-13 02:05:23 +00:00
$ { t } ` ,t}function W4(e,t){const n=e.vertexAttributes;for(const i in n)if(n.hasOwnProperty(i)&&!l(t[i]))throw new x( ` 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 $ De(e,t){return function(){return e[t]}}const N1=Math.max(pn.hardwareConcurrency-1,1);let $ E;const YDe=new Vi("combineGeometry");function XDe(e,t){let n,i,o,r;const s=e._instanceIds;if(e._state===Dr.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 x("_workerName must be defined for asynchronous geometry.");u.push({moduleName:i._workerName,geometry:i})}if(!l( $ E))for( $ E=new Array(N1),o=0;o<N1;o++) $ E[o]=new Vi("createGeometry");let f;for(u=hDe(u,N1),o=0;o<u.length;o++){let h=0;const m=u[o],g=m.length;for(r=0;r<g;++r)f=m[r],i=f.geometry,l(i.constructor.pack)&&(f.offset=h,h+=A(i.constructor.packedLength,i.packedLength));let p;if(h>0){const y=new Float64Array(h);for(p=[y.buffer],r=0;r<g;++r)f=m[r],i=f.geometry,l(i.constructor.pack)&&(i.constructor.pack(i,y,f.offset),f.geometry=y)}c.push( $ E[o].scheduleTask({subTasks:u[o]},p))}e._state=Dr.CREATING,Promise.all(c).then(function(h){e._createGeometryResults=h,e._state=Dr.CREATED}).catch(function(h){Ib(e,t,Dr.FAILED,h)})}else if(e._state===Dr.CREATED){const a=[];n=Array.isArray(e.geometryInstances)?e.geometryInstances:[e.geometryInstances];const c=t.scene3DOnly,u=t.mapProjection,f=YDe.scheduleTask(gB.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=Dr.COMBINING,Promise.resolve(f).then(function(h){const m=gB.unpackCombineGeometryResults(h);e._geometries=m.geometries,e._attributeLocations=m.attributeLocations,e.modelMatrix=B.clone(m.modelMatrix,e.modelMatrix),e._pickOffsets=m.pickOffsets,e._offsetInstanceExtend=m.offsetInstanceExtend,e._instanceBoundingSpheres=m.boundingSpheres,e._instanceBoundingSpheresCV=m.boundingSpheresCV,l(e._geometries)&&e._geometries.length>0?(e._recomputeBoundingSpheres=!0,e._state=Dr.COMBINED):Ib(e,t,Dr.FAILED,void 0)}).catch(function(h){Ib(e,t,Dr.FAILED,h)})}}function KDe(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 m=s.geometry;let g;l(m.attributes)&&l(m.primitiveType)?g=kDe(m):g=m.constructor.createGeometry(m),o[c++]=GDe(s,g),r.push(s.id)}o.length=c;const u=t.scene3DOnly,f=t.mapProjection,h=gB.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=Dr.COMBINED):Ib(e,t,Dr.FAILED,void 0)}function JDe(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 de;e._tempBoundingSpheres=a}for(i=0;i<s;++i){let y=a[i];const b=e._batchTable.getBatchedAttribute(i,n,new d);y=r[i].clone
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,wPe= ` uniform sampler2D image ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,SPe= ` uniform vec4 lightColor ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,vPe= ` uniform vec4 lightColor ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,DPe= ` uniform sampler2D heights ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,IPe= ` # ifdef GL _OES _standard _derivatives
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,PPe= ` uniform sampler2D image ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,OPe= ` uniform vec4 fadeInColor ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,LPe= ` # ifdef GL _OES _standard _derivatives
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,BPe= ` uniform sampler2D image ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,RPe= ` # ifdef GL _OES _standard _derivatives
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,NPe= ` uniform vec4 color ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,MPe= ` uniform vec4 color ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,FPe= ` uniform vec4 color ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,zPe= ` uniform vec4 color ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,UPe= ` uniform sampler2D image ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,HPe= ` uniform vec4 evenColor ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,VPe= ` // Thanks for the contribution Jonas
2023-02-06 08:55:59 +00:00
// 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 ;
}
2023-02-13 02:05:23 +00:00
` ;function ze(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=A(e.minificationFilter,Sn.LINEAR),this._magnificationFilter=A(e.magnificationFilter,Xr.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,kPe(e,this),Object.defineProperties(this,{type:{value:this.type,writable:!1}}),l(ze._uniformList[this.type])||(ze._uniformList[this.type]=Object.keys(this._uniforms))}ze._uniformList={};ze.fromType=function(e,t){if(!l(ze._materialCache.getMaterial(e)))throw new x( ` material with type '${e}' does not exist . ` );const n=new ze({fabric:{type:e}});if(l(t))for(const i in t)t.hasOwnProperty(i)&&(n.uniforms[i]=t[i]);return n};ze.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};ze.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(y){return y.bufferView}),u=u[0]);const h=new ii({minificationFilter:this._minificationFilter,magnificationFilter:this._magnificationFilter});let m;l(u.internalFormat)?m=new kt({context:e,pixelFormat:u.internalFormat,width:u.width,height:u.height,source:{arrayBufferView:u.bufferView,mipLevels:f},sampler:h}):m=new kt({context:e,source:u,sampler:h});const g=this._textures[n];l(g)&&g!==this._defaultTexture&&g.destroy(),this._textures[n]=m;const p= ` $ { n } Dimensions ` ;if(this.uniforms.hasOwnProperty(p)){const y=this.uniforms[p];y.x=m._width,y.y=m._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 gu({context:e,source:{positiveX:u[0],negativeX:u[1],positiveY:u[2],negativeY:u[3],positiveZ:u[4],negativeZ:u[5]},sampler:new ii({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)};ze.prototype.isDestroyed=function(){return!1};ze.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 He(this)};function kPe(e,t){e=A(e,A.EMPTY_OBJECT),t._strict=A(e.strict,!1),t._count=A(e.count,0),t._template=dt(A(e.fabric,A.EMPTY_OBJECT)),t._template.uniforms=dt(A(t._template.uniforms,A.EMPTY_OBJECT)),t._template.materials=dt(A(t._template.materials,A.EMPTY_OBJECT)),t.type=l(t._template.type)?t._template.type:Bs(),t.shaderSource="",t.materials={},t.uniforms={},t._uniforms={},t._translucentFunctions=[];let n;const i=ze._materialCache.getMaterial(t.type);if(l(i)){const r=dt(i.fabric,!0);t._template=un(t._template,r,!0),n=i.translucent}qPe(t),l(i)||ze._materialCache.addMaterial(t.type,t),YPe(t),QPe(t),eOe(t);const o=t._translucentFunctions.length===0?!0:void 0;if(n=A(n,o),n=A(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 W1(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 LH(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 x(n)}function GPe(e,t){const n= ` fabric : uniforms and materials cannot share the same property '${e}' ` ;throw new x(n)}const WPe=["type","materials","uniforms","components","source"],jPe=["diffuse","specular","shininess"
2023-02-06 08:55:59 +00:00
` ;else{if(e.shaderSource+= ` czm _material czm _getMaterial ( czm _materialInput materialInput )
{
` ,e.shaderSource+= ` czm _material material = czm _getDefaultMaterial ( materialInput ) ;
2023-02-13 02:05:23 +00:00
` ,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&& $ Pe(t[o],e)?t[o]: ` czm _gammaCorrect ( $ { t [ o ] } ) ` ;e.shaderSource+= ` material . $ { o } = $ { s } ;
2023-02-06 08:55:59 +00:00
` }else o==="alpha"?e.shaderSource+= ` material . alpha = $ { t . alpha } ;
` :e.shaderSource+= ` material . $ { o } = $ { t [ o ] } ;
` }e.shaderSource+= ` return material ;
}
2023-02-13 02:05:23 +00:00
` }}const BH={mat2:ut,mat3:J,mat4:B},XPe=/ \. ktx2 $ /i;function KPe(e){let t;return function(n,i){const o=n.uniforms,r=o[e],s=t!==r,a=!l(r)||r===ze.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 m=new ii({minificationFilter:n._minificationFilter,magnificationFilter:n._magnificationFilter});c=new kt({context:i,source:r,sampler:m}),n._textures[e]=c;return}c.copyFrom({source:r})}else l(c)||(n._textures[e]=i.defaultTexture);return}if(r instanceof kt&&r!==c){n._texturePaths[e]=void 0;const m=n._textures[e];l(m)&&m!==n._defaultTexture&&m.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 Me;if(!l(n._texturePaths[e])||h&&r.url!==n._texturePaths[e].url||!h&&r!==n._texturePaths[e]){if(typeof r=="string"||h){const m=h?r:Me.createIfNeeded(r);let g;XPe.test(m.url)?g=G_(m.url):g=m.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 JPe(e){return function(t,n){const i=t.uniforms[e];if(i instanceof gu){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===ze.DefaultCubeMapId)return;const o=i.positiveX+i.negativeX+i.positiveY+i.negativeY+i.positiveZ+i.negativeZ;if(o!==t._texturePaths[e]){const r=[Me.createIfNeeded(i.positiveX).fetchImage(),Me.createIfNeeded(i.negativeX).fetchImage(),Me.createIfNeeded(i.positiveY).fetchImage(),Me.createIfNeeded(i.negativeY).fetchImage(),Me.createIfNeeded(i.positiveZ).fetchImage(),Me.createIfNeeded(i.negativeZ).fetchImage()];Promise.all(r).then(function(s){t._loadedCubeMaps.push({id:e,images:s})}),t._texturePaths[e]=o}}}function QPe(e){const t=e._template.uniforms;for(const n in t)t.hasOwnProperty(n)&&o $ (e,n)}function o $ (e,t){const n=e._strict,i=e._template.uniforms,o=i[t],r=ZPe(o);if(!l(r))throw new x( ` fabric : uniform '${t}' has invalid type . ` );let s;if(r==="channels"){if(s=hC(e,t,o,!1),s===0&&n)throw new x( ` strict : shader source does not use channels '${t}' . ` )}else{if(r==="sampler2D"){const u= ` $ { t } Dimensions ` ;tOe(e,u)>0&&(i[u]={type:"ivec3",x:1,y:1},o $ (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=hC(e,t,c),s===1&&n)throw new x( ` 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(KPe(t));else if(r==="samplerCube")e._uniforms[c]=function(){return e._textures[t]},e._updateFunctions.push(JPe(t));else if(r.indexOf("mat")!==-1){const u=new BH[r];e._uniforms[c]=function(){return BH[r].fromColumnMajorArray(e.uniforms[t],u)}}else e._uniforms[c]=function(){return e.uniforms[t]}}}function ZPe(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 Me||e instanceof HTMLCanvasElement||e instanceof HTMLImageElement)/^([rgba]){1,4} $ /i.test(e)?t="channels":e===ze.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 eOe(e){const t=e._strict,n=e._template.materials;for(const i in n)if(n.hasOwnProperty(i)){const o=new ze({strict:t,fabric:n[i],count:e._count
2023-02-06 08:55:59 +00:00
# extension GL _EXT _frag _depth : enable
# endif
2023-02-13 02:05:23 +00:00
` ;lD.prototype.update=function(e){if(!this.show||e.mode!==le.SCENE3D||!l(this.center)||!l(this.radii))return;if(!l(this.material))throw new x("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=Ze.fromCache({cull:{enabled:!0,face:Ho.FRONT},depthTest:{enabled:this._depthTestEnabled},depthMask:!n&&t.fragmentDepth,blending:n?Gi.ALPHA_BLEND:void 0})),l(this._va)||(this._va=nOe(t));let o=!1;const r=this.radii;if(!d.equals(this._radii,r)){d.clone(r,this._radii);const y=this._oneOverEllipsoidRadiiSquared;y.x=1/(r.x*r.x),y.y=1/(r.y*r.y),y.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),de.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,m;(s||a||i||u)&&(h=new We({sources:[zU]}),m=new We({sources:[this.material.shaderSource,FU]}),this.onlySunLighting&&m.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&m.defines.push("WRITE_DEPTH"),this._useLogDepth&&(h.defines.push("LOG_DEPTH"),m.defines.push("LOG_DEPTH"),m.sources.push(RH)),this._sp=yn.replaceCache({context:t,shaderProgram:this._sp,vertexShaderSource:h,fragmentShaderSource:m,attributeLocations:DB}),f.vertexArray=this._va,f.renderState=this._rs,f.shaderProgram=this._sp,f.uniformMap=un(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?Ne.TRANSLUCENT:Ne.OPAQUE,g.push(f)),p.pick){const y=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 We({sources:[zU]}),m=new We({sources:[this.material.shaderSource,FU],pickColorQualifier:"uniform"}),this.onlySunLighting&&m.defines.push("ONLY_SUN_LIGHTING"),!n&&t.fragmentDepth&&m.defines.push("WRITE_DEPTH"),this._useLogDepth&&(h.defines.push("LOG_DEPTH"),m.defines.push("LOG_DEPTH"),m.sources.push(RH)),this._pickSP=yn.replaceCache({context:t,shaderProgram:this._pickSP,vertexShaderSource:h,fragmentShaderSource:m,attributeLocations:DB}),y.vertexArray=this._va,y.renderState=this._rs,y.shaderProgram=this._pickSP,y.uniformMap=un(un(this._uniforms,this._pickUniforms),this.material._uniforms),y.executeInClosestFrustum=n),y.boundingVolume=this._boundingSphere,y.modelMatrix=this._computedModelMatrix,y.pass=n?Ne.TRANSLUCENT:Ne.OPAQUE,g.push(y)}};lD.prototype.isDestroyed=function(){return!1};lD.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(),He(this)};function aT(e){e=A(e,A.EMPTY_OBJECT);let t=e.textureUrl;l(t)||(t=_n("Assets/Textures/moonSmall.jpg")),this.show=A(e.show,!0),this.textureUrl=t,this._ellipsoid=A(e.ellipsoid,me.MOON),this.onlySunLighting=A(e.onlySunLighting,!0),this._ellipsoidPrimitive=new lD({radii:this.ellipsoid.radii,material:ze.fromType(ze.ImageType),depthTestEnabled:!1,_owner:this}),this._ellipsoidPrimitive.material.translucent=!1,this._axes=new e $ }Object.defineProperties(aT.prototype,{ellipsoid:{get:function(){return this._ellipsoid}}});const rx=new J,iOe=new J,oOe=new d,sx=[];aT.prototype.update=function(e){if(!this.show)return;const t=this._ellipsoidPrimitive;t.material.uniforms.image=this.textureUrl,t.onlySu
` ,n}function JBe(){let e="";e+=zs(".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+=zs(".cesium-credit-lightbox",{"background-color":"#303336",color:pA,position:"relative","min-height": ` $ { $Be } px ` ,margin:"auto"}),e+=zs(".cesium-credit-lightbox > ul > li a, .cesium-credit-lightbox > ul > li a:visited",{color:pA}),e+=zs(".cesium-credit-lightbox > ul > li a:hover",{color:Z1}),e+=zs(".cesium-credit-lightbox.cesium-credit-lightbox-expanded",{border:"1px solid #444","border-radius":"5px","max-width":"370px"}),e+=zs(".cesium-credit-lightbox.cesium-credit-lightbox-mobile",{height:"100%",width:"100%"}),e+=zs(".cesium-credit-lightbox-title",{padding:"20px 20px 0 20px"}),e+=zs(".cesium-credit-lightbox-close",{"font-size":"18pt",cursor:"pointer",position:"absolute",top:"0",right:"6px",color:pA}),e+=zs(".cesium-credit-lightbox-close:hover",{color:Z1}),e+=zs(".cesium-credit-lightbox > ul",{margin:"0",padding:"12px 20px 12px 40px","font-size":"13px"}),e+=zs(".cesium-credit-lightbox > ul > li",{"padding-bottom":"6px"}),e+=zs(".cesium-credit-lightbox > ul > li *",{padding:"0",margin:"0"}),e+=zs(".cesium-credit-expand-link",{"padding-left":"5px",cursor:"pointer","text-decoration":"underline",color:pA}),e+=zs(".cesium-credit-expand-link:hover",{color:Z1}),e+=zs(".cesium-credit-text",{color:pA}),e+=zs(".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 Vo(e,t,n){T.defined("container",e);const i=this;n=A(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 m=document.createElement("a");m.className="cesium-credit-expand-link",m.onclick=this.showLightbox.bind(this),m.textContent="Data attribution",e.appendChild(m),JBe();const g=si.clone(Vo.cesiumCredit);this._delimiter=A(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=m,this._expanded=!1,this._defaultCredits=[],this._cesiumCredit=g,this._previousCesiumCredit=void 0,this._currentCesiumCredit=g,this._creditDisplayElementPool=[],this._creditDisplayElementIndex=0,this._currentFrameCredits={screenCredits:new vt,lightboxCredits:new vt},this._defaultCredit=void 0,this.viewport=n,this.container=e}function z $ (e,t,n,i){i=A(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 M $ (n,i),r.push(o)),++e._creditDisplayElementPoolIndex,t.set(n.id,o)}}Vo.prototype.addCredit=function(e){if(T.defined("credit",e),e._isIon){l(this._defaultCredit)||(this._defaultCredit=si.clone(U $ ())),this._currentCesiumCredit=this._defaultCredit;return}let t;e.showOnScreen?t=this._currentFrameCredits.screenCredits:t=this._currentFrameCredits.lightboxCredits,z $ (this,t,e)};Vo.prototype.addDefaultCredit=function(e){T.defined("credit",e);const t=this._defaultCredits;YBe(t,e)||t.push(e)};Vo.prototype.removeDefaultCredit=function(e){T.defined(
2023-02-06 08:55:59 +00:00
# extension GL _EXT _frag _depth : enable
# endif
2023-02-13 02:05:23 +00:00
` ;a.sources.push(c),a.defines.push("LOG_DEPTH"),s.defines.push("LOG_DEPTH")}this._sp=yn.replaceCache({shaderProgram:this._sp,context:t,vertexShaderSource:s,fragmentShaderSource:a,attributeLocations:{position:0}}),this._command.shaderProgram=this._sp}const r=ERe(i,e);if(l(this._va))this._va.getAttribute(0).vertexBuffer.copyFromArrayView(r);else{const s=new Lt({attributes:{position:new Ue({componentDatatype:ee.FLOAT,componentsPerAttribute:3,values:r})},indices:[0,1,2,2,1,3],primitiveType:Qe.TRIANGLES});this._va=fo.fromGeometry({context:t,geometry:s,attributeLocations:{position:0},bufferUsage:tt.DYNAMIC_DRAW}),this._command.vertexArray=this._va}};uT.prototype.execute=function(e,t){this._mode===le.SCENE3D&&this._command.execute(e,t)};uT.prototype.isDestroyed=function(){return!1};uT.prototype.destroy=function(){this._sp=this._sp&&this._sp.destroy(),this._va=this._va&&this._va.destroy()};function md(){}const xRe=/ \b gl_FragDepthEXT \b /,wRe=/ \b discard \b /;function SRe(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(xRe.test(a[r])||wRe.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 ( )
2023-02-06 08:55:59 +00:00
{
gl _FragColor = vec4 ( 1.0 ) ;
}
2023-02-07 08:44:46 +00:00
` ,o=new We({sources:[h]})):!s&&u&&(h= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# extension GL _EXT _frag _depth : enable
# endif
void main ( )
{
gl _FragColor = vec4 ( 1.0 ) ;
czm _writeLogDepth ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,o=new We({defines:["LOG_DEPTH"],sources:[h]})),n=e.shaderCache.createDerivedShaderProgram(t,"depthOnly",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}function vRe(e,t){const n=e._depthOnlyRenderStateCache;let i=n[t.id];if(!l(i)){const o=Ze.getState(t);o.depthMask=!0,o.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i=Ze.fromCache(o),n[t.id]=i}return i}md.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=pt.shallowClone(t,i.depthOnlyCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.depthOnlyCommand.shaderProgram=SRe(n,t.shaderProgram),i.depthOnlyCommand.renderState=vRe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.depthOnlyCommand.shaderProgram=o,i.depthOnlyCommand.renderState=r),i};const DRe=/ \s +czm_writeLogDepth \( /,IRe=/ \s +czm_vertexLogDepth \( /,PRe=/ \s *#extension \s +GL_EXT_frag_depth \s *: \s *enable/;function ORe(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(IRe.test(f[a])){u=!0;break}if(!u){for(a=0;a<h;++a)f[a]=We.replaceMain(f[a],"czm_log_depth_main");c= `
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _log _depth _main ( ) ;
czm _vertexLogDepth ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,f.push(c)}for(f=s.sources,h=f.length,u=!1,a=0;a<h;++a)DRe.test(f[a])&&(u=!0);s.defines.indexOf("LOG_DEPTH_WRITE")!==-1&&(u=!0);let m=!0;for(a=0;a<h;++a)PRe.test(f[a])&&(m=!1);let g="";if(m&&(g+= ` # ifdef GL _EXT _frag _depth
2023-02-06 08:55:59 +00:00
# extension GL _EXT _frag _depth : enable
# endif
2023-02-07 08:44:46 +00:00
` ),!u){for(a=0;a<h;a++)f[a]=We.replaceMain(f[a],"czm_log_depth_main");g+= `
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _log _depth _main ( ) ;
czm _writeLogDepth ( ) ;
}
2023-02-13 02:05:23 +00:00
` }f.push(g),i=e.shaderCache.createDerivedShaderProgram(t,"logDepth",{vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:o})}return i}md.createLogDepthCommand=function(e,t,n){l(n)||(n={});let i;return l(n.command)&&(i=n.command.shaderProgram),n.command=pt.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=ORe(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function LRe(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 ( )
2023-02-06 08:55:59 +00:00
{
czm _non _pick _main ( ) ;
if ( gl _FragColor . a == 0.0 ) {
discard ;
}
gl _FragColor = $ { n } ;
}
2023-02-13 02:05:23 +00:00
` ,u=new Array(a+1);for(let f=0;f<a;++f)u[f]=We.replaceMain(s[f],"czm_non_pick_main");u[a]=c,r=new We({sources:u,defines:r.defines}),i=e.shaderCache.createDerivedShaderProgram(t,"pick",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:r,attributeLocations:o})}return i}function BRe(e,t){const n=e.picking.pickRenderStateCache;let i=n[t.id];if(!l(i)){const o=Ze.getState(t);o.blending.enabled=!1,o.depthMask=!0,i=Ze.fromCache(o),n[t.id]=i}return i}md.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=pt.shallowClone(t,i.pickCommand),!l(o)||i.shaderProgramId!==t.shaderProgram.id?(i.pickCommand.shaderProgram=LRe(n,t.shaderProgram,t.pickId),i.pickCommand.renderState=BRe(e,t.renderState),i.shaderProgramId=t.shaderProgram.id):(i.pickCommand.shaderProgram=o,i.pickCommand.renderState=r),i};function RRe(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}md.createHdrCommand=function(e,t,n){l(n)||(n={});let i;return l(n.command)&&(i=n.command.shaderProgram),n.command=pt.shallowClone(e,n.command),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.command.shaderProgram=RRe(t,e.shaderProgram),n.shaderProgramId=e.shaderProgram.id):n.command.shaderProgram=i,n};function pD(e){if(!l(e))throw new x("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=M.toRadians(o),t._beta=M.toRadians(i.beta),t._gamma=M.toRadians(i.gamma)}window.addEventListener("deviceorientation",n,!1),this._removeListener=function(){window.removeEventListener("deviceorientation",n,!1)}}const NRe=new Te,tV=new Te,MRe=new J;function FRe(e,t,n,i){const o=e.direction,r=e.right,s=e.up,a=Te.fromAxisAngle(o,n,tV),c=Te.fromAxisAngle(r,i,NRe),u=Te.multiply(c,a,c),f=Te.fromAxisAngle(s,t,tV);Te.multiply(f,u,u);const h=J.fromQuaternion(u,MRe);J.multiplyByVector(h,r,r),J.multiplyByVector(h,s,s),J.multiplyByVector(h,o,o)}pD.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;FRe(this._scene.camera,-e,t,n),this._lastAlpha=this._alpha,this._lastBeta=this._beta,this._lastGamma=this._gamma};pD.prototype.isDestroyed=function(){return!1};pD.prototype.destroy=function(){return this._removeListener(),He(this)};function W $ (){this.enabled=!0,this.renderable=!0,this.density=2e-4,this.screenSpaceErrorFactor=2,this.minimumBrightness=.03}const zw=[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],tf=[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<tf.length;++e)tf[e]*=1e6;const j $ =tf[1],RB=tf[tf.length-1];for(let e=0;e<tf.length;++e)tf[e]=(tf[e]-RB)/(j $ -RB);let Zr=0;function zRe(e){const t=zw,n=t.length;if(e<t[0])return Zr=0,Zr;if(e>t[n-1])return Zr=n-2,Zr;if(e>=t[Zr]){if(Zr+1<n&&e<t[Zr+1])return Zr;if(Zr+2<n&&e<t[Zr+2])return++Zr,Zr}else if(Zr-1>=0&&e>=t[Zr-1])return--Zr,Zr;let i;for(i=0;i<n-2&&!(e>=t[i]&&e<t[i+1]);++i);return Zr=i,Zr}const URe=new d;W $ .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
2023-02-06 08:55:59 +00:00
{
gl _FragColor = vec4 ( 1.0 ) ;
}
2023-02-13 02:05:23 +00:00
` ;t.sources=[n]}function WM(e,t){const n=t.sources,i=n.length;for(let r=0;r<i;++r)n[r]=We.replaceMain(n[r],"czm_globe_translucency_main");const o= `
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ;n.push(o)}function $ $ (e,t){WM(e,t),Yc(e.defines,"GROUND_ATMOSPHERE"),Yc(t.defines,"GROUND_ATMOSPHERE"),Yc(e.defines,"FOG"),Yc(t.defines,"FOG")}function XRe(e,t){WM(e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function KRe(e,t){ $ $ (e,t),e.defines.push("GENERATE_POSITION"),t.defines.push("MANUAL_DEPTH_TEST")}function rV(e,t){const n= ` uniform sampler2D u _classificationTexture ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;t.sources=[n]}function JRe(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 QRe(e){e.cull.face=Ho.BACK,e.cull.enabled=!0}function ZRe(e){e.cull.face=Ho.FRONT,e.cull.enabled=!0}function eNe(e){e.cull.face=Ho.BACK,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function tNe(e){e.cull.face=Ho.FRONT,e.cull.enabled=!0,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function nNe(e){e.cull.enabled=!1,e.colorMask={red:!1,green:!1,blue:!1,alpha:!1}}function sV(e){e.cull.face=Ho.BACK,e.cull.enabled=!0,e.depthMask=!1,e.blending=Gi.ALPHA_BLEND}function aV(e){e.cull.face=Ho.FRONT,e.cull.enabled=!0,e.depthMask=!1,e.blending=Gi.ALPHA_BLEND}function iNe(e){e.cull.face=Ho.BACK,e.cull.enabled=!0,e.blending.enabled=!1}function oNe(e){e.cull.face=Ho.FRONT,e.cull.enabled=!0,e.blending.enabled=!1}function rNe(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=Ze.getState(e);i(s),r=Ze.fromCache(s),o[e.id]=r}return r}function Og(e){return{u_classificationTexture:function(){return e._globeTranslucencyFramebuffer.classificationTexture}}}function sNe(e,t,n,i,o){return l(o)?!i&&l(n)?n:un(t,o(e),!1):t}function Ll(e){this.pass=e.pass,this.pickOnly=e.pickOnly,this.getShaderProgramFunction=e.getShaderProgramFunction,this.getRenderStateFunction=e.getRenderStateFunction,this.getUniformMapFunction=e.getUniformMapFunction,this.renderStateCache={}}function aNe(){return[new Ll({pass:Ne.GLOBE,pickOnly:!1,getShaderProgramFunction: $ Re,getRenderStateFunction:QRe,getUniformMapFunction:void 0}),new Ll({pass:Ne.GLOBE,pickOnly:!1,getShaderProgramFunction:YRe,getRenderStateFunction:ZRe,getUniformMapFunction:void 0}),new Ll({pass:Ne.GLOBE,pickOnly:!1,getShaderProgramFunction:iP,getRenderStateFunction:eNe,getUniformMapFunction:void 0}),new Ll({pass:Ne.GLOBE,pickOnly:!1,getShaderProgramFunction:iP,getRenderStateFunction:tNe,getUniformMapFunction:void 0}),new Ll({pass:Ne.GLOBE,pickOnly:!1,getShaderProgramFunction:iP,getRenderStateFunction:nNe,getUniformMapFunction:void 0}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:WM,getRenderStateFunction:sV,getUniformMapFunction:Og}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction: $ $ ,getRenderStateFunction:aV,getUniformMapFunction:Og}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:XRe,getRenderStateFunction:sV,getUniformMapFunction:Og}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!1,getShaderProgramFunction:KRe,getRenderStateFunction:aV,getUniformMapFunction:Og}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:rV,getRenderStateFunction:iNe,getUniformMapFunction:Og}),new Ll({pass:Ne.TRANSLUCENT,pickOnly:!0,getShaderProgramFunction:rV,getRenderStateFunction:oNe,getUniformMapFunction:Og})]}const cV=new Array(Jm),lV=new Array(Jm);Q_.prototype.updateDerivedCommands=function(e,t){const n=this._derivedCommandTypesToUpdate,i=this._derivedCommandsToUpdateLength;if(i!==0){for(let o=0;o<i;++o)lV[o]=this._derivedCommandPacks[n[o]],cV[o]=q $ [n[o]];cNe(this,e,i,n,cV,lV,t)}};function cNe(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=A(a.uniformMapDirtyFrame,0),h=A(a.shaderProgramDirtyFrame,0),m=A(a.renderStateDirtyFrame,0),g=a.uniformMap!==t.uniformMap,p=a.shaderProgramId!==t.shaderProgram.id,y=a.renderStateId!==t.renderState.id;g&&(a.uniformMapDirtyFrame=u),p&&(a.shaderProgramDirtyFrame=u),y&&(a.renderStateDirtyFrame=u),a.uniformMap=t.uniformMap,a.shaderProgramId=t.shaderProgram.id,a.renderStateId=t.renderState.id;for(let b=0;b<n;++b){const C=r[b],E=i[b],w=o[b];let S=a[w],P,L,z;l(S)?(P=S.uniformMap,L=S.shad
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( colorTexture , v _textureCoordinates ) ;
}
2023-02-13 02:05:23 +00:00
` ,fNe={NEVER:ae.NEVER,LESS:ae.LESS,EQUAL:ae.EQUAL,LESS_OR_EQUAL:ae.LEQUAL,GREATER:ae.GREATER,NOT_EQUAL:ae.NOTEQUAL,GREATER_OR_EQUAL:ae.GEQUAL,ALWAYS:ae.ALWAYS},_i=Object.freeze(fNe),dNe={ZERO:ae.ZERO,KEEP:ae.KEEP,REPLACE:ae.REPLACE,INCREMENT:ae.INCR,DECREMENT:ae.DECR,INVERT:ae.INVERT,INCREMENT_WRAP:ae.INCR_WRAP,DECREMENT_WRAP:ae.DECR_WRAP},mt=Object.freeze(dNe),Uw={CESIUM_3D_TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15};Uw.setCesium3DTileBit=function(){return{enabled:!0,frontFunction:_i.ALWAYS,frontOperation:{fail:mt.KEEP,zFail:mt.KEEP,zPass:mt.REPLACE},backFunction:_i.ALWAYS,backOperation:{fail:mt.KEEP,zFail:mt.KEEP,zPass:mt.REPLACE},reference:Uw.CESIUM_3D_TILE_MASK,mask:Uw.CESIUM_3D_TILE_MASK}};const Rt=Object.freeze(Uw);function Tu(){this._numSamples=1,this.previousFramebuffer=void 0,this._previousFramebuffer=void 0,this._depthStencilTexture=void 0,this._depthStencilRenderbuffer=void 0,this._fbo=new Pn({depthStencil:!0,createDepthAttachments:!1}),this._fboClassified=new Pn({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 ao({color:new H(0,0,0,0),owner:this}),this._clearCommand=new ao({color:new H(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(Tu.prototype,{unclassifiedCommand:{get:function(){return this._unclassifiedCommand}}});Tu.isTranslucencySupported=function(e){return e.depthTexture&&e.fragmentDepth};const hNe={depthMask:!1,stencilTest:{enabled:!0,frontFunction:_i.EQUAL,frontOperation:{fail:mt.KEEP,zFail:mt.KEEP,zPass:mt.KEEP},backFunction:_i.NEVER,reference:0,mask:Rt.CLASSIFICATION_MASK},blending:Gi.ALPHA_BLEND},pNe={depthMask:!1,stencilTest:{enabled:!0,frontFunction:_i.NOT_EQUAL,frontOperation:{fail:mt.KEEP,zFail:mt.KEEP,zPass:mt.KEEP},backFunction:_i.NEVER,reference:0,mask:Rt.CLASSIFICATION_MASK},blending:Gi.ALPHA_BLEND},mNe={depthMask:!0,depthTest:{enabled:!0},stencilTest:Rt.setCesium3DTileBit(),stencilMask:Rt.CESIUM_3D_TILE_MASK,blending:Gi.ALPHA_BLEND},_Ne= ` # extension GL _EXT _frag _depth : enable
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,gNe= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ;Tu.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 kt({context:e,width:s,height:a,pixelFormat:rt.DEPTH_STENCIL,pixelDatatype:Je.UNSIGNED_INT_24_8}),t>1&&(this._depthStencilRenderbuffer=new ql({context:e,width:s,height:a,format:od.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=Ze.fromCache(hNe),this._rsClassified=Ze.fromCache(pNe),this._rsDefault=Ze.fromCache(mNe)),!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)?gNe:_Ne,f=new We({defines:["UNCLASSIFIED"],sources:[u]}),h=new We({sources:[u]});this._unclassifiedCommand=e.createViewportQuadCommand(f,{renderState:l(this._previousFramebuffer)?this._rsUnclassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),this._classifiedCommand=e.createViewportQuadCommand(h,{renderState:l(this._previousFramebuffer)?this._rsClassified:this._rsDefault,uniformMap:this._uniformMap,owner:this}),l(this._translucentCommand)&&(this._translucentCommand.shaderProgram=this._translucentCommand.shaderProgram&&this._translucentCommand.shaderProgram.destroy()),l(this._previousFramebuffer)||(this._translucentCommand=e.createViewportQuadCommand(E_,{renderState:this._rsUnclassified,uniformMap:this._uniformMap,owner:this}))}};Tu.prototype.prepareTextures=function(e,t){this._fbo._numSamples>1&&this._fbo.prepareTextures(e,t)};Tu.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))};Tu.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)};Tu.prototype.executeUnclassified=function(e,t){this._unclassifiedCommand.execute(e,t)};Tu.prototype.isDestroyed=function(){return!1};Tu.prototype.destroy=function(){return this._fbo.destroy(),this._fboClassified.destroy(),this._depthStencilTexture=this._depthStencilTexture&&this._depthStencilTexture.destroy(),this._depthStencilRenderbuffer=this._depthStencilRenderbuffer&&this._depthStencilRenderbuffer.destroy(),l(this._unclassifiedCommand)&&(this._unclassifiedCommand.shaderProgram=this._unclassifiedCommand.shaderProgram&&this._unclassifiedCommand.shaderProgram.destroy(),this._classifiedCommand.shaderProgram=this._classifiedCommand.shaderProgram&&this._classifiedCommand.shaderProgram.destroy()),He(this)};const yNe={TEXTURE:0,PROGRAM:1,BUFFER:2,NUMBER_OF_JOB_TYPES:3},Hl=Object.freeze(yNe);function Hw(e){this._total=e,this.usedThisFrame=0,this.stolenFromMeThisFrame=0,this.starvedThisFrame=!1,this.starvedLastFrame=!1}Object.defineProperties(Hw.prototype,{total:{get:function(){return this._total}}})
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = czm _packDepth ( texture2D ( u _texture , v _textureCoordinates ) . r ) ;
}
2023-02-13 02:05:23 +00:00
` ;e._copyDepthCommand=t.createViewportQuadCommand(i,{renderState:Ze.fromCache(),uniformMap:{u_texture:function(){return e._textureToCopy}},owner:e})}e._textureToCopy=n,e._copyDepthCommand.framebuffer=e.framebuffer}Z_.prototype.update=function(e,t){INe(this,e,t),PNe(this,e,t)};const ONe=new oe,LNe=new oe(1,1/255,1/65025,1/16581375);Z_.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,ONe);return oe.divideByScalar(o,255,o),oe.dot(o,LNe)};Z_.prototype.executeCopyDepth=function(e,t){this._copyDepthCommand.execute(e,t)};Z_.prototype.isDestroyed=function(){return!1};Z_.prototype.destroy=function(){return this._framebuffer.destroy(),l(this._copyDepthCommand)&&(this._copyDepthCommand.shaderProgram=l(this._copyDepthCommand.shaderProgram)&&this._copyDepthCommand.shaderProgram.destroy()),He(this)};function qo(e){e=A(e,A.EMPTY_OBJECT),this._primitives=[],this._guid=Bs(),this._zIndex=void 0,this.show=A(e.show,!0),this.destroyPrimitives=A(e.destroyPrimitives,!0)}Object.defineProperties(qo.prototype,{length:{get:function(){return this._primitives.length}}});qo.prototype.add=function(e,t){const n=l(t);if(!l(e))throw new x("primitive is required.");if(n){if(t<0)throw new x("index must be greater than or equal to zero.");if(t>this._primitives.length)throw new x("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};qo.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};qo.prototype.removeAndDestroy=function(e){const t=this.remove(e);return t&&!this.destroyPrimitives&&e.destroy(),t};qo.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=[]};qo.prototype.contains=function(e){return!!(l(e)&&e._external&&e._external._composites&&e._external._composites[this._guid])};function _D(e,t){if(!e.contains(t))throw new x("primitive is not in this collection.");return e._primitives.indexOf(t)}qo.prototype.raise=function(e){if(l(e)){const t=_D(this,e),n=this._primitives;if(t!==n.length-1){const i=n[t];n[t]=n[t+1],n[t+1]=i}}};qo.prototype.raiseToTop=function(e){if(l(e)){const t=_D(this,e),n=this._primitives;t!==n.length-1&&(n.splice(t,1),n.push(e))}};qo.prototype.lower=function(e){if(l(e)){const t=_D(this,e),n=this._primitives;if(t!==0){const i=n[t];n[t]=n[t-1],n[t-1]=i}}};qo.prototype.lowerToBottom=function(e){if(l(e)){const t=_D(this,e),n=this._primitives;t!==0&&(n.splice(t,1),n.unshift(e))}};qo.prototype.get=function(e){if(!l(e))throw new x("index is required.");return this._primitives[e]};qo.prototype.update=function(e){if(!this.show)return;const t=this._primitives;for(let n=0;n<t.length;++n)t[n].update(e)};qo.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)}};qo.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)}};qo.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)}};qo.prototype.isDestroyed=function(){return!1};qo.prototype.destroy=function(){return this.removeAll(),He(this)};const Es={},BNe=new oe(0,0,0,1);let Us=new oe;const RNe=new $ e,rP=new j,sP=new j;Es.wgs84ToWindowCoordinates=function(e,t,n){return Es.wgs84WithEyeOffsetToWindowCoordinates(e,t,d.ZERO,n)};const gV=new oe,yV=new d;function yA(e,t,n,i){const o=n.viewMatrix,r=B.multiplyByVector(o,oe.fromElements(e.x,e.y,e.z,1,gV),gV),s=d.multiplyComponents(t,d.normalize(r,yV),yV);return r.x+=t.x+s.x,r.y+=t.y+s.y,r.z+=s.z
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = czm _packDepth ( texture2D ( u _depthTexture , v _textureCoordinates ) . r ) ;
}
2023-02-13 02:05:23 +00:00
` ;function Cf(){this._picking=!1,this._numSamples=1,this._tempCopyDepthTexture=void 0,this._pickColorFramebuffer=new Pn({depthStencil:!0,supportsDepthTexture:!0}),this._outputFramebuffer=new Pn({depthStencil:!0,supportsDepthTexture:!0}),this._copyDepthFramebuffer=new Pn,this._tempCopyDepthFramebuffer=new Pn,this._updateDepthFramebuffer=new Pn({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 $ e,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(Cf.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 VNe(e){e._pickColorFramebuffer.destroy(),e._outputFramebuffer.destroy(),e._copyDepthFramebuffer.destroy(),e._tempCopyDepthFramebuffer.destroy(),e._updateDepthFramebuffer.destroy()}function Z $ (e,t,n,i,o){e._viewport.width=n,e._viewport.height=i;const r=! $ e.equals(e._viewport,o.viewport);let s=r!==e._useScissorTest;e._useScissorTest=r, $ e.equals(e._scissorRectangle,o.viewport)||(e._scissorRectangle= $ e.clone(o.viewport,e._scissorRectangle),s=!0),(!l(e._rs)||! $ e.equals(e._viewport,e._rs.viewport)||s)&&(e._rs=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}}),e._rsBlend=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blending:Gi.ALPHA_BLEND}),e._rsUpdate=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:_i.EQUAL,frontOperation:{fail:mt.KEEP,zFail:mt.KEEP,zPass:mt.KEEP},backFunction:_i.NEVER,reference:Rt.CESIUM_3D_TILE_MASK,mask:Rt.CESIUM_3D_TILE_MASK}})),l(e._copyDepthCommand)||(e._copyDepthCommand=t.createViewportQuadCommand(NB,{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(E_,{uniformMap:{colorTexture:function(){return e.colorFramebufferManager.getColorTexture()}},owner:e})),e._copyColorCommand.renderState=e._rs,l(e._tempCopyDepthCommand)||(e._tempCopyDepthCommand=t.createViewportQuadCommand(NB,{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(E_,{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 ao({color:new H(0,0,0,0),stencil:0,owner:e})),e._clearGlobeColorCommand.framebuffer=e.framebuffer}Cf.prototype.update=function(e,t,n,i,o,r){const s=n.width,a=n.height,c=o?e.halfFloatingPointTexture?Je.HALF_FLOAT:Je.FLOAT:Je.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),Z $ (this,e,s,a,t),e.uniformState.globeDepthTexture=void 0,this._useHdr=o,this._clearGlobeDepth=r};Cf.prototype.prepareColorTextures=function(e,t){!this.picking&&this._numSamples>1&&this._outputFramebuffer.prepareTextures(e,t)};Cf.prototype.executeCopyDepth=function(e,t){l(this._copyDepthCommand)&&(
2023-02-06 08:55:59 +00:00
float ai = czm _gl _FragColor . a ;
float wzi = czm _alphaWeight ( ai ) ;
gl _FragData [ 0 ] = vec4 ( Ci * wzi , ai ) ;
gl _FragData [ 1 ] = vec4 ( ai * wzi ) ;
2023-02-13 02:05:23 +00:00
` ,eMe= ` vec3 Ci = czm _gl _FragColor . rgb * czm _gl _FragColor . a ;
2023-02-06 08:55:59 +00:00
float ai = czm _gl _FragColor . a ;
float wzi = czm _alphaWeight ( ai ) ;
gl _FragColor = vec4 ( Ci , ai ) * wzi ;
2023-02-13 02:05:23 +00:00
` ,tMe= ` float ai = czm _gl _FragColor . a ;
2023-02-06 08:55:59 +00:00
gl _FragColor = vec4 ( ai ) ;
2023-02-13 02:05:23 +00:00
` ;function $ M(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=We.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
2023-02-06 08:55:59 +00:00
` :""}vec4 czm_gl_FragColor;
bool czm _discard = false ;
` ),s.sources.push( ` void main ( )
{
czm _translucent _main ( ) ;
if ( czm _discard )
{
discard ;
}
$ { i } }
2023-02-13 02:05:23 +00:00
` ),o=e.shaderCache.createDerivedShaderProgram(t,n,{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:s,attributeLocations:r})}return o}function nMe(e,t){return $ M(e,t,"translucentMRT",ZNe)}function iMe(e,t){return $ M(e,t,"translucentMultipass",eMe)}function oMe(e,t){return $ M(e,t,"alphaMultipass",tMe)}qd.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=pt.shallowClone(e,n.translucentCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=nMe(t,e.shaderProgram),n.translucentCommand.renderState=KNe(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=pt.shallowClone(e,n.translucentCommand),n.alphaCommand=pt.shallowClone(e,n.alphaCommand),!l(i)||n.shaderProgramId!==e.shaderProgram.id?(n.translucentCommand.shaderProgram=iMe(t,e.shaderProgram),n.translucentCommand.renderState=JNe(this,t,e.renderState),n.alphaCommand.shaderProgram=oMe(t,e.shaderProgram),n.alphaCommand.renderState=QNe(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 rMe(e,t,n,i,o,r){let s,a,c;const u=t.context,f=t.frameState.useLogDepth,h=t._hdr,m=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 y=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,y);for(l(r)&&(s=r.unclassifiedCommand,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.translucentCommand:s.derivedCommands.oit.translucentCommand,n(a,t,u,i,y)),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,y);l(r)&&(s=r.unclassifiedCommand,a=p&&s.receiveShadows?s.derivedCommands.oit.shadows.alphaCommand:s.derivedCommands.oit.alphaCommand,n(a,t,u,i,y)),i.framebuffer=m}function sMe(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 m=e._opaqueFBO.framebuffer;i.framebuffer=e._translucentFBO.framebuffer;let g,p;for(let y=0;y<f;++y)g=o[y],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,m);l(r)&&(g=r.unclassifiedCommand,p=h&&g.receiveShadows?g.derivedCommands.oit.shadows.translucentCommand:g.derivedCommands.oit.translucentCommand,n(p,t,s,i,m)),i.framebuffer=u}qd.prototype.executeCommands=function(e,t,n,i,o){if(this._translucentMRTSupport){sMe(this,e,t,n,i,o);return}rMe(this,e,t,n,i,o)};qd.prototype.execute=function(e,t){this._compositeCommand.execute(e,t)};qd.prototype.clear=function(e,t,n){const i=t.framebuffer;t.framebuffer=this._opaqueFBO.framebuffer,H.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
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _shadow _cast _main ( ) ;
v _positionEC = ( czm _inverseProjection * gl _Position ) . xyz ;
2023-02-13 02:05:23 +00:00
} ` ;o.push(c)}return new We({defines:i,sources:o})};sl.createShadowCastFragmentShader=function(e,t,n,i){const o=e.defines.slice(0),r=e.sources.slice(0);o.push("SHADOW_MAP");let s=We.findPositionVarying(e);const a=l(s);a||(s="v_positionEC");const c=r.length;for(let f=0;f<c;++f)r[f]=We.replaceMain(r[f],"czm_shadow_cast_main");let u="";return t&&(a||(u+= ` varying vec3 v _positionEC ;
2023-02-06 08:55:59 +00:00
` ),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+= ` }
2023-02-13 02:05:23 +00:00
` ,r.push(u),new We({defines:o,sources:r})};sl.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 } ` };sl.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 We({defines:i,sources:o})};sl.createShadowReceiveFragmentShader=function(e,t,n,i,o){const r=We.findNormalVarying(e),s=!i&&l(r)||i&&o,a=We.findPositionVarying(e),c=l(a),u=t._usesDepthTexture,f=t._polygonOffsetSupported,h=t._isPointLight,m=t._isSpotLight,g=t._numberOfCascades>1,p=t.debugCascadeColors,y=t.softShadows,b=h?t._pointBias:i?t._terrainBias:t._primitiveBias,C=e.defines.slice(0),E=e.sources.slice(0),w=E.length;for(let L=0;L<w;++L)E[L]=We.replaceMain(E[L],"czm_shadow_receive_main");h?C.push("USE_CUBE_MAP_SHADOW"):u&&C.push("USE_SHADOW_DEPTH_TEXTURE"),y&&!h&&C.push("USE_SOFT_SHADOWS"),g&&n&&i&&(s?C.push("ENABLE_VERTEX_LIGHTING"):C.push("ENABLE_DAYNIGHT_SHADING")),n&&b.normalShading&&s&&(C.push("USE_NORMAL_SHADING"),b.normalShadingSmooth>0&&C.push("USE_NORMAL_SHADING_SMOOTH"));let S="";h?S+= ` uniform samplerCube shadowMap _textureCube ;
` :S+= ` uniform sampler2D shadowMap _texture ;
2023-02-06 08:55:59 +00:00
` ;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
2023-02-13 02:05:23 +00:00
` ,S+= ` uniform mat4 shadowMap _matrix ;
2023-02-06 08:55:59 +00:00
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 )
{
2023-02-07 08:44:46 +00:00
$ { b . normalOffset && s ? ` float normalOffset = shadowMap_normalOffsetScaleDistanceMaxDistanceAndDarkness.x;
2023-02-06 08:55:59 +00:00
float normalOffsetScale = 1.0 - nDotL ;
vec3 offset = normalOffset * normalOffsetScale * normalEC ;
positionEC . xyz += offset ;
` :""}}
2023-02-13 02:05:23 +00:00
` ,S+= ` void main ( )
2023-02-06 08:55:59 +00:00
{
czm _shadow _receive _main ( ) ;
vec4 positionEC = getPositionEC ( ) ;
vec3 normalEC = getNormalEC ( ) ;
float depth = - positionEC . z ;
2023-02-13 02:05:23 +00:00
` ,S+= ` czm _shadowParameters shadowParameters ;
2023-02-06 08:55:59 +00:00
shadowParameters . texelStepSize = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . xy ;
shadowParameters . depthBias = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . z ;
shadowParameters . normalShadingSmooth = shadowMap _texelSizeDepthBiasAndNormalShadingSmooth . w ;
shadowParameters . darkness = shadowMap _normalOffsetScaleDistanceMaxDistanceAndDarkness . w ;
2023-02-13 02:05:23 +00:00
` ,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 ;
2023-02-06 08:55:59 +00:00
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 ) ;
2023-02-13 02:05:23 +00:00
` :m?S+= ` vec3 directionEC = normalize ( positionEC . xyz - shadowMap _lightPositionEC . xyz ) ;
2023-02-06 08:55:59 +00:00
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 ) ;
2023-02-13 02:05:23 +00:00
` :g?S+= ` float maxDepth = shadowMap _cascadeSplits [ 1 ] . w ;
2023-02-06 08:55:59 +00:00
// 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 ) ;
2023-02-13 02:05:23 +00:00
` :""} ` : S += ` float nDotL = clamp(dot(normalEC, shadowMap_lightDirectionEC), 0.0, 1.0);
2023-02-06 08:55:59 +00:00
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 ) ;
2023-02-13 02:05:23 +00:00
` ,S+= ` gl _FragColor . rgb *= visibility ;
2023-02-06 08:55:59 +00:00
}
2023-02-13 02:05:23 +00:00
` ,E.push(S),new We({defines:C,sources:E})};function Ic(e){e=A(e,A.EMPTY_OBJECT);const t=e.context;if(!l(t))throw new x("context is required.");if(!l(e.lightCamera))throw new x("lightCamera is required.");if(l(e.numberOfCascades)&&e.numberOfCascades!==1&&e.numberOfCascades!==4)throw new x("Only one or four cascades are supported.");this._enabled=A(e.enabled,!0),this._softShadows=A(e.softShadows,!1),this._normalOffset=A(e.normalOffset,!0),this.dirty=!0,this.fromLightSource=A(e.fromLightSource,!0),this.darkness=A(e.darkness,.3),this._darkness=this.darkness,this.fadingEnabled=A(e.fadingEnabled,!0),this.maximumDistance=A(e.maximumDistance,5e3),this._outOfView=!1,this._outOfViewPrevious=!1,this._needsUpdate=!0;let n=!0;(pn.isInternetExplorer()||pn.isEdge()||(pn.isChrome()||pn.isFirefox())&&pn.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 gD,this._shadowMapCullingVolume=void 0,this._sceneCamera=void 0,this._boundingSphere=new de,this._isPointLight=A(e.isPointLight,!1),this._pointLightRadius=A(e.pointLightRadius,100),this._cascadesEnabled=this._isPointLight?!1:A(e.cascadesEnabled,!0),this._numberOfCascades=this._cascadesEnabled?A(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 Wo: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 uMe(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,YM(this),this._clearCommand=new ao({depth:1,color:new H}),this._clearPassState=new W_(t),this._size=A(e.size,2048),this.size=this._size}Ic.MAXIMUM_DISTANCE=2e4;function uMe(e){this.camera=new gD,this.passState=new W_(e),this.framebuffer=void 0,this.textureOffsets=void 0,this.commandList=[],this.cullingVolume=void 0}function aP(e,t){return Ze.fromCache({cull:{enabled:!0,face:Ho.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 YM(e){const t=!e._usesDepthTexture;e._primitiveRenderState=aP(t,e._primitiveBias),e._terrainRenderState=aP(t,e._terrainBias),e._pointRenderState=aP(t,e._pointBias)}Ic.prototype.debugCreateRenderStates=function(){YM(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
2023-02-06 08:55:59 +00:00
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);
}
2023-02-13 02:05:23 +00:00
` ;const i=t.createViewportQuadCommand(n,{uniformMap:{shadowMap_texture:function(){return e._shadowMapTexture},shadowMap_textureCube:function(){return e._shadowMapTexture}}});return i.pass=Ne.OVERLAY,i}function AMe(e,t){const n=t.context,i=t.context.drawingBufferWidth,o=t.context.drawingBufferHeight,r=Math.min(i,o)*.3,s=gMe;s.x=i-r,s.y=0,s.width=r,s.height=r;let a=e._debugShadowViewCommand;l(a)||(a=yMe(e,n),e._debugShadowViewCommand=a),(!l(a.renderState)||! $ e.equals(a.renderState.viewport,s))&&(a.renderState=Ze.fromCache({viewport: $ e.clone(s)})),t.commandList.push(e._debugShadowViewCommand)}const Ef=new Array(8);Ef[0]=new oe(-1,-1,-1,1);Ef[1]=new oe(1,-1,-1,1);Ef[2]=new oe(1,1,-1,1);Ef[3]=new oe(-1,1,-1,1);Ef[4]=new oe(-1,-1,1,1);Ef[5]=new oe(1,-1,1,1);Ef[6]=new oe(1,1,1,1);Ef[7]=new oe(-1,1,1,1);const Jh=new B,KM=new Array(8);for(let e=0;e<8;++e)KM[e]=new oe;function bMe(e,t){const n=new an({geometry:new Ac({minimum:new d(-.5,-.5,-.5),maximum:new d(.5,.5,.5)}),attributes:{color:fn.fromColor(t)}}),i=new an({geometry:new xp({radius:.5}),attributes:{color:fn.fromColor(t)}});return new Kt({geometryInstances:[n,i],appearance:new Tn({translucent:!1,flat:!0}),asynchronous:!1,modelMatrix:e})}const CMe=[H.RED,H.GREEN,H.BLUE,H.MAGENTA],TMe=new d;function EMe(e,t){AMe(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 Kh({camera:e._sceneCamera,color:H.CYAN,updateOnChange:!1})),e._debugCameraFrustum.update(t)),e._cascadesEnabled){if(e.debugFreezeFrame){n&&(e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=new Kh({camera:e._shadowMapCamera,color:H.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 Kh({camera:e._passes[i].camera,color:CMe[i],updateOnChange:!1})),e._debugCascadeFrustums[i].update(t)}}else if(e._isPointLight){if(!l(e._debugLightFrustum)||e._needsUpdate){const i=e._shadowMapCamera.positionWC,o=Te.IDENTITY,r=e._pointLightRadius*2,s=d.fromElements(r,r,r,TMe),a=B.fromTranslationQuaternionRotationScale(i,o,s,Jh);e._debugLightFrustum=e._debugLightFrustum&&e._debugLightFrustum.destroy(),e._debugLightFrustum=bMe(a,H.YELLOW)}e._debugLightFrustum.update(t)}else(!l(e._debugLightFrustum)||e._needsUpdate)&&(e._debugLightFrustum=new Kh({camera:e._shadowMapCamera,color:H.YELLOW,updateOnChange:!1})),e._debugLightFrustum.update(t)}function gD(){this.viewMatrix=new B,this.inverseViewMatrix=new B,this.frustum=void 0,this.positionCartographic=new Ce,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}gD.prototype.clone=function(e){B.clone(e.viewMatrix,this.viewMatrix),B.clone(e.inverseViewMatrix,this.inverseViewMatrix),this.frustum=e.frustum.clone(this.frustum),Ce.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 xMe=new B(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);gD.prototype.getViewProjection=function(){const e=this.viewMatrix,t=this.frustum.projectionMatrix;return B.multiply(t,e,this.viewProjectionMatrix),B.multiply(xMe,this.viewProjectionMatrix,this.viewProjectionMatrix),this.viewProjectionMatrix};const wMe=new Array(5),SMe=new $ n,vMe=new Array(4),oY=new d,rY=new d;function DMe(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 m=vMe,g=wMe;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.lerp(I,v,f);g[a+1]=_,m[a]=_-g[a]}if(h){for(a=0;a<s;++a)m[a]=Math.min(m[a],e._maximumCascadeDistances[a]);let U=g[0];for(a=0;a<s-1;++a)U+=m[a],g[a+1]=U}oe.unpa
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ;function Yp(e){this._drawClassificationFBO=new Pn({createDepthAttachments:!1}),this._accumulationFBO=new Pn({createDepthAttachments:!1}),this._packFBO=new Pn,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 ao({color:new H(0,0,0,0),owner:this}),this._clearDepthStencilCommand=new ao({depth:1,stencil:0,owner:this}),this._supported=e.depthTexture,this._viewport=new $ e,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(Yp.prototype,{hasTranslucentDepth:{get:function(){return this._hasTranslucentDepth}}});function cY(e){e._textureToComposite=void 0,e._translucentDepthStencilTexture=e._translucentDepthStencilTexture&&!e._translucentDepthStencilTexture.isDestroyed()&&e._translucentDepthStencilTexture.destroy()}function lY(e){e._drawClassificationFBO.destroy(),e._accumulationFBO.destroy(),e._packFBO.destroy()}function GMe(e,t,n,i){cY(e),e._translucentDepthStencilTexture=new kt({context:t,width:n,height:i,pixelFormat:rt.DEPTH_STENCIL,pixelDatatype:Je.UNSIGNED_INT_24_8,sampler:ii.NEAREST})}function WMe(e,t,n,i){lY(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 jMe(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)&&(GMe(e,t,o,r),WMe(e,t,o,r));let s,a;if(l(e._packDepthCommand)||(s=new We({sources:[NTe]}),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 We({sources:[cP]}),a={colorTexture:function(){return e._textureToComposite}},e._compositeCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e});const f=e._compositeCommand,h=f.shaderProgram,m=t.shaderCache.createDerivedShaderProgram(h,"pick",{vertexShaderSource:h.vertexShaderSource,fragmentShaderSource:new We({sources:s.sources,defines:["PICK"]}),attributeLocations:h._attributeLocations}),g=pt.shallowClone(f);g.shaderProgram=m,f.derivedCommands.pick=g}l(e._copyCommand)||(s=new We({sources:[cP]}),a={colorTexture:function(){return e._drawClassificationFBO.getColorTexture()}},e._copyCommand=t.createViewportQuadCommand(s,{uniformMap:a,owner:e})),l(e._accumulateCommand)||(s=new We({sources:[cP]}),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=! $ e.equals(e._viewport,n.viewport);let u=c!==e._useScissorTest;e._useScissorTest=c, $ e.equals(e._scissorRectangle,n.viewport)||(e._scissorRectangle= $ e.clone(n.viewport,e._scissorRectangle),u=!0),(!l(e._rsDepth)||! $ e.equals(e._viewport,e._rsDepth.viewport)||u)&&(e._rsDepth=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle}})),l(e._packDepthCommand)&&(e._packDepthCommand.renderState=e._rsDepth),(!l(e._rsAccumulate)||! $ e.equals(e._viewport,e._rsAccumulate.viewport)||u)&&(e._rsAccumulate=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},stencilTest:{enabled:!0,frontFunction:_i.EQUAL,reference:Rt.CESIUM_3D_TILE_MASK}})),l(e._accumulateCommand)&&(e._accumulateCommand.renderState=e._rsAccumulate),(!l(e._rsComp)||! $ e.equals(e._viewport,e._rsComp.viewport)||u)&&(e._rsComp=Ze.fromCache({viewport:e._viewport,scissorTest:{enabled:e._useScissorTest,rectangle:e._scissorRectangle},blendin
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,S2e= ` uniform sampler2D randomTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,v2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,D2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,I2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,P2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,O2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,L2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,B2e= ` uniform sampler2D depthTexture ;
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( void )
{
float depth = czm _readDepth ( depthTexture , v _textureCoordinates ) ;
gl _FragColor = vec4 ( vec3 ( depth ) , 1.0 ) ;
}
2023-02-13 02:05:23 +00:00
` ,R2e= ` uniform sampler2D depthTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,N2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,M2e= ` varying vec2 v _textureCoordinates ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,FB= ` # define SAMPLES 8
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,F2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,z2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,U2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,H2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,V2e= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ;function tg(){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 Pn,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(tg.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 CY(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 k2e(e,t){CY(e);let n=e._width,i=e._height;const o=t.halfFloatingPointTexture?Je.HALF_FLOAT:Je.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 Pn,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 TY(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 G2e(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 W2e(e,t){let n= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,n}function j2e(e,t){TY(e);const n=e._framebuffers,i=n.length,o=new Array(i);for(let r=0;r<i;++r)o[r]=t.createViewportQuadCommand(W2e(r,i),{framebuffer:n[r].framebuffer,uniformMap:G2e(e,r)});e._commands=o}tg.prototype.clear=function(e){const t=this._framebuffers;if(!l(t))return;let n=this._clearCommand;l(n)||(n=this._clearCommand=new ao({color:new H(0,0,0,0),framebuffer:void 0}));const i=t.length;for(let o=0;o<i;++o)t[o].clear(e,n)};tg.prototype.update=function(e){const t=e.drawingBufferWidth,n=e.drawingBufferHeight;(t!==this._width||n!==this._height)&&(this._width=t,this._height=n,k2e(this,e),j2e(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};tg.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)};tg.prototype.isDestroyed=function(){return!1};tg.prototype.destroy=function(){return CY(this),TY(this),He(this)};const q2e={NEAREST:0,LINEAR:1},x_=q2e;function Bi(e){e=A(e,A.EMPTY_OBJECT);const t=e.fragmentShader,n=A(e.textureScale,1),i=A(e.pixelFormat,rt.RGBA);if(T.typeOf.string("options.fragmentShader",t),T.typeOf.number.greaterThan("options.textureScale",n,0),T.typeOf.number.lessThanOrEquals("options.textureScale",n,1),!rt.isColorFormat(i))throw new x("options.pixelFormat must be a color format.");this._fragmentShader=t,this._uniforms=e.uniforms,this._textureScale=n,this._forcePowerOfTwo=A(e.forcePowerOfTwo,!1),this._sampleMode=A(e.sampleMode,x_.NEAREST),this._pixelFormat=i,this._pixelDatatype=A(e.pixelDatatype,Je.UNSIGNED_BYTE),this._clearColor=A(e.clearColor,H.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 W_;o.scissorTest={enabled:!0,rectangle:l(e.scissorRectangle)? $ e.clone(e.scissorRectangle):new $ e},this._passState=o,this._ready=!1;let r=e.name;l(r)||(r=Bs()),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(Bi.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 $ 2e=/uniform \s +sampler2D \s +depthTexture/g;Bi.prototype._isSupported=function(e){return! $ 2e.test(this._fragmentShader)||e.depthTexture};function Y2e(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
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
$ { n } ` }const i=new We({defines:[e._useLogDepth?"LOG_DEPTH":""],sources:[n]});e._command=t.createViewportQuadCommand(i,{uniformMap:e._uniformMap,owner:e})}function Z2e(e){const t=e._sampleMode;let n,i;t===x_.LINEAR?(n=Sn.LINEAR,i=Xr.LINEAR):(n=Sn.NEAREST,i=Xr.NEAREST);const o=e._sampler;(!l(o)||o.minificationFilter!==n||o.magnificationFilter!==i)&&(e._sampler=new ii({wrapS:Mi.CLAMP_TO_EDGE,wrapT:Mi.CLAMP_TO_EDGE,minificationFilter:n,magnificationFilter:i}))}function eFe(e,t){return function(n){e._texturesToCreate.push({name:t,source:n})}}function tFe(e,t){return function(){return e._textureCache.getOutputTexture(t)}}function nFe(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 m=h.source;e._actualUniforms[o]=new kt({context:t,source:m})}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],m=e._textureCache.getStageByName(h);if(l(m))e._actualUniforms[o]=tFe(e,h);else if(typeof h=="string"){const g=new Me({url:h});f.push(g.fetchImage().then(eFe(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 EY(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 kt&&(l(t.getStageByName(n[o]))||i[o].destroy(),e._dirtyUniforms.push(o))}function iFe(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 oFe(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 kt({context:t,pixelFormat:rt.RGBA,pixelDatatype:Je.UNSIGNED_BYTE,source:{arrayBufferView:f,width:1,height:1},sampler:ii.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 m=0;m<h;++m)a=f[m].color,u[c]=H.floatToByte(a.red),u[c+1]=H.floatToByte(a.green),u[c+2]=H.floatToByte(a.blue),u[c+3]=H.floatToByte(a.alpha),c+=4}else l(o.pickId)&&(a=o.pickId.color,u[c]=H.floatToByte(a.red),u[c+1]=H.floatToByte(a.green),u[c+2]=H.floatToByte(a.blue),u[c+3]=H.floatToByte(a.alpha),c+=4);e._selectedIdTexture=new kt({context:t,pixelFormat:rt.RGBA,pixelDatatype:Je.UNSIGNED_BYTE,source:{arrayBufferView:u,width:r,height:1},sampler:ii.NEAREST})}Bi.prototype.update=function(e,t){if(this.enabled!==this._enabled&&!this.enabled&&EY(this),this._enabled=this.enabled,!this._enabled||(this._logDepthChanged=t!==this._useLogDepth,this._useLogDepth=t,this._selectedDirty=iFe(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
$ { FB } ` ,r=new Bi({name: ` $ { e } _x _direction ` ,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:0},sampleMode:x_.LINEAR}),s=new Bi({name: ` $ { e } _y _direction ` ,fragmentShader:o,uniforms:{delta:1,sigma:2,stepSize:1,direction:1},sampleMode:x_.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 aa({name:e,stages:[r,s],uniforms:a})}ir.createBlurStage=function(){return bD("czm_blur")};ir.createDepthOfFieldStage=function(){const e=bD("czm_depth_of_field_blur"),t=new Bi({name:"czm_depth_of_field_composite",fragmentShader:L2e,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 aa({name:"czm_depth_of_field",stages:[e,t],inputPreviousStageTexture:!1,uniforms:n})};ir.isDepthOfFieldSupported=function(e){return e.context.depthTexture};ir.createEdgeDetectionStage=function(){const e=Bs();return new Bi({name: ` czm _edge _detection _$ { e } ` ,fragmentShader:R2e,uniforms:{length:.25,color:H.clone(H.BLACK)}})};ir.isEdgeDetectionSupported=function(e){return e.context.depthTexture};function sFe(e){if(!l(e))return ir.createEdgeDetectionStage();const t=new aa({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 } ;
2023-02-06 08:55:59 +00:00
` ,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 ;
}
2023-02-13 02:05:23 +00:00
` ,s=new Bi({name:"czm_edge_detection_combine",fragmentShader:r,uniforms:n});return new aa({name:"czm_edge_detection_composite",stages:[t,s]})}ir.createSilhouetteStage=function(e){const t=sFe(e),n=new Bi({name:"czm_silhouette_color_edges",fragmentShader:V2e,uniforms:{silhouetteTexture:t.name}});return new aa({name:"czm_silhouette",stages:[t,n],inputPreviousStageTexture:!1,uniforms:t.uniforms})};ir.isSilhouetteSupported=function(e){return e.context.depthTexture};ir.createBloomStage=function(){const e=new Bi({name:"czm_bloom_contrast_bias",fragmentShader:O2e,uniforms:{contrast:128,brightness:-.3}}),t=bD("czm_bloom_blur"),n=new aa({name:"czm_bloom_contrast_bias_blur",stages:[e,t]}),i=new Bi({name:"czm_bloom_generate_composite",fragmentShader:I2e,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 aa({name:"czm_bloom",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};ir.createAmbientOcclusionStage=function(){const e=new Bi({name:"czm_ambient_occlusion_generate",fragmentShader:S2e,uniforms:{intensity:3,bias:.1,lengthCap:.26,stepSize:1.95,frustumLength:1e3,randomTexture:void 0}}),t=bD("czm_ambient_occlusion_blur");t.uniforms.stepSize=.86;const n=new aa({name:"czm_ambient_occlusion_generate_blur",stages:[e,t]}),i=new Bi({name:"czm_ambient_occlusion_composite",fragmentShader:v2e,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 aa({name:"czm_ambient_occlusion",stages:[n,i],inputPreviousStageTexture:!1,uniforms:o})};ir.isAmbientOcclusionSupported=function(e){return e.context.depthTexture};const aFe= ` # define FXAA _QUALITY _PRESET 39
$ { UTe }
$ { M2e } ` ;ir.createFXAAStage=function(){return new Bi({name:"czm_FXAA",fragmentShader:aFe,sampleMode:x_.LINEAR})};ir.createAcesTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=w2e,new Bi({name:"czm_aces",fragmentShader:t,uniforms:{autoExposure:void 0}})};ir.createFilmicTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=N2e,new Bi({name:"czm_filmic",fragmentShader:t,uniforms:{autoExposure:void 0}})};ir.createReinhardTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=H2e,new Bi({name:"czm_reinhard",fragmentShader:t,uniforms:{autoExposure:void 0}})};ir.createModifiedReinhardTonemappingStage=function(e){let t=e? ` # define AUTO _EXPOSURE
` :"";return t+=z2e,new Bi({name:"czm_modified_reinhard",fragmentShader:t,uniforms:{white:H.WHITE,autoExposure:void 0}})};ir.createAutoExposureStage=function(){return new tg};ir.createBlackAndWhiteStage=function(){return new Bi({name:"czm_black_and_white",fragmentShader:D2e,uniforms:{gradations:5}})};ir.createBrightnessStage=function(){return new Bi({name:"czm_brightness",fragmentShader:P2e,uniforms:{brightness:.5}})};ir.createNightVisionStage=function(){return new Bi({name:"czm_night_vision",fragmentShader:U2e})};ir.createDepthViewStage=function(){return new Bi({name:"czm_depth_view",fragmentShader:B2e})};ir.createLensFlareStage=function(){return new Bi({name:"czm_lens_flare",fragmentShader:F2e,uniforms:{dirtTexture:_n("Assets/Textures/LensFlare/DirtMask.jpg"),starTexture:_n("Assets/Textures/LensFlare/StarBurst.jpg"),intensity:2,distortion:10,ghostDispersal:.4,haloWidth:.4,dirtAmount:.4,earthRadius:me.WGS84.maximumRadius}})};const Qh=ir;function xf(e){this._collection=e,this._framebuffers=[],this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0,this._updateDependencies=!1}function Rb(e){for(;l(e.length);)e=e.get(e.length-1);return e.name}function zB(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[Rb(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[Rb(h)]=!0)}}}return i.name}function ib(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 m=i.get(h);l(m.length)?a=ib(e,t,n,m,o):a=zB(e,t,n,m,o),s&&(o=a)}let u,f;if(s)for(u=1;u<c;++u)f=Rb(i.get(u)),l(n[f])||(n[f]={}),n[f][r]=!0;else for(u=1;u<c;++u){f=Rb(i.get(u));const h=n[f];for(let m=0;m<u;++m)h[Rb(i.get(m))]=!0}return a}function cFe(e,t){const n={};if(l(e.ambientOcclusion)){const i=e.ambientOcclusion,o=e.bloom,r=e._tonemapping,s=e.fxaa;let a=ib(e,t,n,i,void 0);a=ib(e,t,n,o,a),a=zB(e,t,n,r,a),a=ib(e,t,n,e,a),zB(e,t,n,s,a)}else ib(e,t,n,e,void 0);return n}function lFe(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 m=e._framebuffers,g=m.length;for(f=0;f<g;++f){if(h=m[f],r!==h.textureScale||s!==h.forcePowerOfTwo||a!==h.pixelFormat||c!==h.pixelDatatype||!H.equals(u,h.clearColor))continue;const p=h.stages,y=p.length;let b=!1;for(let C=0;C<y;++C)if(n[p[C]]){b=!0;break}if(!b)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 Pn({pixelFormat:a,pixelDatatype:c}),clear:void 0},m.push(h),h)}function uFe(e,t){const n=cFe(e._collection,t);for(const i in n)n.hasOwnProperty(i)&&(e._stageNameToFramebuffer[i]=lFe(e,i,n[i]))}function UB(e){const t=e._framebuffers,n=t.length;for(let i=0;i<n;++i)t[i].buffer.destroy()}function fFe(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&&(M.isPowerOfTwo(h)||(h=M.nextPowerOfTwo(h)),u=h,f=h),a.buffer.update(t,u,f),a.clear=new ao({color:a.clearColor,framebuffer:a.buffer.framebuffer})}}xf.prototype.updateDependencies=function(){this._updateDependencies=!0};xf.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)&&(UB(this),this._framebuffers.length=0,this._stageNameToFramebuffer={},this._width=void 0,this._height=void 0),!n&&!a)return;this._framebuffers.length===0&&u
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,Xze= ` uniform sampler2D colorTexture ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ;function $ d(){this._sceneFramebuffer=new Tf;const e=.125,t=new Array(6);t[0]=new Bi({fragmentShader:E_,textureScale:e,forcePowerOfTwo:!0,sampleMode:x_.LINEAR});const n=t[1]=new Bi({fragmentShader:Xze,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 Bi({fragmentShader:FB,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 Bi({fragmentShader:FB,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 Bi({fragmentShader:E_,sampleMode:x_.LINEAR}),this._uCenter=new j,this._uRadius=void 0,t[5]=new Bi({fragmentShader:Yze,uniforms:{center:function(){return i._uCenter},radius:function(){return i._uRadius},colorTexture2:function(){return i._sceneFramebuffer.framebuffer.getColorTexture(0)}}}),this._stages=new aa({stages:t});const o=new xf(this),r=t.length;for(let s=0;s<r;++s)t[s]._textureCache=o;this._textureCache=o,this.length=t.length} $ d.prototype.get=function(e){return this._stages.get(e)}; $ d.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 Kze=new oe,ZV=new j,Jze=new j,ek=new B;function Qze(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,ek);const u=B.multiplyByPoint(r,o,Kze);let f=sn.pointToGLWindowCoordinates(s,c,o,ZV);u.x+=M.SOLAR_RADIUS;const h=sn.pointToGLWindowCoordinates(a,c,u,u),m=j.magnitude(j.subtract(h,f,h))*30*2,g=Jze;g.x=m,g.y=m,e._uCenter=j.clone(f,e._uCenter),e._uRadius=Math.max(g.x,g.y)*.15;const p=t.drawingBufferWidth,y=t.drawingBufferHeight,b=e._stages,C=b.get(0),E=C.outputTexture.width,w=C.outputTexture.height,S=new $ e;S.width=E,S.height=w,c=B.computeViewportTransformation(S,0,1,ek),f=sn.pointToGLWindowCoordinates(s,c,o,ZV),g.x*=E/p,g.y*=w/y;const P=C.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,y);for(let L=1;L<4;++L) $ e.clone(P,b.get(L).scissorRectangle)} $ d.prototype.clear=function(e,t,n){this._sceneFramebuffer.clear(e,t,n),this._textureCache.clear(e)}; $ d.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),Qze(this,t,n),o}; $ d.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)}; $ d.prototype.copy=function(e,t){if(!l(this._copyColorCommand)){const n=this;this._copyColorCommand=e.createViewportQuadCommand(E_,{uniformMap:{colorTexture:function(){return n._stages.get(n._stages.length-1).outputTexture}},owner:this})}this._copyColorCommand.framebuffer=t,this._copyColorCommand.execute(e)}; $ d.prototype.isDestroyed=function(){return!1}; $ d.prototype.destroy=function(){return this._textureCache.destroy(),this._stages.destroy(),He(this)};function nX(){this._cachedShowFrustumsShaders={}}function Zze(e){const t={},n=e.vertexAttributes;for(const i in n)n.hasOwnProperty(i)&&(t[i]=n[i].index);return t}function eUe(e,t){const n=e.context,i=t,o=i.fragmentShaderSource.clone(),r=[];o.sources=o.sources.map(function(f){f=We.replaceMain(f,"czm_Debug_main");const h=/gl_FragData \[ ( \d +) \] /g;let m;for(;(m=h.exec(f))!==null;)r.indexOf(m[1])===-1&&r.push(m[1]);return f});const s=r.length;let a="";a+= ` uniform vec3 debugShowCommandsColor ;
2023-02-06 08:55:59 +00:00
` ,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 ;
2023-02-13 02:05:23 +00:00
` ;a+="}",o.sources.push(a);const u=Zze(i);return yn.fromCache({context:n,vertexShaderSource:i.vertexShaderSource,fragmentShaderSource:o,attributeLocations:u})}const CA=new H;function tUe(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=H.fromRandom()),t._debugColor):H.WHITE},n.debugShowFrustumsColor=function(){return e.debugShowFrustums?(CA.red=t.debugOverlappingFrustums&1<<0?1:0,CA.green=t.debugOverlappingFrustums&1<<1?1:0,CA.blue=t.debugOverlappingFrustums&1<<2?1:0,CA.alpha=1,CA):H.WHITE}),n}const nUe=new pt;nX.prototype.executeDebugShowFrustumsCommand=function(e,t,n){const i=t.shaderProgram.id;let o=this._cachedShowFrustumsShaders[i];l(o)||(o=eUe(e,t.shaderProgram),this._cachedShowFrustumsShaders[i]=o);const r=pt.shallowClone(t,nUe);r.shaderProgram=o,r.uniformMap=tUe(e,t),r.execute(e.context,n)};const YS=function(e){return function(){e.frameState.afterRender.push(function(){e.requestRender()})}};function Ei(e){e=A(e,A.EMPTY_OBJECT);const t=e.canvas;let n=e.creditContainer,i=e.creditViewport;const o=dt(e.contextOptions);if(!l(t))throw new x("options and options.canvas are required.");const r=l(n),s=new Xa(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=Bs(),this._jobScheduler=new up,this._frameState=new HRe(s,new Vo(n," • ",i),this._jobScheduler),this._frameState.scene3DOnly=A(e.scene3DOnly,!1),this._removeCreditContainer=!r,this._creditContainer=n,this._canvas=t,this._context=s,this._computeEngine=new Yv(s),this._globe=void 0,this._globeTranslucencyState=new Q_,this._primitives=new qo,this._groundPrimitives=new qo,this._globeHeight=void 0,this._cameraUnderground=!1,this._logDepthBuffer=s.fragmentDepth,this._logDepthBufferDirty=!0,this._tweens=new El,this._shaderFrameCount=0,this._sunPostProcess=void 0,this._computeCommandList=[],this._overlayCommandList=[],this._useOIT=A(e.orderIndependentTranslucency,!0),this._executeOITFunction=void 0,this._depthPlane=new uT(e.depthPlaneEllipsoidOffset),this._clearColorCommand=new ao({color:new H,stencil:0,owner:this}),this._depthClearCommand=new ao({depth:1,owner:this}),this._stencilClearCommand=new ao({stencil:0}),this._classificationStencilClearCommand=new ao({stencil:0,renderState:Ze.fromCache({stencilMask:Rt.CLASSIFICATION_MASK})}),this._depthOnlyRenderStateCache={},this._transitioner=new ig(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 nX,this._msaaSamples=A(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=H.clone(H.BLACK),this._mode=le.SCENE3D,this._mapProjection=l(e.mapProjection)?e.mapProjection:new nr,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 W $ ,this._shadowMapCamera=new at(this),this.shadowMap=new Ic({context:s,lightCamera:this._shadowMapCamera,enabled:A(e.shadows,!1)}),this.invertClassification=!1,this.invertClassificationColor=H.clone(H.WHITE),this._actualInvertClassificationColor=H.clone(this._invertClassificationColor),this._invertClassification=new Tu,this.focalLength=void 0,this.eyeSeparation=void 0,this.postProcessStages=new Ra,this.
2023-02-06 08:55:59 +00:00
$ { t }
2023-02-13 02:05:23 +00:00
$ { p } ` );const y=document.createElement("div");y.className="cesium-widget-errorPanel-message-details collapsed";const b=document.createElement("span");b.className="cesium-widget-errorPanel-more-details",b.appendChild(document.createTextNode("See more...")),y.appendChild(b),y.onclick=function(C){y.removeChild(b),y.appendChild(document.createTextNode(p)),y.className="cesium-widget-errorPanel-message-details",r.className="cesium-widget-errorPanel-content expanded",y.onclick=void 0},a.appendChild(y)}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 m = 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 " ) ; m . s e t A t t r i b u t e ( " t y p e " , " b u t t o n " ) , m . c l a s s N a m e = " c e s i u m - b u t t o n " , m . 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 " ) ) , m . 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 ( m ) , i . a p p e n d C h i l d ( o ) } ; o g . 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 } ; o g . 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 ) , H e ( t h i s ) } ; o g . 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 , l X ( t h i s ) , u X ( 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 ( ) ) } ; o g . 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 $ 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 ( $ 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 } } } ) ; $ 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 } ; $ 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 ) ) } } ; $ 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 $ 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 ) ) } ; $ 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 } ; $ 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 Y U 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 X U e ( e ) { r e t u r n n e w $ o ( e ) } f u n c t i o n y e ( e , t , n ) { r e t u r n Y U 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 ` , A ( t , ! 1 ) , A ( n , X U e ) ) } f u n c t i o n y 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
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,T4e= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,E4e= ` varying vec3 v _positionEC ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,x4e= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,w4e= ` varying vec3 v _positionEC ;
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,S4e= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;function Zo(e){e=A(e,A.EMPTY_OBJECT);const t=A(e.translucent,!0),n=A(e.closed,!1),i=A(e.materialSupport,Zo.MaterialSupport.TEXTURED);this.material=l(e.material)?e.material:ze.fromType(ze.ColorType),this.translucent=t,this._vertexShaderSource=A(e.vertexShaderSource,i.vertexShaderSource),this._fragmentShaderSource=A(e.fragmentShaderSource,i.fragmentShaderSource),this._renderState=Tr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._materialSupport=i,this._vertexFormat=i.vertexFormat,this._flat=A(e.flat,!1),this._faceForward=A(e.faceForward,!n)}Object.defineProperties(Zo.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}}});Zo.prototype.getFragmentShaderSource=Tr.prototype.getFragmentShaderSource;Zo.prototype.isTranslucent=Tr.prototype.isTranslucent;Zo.prototype.getRenderState=Tr.prototype.getRenderState;Zo.MaterialSupport={BASIC:Object.freeze({vertexFormat:Fe.POSITION_AND_NORMAL,vertexShaderSource:x4e,fragmentShaderSource:E4e}),TEXTURED:Object.freeze({vertexFormat:Fe.POSITION_NORMAL_AND_ST,vertexShaderSource:S4e,fragmentShaderSource:w4e}),ALL:Object.freeze({vertexFormat:Fe.ALL,vertexShaderSource:T4e,fragmentShaderSource:C4e})};function tn(e){this._definitionChanged=new Xe,this._color=void 0,this._colorSubscription=void 0,this.color=e}Object.defineProperties(tn.prototype,{isConstant:{get:function(){return Z.isConstant(this._color)}},definitionChanged:{get:function(){return this._definitionChanged}},color:ye("color")});tn.prototype.getType=function(e){return"Color"};tn.prototype.getValue=function(e,t){return l(t)||(t={}),t.color=Z.getValueOrClonedDefault(this._color,e,H.WHITE,t.color),t};tn.prototype.equals=function(e){return this===e||e instanceof tn&&Z.equals(this._color,e._color)};const hX={TERRAIN:0,CESIUM_3D_TILE:1,BOTH:2};hX.NUMBER_OF_CLASSIFICATION_TYPES=3;const So=Object.freeze(hX);function $ l(e){if(e=A(e,A.EMPTY_OBJECT),!l(e.componentDatatype))throw new x("options.componentDatatype is required.");if(!l(e.componentsPerAttribute))throw new x("options.componentsPerAttribute is required.");if(e.componentsPerAttribute<1||e.componentsPerAttribute>4)throw new x("options.componentsPerAttribute must be between 1 and 4.");if(!l(e.value))throw new x("options.value is required.");this.componentDatatype=e.componentDatatype,this.componentsPerAttribute=e.componentsPerAttribute,this.normalize=A(e.normalize,!1),this.value=e.value}function ds(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 $ B;i.requiresTextureCoordinates=e,i.requiresEC=!n.flat;const o=new $ B;if(o.requiresTextureCoordinates=e,n instanceof Tn)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}ds.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 Tn&&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 Tn||(o=t.material.shaderSource),new We({defines:i,sources:[o,mq]})};ds.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 We({defines:n,sources:[mq],pickColorQualifier:"varying"})};ds.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),pX(this._colorShaderDependencies,this._planarExtents,n,e,t,this._appearance,i,this._projectionExtentDefines)};ds.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),pX(this._pickShaderDependencies,this._planarExtents,n,e,t,void 0,i,this._projectionExtentDefines)};const rk=new d,sk=new Ce,ak={high:0,low:0};function pX(e,t,n,i,o,r,s,a){const c=i.slice();if(a.eastMostYhighDefine===""){const u=sk;u.longitude=M.PI,u.latitude=0,u.height=0;const f=s.project(u,rk);let h=Ln.encode(f.x,ak);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 m=sk;m.longitude=-M.PI,m.latitude=0,m.height=0;const g=s.project(m,rk);h=Ln.encode(g.x,ak),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 Tn&&c.push("PER_INSTANCE_COLOR"),e.requiresTextureCoordinates&&(c.push("TEXTURE_COORDINATES"),t||n||c.push("SPHERICAL"),n&&c.push("COLUMBUS_VIEW_2D")),new We({defines:c,sources:[o]})}function $ B(){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( $ B.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},
2023-02-06 08:55:59 +00:00
` ,r= ` extrudeDirection = czm _octDecode ( $ { n } , 65535.0 ) ;
2023-02-07 08:44:46 +00:00
` ;let s=t;s=s.replace(/attribute \s +vec3 \s +extrudeDirection;/g,""),s=We.replaceMain(s,"czm_non_compressed_main");const a= ` void main ( )
2023-02-06 08:55:59 +00:00
{
$ { r } czm _non _compressed _main ( ) ;
} ` ;return[i,o,s,a].join( `
2023-02-13 02:05:23 +00:00
` )}}function G4e(e,t){const n=t.context,i=e._primitive;let o=ZTe;o=e._primitive._batchTable.getVertexShaderCallback()(o),o=Kt._appendDistanceDisplayConditionToShader(i,o),o=Kt._modifyShaderPosition(e,o,t.scene3DOnly),o=Kt._updateColorAttribute(i,o);const r=e._hasPlanarExtentsAttributes,s=r||e._hasSphericalExtentsAttribute;e._extruded&&(o=k4e(i,o));const a=e._extruded?"EXTRUDED_GEOMETRY":"";let c=new We({defines:[a],sources:[o]});const u=new We({sources:[iB]}),f=e._primitive._attributeLocations,h=new ds(s,r,e.appearance);if(e._spStencil=yn.replaceCache({context:n,shaderProgram:e._spStencil,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f}),e._primitive.allowPicking){let p=We.createPickVertexShaderSource(o);p=Kt._appendShowToShader(i,p),p=Kt._updatePickColorAttribute(p);const y=h.createPickFragmentShader(!1),b=h.createPickVertexShader([a],p,!1,t.mapProjection);if(e._spPick=yn.replaceCache({context:n,shaderProgram:e._spPick,vertexShaderSource:b,fragmentShaderSource:y,attributeLocations:f}),s){let C=n.shaderCache.getDerivedShaderProgram(e._spPick,"2dPick");if(!l(C)){const E=h.createPickFragmentShader(!0),w=h.createPickVertexShader([a],p,!0,t.mapProjection);C=n.shaderCache.createDerivedShaderProgram(e._spPick,"2dPick",{vertexShaderSource:w,fragmentShaderSource:E,attributeLocations:f})}e._spPick2D=C}}else e._spPick=yn.fromCache({context:n,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});o=Kt._appendShowToShader(i,o),c=new We({defines:[a],sources:[o]}),e._sp=yn.replaceCache({context:n,shaderProgram:e._sp,vertexShaderSource:c,fragmentShaderSource:u,attributeLocations:f});const m=h.createFragmentShader(!1),g=h.createVertexShader([a],o,!1,t.mapProjection);if(e._spColor=yn.replaceCache({context:n,shaderProgram:e._spColor,vertexShaderSource:g,fragmentShaderSource:m,attributeLocations:f}),s){let p=n.shaderCache.getDerivedShaderProgram(e._spColor,"2dColor");if(!l(p)){const y=h.createFragmentShader(!0),b=h.createVertexShader([a],o,!0,t.mapProjection);p=n.shaderCache.createDerivedShaderProgram(e._spColor,"2dColor",{vertexShaderSource:b,fragmentShaderSource:y,attributeLocations:f})}e._spColor2D=p}}function W4e(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 pt({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsStencilDepthPass,r.shaderProgram=e._sp,r.uniformMap=c,r.pass=Ne.TERRAIN_CLASSIFICATION,s=pt.shallowClone(r,r.derivedCommands.tileset),s.renderState=e._rsStencilDepthPass3DTiles,s.pass=Ne.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,r=t[o+1],l(r)||(r=t[o+1]=new pt({owner:e,primitiveType:n._primitiveType})),r.vertexArray=g,r.renderState=e._rsColorPass,r.shaderProgram=e._spColor,r.pass=Ne.TERRAIN_CLASSIFICATION;const y=e.appearance.material;if(l(y)&&(c=un(c,y._uniforms)),r.uniformMap=c,s=pt.shallowClone(r,r.derivedCommands.tileset),s.pass=Ne.CESIUM_3D_TILE_CLASSIFICATION,r.derivedCommands.tileset=s,u){let b=pt.shallowClone(r,r.derivedCommands.appearance2D);b.shaderProgram=e._spColor2D,r.derivedCommands.appearance2D=b,b=pt.shallowClone(s,s.derivedCommands.appearance2D),b.shaderProgram=e._spColor2D,s.derivedCommands.appearance2D=b}}const f=e._commandsIgnoreShow,h=e._spStencil;let m=0;i=f.length=i/2;for(let g=0;g<i;++g){const p=f[g]=pt.shallowClone(t[m],f[g]);p.shaderProgram=h,p.pass=Ne.CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW,m+=2}}function j4e(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 m=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 pt({owner:e,primitiveType:i._primitiveType,pickOnly:!0})),u.vertexArray=p,u.renderState=e._rsStencilDepthPass,u.shaderProgram=e._sp,u.uniformMap=m,u.pass=Ne.TERRAIN_CLASSIFICATION,n&&(u.offset=a.offset,u.count=a.count),f=pt.shallowClone(u,u.derivedCommands
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;let KB= ` $ { nT }
$ { qHe } ` ;const $ He=_7;pn.isInternetExplorer()||(KB= ` # define CLIP _POLYLINE
$ { KB } ` );function Js(e){e=A(e,A.EMPTY_OBJECT);const t=A(e.translucent,!0),n=!1,i=Js.VERTEX_FORMAT;this.material=void 0,this.translucent=t,this._vertexShaderSource=A(e.vertexShaderSource,KB),this._fragmentShaderSource=A(e.fragmentShaderSource, $ He),this._renderState=Tr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(Js.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}}});Js.VERTEX_FORMAT=Fe.POSITION_ONLY;Js.prototype.getFragmentShaderSource=Tr.prototype.getFragmentShaderSource;Js.prototype.isTranslucent=Tr.prototype.isTranslucent;Js.prototype.getRenderState=Tr.prototype.getRenderState;const YHe= ` attribute vec3 position3DHigh ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;let JB= ` $ { nT }
$ { YHe } ` ;const XHe=pq;pn.isInternetExplorer()||(JB= ` # define CLIP _POLYLINE
$ { JB } ` );function ws(e){e=A(e,A.EMPTY_OBJECT);const t=A(e.translucent,!0),n=!1,i=ws.VERTEX_FORMAT;this.material=l(e.material)?e.material:ze.fromType(ze.ColorType),this.translucent=t,this._vertexShaderSource=A(e.vertexShaderSource,JB),this._fragmentShaderSource=A(e.fragmentShaderSource,XHe),this._renderState=Tr.getDefaultRenderState(t,n,e.renderState),this._closed=n,this._vertexFormat=i}Object.defineProperties(ws.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}}});ws.VERTEX_FORMAT=Fe.POSITION_AND_ST;ws.prototype.getFragmentShaderSource=Tr.prototype.getFragmentShaderSource;ws.prototype.isTranslucent=Tr.prototype.isTranslucent;ws.prototype.getRenderState=Tr.prototype.getRenderState;function pl(e){e=A(e,A.EMPTY_OBJECT),this.geometryInstances=e.geometryInstances,this._hasPerInstanceColors=!0;let t=e.appearance;l(t)||(t=new ws),this.appearance=t,this.show=A(e.show,!0),this.classificationType=A(e.classificationType,So.BOTH),this.debugShowBoundingVolume=A(e.debugShowBoundingVolume,!1),this._debugShowShadowVolume=A(e.debugShowShadowVolume,!1),this._primitiveOptions={geometryInstances:void 0,appearance:void 0,vertexCacheOptimize:!1,interleave:A(e.interleave,!1),releaseGeometryInstances:A(e.releaseGeometryInstances,!0),allowPicking:A(e.allowPicking,!0),asynchronous:A(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=Fk(!1),this._renderState3DTiles=Fk(!0),this._renderStateMorph=Ze.fromCache({cull:{enabled:!0,face:Ho.FRONT},depthTest:{enabled:!0},blending:Gi.PRE_MULTIPLIED_ALPHA_BLEND,depthMask:!1})}Object.defineProperties(pl.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}}});pl.initializeTerrainHeights=function(){return co.initialize()};function KHe(e,t,n){const i=t.context,o=e._primitive,r=o._attributeLocations;let s=o._batchTable.getVertexShaderCallback()(XTe);s=Kt._appendShowToShader(o,s),s=Kt._appendDistanceDisplayConditionToShader(o,s),s=Kt._modifyShaderPosition(e,s,t.scene3DOnly);let a=o._batchTable.getVertexShaderCallback()(YTe);a=Kt._appendShowToShader(o,a),a=Kt._appendDistanceDisplayConditionToShader(o,a),a=Kt._modifyShaderPosition(e,a,t.scene3DOnly);let c=o._batchTable.getVertexShaderCallback()(qTe);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 m=e.debugShowShadowVolume?["DEBUG_SHOW_VOLUME",f]:[f],g=new We({defines:u,sources:[s]}),p=new We({defines:m,sources:[h,c]});e._sp=yn.replaceCache({context:i,shaderProgram:o._sp,vertexShaderSource:g,fragmentShaderSource:p,attributeLocations:r});let y=i.shaderCache.getDerivedShaderProgram(e._sp,"2dColor");if(!l(y)){const C=new We({defines:u.concat(["COLUMBUS_VIEW_2D"]),sources:[s]});y=i.shaderCache.createDerivedShaderProgram(e._sp,"2dColor",{context:i,shaderProgram:e._sp2D,vertexShaderSource:C,fragmentShaderSource:p,attributeLocations:r})}e._sp2D=y;let b=i.shaderCache.getDerivedShaderProgram(e._sp,"MorphColor");if(!l(b)){const C=new We({defines:u.concat([ ` MAX _TERRAIN _HEIGHT $ { co . _defaultMaxTerrainHeight . toFixed ( 1 ) } ` ]),sources:[a]});c=o._batchTable.getVertexShaderCallback()( $ Te);const E=new We({defines:m,sources:[h,c]});b=i.shaderCache.createDerivedShaderProgram(e._sp,"MorphColor",{context:i,shaderProgram:e._spMorph,vertexShaderSource:C,fragmentShaderSo
2023-02-06 08:55:59 +00:00
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 ) ) ;
}
2023-02-13 02:05:23 +00:00
` }Ii.prototype.getVertexShaderCallback=function(e,t,n){if(this.featuresLength===0)return;const i=this;return function(o){const r=HX(o,n,!1);let s;return Dt.maximumVertexTextureImageUnits>0?(s="",e&&(s+= ` uniform bool tile _translucentCommand ;
2023-02-06 08:55:59 +00:00
` ),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 }
2023-02-13 02:05:23 +00:00
$ { tke ( i ) } $ { s } ` }};function Uk(e,t){return e=We.replaceMain(e,"tile_main"),t? ` $ { e } uniform float tile _colorBlend ;
2023-02-06 08:55:59 +00:00
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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` }function nke(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 HX(e,t,n){if(!l(t))return Uk(e,n);let i=new RegExp( ` ( uniform | attribute | in ) \ \ s + ( vec [ 34 ] | sampler2D ) \ \ s + $ { t } ; ` );const o=e.match(i);if(!l(o))return Uk(e,n);const r=o[0],s=o[2];e=We.replaceMain(e,"tile_main"),e=e.replace(r,"");const a= ` bool isWhite ( vec3 color )
2023-02-06 08:55:59 +00:00
{
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 ( ) ;
2023-02-13 02:05:23 +00:00
` }else s==="sampler2D"&&(e=nke(e,t),u= ` tile _diffuse = tile _featureColor ;
2023-02-06 08:55:59 +00:00
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+= ` }
2023-02-13 02:05:23 +00:00
` ,e}Ii.prototype.getFragmentShaderCallback=function(e,t,n){if(this.featuresLength!==0)return function(i){return i=HX(i,t,!0),Dt.maximumVertexTextureImageUnits>0?(i+= ` uniform sampler2D tile _pickTexture ;
2023-02-06 08:55:59 +00:00
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+= ` }
2023-02-13 02:05:23 +00:00
` ),i}};Ii.prototype.getClassificationFragmentShaderCallback=function(){if(this.featuresLength!==0)return function(e){return e=We.replaceMain(e,"tile_main"),Dt.maximumVertexTextureImageUnits>0?e+= ` uniform sampler2D tile _pickTexture ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,e}};function ike(e){const t=e._content.tileset,n=t.colorBlendMode,i=t.colorBlendAmount;if(n=== $ w.HIGHLIGHT)return 0;if(n=== $ w.REPLACE)return 1;if(n=== $ w.MIX)return M.clamp(i,M.EPSILON4,1);throw new x( ` Invalid color blend mode "${n}" . ` )}Ii.prototype.getUniformMapCallback=function(){if(this.featuresLength===0)return;const e=this;return function(t){return un(t,{tile_batchTexture:function(){return A(e._batchTexture.batchTexture,e._batchTexture.defaultTexture)},tile_textureDimensions:function(){return e._batchTexture.textureDimensions},tile_textureStep:function(){return e._batchTexture.textureStep},tile_colorBlend:function(){return ike(e)},tile_pickTexture:function(){return e._batchTexture.pickTexture}})}};Ii.prototype.getPickId=function(){return"texture2D(tile_pickTexture, tile_featureSt)"};const qh={ALL_OPAQUE:0,ALL_TRANSLUCENT:1,OPAQUE_AND_TRANSLUCENT:2};Ii.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=oke(this);for(let u=t;u<i;++u){const f=n[u];if(f.pass===Ne.COMPUTE)continue;let h=f.derivedCommands.tileset;(!l(h)||f.dirty)&&(h={},f.derivedCommands.tileset=h,h.originalCommand=rke(f),f.dirty=!1);const m=h.originalCommand;c!==qh.ALL_OPAQUE&&f.pass!==Ne.TRANSLUCENT&&(l(h.translucent)||(h.translucent=ske(m))),c!==qh.ALL_TRANSLUCENT&&f.pass!==Ne.TRANSLUCENT&&(l(h.opaque)||(h.opaque=ake(m)),a&&(r||(l(h.zback)||(h.zback=lke(e.context,m)),s._backfaceCommands.push(h.zback)),(!l(h.stencil)||o._selectionDepth!==fke(h.stencil))&&(f.renderState.depthMask?h.stencil=uke(m,o._selectionDepth):h.stencil=h.opaque)));const g=a?h.stencil:h.opaque,p=h.translucent;f.pass!==Ne.TRANSLUCENT?(c===qh.ALL_OPAQUE&&(n[u]=g),c===qh.ALL_TRANSLUCENT&&(n[u]=p),c===qh.OPAQUE_AND_TRANSLUCENT&&(n[u]=g,n.push(p))):n[u]=m}};function oke(e){const t=e._batchTexture.translucentFeaturesLength;return t===0?qh.ALL_OPAQUE:t===e.featuresLength?qh.ALL_TRANSLUCENT:qh.OPAQUE_AND_TRANSLUCENT}function rke(e){const t=pt.shallowClone(e),n=t.pass===Ne.TRANSLUCENT;return t.uniformMap=l(t.uniformMap)?t.uniformMap:{},t.uniformMap.tile_translucentCommand=function(){return n},t}function ske(e){const t=pt.shallowClone(e);return t.pass=Ne.TRANSLUCENT,t.renderState=dke(e.renderState),t}function ake(e){const t=pt.shallowClone(e);return t.renderState=hke(e.renderState),t}function cke(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
2023-02-06 08:55:59 +00:00
# extension GL _OES _standard _derivatives : enable
# endif
2023-02-13 02:05:23 +00:00
` ),n=e.shaderCache.createDerivedShaderProgram(t,"zBackfaceLogDepth",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:i,attributeLocations:t._attributeLocations})}return n}function lke(e,t){const n=pt.shallowClone(t),i=dt(n.renderState,!0);i.cull.enabled=!0,i.cull.face=Ho.FRONT,i.colorMask={red:!1,green:!1,blue:!1,alpha:!1},i.polygonOffset={enabled:!0,factor:5,units:5},i.stencilTest=Rt.setCesium3DTileBit(),i.stencilMask=Rt.CESIUM_3D_TILE_MASK,n.renderState=Ze.fromCache(i),n.castShadows=!1,n.receiveShadows=!1,n.uniformMap=dt(t.uniformMap);const o=new j(5,5);return n.uniformMap.u_polygonOffset=function(){return o},n.shaderProgram=cke(e,t.shaderProgram),n}function uke(e,t){const n=pt.shallowClone(e),i=dt(n.renderState,!0);return i.stencilTest.enabled=!0,i.stencilTest.mask=Rt.SKIP_LOD_MASK,i.stencilTest.reference=Rt.CESIUM_3D_TILE_MASK|t<<Rt.SKIP_LOD_BIT_SHIFT,i.stencilTest.frontFunction=_i.GREATER_OR_EQUAL,i.stencilTest.frontOperation.zPass=mt.REPLACE,i.stencilTest.backFunction=_i.GREATER_OR_EQUAL,i.stencilTest.backOperation.zPass=mt.REPLACE,i.stencilMask=Rt.CESIUM_3D_TILE_MASK|Rt.SKIP_LOD_MASK,n.renderState=Ze.fromCache(i),n}function fke(e){return(e.renderState.stencilTest.reference&Rt.SKIP_LOD_MASK)>>>Rt.SKIP_LOD_BIT_SHIFT}function dke(e){const t=dt(e,!0);return t.cull.enabled=!1,t.depthTest.enabled=!0,t.depthMask=!1,t.blending=Gi.ALPHA_BLEND,t.stencilTest=Rt.setCesium3DTileBit(),t.stencilMask=Rt.CESIUM_3D_TILE_MASK,Ze.fromCache(t)}function hke(e){const t=dt(e,!0);return t.stencilTest=Rt.setCesium3DTileBit(),t.stencilMask=Rt.CESIUM_3D_TILE_MASK,Ze.fromCache(t)}Ii.prototype.update=function(e,t){this._batchTexture.update(e,t)};Ii.prototype.isDestroyed=function(){return!1};Ii.prototype.destroy=function(){return this._batchTexture=this._batchTexture&&this._batchTexture.destroy(),He(this)};function KS(e){this.offset=e.offset,this.count=e.count,this.color=e.color,this.batchIds=e.batchIds}class pke{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 mke{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 ke{static get version(){return"1.3.8"}static toString(){return"JavaScript Expression Parser (JSEP) v"+ke.version}static addUnaryOp(t){return ke.max_unop_len=Math.max(t.length,ke.max_unop_len),ke.unary_ops[t]=1,ke}static addBinaryOp(t,n,i){return ke.max_binop_len=Math.max(t.length,ke.max_binop_len),ke.binary_ops[t]=n,i?ke.right_associative.add(t):ke.right_associative.delete(t),ke}static addIdentifierChar(t){return ke.additional_identifier_chars.add(t),ke}static addLiteral(t,n){return ke.literals[t]=n,ke}static removeUnaryOp(t){return delete ke.unary_ops[t],t.length===ke.max_unop_len&&(ke.max_unop_len=ke.getMaxKeyLen(ke.unary_ops)),ke}static removeAllUnaryOps(){return ke.unary_ops={},ke.max_unop_len=0,ke}static removeIdentifierChar(t){return ke.additional_identifier_chars.delete(t),ke}static removeBinaryOp(t){return delete ke.binary_ops[t],t.length===ke.max_binop_len&&(ke.max_binop_len=ke.getMaxKeyLen(ke.binary_ops)),ke.right_associative.delete(t),ke}static removeAllBinaryOps(){return ke.binary_ops={},ke.max_binop_len=0,ke}static removeLiteral(t){return delete ke.literals[t],ke}static removeAllLiterals(){return ke.literals={},ke}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 ke(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 ke.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!ke.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:ke.LITERAL,value:t,raw:this.expr.substring(n,this.index)}}gobbleIdentifier(){let t=this.code,n=this.index;for(ke.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,ke.isIdentifierPart(t));)this.index++;return{type:ke.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===ke.CPAREN_CODE&&o&&o>=n.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(r===ke.COMMA_CODE){if(this.index++,o++,o!==n.length){if(t===ke.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===ke.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===ke.COMPOUND)&&this.throwError("Expected comma"),n.push(s)}}return i||this.throwError("Expected "+String.fromCharCode(t)),n}gobbleGroup(){this.index++;let t=this.gobbleExpressions(ke.CPAREN_CODE);if(this.code===ke.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:ke.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:ke.ARRAY_EXP,elements:this.gobbleArguments(ke.CBRACK_CODE)}}}const _ke=new pke;Object.assign(ke,{hooks:_ke,plugins:new mke(ke),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"});ke.max_unop_len=ke.getMaxKeyLen(ke.unary_ops);ke.max_binop_len=ke.getMaxKeyLen(ke.binary_ops);const l_=e=>new ke(e).parse(),gke=Object.getOwnPropertyNames(ke);gke.forEach(e=>{l_[e]===void 0&&e!=="prototype"&&(l_[e]=ke[e])});l_.Jsep=ke;const yke="ConditionalExpression";var Ake={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:yke,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 :")}})}};l_.plugins.register(Ake);const bke={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},lt=Object.freeze(bke);function uu(e,t){T.typeOf.string("expression",e),this._expression=e,e=Bke(e,t),e=Nke(Rke(e)),l_.addBinaryOp("=~",0),l_.addBinaryOp("!~",0);let n;try{n=l_(e)}catch(i){throw new Ie(i)}this._runtimeAst=Qn(this,n)}Object.defineProperties(uu.prototype,{expression:{get:function(){return this._expression}}});const nn={arrayIndex:0,arrayArray:[[]],cartesian2Index:0,cartesian3Index:0,cartesian4Index:0,cartesian2Array:[new j],cartesian3Array:[new d],cartesian4Array:[new oe],reset:function(){this.arrayIndex=0
2023-02-06 08:55:59 +00:00
{
return $ { o } ;
}
2023-02-13 02:05:23 +00:00
` ,o};uu.prototype.getShaderExpression=function(e,t){return this._runtimeAst.getShaderExpression(e,t)};uu.prototype.getVariables=function(){let e=[];return this._runtimeAst.getVariables(e),e=e.filter(function(t,n,i){return i.indexOf(t)===n}),e};const Cke=["!","-","+"],Hk=["+","-","*","/","%","===","!==",">",">=","<","<=","&&","||","!~","=~"],JS=/ \$ {(.*?)}/g,Tke=/ \\ /g,Eke="@#%",xke=/@#%/g,SD=new H,vD={abs:Hr(Math.abs),sqrt:Hr(Math.sqrt),cos:Hr(Math.cos),sin:Hr(Math.sin),tan:Hr(Math.tan),acos:Hr(Math.acos),asin:Hr(Math.asin),atan:Hr(Math.atan),radians:Hr(M.toRadians),degrees:Hr(M.toDegrees),sign:Hr(M.sign),floor:Hr(Math.floor),ceil:Hr(Math.ceil),round:Hr(Math.round),exp:Hr(Math.exp),exp2:Hr(Ske),log:Hr(Math.log),log2:Hr(vke),fract:Hr(wke),length:Dke,normalize:Ike},DD={atan2:xx(Math.atan2,!1),pow:xx(Math.pow,!1),min:xx(Math.min,!0),max:xx(Math.max,!0),distance:Pke,dot:Oke,cross:Lke},_2={clamp:Vk(M.clamp,!0),mix:Vk(M.lerp,!0)};function wke(e){return e-Math.floor(e)}function Ske(e){return Math.pow(2,e)}function vke(e){return M.log2(e)}function Hr(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),nn.getCartesian2());if(n instanceof d)return d.fromElements(e(n.x),e(n.y),e(n.z),nn.getCartesian3());if(n instanceof oe)return oe.fromElements(e(n.x),e(n.y),e(n.z),e(n.w),nn.getCartesian4());throw new Ie( ` Function "${t}" requires a vector or number argument . Argument is $ { n } . ` )}}function xx(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),nn.getCartesian2());if(i instanceof d)return d.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),nn.getCartesian3());if(i instanceof oe)return oe.fromElements(e(i.x,o),e(i.y,o),e(i.z,o),e(i.w,o),nn.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),nn.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),nn.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),nn.getCartesian4());throw new Ie( ` Function "${n}" requires vector or number arguments of matching types . Arguments are $ { i } and $ { o } . ` )}}function Vk(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),nn.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),nn.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),nn.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),nn.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),nn.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),nn.getCartesian4());throw new Ie( ` Function "${n}" requires vector or number arguments of matching types . Arguments are $ { i } , $ { o } , and $ { r } . ` )}}function Dke(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 Ie( ` Function "${e}" requires a vector or number argument . Argument is $ { t } . ` )}function Ike(e,t){if(typeof t=="number")return 1;if(t instanceof j)return j.normalize(t,nn.getCartesian2());if(t instanceof d)return d.normalize(t,nn.getCartesian3());if(t instanceof oe)return oe.normalize(t,nn.getCartesian4());throw new Ie( ` Function "${e}" requires a vector or number argument . Argument is $ { t } . ` )}function Pke(e,t,n){if(typeof t=="number"&&typeof n=="number")return Math.abs(t-n);if(t instanceof j&&
2023-02-06 08:55:59 +00:00
{
czm _non _pick _main ( ) ;
gl _FragColor = $ { o } ;
}
2023-02-13 02:05:23 +00:00
` ,e._spPick=yn.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:i});return}const a=n.getVertexShaderCallback(!1,"a_batchId",void 0)(VU);let c=n.getFragmentShaderCallback(!1,void 0,!0)(iB);o=n.getPickId();let u=new We({sources:[a]}),f=new We({defines:["VECTOR_TILE"],sources:[c]});e._sp=yn.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),u=new We({sources:[VU]}),f=new We({defines:["VECTOR_TILE"],sources:[iB]}),e._spStencil=yn.fromCache({context:t,vertexShaderSource:u,fragmentShaderSource:f,attributeLocations:i}),c=We.replaceMain(c,"czm_non_pick_main"),c= ` $ { c }
2023-02-06 08:55:59 +00:00
void main ( )
{
czm _non _pick _main ( ) ;
gl _FragColor = $ { o } ;
}
2023-02-13 02:05:23 +00:00
` ;const h=new We({sources:[a]}),m=new We({defines:["VECTOR_TILE"],sources:[c]});e._spPick=yn.fromCache({context:t,vertexShaderSource:h,fragmentShaderSource:m,attributeLocations:i})}function qk(e){const t=e?_i.EQUAL:_i.ALWAYS;return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:t,frontOperation:{fail:mt.KEEP,zFail:mt.DECREMENT_WRAP,zPass:mt.KEEP},backFunction:t,backOperation:{fail:mt.KEEP,zFail:mt.INCREMENT_WRAP,zPass:mt.KEEP},reference:Rt.CESIUM_3D_TILE_MASK,mask:Rt.CESIUM_3D_TILE_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:y_.LESS_OR_EQUAL},depthMask:!1}}const e5e={stencilTest:{enabled:!0,frontFunction:_i.NOT_EQUAL,frontOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},backFunction:_i.NOT_EQUAL,backOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},reference:0,mask:Rt.CLASSIFICATION_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:Gi.PRE_MULTIPLIED_ALPHA_BLEND},t5e={stencilTest:{enabled:!0,frontFunction:_i.NOT_EQUAL,frontOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},backFunction:_i.NOT_EQUAL,backOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},reference:0,mask:Rt.CLASSIFICATION_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1};function n5e(e){l(e._rsStencilDepthPass)||(e._rsStencilDepthPass=Ze.fromCache(qk(!1)),e._rsStencilDepthPass3DTiles=Ze.fromCache(qk(!0)),e._rsColorPass=Ze.fromCache(e5e),e._rsPickPass=Ze.fromCache(t5e))}const Am=new B, $ k=new d;function i5e(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,Am),B.multiplyByPoint(Am,e._center, $ k),B.setTranslation(Am, $ k,Am),B.multiply(o,Am,Am),Am},u_highlightColor:function(){return e._highlightColor}};e._uniformMap=e._batchTable.getUniformMapCallback()(n)}function FP(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],m=i[h],g=o[h],p=new e.constructor(e.buffer,a*m,g);t.set(p,n),i[h]=n,n+=g}return n}function o5e(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=FP(n,s,0,i,o,a.batchIds,r);for(a.offset=0,a.count=u;t.length>0;){const f=t.pop();if(H.equals(f.color,a.color))u=FP(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=FP(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 zP(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],m=i[h],g=o[h];t.copyFromBuffer(e,m*a,n*a,g*a),i[h]=n,n+=g}return n}function r5e(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=zP(a,c,0,n,i,r.batchIds,o);for(r.offset=0,r.count=u;t.length>0;){const h=t.pop();if(H.equals(h.color,r.color))u=zP(a,c,u,n,i,h.batchIds,o),r.batchIds=r.batchIds.concat(h.batchIds),r.count=u-r.offset;else{const m=u;u=zP(a,c,u,n,i,h.batchIds,o),h.offset=m,h.count=u-m,s.push(h),r=h}}const f=e._va;e._va=e._vaSwap,e._vaSwap=f,e._batchedIndices=s}function s5e(e,t){return t.color.toRgba()-e.color.toRgba()}function a5e(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(s5e),t.webgl2?r5e(e,n):o5e(e,n),e._framesSinceLastRebatch=0,e._batchDirty=!1,e._pickCommandsDirty=!0,e._wireframeDirty=!0,!0}function c5e(e,t){const n=a5e(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=A(e._modelMatrix,B.IDENTITY),f=e._uniformMap,h=e._boundingVolume;for(let m=0;m<r;++m){const g=o[m].offset,p=o[m].count;let y=i[m*2];l(y)||(y=i[m*2]=new pt({owner:e})),y.vertexArr
$ { t . message } ` );const n=new Ie(e);return l(t)&&(n.stack= ` Original stack :
2023-02-06 08:55:59 +00:00
$ { t . stack }
Handler stack :
2023-02-13 02:05:23 +00:00
$ { n . stack } ` ),n};pr.prototype.isDestroyed=function(){return!1};pr.prototype.destroy=function(){return this.unload(),He(this)};const dGe={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,FAILED:4},Mt=Object.freeze(dGe);function Zl(e){e=A(e,A.EMPTY_OBJECT);const t=e.typedArray,n=e.resource,i=e.cacheKey;if(l(t)===l(n))throw new x("One of options.typedArray and options.resource must be defined.");this._typedArray=t,this._resource=n,this._cacheKey=i,this._state=Mt.UNLOADED,this._promise=void 0}l(Object.create)&&(Zl.prototype=Object.create(pr.prototype),Zl.prototype.constructor=Zl);Object.defineProperties(Zl.prototype,{promise:{get:function(){return this._promise}},cacheKey:{get:function(){return this._cacheKey}},typedArray:{get:function(){return this._typedArray}}});Zl.prototype.load=function(){return l(this._typedArray)?this._promise=Promise.resolve(this):this._promise=hGe(this),this._promise};function hGe(e){const t=e._resource;return e._state=Mt.LOADING,Zl._fetchArrayBuffer(t).then(function(n){if(!e.isDestroyed())return e._typedArray=new Uint8Array(n),e._state=Mt.READY,e}).catch(function(n){if(e.isDestroyed())return;e._state=Mt.FAILED;const i= ` Failed to load external buffer : $ { t . url } ` ;return Promise.reject(e.getError(i,n))})}Zl._fetchArrayBuffer=function(e){return e.fetchArrayBuffer()};Zl.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 Ie(o);return l(i)&&(r.stack= ` Original stack :
2023-02-06 08:55:59 +00:00
$ { i . stack }
Handler stack :
2023-02-13 02:05:23 +00:00
$ { r . stack } ` ),Promise.reject(r)}};Zt.getNodeTransform=function(e){return l(e.matrix)?e.matrix:B.fromTranslationQuaternionRotationScale(l(e.translation)?e.translation:d.ZERO,l(e.rotation)?e.rotation:Te.IDENTITY,l(e.scale)?e.scale:d.ONE)};Zt.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}};Zt.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}};Zt.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}};Zt.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};Zt.getAttributeInfo=function(e){const t=e.semantic,n=e.setIndex;let i,o=!1;l(t)?(i=wt.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=hn.getGlslType(s);r&&(a="vec4");const c=l(e.quantization);let u;return c&&(u=r?"vec4":hn.getGlslType(e.quantization.type)),{attribute:e,isQuantized:c,variableName:i,hasSemantic:o,glslType:a,quantizedGlslType:u}};const h9e=new d,p9e=new d;Zt.getPositionMinMax=function(e,t,n){const i=Zt.getAttributeBySemantic(e,"POSITION");let o=i.max,r=i.min;return l(n)&&l(t)&&(r=d.add(r,t,p9e),o=d.add(o,n,h9e)),{min:r,max:o}};Zt.getAxisCorrectionMatrix=function(e,t,n){return n=B.clone(B.IDENTITY,n),e===ss.Y?n=B.clone(ss.Y_UP_TO_Z_UP,n):e===ss.X&&(n=B.clone(ss.X_UP_TO_Z_UP,n)),t===ss.Z&&(n=B.multiplyTransformation(n,ss.Z_UP_TO_X_UP,n)),n};const m9e=new J;Zt.getCullFace=function(e,t){if(!Qe.isTriangles(t))return Ho.BACK;const n=B.getMatrix3(e,m9e);return J.determinant(n)<0?Ho.FRONT:Ho.BACK};Zt.sanitizeGlslIdentifier=function(e){let t=e.replaceAll(/[^A-Za-z0-9]+/g,"_");return t=t.replace(/^gl_/,""),/^ \d /.test(t)&&(t= ` _$ { t } ` ),t};Zt.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};Zt.checkSupportedExtensions=function(e){const t=e.length;for(let n=0;n<t;n++){const i=e[n];if(!Zt.supportedExtensions[i])throw new Ie( ` Unsupported glTF Extension : $ { i } ` )}};const ny={TRANSLATION:"TRANSLATION",ROTATION:"ROTATION",SCALE:"SCALE",FEATURE_ID:"_FEATURE_ID"};ny.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 ny.TRANSLATION;case"ROTATION":return ny.ROTATION;case"SCALE":return ny.SCALE;case"_FEATURE_ID":return ny.FEATURE_ID}};const Qs=Object.freeze(ny),_9e=65534,g9e=255;function ST(e){e=A(e,A.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 PK(n,i),this._outlineCoordinatesTypedArray=void 0,this._extraVertices=[],y9e(this)}Object.defineProperties(ST.prototype,{updatedTriangleIndices:{get:function(){return this._triangleIndices}},outlineCoordinates:{get:function(){return this._outlineCoordinatesTypedArray}}});function y9e(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),m=n.hasEdge(u,f),g=n.hasEdge(f,c);let p=u5(i,c,u,f,h,m,g);for(;l(p);){let y=s[p];if(!l(y)){y=r+o.length;let b=p;for(;b>=r;)b=o[b-r];o.push(b),s[p]=y}y>_9e&&(t instanceof Uint16Array||t instanceof Uint8Array)?t=new Uint32Array(t):y>g9e&&t instanceof Uint8Array&&(t=new Uint16Array(t)),p===c?(c
Unsupported glTF version : $ { s } ` )}const a=t.extensionsRequired;l(a)&&(Zt.checkSupportedExtensions(a),e._hasKhrMeshQuantization=a.includes("KHR_mesh_quantization"));const c=A(t.extensions,A.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,z=l(P)?P:[],R=l(L)?L:[];e._sortedPropertyTableIds=Object.keys(z).sort(),e._sortedFeatureTextureIds=Object.keys(R).sort()}const m=SWe(e,t,n,i),g=DWe(e,t,m),p=RWe(e,t,m),y=FWe(t),b=UWe(t,m),C=new k9e,E=new H9e,w=t.asset.copyright;if(l(w)){const P=w.split(";").map(function(L){return new si(L.trim())});E.credits=P}if(C.asset=E,C.scene=b,C.nodes=m,C.skins=g,C.animations=p,C.articulations=y,C.upAxis=e._upAxis,C.forwardAxis=e._forwardAxis,l(h)){const P=d.fromArray(h.center,0,HWe);C.transform=B.fromTranslation(P,C.transform)}if(e._components=C,l(u)||l(f)){const L=IWe(e,t,u,f,n,i).promise.then(function(z){e.isDestroyed()||(C.structuralMetadata=z.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=bo.POST_PROCESSING)}).catch(o),Promise.all(e._texturesPromises).then(function(){e.isDestroyed()||(e._textureState=bo.PROCESSED)}).catch(r)}function kWe(e){const t=e._textureLoaders,n=t.length;for(let i=0;i<n;++i)gt.unload(t[i]);e._textureLoaders.length=0}function GK(e){const t=e._bufferViewLoaders,n=t.length;for(let i=0;i<n;++i)gt.unload(t[i]);e._bufferViewLoaders.length=0}function GWe(e){const t=e._geometryLoaders,n=t.length;for(let i=0;i<n;++i)gt.unload(t[i]);e._geometryLoaders.length=0}function WWe(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 jWe(e){l(e._structuralMetadataLoader)&&(e._structuralMetadataLoader.destroy(),e._structuralMetadataLoader=void 0)}eu.prototype.isUnloaded=function(){return this._state===bo.UNLOADED};eu.prototype.unload=function(){l(this._gltfJsonLoader)&>.unload(this._gltfJsonLoader),this._gltfJsonLoader=void 0,kWe(this),GK(this),GWe(this),WWe(this),jWe(this),this._components=void 0,this._typedArray=void 0,this._state=bo.UNLOADED};const qWe= ` # extension GL _EXT _frag _depth : enable
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;function Zp(){this._framebuffer=new Pn({colorAttachmentsLength:2,depth:!0,supportsDepthTexture:!0}),this._drawCommand=void 0,this._clearCommand=void 0,this._strength=1,this._radius=1}Object.defineProperties(Zp.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 $ We(e){e._framebuffer.destroy(),e._drawCommand=void 0,e._clearCommand=void 0}const jP=new j;function YWe(e,t){const n=new We({defines:["LOG_DEPTH_WRITE"],sources:[qWe]}),i={u_pointCloud_colorGBuffer:function(){return e.colorGBuffer},u_pointCloud_depthGBuffer:function(){return e.depthGBuffer},u_distanceAndEdlStrength:function(){return jP.x=e._radius,jP.y=e._strength,jP}},o=Ze.fromCache({blending:Gi.ALPHA_BLEND,depthMask:!0,depthTest:{enabled:!0},stencilTest:Rt.setCesium3DTileBit(),stencilMask:Rt.CESIUM_3D_TILE_MASK});e._drawCommand=t.createViewportQuadCommand(n,{uniformMap:i,renderState:o,pass:Ne.CESIUM_3D_TILE,owner:e}),e._clearCommand=new ao({framebuffer:e.framebuffer,color:new H(0,0,0,0),depth:1,renderState:Ze.fromCache(),pass:Ne.CESIUM_3D_TILE,owner:e})}function XWe(e,t){const n=t.drawingBufferWidth,i=t.drawingBufferHeight;e._framebuffer.update(t,n,i),YWe(e,t)}function WK(e){return e.drawBuffers&&e.fragmentDepth}Zp.isSupported=WK;function KWe(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=We.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
2023-02-06 08:55:59 +00:00
` ),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
2023-02-13 02:05:23 +00:00
} ` ),n=e.shaderCache.createDerivedShaderProgram(t,"EC",{vertexShaderSource:t.vertexShaderSource,fragmentShaderSource:o,attributeLocations:i})}return n}Zp.prototype.update=function(e,t,n,i){if(!WK(e.context))return;this._strength=n.eyeDomeLightingStrength,this._radius=n.eyeDomeLightingRadius*e.pixelRatio,XWe(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!==Qe.POINTS||u.pass===Ne.TRANSLUCENT)continue;let f,h,m=u.derivedCommands.pointCloudProcessor;l(m)&&(f=m.command,h=m.originalShaderProgram),(!l(f)||u.dirty||h!==u.shaderProgram||f.framebuffer!==this.framebuffer)&&(f=pt.shallowClone(u,f),f.framebuffer=this.framebuffer,f.shaderProgram=KWe(e.context,u.shaderProgram),f.castShadows=!1,f.receiveShadows=!1,l(m)||(m={command:f,originalShaderProgram:u.shaderProgram},u.derivedCommands.pointCloudProcessor=m),m.originalShaderProgram=u.shaderProgram),r[o]=f}const a=this._clearCommand,c=this._drawCommand;c.boundingVolume=i,r.push(c),r.push(a)};Zp.prototype.isDestroyed=function(){return!1};Zp.prototype.destroy=function(){return $ We(this),He(this)};function vT(e){const t=A(e,{});this.attenuation=A(t.attenuation,!1),this.geometricErrorScale=A(t.geometricErrorScale,1),this.maximumAttenuation=t.maximumAttenuation,this.baseResolution=t.baseResolution,this.eyeDomeLighting=A(t.eyeDomeLighting,!0),this.eyeDomeLightingStrength=A(t.eyeDomeLightingStrength,1),this.eyeDomeLightingRadius=A(t.eyeDomeLightingRadius,1),this.backFaceCulling=A(t.backFaceCulling,!1),this.normalShading=A(t.normalShading,!0)}vT.isSupported=function(e){return Zp.isSupported(e.context)};const by={};by._deprecationWarning=Gp;const Wf=Uint32Array.BYTES_PER_ELEMENT;by.parse=function(e,t){const n=A(t,0);T.defined("arrayBuffer",e),t=n;const i=new Uint8Array(e),o=new DataView(e);t+=Wf;const r=o.getUint32(t,!0);if(r!==1)throw new Ie( ` Only Batched 3 D Model version 1 is supported . Version $ { r } is not . ` );t+=Wf;const s=o.getUint32(t,!0);t+=Wf;let a=o.getUint32(t,!0);t+=Wf;let c=o.getUint32(t,!0);t+=Wf;let u=o.getUint32(t,!0);t+=Wf;let f=o.getUint32(t,!0);t+=Wf;let h;u>=570425344?(t-=Wf*2,h=a,u=c,f=0,a=0,c=0,by._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-=Wf,h=u,u=a,f=c,a=0,c=0,by._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 m;a===0?m={BATCH_LENGTH:A(h,0)}:(m=qa(i,t,a),t+=a);const g=new Uint8Array(e,t,c);t+=c;let p,y;u>0&&(p=qa(i,t,u),t+=u,f>0&&(y=new Uint8Array(e,t,f),y=new Uint8Array(y),t+=f));const b=n+s-t;if(b===0)throw new Ie("glTF byte length must be greater than 0.");let C;return t%4===0?C=new Uint8Array(e,t,b):(by._deprecationWarning("b3dm-glb-unaligned","The embedded glb is not aligned to a 4-byte boundary."),C=new Uint8Array(i.subarray(t,t+b))),{batchLength:h,featureTableJson:m,featureTableBinary:g,batchTableJson:p,batchTableBinary:y,gltf:C}};const JWe=by;function em(e,t){this.json=e,this.buffer=t,this._cachedTypedArrays={},this.featuresLength=0}function jK(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 QWe(e,t,n,i){const o=e._cachedTypedArrays;let r=o[t];return l(r)||(r=ee.createTypedArray(n,i),o[t]=r),r}em.prototype.getGlobalProperty=function(e,t,n){const i=this.json[e];if(l(i))return l(i.byteOffset)?(t=A(t,ee.UNSIGNED_INT),n=A(n,1),jK(this,e,t,n,1,i.byteOffset)):i};em.prototype.hasProperty=function(e){return l(this.json[e])};em.prototype.getProper
2023-02-06 08:55:59 +00:00
# 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 ;
}
2023-02-13 02:05:23 +00:00
` ,Gje= ` precision highp float ;
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ;function R2(e){e=A(e,A.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!==So.CESIUM_3D_TILE,this._classifies3DTiles=o!==So.TERRAIN,this._useDebugWireframe=i._enableDebugWireframe&&i.debugWireframe,this._pickId=n.pickId,this._commandListTerrain=[],this._commandList3DTiles=[],this._commandListIgnoreShow=[],this._commandListDebugWireframe=[],this._commandListTerrainPicking=[],this._commandList3DTilesPicking=[], $ je(this)}function Wje(e){return{colorMask:{red:!1,green:!1,blue:!1,alpha:!1},stencilTest:{enabled:!0,frontFunction:e,frontOperation:{fail:mt.KEEP,zFail:mt.DECREMENT_WRAP,zPass:mt.KEEP},backFunction:e,backOperation:{fail:mt.KEEP,zFail:mt.INCREMENT_WRAP,zPass:mt.KEEP},reference:Rt.CESIUM_3D_TILE_MASK,mask:Rt.CESIUM_3D_TILE_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!0,func:y_.LESS_OR_EQUAL},depthMask:!1}}const jje={stencilTest:{enabled:!0,frontFunction:_i.NOT_EQUAL,frontOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},backFunction:_i.NOT_EQUAL,backOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},reference:0,mask:Rt.CLASSIFICATION_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1,blending:Gi.PRE_MULTIPLIED_ALPHA_BLEND},qje={stencilTest:{enabled:!0,frontFunction:_i.NOT_EQUAL,frontOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},backFunction:_i.NOT_EQUAL,backOperation:{fail:mt.ZERO,zFail:mt.ZERO,zPass:mt.ZERO},reference:0,mask:Rt.CLASSIFICATION_MASK},stencilMask:Rt.CLASSIFICATION_MASK,depthTest:{enabled:!1},depthMask:!1},iJ=[];function $ je(e){const t=e._command,n=iJ;if(e._useDebugWireframe){t.pass=Ne.OPAQUE,n.length=0,n.push(t),e._commandListDebugWireframe=Mb(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=Ne.TERRAIN_CLASSIFICATION,s=uR(t,r),a=m5(t,r);n.length=0,n.push(s,a),e._commandListTerrain=Mb(e,n,e._commandListTerrain),o&&(e._commandListTerrainPicking=_5(e,n,e._commandListTerrainPicking))}if(e._classifies3DTiles){const r=Ne.CESIUM_3D_TILE_CLASSIFICATION,s=uR(t,r),a=m5(t,r);n.length=0,n.push(s,a),e._commandList3DTiles=Mb(e,n,e._commandList3DTiles),o&&(e._commandList3DTilesPicking=_5(e,n,e._commandList3DTilesPicking))}}function Mb(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 m=t[h],g=pt.shallowClone(m);g.count=u,g.offset=f,n.push(g)}}return n}function uR(e,t){const n=pt.shallowClone(e);n.cull=!1,n.pass=t;const i=t===Ne.TERRAIN_CLASSIFICATION?_i.ALWAYS:_i.EQUAL,o=Wje(i);return n.renderState=Ze.fromCache(o),n}function m5(e,t){const n=pt.shallowClone(e);return n.cull=!1,n.pass=t,n.renderState=Ze.fromCache(jje),n}const Yje=[];function _5(e,t,n){const i=Ze.fromCache(qje),o=t[0],r=t[1],s=pt.shallowClone(o);s.cull=!0,s.pickOnly=!0;const a=pt.shallowClone(r);a.cull=!0,a.pickOnly=!0,a.renderState=i,a.pickId=e._pickId;const c=Yje;return c.length=0,c.push(s,a),Mb(e,c,n)}Object.defineProperties(R2.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=de.transform(t,this._modelMatrix,this._boundingVolume)}},boundingVolume:{get
2023-02-06 08:55:59 +00:00
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
2023-02-13 02:05:23 +00:00
} ` ,sJ={name:"ImageBasedLightingPipelineStage"};sJ.process=function(e,t,n){const i=t.imageBasedLighting,o=e.shaderBuilder;o.addDefine("USE_IBL_LIGHTING",void 0,De.FRAGMENT),o.addUniform("vec2","model_iblFactor",De.FRAGMENT),lu.isSupported(n.context)&&((i.useSphericalHarmonics||i.useSpecularEnvironmentMaps||i.enabled)&&o.addUniform("mat3","model_iblReferenceFrameMatrix",De.FRAGMENT),l(i.sphericalHarmonicCoefficients)?(o.addDefine("DIFFUSE_IBL",void 0,De.FRAGMENT),o.addDefine("CUSTOM_SPHERICAL_HARMONICS",void 0,De.FRAGMENT),o.addUniform("vec3","model_sphericalHarmonicCoefficients[9]",De.FRAGMENT)):i.useDefaultSphericalHarmonics&&o.addDefine("DIFFUSE_IBL",void 0,De.FRAGMENT),l(i.specularEnvironmentMapAtlas)&&i.specularEnvironmentMapAtlas.ready?(o.addDefine("SPECULAR_IBL",void 0,De.FRAGMENT),o.addDefine("CUSTOM_SPECULAR_IBL",void 0,De.FRAGMENT),o.addUniform("sampler2D","model_specularEnvironmentMaps",De.FRAGMENT),o.addUniform("vec2","model_specularEnvironmentMapsSize",De.FRAGMENT),o.addUniform("float","model_specularEnvironmentMapsMaximumLOD",De.FRAGMENT)):t.useDefaultSpecularMaps&&o.addDefine("SPECULAR_IBL",void 0,De.FRAGMENT)),l(i.luminanceAtZenith)&&(o.addDefine("USE_SUN_LUMINANCE",void 0,De.FRAGMENT),o.addUniform("float","model_luminanceAtZenith",De.FRAGMENT)),o.addFragmentLines(hqe);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=un(r,e.uniformMap)};const pqe=sJ,mqe=M.EPSILON16;function N2(e){e=A(e,A.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(N2.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=M.clamp(e,this.minimumValue,this.maximumValue),M.equalsEpsilon(this._currentValue,e,mqe)||(this._currentValue=e,this.runtimeArticulation._dirty=!0)}}});const _qe=new d,qP=new J;N2.prototype.applyStageToMatrix=function(e){T.typeOf.object("result",e);const t=this.type,n=this.currentValue,i=_qe;let o;switch(t){case Fl.XROTATE:o=J.fromRotationX(M.toRadians(n),qP),e=B.multiplyByMatrix3(e,o,e);break;case Fl.YROTATE:o=J.fromRotationY(M.toRadians(n),qP),e=B.multiplyByMatrix3(e,o,e);break;case Fl.ZROTATE:o=J.fromRotationZ(M.toRadians(n),qP),e=B.multiplyByMatrix3(e,o,e);break;case Fl.XTRANSLATE:i.x=n,i.y=0,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case Fl.YTRANSLATE:i.x=0,i.y=n,i.z=0,e=B.multiplyByTranslation(e,i,e);break;case Fl.ZTRANSLATE:i.x=0,i.y=0,i.z=n,e=B.multiplyByTranslation(e,i,e);break;case Fl.XSCALE:i.x=n,i.y=1,i.z=1,e=B.multiplyByScale(e,i,e);break;case Fl.YSCALE:i.x=1,i.y=n,i.z=1,e=B.multiplyByScale(e,i,e);break;case Fl.ZSCALE:i.x=1,i.y=1,i.z=n,e=B.multiplyByScale(e,i,e);break;case Fl.UNIFORMSCALE:e=B.multiplyByUniformScale(e,n,e);break}return e};function MD(e){e=A(e,A.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
2023-02-06 08:55:59 +00:00
{
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 ;
2023-02-13 02:05:23 +00:00
} ` ,ry={name:"ModelColorPipelineStage",COLOR_UNIFORM_NAME:"model_color",COLOR_BLEND_UNIFORM_NAME:"model_colorBlend"};ry.process=function(e,t,n){const i=e.shaderBuilder;i.addDefine("HAS_MODEL_COLOR",void 0,De.FRAGMENT),i.addFragmentLines(bqe);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=Ne.TRANSLUCENT),i.addUniform("vec4",ry.COLOR_UNIFORM_NAME,De.FRAGMENT),o[ry.COLOR_UNIFORM_NAME]=function(){return t.color},i.addUniform("float",ry.COLOR_BLEND_UNIFORM_NAME,De.FRAGMENT),o[ry.COLOR_BLEND_UNIFORM_NAME]=function(){return LD.getColorBlend(t.colorBlendMode,t.colorBlendAmount)},e.uniformMap=un(o,e.uniformMap)};const fR=ry,Cqe= ` # ifdef USE _CLIPPING _PLANES _FLOAT _TEXTURE
2023-02-06 08:55:59 +00:00
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 ;
}
}
2023-02-13 02:05:23 +00:00
` ,aJ={name:"ModelClippingPlanesPipelineStage"},Tqe=new j;aJ.process=function(e,t,n){const i=t.clippingPlanes,o=n.context,r=e.shaderBuilder;r.addDefine("HAS_CLIPPING_PLANES",void 0,De.FRAGMENT),r.addDefine("CLIPPING_PLANES_LENGTH",i.length,De.FRAGMENT),i.unionClippingRegions&&r.addDefine("UNION_CLIPPING_REGIONS",void 0,De.FRAGMENT),Do.useFloatTexture(o)&&r.addDefine("USE_CLIPPING_PLANES_FLOAT_TEXTURE",void 0,De.FRAGMENT);const s=Do.getTextureResolution(i,o,Tqe);r.addDefine("CLIPPING_PLANES_TEXTURE_WIDTH",s.x,De.FRAGMENT),r.addDefine("CLIPPING_PLANES_TEXTURE_HEIGHT",s.y,De.FRAGMENT),r.addUniform("sampler2D","model_clippingPlanes",De.FRAGMENT),r.addUniform("vec4","model_clippingPlanesEdgeStyle",De.FRAGMENT),r.addUniform("mat4","model_clippingPlanesMatrix",De.FRAGMENT),r.addFragmentLines(Cqe);const a={model_clippingPlanes:function(){return i.texture},model_clippingPlanesEdgeStyle:function(){const c=H.clone(i.edgeColor);return c.alpha=i.edgeWidth,c},model_clippingPlanesMatrix:function(){return t._clippingPlanesMatrix}};e.uniformMap=un(a,e.uniformMap)};const Eqe=aJ;function cJ(e,t){T.typeOf.object("model",e),T.typeOf.object("runtimeNode",t),this._model=e,this._runtimeNode=t}Object.defineProperties(cJ.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 xqe= ` mat4 getInstancingTransform ( )
2023-02-06 08:55:59 +00:00
{
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
2023-02-13 02:05:23 +00:00
` ,wqe= ` void instancingStage ( inout ProcessedAttributes attributes )
2023-02-06 08:55:59 +00:00
{
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
}
2023-02-13 02:05:23 +00:00
` ,Sqe= ` void legacyInstancingStage (
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,Rx=new B,vqe=new B,Dqe=new B,lJ={name:"InstancingPipelineStage",_getInstanceTransformsAsMatrices:pJ,_transformsToTypedArray:dR};lJ.process=function(e,t,n){const i=t.instances,o=i.attributes[0].count,r=e.shaderBuilder;r.addDefine("HAS_INSTANCING"),r.addVertexLines(xqe);const s=e.model,a=s.sceneGraph,c=e.runtimeNode,u=n.mode!==le.SCENE3D&&!n.scene3DOnly&&s._projectTo2D,f=[];Hqe(e,n,i,f,u),Gqe(e,n,i,f);const h={};if(i.transformInWorldSpace?(r.addDefine("USE_LEGACY_INSTANCING",void 0,De.VERTEX),r.addUniform("mat4","u_instance_modifiedModelView",De.VERTEX),r.addUniform("mat4","u_instance_nodeTransform",De.VERTEX),h.u_instance_modifiedModelView=function(){let m=B.multiplyTransformation(s.modelMatrix,a.components.transform,Rx);return u?B.multiplyTransformation(n.context.uniformState.view3D,m,Rx):(n.mode!==le.SCENE3D&&(m=sn.basisTo2D(n.mapProjection,m,Rx)),B.multiplyTransformation(n.context.uniformState.view,m,Rx))},h.u_instance_nodeTransform=function(){return B.multiplyTransformation(a.axisCorrectionMatrix,c.computedTransform,vqe)},r.addVertexLines(Sqe)):r.addVertexLines(wqe),u){r.addDefine("USE_2D_INSTANCING",void 0,De.VERTEX),r.addUniform("mat4","u_modelView2D",De.VERTEX);const m=n.context,g=B.fromTranslation(c.instancingReferencePoint2D,new B);h.u_modelView2D=function(){return B.multiplyTransformation(m.uniformState.view,g,Dqe)}}e.uniformMap=un(h,e.uniformMap),e.instanceCount=o,e.attributes.push.apply(e.attributes,f)};const Fb=new B,Iqe=new d;function Pqe(e,t,n,i,o){let r=B.multiplyTransformation(t,e,Fb);return r=B.multiplyTransformation(r,n,Fb),o=sn.basisTo2D(i.mapProjection,r,o),o}function Oqe(e,t,n,i,o){const r=B.fromTranslation(e,Fb);let s=B.multiplyTransformation(t,r,Fb);s=B.multiplyTransformation(s,n,Fb);const a=B.getTranslation(s,Iqe);return o=br.computeActualWgs84Position(i,a,o),o}function uJ(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 fJ=new B,dJ=new B,Lqe=new B,Bqe=new d;function Rqe(e,t,n,i){const o=fJ,r=dJ;uJ(t,o,r);const a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){const f=e[u],h=Pqe(f,o,r,n,Lqe),m=B.getTranslation(h,Bqe),g=d.subtract(m,a,m);i[u]=B.setTranslation(h,g,i[u])}return i}function Nqe(e,t,n,i){const o=fJ,r=dJ;uJ(t,o,r);const a=t.runtimeNode.instancingReferencePoint2D,c=e.length;for(let u=0;u<c;u++){const f=e[u],h=Oqe(f,o,r,n,f);i[u]=d.subtract(h,a,i[u])}return i}const Mqe=new d,Fqe=new d;function hJ(e,t){const n=e.runtimeNode,i=e.model.sceneGraph.computedModelMatrix,o=B.multiplyByPoint(i,n.instancingTranslationMin,Mqe),r=br.computeActualWgs84Position(t,o,o),s=B.multiplyByPoint(i,n.instancingTranslationMax,Fqe),a=br.computeActualWgs84Position(t,s,s);n.instancingReferencePoint2D=d.lerp(r,a,.5,new d)}function dR(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 zqe(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 Te;new d;function pJ(e,t,n){const i=new Array(t),o=Zt.getAttributeBySemantic(e,Qs.TRANSLATION),r=Zt.getAttributeBySemantic(e,Qs.ROTATION),s=Zt.getAttributeBySemantic(e,Qs.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),m=u?o.typedArray:new Float32Array(t*3);let g=f?r.typedArray:new Float32Array(t*4);f&&r.normalized&&(g=mi.dequantize(g,r.componentDatatype,r.type,t));let p;h?p=s.typedArray:(p=new Float32Array(t*3),p.fill(1));for(let b=0;b<t;b++){const C=new d(m[b*3],m[b*3+1],m[b*3+2]);d.maximumByComponent(a,C,a),d.minimumByComponent(c,C,c);const E=new T
2023-02-06 08:55:59 +00:00
{
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
}
2023-02-13 02:05:23 +00:00
` ,Zqe= ` void filterByPassType ( vec4 featureColor )
2023-02-06 08:55:59 +00:00
{
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 ;
}
2023-02-13 02:05:23 +00:00
` ,TJ={name:"CPUStylingPipelineStage"};TJ.process=function(e,t,n){const i=e.model,o=e.shaderBuilder;o.addVertexLines(Qqe),o.addFragmentLines(Zqe),o.addDefine("USE_CPU_STYLING",void 0,De.BOTH),l(i.color)||(o.addUniform("float",fR.COLOR_BLEND_UNIFORM_NAME,De.FRAGMENT),e.uniformMap[fR.COLOR_BLEND_UNIFORM_NAME]=function(){return LD.getColorBlend(i.colorBlendMode,i.colorBlendAmount)}),o.addUniform("bool","model_commandTranslucent",De.BOTH),e.uniformMap.model_commandTranslucent=function(){return e.alphaOptions.pass===Ne.TRANSLUCENT}};const e7e=TJ,EJ={MODIFY_MATERIAL:"MODIFY_MATERIAL",REPLACE_MATERIAL:"REPLACE_MATERIAL"};EJ.getDefineName=function(e){return ` CUSTOM _SHADER _$ { e } ` };const F2=Object.freeze(EJ),t7e= ` void customShaderStage (
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,n7e= ` void customShaderStage (
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,i7e= ` void featureIdStage ( out FeatureIds featureIds , ProcessedAttributes attributes ) {
2023-02-06 08:55:59 +00:00
initializeFeatureIds ( featureIds , attributes ) ;
initializeFeatureIdAliases ( featureIds ) ;
}
2023-02-13 02:05:23 +00:00
` ,o7e= ` void featureIdStage ( out FeatureIds featureIds , ProcessedAttributes attributes )
2023-02-06 08:55:59 +00:00
{
initializeFeatureIds ( featureIds , attributes ) ;
initializeFeatureIdAliases ( featureIds ) ;
setFeatureIdVaryings ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,ci={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()"};ci.process=function(e,t,n){const i=e.shaderBuilder;r7e(i);const o=e.runtimeNode.node.instances;l(o)&&s7e(e,o,n),a7e(e,t,n),i.addVertexLines(o7e),i.addFragmentLines(i7e)};function r7e(e){e.addStruct(ci.STRUCT_ID_FEATURE_IDS_VS,ci.STRUCT_NAME_FEATURE_IDS,De.VERTEX),e.addStruct(ci.STRUCT_ID_FEATURE_IDS_FS,ci.STRUCT_NAME_FEATURE_IDS,De.FRAGMENT),e.addFunction(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,ci.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,De.VERTEX),e.addFunction(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,ci.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_IDS,De.FRAGMENT),e.addFunction(ci.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_VS,ci.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,De.VERTEX),e.addFunction(ci.FUNCTION_ID_INITIALIZE_FEATURE_ID_ALIASES_FS,ci.FUNCTION_SIGNATURE_INITIALIZE_FEATURE_ID_ALIASES,De.FRAGMENT),e.addFunction(ci.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,ci.FUNCTION_SIGNATURE_SET_FEATURE_ID_VARYINGS,De.VERTEX)}function s7e(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 Ot.FeatureIdAttribute?c7e(e,s,a):xJ(e,s,a,o,1,n);const c=s.label;l(c)&&wJ(e,a,c,De.BOTH)}}function a7e(e,t,n){const i=t.featureIds,r=Zt.getAttributeBySemantic(t,wt.POSITION).count;for(let s=0;s<i.length;s++){const a=i[s],c=a.positionalLabel;let u=De.BOTH;a instanceof Ot.FeatureIdAttribute?l7e(e,a,c):a instanceof Ot.FeatureIdImplicitRange?xJ(e,a,c,r,void 0,n):(u7e(e,a,c,s,n),u=De.FRAGMENT);const f=a.label;l(f)&&wJ(e,c,f,u)}}function c7e(e,t,n){const i=e.shaderBuilder;i.addStructField(ci.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ci.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(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[c]),i.addFunctionLines(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[u]),i.addVarying("float",a),i.addFunctionLines(ci.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[ ` $ { a } = $ { s } ; ` ])}function l7e(e,t,n){const i=e.shaderBuilder;i.addStructField(ci.STRUCT_ID_FEATURE_IDS_VS,"int",n),i.addStructField(ci.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(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,s),i.addFunctionLines(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,s)}function xJ(e,t,n,i,o,r){f7e(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(ci.STRUCT_ID_FEATURE_IDS_VS,"int",n),s.addStructField(ci.STRUCT_ID_FEATURE_IDS_FS,"int",n),s.addFunctionLines(ci.FUNCTION_ID_SET_FEATURE_ID_VARYINGS,[ ` $ { c } = $ { a } ; ` ]),s.addFunctionLines(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_VS,[ ` featureIds . $ { n } = int ( czm _round ( $ { a } ) ) ; ` ]),s.addFunctionLines(ci.FUNCTION_ID_INITIALIZE_FEATURE_IDS_FS,[ ` featureIds . $ { n } = int ( czm _round ( $ { c } ) ) ; ` ])}function u7e(e,t,n,i,o){const r= ` u _featureIdTexture _$ { i } ` ,s=e.uniformMap,a=t.textureReader;s[r]=function(){return A(a.texture,o.context.defaultTexture)};const c=a.channels,u=e.shaderBuilder;u.addStructField(ci.STRUCT_ID_FEATURE_IDS_FS,"int",n),u.addUniform("sampler2D",r,De.FRAGMENT);const f= ` v _texCoord _$ { a . texCo
2023-02-06 08:55:59 +00:00
out Metadata metadata ,
out MetadataClass metadataClass ,
out MetadataStatistics metadataStatistics ,
ProcessedAttributes attributes
)
{
initializeMetadata ( metadata , metadataClass , metadataStatistics , attributes ) ;
}
2023-02-13 02:05:23 +00:00
` ,p7e= ` void metadataStage (
2023-02-06 08:55:59 +00:00
out Metadata metadata ,
out MetadataClass metadataClass ,
out MetadataStatistics metadataStatistics ,
ProcessedAttributes attributes
)
{
initializeMetadata ( metadata , metadataClass , metadataStatistics , attributes ) ;
setMetadataVaryings ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,Zn={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"}]};Zn.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=m7e(r.propertyAttributes,t,a),u=g7e(r.propertyTextures,a),f=c.concat(u);A7e(i,f),T7e(i),i.addVertexLines(p7e),i.addFragmentLines(h7e);for(let m=0;m<c.length;m++){const g=c[m];E7e(e,g)}for(let m=0;m<u.length;m++){const g=u[m];w7e(e,g)}};function m7e(e,t,n){return l(e)?e.flatMap(i=>_7e(i,t,n)):[]}function _7e(e,t,n){const{getAttributeByName:i,getAttributeInfo:o,sanitizeGlslIdentifier:r}=Zt,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,m]=c[f],g=i(t,m.attribute),{glslType:p,variableName:y}=o(g);u[f]={metadataVariable:r(h),property:m,type:m.classProperty.type,glslType:p,variableName:y,propertyStatistics:a==null?void 0:a.properties[h],shaderDestination:De.BOTH}}return u}function g7e(e,t){return l(e)?e.flatMap(n=>y7e(n,t)):[]}function y7e(e,t){const{sanitizeGlslIdentifier:n}=Zt,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:De.FRAGMENT}}return s}function A7e(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!==Bt.ENUM&&i.add(u)}const o=Zn.METADATA_CLASS_FIELDS;for(const a of n){const c= ` $ { a } MetadataClass ` ;s(c,a,o)}const r=Zn.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,De.BOTH);for(let f=0;f<u.length;f++){const{shaderName:h}=u[f],m=u[f].type==="float"?C7e(c):c;e.addStructField(a,m,h)}}}const b7e={int:"float",ivec2:"vec2",ivec3:"vec3",ivec4:"vec4"};function C7e(e){const t=b7e[e];return l(t)?t:e}function T7e(e){e.addStruct(Zn.STRUCT_ID_METADATA_VS,Zn.STRUCT_NAME_METADATA,De.VERTEX),e.addStruct(Zn.STRUCT_ID_METADATA_FS,Zn.STRUCT_NAME_METADATA,De.FRAGMENT),e.addStruct(Zn.STRUCT_ID_METADATA_CLASS_VS,Zn.STRUCT_NAME_METADATA_CLASS,De.VERTEX),e.addStruct(Zn.STRUCT_ID_METADATA_CLASS_FS,Zn.STRUCT_NAME_METADATA_CLASS,De.FRAGMENT),e.addStruct(Zn.STRUCT_ID_METADATA_STATISTICS_VS,Zn.STRUCT_NAME_METADATA_STATISTICS,De.VERTEX),e.addStruct(Zn.STRUCT_ID_METADATA_STATISTICS_FS,Zn.STRUCT_NAME_METADATA_STATISTICS,De.FRAGMENT),e.addFunction(Zn.FUNCTION_ID_INITIALIZE_METADATA_VS,Zn.FUNCTION_SIGNATURE_INITIALIZE_METADATA,De.VERTEX),e.addFunction(Zn.FUNCTION
2023-02-06 08:55:59 +00:00
{
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 ) ;
}
2023-02-13 02:05:23 +00:00
` , $ 7e= ` vec4 geometryStage ( inout ProcessedAttributes attributes , mat4 modelView , mat3 normal )
2023-02-06 08:55:59 +00:00
{
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 ;
}
2023-02-13 02:05:23 +00:00
` ,A5= ` vec2 computeSt ( float featureId )
2023-02-06 08:55:59 +00:00
{
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
}
2023-02-13 02:05:23 +00:00
` ,Ub={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)"};Ub.process=function(e,t,n){const i=e.shaderBuilder;e.hasPropertyTable=!0;const o=e.model,r=e.runtimeNode.node,s=Y7e(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),X7e(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===De.BOTH&&i.addVertexLines(A5),i.addFragmentLines(A5)};function b5(e){return e instanceof Ot.FeatureIdTexture?"HAS_SELECTED_FEATURE_ID_TEXTURE":"HAS_SELECTED_FEATURE_ID_ATTRIBUTE"}function C5(e){return e instanceof Ot.FeatureIdTexture?De.FRAGMENT:De.BOTH}function Y7e(e,t,n){let i,o;return l(t.instances)&&(o=Zt.getFeatureIdsByLabel(t.instances.featureIds,e.instanceFeatureIdLabel),l(o))?(i=A(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:C5(o),featureIdDefine:b5(o)}):(o=Zt.getFeatureIdsByLabel(n.featureIds,e.featureIdLabel),i=A(o.label,o.positionalLabel),{featureIds:o,variableName:i,shaderDestination:C5(o),featureIdDefine:b5(o)})}function X7e(e){e.addStructField(Ub.STRUCT_ID_SELECTED_FEATURE,"int","id"),e.addStructField(Ub.STRUCT_ID_SELECTED_FEATURE,"vec2","st"),e.addStructField(Ub.STRUCT_ID_SELECTED_FEATURE,"vec4","color")}const mR=Ub,kr={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)"};kr.process=function(e,t,n){const i=e.shaderBuilder,o=e.model;i.addStruct(kr.STRUCT_ID_PROCESSED_ATTRIBUTES_VS,"ProcessedAttributes",De.VERTEX),i.addStruct(kr.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"ProcessedAttributes",De.FRAGMENT),i.addStruct(mR.STRUCT_ID_SELECTED_FEATURE,mR.STRUCT_NAME_SELECTED_FEATURE,De.BOTH),i.addFunction(kr.FUNCTION_ID_INITIALIZE_ATTRIBUTES,kr.FUNCTION_SIGNATURE_INITIALIZE_ATTRIBUTES,De.VERTEX),i.addVarying("vec3","v_positionWC"),i.addVarying("vec3","v_positionEC"),i.addStructField(kr.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionWC"),i.addStructField(kr.STRUCT_ID_PROCESSED_ATTRIBUTES_FS,"vec3","positionEC"),i.addFunction(kr.FUNCTION_ID_SET_DYNAMIC_VARYINGS_VS,kr.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,De.VERTEX),i.addFunction(kr.FUNCTION_ID_SET_DYNAMIC_VARYINGS_FS,kr.FUNCTION_SIGNATURE_SET_DYNAMIC_VARYINGS,De.FRAGMENT),o.type===ua.TILE_PNTS&&i.addDefine("HAS_SRGB_COLOR",void 0,De.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],m=hn.getAttributeLocationCount(h.type);if(!l(h.buffer)&&!l(h.constant))throw new x("Attributes must be provided as a Buffer or constant value");const g=h.semantic===wt.POSITION;let p;m>1?(p=e.attributeIndex,e.attributeIndex+=m):g&&!c?p=0:p=e.attributeIndex++,K7e(e,h,p,m,s,a)}r $ e(i,t.attributes),t.primitiveType===Qe.POINTS&&i.addDefine("PRIMITIVE_TYPE_POINTS"),i.addVertexLines( $ 7e),i.addFragmentLines(q7e)};function K7e(e,t,n,i,o,r){const s=e.shaderBuilder,a=Zt.getAttributeInfo(t),c=o&&!r;i>1?Z7e(e,t,n,i):Q7e(e,t,n,c),t $ e(s,a,c),e $ e(s,a),l(t.semantic)&&J7e(s,t),n $ e(s,a,o),i $ e(s,a,c),o $ e(s,a)}function J7e(e,t){const n=t.semantic,i=t.setIndex;switch(n){case wt.NORMAL:e.addDefine("HAS_NORMAL
2023-02-06 08:55:59 +00:00
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 ;
}
2023-02-13 02:05:23 +00:00
` ,c $ e={UNLIT:0,PBR:1},cv=Object.freeze(c $ e),LJ={name:"LightingPipelineStage"};LJ.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,De.FRAGMENT),o.addUniform("vec3","model_lightColorHdr",De.FRAGMENT);const s=e.uniformMap;s.model_lightColorHdr=function(){return n.lightColor}}i.lightingModel===cv.PBR?o.addDefine("LIGHTING_PBR",void 0,De.FRAGMENT):o.addDefine("LIGHTING_UNLIT",void 0,De.FRAGMENT),o.addFragmentLines(a $ e)};const l $ e=LJ,u $ e= ` // If the style color is white, it implies the feature has not been styled.
2023-02-06 08:55:59 +00:00
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
}
2023-02-13 02:05:23 +00:00
` ,f $ e=Ot.Material,XP=Ot.MetallicRoughness,KP=Ot.SpecularGlossiness,BJ={name:"MaterialPipelineStage",_processTexture:_p,_processTextureTransform:RJ};BJ.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;d $ e(i,a,c,u,f,h,s),l(i.specularGlossiness)?h $ e(i,a,c,u,s):p $ e(i,a,c,u,s);const m=Zt.getAttributeBySemantic(t,wt.NORMAL),g=e.lightingOptions;i.unlit||!m||r?g.lightingModel=cv.UNLIT:g.lightingModel=cv.PBR;const p=o.backFaceCulling&&!i.doubleSided;e.renderStateOptions.cull.enabled=p;const y=e.alphaOptions;i.alphaMode===tv.BLEND?y.pass=Ne.TRANSLUCENT:i.alphaMode===tv.MASK&&(y.alphaCutoff=i.alphaCutoff),c.addFragmentLines(u $ e),i.doubleSided&&c.addDefine("HAS_DOUBLE_SIDED_MATERIAL",void 0,De.BOTH)};function RJ(e,t,n,i,o){const r= ` HAS _$ { o } _TEXTURE _TRANSFORM ` ;e.addDefine(r,void 0,De.FRAGMENT);const s= ` $ { i } Transform ` ;e.addUniform("mat3",s,De.FRAGMENT),t[s]=function(){return n.transform}}function _p(e,t,n,i,o,r){e.addUniform("sampler2D",i,De.FRAGMENT),t[i]=function(){return A(n.texture,r)};const s= ` HAS _$ { o } _TEXTURE ` ;e.addDefine(s,void 0,De.FRAGMENT);const c= ` v _texCoord _$ { n . texCoord } ` ,u= ` TEXCOORD _$ { o } ` ;e.addDefine(u,c,De.FRAGMENT);const f=n.transform;l(f)&&!J.equals(f,J.IDENTITY)&&RJ(e,t,n,i,o)}function d $ e(e,t,n,i,o,r,s){const a=e.emissiveTexture;l(a)&&!s&&_p(n,t,a,"u_emissiveTexture","EMISSIVE",r);const c=e.emissiveFactor;l(c)&&!d.equals(c,f $ e.DEFAULT_EMISSIVE_FACTOR)&&(n.addUniform("vec3","u_emissiveFactor",De.FRAGMENT),t.u_emissiveFactor=function(){return e.emissiveFactor},n.addDefine("HAS_EMISSIVE_FACTOR",void 0,De.FRAGMENT));const u=e.normalTexture;l(u)&&!s&&_p(n,t,u,"u_normalTexture","NORMAL",o);const f=e.occlusionTexture;l(f)&&!s&&_p(n,t,f,"u_occlusionTexture","OCCLUSION",i)}function h $ e(e,t,n,i,o){const r=e.specularGlossiness;n.addDefine("USE_SPECULAR_GLOSSINESS",void 0,De.FRAGMENT);const s=r.diffuseTexture;l(s)&&!o&&_p(n,t,s,"u_diffuseTexture","DIFFUSE",i);const a=r.diffuseFactor;l(a)&&!oe.equals(a,KP.DEFAULT_DIFFUSE_FACTOR)&&(n.addUniform("vec4","u_diffuseFactor",De.FRAGMENT),t.u_diffuseFactor=function(){return r.diffuseFactor},n.addDefine("HAS_DIFFUSE_FACTOR",void 0,De.FRAGMENT));const c=r.specularGlossinessTexture;l(c)&&!o&&_p(n,t,c,"u_specularGlossinessTexture","SPECULAR_GLOSSINESS",i);const u=r.specularFactor;l(u)&&!d.equals(u,KP.DEFAULT_SPECULAR_FACTOR)&&(n.addUniform("vec3","u_specularFactor",De.FRAGMENT),t.u_specularFactor=function(){return r.specularFactor},n.addDefine("HAS_SPECULAR_FACTOR",void 0,De.FRAGMENT));const f=r.glossinessFactor;l(f)&&f!==KP.DEFAULT_GLOSSINESS_FACTOR&&(n.addUniform("float","u_glossinessFactor",De.FRAGMENT),t.u_glossinessFactor=function(){return r.glossinessFactor},n.addDefine("HAS_GLOSSINESS_FACTOR",void 0,De.FRAGMENT))}function p $ e(e,t,n,i,o){const r=e.metallicRoughness;n.addDefine("USE_METALLIC_ROUGHNESS",void 0,De.FRAGMENT);const s=r.baseColorTexture;l(s)&&!o&&_p(n,t,s,"u_baseColorTexture","BASE_COLOR",i);const a=r.baseColorFactor;l(a)&&!oe.equals(a,XP.DEFAULT_BASE_COLOR_FACTOR)&&(n.addUniform("vec4","u_baseColorFactor",De.FRAGMENT),t.u_baseColorFactor=function(){return r.baseColorFactor},n.addDefine("HAS_BASE_COLOR_FACTOR",void 0,De.FRAGMENT));const c=r.metallicRoughnessTexture;l(c)&&!o&&_p(n,t,c,"u_metallicRoughnessTexture","METALLIC_ROUGHNESS",i);const u=r.metallicFactor;l(u)&&u!==XP.DEFAULT_METALLIC_FACTOR&&(n.addUniform("float","u_metallicFactor",De.FRAGMENT),t.u_metallicFactor=function(){return r.metallicFactor},n.addDefine("HAS_METALLIC_FACTOR",void 0,De.FRAGMENT));const f=r.roughnessFactor;l(f)&&f!==XP.DEFAULT_ROUGHNESS_FACTOR&&(n.addUniform("float","u_roughnessFactor",De.FRAGMENT),t.u_roughnessFactor=function(){return r.roughnessFactor},n.addDefine("HAS_ROUGHNESS_FACTOR",void 0,De.FRAGMENT))}const m $ e=BJ,_ $ e= ` void morphTargetsStage ( inout ProcessedAttributes attributes )
2023-02-06 08:55:59 +00:00
{
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
2023-02-13 02:05:23 +00:00
} ` ,Cs={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)"};Cs.process=function(e,t){const n=e.shaderBuilder;n.addDefine("HAS_MORPH_TARGETS",void 0,De.VERTEX),T $ e(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],m=h.semantic;m!==wt.POSITION&&m!==wt.NORMAL&&m!==wt.TANGENT||(y $ e(e,h,e.attributeIndex,a),e.attributeIndex++)}}E $ e(n);const r=e.runtimeNode.morphWeights.length;n.addUniform("float", ` u _morphWeights [ $ { r } ] ` ,De.VERTEX),n.addVertexLines(_ $ e);const s={u_morphWeights:function(){return e.runtimeNode.morphWeights}};e.uniformMap=un(s,e.uniformMap)};const g $ e={attributeString:void 0,functionId:void 0};function y $ e(e,t,n,i){const o=e.shaderBuilder;A $ e(e,t,n);const r=b $ e(t,g $ e);C $ e(o,r,i)}function A $ e(e,t,n){const i={index:n,value:l(t.buffer)?void 0:t.constant,vertexBuffer:t.buffer,componentsPerAttribute:hn.getNumberOfComponents(t.type),componentDatatype:t.componentDatatype,offsetInBytes:t.byteOffset,strideInBytes:t.byteStride,normalize:t.normalized};e.attributes.push(i)}function b $ e(e,t){switch(e.semantic){case wt.POSITION:t.attributeString="Position",t.functionId=Cs.FUNCTION_ID_GET_MORPHED_POSITION;break;case wt.NORMAL:t.attributeString="Normal",t.functionId=Cs.FUNCTION_ID_GET_MORPHED_NORMAL;break;case wt.TANGENT:t.attributeString="Tangent",t.functionId=Cs.FUNCTION_ID_GET_MORPHED_TANGENT;break}return t}function C $ e(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 T $ e(e){e.addFunction(Cs.FUNCTION_ID_GET_MORPHED_POSITION,Cs.FUNCTION_SIGNATURE_GET_MORPHED_POSITION,De.VERTEX);const t="vec3 morphedPosition = position;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_POSITION,[t]),e.addFunction(Cs.FUNCTION_ID_GET_MORPHED_NORMAL,Cs.FUNCTION_SIGNATURE_GET_MORPHED_NORMAL,De.VERTEX);const n="vec3 morphedNormal = normal;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_NORMAL,[n]),e.addFunction(Cs.FUNCTION_ID_GET_MORPHED_TANGENT,Cs.FUNCTION_SIGNATURE_GET_MORPHED_TANGENT,De.VERTEX);const i="vec3 morphedTangent = tangent;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}function E $ e(e){const t="return morphedPosition;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_POSITION,[t]);const n="return morphedNormal;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_NORMAL,[n]);const i="return morphedTangent;";e.addFunctionLines(Cs.FUNCTION_ID_GET_MORPHED_TANGENT,[i])}const x $ e=Cs,NJ={name:"PickingPipelineStage"};NJ.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)w $ e(e,t,a);else if(l(a))S $ e(e,i);else{const c=MJ(e),u=i.createPickId(c);s._pipelineResources.push(u),s._pickIds.push(u),r.addUniform("vec4","czm_pickColor",De.FRAGMENT);const f=e.uniformMap;f.czm_pickColor=function(){return u.color},e.pickId="czm_pickColor"}};function MJ(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(ua.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 w $ e(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=Zt.getFeatureIdsByLabel(n.featureIds,a),o=r.propertyTableId):(r=Zt.getFeatureIdsByLabel(t.featureIds,s),o=r.propertyTableId);const c=i.featureTables[o];e.shaderBuilder.addUniform("sampler2D","model_pickTexture",De.FRAGMENT);const f=c.batchTexture;e.uniformMap.model_pickTexture=function(){return A(f.pickTexture,f.default
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
# endif ` ,I $ e=new oe,FJ={name:"PointCloudStylingPipelineStage"};FJ.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 y=B $ e(a),b=R $ e(r,y);N $ e(i,b);const E=M $ e(b).indexOf("normalMC")>=0,w=Zt.getAttributeBySemantic(t,wt.NORMAL);if(E&&!w)throw new Ie("Style references the NORMAL semantic but the point cloud does not have normals");i.addDefine("COMPUTE_POSITION_WC_STYLE",void 0,De.VERTEX),b.styleTranslucent&&(e.alphaOptions.pass=Ne.TRANSLUCENT)}const f=o.pointCloudShading;f.attenuation&&i.addDefine("HAS_POINT_CLOUD_ATTENUATION",void 0,De.VERTEX),f.backFaceCulling&&i.addDefine("HAS_POINT_CLOUD_BACK_FACE_CULLING",void 0,De.VERTEX);let h,m,g;ua.is3DTiles(o.type)&&(m=!0,h=o.content,g=h.tile.refine===Da.ADD),i.addUniform("vec4","model_pointCloudParameters",De.VERTEX),i.addVertexLines(D $ e);const p=e.uniformMap;p.model_pointCloudParameters=function(){const y=I $ e;let b=1;m&&(b=g?5:h.tileset.maximumScreenSpaceError),y.x=A(f.maximumAttenuation,b),y.x*=n.pixelRatio;const C=P $ e(e,t,f,h);y.y=C*f.geometricErrorScale;const E=n.context,w=n.camera.frustum;let S;return n.mode===le.SCENE2D||w instanceof Vt?S=Number.POSITIVE_INFINITY:S=E.drawingBufferHeight/n.camera.frustum.sseDenominator,y.z=S,m&&(y.w=h.tileset.timeSinceLoad),y}};const T5=new d;function P $ e(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=Zt.getAttributeBySemantic(t,wt.POSITION),r=o.count,s=e.runtimeNode.transform;let a=d.subtract(o.max,o.min,T5);a=B.multiplyByPointAsVector(s,a,T5);const c=a.x*a.y*a.z;return M.cbrt(c/r)}const O $ e={colorStyleFunction:void 0,showStyleFunction:void 0,pointSizeStyleFunction:void 0,styleTranslucent:!1},L $ e={POSITION:"attributes.positionMC",POSITION_ABSOLUTE:"v_positionWC",COLOR:"attributes.color_0",NORMAL:"attributes.normalMC"};function B $ e(e){const t=dt(L $ e);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 JP="ProcessedAttributes attributes, Metadata metadata, float tiles3d_tileset_time";function R $ e(e,t){const n=O $ e,i={translucent:!1};return n.colorStyleFunction=e.getColorShaderFunction( ` getColorFromStyle ( $ { JP } ) ` ,t,i),n.showStyleFunction=e.getShowShaderFunction( ` getShowFromStyle ( $ { JP } ) ` ,t,i),n.pointSizeStyleFunction=e.getPointSizeShaderFunction( ` getPointSizeFromStyle ( $ { JP } ) ` ,t,i),n.styleTranslucent=l(n.colorStyleFunction)&&i.translucent,n}function N $ e(e,t){const n=t.colorStyleFunction;l(n)&&(e.addDefine("HAS_POINT_CLOUD_COLOR_STYLE",void 0,De.BOTH),e.addVertexLines(n),e.addVarying("vec4","v_pointCloudColor"));const i=t.showStyleFunction;l(i)&&(e.addDefine("HAS_POINT_CLOUD_SHOW_STYLE",void 0,De.VERTEX),e.addVertexLines(i));const o=t.pointSizeStyleFunction;l(o)&&(e.addDefine("HAS_POINT_CLOUD_POINT_SIZE_STYLE",void 0,De.VERTEX),e.addVertexLines(o))}function QP(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 M $ e(e){const t=e.colorStyleFunction,n=e.showStyleFunction,i=e.pointSizeStyleFunction,o=[];return l(t)&&QP(t,o),l(n)&&QP(n,o),l(i)&&QP(i,o),o}const F $ e=FJ,z $ e= ` void primitiveOutlineStage ( ) {
2023-02-06 08:55:59 +00:00
v _outlineCoordinates = a _outlineCoordinates ;
}
2023-02-13 02:05:23 +00:00
` ,U $ e= ` void primitiveOutlineStage ( inout czm _modelMaterial material ) {
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,zJ={name:"PrimitiveOutlinePipelineStage"};zJ.process=function(e,t,n){const i=e.shaderBuilder,o=e.uniformMap;i.addDefine("HAS_PRIMITIVE_OUTLINE",void 0,De.BOTH),i.addAttribute("vec3","a_outlineCoordinates"),i.addVarying("vec3","v_outlineCoordinates");const r=t.outlineCoordinates,s={index:e.attributeIndex++,vertexBuffer:r.buffer,componentsPerAttribute:hn.getNumberOfComponents(r.type),componentDatatype:r.componentDatatype,offsetInBytes:r.byteOffset,strideInBytes:r.byteStride,normalize:r.normalized};e.attributes.push(s),i.addUniform("sampler2D","model_outlineTexture",De.FRAGMENT);const a=ST.createTexture(n.context);o.model_outlineTexture=function(){return a};const c=e.model;i.addUniform("vec4","model_outlineColor",De.FRAGMENT),o.model_outlineColor=function(){return c.outlineColor},i.addUniform("bool","model_showOutline",De.FRAGMENT),o.model_showOutline=function(){return c.showOutline},i.addVertexLines(z $ e),i.addFragmentLines(U $ e)};const H $ e=zJ,UJ={name:"PrimitiveStatisticsPipelineStage",_countGeometry:HJ,_count2DPositions:VJ,_countMorphTargetAttributes:kJ,_countMaterialTextures:GJ,_countFeatureIdTextures:WJ,_countBinaryMetadata:jJ};UJ.process=function(e,t,n){const i=e.model,o=i.statistics;HJ(o,t),VJ(o,e.runtimePrimitive),kJ(o,t),GJ(o,t.material),WJ(o,t.featureIds),jJ(o,i)};function HJ(e,t){const n=l(t.indices)?t.indices.count:Zt.getAttributeBySemantic(t,"POSITION").count,i=t.primitiveType;i===Qe.POINTS?e.pointsLength+=n:Qe.isTriangles(i)&&(e.trianglesLength+=V $ e(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 V $ e(e,t){switch(e){case Qe.TRIANGLES:return t/3;case Qe.TRIANGLE_STRIP:case Qe.TRIANGLE_FAN:return Math.max(t-2,0);default:return 0}}function VJ(e,t){const n=t.positionBuffer2D;l(n)&&e.addBuffer(n,!0)}function kJ(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 GJ(e,t){const n=k $ e(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 k $ e(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 WJ(e,t){const n=t.length;for(let i=0;i<n;i++){const o=t[i];if(o instanceof Ot.FeatureIdTexture){const r=o.textureReader;l(r.texture)&&e.addTexture(r.texture)}}}function jJ(e,t){const n=t.structuralMetadata;l(n)&&(G $ e(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 G $ e(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 W $ e=UJ,j $ e=new B,q $ e=new B,qJ={name:"SceneMode2DPipelineStage"};qJ.process=function(e,t,n){const i=Zt.getAttributeBySemantic(t,wt.POSITION),o=e.shaderBuilder,r=e.model,s=r.sceneGraph.computedModelMatrix,a=e.runtimeNode.computedTransform,c=B.multiplyTransformation(s,a,j $ e),u=X $ e(e,c,n),f=e.runtimePrimitive;f.boundingSphere2D=u;const h=e.runtimeNode.node.instances;if(l(h))return;if(l(i.typedArray)){const y=Q $ e(i,c,u,n);f.positionBuffer2D=y,r._modelResources.push(y),i.typedArray=void 0}o.addDefine("USE_2D_POSITIONS",void 0,De.VERTEX),o.addUniform("mat4","u_modelView2D",De.VERTEX);const m=B.fromTranslation(u.center,new B),g=n.context,p={u_modelView2D:function(){return B.multiplyTransformation(g.uniformState.view,m,q $ e)}};e.uniformMap=un(p,e.uniformMap)};const $ $ e=new d,Y $ e=new d;function X $ e(e,t,n){const i=B.multiplyByPoint(t,e.positionMin, $ $ e),o=br.computeActualWgs
2023-02-06 08:55:59 +00:00
{
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
2023-02-13 02:05:23 +00:00
} ` ,qm={name:"SkinningPipelineStage",FUNCTION_ID_GET_SKINNING_MATRIX:"getSkinningMatrix",FUNCTION_SIGNATURE_GET_SKINNING_MATRIX:"mat4 getSkinningMatrix()"};qm.process=function(e,t){const n=e.shaderBuilder;n.addDefine("HAS_SKINNING",void 0,De.VERTEX),nYe(n,t);const i=e.runtimeNode,o=i.computedJointMatrices;n.addUniform("mat4", ` u _jointMatrices [ $ { o . length } ] ` ,De.VERTEX),n.addVertexLines(eYe);const r={u_jointMatrices:function(){return i.computedJointMatrices}};e.uniformMap=un(r,e.uniformMap)};function tYe(e){let t=-1;const n=e.attributes,i=n.length;for(let o=0;o<i;o++){const r=n[o];(r.semantic===wt.JOINTS||r.semantic===wt.WEIGHTS)&&(t=Math.max(t,r.setIndex))}return t}function nYe(e,t){e.addFunction(qm.FUNCTION_ID_GET_SKINNING_MATRIX,qm.FUNCTION_SIGNATURE_GET_SKINNING_MATRIX,De.VERTEX);const n="mat4 skinnedMatrix = mat4(0);";e.addFunctionLines(qm.FUNCTION_ID_GET_SKINNING_MATRIX,[n]);let i,o;const r=["x","y","z","w"],s=tYe(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(qm.FUNCTION_ID_GET_SKINNING_MATRIX,[u])}const a="return skinnedMatrix;";e.addFunctionLines(qm.FUNCTION_ID_GET_SKINNING_MATRIX,[a])}const iYe=qm,U2={};function oYe(e){const t=st.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 rYe(e,t){const n=t.length,i=st.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 sYe(e){const t=e-2,n=2+t*4,i=st.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 aYe(e,t){const i=t.length-2,o=2+i*4,r=st.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 cYe(e){const t=e-2,n=2+t*4,i=st.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 lYe(e,t){const i=t.length-2,o=2+i*4,r=st.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}U2.createWireframeIndices=function(e,t,n){const i=l(n);if(e===Qe.TRIANGLES)return i?rYe(t,n):oYe(t);if(e===Qe.TRIANGLE_STRIP)return i?aYe(t,n):sYe(t);if(e===Qe.TRIANGLE_FAN)return i?lYe(t,n):cYe(t)};U2.getWireframeIndicesCount=function(e,t){return e===Qe.TRIANGLES?t*2:e===Qe.TRIANGLE_STRIP||e===Qe.TRIANGLE_FAN?2+(t-2)*4:t};const YJ=U2,XJ={name:"WireframePipelineStage"};XJ.process=function(e,t,n){e.shaderBuilder.addDefine("HAS_WIREFRAME",void 0,De.FRAGMENT);const o=e.model,r=uYe(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=Qe.LINES,e.count=YJ.getWireframeIndicesCount(a,c)};function uYe(e,t,n){const o=Zt.getAttributeBySemantic(e,wt.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):st.createTypedArray(o,h),f.getBufferData(s)):s=t.typedArray}const a=e.primitiveType,c=YJ.createWireframeIndices(a,o,s),u=st.fromSizeInBytes(c.BYTES_PER_ELEMENT);return Tt.createIndexBuffer({context:n.context,typedArray:c,usage:tt.STATIC_DRAW,indexDatatype:u})}const fYe=XJ;function KJ(e){e=A(e,A.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=[]}KJ.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
2023-02-06 08:55:59 +00:00
if ( model _silhouettePass ) {
color = czm _gammaCorrect ( model _silhouetteColor ) ;
}
2023-02-13 02:05:23 +00:00
} ` ,gYe= ` void silhouetteStage ( in ProcessedAttributes attributes , inout vec4 positionClip ) {
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,lv={name:"ModelSilhouettePipelineStage"};lv.silhouettesLength=0;lv.process=function(e,t,n){l(t._silhouetteId)||(t._silhouetteId=++lv.silhouettesLength);const i=e.shaderBuilder;i.addDefine("HAS_SILHOUETTE",void 0,De.BOTH),i.addVertexLines(gYe),i.addFragmentLines(_Ye),i.addUniform("vec4","model_silhouetteColor",De.FRAGMENT),i.addUniform("float","model_silhouetteSize",De.VERTEX),i.addUniform("bool","model_silhouettePass",De.BOTH);const o={model_silhouetteColor:function(){return t.silhouetteColor},model_silhouetteSize:function(){return t.silhouetteSize},model_silhouettePass:function(){return!1}};e.uniformMap=un(o,e.uniformMap),e.hasSilhouette=!0};const yYe=lv,AYe= ` void modelSplitterStage ( )
2023-02-06 08:55:59 +00:00
{
// 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
}
2023-02-13 02:05:23 +00:00
` ,Jw={name:"ModelSplitterPipelineStage",SPLIT_DIRECTION_UNIFORM_NAME:"model_splitDirection"};Jw.process=function(e,t,n){const i=e.shaderBuilder;i.addDefine("HAS_MODEL_SPLITTER",void 0,De.FRAGMENT),i.addFragmentLines(AYe);const o={};i.addUniform("float",Jw.SPLIT_DIRECTION_UNIFORM_NAME,De.FRAGMENT),o[Jw.SPLIT_DIRECTION_UNIFORM_NAME]=function(){return t.splitDirection},e.uniformMap=un(o,e.uniformMap)};const bYe=Jw;function CYe(e,t){T.typeOf.object("modelRenderResources",e),T.typeOf.object("runtimeNode",t),this.model=e.model,this.shaderBuilder=e.shaderBuilder.clone(),this.uniformMap=dt(e.uniformMap),this.alphaOptions=dt(e.alphaOptions),this.renderStateOptions=dt(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 TYe(e){e=A(e,A.EMPTY_OBJECT),this.lightingModel=A(e.lightingModel,cv.UNLIT)}function EYe(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=dt(e.uniformMap),this.alphaOptions=dt(e.alphaOptions),this.renderStateOptions=dt(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:Zt.getAttributeBySemantic(n,"POSITION").count,this.hasPropertyTable=!1,this.indices=n.indices,this.wireframeIndexBuffer=void 0,this.primitiveType=n.primitiveType;const i=Zt.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=de.fromCornerPoints(this.positionMin,this.positionMax,new de),this.lightingOptions=new TYe,this.pickId=void 0}function Oc(e){e=A(e,A.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=Zt.getAxisCorrectionMatrix(t.upAxis,t.forwardAxis,new B),this._runtimeArticulations={},xYe(this)}Object.defineProperties(Oc.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 xYe(e){const t=e._components,n=t.scene,o=e._model.modelMatrix;QJ(e,o);const r=t.articulations,s=r.length,a=e._runtimeArticulations;for(let E=0;E<s;E++){const w=r[E],S=new MD({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,m=B.IDENTITY;for(let E=0;E<h;E++){const w=n.nodes[E],S=ZJ(e,w,m);e._rootNodes.push(S)}const g=t.skins,p=e._runtimeSkins,y=g.length;for(let E=0;E<y;E++){const w=g[E];p.push(new H2({skin:w,sceneGraph:e}))}const b=e._skinnedNodes,C=b.length;for(let E=0;E<C;E++){const w=b[E],S=e._runtimeNodes[w],L=c[w].skin.index;S._runtimeSkin=p[L],S.updateJointMatrices()}e.applyArticulations()}function QJ(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
2023-02-06 08:55:59 +00:00
varying vec2 v _textureCoordinates ;
void main ( )
{
gl _FragColor = texture2D ( billboard _texture , v _textureCoordinates ) ;
}
2023-02-13 02:05:23 +00:00
` ,i=t.createViewportQuadCommand(n,{uniformMap:{billboard_texture:function(){return e._textureAtlas.texture}}});return i.pass=Ne.OVERLAY,i}const IKe=[];fa.prototype.update=function(e){if(k2(this),!this.show)return;let t=this._billboards,n=t.length;const i=e.context;this._instanced=i.instancedArrays,Xi=this._instanced?mKe:pKe,eO=this._instanced?gKe:_Ke;let o=this._textureAtlas;if(!l(o)){o=this._textureAtlas=new df({context:i});for(let R=0;R<n;++R)t[R]._loadImage()}const r=o.textureCoordinates;if(r.length===0)return;SKe(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 m=e.passes,g=m.pick;if(f||!g&&this.computeNewBuffersUsage()){this._createVertexArray=!1;for(let R=0;R<V2;++R)c[R]=0;if(this._vaf=this._vaf&&this._vaf.destroy(),n>0){this._vaf=AKe(i,n,this._buffersUsage,this._instanced,this._batchTable,this._sdf),h=this._vaf.writers;for(let R=0;R<n;++R){const F=this._billboards[R];F._dirty=!1,wKe(this,e,r,h,F)}this._vaf.commit(eO(i))}this._billboardsToUpdateIndex=0}else if(a>0){const R=IKe;R.length=0,(c[Hb]||c[uKe]||c[lKe])&&R.push(bQ),(c[vA]||c[fQ]||c[aKe]||c[cKe]||c[sKe])&&(R.push(SQ),this._instanced&&R.push(yR)),(c[vA]||c[fKe]||c[mQ])&&(R.push(vQ),R.push(gR)),(c[vA]||c[hQ])&&R.push(gR),c[dQ]&&R.push(yR),c[pQ]&&R.push(DQ),c[_Q]&&R.push(IQ),(c[gQ]||c[dKe]||c[vA]||c[Hb])&&R.push(PQ),(c[vA]||c[Hb])&&R.push(OQ),c[yQ]&&R.push(LQ);const F=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<F;++I)R[I](this,e,r,h,v)}this._vaf.commit(eO(i))}else{for(let U=0;U<a;++U){const v=s[U];v._dirty=!1;for(let I=0;I<F;++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,de.transform(this._baseVolume,this.modelMatrix,this._baseVolumeWC));let p,y=B.IDENTITY;e.mode===le.SCENE3D?(y=this.modelMatrix,p=de.clone(this._baseVolumeWC,this._boundingVolume)):p=de.clone(this._baseVolume2D,this._boundingVolume),vKe(this,e,p);const b=this._blendOption!==this.blendOption;if(this._blendOption=this.blendOption,b){this._blendOption===Ko.OPAQUE||this._blendOption===Ko.OPAQUE_AND_TRANSLUCENT?this._rsOpaque=Ze.fromCache({depthTest:{enabled:!0,func:ae.LESS},depthMask:!0}):this._rsOpaque=void 0;const R=this._blendOption===Ko.TRANSLUCENT;this._blendOption===Ko.TRANSLUCENT||this._blendOption===Ko.OPAQUE_AND_TRANSLUCENT?this._rsTranslucent=Ze.fromCache({depthTest:{enabled:!0,func:R?ae.LEQUAL:ae.LESS},depthMask:R,blending:Gi.ALPHA_BLEND}):this._rsTranslucent=void 0}this._shaderDisableDepthDistance=this._shaderDisableDepthDistance||e.minimumDisableDepthTestDistance!==0;let C,E,w,S,P;const L=Dt.maximumVertexTextureImageUnits>0;if(b||this._shaderRotation!==this._compiledShaderRotation||this._shaderAlignedAxis!==this._compiledShaderAlignedAxis||this._shaderScaleByDistance!==this._compiledShaderScaleByDistance||this._shaderTranslucencyByDistance!==this._compiledShaderTranslucencyByDistance||this._shaderPixelOffsetScaleByDistance!==this._compiledShaderPixelOffsetScaleByDistance||this._shaderDistanceDisplayCondition!==this._compiledShaderDistanceDisplayCondition||this._shaderDisableDepthDistance!==this._compiledShaderDisableDepthDistance||this._shaderClampToGround!==this._compiledShaderClampToGround||this._sdf!==this._compiledSDF){C=BTe,E=LTe,P=[],l(this._batchTable)&&(P.push("VECTOR_TILE"),C=this._batchTable.getVertexShaderCallback(!1,"a_batchId",void 0)(C),E=this._batchTable.getFragmentShaderCallback(!1,void 0)(E)),w=new We({defines:P,sources:[C]}),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=N5.test(o.charAt(0)),s=UKe(o,N5);let a=0,c="";for(let u=0;u<s.length;++u){const f=s[u],h=f.Type===_r.BRACKETS?VKe(f.Word):HKe(f.Word);r?f.Type===_r.RTL?(c=h+c,a=0):f.Type===_r.LTR?(c=PA(c,a,f.Word),a+=f.Word.length):(f.Type===_r.WEAK||f.Type===_r.BRACKETS)&&(f.Type===_r.WEAK&&s[u-1].Type===_r.BRACKETS?c=h+c:s[u-1].Type===_r.RTL?(c=h+c,a=0):s.length>u+1?s[u+1].Type===_r.RTL?(c=h+c,a=0):(c=PA(c,a,f.Word),a+=f.Word.length):c=PA(c,0,h)):f.Type===_r.RTL?c=PA(c,a,h):f.Type===_r.LTR?(c+=f.Word,a=c.length):(f.Type===_r.WEAK||f.Type===_r.BRACKETS)&&(u>0&&s[u-1].Type===_r.RTL?s.length>u+1?s[u+1].Type===_r.RTL?c=PA(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 AR={},jKe={get exports(){return AR},set exports(e){AR=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,m=10,g=11,p=12,y=13,b=14,C=15,E=16,w=17,S=0,P=1,L=2,z=3,R=4;function F(_,D){return 55296<=_.charCodeAt(D)&&_.charCodeAt(D)<=56319&&56320<=_.charCodeAt(D+1)&&_.charCodeAt(D+1)<=57343}function U(_,D){D===void 0&&(D=0);var O=_.charCodeAt(D);if(55296<=O&&O<=56319&&D<_.length-1){var N=O,V=_.charCodeAt(D+1);return 56320<=V&&V<=57343?(N-55296)*1024+(V-56320)+65536:N}if(56320<=O&&O<=57343&&D>=1){var N=_.charCodeAt(D-1),V=O;return 55296<=N&&N<=56319?(N-55296)*1024+(V-56320)+65536:V}return O}function v(_,D,O){var N=[_].concat(D).concat([O]),V=N[N.length-2],k=O,G=N.lastIndexOf(b);if(G>1&&N.slice(1,G).every(function(q){return q==r})&&[r,y,w].indexOf(_)==-1)return L;var W=N.lastIndexOf(s);if(W>0&&N.slice(1,W).every(function(q){return q==s})&&[p,s].indexOf(V)==-1)return N.filter(function(q){return q==s}).length%2==1?z:R;if(V==n&&k==i)return S;if(V==o||V==n||V==i)return k==b&&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==m))return S;if((V==h||V==u)&&(k==u||k==f))return S;if((V==m||V==f)&&k==f)return S;if(k==r||k==C)return S;if(k==a)return S;if(V==p)return S;var K=N.indexOf(r)!=-1?N.lastIndexOf(r)-1:N.length-2;return[y,w].indexOf(N[K])!=-1&&N.slice(K+1,-1).every(function(q){return q==r})&&k==b||V==C&&[E,w].indexOf(k)!=-1?S:D.indexOf(s)!=-1?L:V==s&&k==s?S:P}this.nextBreak=function(_,D){if(D===void 0&&(D=0),D<0)return 0;if(D>=_.length-1)return _.length;for(var O=I(U(_,D)),N=[],V=D+1;V<_.length;V++)if(!F(_,V-1)){var k=I(U(_,V));if(v(O,N,k))return V;N.push(k)}return _.length},this.splitGraphemes=function(_){for(var D=[],O=0,N;(N=this.nextBreak(_,O))<_.length;)D.push(_.slice(O,N)),O=N;return O<_.length&&D.push(_.slice(O)),D},this.iterateGraphemes=function(_){var D=0,O={next:function(){var N,V;return(V=this.nextBreak(_,D))<_.length?(N=_.slice(D,V),D=V,{value:N,done:!1}):D<_.length?(N=_.slice(D),D=_.length,{value:N,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(_){for(var D=0,O=0,N;(N=this.nextBreak(_,O))<_.length;)O=N,D++;return O<_.length&&D++,D};function I(_){return 1536<=_&&_<=1541||_==1757||_==1807||_==2274||_==3406||_==69821||70082<=_&&_<=70083||_==72250||72326<=_&&_<=72329||_==73030?p:_==13?n:_==10?i:0<=_&&_<=9||11<=_&&_<=12||14<=_&&_<=31||127<=_&&_<=159||_==173||_==1564||_==6158||_==8203||8206<=_&&_<=8207||_==8232||_==8233||8234<=_&&_<=8238||8288<=_&&_<=8292||_==8293||8294<=_&&_<=8303||55296<=_&&_<=57343||_==65279||65520<=_&&_<=65528||65529<=_&&_<=65531||113824<=_&&_<=113827||119155<=_&&_<=119162||_==917504||_==917505||917506<=_&&_<=917535||917632<=_&&_<=917759||918e3<=_&&_<=921599?o:768<=_&&_<=879||1155<=_&&_<=1159||1160<=_&&_<=1161||1425<=_&&_<=1469||_==1471||1473<=_&&_<=1474||1476<=_&&_<=1477||_==1479||1552<=_&&_<=1562||1611<=_&&_<=1631||_==1648||1750<=_&&_<=1756||1759<=_&&_<=1764||1767<=_&&_<=1768||1770<=_&&_<=1773||_==1809||1840<=_&&_<=1866||1958<=_&&_<=1968||2027<=_&&_<=2035||2070<=_&&_<=2073||2075<=_&&_<=2083||2085<=_&&_<=2087||2089<=_&&_<=2093||2137<=_&&_<=2139||2260<=_&&_<=2273||2275<=_&&_<=2306||_==2362||_==2364||2369<=_&&_<=2376||_==2381||2385<=_&&_<=2391||2402<=_&&_<=2403||_==2433||_==2492||_==2494||2497<=_&&_<=2500||_==2509||_==2519||2530<=_&&_<=2531||2561<=_&&_<=2562||_==2620||2625<=_&&_<=2626||2631<=_&&_<=2632||2635<=_&&_<=2637||_==2641||2672<=_&&_<=2673||_==2677||2689<=_&&_<=2690||_==2748||2753<=_&&_<=2757||2759<=_&&_<=2760||_==2765||2786<=_&&_<=2787||2810<=_&&_<=2815||_==2817||_==2876||_==2878||_==2879||2881<=_&&_<=2884||_==2893||_==2902||_==2903||2914<=_&&_<=2915||_==2946||_==3006||_==3008||_==3021||_==3031||_==3072||3134<=_&&_<=3136||3142<=_&&_<=3144||3146<=_&&_<=3149||3157<=_&&_<=3158||3170<=_&&_<=3171||_==3201||_==3260||_==3263||_==3266||_==3270||3276<=_&&_<=3277||3285<=_&&_<=3286||3298<=_&&_<=3299||3328<=_&&_<=3329||3387<=_&&_<=3388||_==3390||3393<=_&&_<=3396||_==3405||_==3415||3426<=_&&_<=3427||_==3530||_=
` ).join("").length>0;let h=t._backgroundBillboard;const m=e._backgroundBillboardCollection;f?(l(h)||(h=m.add({collection:e,image:NQ,imageSubRegion:KKe}),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=Oa.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)&&(m.remove(h),t._backgroundBillboard=h=void 0);const g=e._glyphTextureCache;for(u=0;u<o;++u){const p=i[u],y=t._verticalOrigin,b=JSON.stringify([p,t._fontFamily,t._fontStyle,t._fontWeight,+y]);let C=g[b];if(!l(C)){const E= ` $ { t . _fontStyle } $ { t . _fontWeight } $ { cc . FONT _SIZE } px $ { t . _fontFamily } ` ,w=QKe(p,E,H.WHITE,H.WHITE,0,Kl.FILL,y);if(C=new YKe(e,-1,w.dimensions),g[b]=C,w.width>0&&w.height>0){const S=BKe(w,{cutoff:cc.CUTOFF,radius:cc.RADIUS}),P=w.getContext("2d"),L=w.width,z=w.height,R=P.getImageData(0,0,L,z);for(let F=0;F<L;F++)for(let U=0;U<z;U++){const v=U*L+F,I=S[v]*255,_=v*4;R.data[_+0]=I,R.data[_+1]=I,R.data[_+2]=I,R.data[_+3]=I}P.putImageData(R,0,0),p!==" "&&ZKe(e._textureAtlas,b,w,C)}}if(a=r[u],l(a)?C.index===-1?CR(e,a):l(a.textureInfo)&&(a.textureInfo=void 0):(a=new $ Ke,r[u]=a),a.textureInfo=C,a.dimensions=C.dimensions,C.index!==-1){let E=a.billboard;const w=e._spareBillboards;l(E)||(w.length>0?E=w.pop():(E=e._billboardCollection.add({collection:e}),E._labelDimensions=new j,E._labelTranslate=new j),a.billboard=E),E.show=t._show,E.position=t._position,E.eyeOffset=t._eyeOffset,E.pixelOffset=t._pixelOffset,E.horizontalOrigin=Oa.LEFT,E.verticalOrigin=t._verticalOrigin,E.heightReference=t._heightReference,E.scale=t.totalScale,E.pickPrimitive=t,E.id=t._id,E.image=b,E.translucencyByDistance=t._translucencyByDistance,E.pixelOffsetScaleByDistance=t._pixelOffsetScaleByDistance,E.scaleByDistance=t._scaleByDistance,E.distanceDisplayCondition=t._distanceDisplayCondition,E.disableDepthTestDistance=t._disableDepthTestDistance,E._batchIndex=t._batchIndex,E.outlineColor=t.outlineColor,t.style===Kl.FILL_AND_OUTLINE?(E.color=t._fillColor,E.outlineWidth=t.outlineWidth):t.style===Kl.FILL?(E.color=t._fillColor,E.outlineWidth=0):t.style===Kl.OUTLINE&&(E.color=H.TRANSPARENT,E.outlineWidth=t.outlineWidth)}}t._repositionAllGlyphs=!0}function M5(e,t,n){return t===Oa.CENTER?-e/2:t===Oa.RIGHT?-(e+n.x):n.x}const Ao=new j,nJe=new j;function iJe(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 m=t.length,g=e._backgroundBillboard,p=j.clone(l(g)?e._backgroundPadding:j.ZERO,nJe);for(p.x/=e._relativeSize,p.y/=e._relativeSize,h=0;h<m;++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<m-1&&(r+=t[h+1].dimensions.minx),s=Math.max(s,r));a.push(r);const y=u+c,b=e.totalScale,C=e._horizontalOrigin,E=e._verticalOrigin;let w=0,S=a[w],P=M5(S,C,p);const L=(l(e._lineHeight)?e._lineHeight:XKe*e._fontSize)/e._relativeSize,z=L*(f-1);let R=s,F=y+z;l(g)&&(R+=p.x*2,F+=p.y*2,g._labelHorizontalOrigin=C),Ao.x=P*b,Ao.y=0;let U=!0,v=0;for(h=0;h<m;++h)if(n.charAt(h)=== `
` )++w,v+=L,S=a[w],P=M5(S,C,p),Ao.x=P*b,U=!0;else if(i=t[h],o=i.dimensions,E===Hi.TOP?(Ao.y=o.height-u-p.y,Ao.y+=cc.PADDING):E===Hi.CENTER?Ao.y=(z+o.height-u)/2:E===Hi.BASELINE?(Ao.y=z,Ao.y-=cc.PADDING):(Ao.y=z+c+p.y,Ao.y-=cc.PADDING),Ao.y=(Ao.y-o.descent-v)*b,U&&(Ao.x-=cc.PADDING*b,U=!1),l(i.billboard)&&(i.billboard._setTranslate(Ao),i.billboard._labelDimensions.x=R,i.billboard._labelDimensions.y=F,i.billboard._labelHorizontalOrigin=C),h<m-1){const I=t[h+1];Ao.x+=(o.width-o.minx+I.dimensions.minx)*b}if(l(g)&&n.split( `
` ).join("").length>0&&(C===Oa.CENTER?P=-s/2-p.x:C===Oa.RIGHT?P=-(s+p.x*2):P=0,Ao.x=P*b,E===Hi.TOP?Ao.y=y-u-c:E===Hi.CENTER?Ao.y=(y-u)/2-c:E===Hi.BASELINE?Ao.y=-p.y-c:Ao.y=0,Ao.y=Ao.y*b,g.width=R,g.height=F,g._setTranslate(Ao),g._labelTranslate=j.clone(Ao,g._labelTranslate)),e.heightReference===St.CLAMP_TO_GROUND)for(h=0;h<m;++h){i=t[h];const I=i.billboard;l(I)&&(I._labelTranslate=j.clone(Ao,I._labelTranslate))}}function MQ(e,t){const n=t._glyphs;for(let i=0,o=n.length;i<o;++i)CR(e,n[i]);l(t._backgroundBillboard)&&(e._backgroundBillboardCollection.remove(t._backgroundBillboard),t._backgroundBillboard=void 0),t._labelCollection=void 0,l(t._removeCallbackFunc)&&t._removeCallbackFunc(),He(t)}function Lc(e){e=A(e,A.EMPTY_OBJECT),this._scene=e.scene,this._batchTable=e.batchTable,this._textureAtlas=void 0,this._backgroundTextureAtlas=void 0,this._backgroundBillboardCollection=new fa({scene:this._scene}),this._backgroundBillboardCollection.destroyTextureAtlas=!1,this._billboardCollection=new fa({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=H.clone(H.WHITE),this.show=A(e.show,!0),this.modelMatrix=B.clone(A(e.modelMatrix,B.IDENTITY)),this.debugShowBoundingVolume=A(e.debugShowBoundingVolume,!1),this.blendOption=A(e.blendOption,Ko.OPAQUE_AND_TRANSLUCENT)}Object.defineProperties(Lc.prototype,{length:{get:function(){return this._labels.length}}});Lc.prototype.add=function(e){const t=new fu(e,this);return this._labels.push(t),this._labelsToUpdate.push(t),t};Lc.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),MQ(this,e),!0}return!1};Lc.prototype.removeAll=function(){const e=this._labels;for(let t=0,n=e.length;t<n;++t)MQ(this,e[t]);e.length=0};Lc.prototype.contains=function(e){return l(e)&&e._labelCollection===this};Lc.prototype.get=function(e){if(!l(e))throw new x("index is required.");return this._labels[e]};Lc.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 df({context:i}),t.textureAtlas=this._textureAtlas),l(this._backgroundTextureAtlas)||(this._backgroundTextureAtlas=new df({context:i,initialSize:bR}),n.textureAtlas=this._backgroundTextureAtlas,JKe(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&&(tJe(this,a),a._rebindAllGlyphs=!1),a._repositionAllGlyphs&&(iJe(a),a._repositionAllGlyphs=!1);const u=a._glyphs.length-c;this._totalGlyphCount+=u}const r=n.length>0?Ko.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)};Lc.prototype.isDestroyed=function(){return!1};Lc.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(),He(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 oJe=new Ce;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,oJe).hei
` ,this.material.shaderSource,pq]}),r=t.getVertexShaderCallback()(KTe),s=new We({defines:i,sources:[nT,r]});this.shaderProgram=yn.fromCache({context:e,vertexShaderSource:s,fragmentShaderSource:o,attributeLocations:ka})};function qQ(e){return d.dot(d.UNIT_X,e._boundingVolume.center)<0||e._boundingVolume.intersectPlane(It.ORIGIN_ZX_PLANE)===Cn.INTERSECTING}Of.prototype.getPolylinePositionsLength=function(e){let t;if(this.mode===le.SCENE3D||!qQ(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 Sr=new d,Xc=new d,Kc=new d,fv=new d,PJe=new oe,OJe=new j;Of.prototype.write=function(e,t,n,i,o,r,s,a){const c=this.mode,u=a.ellipsoid.maximumRadius*M.PI,f=this.polylines,h=f.length;for(let m=0;m<h;++m){const g=f[m],p=g.width,y=g.show&&p>0,b=g._index,C=this.getSegments(g,a),E=C.positions,w=C.lengths,S=E.length,P=g.getPickId(s).color;let L=0,z=0,R;for(let V=0;V<S;++V){V===0?g._loop?R=E[S-2]:(R=fv,d.subtract(E[0],E[1],R),d.add(E[0],R,R)):R=E[V-1],d.clone(R,Xc),d.clone(E[V],Sr),V===S-1?g._loop?R=E[1]:(R=fv,d.subtract(E[S-1],E[S-2],R),d.add(E[S-1],R,R)):R=E[V+1],d.clone(R,Kc);const k=w[L];V===z+k&&(z+=k,++L);const G=V-z===0,W=V===z+w[L]-1;c===le.SCENE2D&&(Xc.z=0,Sr.z=0,Kc.z=0),(c===le.SCENE2D||c===le.MORPHING)&&(G||W)&&u-Math.abs(Sr.x)<1&&((Sr.x<0&&Xc.x>0||Sr.x>0&&Xc.x<0)&&d.clone(Sr,Xc),(Sr.x<0&&Kc.x>0||Sr.x>0&&Kc.x<0)&&d.clone(Sr,Kc));const K=G?2:0,q=W?2:4;for(let te=K;te<q;++te){Ln.writeElements(Sr,e,n),Ln.writeElements(Xc,e,n+6),Ln.writeElements(Kc,e,n+12);const Y=te-2<0?-1:1;t[o]=V/(S-1),t[o+1]=2*(te%2)-1,t[o+2]=Y,t[o+3]=b,n+=6*3,o+=4}}const F=PJe;F.x=H.floatToByte(P.red),F.y=H.floatToByte(P.green),F.z=H.floatToByte(P.blue),F.w=H.floatToByte(P.alpha);const U=OJe;U.x=p,U.y=y?1:0;const v=c===le.SCENE2D?g._boundingVolume2D:g._boundingVolumeWC,I=Ln.fromCartesian(v.center,VQ),_=I.high,D=oe.fromElements(I.low.x,I.low.y,I.low.z,v.radius,kQ),O=GQ;O.x=0,O.y=Number.MAX_VALUE;const N=g.distanceDisplayCondition;l(N)&&(O.x=N.near,O.y=N.far),r.setBatchedAttribute(b,0,U),r.setBatchedAttribute(b,1,F),r.attributes.length>2&&(r.setBatchedAttribute(b,2,_),r.setBatchedAttribute(b,3,D),r.setBatchedAttribute(b,4,O))}};const LJe=new d,BJe=new d,RJe=new d,W5=new d;Of.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 m=0;m<u;++m){let g;m===0?s._loop?g=a[u-2]:(g=W5,d.subtract(a[0],a[1],g),d.add(a[0],g,g)):g=a[m-1],g=B.multiplyByPoint(n,g,BJe);const p=B.multiplyByPoint(n,a[m],LJe);let y;m===u-1?s._loop?y=a[1]:(y=W5,d.subtract(a[u-1],a[u-2],y),d.add(a[u-1],y,y)):y=a[m+1],y=B.multiplyByPoint(n,y,RJe);const b=c[f];m===h+b&&(h+=b,++f);const C=m-h===0,E=m===h+c[f]-1,w=C?2:0,S=E?2:4;for(let P=w;P<S;++P)Ln.writeElements(p,e,t),Ln.writeElements(g,e,t+6),Ln.writeElements(y,e,t+12),t+=6*3}}};const NJe=new Array(1);Of.prototype.updateIndices=function(e,t,n,i){let o=n.length-1,r=new rO(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 m=u[h];m._locatorBuckets=[];let g;if(this.mode===le.SCENE3D){g=NJe;const y=m._actualPositions.length;if(y>0)g[0]=y;else continue}else g=m._segments.lengths;const p=g.length;if(p>0){let y=0;for(let b=0;b<p;++b){const C=g[b]-1;for(let E=0;E<C;++E)c+4>M.SIXTY_FOUR_KILOBYTES&&(m._locatorBuckets.push({locator:r,count:y}),y=0,t.push(4),a=[],e.push(a),c=0,r.count=s,s=0,i=0,r=new rO(0,0,this),n[++o]=[r]),a.push(c,c+2,c+1),a.push(c+1,c+2,c+3),y+=6,s+=6,i+=6,c+=4}m._locatorBuckets.push({locator:r,count:y}),c+4>M.SIXTY_FOUR_KILOBYTES&&(t.push(0),a=[],e.push(a),c=0,r.count=s,i=0,s=0,r=new rO(0,0,this),n[++o]=[r])}m._clean()}return r.count=s,i};Of.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 Fg={positions:void 0,lengths:void 0},j5=new Array(1),MJe=new d,FJe=new Ce;Of.prototype.getSegments=function(
2023-02-06 08:55:59 +00:00
void main ( )
{
gl _FragColor = u _highlightColor ;
}
2023-02-13 02:05:23 +00:00
` ;function uQe(e,t){if(l(e._sp))return;const n=e._batchTable,i=n.getVertexShaderCallback(!1,"a_batchId",void 0)(lEe),o=n.getFragmentShaderCallback(!1,void 0,!1)(lQe),r=new We({defines:["VECTOR_TILE",pn.isInternetExplorer()?"":"CLIP_POLYLINE"],sources:[nT,i]}),s=new We({defines:["VECTOR_TILE"],sources:[o]});e._sp=yn.fromCache({context:t,vertexShaderSource:r,fragmentShaderSource:s,attributeLocations:ay})}function fQe(e,t){if(!l(e._command)){const n=e._batchTable.getUniformMapCallback()(e._uniformMap);e._command=new pt({owner:e,vertexArray:e._va,renderState:e._rs,shaderProgram:e._sp,uniformMap:n,boundingVolume:e._boundingVolume,pass:Ne.TRANSLUCENT,pickId:e._batchTable.getPickId()})}t.commandList.push(e._command)}ml.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],m=o[r+1]-h;for(s=0;s<m;++s){const g=(h+s)*3;f[u++]=i[g],f[u++]=i[g+1],f[u++]=i[g+2]}}return f};ml.prototype.getPositions=function(e){return ml.getPolylinePositions(this,e)};ml.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 _s(e,r)}};ml.prototype.applyDebugSettings=function(e,t){this._highlightColor=e?t:this._constantColor};function dQe(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=H.WHITE}}const hQe=new H,pQe=H.WHITE,mQe=!0;ml.prototype.applyStyle=function(e,t){if(!l(e)){dQe(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,hQe):pQe,s.show=l(e.show)?e.show.evaluate(s):mQe}};function _Qe(e){return new Promise(function(t,n){e._update=function(i,o){const r=o.context,s=rQe(i);if(aQe(i,r),uQe(i,r),cQe(i),i._ready){const a=o.passes;(a.render||a.pick)&&fQe(i,o)}l(s)&&s.then(function(){sQe(i,r),t()}).catch(function(a){n(a)})}})}ml.prototype.update=function(e){this._update(this,e)};ml.prototype.isDestroyed=function(){return!1};ml.prototype.destroy=function(){return this._va=this._va&&this._va.destroy(),this._sp=this._sp&&this._sp.destroy(),He(this)};function eh(e){this._positions=e.positions,this._widths=e.widths,this._counts=e.counts,this._batchIds=e.batchIds,this._ellipsoid=A(e.ellipsoid,me.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(co._defaultMinTerrainHeight,co._defaultMaxTerrainHeight),this._boundingVolume=Ft.fromRectangle(e.rectangle,co._defaultMinTerrainHeight,co._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=H.clone(H.WHITE),this._highlightColor=this._constantColor,this._trianglesLength=0,this._geometryByteLength=0,this._ready=!1,this._update=function(t,n){},this._readyPromise=PQe(this),this._verticesPromise=void 0}Object.defineProperties(eh.prototype,{trianglesLength:{get:function(){return this._trianglesLength}},geometryByteLength:{get:function(){return this._geometryByteLength}},readyPromise:{get:function(){return this._readyPromise}}});function gQe(e,t,n){const i=co.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;Ft.fromRectangle(c,o,r,n,a)}function yQe(e){c
2023-02-06 08:55:59 +00:00
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+= `
2023-02-13 02:05:23 +00:00
Texture Memory : $ { aG ( e . content . texturesByteLength ) } ` ,i+= `
Geometry Memory : $ { aG ( e . content . geometryByteLength ) } ` ,o+=2),t.debugShowUrl)if(e.hasMultipleContents){i+= `
2023-02-06 08:55:59 +00:00
Urls : ` ;const s=e.content.innerContentUrls;for(let a=0;a<s.length;a++)i+= `
- $ { s [ a ] } ` ;o+=s.length}else i+= `
2023-02-13 02:05:23 +00:00
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 Aet(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:xO(e.debugPickedTile),u=wO(e.debugPickedTile,e,c);u.pixelOffset=new j(15,-15)}}else{for(n=0;n<r;++n)i=o[n],wO(i,e,xO(i));for(n=0;n<a;++n)i=s[n],(i.hasTilesetContent||i.hasImplicitContent)&&wO(i,e,xO(i))}e._tileDebugLabels.update(t)}function bet(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 m,g;const p=e._skipLevelOfDetail&&e._hasMixedContent&&t.context.stencilBuffer&&c>0;e._backfaceCommands.length=0,p&&(l(e._stencilClearCommand)||(e._stencilClearCommand=new ao({stencil:0,pass:Ne.CESIUM_3D_TILE,renderState:Ze.fromCache({stencilMask:Rt.SKIP_LOD_MASK})})),r.push(e._stencilClearCommand));const y=r.length;for(m=0;m<c;++m)g=a[m],i&&h.raiseEvent(g),g.update(e,t,n),o.incrementSelectionCounts(g.content),++o.selected;for(m=0;m<f;++m)g=u[m],g.update(e,t,n);let b=r.length-y;if(e._backfaceCommands.trim(),p){const C=e._backfaceCommands.values,E=C.length;for(r.length+=E,m=b-1;m>=0;--m)r[y+E+m]=r[y+m];for(m=0;m<E;++m)r[y+m]=C[m]}b=r.length-s,o.numberOfCommands=b,i&&e.pointCloudShading.attenuation&&e.pointCloudShading.eyeDomeLighting&&b>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 Lc),Aet(e,t)):e._tileDebugLabels=e._tileDebugLabels&&e._tileDebugLabels.destroy())}const mZ=[];function Cet(e,t){const n=t,i=mZ;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&&(Tet(e,t),--e._statistics.numberOfTilesTotal)}n.children=[]}function _Z(e,t){e.tileUnload.raiseEvent(t),e._statistics.decrementLoadCounts(t.content),--e._statistics.numberOfTilesWithContentReady,t.unloadContent()}function Tet(e,t){e._cache.unloadTile(e,t,_Z),t.destroy()}Nr.prototype.trimLoadedTiles=function(){this._cache.trim()};function Eet(e,t){const n=e._statistics,i=e._statisticsLast,o=n.numberOfPendingRequests,r=n.numberOfTilesProcessing,s=i.numberOfPendingRequests,a=i.numberOfTilesProcessing;rf.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 xet(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 wet(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 vet(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,xet(e),wet(e,t),e._cullRequestsWhileMoving=e.cullRequestsWhileMoving&&!e._modelMatrixChanged;const s=i.traversal.selectTiles(e,t);if(i.requestTiles&&det(e),bet(e,t,i),rf.clone(o,n)
2023-02-06 08:55:59 +00:00
vec4 clippingPlanesEdgeColor = vec4 ( 1.0 ) ;
clippingPlanesEdgeColor . rgb = $ { n } . rgb ;
float clippingPlanesEdgeWidth = $ { n } . a ;
if ( clipDistance > 0.0 && clipDistance < clippingPlanesEdgeWidth )
{
gl _FragColor = clippingPlanesEdgeColor ;
}
2023-02-13 02:05:23 +00:00
` }const yat={modifyFragmentShader:function(t){return t=We.replaceMain(t,"czm_splitter_main"),t+= ` uniform float czm _splitDirection ;
2023-02-06 08:55:59 +00:00
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 ( ) ;
}
2023-02-13 02:05:23 +00:00
` ,t},addUniforms:function(t,n){n.czm_splitDirection=function(){return t.splitDirection}}},vte=yat, $ m={NEEDS_DECODE:0,DECODING:1,READY:2,FAILED:3};function HT(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=H.clone(H.DARKGRAY),this._highlightColor=H.clone(H.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= $ m.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=A(e.opaquePass,Ne.OPAQUE),this._cull=A(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=Io.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=A(e.splitDirection, $ _.NONE),this._splittingEnabled=!1,this._resolveReadyPromise=void 0,this._rejectReadyPromise=void 0,this._readyPromise=Aat(this,e)}Object.defineProperties(HT.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 H.clone(this._highlightColor)},set:function(e){this._highlightColor=H.clone(e,this._highlightColor)}},boundingSphere:{get:function(){if(l(this._drawCommand))return this._drawCommand.boundingVolume},set:function(e){this._boundingSphere=de.clone(e,this._boundingSphere)}}});function Aat(e,t){const n=iQ.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=Ii.getBinaryProperties(n.pointsLength,n.batchTableJson,n.batchTableBinary)),l(n.draco)){const a=n.draco;e._decodingState= $ m.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=H.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 bat=new d,Cat=new d,Tat=new d;let z8,aw;function Eat(e){if(!l(aw)){z8=new qv(0),aw=new Array(e);for(let t=0;t<e;++t)aw[t]=z8.random()}return aw}function xat(e){const n=e.length/3,i=Math.min(n,20),o=Eat(20),r=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=d.fromElements(r,r,r,bat),c=d.fromElements(s,s,s,Cat);for(let f=0;f<i;++f){const h=Math.floor(o[f]*n),m=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 iL(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 Lat={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 Bat(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,m=e._isRGB565,g=e._isTranslucent,p=e._hasColors,y=e._hasNormals,b=e._hasBatchIds,C=e._backFaceCulling,E=e._normalShading,w=e._drawCommand.vertexArray,S=e.clippingPlanes,P=e._attenuation;let L,z,R,F=g;const U=dt(Lat),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),z=n.getShowShaderFunction( ` getShowFromStyle$ { he } ` ,U,re),R=n.getPointSizeShaderFunction( ` getPointSizeFromStyle$ { he } ` ,U,re),l(L)&&re.translucent&&(F=!0)}e._styleTranslucent=F;const _=l(L),D=l(z),O=l(R),N=e.isClipped,V=[],k=[];_&&(tL(L,V),nL(L,k)),D&&(tL(z,V),nL(z,k)),O&&(tL(R,V),nL(R,k));const G=k.indexOf("COLOR")>=0,W=k.indexOf("NORMAL")>=0;if(W&&!y)throw new Ie("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=iL(w,r.location);he.enabled=re}const K=p&&(!_||G);if(p){const re=iL(w,bv);re.enabled=K}const q=y&&(E||C||W);if(y){const re=iL(w,HR);re.enabled=q}const te={a_position:Dte};K&&(te.a_color=bv),q&&(te.a_normal=HR),b&&(te.a_batchId=Ite);let Y="";const X=V.length;for(i=0;i<X;++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 } ` ,Y+= ` attribute $ { Q } $ { ce } ;
` ,te[ce]=r.location}Oat(e,t);let $ = ` attribute vec3 a _position ;
2023-02-06 08:55:59 +00:00
varying vec4 v _color ;
uniform vec4 u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier ;
uniform vec4 u _constantColor ;
uniform vec4 u _highlightColor ;
2023-02-13 02:05:23 +00:00
` ; $ += ` float u _pointSize ;
2023-02-06 08:55:59 +00:00
float tiles3d _tileset _time ;
2023-02-13 02:05:23 +00:00
` ,P&&( $ += ` float u _geometricError ;
2023-02-06 08:55:59 +00:00
float u _depthMultiplier ;
2023-02-13 02:05:23 +00:00
` ), $ +=Y,K&&(g? $ += ` attribute vec4 a _color ;
` :m? $ += ` attribute float a _color ;
2023-02-06 08:55:59 +00:00
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 ;
2023-02-13 02:05:23 +00:00
` : $ += ` attribute vec3 a _color ;
` ),q&&(f||h? $ += ` attribute vec2 a _normal ;
` : $ += ` attribute vec3 a _normal ;
` ),b&&( $ += ` attribute float a _batchId ;
` ),(c||u||h)&&( $ += ` uniform vec4 u _quantizedVolumeScaleAndOctEncodedRange ;
` ),_&&( $ +=L),D&&( $ +=z),O&&( $ +=R), $ += ` void main ( )
2023-02-06 08:55:59 +00:00
{
u _pointSize = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . x ;
tiles3d _tileset _time = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . y ;
2023-02-13 02:05:23 +00:00
` ,P&&( $ += ` u _geometricError = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . z ;
2023-02-06 08:55:59 +00:00
u _depthMultiplier = u _pointSizeAndTimeAndGeometricErrorAndDepthMultiplier . w ;
2023-02-13 02:05:23 +00:00
` ),K?g? $ += ` vec4 color = a _color ;
` :m? $ += ` float compressed = a _color ;
2023-02-06 08:55:59 +00:00
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 ) ;
2023-02-13 02:05:23 +00:00
` : $ += ` vec4 color = vec4 ( a _color , 1.0 ) ;
` : $ += ` vec4 color = u _constantColor ;
` ,c||u? $ += ` vec3 position = a _position * u _quantizedVolumeScaleAndOctEncodedRange . xyz ;
` : $ += ` vec3 position = a _position ;
` , $ += ` vec3 position _absolute = vec3 ( czm _model * vec4 ( position , 1.0 ) ) ;
` ,q?(f? $ += ` vec3 normal = czm _octDecode ( a _normal ) ;
` :h? $ += ` vec3 normal = czm _octDecode ( a _normal , u _quantizedVolumeScaleAndOctEncodedRange . w ) . zxy ;
` : $ += ` vec3 normal = a _normal ;
` , $ += ` vec3 normalEC = czm _normal * normal ;
` ): $ += ` vec3 normal = vec3 ( 1.0 ) ;
` ,_&&( $ += ` color = getColorFromStyle ( position , position _absolute , color , normal ) ;
` ),D&&( $ += ` float show = float ( getShowFromStyle ( position , position _absolute , color , normal ) ) ;
` ),O? $ += ` gl _PointSize = getPointSizeFromStyle ( position , position _absolute , color , normal ) * czm _pixelRatio ;
` :P? $ += ` vec4 positionEC = czm _modelView * vec4 ( position , 1.0 ) ;
2023-02-06 08:55:59 +00:00
float depth = - positionEC . z ;
gl _PointSize = min ( ( u _geometricError / depth ) * u _depthMultiplier , u _pointSize ) ;
2023-02-13 02:05:23 +00:00
` : $ += ` gl _PointSize = u _pointSize ;
` , $ += ` color = color * u _highlightColor ;
` ,q&&E&&( $ += ` float diffuseStrength = czm _getLambertDiffuse ( czm _lightDirectionEC , normalEC ) ;
2023-02-06 08:55:59 +00:00
diffuseStrength = max ( diffuseStrength , 0.4 ) ;
color . xyz *= diffuseStrength * czm _lightColor ;
2023-02-13 02:05:23 +00:00
` ), $ += ` v _color = color ;
2023-02-06 08:55:59 +00:00
gl _Position = czm _modelViewProjection * vec4 ( position , 1.0 ) ;
2023-02-13 02:05:23 +00:00
` ,q&&C&&( $ += ` float visible = step ( - normalEC . z , 0.0 ) ;
2023-02-06 08:55:59 +00:00
gl _Position *= visible ;
gl _PointSize *= visible ;
2023-02-13 02:05:23 +00:00
` ),D&&( $ += ` gl _Position . w *= float ( show ) ;
2023-02-06 08:55:59 +00:00
gl _PointSize *= float ( show ) ;
2023-02-13 02:05:23 +00:00
` ), $ += ` }
2023-02-07 08:44:46 +00:00
` ;let se= ` varying vec4 v _color ;
2023-02-13 02:05:23 +00:00
` ;N&&(se+= ` uniform highp sampler2D u _clippingPlanes ;
2023-02-06 08:55:59 +00:00
uniform mat4 u _clippingPlanesMatrix ;
uniform vec4 u _clippingPlanesEdgeStyle ;
2023-02-07 08:44:46 +00:00
` ,se+= `
2023-02-13 02:05:23 +00:00
` ,se+=vM(S,s),se+= `
2023-02-07 08:44:46 +00:00
` ),se+= ` void main ( )
2023-02-06 08:55:59 +00:00
{
gl _FragColor = czm _gammaCorrect ( v _color ) ;
2023-02-13 02:05:23 +00:00
` ,N&&(se+=gat("u_clippingPlanes","u_clippingPlanesMatrix","u_clippingPlanesEdgeStyle")),se+= ` }
` ,e.splitDirection!== $ _.NONE&&(se=vte.modifyFragmentShader(se)),l(e._vertexShaderLoaded)&&( $ =e._vertexShaderLoaded( $ )),l(e._fragmentShaderLoaded)&&(se=e._fragmentShaderLoaded(se));const ue=e._drawCommand;l(ue.shaderProgram)&&ue.shaderProgram.destroy(),ue.shaderProgram=yn.fromCache({context:s,vertexShaderSource: $ ,fragmentShaderSource:se,attributeLocations:te});try{ue.shaderProgram._bind()}catch{throw new Ie("Error generating style shader: this may be caused by a type mismatch, index out-of-bounds, or other syntax error.")}}function Rat(e,t){if(e._decodingState=== $ m.READY)return!1;if(e._decodingState=== $ m.NEEDS_DECODE){const n=e._parsedContent,i=n.draco,o=as.decodePointCloud(i,t);l(o)&&(e._decodingState= $ m.DECODING,o.then(function(r){e._decodingState= $ m.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),m=l(u)&&l(r.NORMAL.data.quantization);if(h){const b=r.POSITION.data.quantization,C=b.range;e._quantizedVolumeScale=d.fromElements(C,C,C),e._quantizedVolumeOffset=d.unpack(b.minValues),e._quantizedRange=(1<<b.quantizationBits)-1,e._isQuantizedDraco=!0}m&&(e._octEncodedRange=(1<<r.NORMAL.data.quantization.quantizationBits)-1,e._isOctEncodedDraco=!0);let g=n.styleableProperties;const p=i.batchTableProperties;for(const b in p)if(p.hasOwnProperty(b)){const C=r[b];l(g)||(g={}),g[b]={typedArray:C.array,componentCount:C.data.componentsPerAttribute}}l(s)&&(n.positions={typedArray:s});const y=A(c,a);l(y)&&(n.colors={typedArray:y}),l(u)&&(n.normals={typedArray:u}),l(f)&&(n.batchIds={typedArray:f}),n.styleableProperties=g}).catch(function(r){e._decodingState= $ m.FAILED,e._rejectReadyPromise(r)}))}return!0}const Nat=new oe,Mat=new d;HT.prototype.update=function(e){const t=e.context;if(Rat(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)||(Pat(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,m=B.getColumn(u,3,Nat);oe.equals(m,oe.UNIT_W)||sn.basisTo2D(h,u,u)}const f=this._drawCommand.boundingVolume;if(de.clone(this._boundingSphere,f),this._cull){const h=f.center;B.multiplyByPoint(u,h,h);const m=B.getScale(u,Mat);f.radius*=d.maximumComponent(m)}}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!== $ _.NONE;this._splittingEnabled!==r&&(this._splittingEnabled=r,i=!0),i&&Bat(this,e,this._style),this._drawCommand.castShadows=Io.castShadows(this.shadows),this._drawCommand.receiveShadows=Io.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?Ne.TRANSLUCENT:this._opaquePass;const a=e.commandList,c=e.passes;(c.render||c.pick)&&a.push(this._drawCommand)};HT.prototype.isDestroyed=function(){return!1};HT.prototype.destroy=function(){const e=this._drawCommand;return l(e)&&(e.vertexArray=e.vertexArray&&e.vertexArray.destroy(),e.shaderProgram=e.shaderProgram&&e.shaderProgram.destroy()),He(this)};function Sl(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.rend
$ { e } ` }function Uat(e){return function(t){return un(t,{czm_pickColor:function(){return e._pickId.color}})}}function Hat(){return"czm_pickColor"}im.prototype.makeStyleDirty=function(){this._styleDirty=!0};im.prototype._getAverageLoadTime=function(){return this._runningLength===0?.05:this._runningAverage};const Vat=new ie;function CF(e){const t=e._clock,n=t.canAnimate&&t.shouldAnimate,i=t.multiplier;return n?i:0}function N_(e,t){return e._intervals.indexOf(t.start)}function kat(e,t){const n=e._intervals,i=e._clock,o=CF(e);if(o===0)return;const r=e._getAverageLoadTime(),s=ie.addSeconds(i.currentTime,r*o,Vat);let a=n.indexOf(s);const c=N_(e,t);return a===c&&(o>=0?++a:--a),n.get(a)}function Gat(e){const t=e._intervals,i=e._clock.currentTime,o=t.indexOf(i);return t.get(o)}function Wat(e,t,n){const i=CF(e),o=N_(e,t),r=N_(e,n);return i>=0?o>=r:o<=r}function jat(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 qat(e,t,n){const i=N_(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:fr(),sequential:!0,ready:!1,touchedFrameNumber:n.frameNumber},o[i]=r,Me.fetchArrayBuffer({url:c}).then(function(u){return r.pointCloud=new HT({arrayBuffer:u,cull:!0,fragmentShaderLoaded:zat,uniformMapLoaded:Uat(e),pickIdLoaded:Hat}),r.pointCloud.readyPromise}).catch(jat(e,c))}return r}function $ at(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 Yat(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(Pte(e,t,n,i),o.ready&&(t.ready=!0,e._totalMemoryUsageInBytes+=o.geometryByteLength,r.length=s,t.sequential)){const a=(fr()-t.timestamp)/1e3; $ at(e,a)}}t.touchedFrameNumber=i.frameNumber}const Xat=new B;function Kat(e,t){const n=e.shading;return l(n)&&l(n.baseResolution)?n.baseResolution:l(t.boundingSphere)?M.cbrt(t.boundingSphere.volume()/t.pointsLength):0}function Jat(e){const t=e.shading;return l(t)&&l(t.maximumAttenuation)?t.maximumAttenuation:10}const Qat=new vT;function Pte(e,t,n,i){const o=A(e.shading,Qat),r=t.pointCloud,s=A(t.transform,B.IDENTITY);r.modelMatrix=B.multiplyTransformation(e.modelMatrix,s,Xat),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=Kat(e,r),r.geometricErrorScale=o.geometricErrorScale,r.maximumAttenuation=Jat(e),r.update(i),t.touchedFrameNumber=i.frameNumber}function VR(e,t,n,i){const o=qat(e,t,i);Yat(e,o,n,i)}function Zat(e){return function(t){return t.touchedFrameNumber<e.frameNumber}}function Ote(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 ect(e,t){const n=N_(e,t),i=e._frames[n];if(l(i)&&i.ready)return i}function V8(e,t,n,i,o){return l(n)?n.ready?!0:(VR(e,t,i,o),n.ready):!1}function tct(e,t,n,i,o){let r,s,a;const c=e._intervals,u=e._frames,f=N_(e,n),h=N_(e,t);if(f>=h){for(r=f;r>=h;--r)if(s=c.get(r),a=u[r],V8(e,s,a,i,o))return s}else for(r=f;r<=h;++r)if(s=c.get(r),a=u[r],V8(e,s,a,i,o))return s;return t}function nct(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 Kg={timeSinceLoad:0,isClipped:!1,clippingPlanesDirty:!1};im.prototype.update=function(e){if(e.mode===le.MORPHING||!this.show)return;l(this._pickId)||(
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
` ,oct= ` attribute vec2 position ;
2023-02-06 08:55:59 +00:00
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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,rct= ` / * Intersection defines
2023-02-06 08:55:59 +00:00
# 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 };
2023-02-13 02:05:23 +00:00
` ,sct= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections,
2023-02-06 08:55:59 +00:00
// 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 ) ) ;
}
}
2023-02-13 02:05:23 +00:00
` ,act= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections, INF_HIT,
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
` ,cct= ` // See IntersectionUtils.glsl for the definitions of Ray and NO_HIT
2023-02-06 08:55:59 +00:00
/ * 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,lct= ` // See IntersectionUtils.glsl for the definitions of Ray, setIntersection,
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
` ,uct= ` // See IntersectionUtils.glsl for the definitions of Ray, Intersections,
2023-02-06 08:55:59 +00:00
// 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
}
2023-02-13 02:05:23 +00:00
` ,oL= ` // Main intersection function for Voxel scenes.
2023-02-06 08:55:59 +00:00
// 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 ;
}
2023-02-13 02:05:23 +00:00
` ,fct= ` / * Box defines ( set in Scene / VoxelBoxShape . js )
2023-02-06 08:55:59 +00:00
# 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
}
2023-02-13 02:05:23 +00:00
` ,dct= ` / * Cylinder defines ( set in Scene / VoxelCylinderShape . js )
2023-02-06 08:55:59 +00:00
# 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,hct= ` / * Ellipsoid defines ( set in Scene / VoxelEllipsoidShape . js )
2023-02-06 08:55:59 +00:00
# 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 ) ;
}
2023-02-13 02:05:23 +00:00
` ,pct= ` // These octree flags must be in sync with GpuOctreeFlag in VoxelTraversal.js
2023-02-06 08:55:59 +00:00
# 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 ) ;
}
}
2023-02-13 02:05:23 +00:00
` ,mct= ` // See Octree.glsl for the definitions of SampleData and intMod
2023-02-06 08:55:59 +00:00
/ * 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
}
2023-02-13 02:05:23 +00:00
` ;function _ct(e){const t=new ha;this.shaderBuilder=t;const n=e._customShader,i=un(e._uniformMap,n.uniformMap);e._uniformMap=i;const o=n.uniforms;for(const m in o)if(o.hasOwnProperty(m)){const g=o[m];t.addUniform(g.type,m,De.FRAGMENT)}t.addUniform("sampler2D","u_megatextureTextures[METADATA_COUNT]",De.FRAGMENT),this.uniformMap=i;const r=e._clippingPlanes,s=l(r)&&r.enabled?r.length:0;this.clippingPlanes=r,this.clippingPlanesLength=s,t.addVertexLines([oct]),t.addFragmentLines([n.fragmentShaderText,"#line 0",rct]),s>0&&(t.addDefine("CLIPPING_PLANES",void 0,De.FRAGMENT),t.addDefine("CLIPPING_PLANES_COUNT",s,De.FRAGMENT),r.unionClippingRegions&&t.addDefine("CLIPPING_PLANES_UNION",void 0,De.FRAGMENT),t.addFragmentLines([act])),e._depthTest&&(t.addDefine("DEPTH_TEST",void 0,De.FRAGMENT),t.addFragmentLines([sct]));const a=e._provider.shape;a==="BOX"?t.addFragmentLines([cct,oL,fct]):a==="CYLINDER"?t.addFragmentLines([lct,oL,dct]):a==="ELLIPSOID"&&t.addFragmentLines([uct,oL,hct]),t.addFragmentLines([pct,mct,ict]);const c=e._shape,u=c.shaderDefines;for(const m in u)if(u.hasOwnProperty(m)){let g=u[m];l(g)&&(g=g===!0?void 0:g,t.addDefine(m,g,De.FRAGMENT))}let f=c.shaderMaximumIntersectionsLength;s>0&&(t.addDefine("CLIPPING_PLANES_INTERSECTION_INDEX",f,De.FRAGMENT),s===1?f+=1:r.unionClippingRegions?f+=2:f+=1),e._depthTest&&(t.addDefine("DEPTH_INTERSECTION_INDEX",f,De.FRAGMENT),f+=1),t.addDefine("INTERSECTION_COUNT",f,De.FRAGMENT),(!d.equals(e.paddingBefore,d.ZERO)||!d.equals(e.paddingAfter,d.ZERO))&&t.addDefine("PADDING",void 0,De.FRAGMENT),e._useLogDepth&&t.addDefine("LOG_DEPTH_READ_ONLY",void 0,De.FRAGMENT),e._jitter&&t.addDefine("JITTER",void 0,De.FRAGMENT),e._nearestSampling&&t.addDefine("NEAREST_SAMPLING",void 0,De.FRAGMENT);const h=e._traversal;t.addDefine("SAMPLE_COUNT", ` $ { h . _sampleCount } ` ,De.FRAGMENT)}function gct(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,De.FRAGMENT),u&&n.addDefine("STATISTICS",void 0,De.FRAGMENT);for(let R=0;R<c;R++){const F=i[R],U=o[R],v= ` PropertyStatistics _$ { F } ` ,I= ` PropertyStatistics _$ { F } ` ;n.addStruct(v,I,De.FRAGMENT);const _=cw(U);n.addStructField(v,_,"min"),n.addStructField(v,_,"max")}const f="Statistics",h="Statistics",m="statistics";n.addStruct(f,h,De.FRAGMENT);for(let R=0;R<c;R++){const F=i[R],U= ` PropertyStatistics _$ { F } ` ,v=F;n.addStructField(f,U,v)}const g="Metadata",p="Metadata",y="metadata";n.addStruct(g,p,De.FRAGMENT),n.addStructField(g,h,m);for(let R=0;R<c;R++){const F=i[R],U=o[R],v=cw(U);n.addStructField(g,v,F)}for(let R=0;R<c;R++){const F=i[R],U=o[R],v=Act(U),I= ` VoxelProperty _$ { F } ` ,_= ` VoxelProperty _$ { F } ` ;n.addStruct(I,_,De.FRAGMENT),n.addStructField(I,v,"partialDerivativeLocal"),n.addStructField(I,v,"partialDerivativeWorld"),n.addStructField(I,v,"partialDerivativeView"),n.addStructField(I,v,"partialDerivativeValid")}const b="Voxel",C="Voxel",E="voxel";n.addStruct(b,C,De.FRAGMENT);for(let R=0;R<c;R++){const F=i[R],U= ` VoxelProperty _$ { F } ` ;n.addStructField(b,U,F)}n.addStructField(b,"vec3","positionEC"),n.addStructField(b,"vec3","positionUv"),n.addStructField(b,"vec3","positionShapeUv"),n.addStructField(b,"vec3","positionUvLocal"),n.addStructField(b,"vec3","viewDirUv"),n.addStructField(b,"vec3","viewDirWorld"),n.addStructField(b,"float","travelDistance");const w="FragmentInput",S="FragmentInput";n.addStruct(w,S,De.FRAGMENT),n.addStructField(w,p,y),n.addStructField(w,C,E);const P="Properties",L="Properties",z="properties";n.addStruct(P,L,De.FRAGMENT);for(let R=0;R<c;R++){const F=i[R],U=o[R],v=cw(U);n.addStructField(P,v,F)}{const R="clearProperties";n.addFunction(R, ` $ { L } clearProperties ( ) ` ,De.FRAGMENT),n.addFunctionLines(R,[ ` $ { L } $ { z } ; ` ]);for(let F=0;F<c;F++){const U=i[F],v=o[F];r[F];const I=cw(v);n.addFunctionLines(R,[ ` $ { z } . $ { U } = $ { I } ( 0.0 ) ; ` ])}n.addFunctionLines(R,[ ` return $ { z } ; ` ])}{const R="sumProperties";n.addFunction(R, ` $ { L } sumProperties ( $ { L } propertiesA , $ { L } propertiesB ) ` ,De.FRAGMENT),n.addFunctionLines(R,[ ` $ { L } $ { z } ; ` ]);for(let F=0;F<c;F++){const U=i[F];n.addFunctionLines(
2023-02-06 08:55:59 +00:00
{
material . diffuse = vec3 ( 1.0 ) ;
material . alpha = 1.0 ;
2023-02-13 02:05:23 +00:00
} ` });function Fte(){this.ready=!0,this.readyPromise=Promise.resolve(this),this.shape=dy.BOX,this.dimensions=new d(1,1,1),this.names=["data"],this.types=[Bt.SCALAR],this.componentTypes=[jt.FLOAT32],this.maximumTileCount=1}Fte.prototype.requestData=function(e){if(!((l(e)?A(e.tileLevel,0):0)>=1))return Promise.resolve([new Float32Array(1)])};mu.DefaultProvider=new Fte;function $ D(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=[ge.center(e),ge.southeast(e),ge.southwest(e),ge.northeast(e),ge.northwest(e)];return $ D._sampleTerrainMostDetailed(n,c).then(function(u){const f=u.reduce(function(m,g){return Math.max(g.height,m)},-Number.MAX_VALUE),h=r;return h.height+=f,h})}):Promise.resolve(r)} $ D._sampleTerrainMostDetailed=jD;var mb;typeof ko<"u"&&(mb=ko);(function(){/*!
2023-02-06 08:55:59 +00:00
* Knockout JavaScript library v3 . 5.1
* ( c ) The Knockout . js team - http : //knockoutjs.com/
* License : MIT ( http : //www.opensource.org/licenses/mit-license.php)
2023-02-13 02:05:23 +00:00
* /(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 y?v===I:!1}function u(v,I){var _;return function(){_||(_=p.a.setTimeout(function(){_=e,v()},I))}}function f(v,I){var _;return function(){clearTimeout(_),_=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 m(v,I){I!==null&&I.s&&I.s()}function g(v,I){var _=this.qd,D=_[S];D.ra||(this.Qb&&this.mb[I]?(_.uc(I,v,this.mb[I]),this.mb[I]=null,--this.Qb):D.I[I]||_.uc(I,v,D.J?{da:v}:_.$c(v)),v.Ja&&v.gd())}var p=typeof s<"u"?s:{};p.b=function(v,I){for(var _=v.split("."),D=p,O=0;O<_.length-1;O++)D=D[_[O]];D[_[_.length-1]]=I},p.L=function(v,I,_){v[I]=_},p.version="3.5.1",p.b("version",p.version),p.options={deferUpdates:!1,useOnlyNativeEvents:!1,foreachHidesDestroyed:!1},p.a=function(){function v(Y,X){for(var $ in Y)O.call(Y,$)&&X($,Y[$])}function I(Y,X){if(X)for(var $ in X)O.call(X,$)&&(Y[$]=X[$]);return Y}function _(Y,X){return Y.__proto__=X,Y}function D(Y,X,$,se){var ue=Y[X].match(q)||[];p.a.D($.match(q),function(re){p.a.Na(ue,re,se)}),Y[X]=ue.join(" ")}var O=Object.prototype.hasOwnProperty,N={__proto__:[]}instanceof Array,V=typeof Symbol=="function",k={},G={};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(Y,X){if(X.length)for(var $=0,se=X.length;$<se;$++)G[X[$]]=Y});var W={propertychange:!0},K=n&&function(){for(var Y=3,X=n.createElement("div"),$=X.getElementsByTagName("i");X.innerHTML="<!--[if gt IE "+ ++Y+"]><i></i > < ! [ endif ] -- > ",$[0];);return 4<Y?Y:e}(),q=/\S+/g,te;return{Jc:[" authenticity _token ",/^__RequestVerificationToken(_.*)?$/],D:function(Y,X,$){for(var se=0,ue=Y.length;se<ue;se++)X.call($,Y[se],se,Y)},A:typeof Array.prototype.indexOf==" function "?function(Y,X){return Array.prototype.indexOf.call(Y,X)}:function(Y,X){for(var $=0,se=Y.length;$<se;$++)if(Y[$]===X)return $;return-1},Lb:function(Y,X,$){for(var se=0,ue=Y.length;se<ue;se++)if(X.call($,Y[se],se,Y))return Y[se];return e},Pa:function(Y,X){var $=p.a.A(Y,X);0<$?Y.splice($,1):$===0&&Y.shift()},wc:function(Y){var X=[];return Y&&p.a.D(Y,function($){0>p.a.A(X,$)&&X.push($)}),X},Mb:function(Y,X,$){var se=[];if(Y)for(var ue=0,re=Y.length;ue<re;ue++)se.push(X.call($,Y[ue],ue));return se},jb:function(Y,X,$){var se=[];if(Y)for(var ue=0,re=Y.length;ue<re;ue++)X.call($,Y[ue],ue)&&se.push(Y[ue]);return se},Nb:function(Y,X){if(X instanceof Array)Y.push.apply(Y,X);else for(var $=0,se=X.length;$<se;$++)Y.push(X[$]);return Y},Na:function(Y,X,$){var se=p.a.A(p.a.bc(Y),X);0>se?$&&Y.push(X):$||Y.splice(se,1)},Ba:N,extend:I,setPrototypeOf:_,Ab:N?_:I,P:v,Ga:function(Y,X,$){if(!Y)return Y;var se={},ue;for(ue in Y)O.call(Y,ue)&&(se[ue]=X.call($,Y[ue],ue,Y));return se},Tb:function(Y){for(;Y.firstChild;)p.removeNode(Y.firstChild)},Yb:function(Y){Y=p.a.la(Y);for(var X=(Y[0]&&Y[0].ownerDocument||n).createElement(" div "),$=0,se=Y.length;$<se;$++)X.appendChild(p.oa(Y[$]));return X},Ca:function(Y,X){for(var $=0,se=Y.length,ue=[];$<se;$++){var re=Y[$].cloneNode(!0);ue.push(X?p.oa(re):re)}return ue},va:function(Y,X){if(p.a.Tb(Y),X)for(var $=0,se=X.length;$<se;$++)Y.appendChild(X[$])},Xc:function(Y,X){var $=Y.nodeType?[Y]:Y;if(0<$.length){for(var se=$[0],ue=se.parentNode,re=0,he=X.length;re<he;re++)ue.insertBefore(X[re],se);for(re=0,he=$.length;re<he;re++)p.removeNode($[re])}},Ua:function(Y,X){if(Y.length){for(X=X.nodeType===8&&X.parentNode||X;Y.length&&Y[0].parentNode!==X;)Y.splice(0,1);for(;1<Y.length&&Y[Y.length-1].parentNode!==X;)Y.length--;if(1<Y.length){var $=Y[0],se=Y[Y.length-1];for(Y.length=0;$!==se;)Y.push($),$=$.nextSibling;Y.push(se)}}return Y},Zc:function(Y,X){7>K?Y.setAttribute(" selected ",X):Y.selected=X},Db:function(Y){return Y===null||Y===e?" ":Y.trim?Y.trim():Y.toString().replace(/^[\s\xa0]+|[\s\xa0]+$/g," " ) } , Ud : function ( Y , X ) { return Y = Y ||
, ` ;var G=[],W=k.match(D),K,q=[],te=0;if(1<W.length){for(var Y=0,X;X=W[Y];++Y){var $ =X.charCodeAt(0);if( $ ===44){if(0>=te){G.push(K&&q.length?{key:K,value:q.join("")}:{unknown:K||q.join("")}),K=te=0,q=[];continue}}else if( $ ===58){if(!te&&!K&&q.length===1){K=q.pop();continue}}else{if( $ ===47&&1<X.length&&(X.charCodeAt(1)===47||X.charCodeAt(1)===42))continue; $ ===47&&Y&&1<X.length?( $ =W[Y-1].match(O))&&!N[ $ [0]]&&(k=k.substr(k.indexOf(X)+1),W=k.match(D),Y=-1,X="/"): $ ===40|| $ ===123|| $ ===91?++te: $ ===41|| $ ===125|| $ ===93?--te:K||q.length|| $ !==34&& $ !==39||(X=X.slice(1,-1))}q.push(X)}if(0<te)throw Error("Unbalanced parentheses, braces, or brackets")}return G}var I=["true","false","null","undefined"],_=/^(?:[ $ _a-z][ $ \w ]*|(.+)( \. \s *[ $ _a-z][ $ \w ]*| \[ .+ \] )) $ /i,D=RegExp( ` "(?:\\\\.|[^" ] ) * " | '(?:\\\\.|[^' ] ) * ' | \ ` (?: \\ \\ .|[^ \` ])* \` |/ \\ *(?:[^*]| \\ *+[^*/])* \\ *+/|//.*
| / ( ? : \ \ \ \ . | [ ^ / ] ) + / w * | [ ^ \ \ s : , / ] [ ^ , " ' \ ` { } ( ) / : [ \ \ ] ] * [ ^ \ \ s , " ' \ ` { } ( ) / : [ \ \ ] ] | [ ^ \ \ s ] ` , " g " ) , O = / [ \ ] ) " ' A - Z a - z 0 - 9 _ $ ] + $ / , N = { 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 , G ) { f u n c t i o n W ( $ , s e ) { v a r u e ; i f ( ! Y ) { v a r r e = p . g e t B i n d i n g H a n d l e r ( $ ) ; i f ( r e & & r e . p r e p r o c e s s & & ! ( s e = r e . p r e p r o c e s s ( s e , $ , W ) ) ) r e t u r n ; ( r e = V [ $ ] ) & & ( u e = s e , 0 < = p . a . A ( I , u e ) ? u e = ! 1 : ( r e = u e . m a t c h ( _ ) , 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 [ $ ] = = " s t r i n g " ? V [ $ ] : $ ) + " ' : f u n c t i o n ( _ z ) { " + u e + " = _ z } " ) } t e & & ( s e = " f u n c t i o n ( ) { r e t u r n " + s e + " } " ) , K . p u s h ( " ' " + $ + " ' : " + s e ) } G = G | | { } ; v a r K = [ ] , q = [ ] , t e = G . v a l u e A c c e s s o r s , Y = G . b i n d i n g P a r a m s , X = 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 ( X , f u n c t i o n ( $ ) { W ( $ . k e y | | $ . u n k n o w n , $ . v a l u e ) } ) , q . l e n g t h & & W ( " _ 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 , G ) { f o r ( v a r W = 0 ; W < k . l e n g t h ; W + + ) i f ( k [ W ] . k e y = = G ) 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 , G , W , K , q ) { k & & p . O ( k ) ? ! p . Z a ( k ) | | q & & k . v ( ) = = = K | | k ( K ) : ( k = G . g e t ( " _ k o _ p r o p e r t y _ w r i t e r s " ) ) & & k [ W ] & & k [ W ] ( 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 ( W ) { r e t u r n W . n o d e T y p e = = 8 & & N . t e s t ( O ? W . t e x t : W . n o d e V a l u e ) } f u n c t i o n I ( W ) { r e t u r n W . n o d e T y p e = = 8 & & V . t e s t ( O ? W . t e x t : W . n o d e V a l u e ) } f u n c t i o n _ ( W , K ) { f o r ( v a r q = W , t e = 1 , Y = [ ] ; q = q . n e x t S i b l i n g ; ) { i f ( I ( q ) & & ( p . a . g . s e t ( q , G , ! 0 ) , t e - - , t e = = = 0 ) ) r e t u r n Y ; Y . 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 : " + W . 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 ( W , K ) { v a r q = _ ( W , 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 : W . 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 - - > " , N = 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 } , G = " _ _ 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 ( W ) { r e t u r n v ( W ) ? _ ( W ) : W . c h i l d N o d e s } , E a : f u n c t i o n ( W ) { i f ( v ( W ) ) { W = p . h . c h i l d N o d e s ( W ) ; f o r ( v a r K = 0 , q = W . l e n g t h ; K < q ; K + + ) p . r e m o v e N o d e ( W [ K ] ) } e l s e p . a . T b ( W ) } , v a : f u n c t i o n ( W , K ) { i f ( v ( W ) ) { p . h . E a ( W ) ; f o r ( v a r q = W . n e x t S i b l i n g , t e = 0 , Y = K . l e n g t h ; t e < Y ; 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 ( W , K ) } , V c : f u n c t i o n ( W , K ) { v a r q ; v ( W ) ? ( q = W . n e x t S i b l i n g , W = W . p a r e n t N o d e ) : q = W . f i r s t C h i l d , q ? K ! = = q & & W . i n s e r t B e f o r e ( K , q ) : W . a p p e n d C h i l d ( K ) } , W b : f u n c t i o n ( W , K , q ) { q ? ( q = q . n e x t S i b l i n g , v ( W ) & & ( W = W . p a r e n t N o d e ) , q ? K ! = = q & & W . i n s e r t B e f o r e ( K , q ) : W . a p p e n d C h i l d ( K ) ) : p . h . V c ( W , K ) } , f i r s t C h i l d : f u n c t i o n ( W ) { i f ( v ( W ) ) r e t u r n ! W . n e x t S i b l i n g | | I ( W . n e x t S i b l i n g ) ? n u l l : W . n e x t S i b l i n g ; i f ( W . f i r s t C h i l d & & I ( W . 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 " + W ) ; r e t u r n W . 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 ( W ) { i f ( v ( W ) & & ( W = D ( W ) ) , W . n e x t S i b l i n g & & I ( W . n e x t S i b l i n g ) ) { v a r K = W . n e x t S i b l i n g ; i f ( I ( K ) & & ! p . a . g . g e t ( K , G ) ) 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 " + W ) ; r e t u r n n u l l } r e t u r n W . n e x t S i b l i n g } , C d : v , V d : f u n c t i o n ( W ) { r e t u r n ( W = ( O ? W . t e x t : W . n o d e V a l u e ) . m a t c h ( N ) ) ? W [ 1 ] : n u l l } , S c : f u n c t i o n ( W ) { i f ( k [ p . a . R ( W ) ] ) { v a r K = W . 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 Y = D ( q , ! 0 ) ; Y ? q = Y : 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 , Y = 0 ; Y < q . l e n g t h ; Y + + ) t e ? W . i n s e r t B e f o r e ( q [ Y ] , t e ) : W . a p p e n d C h i l d ( q [ Y ] ) } 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 _ = t h i s . g e t B i n d i n g s S t r i n g ( v , I ) , _ = _ ? t h i s . p a r s e B i n d i n g s S t r i n g ( _ , I , v ) : n u l l ; r e t u r n p . j . t c ( _ , 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 _ = t h i s . g e t B i n d i n g s S t r i n g ( v , I ) , _ = _ ? t h i s . p a r s e B i n d i n
Bindings value : ` +v+ `
Message : ` +W.message,W}}}),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 _(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 N(re,he,ce){return typeof re=="function"?O(re.bind(null,he,ce)):p.a.Ga(re,_)}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,ne=p.ga.instance,fe=ne.preprocessNode;if(fe){for(;Q=ce;)ce=p.h.nextSibling(Q),fe.call(ne,Q);ce=p.h.firstChild(he)}for(;Q=ce;)ce=p.h.nextSibling(Q),G(re,Q)}p.i.ma(he,p.i.H)}function G(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&&! $ [p.a.R(he)]&&k(ce,he)}function W(re){var he=[],ce={},Q=[];return p.a.P(re,function ne(fe){if(!ce[fe]){var _e=p.getBindingHandler(fe);_e&&(_e.after&&(Q.push(fe),p.a.D(_e.after,function(Se){if(re[Se]){if(p.a.A(Q,Se)!==-1)throw Error("Cannot combine the following bindings, because they have a cyclic dependency: "+Q.join(", "));ne(Se)}}),Q.length--),he.push({key:fe,Mc:_e})),ce[fe]=!0}}),he}function K(re,he,ce){var Q=p.a.g.Ub(re,ue,{}),ne=Q.hd;if(!he){if(ne)throw Error("You cannot apply bindings multiple times to the same element.");Q.hd=!0}ne||(Q.context=ce),Q.Zb||(Q.Zb={});var fe;if(he&&typeof he!="function")fe=he;else{var _e=p.ga.instance,Se=_e.getBindingAccessors||V,ve=p. $ (function(){return(fe=he?he(ce,re):Se.call(_e,re,ce))&&(ce[te]&&ce[te](),ce[X]&&ce[X]()),fe},null,{l:re});fe&&ve.ja()||(ve=null)}var Le=ce,Ee;if(fe){var Be=function(){return p.a.Ga(ve?ve():fe,D)},Pe=ve?function(Ae){return function(){return D(ve()[Ae])}}:function(Ae){return fe[Ae]};Be.get=function(Ae){return fe[Ae]&&D(Pe(Ae))},Be.has=function(Ae){return Ae in fe},p.i.H in fe&&p.i.subscribe(re,p.i.H,function(){var Ae=(0,fe[p.i.H])();if(Ae){var xe=p.h.childNodes(re);xe.length&&Ae(xe,p.Ec(xe[0]))}}),p.i.pa in fe&&(Le=p.i.Cb(re,ce),p.i.subscribe(re,p.i.pa,function(){var Ae=(0,fe[p.i.pa])();Ae&&p.h.firstChild(re)&&Ae(re)})),Q=W(fe),p.a.D(Q,function(Ae){var xe=Ae.Mc.init,Oe=Ae.Mc.update,Ve=Ae.key;if(re.nodeType===8&&!p.h.ea[Ve])throw Error("The binding '"+Ve+"' cannot be used with virtual elements");try{typeof xe=="function"&&p.u.G(function(){var Re=xe(re,Pe(Ve),Be,Le. $ data,Le);if(Re&&Re.controlsDescendantBindings){if(Ee!==e)throw Error("Multiple bindings ("+Ee+" and "+Ve+") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.");Ee=Ve}}),typeof Oe=="function"&&p. $ (function(){Oe(re,Pe(Ve),Be,Le. $ data,Le)},null,{l:re})}catch(Re){throw Re.message='Unable to process binding "'+Ve+": "+fe[Ve]+ ` "
Message : ` +Re.message,Re}})}return Q=Ee===e,{shouldBindDescendants:Q,bindingContextForDescendants:Q&&Le}}function q(re,he){return re&&re instanceof p.fa?re:new p.fa(re,e,e,he)}var te=p.a.Da("_subscribable"),Y=p.a.Da("_ancestorBindingInfo"),X=p.a.Da("_dataDependency");p.c={};var $ ={script:!0,textarea:!0,template:!0};p.getBindingHandler=function(re){return p.c[re]};var se={};p.fa=function(re,he,ce,Q,ne){function fe(){var Pe=Le?ve():ve,Ae=p.a.f(Pe);return he?(p.a.extend(_e,he),Y in he&&(_e[Y]=he[Y])):(_e. $ parents=[],_e. $ root=Ae,_e.ko=p),_e[te]=Ee,Se?Ae=_e. $ data:(_e. $ rawData=Pe,_e. $ data=Ae),ce&&(_e[ce]=Ae),Q&&Q(_e,he,Ae),he&&he[te]&&!p.S.o().Vb(he[te])&&he[te](),Be&&(_e[X]=Be),_e. $ data}var _e=this,Se=re===se,ve=Se?e:re,Le=typeof ve=="function"&&!p.O(ve),Ee,Be=ne&&ne.dataDependency;ne&&ne.exportDependencies?fe():(Ee=p.xb(fe),Ee.v(),Ee.ja()?Ee.equalityComparer=null:_e[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 ne=typeof re=="function"&&!p.O(re);return new p.fa(se,this,null,function(fe){ce&&ce(fe),fe[he]=ne?re():re},Q)}return new p.fa(re,this,he,function(fe,_e){fe. $ parentContext=_e,fe. $ parent=_e. $ data,fe. $ parents=(_e. $ parents||[]).slice(0),fe. $ parents.unshift(fe. $ parent),ce&&ce(fe)},Q)},p.fa.prototype.extend=function(re,he){return new p.fa(se,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,ne){var fe=p.a.g.Ub(re,ue,{});return fe.Fa||(fe.Fa=new p.T),ne&&ne.notifyImmediately&&fe.Zb[he]&&p.u.G(ce,Q,[re]),fe.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[Y])),he[Y]==ce?he:he.extend(function(Q){Q[Y]=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,N(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");G(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 G=Object.prototype.hasOwnProperty.call(O,V)?O[V]:v,W;G?G.subscribe(k):(G=O[V]=new p.T,G.subscribe(k),_(V,function(K,q){var te=!(!q||!q.synchronous);N[V]={definition:K,Gd:te},delete O[V],W||te?G.notifySubscribers(K):p.na.zb(function(){G.notifySubscribers(K)})}),W=!0)}function _(V,k){D("getConfig",[V],function(G){G?D("loadComponent",[V,G],function(W){k(W,G)}):k(null,null)})}function D(V,k,G,W){W||(W=p.j.loaders.slice(0));var K=W.shift();if(K){var q=K[V];if(q){var te=!1;if(q.apply(K,k.concat(function(Y){te?G(null):Y!==null?G(Y):D(V,k,G,W)}))!==v&&(te=!0,!K.suppressLoaderExceptions))throw Error("Component loader
2023-02-06 08:55:59 +00:00
* @ license
* Knockout ES5 plugin - https : //github.com/SteveSanderson/knockout-es5
* Copyright ( c ) Steve Sanderson
* MIT license
2023-02-13 02:05:23 +00:00
* /var GR="__knockoutObservables",WR="__knockoutSubscribable";function zte(e,t){if(!e)throw new Error("When calling ko.track, you must pass an object as the first parameter.");var n=this,i=Ute(e,!0);return t=t||Object.getOwnPropertyNames(e),t.forEach(function(o){if(!(o===GR||o===WR)&&!(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&&plt(n,a)}}),e}function Ute(e,t){var n=e[GR];return!n&&t&&(n={},Object.defineProperty(e,GR,{value:n})),n}function hlt(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),zte.call(i,e,[t]),e}function plt(e,t){var n=null;e.computed(function(){n&&(n.dispose(),n=null);var i=t();i instanceof Array&&(n=mlt(e,t,i))})}function mlt(e,t,n){var i=_lt(e,n);return i.subscribe(t)}function _lt(e,t){var n=t[WR];if(!n){n=new e.subscribable,Object.defineProperty(t,WR,{value:n});var i={};glt(t,n,i),ylt(e,t,n,i)}return n}function glt(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 ylt(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 Hte(e,t){if(!e)return null;var n=Ute(e,!1);return n&&n[t]||null}function Alt(e,t){var n=Hte(e,t);n&&n.valueHasMutated()}function blt(e){e.track=zte,e.getObservable=Hte,e.valueHasMutated=Alt,e.defineProperty=hlt}const Clt={attachToKo:blt},j8="http:/ / www . w3 . org / 2000 / svg ",q8=" cesium - svgPath - svg ",Tlt={register:function(e){e.bindingHandlers.cesiumSvgPath={init:function(t,n){const i=document.createElementNS(j8," svg : svg ");i.setAttribute(" class ",q8);const o=document.createElementNS(j8," 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 " , ` ${ q8 } ${ e . unwrap ( r . css ) } ` ) } , disposeWhenNodeIsRemoved : t } ) , { controlsDescendantBindings : ! 0 } } } , e . virtualElements . allowedBindings . cesiumSvgPath = ! 0 } } , Elt = Tlt ; Clt . attachToKo ( nt ) ; Elt . register ( nt ) ; function kT ( e ) { l ( e ) || ( e = new sT ) , this . _clock = e , this . _eventHelper = new Bf , this . _eventHelper . add ( e . onTick , this . synchronize , this ) , this . systemTime = nt . observable ( ie . now ( ) ) , this . systemTime . equalityComparer = ie . equals , this . startTime = nt . observable ( e . startTime ) , this . startTime . equalityComparer = ie . equals , this . startTime . subscribe ( function ( t ) { e . startTime = t , this . synchronize ( ) } , this ) , this . stopTime = nt . observable ( e . stopTime ) , this . stopTime . equalityComparer = ie . equals , this . stopTime . subscribe ( function ( t ) { e . stopTime = t , this . synchronize ( ) } , this ) , this . currentTime = nt . observable ( e . currentTime ) , this . currentTime . equalityComparer = ie . equals , this . currentTime . subscribe ( function ( t ) { e . currentTime = t , this . synchronize ( ) } , this ) , this . multiplier = nt . observable ( e . multiplier ) , this . multiplier . subscribe ( function ( t ) { e . multiplier = t , this . synchronize ( ) } , this ) , this . clockStep = nt . observable ( e . clockStep ) , this . clockStep . subscribe ( function ( t ) { e . clockStep = t , this . synchronize ( ) } , this ) , this . clockRange = nt . observable ( e . clockRange ) , this . clockRange . subscribe ( function ( t ) { e . clockRange = t , this . synchronize ( ) } , this ) , this . canAnimate = nt . observable ( e . canAnimate ) , this . canAnimate . subscribe ( function ( t ) { e . canAni
$ { p } ` :l(g)?g:p}),this.buttonImageUrl=void 0,nt.defineProperty(this,"buttonImageUrl",function(){const h=this.selectedImagery;if(l(h))return h.iconUrl}),this.selectedImagery=void 0;const c=nt.observable();this._currentImageryProviders=[],nt.defineProperty(this,"selectedImagery",{get:function(){return c()},set:function(h){if(c()===h){this.dropDownVisible=!1;return}let m;const g=this._currentImageryProviders,p=g.length,y=this._globe.imageryLayers;let b=!1;for(m=0;m<p;m++){const C=y.length;for(let E=0;E<C;E++){const w=y.get(E);if(w.imageryProvider===g[m]){y.remove(w),b=!0;break}}}if(l(h)){const C=h.creationCommand();if(Array.isArray(C)){const E=C.length;for(m=E-1;m>=0;m--)y.addImageryProvider(C[m],0);this._currentImageryProviders=C.slice(0)}else if(this._currentImageryProviders=[C],b)y.addImageryProvider(C,0);else{const E=y.get(0);l(E)&&y.remove(E),y.addImageryProvider(C,0)}}c(h),this.dropDownVisible=!1}}),this.selectedTerrain=void 0;const u=nt.observable();nt.defineProperty(this,"selectedTerrain",{get:function(){return u()},set:function(h){if(u()===h){this.dropDownVisible=!1;return}let m;l(h)&&(m=h.creationCommand()),this._globe.depthTestAgainstTerrain=!(m instanceof $ p),this._globe.terrainProvider=m,u(h),this.dropDownVisible=!1}});const f=this;this._toggleDropDown=sr(function(){f.dropDownVisible=!f.dropDownVisible}),this.selectedImagery=A(e.selectedImageryProviderViewModel,n[0]),this.selectedTerrain=A(e.selectedTerrainProviderViewModel,i[0])}Object.defineProperties(Gte.prototype,{toggleDropDown:{get:function(){return this._toggleDropDown}},globe:{get:function(){return this._globe}}});function YD(e,t){if(!l(e))throw new x("container is required.");e=Ar(e);const n=new Gte(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 m=document.createElement("img");m.className="cesium-baseLayerPicker-itemIcon",m.setAttribute("data-bind","attr: { src: iconUrl }"),m.setAttribute("draggable","false"),h.appendChild(m);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 y=document.createElement("div");y.className="cesium-baseLayerPicker-section",y.setAttribute("data-bind","foreach: _terrainProviders")
http : //www.esri.com`,category:"Other",creationFunction:function(){return new ap({url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",enablePickFeatures:!1})}})),e.push(new ks({name:"ESRI World Street Map",iconUrl:_n("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 ap({url:"https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",enablePickFeatures:!1})}})),e.push(new ks({name:"ESRI National Geographic",iconUrl:_n("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 ap({url:"https://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/",enablePickFeatures:!1})}})),e.push(new ks({name:"Open Street Map",iconUrl:_n("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 Wy({url:"https://a.tile.openstreetmap.org/"})}})),e.push(new ks({name:"Stamen Watercolor",iconUrl:_n("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 Wy({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 ks({name:"Stamen Toner",iconUrl:_n("Widgets/Images/ImageryProviders/stamenToner.png"),tooltip:`A high contrast black and white map.
http : //maps.stamen.com`,category:"Other",creationFunction:function(){return new Wy({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 ks({name:"Sentinel-2",iconUrl:_n("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 Ql({assetId:3954})}})),e.push(new ks({name:"Blue Marble",iconUrl:_n("Widgets/Images/ImageryProviders/blueMarble.png"),tooltip:"Blue Marble Next Generation July, 2004 imagery from NASA.",category:"Cesium ion",creationFunction:function(){return new Ql({assetId:3845})}})),e.push(new ks({name:"Earth at night",iconUrl:_n("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 Ql({assetId:3812})}})),e.push(new ks({name:"Natural Earth II",iconUrl:_n("Widgets/Images/ImageryProviders/naturalEarthII.png"),tooltip:`Natural Earth II, darkened for contrast.
http : //www.naturalearthdata.com/`,category:"Cesium ion",creationFunction:function(){return new hd({url:_n("Assets/Textures/NaturalEarthII")})}})),e}function Blt(){const e=[];return e.push(new ks({name:"WGS84 Ellipsoid",iconUrl:_n("Widgets/Images/TerrainProviders/Ellipsoid.png"),tooltip:"WGS84 standard ellipsoid, also known as EPSG:4326",category:"Cesium ion",creationFunction:function(){return new $p}})),e.push(new ks({name:"Cesium World Terrain",iconUrl:_n("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 Sst({requestWaterMask:!0,requestVertexNormals:!0})}})),e}function XD(e,t){l(t)||(t=document.body),t=Ar(t);const n=this,i=nt.observable(is.fullscreen),o=nt.observable(is.enabled),r=t.ownerDocument;this.isFullscreen=void 0,nt.defineProperty(this,"isFullscreen",{get:function(){return i()}}),this.isFullscreenEnabled=void 0,nt.defineProperty(this,"isFullscreenEnabled",{get:function(){return o()},set:function(s){o(s&&is.enabled)}}),this.tooltip=void 0,nt.defineProperty(this,"tooltip",function(){return this.isFullscreenEnabled?i()?"Exit full screen":"Full screen":"Full screen unavailable"}),this._command=sr(function(){is.fullscreen?is.exitFullscreen():is.requestFullscreen(n._fullscreenElement)},nt.getObservable(this,"isFullscreenEnabled")),this._fullscreenElement=A(Ar(e),r.body),this._callback=function(){i(is.fullscreen)},r.addEventListener(is.changeEventName,this._callback)}Object.defineProperties(XD.prototype,{fullscreenElement:{get:function(){return this._fullscreenElement},set:function(e){if(!(e instanceof Element))throw new x("value must be a valid Element.");this._fullscreenElement=e}},command:{get:function(){return this._command}}});XD.prototype.isDestroyed=function(){return!1};XD.prototype.destroy=function(){document.removeEventListener(is.changeEventName,this._callback),He(this)};const Rlt="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",Nlt="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 KD(e,t){if(!l(e))throw new x("container is required.");e=Ar(e);const n=new XD(t,e);n._exitFullScreenPath=Nlt,n._enterFullScreenPath=Rlt;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),nt.applyBindings(n,i),this._container=e,this._viewModel=n,this._element=i}Object.defineProperties(KD.prototype,{con
2023-02-06 08:55:59 +00:00
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.
2023-02-13 02:05:23 +00:00
` ),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(){dL()?(this._wakeLock&&this._wakeLock.release(),this._wakeLock=null):fL()?this.noSleepTimer&&(console.warn( `
2023-02-06 08:55:59 +00:00
NoSleep now disabled for older iOS devices .
2023-02-13 02:05:23 +00:00
` ),window.clearInterval(this.noSleepTimer),this.noSleepTimer=null):this.noSleepVideo.pause(),this.enabled=!1}}var fut=uut;function dut(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 Xte(){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 hut(e,t,n,i){i()||(n()?(t.useWebVR=!1,e._locked&&(Xte(),e._locked=!1),e._noSleep.disable(),is.exitFullscreen(),n(!1)):(is.fullscreen||is.requestFullscreen(e._vrElement),e._noSleep.enable(),e._locked||(e._locked=dut("landscape")),t.useWebVR=!0,n(!0)))}function sI(e,t){if(!l(e))throw new x("scene is required.");const n=this,i=nt.observable(is.enabled),o=nt.observable(!1);this.isVRMode=void 0,nt.defineProperty(this,"isVRMode",{get:function(){return o()}}),this.isVREnabled=void 0,nt.defineProperty(this,"isVREnabled",{get:function(){return i()},set:function(s){i(s&&is.enabled)}}),this.tooltip=void 0,nt.defineProperty(this,"tooltip",function(){return i()?o()?"Exit VR mode":"Enter VR mode":"VR mode is unavailable"});const r=nt.observable(!1);this._isOrthographic=void 0,nt.defineProperty(this,"_isOrthographic",{get:function(){return r()}}),this._eventHelper=new Bf,this._eventHelper.add(e.preRender,function(){r(e.camera.frustum instanceof Vt)}),this._locked=!1,this._noSleep=new fut,this._command=sr(function(){hut(n,e,o,r)},nt.getObservable(this,"isVREnabled")),this._vrElement=A(Ar(t),document.body),this._callback=function(){!is.fullscreen&&o()&&(e.useWebVR=!1,n._locked&&(Xte(),n._locked=!1),n._noSleep.disable(),o(!1))},document.addEventListener(is.changeEventName,this._callback)}Object.defineProperties(sI.prototype,{vrElement:{get:function(){return this._vrElement},set:function(e){if(!(e instanceof Element))throw new x("value must be a valid Element.");this._vrElement=e}},command:{get:function(){return this._command}}});sI.prototype.isDestroyed=function(){return!1};sI.prototype.destroy=function(){this._eventHelper.removeAll(),document.removeEventListener(is.changeEventName,this._callback),He(this)};const put="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",mut="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
` ).forEach(function(s){o=s.indexOf(":"),n=s.substring(0,o).trim().toLowerCase(),i=s.substring(o+1).trim(),!(!n||t[n]&&mft[n])&&(n==="set-cookie"?t[n]?t[n].push(i):t[n]=[i]:t[n]=t[n]?t[n]+", "+i:i)}),t},o6=Symbol("internals");function XA(e){return e&&String(e).trim().toLowerCase()}function aS(e){return e===!1||e==null?e:je.isArray(e)?e.map(aS):String(e)}function gft(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 yft(e){return/^[-_a-zA-Z]+ $ /.test(e.trim())}function r6(e,t,n,i){if(je.isFunction(i))return i.call(this,t,n);if(je.isString(t)){if(je.isString(i))return t.indexOf(i)!==-1;if(je.isRegExp(i))return i.test(t)}}function Aft(e){return e.trim().toLowerCase().replace(/([a-z \d ])( \w *)/g,(t,n,i)=>n.toUpperCase()+i)}function bft(e,t){const n=je.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 fI{constructor(t){t&&this.set(t)}set(t,n,i){const o=this;function r(a,c,u){const f=XA(c);if(!f)throw new Error("header name must be a non-empty string");const h=je.findKey(o,f);(!h||o[h]===void 0||u===!0||u===void 0&&o[h]!==!1)&&(o[h||c]=aS(a))}const s=(a,c)=>je.forEach(a,(u,f)=>r(u,f,c));return je.isPlainObject(t)||t instanceof this.constructor?s(t,n):je.isString(t)&&(t=t.trim())&&!yft(t)?s(_ft(t),n):t!=null&&r(n,t,i),this}get(t,n){if(t=XA(t),t){const i=je.findKey(this,t);if(i){const o=this[i];if(!n)return o;if(n===!0)return gft(o);if(je.isFunction(n))return n.call(this,o,i);if(je.isRegExp(n))return n.exec(o);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=XA(t),t){const i=je.findKey(this,t);return!!(i&&(!n||r6(this,this[i],i,n)))}return!1}delete(t,n){const i=this;let o=!1;function r(s){if(s=XA(s),s){const a=je.findKey(i,s);a&&(!n||r6(i,i[a],a,n))&&(delete i[a],o=!0)}}return je.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 je.forEach(this,(o,r)=>{const s=je.findKey(i,r);if(s){n[s]=aS(o),delete n[r];return}const a=t?Aft(r):String(r).trim();a!==r&&delete n[r],n[a]=aS(o),i[a]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return je.forEach(this,(i,o)=>{i!=null&&i!==!1&&(n[o]=t&&je.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[o6]=this[o6]={accessors:{}}).accessors,o=this.prototype;function r(s){const a=XA(s);i[a]||(bft(o,s),i[a]=!0)}return je.isArray(t)?t.forEach(r):r(t),this}}fI.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]);je.freezeMethods(fI.prototype);je.freezeMethods(fI);const xd=fI;function hL(e,t){const n=this||DF,i=t||n,o=xd.from(i.headers);let r=i.data;return je.forEach(e,function(a){r=a.call(n,r,o.normalize(),t?t.status:void 0)}),o.normalize(),r}function pne(e){return!!(e&&e.__CANCEL__)}function jT(e,t,n){wi.call(this,e??"canceled",wi.ERR_CANCELED,t,n),this.name="CanceledError"}je.inherits(jT,wi,{__CANCEL__:!0});const Cft=null;function Tft(e,t,n){const i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):t(new wi("Request failed with status code "+n.status,[wi.ERR_BAD_REQUEST,wi.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const Eft=Qu.isStandardBrowserEnv?function(){return{write:function(n,i,o,r,s,a){const c=[];c.push(n+"="+encodeURIComponent(i)),je.isNumber(o)&&c.push("expires="+new Date(o).toGMTString()),je.isString(r)&&c.push("path="+r),je.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 xft(e){return/^([a-z][a-z \d + \- .]*:)? \/ \/ /i.test(e)}function wft(e,t){return t?e.replace(/ \/ + $ /,"")+"/"+t.replace(/^ \/ +/,""):e}function mne(e,t){return e&&!xft(t)?wft(e,t):t}const Sft=Qu.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=je.isString(s)?o(s):s;return a.protocol===i.protocol&&a.host===i.host}}():function(){return function(){return!0}}();function vft(e){const t=/^([-+ \w ]{1,25})(:? \/ \/ |:)/.exec(e);return t&&t[1]||""}function Dft(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,m=0;for(;h!==o;)m+=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(m*1e3/g):void 0}}function s6(e,t){let n=0;const i=Dft(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 Ift=typeof XMLHttpRequest<"u",Pft=Ift&&function(e){return new Promise(function(n,i){let o=e.data;const r=xd.from(e.headers).normalize(),s=e.responseType;let a;function c(){e.cancelToken&&e.cancelToken.unsubscribe(a),e.signal&&e.signal.removeEventListener("abort",a)}je.isFormData(o)&&(Qu.isStandardBrowserEnv||Qu.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=mne(e.baseURL,e.url);u.open(e.method.toUpperCase(),fne(f,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function h(){if(!u)return;const g=xd.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),y={data:!s||s==="text"||s==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:g,config:e,request:u};Tft(function(C){n(
2023-02-06 08:55:59 +00:00
* satellite - js v4 . 1.4
* ( c ) 2013 Shashwat Kandadai and UCSC
* https : //github.com/shashwatak/satellite-js
* License : MIT
2023-02-13 02:05:23 +00:00
* / v a r F d = M a t h . P I , l r = F d * 2 , g b = F d / 1 8 0 , H f t = 1 4 4 0 , V f t = 3 9 8 6 0 0 . 5 , o c = 6 3 7 8 . 1 3 7 , c d = 6 0 / M a t h . s q r t ( o c * o c * o c / V f t ) , m L = o c * c d / 6 0 , k f t = 1 / c d , e _ = . 0 0 1 0 8 2 6 2 9 9 8 9 0 5 , G f t = - 2 5 3 2 1 5 3 0 6 e - 1 4 , W f t = - 1 6 1 0 9 8 7 6 1 e - 1 4 , t _ = G f t / e _ , q C = 2 / 3 ; f u n c t i o n j f 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 u 6 ( 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 O F ( 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 u 6 ( 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 u 6 ( e , t , n , i , o , r , s ) } f u n c t i o n y n e ( 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 , m = e . s g h 3 , g = e . s g h 4 , p = e . s h 2 , y = e . s h 3 , b = e . s i 2 , C = e . s i 3 , E = e . s l 2 , w = e . s l 3 , S = e . s l 4 , P = e . t , L = e . x g h 2 , z = e . x g h 3 , R = e . x g h 4 , F = e . x h 2 , U = e . x h 3 , v = e . x i 2 , I = e . x i 3 , _ = e . x l 2 , D = e . x l 3 , O = e . x l 4 , N = e . z m o l , V = e . z m o s , k = t . i n i t , G = t . o p s m o d e , W = 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 , Y = t . m p , X , $ , s e , u e , r e , h e , c e , Q , n e , f e , _ e , S e , v e , L e , E e , B e , P e , A e , x e , O e , V e , R e = 1 1 9 4 5 9 e - 1 0 , A t = . 0 1 6 7 5 , x t = . 0 0 0 1 5 8 3 5 2 1 8 , N t = . 0 5 4 9 ; V e = V + R e * P , k = = = " y " & & ( V e = V ) , O e = V e + 2 * A t * M a t h . s i n ( V e ) , P e = M a t h . s i n ( O e ) , f e = . 5 * P e * P e - . 2 5 , _ e = - . 5 * P e * M a t h . c o s ( O e ) ; v a r I n = u * f e + f * _ e , B n = b * f e + C * _ e , E n = E * f e + w * _ e + S * P e , c n = h * f e + m * _ e + g * P e , U t = p * f e + y * _ e ; V e = N + x t * P , k = = = " y " & & ( V e = N ) , O e = V e + 2 * N t * M a t h . s i n ( V e ) , P e = M a t h . s i n ( O e ) , f e = . 5 * P e * P e - . 2 5 , _ e = - . 5 * P e * M a t h . c o s ( O e ) ; v a r x n = i * f e + n * _ e , v n = v * f e + I * _ e , W t = _ * f e + D * _ e + O * P e , e n = L * f e + z * _ e + R * P e , W n = F * f e + U * _ e ; r e t u r n S e = I n + x n , E e = B n + v n , B e = E n + W t , v e = c n + e n , L e = U t + W n , k = = = " n " & & ( S e - = o , E e - = a , B e - = c , v e - = r , L e - = s , K + = E e , W + = S e , u e = M a t h . s i n ( K ) , s e = M a t h . c o s ( K ) , K > = . 2 ? ( L e / = u e , v e - = s e * L e , t e + = v e , q + = L e , Y + = B e ) : ( h e = M a t h . s i n ( q ) , r e = M a t h . c o s ( q ) , X = u e * h e , $ = u e * r e , c e = L e * r e + E e * s e * h e , Q = - L e * h e + E e * s e * r e , X + = c e , $ + = Q , q % = l r , q < 0 & & G = = = " a " & & ( q + = l r ) , A e = Y + t e + s e * q , n e = B e + v e - E e * q * u e , A e + = n e , x e = q , q = M a t h . a t a n 2 ( X , $ ) , q < 0 & & G = = = " a " & & ( q + = l r ) , M a t h . a b s ( x e - q ) > F d & & ( q < x e ? q + = l r : q - = l r ) , Y + = B e , t e = A e - Y - s e * q ) ) , { e p : W , i n c l p : K , n o d e p : q , a r g p p : t e , m p : Y } } f u n c t i o n q f 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 , m , g , p , y , b , C , E , w , S , P , L , z , R , F , U , v , I , _ , D , O , N , V , k , G , W , K , q , t e , Y , X , $ , s e , u e , r e , h e , c e , Q , n e , f e , _ e , S e , v e , L e , E e , B e , P e , A e , x e , O e , V e , R e , A t , x t , N t , I n , B n , E n , c n , U t , x n = . 0 1 6 7 5 , v n = . 0 5 4 9 , W t = 2 9 8 6 4 7 9 7 e - 1 3 , e n = 4 7 9 6 8 0 6 5 e - 1 4 , W n = . 3 9 7 8 5 4 1 6 , d i = . 9 1 7 4 4 8 6 7 , r n = . 1 9 4 5 9 0 5 , z i = - . 9 8 0 8 8 4 5 8 , i o = a , W i = n , a i = M a t h . s i n ( s ) , d n = M a t h . c o s ( s ) , X n = M a t h . s i n ( i ) , U n = M a t h . c o s ( i ) , l n = M a t h . s i n ( r ) , b t = M a t h . c o s ( r ) , G e = W i * W i , R n = 1 - G e , A n = M a t h . s q r t ( R n ) , Q i = 0 , N n = 0 , j i = 0 , O o = 0 , h o = 0 , z r = t + 1 8 2 6 1 . 5 + o / 1 4 4 0 , Z i = ( 4 . 5 2 3 6 0 2 - . 0 0 0 9 2 4 2 2 0 2 9 * z r ) % l r , q i = M a t h . s i n ( Z i ) , U r = M a t h . c o s ( Z i ) , g a = . 9 1 3 7 5 1 6 4 - . 0 3 5 6 8 0 9 6 * U r , C t = M a t h . s q r t ( 1 - g a * g a ) , w e = . 0 8 9 6 8 3 5 1 1 * q i / C t , q e = M a t h . s q r t ( 1 - w e * w e ) , o t = 5 . 8 3 5 1 5 1 4 + . 0 0 1 9 4 4 3 6 8 * z r , K n = . 3 9 7 8 5 4 1 6 * q i / C t , Q r = q e * U r + . 9 1 7 4 4 8 6 7 * w e * q i ; K n = M a t h . a t a n 2 ( K n , Q r ) , K n + = o t - Z i ; v a r x r = M a t h . c o s ( K n ) , m r = M a t h . s i n ( K n ) ; v = r n , I = z i , O = d i , N = W n , _ = d n , D = a i , E = W t ; f o r ( v a r c h = 1 / i o , L o = 0 ; L o < 2 ; ) L o + = 1 , c = v * _ + I * O * D , f = - I * _ + v * O * D , p = - v * D + I * O * _ , y = I * N , b = I * D + v * O * _ , C = v * N , u = b t * p + l n * y , h = b t * b + l n * C , m = - l n * p + b t * y , g = - l n * b + b t * C , w = c * U n + u * X n , S = f * U n + h * X n , P = - c * X n + u * U n , L = - f * X n + h * U n , z = m * X n , R = g * X n , F = m * U n , U = g * U n , E n = 1 2 * w * w - 3 * P * P , c n = 2 4 * w * S - 6 * P * L , U t = 1 2 * S * S - 3 * L * L , x e = 3 * ( c * c + u * u ) + E n * G e , O e = 6 * ( c * f + u * h ) + c n * G e , V e = 3 * ( f * f + h * h ) + U t * G e , R e = - 6 * c * m + G e * ( - 2 4 * w * F - 6 * P * z ) , A t = - 6 * ( c * g + f * m ) + G e * ( - 2 4 * ( S * F + w * U ) + - 6 * ( P * R + L * z ) ) , x t = - 6 * f * g + G e * ( - 2 4 * S * U - 6 * L * R ) , N t = 6 * u * m + G e * ( 2 4 * w * z - 6 * P * F ) , I n = 6 * ( h * m + u * g ) + G e * ( 2 4 * ( S * z + w * R ) - 6 * ( L * F + P * U ) ) , B n = 6 * h * g + G e * ( 2 4 * S * R - 6 * L * U ) , x e = x e + x e + R n * E n , O e = O e + O e + R n * c n , V e = V e + V e + R n * U t , L e = E * c h , v e = - . 5 * L e / A n , E e = L e * A n , S e = - 1 5 * W i * E e , B e = w * P + S * L , P e = S * P + w * L , A e = S * L - w * P , L o = = = 1 & & ( V = S e , k = v e , G = L e , W = E e , K = B e , q = P e , t e = A e , Y = x e , X = O e , $ = V e , s e = R e , u e = A t , r e = x t , h e = N t , c e = I n , Q = B n , n e = E n , f e = c n , _ e = U t , v = x r , I = m r , O = g a , N = C t , _ = q e * d n + w e * a i , D = a i * q e - d n * w e , E = e n ) ; v a r N f = ( 4 . 7 1 9 9 6 7 2 + ( . 2 2 9 9 7 1 5 * z r - o t ) ) % l r , h g = ( 6 . 2 5 6 5 8 3 7 + . 0 1 7 2 0 1 9 7 7 * z r ) % l r , q T = 2 * V * q , o m = 2 * V * t e , r m = 2 * k * u e , d I = 2 * k * ( r e - s e ) , h I = - 2 * G * X , p I = - 2 * G * ( $ - Y ) , m I = - 2 * G * ( - 2 1 - 9 * G e ) * x n , p g = 2 * W * f e , _ I = 2 * W * ( _ e - n e ) , g I = - 1 8 * W * x n , j 0 = - 2 * k * c e , $ T = - 2 * k * ( Q - h e ) , q 0 = 2 * S e * P e , y I = 2 * S
In order to be iterable , non - array objects must have a [ Symbol . iterator ] ( ) method . ` )}function odt(){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=OF.apply(void 0,Zft(o)),s=(r-i.jdsatepoch)*Hft;return Ane(i,s)}class d6{constructor(t="",n={}){const[i,o,r]=this._checkTle(t);let s=r.slice(52,64);this.name=i.trim(),this.tleLine1=o.trim(),this.tleLine2=r.trim(),this.satrec=Qft(this.tleLine1,this.tleLine2),this.totalSeconds=86400,this.stepSeconds=100,this.leadTime=parseInt(24*3600/s),this.trailTime=0}_checkTle(t){let n=t.split( `
` );if(n.length!==3)throw new Error("tle data error");return n}getPositionEci(t){return odt(this.satrec,t).position}_getPositionProperty(){const t=ie.fromIso8601(new Date().toISOString()),n=new Sc(la.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);if(!s)continue;const a=ie.addSeconds(t,o*this.stepSeconds,new ie),c={x:s.x*1e3,y:s.y*1e3,z:s.z*1e3};n.addSample(a,c)}return n}createSatelliteEntity(){const t=ie.fromIso8601(new Date().toISOString()),n=ie.addSeconds(t,this.totalSeconds,new ie);return{name:this.name,description:this.name,availability:new Po([new on({start:t,stop:n})]),position:this._getPositionProperty(),point:{pixelSize:8,color:H.fromRandom({alpha:1})},path:new f0({width:1,show:!1,leadTime:this.leadTime,trailTime:this.trailTime,material:H.LIME}),label:{text:this.name,font:"12px sans-serif",showBackground:!0,backgroundColor:new H(.165,.165,.165,.5),backgroundPadding:new j(4,4),outlineWidth:1,verticalOrigin:Hi.TOP,horizontalOrigin:Hi.LEFT,pixelOffset:new j(0,5),fillColor:H.WHITE,distanceDisplayCondition:new Gt(10,5e6)}}}}let rdt=[{label:"特殊卫星",value:null,group:null,type:"title"},{label:"Last 30 Days' Launches",value:1,group:"last-30-days"},{label:"Space Stations",value:2,group:"stations"},{label:"100 (or so) Brightest",value:3,group:"visual"},{label:"Active Satellites",value:4,group:"active"},{label:"Analyst Satellites ",value:5,group:"analyst"}],sdt=[{label:"气象和地球资源卫星",value:null,group:null,type:"title"},{label:"Weather",value:6,group:"weather"},{label:"NOAA",value:7,group:"noaa"},{label:"GOES",value:8,group:"goes"},{label:"Earth Resources",value:9,group:"resource"},{label:"Search & Rescue (SARSAT) ",value:10,group:"sarsat"},{label:"Disaster Monitoring",value:11,group:"dmc"},{label:"TDRSS",value:12,group:"tdrss"},{label:"ARGOS Data Collection System",value:13,group:"argos"},{label:"Planet",value:14,group:"planet"},{label:"Spire",value:15,group:"spire"}],adt=[{label:"通讯卫星",value:null,group:null,type:"title"},{label:"Active Geosynchronous",value:16,group:"geo"},{label:"GEO Protected Zone",value:17,group:"gpz"},{label:"GEO Protected Zone Plus",value:18,group:"gpz-plus"},{label:"Intelsat",value:19,group:"intelsat"},{label:"SES",value:20,group:"ses"},{label:"Iridium",value:21,group:"iridium"},{label:"Iridium NEXT",value:22,group:"iridium-NEXT"},{label:"Starlink",value:23,group:"starlink"},{label:"OneWeb",value:24,group:"oneweb"},{label:"Orbcomm",value:25,group:"orbcomm"},{label:"Globalstar",value:26,group:"globalstar"},{label:"Swarm",value:27,group:"swarm"},{label:"Amateur Radio",value:28,group:"amateur"},{label:"Experimental Comm",value:29,group:"x-comm"},{label:"Other Comm",value:30,group:"other-comm"},{label:"SatNOGS",value:31,group:"satnogs"},{label:"Gorizont",value:32,group:"gorizont"},{label:"Raduga",value:33,group:"raduga"},{label:"Molniya",value:34,group:"molniya"}],cdt=[{label:"导航卫星",value:null,group:null,type:"title"},{label:"GNSS",value:35,group:"gnss"},{label:"GPS Operational",value:36,group:"gps-ops"},{label:"GLONASS Operational",value:37,group:"glo-ops"},{label:"Galileo",value:38,group:"galileo"},{label:"Beidou",value:39,group:"beidou"},{label:"Satellite-Based Augmentation System",value:40,group:"sbas"},{label:"Navy Navigation Satellite System (NNSS)",value:41,group:"nnss"},{label:"Russian LEO Navigation",value:42,group:"musson"}],ldt=[{label:"科学卫星",value:null,group:null,type:"title"},{label:"Space & Earth Science",value:43,group:"science"},{label:"Geodetic",value:44,group:"geodetic"},{label:"Engineering",value:45,group:"engineering"},{label:"Education",value:46,group:"education"}],udt=[{label:"其他卫星",value:null,group:null,type:"title"},{label:"Miscellaneous Military",value:47,group:"military"},{label:"Radar Calibration",value:48,group:"radar"},{label:"CubeSats",value:49,group:"cubesat"},{label:"Other Satellites",value:50,group:"other"}];const fdt=gn("div",{id:"cesiumContainer"},null,-1),ddt={class:"operate_container"},hdt=gn("img",{src:vme,width:"28"
2023-02-07 08:44:46 +00:00
1 45344 U 20017 A 23037.82027362 - . 00000136 00000 + 0 00000 + 0 0 9994
2 45344 1.9879 4.6761 0000950 328.7503 178.5761 1.00272999 10962
BEIDOU - 3 G3
1 45807 U 20040 A 23037.85365455 - . 00000347 00000 + 0 00000 + 0 0 9999
2023-02-13 02:05:23 +00:00
2 45807 0.9369 314.6571 0008244 342.4957 257.2704 1.00264764 9772 ` );a_.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiYjZmMWM4Ny01YzQ4LTQ3MzUtYTI5Mi1hNTgyNjdhMmFiMmMiLCJpZCI6NjIwMjgsImlhdCI6MTYyNjY3MTMxNX0.5SelYUyzXWRoMyjjFvmFIAoPtWlJPQMjsVl2e_jQe-c";function m(){_a.prototype.makeLabel=function(D){let O=0-new Date().getTimezoneOffset(),N=ie.addMinutes(D,O,new ie);return ie.toIso8601(N).slice(0,19)};let I=new q_({mapId:"mapbox.satellite",accessToken:"pk.eyJ1Ijoiamlhbmd0ZW5nIiwiYSI6ImNqbGhhcDhzMjAxdncza294c2ZqcHFxNGIifQ.rjSmtZ5QzE2sJ-qDANh3WQ"});n=new oi("cesiumContainer",{imageryProvider:I,baseLayerPicker:!1,geocoder:!1,navigationHelpButton:!1,infoBox:!1});let _=0-new Date().getTimezoneOffset();n.animation.viewModel.timeFormatter=function(D,O){let N=ie.addMinutes(D,_,new ie);return ie.toIso8601(N).slice(11,19)},n.animation.viewModel.dateFormatter=function(D,O){let N=ie.addMinutes(D,_,new ie);return ie.toIso8601(N).slice(0,10)},at.DEFAULT_VIEW_RECTANGLE=ge.fromDegrees(75,10,140,60)}function g(){const I=ie.fromIso8601(new Date().toISOString()),_=ie.addSeconds(I,i,new ie);n.clock.startTime=I.clone(),n.clock.stopTime=_.clone(),n.clock.currentTime=I.clone(),n.timeline.zoomTo(I,_),n.clock.multiplier=1,n.clock.shouldAnimate=!0,n.clock.clockRange=cp.LOOP_STOP}function p(I=""){if(I.length===0)return;let _=I.split( ` \ r
` ),D=[],O=0,N=[];return _.forEach(V=>{O++,N.push(V),O===3&&(D.push(N.join( ` \ r
` )),N=[],O=0)}),D}function y(I=""){if(I.length===0)return;let _=I.split( `
` );console.log(_);let D=[],O=0,N=[];return _.forEach(V=>{O++,N.push(V),O===3&&(D.push(N.join( ` \ r
` )),N=[],O=0)}),D}function b(){let I=n.screenSpaceEventHandler.getInputAction(Vn.LEFT_CLICK);n.screenSpaceEventHandler.setInputAction(function(D){I(D);const O=n.scene.pick(D.position);console.log(O),O&&(O.id.path.show=new $ o(!0),O.id.label.distanceDisplayCondition=void 0,u.push(O))},Vn.LEFT_CLICK)}function C(I){}function E(){localStorage.clear(),wb.success("清除成功")}function w(){u.length&&u.forEach(I=>{I.id&&(I.id.path.show=!1)})}function S(I){try{if(!I.length)return!1;let _=I.split( `
` );return _.length%3!==0?!1:(_.forEach((D,O)=>{if(O%3===0&&!D)throw new Error(!1);if(O%3===1&&D.length<69)throw new Error(!1);if(O%3===2&&D.length<69)throw new Error(!1)}),!0)}catch(_){return console.log(_),!1}}function P(){if(!S(h.value)){wb.error("wrong TLE data");return}R(),y(h.value).forEach(_=>{let D=new d6(_),O=D.createSatelliteEntity(),N=n.entities.add(O);r.set(D.name,N)}),n.zoomTo(n.entities)}async function L(I){if(I.raw.type!=="text/plain"){wb.warning("请上传TXT格式的TLE数据");return}let _=await I.raw.text();h.value=_}function z(){R(),h.value="",f.value.clearFiles()}function R(){r.forEach(I=>n.entities.remove(I)),r.clear()}async function F(I){let _=localStorage.getItem(I);return _?(console.log( ` % c 命中缓存 , key值为$ { I } ` ,"color:#0f0;"),_):(console.warn("未命中缓存, 开始下载TLE数据"),await Uft(I))}async function U(I){if(o.has(I))o.get(I).forEach(D=>n.entities.add(D));else{let _=await F(I),D=p(_),O=new Set;D.forEach(N=>{let k=new d6(N).createSatelliteEntity(),G=n.entities.add(k);O.add(G)}),o.set(I,O)}}function v(I){o.has(I)&&o.get(I).forEach(D=>n.entities.remove(D))}return _o(c,(I,_)=>{let D=I.concat(_).filter((N,V,k)=>k.indexOf(N)===k.lastIndexOf(N)),O=t.find(N=>N.value===D[0]);I.length>_.length?U(O.group):v(O.group)}),_u(async()=>{m(),g(),b(),U("last-30-days")}),(I,_)=>{const D=Lhe,O=Npe,N=Qhe,V=Zhe,k=ype,G=Vde,W=hme;return et(),Pt(Jo,null,[fdt,gn("div",ddt,[gn("div",{class:"menu_button",onClick:_[0]||(_[0]=K=>s.value=!s.value),title:"控制面板"},pdt),gn("div",{class:"menu_button",onClick:_[1]||(_[1]=K=>a.value=!a.value),title:"导入"},_dt)]),bn(k,{modelValue:s.value,"onUpdate:modelValue":_[3]||(_[3]=K=>s.value=K),title:"控制面板",direction:"ltr"},{default:wn(()=>[bn(O,{style:{"padding-bottom":"10px"}},{default:wn(()=>[bn(D,{type:"primary",onClick:E},{default:wn(()=>[Hu(" 清除TLE缓存 ")]),_:1}),bn(D,{type:"primary",onClick:w},{default:wn(()=>[Hu(" 清除轨道 ")]),_:1})]),_:1}),bn(V,{modelValue:c.value,"onUpdate:modelValue":_[2]||(_[2]=K=>c.value=K),onChange:C,max:5},{default:wn(()=>[(et(!0),Pt(Jo,null,t9(pe(t),(K,q)=>(et(),Pt(Jo,{key:q},[K.type==="title"?(et(),ti(O,{key:0,class:"satellite_type"},{default:wn(()=>[Hu(va(K.label),1)]),_:2},1024)):Yt("",!0),K.type?Yt("",!0):(et(),ti(N,{key:1,label:K.value},{default:wn(()=>[Hu(va(K.label),1)]),_:2},1032,["label"]))],64))),128))]),_:1},8,["modelValue"])]),_:1},8,["modelValue"]),bn(k,{modelValue:a.value,"onUpdate:modelValue":_[5]||(_[5]=K=>a.value=K),title:"自定义卫星数据",direction:"ltr"},{default:wn(()=>[bn(G,{modelValue:pe(h),"onUpdate:modelValue":_[4]||(_[4]=K=>Uo(h)?h.value=K:h=K),type:"textarea",placeholder:"Please input tle data",rows:20},null,8,["modelValue"]),bn(O,{class:"add_satellite"},{default:wn(()=>[bn(D,{type:"primary",onClick:P},{default:wn(()=>[Hu(" 添加 ")]),_:1}),bn(W,{class:"upload_button","on-change":L,"show-file-list":!1,accept:"txt",limit:1,"auto-upload":!1,ref_key:"upload",ref:f},{trigger:wn(()=>[bn(D,{type:"primary"},{default:wn(()=>[Hu("导入")]),_:1})]),_:1},512),bn(D,{type:"danger",onClick:z},{default:wn(()=>[Hu(" 清空 ")]),_:1})]),_:1})]),_:1},8,["modelValue"])],64)}}},ydt=lse({history:Sre("/satellite-track/"),routes:[{path:"/",name:"home",component:gdt}]}),LF=ore(hse);LF.use(cre());LF.use(ydt);LF.mount("#app")});export default Adt();