/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var g7 = Object . create ; var aa = Object . defineProperty ; var v7 = Object . getOwnPropertyDescriptor ; var x7 = Object . getOwnPropertyNames ; var y7 = Object . getPrototypeOf , w7 = Object . prototype . hasOwnProperty ; var cn = ( a , e ) => ( ) => ( e || a ( ( e = { exports : { } } ) . exports , e ) , e . exports ) , b7 = ( a , e ) => { for ( var t in e ) aa ( a , t , { get : e [ t ] , enumerable : ! 0 } ) } , Jc = ( a , e , t , i ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let n of x7 ( e ) ) ! w7 . call ( a , n ) && n !== t && aa ( a , n , { get : ( ) => e [ n ] , enumerable : ! ( i = v7 ( e , n ) ) || i . enumerable } ) ; return a } ; var Ar = ( a , e , t ) => ( t = a != null ? g7 ( y7 ( a ) ) : { } , Jc ( e || ! a || ! a . _ _esModule ? aa ( t , "default" , { value : a , enumerable : ! 0 } ) : t , a ) ) , M7 = a => Jc ( aa ( { } , "__esModule" , { value : ! 0 } ) , a ) ; var Qc = cn ( oa => { "use strict" ; Object . defineProperty ( oa , "__esModule" , { value : ! 0 } ) ; require ( "obsidian" ) ; var z7 = a => { var e ; return a ? ( e = a . plugins . plugins . dataview ) === null || e === void 0 ? void 0 : e . api : window . DataviewAPI } , C7 = a => a . plugins . enabledPlugins . has ( "dataview" ) ; oa . getAPI = z7 ; oa . isPluginEnabled = C7 } ) ; var R8 = cn ( ( ma , Lr ) => { ( function ( a ) { var e = typeof ma == "object" && ma , t = typeof Lr == "object" && Lr && Lr . exports == e && Lr , i = typeof global == "object" && global ; ( i . global === i || i . window === i ) && ( a = i ) ; var n = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g , r = /[\x01-\x7F]/g , s = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g , o = / < \ u 2 0 D 2 | = \ u 2 0 E 5 | > \ u 2 0 D 2 | \ u 2 0 5 F \ u 2 0 0 A | \ u 2 1 9 D \ u 0 3 3 8 | \ u 2 2 0 2 \ u 0 3 3 8 | \ u 2 2 2 0 \ u 2 0 D 2 | \ u 2 2 2 9 \ u F E 0 0 | \ u 2 2 2 A \ u F E 0 0 | \ u 2 2 3 C \ u 2 0 D 2 | \ u 2 2 3 D \ u 0 3 3 1 | \ u 2 2 3 E \ u 0 3 3 3 | \ u 2 2 4 2 \ u 0 3 3 8 | \ u 2 2 4 B \ u 0 3 3 8 | \ u 2 2 4 D \ u 2 0 D 2 | \ u 2 2 4 E \ u 0 3 3 8 | \ u 2 2 4 F \ u 0 3 3 8 | \ u 2 2 5 0 \ u 0 3 3 8 | \ u 2 2 6 1 \ u 2 0 E 5 | \ u 2 2 6 4 \ u 2 0 D 2 | \ u 2 2 6 5 \ u 2 0 D 2 | \ u 2 2 6 6 \ u 0 3 3 8 | \ u 2 2 6 7 \ u 0 3 3 8 | \ u 2 2 6 8 \ u F E 0 0 | \ u 2 2 6 9 \ u F E 0 0 | \ u 2 2 6 A \ u 0 3 3 8 | \ u 2 2 6 A \ u 2 0 D 2 | \ u 2 2 6 B \ u 0 3 3 8 | \ u 2 2 6 B \ u 2 0 D 2 | \ u 2 2 7 F \ u 0 3 3 8 | \ u 2 2 8 2 \ u 2 0 D 2 | \ u 2 2 8 3 \ u 2 0 D 2 | \ u 2 2 8 A \ u F E 0 0 | \ u 2 2 8 B \ u F E 0 0 | \ u 2 2 8 F \ u 0 3 3 8 | \ u 2 2 9 0 \ u 0 3 3 8 | \ u 2 2 9 3 \ u F E 0 0 | \ u 2 2 9 4 \ u F E 0 0 | \ u 2 2 B 4 \ u 2 0 D 2 | \ u 2 2 B 5 \ u 2 0 D 2 | \ u 2 2 D 8 \ u 0 3 3 8 | \ u 2 2 D 9 \ u 0 3 3 8 | \ u 2 2 D A \ u F E 0 0 | \ u 2 2 D B \ u F E 0 0 | \ u 2 2 F 5 \ u 0 3 3 8 | \ u 2 2 F 9 \ u 0 3 3 8 | \ u 2 9 3 3 \ u 0 3 3 8 | \ u 2 9 C F \ u 0 3 3 8 | \ u 2 9 D 0 \ u 0 3 3 8 | \ u 2 A 6 D \ u 0 3 3 8 | \ u 2 A 7 0 \ u 0 3 3 8 | \ u 2 A 7 D \ u 0 3 3 8 | \ u 2 A 7 E \ u 0 3 3 8 | \ u 2 A A 1 \ u 0 3 3 8 | \ u 2 A A 2 \ u 0 3 3 8 | \ u 2 A A C \ u F E 0 0 | \ u 2 A A D \ u F E 0 0 | \ u 2 A A F \ u 0 3 3 8 | \ u 2 A B 0 \ u 0 3 3 8 | \ u 2 A C 5 \ u 0 3 3 8 | \ u 2 A C 6 \ u 0 3 3 8 | \ u 2 A C B \ u F E 0 0 | \ u 2 A C C \ u F E 0 0 | \ u 2 A F D \ u 2 0 E 5 | [ \ x A 0 - \ u 0 1 1 3 \ u 0 1 1 6 - \ u 0 1 2 2 \ u 0 1 2 4 - \ u 0 1 2 B \ u 0 1 2 E - \ u 0 1 4 D \ u 0 1 5 0 - \ u 0 1 7 E \ u 0 1 9 2 \ u 0 1 B 5 \ u 0 1 F 5 \ u 0 2 3 7 \ u 0 2 C 6 \ u 0 2 C 7 \ u 0 2 D 8 - \ u 0 2 D D \ u 0 3 1 1 \ u 0 3 9 1 - \ u 0 3 A 1 \ u 0 3 A 3 - \ u 0 3 A 9 \ u 0 3 B 1 - \ u 0 3 C 9 \ u 0 3 D 1 \ u 0 3 D 2 \ u 0 3 D 5 \ u 0 3 D 6 \ u 0 3 D C \ u 0 3 D D \ u 0 3 F 0 \ u 0 3 F 1 \ u 0 3 F 5 \ u 0 3 F 6 \ u 0 4 0 1 - \ u 0 4 0 C \ u 0 4 0 E - \ u 0 4 4 F \ u 0 4 5 1 - \ u 0 4 5 C \ u 0 4 5 E \ u 0 4 5 F \ u 2 0 0 2 - \ u 2 0 0 5 \ u 2 0 0 7 - \ u 2 0 1 0 \ u 2 0 1 3 - \ u 2 0 1 6 \ u 2 0 1 8 - \ u 2 0 1 A \ u 2 0 1 C - \ u 2 0 1 E \ u 2 0 2 0 - \ u 2 0 2 2 \ u 2 0 2 5 \ u 2 0 2 6 \ u 2 0 3 0 - \ u 2 0 3 5 \ u 2 0 3 9 \ u 2 0 3 A \ u 2 0 3 E \ u 2 0 4 1 \ u 2 0 4 3 \ u 2 0 4 4 \ u 2 0 4 F \ u 2 0 5 7 \ u 2 0 5 F - \ u 2 0 6 3 \ u 2 0 A C \ u 2 0 D B \ u 2 0 D C \ u 2 1 0 2 \ u 2 1 0 5 \ u 2 1 0 A - \ u 2 1 1 3 \ u 2 1 1 5 - \ u 2 1 1 E \ u 2 1 2 2 \ u 2 1 2 4 \ u 2 1 2 7 - \ u 2 1 2 9 \ u 2 1 2 C \ u 2 1 2 D \ u 2 1 2 F - \ u 2 1 3 1 \ u 2 1 3 3 - \ u 2 1 3 8 \ u 2 1 4 5 - \ u 2 1 4 8 \ u 2 1 5 3 - \ u 2 1 5 E \ u 2 1 9 0 - \ u 2 1 9 B \ u 2 1 9 D - \ u 2 1 A 7 \ u 2 1 A 9 - \ u 2 1 A E \ u 2 1 B 0 - \ u 2 1 B 3 \ u 2 1 B 5 - \ u 2 1 B 7 \ u 2 1 B A - \ u 2 1 D B \ u 2 1 D D \ u 2 1 E 4 \ u 2 1 E 5 \ u 2 1 F 5 \ u 2 1 F D - \ u 2 2 0 5 \ u 2 2 0 7 - \ u 2 2 0 9 \ u 2 2 0 B \ u 2 2 0 C \ u 2 2 0 F - \ u 2 2 1 4 \ u 2 2 1 6 - \ u 2 2 1 8 \ u 2 2 1 A \ u 2 2 1 D - \ u 2 2 3 8 \ u 2 2 3 A - \ u 2 2 5 7 \ u 2 2 5 9 \ u 2 2 5 A \ u 2 2 5 C \ u 2 2 5 F - \ u 2 2 6 2 \ u 2 2 6 4 - \ u 2 2 8 B \ u 2 2 8 D - \ u 2 2 9 B \ u 2 2 9 D - \ u 2 2 A 5 \ u 2 2 A 7 - \ u 2 2 B 0 \ u 2 2 B 2 - \ u 2 2 B B \ u 2 2 B D - \ u 2 2 D B \ u 2 2 D E - \ u 2 2 E 3 \ u 2 2 E 6 - \ u 2 2 F 7 \ u 2 2 F 9 - \ u 2 2 F E \ u 2 3 0 5 \ u 2 3 0 6 \ u 2 3 0 8 - \ u 2 3 1 0 \ u 2 3 1 2 \ u 2 3 1 3 \ u 2 3 1 5 \ u 2 3 1 6 \ u 2 3 1 C - \ u 2 3 1 F \ u 2 3 2 2 \ u 2 3 2 3 \ u 2 3 2 D \ u 2 3 2 E \ u 2 3 3 6 \ u 2 3 3 D \ u 2 3 3 F \ u 2 3 7 C \ u 2 3 B 0 \ u 2 3 B 1 \ u 2 3 B 4 - \ u 2 3 B 6 \ u 2 3 D C - \ u 2 3 D F \ u 2 3 E 2 \ u 2 3 E 7 \ u 2 4 2 3 \ u 2 4 C 8 \ u 2 5 0 0 \ u 2 5 0 2 \ u 2 5 0 C \ u 2 5 1 0 \ u 2 5 1 4 \ u 2 5 1 8 \ u 2 5 1 C \ u 2 5 2 4 \ u 2 5 2 C \ u 2 5 3 4 \ u 2 5 3 C \ u 2 5 5 0 - \ u 2 5 6 C \ u 2 5 8 0 \ u 2 5 8 4 \ u 2 5 8 8 \ u 2 5 9 1 - \ u 2 5 9 3 \ u 2 5 A 1 \ u 2 5 A A \ u 2 5 A B \ u 2 5 A D \ u 2 5 A E \ u 2 5 B 1 \ u 2 5 B 3 - \ u 2 5 B 5 \ u 2 5 B 8 \ u 2 5 B 9 \ u 2 5 B D - \ u 2 5 B F \ u 2 5 C 2 \ u 2 5 C 3 \ u 2 5 C A \ u 2 5 C B \ u 2 5 E C \ u 2 5 E F \ u 2 5 F 8 - \ u 2 5 F C \ u 2 6 0 5 \ u 2 6 0 6 \ u 2 6 0 E \ u 2 6 4 0 \ u 2 6 4 2 \ u 2 6 6 0 \ u 2 6 6 3 \ u 2 6 6 5 \ u 2 6 6 6 \ u 2 6 6 A \ u 2 6 6 D - \ u 2 6 6 F \ u 2 7 1 3 \ u 2 7 1 7 \ u 2 7 2 0 \ u 2 7 3 6 \ u 2 7 5 8 \ u 2 7 7 2 \ u 2 7 7 3 \ u 2 7 C 8 \ u 2 7 C 9 \ u 2 7 E 6 - \ u 2 7 E D \ u 2 7 F 5 - \ u 2 7 F A \ u 2 7 F C \ u 2 7 F F \ u 2 9 0 2 - \ u 2 9 0 5 \ u 2 9 0 C - \ u 2 9 1 3 \ u 2 9 1 6 \ u 2 9 1 9 - \ u 2 9 2 0 \ u 2 9 2 3 - \ u 2 9 2 A \ u 2 9 3 3 \ u 2 9 3 5 - \ u 2 9 3 9 \ u 2 9 3 C \ u 2 9 3 D \ u 2 9 4 5 \ u 2 9 4 8 - \ u 2 9 4 B \ u 2 9 4 E - \ u 2 9 7 6 \ u 2 9 7 8 \ u 2 9 7 9 \ u 2 9 7 B - \ u 2 9 7 F \ u 2 9 8 5 \ u 2 9 8 6 \ u 2 9 8 B - \ u 2 9 9 6 \ u 2 9 9 A \ u 2 9 9 C \ u 2 9 9 D \ u 2 9 A 4 - \ u 2 9 B 7 \ u 2 9 B 9 \ u 2 9 B B \ u 2 9 B C \ u 2 9 B E - \ u 2 9 C 5 \ u 2 9 C 9 \ u 2 9 C D - \ u 2 9 D 0 \ u 2 9 D C - \ u 2 9 D E \ u 2 9 E 3 - \ u 2 9 E 5 \ u 2 9 E B \ u 2 9 F 4 \ u 2 9 F 6 \ u 2 A 0 0 - \ u 2 A 0 2 \ u 2 A 0 4 \ u 2 A 0 6 \ u 2 A 0 C \ u 2 A 0 D \ u 2 A 1 0 - \ u 2 A 1 7 \ u 2 A 2 2 - \ u 2 A 2 7 \ u 2 A 2 9 \ u 2 A 2 A \ u 2 A 2 D - \ u 2 A 3 1 \ u 2 A 3 3 - \ u 2 A 3 C \ u 2 A 3 F \ u 2 A 4 0 \ u 2 A 4 2 - \ u 2 A 4 D \ u 2 A 5 0 \ u 2 A 5 3 - \ u 2 A 5 8 \ u 2 A 5 A - \ u 2 A 5 D \ u 2 A 5 F \ u 2 A 6 6 \ u 2 A 6 A \ u 2 A 6 D - \ u 2 A 7 5 \ u 2 A 7 7 - \ u 2 A 9 A \ u 2 A 9 D - \ u 2 A A 2 \ u 2 A A 4 - \ u 2 A B 0 \ u 2 A B 3 - \ u 2 A C 8 \ u 2 A C B \ u 2 A C C \ u 2 A
` ,nexist:" \u 2204",nexists:" \u 2204",nfr:" \u {1D52B}",Nfr:" \u {1D511}",nge:" \u 2271",ngE:" \u 2267 \u 0338",ngeq:" \u 2271",ngeqq:" \u 2267 \u 0338",ngeqslant:" \u 2A7E \u 0338",nges:" \u 2A7E \u 0338",nGg:" \u 22D9 \u 0338",ngsim:" \u 2275",ngt:" \u 226F",nGt:" \u 226B \u 20D2",ngtr:" \u 226F",nGtv:" \u 226B \u 0338",nharr:" \u 21AE",nhArr:" \u 21CE",nhpar:" \u 2AF2",ni:" \u 220B",nis:" \u 22FC",nisd:" \u 22FA",niv:" \u 220B",njcy:" \u 045A",NJcy:" \u 040A",nlarr:" \u 219A",nlArr:" \u 21CD",nldr:" \u 2025",nle:" \u 2270",nlE:" \u 2266 \u 0338",nleftarrow:" \u 219A",nLeftarrow:" \u 21CD",nleftrightarrow:" \u 21AE",nLeftrightarrow:" \u 21CE",nleq:" \u 2270",nleqq:" \u 2266 \u 0338",nleqslant:" \u 2A7D \u 0338",nles:" \u 2A7D \u 0338",nless:" \u 226E",nLl:" \u 22D8 \u 0338",nlsim:" \u 2274",nlt:" \u 226E",nLt:" \u 226A \u 20D2",nltri:" \u 22EA",nltrie:" \u 22EC",nLtv:" \u 226A \u 0338",nmid:" \u 2224",NoBreak:" \u 2060",NonBreakingSpace:" \x A0",nopf:" \u {1D55F}",Nopf:" \u 2115",not:" \x AC",Not:" \u 2AEC",NotCongruent:" \u 2262",NotCupCap:" \u 226D",NotDoubleVerticalBar:" \u 2226",NotElement:" \u 2209",NotEqual:" \u 2260",NotEqualTilde:" \u 2242 \u 0338",NotExists:" \u 2204",NotGreater:" \u 226F",NotGreaterEqual:" \u 2271",NotGreaterFullEqual:" \u 2267 \u 0338",NotGreaterGreater:" \u 226B \u 0338",NotGreaterLess:" \u 2279",NotGreaterSlantEqual:" \u 2A7E \u 0338",NotGreaterTilde:" \u 2275",NotHumpDownHump:" \u 224E \u 0338",NotHumpEqual:" \u 224F \u 0338",notin:" \u 2209",notindot:" \u 22F5 \u 0338",notinE:" \u 22F9 \u 0338",notinva:" \u 2209",notinvb:" \u 22F7",notinvc:" \u 22F6",NotLeftTriangle:" \u 22EA",NotLeftTriangleBar:" \u 29CF \u 0338",NotLeftTriangleEqual:" \u 22EC",NotLess:" \u 226E",NotLessEqual:" \u 2270",NotLessGreater:" \u 2278",NotLessLess:" \u 226A \u 0338",NotLessSlantEqual:" \u 2A7D \u 0338",NotLessTilde:" \u 2274",NotNestedGreaterGreater:" \u 2AA2 \u 0338",NotNestedLessLess:" \u 2AA1 \u 0338",notni:" \u 220C",notniva:" \u 220C",notnivb:" \u 22FE",notnivc:" \u 22FD",NotPrecedes:" \u 2280",NotPrecedesEqual:" \u 2AAF \u 0338",NotPrecedesSlantEqual:" \u 22E0",NotReverseElement:" \u 220C",NotRightTriangle:" \u 22EB",NotRightTriangleBar:" \u 29D0 \u 0338",NotRightTriangleEqual:" \u 22ED",NotSquareSubset:" \u 228F \u 0338",NotSquareSubsetEqual:" \u 22E2",NotSquareSuperset:" \u 2290 \u 0338",NotSquareSupersetEqual:" \u 22E3",NotSubset:" \u 2282 \u 20D2",NotSubsetEqual:" \u 2288",NotSucceeds:" \u 2281",NotSucceedsEqual:" \u 2AB0 \u 0338",NotSucceedsSlantEqual:" \u 22E1",NotSucceedsTilde:" \u 227F \u 0338",NotSuperset:" \u 2283 \u 20D2",NotSupersetEqual:" \u 2289",NotTilde:" \u 2241",NotTildeEqual:" \u 2244",NotTildeFullEqual:" \u 2247",NotTildeTilde:" \u 2249",NotVerticalBar:" \u 2224",npar:" \u 2226",nparallel:" \u 2226",nparsl:" \u 2AFD \u 20E5",npart:" \u 2202 \u 0338",npolint:" \u 2A14",npr:" \u 2280",nprcue:" \u 22E0",npre:" \u 2AAF \u 0338",nprec:" \u 2280",npreceq:" \u 2AAF \u 0338",nrarr:" \u 219B",nrArr:" \u 21CF",nrarrc:" \u 2933 \u 0338",nrarrw:" \u 219D \u 0338",nrightarrow:" \u 219B",nRightarrow:" \u 21CF",nrtri:" \u 22EB",nrtrie:" \u 22ED",nsc:" \u 2281",nsccue:" \u 22E1",nsce:" \u 2AB0 \u 0338",nscr:" \u {1D4C3}",Nscr:" \u {1D4A9}",nshortmid:" \u 2224",nshortparallel:" \u 2226",nsim:" \u 2241",nsime:" \u 2244",nsimeq:" \u 2244",nsmid:" \u 2224",nspar:" \u 2226",nsqsube:" \u 22E2",nsqsupe:" \u 22E3",nsub:" \u 2284",nsube:" \u 2288",nsubE:" \u 2AC5 \u 0338",nsubset:" \u 2282 \u 20D2",nsubseteq:" \u 2288",nsubseteqq:" \u 2AC5 \u 0338",nsucc:" \u 2281",nsucceq:" \u 2AB0 \u 0338",nsup:" \u 2285",nsupe:" \u 2289",nsupE:" \u 2AC6 \u 0338",nsupset:" \u 2283 \u 20D2",nsupseteq:" \u 2289",nsupseteqq:" \u 2AC6 \u 0338",ntgl:" \u 2279",ntilde:" \x F1",Ntilde:" \x D1",ntlg:" \u 2278",ntriangleleft:" \u 22EA",ntrianglelefteq:" \u 22EC",ntriangleright:" \u 22EB",ntrianglerighteq:" \u 22ED",nu:" \u 03BD",Nu:" \u 039D",num:"#",numero:" \u 2116",numsp:" \u 2007",nvap:" \u 224D \u 20D2",nvdash:" \u 22AC",nvDash:" \u 22AD",nVdash:" \u 22AE",nVDash:" \u 22AF",nvge:" \u 2265 \u 20D2",nvgt:"> \u 20D2",nvHarr:" \u 2904",nvinfin:" \u 29DE",nvlArr:" \u 2902",nvle:" \u 2264 \u 20D2",nvlt:"< \u 20D2",nvltrie:" \u 22B4 \u 20D2",nvrArr:" \u 2903",nvrtrie:" \u 22B5 \u 20D2",nvsim:" \u 223C \u 20D2",nwarhk:" \u 2923",nwarr:" \u 2196",nwArr:" \u 21D6",nwarrow:" \u 2196",nwnear:" \u 2927",oacute:" \x F3",Oacute:" \x D3",oast:" \u 229B",ocir:" \u 229A",ocirc:" \x F4",Ocirc:" \x D4",ocy:" \u 043E",Ocy:" \u 041E",odash:" \u 229D",odblac:" \u 0151",Odblac:" \u 0150",odiv:" \u 2A38",odot:" \u 2299",odsold:" \u 29BC",oelig:" \u 0153",OElig:" \u 01
Use ( ? : \u2026 ) instead ` );if(!N.lineBreaks&&ie.test( `
` ))throw new Error("Rule should declare lineBreaks: "+ie);V.push(o(j))}}var U=H&&H.fallback,Ce=t&&!U?"ym":"gm",ce=t||U?"":"|";A===!0&&(Ce+="u");var xe=new RegExp(c(V)+ce,Ce);return{regexp:xe,groups:R,fast:w,error:H||p}}function x(S){var P=v(d(S));return new y({start:P},"start")}function g(S,P,H){var w=S&&(S.push||S.next);if(w&&!H[w])throw new Error("Missing state '"+w+"' (in token '"+S.defaultType+"' of state '"+P+"')");if(S&&S.pop&&+S.pop!=1)throw new Error("pop must be 1 (in token '"+S.defaultType+"' of state '"+P+"')")}function m(S,P){var H=S. $ all?d(S. $ all):[];delete S. $ all;var w=Object.getOwnPropertyNames(S);P||(P=w[0]);for(var T=Object.create(null),A=0;A<w.length;A++){var R=w[A];T[R]=d(S[R]).concat(H)}for(var A=0;A<w.length;A++)for(var R=w[A],V=T[R],L=Object.create(null),N=0;N<V.length;N++){var I=V[N];if(I.include){var W=[N,1];if(I.include!==R&&!L[I.include]){L[I.include]=!0;var O=T[I.include];if(!O)throw new Error("Cannot include nonexistent state '"+I.include+"' (in state '"+R+"')");for(var q=0;q<O.length;q++){var j=O[q];V.indexOf(j)===-1&&W.push(j)}}V.splice.apply(V,W),N--}}for(var ie=Object.create(null),A=0;A<w.length;A++){var R=w[A];ie[R]=v(T[R],!0)}for(var A=0;A<w.length;A++){for(var ae=w[A],U=ie[ae],Ce=U.groups,N=0;N<Ce.length;N++)g(Ce[N],ae,ie);for(var ce=Object.getOwnPropertyNames(U.fast),N=0;N<ce.length;N++)g(U.fast[ce[N]],ae,ie)}return new y(ie,P)}function M(S){for(var P=Object.create(null),H=Object.create(null),w=Object.getOwnPropertyNames(S),T=0;T<w.length;T++){var A=w[T],R=S[A],V=Array.isArray(R)?R:[R];V.forEach(function(O){if((H[O.length]=H[O.length]||[]).push(O),typeof O!="string")throw new Error("keyword must be string (in keyword '"+A+"')");P[O]=A})}function L(O){return JSON.stringify(O)}var N="";N+= ` switch ( value . length ) {
` ;for(var I in H){var W=H[I];N+="case "+I+ ` :
` ,N+= ` switch ( value ) {
` ,W.forEach(function(O){var q=P[O];N+="case "+L(O)+": return "+L(q)+ `
` }),N+= ` }
` }return N+= ` }
` ,Function("value",N)}var y=function(S,P){this.startState=P,this.states=S,this.buffer="",this.stack=[],this.reset()};y.prototype.reset=function(S,P){return this.buffer=S||"",this.index=0,this.line=P?P.line:1,this.col=P?P.col:1,this.queuedToken=P?P.queuedToken:null,this.queuedThrow=P?P.queuedThrow:null,this.setState(P?P.state:this.startState),this.stack=P&&P.stack?P.stack.slice():[],this},y.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedThrow:this.queuedThrow}},y.prototype.setState=function(S){if(!(!S||this.state===S)){this.state=S;var P=this.states[S];this.groups=P.groups,this.error=P.error,this.re=P.regexp,this.fast=P.fast}},y.prototype.popState=function(){this.setState(this.stack.pop())},y.prototype.pushState=function(S){this.stack.push(this.state),this.setState(S)};var b=t?function(S,P){return S.exec(P)}:function(S,P){var H=S.exec(P);return H[0].length===0?null:H};y.prototype._getGroup=function(S){for(var P=this.groups.length,H=0;H<P;H++)if(S[H+1]!==void 0)return this.groups[H];throw new Error("Cannot find token type for matched text")};function C(){return this.value}if(y.prototype.next=function(){var S=this.index;if(this.queuedGroup){var P=this._token(this.queuedGroup,this.queuedText,S);return this.queuedGroup=null,this.queuedText="",P}var H=this.buffer;if(S!==H.length){var R=this.fast[H.charCodeAt(S)];if(R)return this._token(R,H.charAt(S),S);var w=this.re;w.lastIndex=S;var T=b(w,H),A=this.error;if(T==null)return this._token(A,H.slice(S,H.length),S);var R=this._getGroup(T),V=T[0];return A.fallback&&T.index!==S?(this.queuedGroup=R,this.queuedText=V,this._token(A,H.slice(S,T.index),S)):this._token(R,V,S)}},y.prototype._token=function(S,P,H){var w=0;if(S.lineBreaks){var T=/ \n /g,A=1;if(P=== `
` )w=1;else for(;T.exec(P);)w++,A=T.lastIndex}var R={type:typeof S.type=="function"&&S.type(P)||S.defaultType,value:typeof S.value=="function"?S.value(P):P,text:P,toString:C,offset:H,lineBreaks:w,line:this.line,col:this.col},V=P.length;if(this.index+=V,this.line+=w,w!==0?this.col=V-A+1:this.col+=V,S.shouldThrow)throw new Error(this.formatError(R,"invalid syntax"));return S.pop?this.popState():S.push?this.pushState(S.push):S.next&&this.setState(S.next),R},typeof Symbol<"u"&&Symbol.iterator){var _=function(S){this.lexer=S};_.prototype.next=function(){var S=this.lexer.next();return{value:S,done:!S}},_.prototype[Symbol.iterator]=function(){return this},y.prototype[Symbol.iterator]=function(){return new _(this)}}return y.prototype.formatError=function(S,P){if(S==null)var H=this.buffer.slice(this.index),S={text:H,offset:this.index,lineBreaks:H.indexOf( `
` )===-1?0:1,line:this.line,col:this.col};var w=Math.max(0,S.offset-S.col+1),T=S.lineBreaks?S.text.indexOf( `
` ):S.text.length,A=this.buffer.substring(w,S.offset+T);return P+=" at line "+S.line+" col "+S.col+ ` :
` ,P+=" "+A+ `
` ,P+=" "+Array(S.col).join(" ")+"^",P},y.prototype.clone=function(){return new y(this.states,this.state)},y.prototype.has=function(S){return!0},{compile:x,states:m,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:M}})});var Zb={};b7(Zb,{DEFAULT_SETTINGS:()=>Na,default:()=>i0});module.exports=M7(Zb);var ft=require("obsidian"),h7=Ar(Qc());var Kc={prefix:"fas",iconName:"dice",icon:[640,512,[],"f522","M592 192H473.26c12.69 29.59 7.12 65.2-17 89.32L320 417.58V464c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48V240c0-26.51-21.49-48-48-48zM480 376c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm-46.37-186.7L258.7 14.37c-19.16-19.16-50.23-19.16-69.39 0L14.37 189.3c-19.16 19.16-19.16 50.23 0 69.39L189.3 433.63c19.16 19.16 50.23 19.16 69.39 0L433.63 258.7c19.16-19.17 19.16-50.24 0-69.4zM96 248c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm0-128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24zm128 128c-13.25 0-24-10.75-24-24 0-13.26 10.75-24 24-24s24 10.74 24 24c0 13.25-10.75 24-24 24z"]};var e8={prefix:"far",iconName:"copy",icon:[448,512,[],"f0c5","M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"]};function _r(a){return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?_r=function(e){return typeof e}:_r=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_r(a)}function A7(a,e){if(!(a instanceof e))throw new TypeError("Cannot call a class as a function")}function t8(a,e){for(var t=0;t<e.length;t++){var i=e[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(a,i.key,i)}}function S7(a,e,t){return e&&t8(a.prototype,e),t&&t8(a,t),a}function _7(a,e,t){return e in a?Object.defineProperty(a,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):a[e]=t,a}function We(a){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),i.forEach(function(n){_7(a,n,t[n])})}return a}function d8(a,e){return E7(a)||L7(a,e)||T7()}function E7(a){if(Array.isArray(a))return a}function L7(a,e){var t=[],i=!0,n=!1,r=void 0;try{for(var s=a[Symbol.iterator](),o;!(i=(o=s.next()).done)&&(t.push(o.value),!(e&&t.length===e));i=!0);}catch(c){n=!0,r=c}finally{try{!i&&s.return!=null&&s.return()}finally{if(n)throw r}}return t}function T7(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}var i8=function(){},h0={},p8={},D7=null,m8={mark:i8,measure:i8};try{typeof window<"u"&&(h0=window),typeof document<"u"&&(p8=document),typeof MutationObserver<"u"&&(D7=MutationObserver),typeof performance<"u"&&(m8=performance)}catch{}var H7=h0.navigator||{},n8=H7.userAgent,r8=n8===void 0?"":n8,da=h0,qt=p8;var ca=m8,Qb=!!da.document,u0=!!qt.documentElement&&!!qt.head&&typeof qt.addEventListener=="function"&&typeof qt.createElement=="function",Kb=~r8.indexOf("MSIE")||~r8.indexOf("Trident/"),n2="___FONT_AWESOME___";var g8="fa",v8="svg-inline--fa",V7="data-fa-i2svg";var eM=function(){try{return!0}catch{return!1}}();var x8=[1,2,3,4,5,6,7,8,9,10],R7=x8.concat([11,12,13,14,15,16,17,18,19,20]);var Ai={GROUP:"group",SWAP_OPACITY:"swap-opacity",PRIMARY:"primary",SECOND
overflow : visible ;
}
. svg - inline -- fa {
display : inline - block ;
font - size : inherit ;
height : 1 em ;
overflow : visible ;
vertical - align : - 0.125 em ;
}
. svg - inline -- fa . fa - lg {
vertical - align : - 0.225 em ;
}
. svg - inline -- fa . fa - w - 1 {
width : 0.0625 em ;
}
. svg - inline -- fa . fa - w - 2 {
width : 0.125 em ;
}
. svg - inline -- fa . fa - w - 3 {
width : 0.1875 em ;
}
. svg - inline -- fa . fa - w - 4 {
width : 0.25 em ;
}
. svg - inline -- fa . fa - w - 5 {
width : 0.3125 em ;
}
. svg - inline -- fa . fa - w - 6 {
width : 0.375 em ;
}
. svg - inline -- fa . fa - w - 7 {
width : 0.4375 em ;
}
. svg - inline -- fa . fa - w - 8 {
width : 0.5 em ;
}
. svg - inline -- fa . fa - w - 9 {
width : 0.5625 em ;
}
. svg - inline -- fa . fa - w - 10 {
width : 0.625 em ;
}
. svg - inline -- fa . fa - w - 11 {
width : 0.6875 em ;
}
. svg - inline -- fa . fa - w - 12 {
width : 0.75 em ;
}
. svg - inline -- fa . fa - w - 13 {
width : 0.8125 em ;
}
. svg - inline -- fa . fa - w - 14 {
width : 0.875 em ;
}
. svg - inline -- fa . fa - w - 15 {
width : 0.9375 em ;
}
. svg - inline -- fa . fa - w - 16 {
width : 1 em ;
}
. svg - inline -- fa . fa - w - 17 {
width : 1.0625 em ;
}
. svg - inline -- fa . fa - w - 18 {
width : 1.125 em ;
}
. svg - inline -- fa . fa - w - 19 {
width : 1.1875 em ;
}
. svg - inline -- fa . fa - w - 20 {
width : 1.25 em ;
}
. svg - inline -- fa . fa - pull - left {
margin - right : 0.3 em ;
width : auto ;
}
. svg - inline -- fa . fa - pull - right {
margin - left : 0.3 em ;
width : auto ;
}
. svg - inline -- fa . fa - border {
height : 1.5 em ;
}
. svg - inline -- fa . fa - li {
width : 2 em ;
}
. svg - inline -- fa . fa - fw {
width : 1.25 em ;
}
. fa - layers svg . svg - inline -- fa {
bottom : 0 ;
left : 0 ;
margin : auto ;
position : absolute ;
right : 0 ;
top : 0 ;
}
. fa - layers {
display : inline - block ;
height : 1 em ;
position : relative ;
text - align : center ;
vertical - align : - 0.125 em ;
width : 1 em ;
}
. fa - layers svg . svg - inline -- fa {
- webkit - transform - origin : center center ;
transform - origin : center center ;
}
. fa - layers - counter , . fa - layers - text {
display : inline - block ;
position : absolute ;
text - align : center ;
}
. fa - layers - text {
left : 50 % ;
top : 50 % ;
- webkit - transform : translate ( - 50 % , - 50 % ) ;
transform : translate ( - 50 % , - 50 % ) ;
- webkit - transform - origin : center center ;
transform - origin : center center ;
}
. fa - layers - counter {
background - color : # ff253a ;
border - radius : 1 em ;
- webkit - box - sizing : border - box ;
box - sizing : border - box ;
color : # fff ;
height : 1.5 em ;
line - height : 1 ;
max - width : 5 em ;
min - width : 1.5 em ;
overflow : hidden ;
padding : 0.25 em ;
right : 0 ;
text - overflow : ellipsis ;
top : 0 ;
- webkit - transform : scale ( 0.25 ) ;
transform : scale ( 0.25 ) ;
- webkit - transform - origin : top right ;
transform - origin : top right ;
}
. fa - layers - bottom - right {
bottom : 0 ;
right : 0 ;
top : auto ;
- webkit - transform : scale ( 0.25 ) ;
transform : scale ( 0.25 ) ;
- webkit - transform - origin : bottom right ;
transform - origin : bottom right ;
}
. fa - layers - bottom - left {
bottom : 0 ;
left : 0 ;
right : auto ;
top : auto ;
- webkit - transform : scale ( 0.25 ) ;
transform : scale ( 0.25 ) ;
- webkit - transform - origin : bottom left ;
transform - origin : bottom left ;
}
. fa - layers - top - right {
right : 0 ;
top : 0 ;
- webkit - transform : scale ( 0.25 ) ;
transform : scale ( 0.25 ) ;
- webkit - transform - origin : top right ;
transform - origin : top right ;
}
. fa - layers - top - left {
left : 0 ;
right : auto ;
top : 0 ;
- webkit - transform : scale ( 0.25 ) ;
transform : scale ( 0.25 ) ;
- webkit - transform - origin : top left ;
transform - origin : top left ;
}
. fa - lg {
font - size : 1.3333333333 em ;
line - height : 0.75 em ;
vertical - align : - 0.0667 em ;
}
. fa - xs {
font - size : 0.75 em ;
}
. fa - sm {
font - size : 0.875 em ;
}
. fa - 1 x {
font - size : 1 em ;
}
. fa - 2 x {
font - size : 2 em ;
}
. fa - 3 x {
font - size : 3 em ;
}
. fa - 4 x {
font - size : 4 em ;
}
. fa - 5 x {
font - size : 5 em ;
}
. fa - 6 x {
font - size : 6 em ;
}
. fa - 7 x {
font - size : 7 em ;
}
. fa - 8 x {
font - size : 8 em ;
}
. fa - 9 x {
font - size : 9 em ;
}
. fa - 10 x {
font - size : 10 em ;
}
. fa - fw {
text - align : center ;
width : 1.25 em ;
}
. fa - ul {
list - style - type : none ;
margin - left : 2.5 em ;
padding - left : 0 ;
}
. fa - ul > li {
position : relative ;
}
. fa - li {
left : - 2 em ;
position : absolute ;
text - align : center ;
width : 2 em ;
line - height : inherit ;
}
. fa - border {
border : solid 0.08 em # eee ;
border - radius : 0.1 em ;
padding : 0.2 em 0.25 em 0.15 em ;
}
. fa - pull - left {
float : left ;
}
. fa - pull - right {
float : right ;
}
. fa . fa - pull - left ,
. fas . fa - pull - left ,
. far . fa - pull - left ,
. fal . fa - pull - left ,
. fab . fa - pull - left {
margin - right : 0.3 em ;
}
. fa . fa - pull - right ,
. fas . fa - pull - right ,
. far . fa - pull - right ,
. fal . fa - pull - right ,
. fab . fa - pull - right {
margin - left : 0.3 em ;
}
. fa - spin {
- webkit - animation : fa - spin 2 s infinite linear ;
animation : fa - spin 2 s infinite linear ;
}
. fa - pulse {
- webkit - animation : fa - spin 1 s infinite steps ( 8 ) ;
animation : fa - spin 1 s infinite steps ( 8 ) ;
}
@ - webkit - keyframes fa - spin {
0 % {
- webkit - transform : rotate ( 0 deg ) ;
transform : rotate ( 0 deg ) ;
}
100 % {
- webkit - transform : rotate ( 360 deg ) ;
transform : rotate ( 360 deg ) ;
}
}
@ keyframes fa - spin {
0 % {
- webkit - transform : rotate ( 0 deg ) ;
transform : rotate ( 0 deg ) ;
}
100 % {
- webkit - transform : rotate ( 360 deg ) ;
transform : rotate ( 360 deg ) ;
}
}
. fa - rotate - 90 {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=1)" ;
- webkit - transform : rotate ( 90 deg ) ;
transform : rotate ( 90 deg ) ;
}
. fa - rotate - 180 {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)" ;
- webkit - transform : rotate ( 180 deg ) ;
transform : rotate ( 180 deg ) ;
}
. fa - rotate - 270 {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)" ;
- webkit - transform : rotate ( 270 deg ) ;
transform : rotate ( 270 deg ) ;
}
. fa - flip - horizontal {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)" ;
- webkit - transform : scale ( - 1 , 1 ) ;
transform : scale ( - 1 , 1 ) ;
}
. fa - flip - vertical {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)" ;
- webkit - transform : scale ( 1 , - 1 ) ;
transform : scale ( 1 , - 1 ) ;
}
. fa - flip - both , . fa - flip - horizontal . fa - flip - vertical {
- ms - filter : "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)" ;
- webkit - transform : scale ( - 1 , - 1 ) ;
transform : scale ( - 1 , - 1 ) ;
}
: root . fa - rotate - 90 ,
: root . fa - rotate - 180 ,
: root . fa - rotate - 270 ,
: root . fa - flip - horizontal ,
: root . fa - flip - vertical ,
: root . fa - flip - both {
- webkit - filter : none ;
filter : none ;
}
. fa - stack {
display : inline - block ;
height : 2 em ;
position : relative ;
width : 2.5 em ;
}
. fa - stack - 1 x ,
. fa - stack - 2 x {
bottom : 0 ;
left : 0 ;
margin : auto ;
position : absolute ;
right : 0 ;
top : 0 ;
}
. svg - inline -- fa . fa - stack - 1 x {
height : 1 em ;
width : 1.25 em ;
}
. svg - inline -- fa . fa - stack - 2 x {
height : 2 em ;
width : 2.5 em ;
}
. fa - inverse {
color : # fff ;
}
. sr - only {
border : 0 ;
clip : rect ( 0 , 0 , 0 , 0 ) ;
height : 1 px ;
margin : - 1 px ;
overflow : hidden ;
padding : 0 ;
position : absolute ;
width : 1 px ;
}
. sr - only - focusable : active , . sr - only - focusable : focus {
clip : auto ;
height : auto ;
margin : 0 ;
overflow : visible ;
position : static ;
width : auto ;
}
. svg - inline -- fa . fa - primary {
fill : var ( -- fa - primary - color , currentColor ) ;
opacity : 1 ;
opacity : var ( -- fa - primary - opacity , 1 ) ;
}
. svg - inline -- fa . fa - secondary {
fill : var ( -- fa - secondary - color , currentColor ) ;
opacity : 0.4 ;
opacity : var ( -- fa - secondary - opacity , 0.4 ) ;
}
. svg - inline -- fa . fa - swap - opacity . fa - primary {
opacity : 0.4 ;
opacity : var ( -- fa - secondary - opacity , 0.4 ) ;
}
. svg - inline -- fa . fa - swap - opacity . fa - secondary {
opacity : 1 ;
opacity : var ( -- fa - primary - opacity , 1 ) ;
}
. svg - inline -- fa mask . fa - primary ,
. svg - inline -- fa mask . fa - secondary {
fill : black ;
}
. fad . fa - inverse {
color : # fff ;
} ` ;function c9(){var a=g8,e=v8,t=n1.familyPrefix,i=n1.replacementClass,n=o9;if(t!==a||i!==e){var r=new RegExp(" \\ .".concat(a," \\ -"),"g"),s=new RegExp(" \\ --".concat(a," \\ -"),"g"),o=new RegExp(" \\ .".concat(e),"g");n=n.replace(r,".".concat(t,"-")).replace(s,"--".concat(t,"-")).replace(o,".".concat(i))}return n}var l9=function(){function a(){A7(this,a),this.definitions={}}return S7(a,[{key:"add",value:function(){for(var t=this,i=arguments.length,n=new Array(i),r=0;r<i;r++)n[r]=arguments[r];var s=n.reduce(this._pullDefinitions,{});Object.keys(s).forEach(function(o){t.definitions[o]=We({},t.definitions[o]||{},s[o]),T8(o,s[o]),D8()})}},{key:"reset",value:function(){this.definitions={}}},{key:"_pullDefinitions",value:function(t,i){var n=i.prefix&&i.iconName&&i.icon?{0:i}:i;return Object.keys(n).map(function(r){var s=n[r],o=s.prefix,c=s.iconName,l=s.icon;t[o]||(t[o]={}),t[o][c]=l}),t}}]),a}();function h9(){n1.autoAddCss&&!f8&&(Z7(c9()),f8=!0)}function u9(a,e){return Object.defineProperty(a,"abstract",{get:e}),Object.defineProperty(a,"html",{get:function(){return a.abstract.map(function(i){return H8(i)})}}),Object.defineProperty(a,"node",{get:function(){if(u0){var i=qt.createElement("div");return i.innerHTML=a.html,i.children}}}),a}function u8(a){var e=a.prefix,t=e===void 0?"fa":e,i=a.iconName;if(i)return l8(d9.definitions,t,i)||l8(O1.styles,t,i)}function f9(a){return function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=(e||{}).icon?e:u8(e||{}),n=t.mask;return n&&(n=(n||{}).icon?n:u8(n||{})),a(i,We({},t,{mask:n}))}}var d9=new l9;var f8=!1;var m0=f9(function(a){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.transform,i=t===void 0?ln:t,n=e.symbol,r=n===void 0?!1:n,s=e.mask,o=s===void 0?null:s,c=e.maskId,l=c===void 0?null:c,h=e.title,u=h===void 0?null:h,f=e.titleId,d=f===void 0?null:f,p=e.classes,v=p===void 0?[]:p,x=e.attributes,g=x===void 0?{}:x,m=e.styles,M=m===void 0?{}:m;if(a){var y=a.prefix,b=a.iconName,C=a.icon;return u9(We({type:"icon"},a),function(){return h9(),n1.autoA11y&&(u?g["aria-labelledby"]="".concat(n1.replacementClass,"-title-").concat(d||fa()):(g["aria-hidden"]="true",g.focusable="false")),t9({icons:{main:h8(C),mask:o?h8(o.icon):{found:!1,width:null,height:null,icon:{}}},prefix:y,iconName:b,transform:We({},ln,i),symbol:r,title:u,maskId:l,titleId:d,extra:{attributes:g,styles:M,classes:v}})})}});function g0(a,e){let t=Object.keys(e).map(i=>p9(a,i,e[i]));return t.length===1?t[0]:function(){t.forEach(i=>i())}}function p9(a,e,t){let i=a[e],n=a.hasOwnProperty(e),r=t(i);return i&&Object.setPrototypeOf(r,i),Object.setPrototypeOf(s,r),a[e]=s,o;function s(...c){return r===i&&a[e]===s&&o(),r.apply(this,c)}function o(){a[e]===s&&(n?a[e]=i:delete a[e]),r!==i&&(r=i,Object.setPrototypeOf(s,i||Function))}}var u7=Ar(R8());var v0=/(?:(?<roll> \d +)[Dd])?#(?<query>[ \p {Letter} \p {Emoji_Presentation} \w /-]+)(?: \| (?<collapse>[ \+ -]))?(?: \| (?<types>[^ \+ -]+))?/u,N8=/(?:(?<roll> \d +)[Dd]?)?dv \( (?<query>.+) \) (?: \| (?<collapse>[ \+ -]))?(?: \| (?<types>[^ \+ -]+))?/u,F8=/(?<diceRoll>.*)?(?: \[ .* \] \( | \[ \[ )(?<link>.+?)#? \^ (?<block>.+?)(?: \] \] | \) )(?: \| (?<header>.+))?/,ga=/(?:(?<roll> \d +)[Dd])?(?: \[ .* \] \( | \[ \[ )(?<link>.+)(?: \] \] | \) ) \| ?(?<types>.+)?/;var M1="dice-roller-icon",U1="dice-roller-copy";var B2=require("obsidian");var hn=(n=>(n.None="None",n.Normal="Normal",n.Up="Up",n.Down="Down",n))(hn||{});function B8(a,e,t){[...a].slice(e).reverse().forEach(([n,r])=>{a.set(n+1,r)}),a.set(e,t)}function va(a,e){return Object.entries(a).reduce((t,i)=>{let n=i[0],s=i[1]?e.parent.path.startsWith(n):e.parent.path==n;return t||s},!1)}var s2=require("obsidian");var Tr=class extends s2.Events{getRandomBetween(e,t){let i=new Uint32Array(1);crypto.getRandomValues(i);let n=i[0]/4294967296;return Math.floor(n*(t-e+1))+e}},xa=class extends Tr{constructor(t,i="",n=t.data.showDice){super();this.plugin=t;this.original=i;this.loaded=!1;this.containerEl=createSpan({cls:"dice-roller",attr:{"aria-label-position":"top","data-dice":this.original}});this.resultEl=this.containerEl.createSpan("dice-roller-result");n?(this.iconEl=this.container
` ).join(" -> ")} -> ` } } , F2 = class extends Dr { } , Hr = class extends F2 { constructor ( t , i , n , r , s = t . data . showDice ) { super ( t , i , [ n ] , s ) ; this . plugin = t ; this . original = i ; this . lexeme = n ; this . source = r ; this . watch = ! 0 ; this . getPath ( ) , this . init = this . getFile ( ) } async getFile ( ) { if ( this . file = this . plugin . app . metadataCache . getFirstLinkpathDest ( this . path , this . source ) , ! this . file || ! ( this . file instanceof s2 . TFile ) ) throw new Error ( "Could not load file." ) ; await this . load ( ) } } , un = class extends Hr { constructor ( t , i , n , r , s = ! 0 , o = t . data . showDice ) { super ( t , i , n , r , o ) ; this . plugin = t ; this . original = i ; this . lexeme = n ; this . inline = s ; this . plugin . data . displayAsEmbed && ( this . containerEl . addClasses ( [ "has-embed" , "markdown-embed" ] ) , this . resultEl . addClass ( "internal-embed" ) ) , this . resultEl . setAttrs ( { src : r } ) , this . copy = this . containerEl . createDiv ( { cls : "dice-content-copy dice-roller-button no-show" , attr : { "aria-label" : "Copy Contents" } } ) , this . copy . addEventListener ( "click" , c => { c . stopPropagation ( ) , navigator . clipboard . writeText ( this . transformResultsToString ( ) ) . then ( async ( ) => { new s2 . Notice ( "Result copied to clipboard." ) } ) } ) , ( 0 , s2 . setIcon ) ( this . copy , U1 ) } getEmbedClass ( ) { return this . plugin . data . displayAsEmbed ? "markdown-embed" : "" } } , ya = class extends xa { constructor ( t , i , n ) { super ( t , "" ) ; this . options = i ; this . rolls = n } get tooltip ( ) { return ` ${ this . options . toString ( ) }
$ { this . results . toString ( ) } ` }async roll(){let t=[...this.options];return this.results=[...Array(this.rolls)].map(()=>{let i=t[this.getRandomBetween(0,t.length-1)];return t.splice(t.indexOf(i),1),i}).filter(i=>i),this.render(),this.trigger("new-result"),this.result=this.results[0],this.results[0]}async build(){this.resultEl.empty(),this.resultEl.setText(this.results.toString())}};var $ t=class{constructor(e,t,i={value: ` $ { e } ` ,conditions:[],type:"dice"}){this.renderer=t;this.lexeme=i;this.modifiers=new Map;this.possibilities=[];this.results=new Map;this.shapes=new Map;this.modifiersAllowed=!0;this.static=!1;this.conditions=[];this.fudge=!1;this.shouldRender=!1;if(!/( \- ? \d +)[dD]?( \d +|%| \[ \d +, \s ? \d + \] )?/.test( ` $ { e } ` ))throw new Error("Non parseable dice string passed to DiceRoll.");this.dice= ` $ { e } ` .split(" ").join(""),/^-? \d +(?: \. \d +)? $ /.test(this.dice)&&(this.static=!0,this.modifiersAllowed=!1);let[,n,r="1"]=this.dice.match(/( \- ? \d +)[dD](%|F|-? \d +| \[ \d +(?:[ \t ]*,[ \t ]* \d +)+ \] )/)||[,1,"1"];n=Number(n),this.multiplier=n<0?-1:1;let s=1,o=isNaN(Number(r))?1:Number(r);this.rolls=Math.abs(Number(n))||1,/ \[ \d +(?:[ \t ]*,[ \t ]* \d +)+ \] /.test(r)?this.possibilities=r.replace(/[ \[ \] \s ]/g,"").split(",").map(c=>Number(c)):r==="F"?(this.possibilities=[-1,0,1],this.fudge=!0):(r==="%"?o=100:o=Number(r),Number(o)<0&&!s&&(s=-1),Number(o)<Number(s)&&([o,s]=[s,o]),this.possibilities=[...Array(Number(o)).keys()].map(c=>c+s)),this.conditions=this.lexeme.conditions??[]}get faces(){return{max:this.possibilities[this.possibilities.length-1],min:this.possibilities[0]}}getShapes(e){if(this.shapes.has(e))return this.shapes.get(e);let t=this.renderer.getDiceForRoller(this);return e!=null&&this.shapes.set(e,t),t}get text(){return ` $ { this . result } ` }get result(){if(this.static)return this.multiplier*Number(this.dice);let e=[...this.results].map(([,{usable:t,value:i}])=>t?i:0);return this.multiplier*e.reduce((t,i)=>t+i,0)}get display(){if(this.static)return ` $ { this . result } ` ;let e=[ ` [ $ { [ ... this . results ] . map ( ( [ , { modifiers : t , display : i } ] ) => ` ${ i } ${ [ ... t ] . join ( "" ) } ` ) . join ( ", " ) } ] ` ];return this.conditions.length&&e.push(this.conditions.map(({result:t,operator:i})=> ` $ { i } $ { t } ` ).join("")),e.join("")}get modifierText(){let e=this.conditions.map(({value:i})=>i).join(""),t=[...this.modifiers].map(([i,{conditionals:n,value:r}])=>{let s=n.map(o=>o.value);return ` $ { r } $ { s . join ( "" ) } ` }).join("");return ` $ { e } $ { t } ` }keepLow(e=1){if(!this.modifiersAllowed){new B2.Notice("Modifiers are only allowed on dice rolls.");return}[...this.results].sort((t,i)=>t[1].value-i[1].value).slice(e-this.results.size).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}keepHigh(e=1){if(!this.modifiersAllowed){new B2.Notice("Modifiers are only allowed on dice rolls.");return}[...this.results].sort((t,i)=>i[1].value-t[1].value).slice(e).forEach(([t])=>{let i=this.results.get(t);i.usable=!1,i.modifiers.add("d"),this.results.set(t,{...i})})}async reroll(e,t){if(!this.modifiersAllowed){new B2.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.min,lexemes:[{value: ` $ { this . faces . min } ` ,text: ` $ { this . faces . min } ` ,type:"dice"}],value:""});let i=0,n=[...this.results].filter(([,{value:r}])=>this.checkCondition(r,t));for(;i<e&&n.length>0;){let r=[];for(let[s,o]of n)r.push(new Promise(async c=>{o.modifiers.add("r");let l=this.getShapes(s),h=await this.getValue(l);o.value=h,o.display= ` $ { h } ` ,c()}));await Promise.all(r),n=n.filter(([,{value:s}])=>this.checkCondition(s,t)),i++}n.forEach(([r,s])=>{this.results.set(r,s)})}async explode(e,t,i=!1){if(!this.modifiersAllowed){new B2.Notice("Modifiers are only allowed on dice rolls.");return}t.length||t.push({operator:"=",comparer:this.faces.max,lexemes:[{value: ` $ { this . faces . max } ` ,text: ` $ { this . faces . max } ` ,type:"dice"}],value:""});let n=[...this.results].filter(([,{value:s}])=>this.checkCondition(s,t)),r=0;await Promise.all(n.map(async([s,o])=>{if(i){let c=await this.getValue(),l=0;for(o.modifiers.add("!"),o.value+=c,o.display= ` $ { o . value } ` ,this.results.set(s,o);l<e&&this.check
$ { this . result } = $ { this . resultText } ` : ` $ { this . original }
$ { this . resultText } ` :this.expectedValue==="Average"?this.displayFixedText? ` $ { this . original }
$ { this . result } = average : $ { this . resultText } ` : ` $ { this . original }
average : $ { this . resultText } ` : ` $ { this . original }
empty ` }allowAverage(){let t=i=>i.allowAverage();return this.dynamic.every(t)}async build(){if(this.resultEl.empty(),this.expectedValue==="Average"&&!this.shouldRender){if(this.allowAverage()){for(let r of this.dynamic){let s=r.average(),o=new Map;for(let c=0;c<r.rolls;c++)o.set(c,s);r.setResults(o)}this.calculate()}else this.expectedValue="Roll";this.result=Math.floor(this.result),this.setTooltip()}let t=this.result;switch(this.round){case"None":{t=Math.trunc(t*100)/100;break}case"Normal":{t=Math.round(t);break}case"Up":{t=Math.ceil(t);break}case"Down":{t=Math.floor(t);break}}let i=this.signed&&t>0?"+":"",n;this.expectedValue==="None"&&!this.shouldRender?(this.showDice?n=[""]:n=[" \x A0"],this.showFormula&&n.unshift(this.original+" -> ")):(n=[ ` $ { i } $ { t } ` ],this.showFormula&&n.unshift(this.inlineText)),this.expectedValue="Roll",this.displayFixedText?this.resultEl.setText(this.fixedText):this.resultEl.setText(n.join("")+this.stunted),this.result===this.max?this.containerEl.addClass("is-max"):this.containerEl.removeClass("is-max"),this.result===this.min?this.containerEl.addClass("is-min"):this.containerEl.removeClass("is-min")}async onClick(t){t.stopPropagation(),t.stopImmediatePropagation(),t.getModifierState("Alt")?this.expectedValue="Average":t.getModifierState("Control")&&(this.expectedValue="None"),t.getModifierState("Shift")?(await this.roll(!0),this.hasRunOnce=!0):window.getSelection()?.isCollapsed&&await this.roll()}get dynamic(){return this.dice.filter(t=>!t.static)}get static(){return this.dice.filter(t=>t.static)}get isStatic(){return this.dice.every(t=>t.static)}rollSync(){this.stunted="",this.buildDiceTree();for(let t of this.dice)t.rollSync();return this.calculate(),this._tooltip=null,this.render(),this.trigger("new-result"),this.hasRunOnce=!0,this.result}setSpinner(){this.resultEl.empty(),(0,B2.setIcon)(this.resultEl.createDiv("should-spin"),"loader-2")}async renderDice(){this.isRendering=!0,this.setTooltip(),this.setSpinner();let t=[];for(let i of this.dice)t.push(new Promise(async n=>{await i.render(),n()}));await Promise.all(t),this.isRendering=!1,this.setTooltip()}buildDiceTree(){let t=0;for(let i of this.lexemes)switch(i.type){case"+":case"*":case"/":case"^":case"-":case"math":continue;case"u":{let n=this.dice[t-1],r=i.value?Number(i.value):1;n.modifiers.set("u",{data:r,conditionals:[],value:i.text});break}case"kh":{let n=this.dice[t-1],r=i.value?Number(i.value):1;n.modifiers.set("kh",{data:r,conditionals:[],value:i.text});break}case"dl":{let n=this.dice[t-1],r=i.value?Number(i.value):1;r=n.rolls-r,n.modifiers.set("kh",{data:r,conditionals:[],value:i.text});break}case"kl":{let n=this.dice[t-1],r=i.value?Number(i.value):1;n.modifiers.set("kl",{data:r,conditionals:[],value:i.text});break}case"dh":{let n=this.dice[t-1],r=i.value?Number(i.value):1;r=n.rolls-r,n.modifiers.set("kl",{data:r,conditionals:[],value:i.text});break}case"!":{let n=this.dice[t-1],r=Number(i.value)||1;n.modifiers.set("!",{data:r,conditionals:i.conditions??[],value:i.text});break}case"!!":{let n=this.dice[t-1],r=Number(i.value)||1;n.modifiers.set("!!",{data:r,conditionals:i.conditions??[],value:i.text});break}case"r":{let n=this.dice[t-1],r=Number(i.value)||1;n.modifiers.set("r",{data:r,conditionals:i.conditions??[],value:i.text});break}case"sort":{let n=this.dice[t-1],r=Number(i.value);n.modifiers.set("sort",{data:r,conditionals:i.conditions??[],value:i.value});break}case"dice":{if(i.parenedDice&&/^d/.test(i.value)&&this.stack.length){let n=this.stack.pop();i.value= ` $ { n . result } $ { i . value } ` ,this.dice[t]=new $ t(i.value,this.renderer,i)}this.dice[t]||(this.dice[t]=new $ t(i.value,this.renderer,i)),t++;break}case"stunt":{this.dice[t]||(this.dice[t]=new q1(i.value,this.renderer,i)),t++;break}case"%":{this.dice[t]||(this.dice[t]=new wa(i.value,this.renderer,i)),t++;break}}}async roll(t){if(this.stunted="",this.stackCopy=[],this.dice.length||this.buildDiceTree(),this.renderer.stop(),this.dice.forEach(i=>i.shouldRender=!1),t||this.shouldRender&&this.hasRunOnce)await this.renderDice();else for(let i of this.dice)await i.roll();return this.calculate(
Result : $ { this . result } ` ),this.trigger("new-result"),this.hasRunOnce=!0,this.result}calculate(){let t=0;for(let n of this.lexemes)switch(n.type){case"+":case"-":case"*":case"/":case"^":case"math":{let r=this.stack.pop(),s=this.stack.pop();r instanceof q1&&r.doubles&&(this.stunted= ` - $ { r . results . get ( 0 ) . value } Stunt Points ` ),s instanceof q1&&s.doubles&&(this.stunted= ` - $ { s . results . get ( 0 ) . value } Stunt Points ` );let o=this.operators[n.value](s.result,r.result),c=this.operators[n.value](this.minStack.pop(),this.minStack.pop()),l=this.operators[n.value](this.maxStack.pop(),this.maxStack.pop());this.stackCopy.push(n.value),this.stack.push(new $ t( ` $ { o } ` ,this.renderer,n)),this.minStack.push(c),this.maxStack.push(l);break}case"stunt":case"%":case"dice":this.stack.push(this.dice[t]),this.stackCopy.push(this.dice[t]),this.minStack.push(this.dice[t].getMinPossible()),this.maxStack.push(this.dice[t].getMaxPossible()),t++;default:continue}let i=this.stack.pop();this.min=this.minStack.pop(),this.max=this.maxStack.pop(),i instanceof q1&&i.doubles&&(this.stunted= ` - $ { i . results . get ( 0 ) . value } Stunt Points ` ),this.result=i.result}recalculate(t=!1){let i=[],n=0;if(!this.stackCopy.length)return this.roll();for(let r of this.stackCopy)if(typeof r=="string"){let s=i.pop(),o=i.pop(),c=this.operators[r](o.result,s.result);i.push(new $ t( ` $ { c } ` ,this.renderer))}else i.push(r),r instanceof $ t&&this.stackCopy.indexOf(r)!=this.stackCopy.length-1&&t&&r.applyModifiers();i.length&&i[0]instanceof $ t&&(t&&i[0].applyModifiers(),n+=i[0].result),this.result=n,this.render()}toResult(){return{type:"dice",result:this.result,tooltip:this.tooltip}}async applyResult(t){t.type==="dice"&&(t.result&&(this.result=t.result),t.tooltip&&(this._tooltip=t.tooltip),await this.render())}setResult(t){}};var P2=require("obsidian");function m9(a){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789",i=t.length;for(let n=0;n<a;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function g9(a){return ` dice - $ { m9 ( 4 ) } ` }var Si=class extends un{constructor(t,i,n,r,s=!0,o=t.data.showDice){super(t,i,n,r,o);this.plugin=t;this.original=i;this.lexeme=n;this.inline=s}async getReplacer(){let t=await this.getBlockId();return t? ` ! [ [ $ { this . path } # ^ $ { t } ] ] ` :""}get tooltip(){return ` $ { this . original }
$ { this . path } ` }async build(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.inline&&this.resultEl.createSpan({text:this.inlineText}),!this.results||!this.results.length){this.resultEl.createDiv({cls:"dice-no-results",text:"No results."});return}this.plugin.data.copyContentButton&&this.copy.removeClass("no-show");for(let t of this.results){this.resultEl.onclick=async n=>{if(n&&n.getModifierState("Control")||n.getModifierState("Meta")){n.stopPropagation();return}};let i=this.resultEl.createDiv({cls:this.getEmbedClass()});if(!this.plugin.data.displayResultsInline){let n="type"in t?t.type:"List Item";i.setAttrs({"aria-label": ` $ { this . file . basename } : $ { n } ` })}if(!t){i.createDiv({cls:"dice-no-results",text:"No results."});continue}if(P2.MarkdownRenderer.render(app,this.displayFromCache(t),i.createDiv(),this.source,new P2.Component),this.plugin.data.copyContentButton&&this.results.length>1){let n=i.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});n.addEventListener("click",r=>{r.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(t).trim()).then(async()=>{new P2.Notice("Result copied to clipboard.")})}),(0,P2.setIcon)(n,U1)}}}async load(){await this.getOptions()}displayFromCache(...t){let i=[];for(let n of t)i.push(this.content.slice(n.position.start.offset,n.position.end.offset));return i.join( `
` )}transformResultsToString(){return this.displayFromCache(...this.results)}async getBlockId(){this.result||await this.roll();let t=this.cache.blocks??{},i=Object.entries(t).find(([n,r])=>P8(r.position,this.result.position));if(!i){let n= ` $ { g9 ( 4 ) } ` ,r= ` $ { this . content . slice ( 0 , this . result . position . end . offset + 1 ) } ^ $ { n } $ { this . content . slice ( this . result . position . end . offset ) } ` ;return this.watch=!1,this.plugin.app.vault.modify(this.file,r),n}return i[0]}getPath(){let{groups:t}=this.lexeme.value.match(ga)??{},{roll:i=1,link:n,types:r}=t??{};if(!n)throw new Error("Could not parse link.");this.rolls=(i&&!isNaN(Number(i))&&Number(i))??1,this.path=decodeURIComponent(n.replace(/( \[ | \] | \( | \) )/g,"")),this.types=r?.split(","),this.levels=r?.split(",").map(s=>/heading \- \d +/.test(s)?s.split("-").pop():null).filter(s=>s),this.types=r?.split(",").map(s=>/heading \- \d +/.test(s)?s.split("-").shift():s)}async getOptions(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");this.content=await this.plugin.app.vault.cachedRead(this.file),this.options=this.cache.sections.filter(({type:t,position:i})=>this.types?t=="heading"&&this.types.includes(t)&&this.levels.length?(this.cache.headings??[]).filter(({level:r})=>this.levels.includes( ` $ { r } ` )).some(({position:r})=>P8(r,i)):this.types.includes(t):!["yaml","thematicBreak"].includes(t)),this.types&&this.types.includes("listItem")&&this.options.push(...this.cache.listItems),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((t,i)=>{if(!this.loaded)this.on("loaded",()=>{let n=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let r=n[this.getRandomBetween(0,n.length-1)];return n.splice(n.indexOf(r),1),r}).filter(r=>r),this.render(),this.trigger("new-result"),this.result=this.results[0],t(this.results[0])});else{let n=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let r=n[this.getRandomBetween(0,n.length-1)];return n.splice(n.indexOf(r),1),r}).filter(r=>r),this.render(),this.trigger("new-result"),this.result=this.results[0],t(this.results[0])}})}toResult(){return{type:"section",result:this.results}}async applyResult(t){t.type==="section"&&(t.result&&(this.results=t.result),await this.render())}},P8=(a,e)=>a.start.col==e.start.col&&a.start.line==e.start.line&&a.start.offset==e.start.offset;var a2=require("obsidian");var y0=class{constructor(){this.result="";this.combinedTooltip=""}},Vr=class a extends Hr{constructor(){super(...arguments);this.combinedTooltip="";this.prettyTooltip=""}getPath(){let{groups:t}=this.lexeme.value.match(F8)??{},{diceRoll:i="1",link:n,block:r,header:s}=t??{};if(!n||!r)throw new Error("Could not parse link.");let o=i.match(/( \d *?)[Dd] $ /);if(o){let[,c="1"]=o;this.rollsFormula=c}else this.rollsFormula=i;this.rolls=1,this.path=decodeURIComponent(n.replace(/( \[ | \] | \( | \) )/g,"")),this.block=r.replace(/( \^ |#)/g,"").trim().toLowerCase(),this.header=s}get tooltip(){return this.prettyTooltip}async getReplacer(){return this.result}async build(){this.resultEl.empty();let t=[this.result];this.plugin.data.displayResultsInline&&t.unshift(this.inlineText);let i=createSpan();await a2.MarkdownRenderer.renderMarkdown(t.join(""),i,this.source,new a2.Component);let n=this.resultEl.createSpan("embedded-table-result");i.childElementCount==1&&i.firstElementChild instanceof HTMLParagraphElement?n.append(...Array.from(i.firstElementChild.childNodes)):n.append(...Array.from(i.childNodes))}prettify(t){let i=/(.*?)( \( | \) |;| \| \| )(.*)/,n=" ",r=0,s="",o=t,c;for(;c=o.match(i);){let[,l,h,u]=c;s+=l,h==")"?(r--,s+= `
` ,s+=n.repeat(r),s+=")"):(h=="("?(r++,s+="("):h==";"?s+=",":h=="||"&&(s+="|"),s+= `
` ,s+=n.repeat(r)),o=u}return s+=o,s}async getSubResult(t){let i=new y0;typeof t=="number"?i.result=t.toString():i.result=t;let n=[];if(typeof t=="string"){let r=/(?: \` dice:)(.*?)(?: \` )/g,s=t.matchAll(r);for(let o of s){let c=o[1].trim(),l=await this.plugin.getRoller(c,this.source);await l.roll();let h=await this.getSubResult(l.result),u;if(h.result instanceof a2.TFile?u=h.result.basename:u=h.result,i.result=i.result.replace(o[0],u),l instanceof a)n.push(l.combinedTooltip);else{let[f,d]=l.tooltip.split( `
` );n.push(f+" --> "+d)}}}return i.combinedTooltip=n.join(";"),i}async getResult(){let t=[],i=[],n=this.original;if(this.rollsFormula)try{let r=await this.plugin.getRoller(this.rollsFormula,this.source);if(!(r instanceof Gt))return this.prettyTooltip="TableRoller only supports dice rolls to select multiple elements.",new a2.Notice(this.prettyTooltip),"ERROR";let s=r;await s.roll(),this.rolls=s.result,s.isStatic||(n=n.replace(this.rollsFormula, ` $ { this . rollsFormula . trim ( ) } -- > $ { s . resultText } > ` ))}catch{return this.prettyTooltip= ` TableRoller : '${this.rollsFormula}' is not a valid dice roll . ` ,new a2.Notice(this.prettyTooltip),"ERROR"}for(let r=0;r<this.rolls;r++){let s="",o,c="";if(this.isLookup){let l=await this.lookupRoller.roll(),h=this.lookupRanges.find(([u])=>u[1]===void 0&&l===u[0]||l>=u[0]&&u[1]>=l);h&&(s=this.lookupRoller.original.trim()+" --> "+ ` $ { this . lookupRoller . resultText } $ { this . header ? " | " + this . header : "" } ` .trim(),c=h[1])}else{let l=[...this.options],h=this.getRandomBetween(0,l.length-1);s=l.length+" rows --> [row "+(h+1)+"]",c=l[h]}o=await this.getSubResult(c),t.push(o.result),o.combinedTooltip&&(s+=" > ("+o.combinedTooltip+")"),i.push(s)}return i.length==0?this.combinedTooltip=n:i.length==1?this.combinedTooltip=n+" "+i.join(""):this.combinedTooltip=n+" ==> ("+i.join(" ||")+")",this.prettyTooltip=this.prettify(this.combinedTooltip),t.join("||")}async roll(){return new Promise(async t=>{this.loaded?(this.result=await this.getResult(),this.render(),this.trigger("new-result"),t(this.result)):this.on("loaded",async()=>{this.result=await this.getResult(),this.render(),this.trigger("new-result"),t(this.result)})})}async load(){await this.getOptions()}async getOptions(){if(this.cache=this.plugin.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.blocks||!(this.block in this.cache.blocks))throw new Error( ` Could not read file cache . Does the block reference exist ?
$ { this . path } > $ { this . block } ` );let t=this.cache.sections?.find(r=>r.position==this.cache.blocks[this.block].position),i=this.cache.blocks[this.block].position,n=await this.plugin.app.vault.cachedRead(this.file);if(this.content=n.slice(i.start.offset,i.end.offset),t&&t.type==="list")this.options=this.content.split( `
` );else{let r=x9(this.content);if(r.columns.size===2&&/dice: \s *([ \s \S ]+) \s *?/.test(Array.from(r.columns.keys())[0])){let s=await this.plugin.getRoller(Array.from(r.columns.keys())[0].split(":").pop().replace(/ \` /g,""),this.source);s instanceof Gt&&(this.lookupRoller=s,this.lookupRanges=r.rows.map(o=>{let[c,l]=o.replace(/ \\ \| /g,"{ESCAPED_PIPE}").split("|").map(f=>f.replace(/{ESCAPED_PIPE}/g," \\ |")).map(f=>f.trim()),[,h,u]=c.match(/( \d +)(?:[^ \d ]+?( \d +))?/)??[];if(!(!h&&!u))return[[Number(h),u?Number(u):void 0],l]}),this.isLookup=!0)}if(this.header==="xy"&&!r.columns.has("xy")){this.options=[];for(let s of Array.from(r.columns.values()).slice(1))this.options.push(...s)}else if(this.header&&r.columns.has(this.header))this.options=r.columns.get(this.header);else{if(this.header)throw new Error( ` Header $ { this . header } was not found in table $ { this . path } > $ { this . block } . ` );this.options=r.rows}}this.loaded=!0,this.trigger("loaded")}toResult(){return{type:"table",result:this.result}}async applyResult(t){t.type==="table"&&(t.result&&(this.result=t.result),await this.render())}},v9=/^ \| ?([ \s \S ]+?) \| ? $ /,I8=/ \| /g;function x9(a){let e=a.split( `
` ),i=e.map(s=>(s.trim().match(v9)??[,s.trim()])[1])[0].replace(" \\ |","{ESCAPED_PIPE}").split(I8),n=[],r=[];for(let s in i){let o=i[s];o.trim().length||(o=s),r.push([o.trim(),[]])}for(let s of e.slice(2)){let o=s.trim().replace(/ \\ \| /g,"{ESCAPED_PIPE}").split(I8).map(c=>c.replace(/{ESCAPED_PIPE}/g," \\ |")).map(c=>c.trim()).filter(c=>c.length);n.push(o.join(" | "));for(let c in o){let l=o[c].trim();!l.length||!r[c]||r[c][1].push(l)}}return{columns:new Map(r),rows:n}}var I2=require("obsidian");var Rr=class extends un{constructor(t,i,n,r,s=!0,o=t.data.showDice){super(t,i,n,r,o);this.plugin=t;this.original=i;this.lexeme=n}async getReplacer(){return this.result}get tooltip(){return ` $ { this . original }
$ { this . path } ` }async build(){if(this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.inline&&this.resultEl.createSpan({text:this.inlineText}),!this.results||!this.results.length){this.resultEl.createDiv({cls:"dice-no-results",text:"No results."});return}this.plugin.data.copyContentButton&&this.copy.removeClass("no-show");for(let t of this.results){this.resultEl.onclick=async n=>{if(n&&n.getModifierState("Control")||n.getModifierState("Meta")){n.stopPropagation();return}};let i=this.resultEl.createDiv({cls:this.getEmbedClass()});if(!t){i.createDiv({cls:"dice-no-results",text:"No results."});continue}if(I2.MarkdownRenderer.renderMarkdown(t,i.createDiv(),this.source,new I2.Component),this.plugin.data.copyContentButton&&this.results.length>1){let n=i.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});n.addEventListener("click",r=>{r.stopPropagation(),navigator.clipboard.writeText(t).then(async()=>{new I2.Notice("Result copied to clipboard.")})}),(0,I2.setIcon)(n,U1)}}}transformResultsToString(){return this.results.join( `
` )}async load(){await this.getOptions()}getPath(){let{groups:t}=this.lexeme.value.match(ga)??{},{roll:i=1,link:n,types:r}=t??{};if(!n)throw new Error("Could not parse link.");this.rolls=(i&&!isNaN(Number(i))&&Number(i))??1,this.path=n.replace(/( \[ | \] )/g,""),this.types=r?.split(",")}async getOptions(){if(this.content=await this.plugin.app.vault.cachedRead(this.file),!this.content)throw new Error("Could not read file cache.");this.options=this.content.trim().split( `
` ).map(t=>t.trim()).filter(t=>t&&t.length),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((t,i)=>{if(!this.loaded)this.on("loaded",()=>{let n=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let r=n[this.getRandomBetween(0,n.length-1)];return n.splice(n.indexOf(r),1),r}).filter(r=>r),this.render(),this.trigger("new-result"),t(this.results[0])});else{let n=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let r=n[this.getRandomBetween(0,n.length-1)];return n.splice(n.indexOf(r),1),r}).filter(r=>r),this.render(),this.trigger("new-result"),t(this.results[0])}})}toResult(){return{type:"section",result:this.results}}async applyResult(t){t.type==="section"&&(t.result&&(this.results=t.result),await this.render())}};var k8=require("obsidian");var _i=require("obsidian");var Ma=class extends F2{constructor(t,i,n,r,s=t.data.showDice){super(t,i,[n],s);this.plugin=t;this.original=i;this.lexeme=n;this.source=r;this.isLink=!1;this.loaded=!1;this.guardDataview()}async getReplacer(){return this.isLink? ` [ [ $ { this . result . file . basename } ] ] ` :await this.result.getReplacer()}guardDataview(){if(!this.plugin.canUseDataview)throw new _i.Notice("A query can only be rolled with the Dataview plugin enabled."),new Error("A query can only be rolled with the Dataview plugin enabled.")}initialize(){let{roll:t=1,query:i,types:n}=this.lexeme.value.match(this.regex).groups;this.base=i,this.rolls=Number(t),this.types=n,this.types&&(this.isLink=this.types.includes("link"),this.types=this.types.replace("link","")),!this.isLink&&this.plugin.data.displayAsEmbed&&this.containerEl.addClasses(["has-embed","markdown-embed"]),this.getFiles()}get typeText(){return this.types?.length? ` | $ { this . types } ` :""}async getFiles(){if(!this.plugin.dataviewAPI){new _i.Notice("Dice Roller: Dataview must be installed and enabled to use query rollers.");return}await this.plugin.dataviewReady();let t=await this.plugin.dataviewAPI.query(this.query);if(!t.successful)throw new Error( ` No files found with that query . Is the query correct ?
` +this.query);let i=new Set(t.value.values.reduce((s,o)=>(o.type=="file"&&s.push(o.path),s),[]));if(i&&i.delete(this.source),!i||!i.size)throw new Error( ` No files found with that query . Is the query correct ?
` +this.query);let n=Array.from(i).map(s=> ` [ [ $ { s } ] ] $ { this . typeText } ` );this.results=[];let r=[];for(let s of n)r.push(new Promise(async o=>{let c=new Si(this.plugin,s,{...this.lexeme,value:s,type:"section"},this.source,!1);this.results.push(c),o()}));await Promise.all(r),this.loaded=!0,this.trigger("loaded")}async build(){this.resultEl.empty(),this.plugin.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText});let t=[],i=new Map(this.results.map((n,r)=>[r,n]));for(let n=0;n<this.rolls;n++){if(!i.size)continue;let r=this.getRandomBetween(0,i.size),s=i.get(r);await s.roll(),t.push(s),i.delete(r)}if(this.isLink){let n=t.reduce((r,s,o,c)=>(r.push( ` [ [ $ { s . file . basename } ] ] ` ),c.length>1&&o!=c.length-1&&r.push(","),r),[]);_i.MarkdownRenderer.render(this.plugin.app,n.join(" "),this.resultEl,this.plugin.app.workspace.getActiveFile()?.path,new _i.Component)}else for(let n of t){let r=this.resultEl.createDiv();r.createEl("h5",{cls:"dice-file-name",text:n.file.basename}),r.appendChild(n.containerEl)}}async roll(){return new Promise((t,i)=>{this.loaded?(this.result=this.results[0],this.render(),this.trigger("new-result"),t(this.result)):this.on("loaded",()=>{this.result=this.results[0],this.render(),this.trigger("new-result"),t(this.result)})})}get tooltip(){return this.original}toResult(){return{type:"query",random:this.chosen,result:Object.fromEntries(this.results.map(t=>[t.path,t.toResult()]))}}async applyResult(t){if(t.type==="query"){if(t.result)for(let i in t.result){let n=this.results.find(r=>r.path===i);n&&n.applyResult(t.result[i])}t.random&&(this.random=t.random),await this.render()}}},Nr=class extends Ma{constructor(t,i,n,r,s=t.data.showDice){super(t,i,n,r,s);this.plugin=t;this.original=i;this.lexeme=n;this.source=r;this.regex=N8;this.initialize()}get query(){return this.base}},Fr=class extends Ma{constructor(t,i,n,r,s=t.data.showDice){super(t,i,n,r,s);this.plugin=t;this.original=i;this.lexeme=n;this.source=r;this.regex=v0;this.initialize()}get query(){return ` list from # $ { this . base } ` }};var ue=require("obsidian");var fn=require("obsidian"),y9=createSvg("svg",{attr:{viewBox:"0 0 500 500"}}),w9=createSvg("text",{attr:{class:"font",fill:"currentColor",x:"50%",y:"50%","text-anchor":"middle","dominant-baseline":"central"}}),za=(o=>(o.NONE="None",o.TRIANGLE="Triangle",o.SQUARE="Square",o.DIAMOND="Diamond",o.DODECAHEDRON="Dodecahedron",o.ICOSAHEDRON="Icosahedron",o.CIRCLE="Circle",o))(za||{}),O8=[{id:"dice-roller-d4",shape:"Triangle",formula:"d4",text:"4"},{id:"dice-roller-d6",shape:"Square",formula:"d6",text:"6"},{id:"dice-roller-d8",shape:"Diamond",formula:"d8",text:"8"},{id:"dice-roller-d10",shape:"Diamond",formula:"d10",text:"10"},{id:"dice-roller-d12",shape:"Dodecahedron",formula:"d12",text:"12"},{id:"dice-roller-d20",shape:"Icosahedron",formula:"d20",text:"20"},{id:"dice-roller-d100",shape:"Circle",formula:"d%",text:"%"}],w0=class extends fn.Component{#e(){return y9.cloneNode(!0)}#t(){return w9.cloneNode()}#i=new Set;registerIcon(e,t,i){this.#i.add(e);let n=this.#e(),r=this.#t();r.textContent=i,n.appendChild(r);let s;switch(t){case"Triangle":s=this.getTriangle();break;case"Square":{s=this.getSquare();break}case"Diamond":{s=this.getDiamond();break}case"Dodecahedron":{s=this.getDodecahedron();break}case"Icosahedron":{s=this.getIcosahedron();break}case"Circle":{s=this.getCircle();break}case"None":s=createSvg("defs")}n.appendChild(s),(0,fn.addIcon)(e,n.outerHTML),this.register(()=>(0,fn.removeIcon)(e))}getTriangle(){return this.#n("path",{d:"M244.6,49.3L40.3,403.2c-1.7,3-0.7,6.8,2.3,8.5c0.9,0.5,2,0.8,3.1,0.8h408.6c3.4,0,6.2-2.8,6.2-6.2 c0-1.1-0.3-2.2-0.8-3.1L255.4,49.3c-1.7-3-5.5-4-8.5-2.3C246,47.6,245.2,48.4,244.6,49.3z"})}getSquare(){return this.#n("rect",{x:"87.5",y:"87.5",width:"325",height:"325",rx:"10"})}getDiamond(){return this.#n("rect",{x:"102.75",y:"102.75",width:"294.51",height:"294.51",rx:"9.8",transform:"translate(-103.55 250) rotate(-45)"})}getDodecahedron(){return this.#n("path",{d:"M244.31,29.14,52,168.87a9.72,9.72,0,0,0-3.52,10.84l73.47,226.1a9.69,9.69,0,0,0,9.21,6.69H368.87a9.69,9.69,0,0,0,9.
` );l.length>1&&(o=o/l.length,s.font= ` $ { o } pt '${this.fontFace}' ` ,c=s.measureText("M").width*1.2,n-=c*l.length/2);for(let u=0,f=l.length;u<f;u++){let d=l[u].trim();s.fillText(l[u],r,n),(d=="6"||d=="9")&&s.fillText(" .",r,n),n+=c*1.5}let h=new ti(i);return h.needsUpdate=!0,i.detach(),h}getContext(e){let t=e.getContext("2d",{alpha:!0});t.clearRect(0,0,e.width,e.height);let i=e.width/(1+2*this.margin);return this.sides==100&&(i*=.75),t.font= ` $ { i } pt '${this.fontFace}' ` ,t.fillStyle=this.diceColor,t.fillRect(0,0,e.width,e.height),t.textAlign="center",t.textBaseline="middle",(this.sides==10||this.sides==100)&&(t.translate(e.width/2,e.height/2),t.rotate(60*Math.PI/180),t.translate(-e.width/2,-e.height/2)),t.fillStyle=this.textColor,{context:t,fontsize:i}}clone(){return{body:new Te({mass:this.mass,shape:this.shape}),geometry:this.geometry.clone(),values:this.values}}},y4=class extends v1{constructor(t,i,n={diceColor:"#171120",textColor:"#FF0000"},r){super(t,i,n,r);this.sides=20;this.tab=-.2;this.af=-Math.PI/4/2;this.chamfer=.955;this.vertices=[];this.faces=[[0,11,5,1],[0,5,1,2],[0,1,7,3],[0,7,10,4],[0,10,11,5],[1,5,9,6],[5,11,4,7],[11,10,2,8],[10,7,6,9],[7,1,8,10],[3,9,4,11],[3,4,2,12],[3,2,6,13],[3,6,8,14],[3,8,9,15],[4,9,5,16],[2,4,11,17],[6,2,10,18],[8,6,7,19],[9,8,1,20]];this.scaleFactor=1;this.values=[...Array(20).keys()];this.margin=1;this.mass=400;let s=(1+Math.sqrt(5))/2;this.vertices=[[-1,s,0],[1,s,0],[-1,-s,0],[1,-s,0],[0,-1,s],[0,1,s],[0,-1,-s],[0,1,-s],[s,0,-1],[s,0,1],[-s,0,-1],[-s,0,1]]}},w4=class extends v1{constructor(t,i,n={diceColor:"#7339BE",textColor:"#FFFFFF"},r){super(t,i,n,r);this.mass=350;this.sides=12;this.tab=.2;this.af=-Math.PI/4/2;this.chamfer=.968;this.vertices=[];this.faces=[[2,14,4,12,0,1],[15,9,11,19,3,2],[16,10,17,7,6,3],[6,7,19,11,18,4],[6,18,2,0,16,5],[18,11,9,14,2,6],[1,17,10,8,13,7],[1,13,5,15,3,8],[13,8,12,4,5,9],[5,4,14,9,15,10],[0,12,8,10,16,11],[3,19,7,17,1,12]];this.scaleFactor=.9;this.values=[...Array(12).keys()];this.margin=1;let s=(1+Math.sqrt(5))/2,o=1/s;this.vertices=[[0,o,s],[0,o,-s],[0,-o,s],[0,-o,-s],[s,0,o],[s,0,-o],[-s,0,o],[-s,0,-o],[o,s,0],[o,-s,0],[-o,s,0],[-o,-s,0],[1,1,1],[1,1,-1],[1,-1,1],[1,-1,-1],[-1,1,1],[-1,1,-1],[-1,-1,1],[-1,-1,-1]]}},b4=class extends v1{constructor(t,i,n={diceColor:"#c74749",textColor:"#FFFFFF"},r){super(t,i,n,r);this.mass=350;this.sides=10;this.tab=0;this.af=-Math.PI*6/5;this.chamfer=.945;this.vertices=[];this.faces=[[5,7,11,0],[4,2,10,1],[1,3,11,2],[0,8,10,3],[7,9,11,4],[8,6,10,5],[9,1,11,6],[2,0,10,7],[3,5,11,8],[6,4,10,9],[1,0,2,-1],[1,2,3,-1],[3,2,4,-1],[3,4,5,-1],[5,4,6,-1],[5,6,7,-1],[7,6,8,-1],[7,8,9,-1],[9,8,0,-1],[9,0,1,-1]];this.scaleFactor=.9;this.values=[...Array(10).keys()];this.margin=1;for(let s=0,o=0;s<10;++s,o+=Math.PI*2/10)this.vertices.push([Math.cos(o),Math.sin(o),.105*(s%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},M4=class extends v1{constructor(t,i,n={diceColor:"#7a2c2d",textColor:"#FFFFFF"},r){super(t,i,n,r);this.labels=["","00","10","20","30","40","50","60","70","80","90"];this.sides=100;this.mass=350;this.tab=0;this.af=-Math.PI*6/5;this.chamfer=.945;this.vertices=[];this.faces=[[5,7,11,0],[4,2,10,1],[1,3,11,2],[0,8,10,3],[7,9,11,4],[8,6,10,5],[9,1,11,6],[2,0,10,7],[3,5,11,8],[6,4,10,9],[1,0,2,-1],[1,2,3,-1],[3,2,4,-1],[3,4,5,-1],[5,4,6,-1],[5,6,7,-1],[7,6,8,-1],[7,8,9,-1],[9,8,0,-1],[9,0,1,-1]];this.scaleFactor=.9;this.values=[...Array(10).keys()];this.margin=1;for(let s=0,o=0;s<10;++s,o+=Math.PI*2/10)this.vertices.push([Math.cos(o),Math.sin(o),.105*(s%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},z4=class extends v1{constructor(t,i,n={diceColor:"#5eb0c5",textColor:"#FFFFFF"},r){super(t,i,n,r);this.mass=340;this.sides=8;this.tab=0;this.af=-Math.PI/4/2;this.chamfer=.965;this.vertices=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];this.faces=[[0,2,4,1],[0,4,3,2],[0,3,5,3],[0,5,2,4],[1,3,4,5],[1,4,2,6],[1,2,5,7],[1,5,3,8]];this.scaleFactor=1;this.values=[...Array(8).keys()];this.margin=1.2}},C4=class extends v1{constructor(t,i,n={diceColor:"#d68316",textColor:"#FFFFFF"},r){
a ` ,"a", ` a
a ` ,"x","s", ` s
a ` ,"s", ` s
a ` , ` s
s ` , ` s
a ` , ` s
s ` ,""];this.setColor({diceColor:"#FEF035",textColor:"#000000"})}},L4=class extends _4{constructor(t,i,n=ii,r){super(t,i,n,r);this.labels=["","", ` t
t ` ,"t", ` t
t ` ,"t", ` t
f ` ,"f", ` t
f ` ,"f", ` f
f ` ,"y", ` f
f ` ,""];this.setColor({diceColor:"#751317",textColor:"#FFFFFF"})}},T4=class extends ss{constructor(){super(...arguments);this.mass=340;this.sides=8;this.tab=0;this.af=-Math.PI/4/2;this.chamfer=.965;this.vertices=[[1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1]];this.faces=[[0,2,4,1],[0,4,3,2],[0,3,5,3],[0,5,2,4],[1,3,4,5],[1,4,2,6],[1,2,5,7],[1,5,3,8]];this.scaleFactor=1;this.values=[...Array(8).keys()];this.margin=1.2}},D4=class extends T4{constructor(t,i,n=ii,r){super(t,i,n,r);this.labels=["","","s","a", ` s
a ` , ` s
s ` ,"a","s", ` a
a ` ,""];this.setColor({diceColor:"#46AC4E",textColor:"#000000"})}},H4=class extends T4{constructor(t,i,n=ii,r){super(t,i,n,r);this.labels=["","","t","f", ` f
t ` ,"t","", ` t
t ` , ` f
f ` ,"t",""];this.setColor({diceColor:"#52287E",textColor:"#FFFFFF"})}},V4=class extends ss{constructor(){super(...arguments);this.mass=300;this.tab=.1;this.af=Math.PI/4;this.chamfer=.96;this.vertices=[[-1,-1,-1],[1,-1,-1],[1,1,-1],[-1,1,-1],[-1,-1,1],[1,-1,1],[1,1,1],[-1,1,1]];this.faces=[[0,3,2,1,1],[1,2,6,5,2],[0,1,5,4,3],[3,7,6,2,4],[0,4,7,3,5],[4,5,6,7,6]];this.scaleFactor=.9;this.sides=6;this.margin=1;this.values=[null,1,-1,0,1,-1,0]}},R4=class extends V4{constructor(t,i,n=ii,r){super(t,i,n,r);this.labels=["","","","","s", ` s
a ` , ` a
a ` ,"a","",""];this.setColor({diceColor:"#76CDDB",textColor:"#000000"})}},N4=class extends V4{constructor(t,i,n=ii,r){super(t,i,n,r);this.labels=["","","","t","f","",""];this.setColor({diceColor:"#000000",textColor:"#FFFFFF"})}};var kp={pos:{x:0+100*Math.random(),y:0+100*Math.random(),z:250},velocity:{x:600*(Math.random()*2+1),y:750*(Math.random()*2+1),z:0},angular:{x:200*Math.random(),y:200*Math.random(),z:100*Math.random()},axis:{x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()}},ni=class{constructor(e,t,i){this.w=e;this.h=t;this.data=i;this.scale=50;this.stopped=!1;this.iterations=0;this.vector={...kp};this.exploded=!1;this.rerolled=0;this.geometry=i.geometry,this.body=i.body}generateVector(e){let t=Math.sqrt(e.x*e.x+e.y*e.y),i=(Math.random()+5)*t,n={x:e.x/t,y:e.y/t},r=this.makeRandomVector(n),s={x:this.w*(r.x>0?-1:1)*.9,y:this.h*(r.y>0?-1:1)*.9,z:Math.random()*200+200},o=Math.abs(r.x/r.y);o>1?s.y/=o:s.x*=o;let c=this.makeRandomVector(n),l={x:c.x*i,y:c.y*i,z:-10},h={x:-(Math.random()*r.y*5+this.inertia*r.y),y:Math.random()*r.x*5+this.inertia*r.x,z:0},u={x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()};return{pos:s,velocity:l,angular:h,axis:u}}makeRandomVector(e){let t=Math.random()*Math.PI/5-Math.PI/5/2,i={x:e.x*Math.cos(t)-e.y*Math.sin(t),y:e.x*Math.sin(t)+e.y*Math.cos(t)};return i.x==0&&(i.x=.01),i.y==0&&(i.y=.01),i}get buffer(){return this.geometry.geometry}get result(){return this.getUpsideValue()}getUpsideValue(){let e=new Y(0,0,this.sides==4?-1:1),t,i=Math.PI*2,n=this.buffer.getAttribute("normal").array;for(let s=0,o=this.buffer.groups.length;s<o;++s){let c=this.buffer.groups[s];if(c.materialIndex==0)continue;let l=s*9,u=new Y(n[l],n[l+1],n[l+2]).clone().applyQuaternion(new Mt(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)).angleTo(e);u<i&&(i=u,t=c)}let r=t.materialIndex-1;return this.sides==10&&r==0&&(r=10),this.data.values?.[r]??r}shiftUpperValue(e){let t=this.geometry.geometry.clone(),i=this.getUpsideValue();for(let n=0,r=t.groups.length;n<r;++n){let s=t.groups[n].materialIndex;if(s!==0){for(s+=e-i-1;s>this.sides;)s-=this.sides;for(;s<1;)s+=this.sides;t.groups[n].materialIndex=s+1}}this.updateMaterialsForValue(e-i),this.geometry.geometry=t}resetBody(){return this.body.vlambda=new z,this.body.position=new z,this.body.previousPosition=new z,this.body.initPosition=new z,this.body.velocity=new z,this.body.initVelocity=new z,this.body.force=new z,this.body.torque=new z,this.body.quaternion=new Mt,this.body.initQuaternion=new Mt,this.body.angularVelocity=new z,this.body.initAngularVelocity=new z,this.body.interpolatedPosition=new z,this.body.interpolatedQuaternion=new Mt,this.body.inertia=new z,this.body.invInertia=new z,this.body.invInertiaWorld=new Z1,this.body.invInertiaSolve=new z,this.body.invInertiaWorldSolve=new Z1,this.body.wlambda=new z,this.body.updateMassProperties(),this}updateMaterialsForValue(e){}set(){this.geometry.position.set(this.body.position.x,this.body.position.y,this.body.position.z),this.geometry.quaternion.set(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)}recreate(e,t,i){this.w=t,this.h=i,this.vector=this.generateVector(e),this.stopped=!1,this.iterations=0,this.create()}create(){return this.body.position.set(this.vector.pos.x,this.vector.pos.y,this.vector.pos.z),this.body.quaternion.setFromAxisAngle(new z(this.vector.axis.x,this.vector.axis.y,this.vector.axis.z),this.vector.axis.w*Math.PI*2),this.body.angularVelocity.set(this.vector.angular.x,this.vector.angular.y,this.vector.angular.z),this.body.velocity.set(this.vector.velocity.x,this.vector.velocity.y,this.vector.velocity.z),this.body.linearDamping=.1,this.body.angularDamping=.1,this}},as=class extends ni{constructor(t,i,n,r){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=20;this.inertia=6;r&&(this.vector=this.generateVector(r)),this.create()}},os=class extends ni{constructor(t,i,n,r){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;r&&(this.vector=this.generateVector(r)),this.create()
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,Km= ` void main ( ) {
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
} ` ,N2=class extends xt{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Qm,this.fragmentShader=Km,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&(e.attributes!==void 0&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(e))}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=hr(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){let t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(let n in this.uniforms){let s=this.uniforms[n].value;s&&s.isTexture?t.uniforms[n]={type:"t",value:s.toJSON(e).uuid}:s&&s.isColor?t.uniforms[n]={type:"c",value:s.getHex()}:s&&s.isVector2?t.uniforms[n]={type:"v2",value:s.toArray()}:s&&s.isVector3?t.uniforms[n]={type:"v3",value:s.toArray()}:s&&s.isVector4?t.uniforms[n]={type:"v4",value:s.toArray()}:s&&s.isMatrix3?t.uniforms[n]={type:"m3",value:s.toArray()}:s&&s.isMatrix4?t.uniforms[n]={type:"m4",value:s.toArray()}:t.uniforms[n]={value:s}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;let i={};for(let n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}};N2.prototype.isShaderMaterial=!0;var Hs=class extends Ze{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new _e,this.projectionMatrix=new _e,this.projectionMatrixInverse=new _e}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this}getWorldDirection(e){this.updateWorldMatrix(!0,!1);let t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}};Hs.prototype.isCamera=!0;var Ht=class extends Hs{constructor(e=50,t=1,i=.1,n=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){let t=.5*this.getFilmHeight()/e;this.fov=A3*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(k6*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return A3*2*Math.atan(Math.tan(k6*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}setViewOffset(e,t,i,n,r,s){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=n,this.view.width=r,this.view.height=s,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(k6*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,r=-.5*n,s=this.view;if(this.view!==null&&this.vie
varying vec3 vWorldDirection ;
vec3 transformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir , 0.0 ) ) . xyz ) ;
}
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
}
` ,fragmentShader: `
uniform sampler2D tEquirect ;
varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vec3 direction = normalize ( vWorldDirection ) ;
vec2 sampleUV = equirectUv ( direction ) ;
gl _FragColor = texture2D ( tEquirect , sampleUV ) ;
}
` },n=new Ds(5,5,5),r=new N2({name:"CubemapFromEquirect",uniforms:hr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:zt,blending:fi});r.uniforms.tEquirect.value=t;let s=new Vt(n,r),o=t.minFilter;return t.minFilter===Xo&&(t.minFilter=It),new Vs(1,10,this).update(e,s),t.minFilter=o,s.geometry.dispose(),s.material.dispose(),this}clear(e,t,i,n){let r=e.getRenderTarget();for(let s=0;s<6;s++)e.setRenderTarget(this,s),e.clear(t,i,n);e.setRenderTarget(r)}};Co.prototype.isWebGLCubeRenderTarget=!0;var c3=new B,eg=new B,tg=new At,N1=class{constructor(e=new B(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,n){return this.normal.set(e,t,i),this.constant=n,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){let n=c3.subVectors(i,t).cross(eg.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(n,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){let e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(this.normal).multiplyScalar(-this.distanceToPoint(e)).add(e)}intersectLine(e,t){let i=e.delta(c3),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let r=-(e.start.dot(this.normal)+this.constant)/n;return r<0||r>1?null:t.copy(i).multiplyScalar(r).add(e.start)}intersectsLine(e){let t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){let i=t||tg.getNormalMatrix(e),n=this.coplanarPoint(c3).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}};N1.prototype.isPlane=!0;var jn=new yi,K4=new B,fr=class{constructor(e=new N1,t=new N1,i=new N1,n=new N1,r=new N1,s=new N1){this.planes=[e,t,i,n,r,s]}set(e,t,i,n,r,s){let o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(n),o[4].copy(r),o[5].copy(s),this}copy(e){let t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e){let t=this.planes,i=e.elements,n=i[0],r=i[1],s=i[2],o=i[3],c=i[4],l=i[5],h=i[6],u=i[7],f=i[8],d=i[9],p=i[10],v=i[11],x=i[12],g=i[13],m=i[14],M=i[15];return t[0].setComponents(o-n,u-c,v-f,M-x).normalize(),t[1].setComponents(o+n,u+c,v+f,M+x).normalize(),t[2].setComponents(o+r,u+l,v+d,M+g).normalize(),t[3].setComponents(o-r,u-l,v-d,M-g).normalize(),t[4].setComponents(o-s,u-h,v-p,M-m).normalize(),t[5].setComponents(o+s,u+h,v+p,M+m).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),jn.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(jn)}intersectsSprite(e){return jn.center.set(0,0,0),jn.radius=.7071067811865476,jn.applyMatrix4(e.matrixWorld),this.intersectsSphere(jn)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)<n)return!1;return!0}intersectsBox(e){let t=this.planes;for(let i=0;i<6;i++){let n=t[i];if(K4.x=n.normal.x>0?e.max.x:e.min.x,K4.y=n.normal.y>0?e.max.y:e.min.y,K4.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(K4)<0)return!1}return!0}containsPoint(e){let t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}};function Du(){let a=null,e=!1,t=null,i=null;function n(r,s){t(r,s),i=a.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!
diffuseColor . a *= texture2D ( alphaMap , vUv ) . g ;
# endif ` ,rg= ` # ifdef USE _ALPHAMAP
uniform sampler2D alphaMap ;
# endif ` ,sg= ` # ifdef USE _ALPHATEST
if ( diffuseColor . a < alphaTest ) discard ;
# endif ` ,ag= ` # ifdef USE _ALPHATEST
uniform float alphaTest ;
# endif ` ,og= ` # ifdef USE _AOMAP
float ambientOcclusion = ( texture2D ( aoMap , vUv2 ) . r - 1.0 ) * aoMapIntensity + 1.0 ;
reflectedLight . indirectDiffuse *= ambientOcclusion ;
# if defined ( USE _ENVMAP ) && defined ( STANDARD )
float dotNV = saturate ( dot ( geometry . normal , geometry . viewDir ) ) ;
reflectedLight . indirectSpecular *= computeSpecularOcclusion ( dotNV , ambientOcclusion , material . roughness ) ;
# endif
# endif ` ,cg= ` # ifdef USE _AOMAP
uniform sampler2D aoMap ;
uniform float aoMapIntensity ;
# endif ` ,lg="vec3 transformed = vec3( position );",hg= ` vec3 objectNormal = vec3 ( normal ) ;
# ifdef USE _TANGENT
vec3 objectTangent = vec3 ( tangent . xyz ) ;
# endif ` ,ug= ` vec3 BRDF _Lambert ( const in vec3 diffuseColor ) {
return RECIPROCAL _PI * diffuseColor ;
}
vec3 F _Schlick ( const in vec3 f0 , const in float f90 , const in float dotVH ) {
float fresnel = exp2 ( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ) ;
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ) ;
}
float V _GGX _SmithCorrelated ( const in float alpha , const in float dotNL , const in float dotNV ) {
float a2 = pow2 ( alpha ) ;
float gv = dotNL * sqrt ( a2 + ( 1.0 - a2 ) * pow2 ( dotNV ) ) ;
float gl = dotNV * sqrt ( a2 + ( 1.0 - a2 ) * pow2 ( dotNL ) ) ;
return 0.5 / max ( gv + gl , EPSILON ) ;
}
float D _GGX ( const in float alpha , const in float dotNH ) {
float a2 = pow2 ( alpha ) ;
float denom = pow2 ( dotNH ) * ( a2 - 1.0 ) + 1.0 ;
return RECIPROCAL _PI * a2 / pow2 ( denom ) ;
}
vec3 BRDF _GGX ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , const in vec3 f0 , const in float f90 , const in float roughness ) {
float alpha = pow2 ( roughness ) ;
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNL = saturate ( dot ( normal , lightDir ) ) ;
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float dotVH = saturate ( dot ( viewDir , halfDir ) ) ;
vec3 F = F _Schlick ( f0 , f90 , dotVH ) ;
float V = V _GGX _SmithCorrelated ( alpha , dotNL , dotNV ) ;
float D = D _GGX ( alpha , dotNH ) ;
return F * ( V * D ) ;
}
vec2 LTC _Uv ( const in vec3 N , const in vec3 V , const in float roughness ) {
const float LUT _SIZE = 64.0 ;
const float LUT _SCALE = ( LUT _SIZE - 1.0 ) / LUT _SIZE ;
const float LUT _BIAS = 0.5 / LUT _SIZE ;
float dotNV = saturate ( dot ( N , V ) ) ;
vec2 uv = vec2 ( roughness , sqrt ( 1.0 - dotNV ) ) ;
uv = uv * LUT _SCALE + LUT _BIAS ;
return uv ;
}
float LTC _ClippedSphereFormFactor ( const in vec3 f ) {
float l = length ( f ) ;
return max ( ( l * l + f . z ) / ( l + 1.0 ) , 0.0 ) ;
}
vec3 LTC _EdgeVectorFormFactor ( const in vec3 v1 , const in vec3 v2 ) {
float x = dot ( v1 , v2 ) ;
float y = abs ( x ) ;
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y ;
float b = 3.4175940 + ( 4.1616724 + y ) * y ;
float v = a / b ;
float theta _sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt ( max ( 1.0 - x * x , 1e-7 ) ) - v ;
return cross ( v1 , v2 ) * theta _sintheta ;
}
vec3 LTC _Evaluate ( const in vec3 N , const in vec3 V , const in vec3 P , const in mat3 mInv , const in vec3 rectCoords [ 4 ] ) {
vec3 v1 = rectCoords [ 1 ] - rectCoords [ 0 ] ;
vec3 v2 = rectCoords [ 3 ] - rectCoords [ 0 ] ;
vec3 lightNormal = cross ( v1 , v2 ) ;
if ( dot ( lightNormal , P - rectCoords [ 0 ] ) < 0.0 ) return vec3 ( 0.0 ) ;
vec3 T1 , T2 ;
T1 = normalize ( V - N * dot ( V , N ) ) ;
T2 = - cross ( N , T1 ) ;
mat3 mat = mInv * transposeMat3 ( mat3 ( T1 , T2 , N ) ) ;
vec3 coords [ 4 ] ;
coords [ 0 ] = mat * ( rectCoords [ 0 ] - P ) ;
coords [ 1 ] = mat * ( rectCoords [ 1 ] - P ) ;
coords [ 2 ] = mat * ( rectCoords [ 2 ] - P ) ;
coords [ 3 ] = mat * ( rectCoords [ 3 ] - P ) ;
coords [ 0 ] = normalize ( coords [ 0 ] ) ;
coords [ 1 ] = normalize ( coords [ 1 ] ) ;
coords [ 2 ] = normalize ( coords [ 2 ] ) ;
coords [ 3 ] = normalize ( coords [ 3 ] ) ;
vec3 vectorFormFactor = vec3 ( 0.0 ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 0 ] , coords [ 1 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 1 ] , coords [ 2 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 2 ] , coords [ 3 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 3 ] , coords [ 0 ] ) ;
float result = LTC _ClippedSphereFormFactor ( vectorFormFactor ) ;
return vec3 ( result ) ;
}
float G _BlinnPhong _Implicit ( ) {
return 0.25 ;
}
float D _BlinnPhong ( const in float shininess , const in float dotNH ) {
return RECIPROCAL _PI * ( shininess * 0.5 + 1.0 ) * pow ( dotNH , shininess ) ;
}
vec3 BRDF _BlinnPhong ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , const in vec3 specularColor , const in float shininess ) {
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float dotVH = saturate ( dot ( viewDir , halfDir ) ) ;
vec3 F = F _Schlick ( specularColor , 1.0 , dotVH ) ;
float G = G _BlinnPhong _Implicit ( ) ;
float D = D _BlinnPhong ( shininess , dotNH ) ;
return F * ( G * D ) ;
}
# if defined ( USE _SHEEN )
float D _Charlie ( float roughness , float dotNH ) {
float alpha = pow2 ( roughness ) ;
float invAlpha = 1.0 / alpha ;
float cos2h = dotNH * dotNH ;
float sin2h = max ( 1.0 - cos2h , 0.0078125 ) ;
return ( 2.0 + invAlpha ) * pow ( sin2h , invAlpha * 0.5 ) / ( 2.0 * PI ) ;
}
float V _Neubelt ( float dotNV , float dotNL ) {
return saturate ( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ) ;
}
vec3 BRDF _Sheen ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , vec3 sheenColor , const in float sheenRoughness ) {
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNL = saturate ( dot ( normal , lightDir ) ) ;
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float D = D _Charlie ( sheenRoughness , dotNH ) ;
float V = V _Neubelt ( dotNV , dotNL ) ;
return sheenColor * ( D * V ) ;
}
# endif ` ,fg= ` # ifdef USE _BUMPMAP
uniform sampler2D bumpMap ;
uniform float bumpScale ;
vec2 dHdxy _fwd ( ) {
vec2 dSTdx = dFdx ( vUv ) ;
vec2 dSTdy = dFdy ( vUv ) ;
float Hll = bumpScale * texture2D ( bumpMap , vUv ) . x ;
float dBx = bumpScale * texture2D ( bumpMap , vUv + dSTdx ) . x - Hll ;
float dBy = bumpScale * texture2D ( bumpMap , vUv + dSTdy ) . x - Hll ;
return vec2 ( dBx , dBy ) ;
}
vec3 perturbNormalArb ( vec3 surf _pos , vec3 surf _norm , vec2 dHdxy , float faceDirection ) {
vec3 vSigmaX = vec3 ( dFdx ( surf _pos . x ) , dFdx ( surf _pos . y ) , dFdx ( surf _pos . z ) ) ;
vec3 vSigmaY = vec3 ( dFdy ( surf _pos . x ) , dFdy ( surf _pos . y ) , dFdy ( surf _pos . z ) ) ;
vec3 vN = surf _norm ;
vec3 R1 = cross ( vSigmaY , vN ) ;
vec3 R2 = cross ( vN , vSigmaX ) ;
float fDet = dot ( vSigmaX , R1 ) * faceDirection ;
vec3 vGrad = sign ( fDet ) * ( dHdxy . x * R1 + dHdxy . y * R2 ) ;
return normalize ( abs ( fDet ) * surf _norm - vGrad ) ;
}
# endif ` ,dg= ` # if NUM _CLIPPING _PLANES > 0
vec4 plane ;
# pragma unroll _loop _start
for ( int i = 0 ; i < UNION _CLIPPING _PLANES ; i ++ ) {
plane = clippingPlanes [ i ] ;
if ( dot ( vClipPosition , plane . xyz ) > plane . w ) discard ;
}
# pragma unroll _loop _end
# if UNION _CLIPPING _PLANES < NUM _CLIPPING _PLANES
bool clipped = true ;
# pragma unroll _loop _start
for ( int i = UNION _CLIPPING _PLANES ; i < NUM _CLIPPING _PLANES ; i ++ ) {
plane = clippingPlanes [ i ] ;
clipped = ( dot ( vClipPosition , plane . xyz ) > plane . w ) && clipped ;
}
# pragma unroll _loop _end
if ( clipped ) discard ;
# endif
# endif ` ,pg= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
uniform vec4 clippingPlanes [ NUM _CLIPPING _PLANES ] ;
# endif ` ,mg= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
# endif ` ,gg= ` # if NUM _CLIPPING _PLANES > 0
vClipPosition = - mvPosition . xyz ;
# endif ` ,vg= ` # if defined ( USE _COLOR _ALPHA )
diffuseColor *= vColor ;
# elif defined ( USE _COLOR )
diffuseColor . rgb *= vColor ;
# endif ` ,xg= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR )
varying vec3 vColor ;
# endif ` ,yg= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR ) || defined ( USE _INSTANCING _COLOR )
varying vec3 vColor ;
# endif ` ,wg= ` # if defined ( USE _COLOR _ALPHA )
vColor = vec4 ( 1.0 ) ;
# elif defined ( USE _COLOR ) || defined ( USE _INSTANCING _COLOR )
vColor = vec3 ( 1.0 ) ;
# endif
# ifdef USE _COLOR
vColor *= color ;
# endif
# ifdef USE _INSTANCING _COLOR
vColor . xyz *= instanceColor . xyz ;
# endif ` ,bg= ` # define PI 3.141592653589793
# define PI2 6.283185307179586
# define PI _HALF 1.5707963267948966
# define RECIPROCAL _PI 0.3183098861837907
# define RECIPROCAL _PI2 0.15915494309189535
# define EPSILON 1e-6
# ifndef saturate
# define saturate ( a ) clamp ( a , 0.0 , 1.0 )
# endif
# define whiteComplement ( a ) ( 1.0 - saturate ( a ) )
float pow2 ( const in float x ) { return x * x ; }
float pow3 ( const in float x ) { return x * x * x ; }
float pow4 ( const in float x ) { float x2 = x * x ; return x2 * x2 ; }
float max3 ( const in vec3 v ) { return max ( max ( v . x , v . y ) , v . z ) ; }
float average ( const in vec3 color ) { return dot ( color , vec3 ( 0.3333 ) ) ; }
highp float rand ( const in vec2 uv ) {
const highp float a = 12.9898 , b = 78.233 , c = 43758.5453 ;
highp float dt = dot ( uv . xy , vec2 ( a , b ) ) , sn = mod ( dt , PI ) ;
return fract ( sin ( sn ) * c ) ;
}
# ifdef HIGH _PRECISION
float precisionSafeLength ( vec3 v ) { return length ( v ) ; }
# else
float precisionSafeLength ( vec3 v ) {
float maxComponent = max3 ( abs ( v ) ) ;
return length ( v / maxComponent ) * maxComponent ;
}
# endif
struct IncidentLight {
vec3 color ;
vec3 direction ;
bool visible ;
} ;
struct ReflectedLight {
vec3 directDiffuse ;
vec3 directSpecular ;
vec3 indirectDiffuse ;
vec3 indirectSpecular ;
} ;
struct GeometricContext {
vec3 position ;
vec3 normal ;
vec3 viewDir ;
# ifdef USE _CLEARCOAT
vec3 clearcoatNormal ;
# endif
} ;
vec3 transformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir , 0.0 ) ) . xyz ) ;
}
vec3 inverseTransformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( vec4 ( dir , 0.0 ) * matrix ) . xyz ) ;
}
mat3 transposeMat3 ( const in mat3 m ) {
mat3 tmp ;
tmp [ 0 ] = vec3 ( m [ 0 ] . x , m [ 1 ] . x , m [ 2 ] . x ) ;
tmp [ 1 ] = vec3 ( m [ 0 ] . y , m [ 1 ] . y , m [ 2 ] . y ) ;
tmp [ 2 ] = vec3 ( m [ 0 ] . z , m [ 1 ] . z , m [ 2 ] . z ) ;
return tmp ;
}
float linearToRelativeLuminance ( const in vec3 color ) {
vec3 weights = vec3 ( 0.2126 , 0.7152 , 0.0722 ) ;
return dot ( weights , color . rgb ) ;
}
bool isPerspectiveMatrix ( mat4 m ) {
return m [ 2 ] [ 3 ] == - 1.0 ;
}
vec2 equirectUv ( in vec3 dir ) {
float u = atan ( dir . z , dir . x ) * RECIPROCAL _PI2 + 0.5 ;
float v = asin ( clamp ( dir . y , - 1.0 , 1.0 ) ) * RECIPROCAL _PI + 0.5 ;
return vec2 ( u , v ) ;
} ` ,Mg= ` # ifdef ENVMAP _TYPE _CUBE _UV
# define cubeUV _maxMipLevel 8.0
# define cubeUV _minMipLevel 4.0
# define cubeUV _maxTileSize 256.0
# define cubeUV _minTileSize 16.0
float getFace ( vec3 direction ) {
vec3 absDirection = abs ( direction ) ;
float face = - 1.0 ;
if ( absDirection . x > absDirection . z ) {
if ( absDirection . x > absDirection . y )
face = direction . x > 0.0 ? 0.0 : 3.0 ;
else
face = direction . y > 0.0 ? 1.0 : 4.0 ;
} else {
if ( absDirection . z > absDirection . y )
face = direction . z > 0.0 ? 2.0 : 5.0 ;
else
face = direction . y > 0.0 ? 1.0 : 4.0 ;
}
return face ;
}
vec2 getUV ( vec3 direction , float face ) {
vec2 uv ;
if ( face == 0.0 ) {
uv = vec2 ( direction . z , direction . y ) / abs ( direction . x ) ;
} else if ( face == 1.0 ) {
uv = vec2 ( - direction . x , - direction . z ) / abs ( direction . y ) ;
} else if ( face == 2.0 ) {
uv = vec2 ( - direction . x , direction . y ) / abs ( direction . z ) ;
} else if ( face == 3.0 ) {
uv = vec2 ( - direction . z , direction . y ) / abs ( direction . x ) ;
} else if ( face == 4.0 ) {
uv = vec2 ( - direction . x , direction . z ) / abs ( direction . y ) ;
} else {
uv = vec2 ( direction . x , direction . y ) / abs ( direction . z ) ;
}
return 0.5 * ( uv + 1.0 ) ;
}
vec3 bilinearCubeUV ( sampler2D envMap , vec3 direction , float mipInt ) {
float face = getFace ( direction ) ;
float filterInt = max ( cubeUV _minMipLevel - mipInt , 0.0 ) ;
mipInt = max ( mipInt , cubeUV _minMipLevel ) ;
float faceSize = exp2 ( mipInt ) ;
float texelSize = 1.0 / ( 3.0 * cubeUV _maxTileSize ) ;
vec2 uv = getUV ( direction , face ) * ( faceSize - 1.0 ) + 0.5 ;
if ( face > 2.0 ) {
uv . y += faceSize ;
face -= 3.0 ;
}
uv . x += face * faceSize ;
if ( mipInt < cubeUV _maxMipLevel ) {
uv . y += 2.0 * cubeUV _maxTileSize ;
}
uv . y += filterInt * 2.0 * cubeUV _minTileSize ;
uv . x += 3.0 * max ( 0.0 , cubeUV _maxTileSize - 2.0 * faceSize ) ;
uv *= texelSize ;
return texture2D ( envMap , uv ) . rgb ;
}
# define r0 1.0
# define v0 0.339
# define m0 - 2.0
# define r1 0.8
# define v1 0.276
# define m1 - 1.0
# define r4 0.4
# define v4 0.046
# define m4 2.0
# define r5 0.305
# define v5 0.016
# define m5 3.0
# define r6 0.21
# define v6 0.0038
# define m6 4.0
float roughnessToMip ( float roughness ) {
float mip = 0.0 ;
if ( roughness >= r1 ) {
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0 ;
} else if ( roughness >= r4 ) {
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1 ;
} else if ( roughness >= r5 ) {
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4 ;
} else if ( roughness >= r6 ) {
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5 ;
} else {
mip = - 2.0 * log2 ( 1.16 * roughness ) ; }
return mip ;
}
vec4 textureCubeUV ( sampler2D envMap , vec3 sampleDir , float roughness ) {
float mip = clamp ( roughnessToMip ( roughness ) , m0 , cubeUV _maxMipLevel ) ;
float mipF = fract ( mip ) ;
float mipInt = floor ( mip ) ;
vec3 color0 = bilinearCubeUV ( envMap , sampleDir , mipInt ) ;
if ( mipF == 0.0 ) {
return vec4 ( color0 , 1.0 ) ;
} else {
vec3 color1 = bilinearCubeUV ( envMap , sampleDir , mipInt + 1.0 ) ;
return vec4 ( mix ( color0 , color1 , mipF ) , 1.0 ) ;
}
}
# endif ` ,zg= ` vec3 transformedNormal = objectNormal ;
# ifdef USE _INSTANCING
mat3 m = mat3 ( instanceMatrix ) ;
transformedNormal /= vec3 ( dot ( m [ 0 ] , m [ 0 ] ) , dot ( m [ 1 ] , m [ 1 ] ) , dot ( m [ 2 ] , m [ 2 ] ) ) ;
transformedNormal = m * transformedNormal ;
# endif
transformedNormal = normalMatrix * transformedNormal ;
# ifdef FLIP _SIDED
transformedNormal = - transformedNormal ;
# endif
# ifdef USE _TANGENT
vec3 transformedTangent = ( modelViewMatrix * vec4 ( objectTangent , 0.0 ) ) . xyz ;
# ifdef FLIP _SIDED
transformedTangent = - transformedTangent ;
# endif
# endif ` ,Cg= ` # ifdef USE _DISPLACEMENTMAP
uniform sampler2D displacementMap ;
uniform float displacementScale ;
uniform float displacementBias ;
# endif ` ,Ag= ` # ifdef USE _DISPLACEMENTMAP
transformed += normalize ( objectNormal ) * ( texture2D ( displacementMap , vUv ) . x * displacementScale + displacementBias ) ;
# endif ` ,Sg= ` # ifdef USE _EMISSIVEMAP
vec4 emissiveColor = texture2D ( emissiveMap , vUv ) ;
totalEmissiveRadiance *= emissiveColor . rgb ;
# endif ` ,_g= ` # ifdef USE _EMISSIVEMAP
uniform sampler2D emissiveMap ;
# endif ` ,Eg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Lg= ` vec4 LinearToLinear ( in vec4 value ) {
return value ;
}
vec4 LinearTosRGB ( in vec4 value ) {
return vec4 ( mix ( pow ( value . rgb , vec3 ( 0.41666 ) ) * 1.055 - vec3 ( 0.055 ) , value . rgb * 12.92 , vec3 ( lessThanEqual ( value . rgb , vec3 ( 0.0031308 ) ) ) ) , value . a ) ;
} ` ,Tg= ` # ifdef USE _ENVMAP
# ifdef ENV _WORLDPOS
vec3 cameraToFrag ;
if ( isOrthographic ) {
cameraToFrag = normalize ( vec3 ( - viewMatrix [ 0 ] [ 2 ] , - viewMatrix [ 1 ] [ 2 ] , - viewMatrix [ 2 ] [ 2 ] ) ) ;
} else {
cameraToFrag = normalize ( vWorldPosition - cameraPosition ) ;
}
vec3 worldNormal = inverseTransformDirection ( normal , viewMatrix ) ;
# ifdef ENVMAP _MODE _REFLECTION
vec3 reflectVec = reflect ( cameraToFrag , worldNormal ) ;
# else
vec3 reflectVec = refract ( cameraToFrag , worldNormal , refractionRatio ) ;
# endif
# else
vec3 reflectVec = vReflect ;
# endif
# ifdef ENVMAP _TYPE _CUBE
vec4 envColor = textureCube ( envMap , vec3 ( flipEnvMap * reflectVec . x , reflectVec . yz ) ) ;
# elif defined ( ENVMAP _TYPE _CUBE _UV )
vec4 envColor = textureCubeUV ( envMap , reflectVec , 0.0 ) ;
# else
vec4 envColor = vec4 ( 0.0 ) ;
# endif
# ifdef ENVMAP _BLENDING _MULTIPLY
outgoingLight = mix ( outgoingLight , outgoingLight * envColor . xyz , specularStrength * reflectivity ) ;
# elif defined ( ENVMAP _BLENDING _MIX )
outgoingLight = mix ( outgoingLight , envColor . xyz , specularStrength * reflectivity ) ;
# elif defined ( ENVMAP _BLENDING _ADD )
outgoingLight += envColor . xyz * specularStrength * reflectivity ;
# endif
# endif ` ,Dg= ` # ifdef USE _ENVMAP
uniform float envMapIntensity ;
uniform float flipEnvMap ;
# ifdef ENVMAP _TYPE _CUBE
uniform samplerCube envMap ;
# else
uniform sampler2D envMap ;
# endif
# endif ` ,Hg= ` # ifdef USE _ENVMAP
uniform float reflectivity ;
# if defined ( USE _BUMPMAP ) || defined ( USE _NORMALMAP ) || defined ( PHONG )
# define ENV _WORLDPOS
# endif
# ifdef ENV _WORLDPOS
varying vec3 vWorldPosition ;
uniform float refractionRatio ;
# else
varying vec3 vReflect ;
# endif
# endif ` ,Vg= ` # ifdef USE _ENVMAP
# if defined ( USE _BUMPMAP ) || defined ( USE _NORMALMAP ) || defined ( PHONG )
# define ENV _WORLDPOS
# endif
# ifdef ENV _WORLDPOS
varying vec3 vWorldPosition ;
# else
varying vec3 vReflect ;
uniform float refractionRatio ;
# endif
# endif ` ,Rg= ` # ifdef USE _ENVMAP
# ifdef ENV _WORLDPOS
vWorldPosition = worldPosition . xyz ;
# else
vec3 cameraToVertex ;
if ( isOrthographic ) {
cameraToVertex = normalize ( vec3 ( - viewMatrix [ 0 ] [ 2 ] , - viewMatrix [ 1 ] [ 2 ] , - viewMatrix [ 2 ] [ 2 ] ) ) ;
} else {
cameraToVertex = normalize ( worldPosition . xyz - cameraPosition ) ;
}
vec3 worldNormal = inverseTransformDirection ( transformedNormal , viewMatrix ) ;
# ifdef ENVMAP _MODE _REFLECTION
vReflect = reflect ( cameraToVertex , worldNormal ) ;
# else
vReflect = refract ( cameraToVertex , worldNormal , refractionRatio ) ;
# endif
# endif
# endif ` ,Ng= ` # ifdef USE _FOG
vFogDepth = - mvPosition . z ;
# endif ` ,Fg= ` # ifdef USE _FOG
varying float vFogDepth ;
# endif ` ,Bg= ` # ifdef USE _FOG
# ifdef FOG _EXP2
float fogFactor = 1.0 - exp ( - fogDensity * fogDensity * vFogDepth * vFogDepth ) ;
# else
float fogFactor = smoothstep ( fogNear , fogFar , vFogDepth ) ;
# endif
gl _FragColor . rgb = mix ( gl _FragColor . rgb , fogColor , fogFactor ) ;
# endif ` ,Pg= ` # ifdef USE _FOG
uniform vec3 fogColor ;
varying float vFogDepth ;
# ifdef FOG _EXP2
uniform float fogDensity ;
# else
uniform float fogNear ;
uniform float fogFar ;
# endif
# endif ` ,Ig= ` # ifdef USE _GRADIENTMAP
uniform sampler2D gradientMap ;
# endif
vec3 getGradientIrradiance ( vec3 normal , vec3 lightDirection ) {
float dotNL = dot ( normal , lightDirection ) ;
vec2 coord = vec2 ( dotNL * 0.5 + 0.5 , 0.0 ) ;
# ifdef USE _GRADIENTMAP
return vec3 ( texture2D ( gradientMap , coord ) . r ) ;
# else
return ( coord . x < 0.7 ) ? vec3 ( 0.7 ) : vec3 ( 1.0 ) ;
# endif
} ` ,kg= ` # ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
# ifndef PHYSICALLY _CORRECT _LIGHTS
lightMapIrradiance *= PI ;
# endif
reflectedLight . indirectDiffuse += lightMapIrradiance ;
# endif ` ,Og= ` # ifdef USE _LIGHTMAP
uniform sampler2D lightMap ;
uniform float lightMapIntensity ;
# endif ` ,Ug= ` vec3 diffuse = vec3 ( 1.0 ) ;
GeometricContext geometry ;
geometry . position = mvPosition . xyz ;
geometry . normal = normalize ( transformedNormal ) ;
geometry . viewDir = ( isOrthographic ) ? vec3 ( 0 , 0 , 1 ) : normalize ( - mvPosition . xyz ) ;
GeometricContext backGeometry ;
backGeometry . position = geometry . position ;
backGeometry . normal = - geometry . normal ;
backGeometry . viewDir = geometry . viewDir ;
vLightFront = vec3 ( 0.0 ) ;
vIndirectFront = vec3 ( 0.0 ) ;
# ifdef DOUBLE _SIDED
vLightBack = vec3 ( 0.0 ) ;
vIndirectBack = vec3 ( 0.0 ) ;
# endif
IncidentLight directLight ;
float dotNL ;
vec3 directLightColor _Diffuse ;
vIndirectFront += getAmbientLightIrradiance ( ambientLightColor ) ;
vIndirectFront += getLightProbeIrradiance ( lightProbe , geometry . normal ) ;
# ifdef DOUBLE _SIDED
vIndirectBack += getAmbientLightIrradiance ( ambientLightColor ) ;
vIndirectBack += getLightProbeIrradiance ( lightProbe , backGeometry . normal ) ;
# endif
# if NUM _POINT _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHTS ; i ++ ) {
getPointLightInfo ( pointLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHTS ; i ++ ) {
getSpotLightInfo ( spotLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _DIR _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHTS ; i ++ ) {
getDirectionalLightInfo ( directionalLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _HEMI _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _HEMI _LIGHTS ; i ++ ) {
vIndirectFront += getHemisphereLightIrradiance ( hemisphereLights [ i ] , geometry . normal ) ;
# ifdef DOUBLE _SIDED
vIndirectBack += getHemisphereLightIrradiance ( hemisphereLights [ i ] , backGeometry . normal ) ;
# endif
}
# pragma unroll _loop _end
# endif ` ,qg= ` uniform bool receiveShadow ;
uniform vec3 ambientLightColor ;
uniform vec3 lightProbe [ 9 ] ;
vec3 shGetIrradianceAt ( in vec3 normal , in vec3 shCoefficients [ 9 ] ) {
float x = normal . x , y = normal . y , z = normal . z ;
vec3 result = shCoefficients [ 0 ] * 0.886227 ;
result += shCoefficients [ 1 ] * 2.0 * 0.511664 * y ;
result += shCoefficients [ 2 ] * 2.0 * 0.511664 * z ;
result += shCoefficients [ 3 ] * 2.0 * 0.511664 * x ;
result += shCoefficients [ 4 ] * 2.0 * 0.429043 * x * y ;
result += shCoefficients [ 5 ] * 2.0 * 0.429043 * y * z ;
result += shCoefficients [ 6 ] * ( 0.743125 * z * z - 0.247708 ) ;
result += shCoefficients [ 7 ] * 2.0 * 0.429043 * x * z ;
result += shCoefficients [ 8 ] * 0.429043 * ( x * x - y * y ) ;
return result ;
}
vec3 getLightProbeIrradiance ( const in vec3 lightProbe [ 9 ] , const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection ( normal , viewMatrix ) ;
vec3 irradiance = shGetIrradianceAt ( worldNormal , lightProbe ) ;
return irradiance ;
}
vec3 getAmbientLightIrradiance ( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor ;
return irradiance ;
}
float getDistanceAttenuation ( const in float lightDistance , const in float cutoffDistance , const in float decayExponent ) {
# if defined ( PHYSICALLY _CORRECT _LIGHTS )
float distanceFalloff = 1.0 / max ( pow ( lightDistance , decayExponent ) , 0.01 ) ;
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2 ( saturate ( 1.0 - pow4 ( lightDistance / cutoffDistance ) ) ) ;
}
return distanceFalloff ;
# else
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
return pow ( saturate ( - lightDistance / cutoffDistance + 1.0 ) , decayExponent ) ;
}
return 1.0 ;
# endif
}
float getSpotAttenuation ( const in float coneCosine , const in float penumbraCosine , const in float angleCosine ) {
return smoothstep ( coneCosine , penumbraCosine , angleCosine ) ;
}
# if NUM _DIR _LIGHTS > 0
struct DirectionalLight {
vec3 direction ;
vec3 color ;
} ;
uniform DirectionalLight directionalLights [ NUM _DIR _LIGHTS ] ;
void getDirectionalLightInfo ( const in DirectionalLight directionalLight , const in GeometricContext geometry , out IncidentLight light ) {
light . color = directionalLight . color ;
light . direction = directionalLight . direction ;
light . visible = true ;
}
# endif
# if NUM _POINT _LIGHTS > 0
struct PointLight {
vec3 position ;
vec3 color ;
float distance ;
float decay ;
} ;
uniform PointLight pointLights [ NUM _POINT _LIGHTS ] ;
void getPointLightInfo ( const in PointLight pointLight , const in GeometricContext geometry , out IncidentLight light ) {
vec3 lVector = pointLight . position - geometry . position ;
light . direction = normalize ( lVector ) ;
float lightDistance = length ( lVector ) ;
light . color = pointLight . color ;
light . color *= getDistanceAttenuation ( lightDistance , pointLight . distance , pointLight . decay ) ;
light . visible = ( light . color != vec3 ( 0.0 ) ) ;
}
# endif
# if NUM _SPOT _LIGHTS > 0
struct SpotLight {
vec3 position ;
vec3 direction ;
vec3 color ;
float distance ;
float decay ;
float coneCos ;
float penumbraCos ;
} ;
uniform SpotLight spotLights [ NUM _SPOT _LIGHTS ] ;
void getSpotLightInfo ( const in SpotLight spotLight , const in GeometricContext geometry , out IncidentLight light ) {
vec3 lVector = spotLight . position - geometry . position ;
light . direction = normalize ( lVector ) ;
float angleCos = dot ( light . direction , spotLight . direction ) ;
float spotAttenuation = getSpotAttenuation ( spotLight . coneCos , spotLight . penumbraCos , angleCos ) ;
if ( spotAttenuation > 0.0 ) {
float lightDistance = length ( lVector ) ;
light . color = spotLight . color * spotAttenuation ;
light . color *= getDistanceAttenuation ( lightDistance , spotLight . distance , spotLight . decay ) ;
light . visible = ( light . color != vec3 ( 0.0 ) ) ;
} else {
light . color = vec3 ( 0.0 ) ;
light . visible = false ;
}
}
# endif
# if NUM _RECT _AREA _LIGHTS > 0
struct RectAreaLight {
vec3 color ;
vec3 position ;
vec3 halfWidth ;
vec3 halfHeight ;
} ;
uniform sampler2D ltc _1 ; uniform sampler2D ltc _2 ;
uniform RectAreaLight rectAreaLights [ NUM _RECT _AREA _LIGHTS ] ;
# endif
# if NUM _HEMI _LIGHTS > 0
struct HemisphereLight {
vec3 direction ;
vec3 skyColor ;
vec3 groundColor ;
} ;
uniform HemisphereLight hemisphereLights [ NUM _HEMI _LIGHTS ] ;
vec3 getHemisphereLightIrradiance ( const in HemisphereLight hemiLight , const in vec3 normal ) {
float dotNL = dot ( normal , hemiLight . direction ) ;
float hemiDiffuseWeight = 0.5 * dotNL + 0.5 ;
vec3 irradiance = mix ( hemiLight . groundColor , hemiLight . skyColor , hemiDiffuseWeight ) ;
return irradiance ;
}
# endif ` ,Gg= ` # if defined ( USE _ENVMAP )
# ifdef ENVMAP _MODE _REFRACTION
uniform float refractionRatio ;
# endif
vec3 getIBLIrradiance ( const in vec3 normal ) {
# if defined ( ENVMAP _TYPE _CUBE _UV )
vec3 worldNormal = inverseTransformDirection ( normal , viewMatrix ) ;
vec4 envMapColor = textureCubeUV ( envMap , worldNormal , 1.0 ) ;
return PI * envMapColor . rgb * envMapIntensity ;
# else
return vec3 ( 0.0 ) ;
# endif
}
vec3 getIBLRadiance ( const in vec3 viewDir , const in vec3 normal , const in float roughness ) {
# if defined ( ENVMAP _TYPE _CUBE _UV )
vec3 reflectVec ;
# ifdef ENVMAP _MODE _REFLECTION
reflectVec = reflect ( - viewDir , normal ) ;
reflectVec = normalize ( mix ( reflectVec , normal , roughness * roughness ) ) ;
# else
reflectVec = refract ( - viewDir , normal , refractionRatio ) ;
# endif
reflectVec = inverseTransformDirection ( reflectVec , viewMatrix ) ;
vec4 envMapColor = textureCubeUV ( envMap , reflectVec , roughness ) ;
return envMapColor . rgb * envMapIntensity ;
# else
return vec3 ( 0.0 ) ;
# endif
}
# endif ` ,Wg= ` ToonMaterial material ;
material . diffuseColor = diffuseColor . rgb ; ` ,jg= ` varying vec3 vViewPosition ;
struct ToonMaterial {
vec3 diffuseColor ;
} ;
void RE _Direct _Toon ( const in IncidentLight directLight , const in GeometricContext geometry , const in ToonMaterial material , inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance ( geometry . normal , directLight . direction ) * directLight . color ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectDiffuse _Toon ( const in vec3 irradiance , const in GeometricContext geometry , const in ToonMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
# define RE _Direct RE _Direct _Toon
# define RE _IndirectDiffuse RE _IndirectDiffuse _Toon
# define Material _LightProbeLOD ( material ) ( 0 ) ` ,Zg= ` BlinnPhongMaterial material ;
material . diffuseColor = diffuseColor . rgb ;
material . specularColor = specular ;
material . specularShininess = shininess ;
material . specularStrength = specularStrength ; ` ,Xg= ` varying vec3 vViewPosition ;
struct BlinnPhongMaterial {
vec3 diffuseColor ;
vec3 specularColor ;
float specularShininess ;
float specularStrength ;
} ;
void RE _Direct _BlinnPhong ( const in IncidentLight directLight , const in GeometricContext geometry , const in BlinnPhongMaterial material , inout ReflectedLight reflectedLight ) {
float dotNL = saturate ( dot ( geometry . normal , directLight . direction ) ) ;
vec3 irradiance = dotNL * directLight . color ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
reflectedLight . directSpecular += irradiance * BRDF _BlinnPhong ( directLight . direction , geometry . viewDir , geometry . normal , material . specularColor , material . specularShininess ) * material . specularStrength ;
}
void RE _IndirectDiffuse _BlinnPhong ( const in vec3 irradiance , const in GeometricContext geometry , const in BlinnPhongMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
# define RE _Direct RE _Direct _BlinnPhong
# define RE _IndirectDiffuse RE _IndirectDiffuse _BlinnPhong
# define Material _LightProbeLOD ( material ) ( 0 ) ` ,Yg= ` PhysicalMaterial material ;
material . diffuseColor = diffuseColor . rgb * ( 1.0 - metalnessFactor ) ;
vec3 dxy = max ( abs ( dFdx ( geometryNormal ) ) , abs ( dFdy ( geometryNormal ) ) ) ;
float geometryRoughness = max ( max ( dxy . x , dxy . y ) , dxy . z ) ;
material . roughness = max ( roughnessFactor , 0.0525 ) ; material . roughness += geometryRoughness ;
material . roughness = min ( material . roughness , 1.0 ) ;
# ifdef IOR
# ifdef SPECULAR
float specularIntensityFactor = specularIntensity ;
vec3 specularColorFactor = specularColor ;
# ifdef USE _SPECULARINTENSITYMAP
specularIntensityFactor *= texture2D ( specularIntensityMap , vUv ) . a ;
# endif
# ifdef USE _SPECULARCOLORMAP
specularColorFactor *= texture2D ( specularColorMap , vUv ) . rgb ;
# endif
material . specularF90 = mix ( specularIntensityFactor , 1.0 , metalnessFactor ) ;
# else
float specularIntensityFactor = 1.0 ;
vec3 specularColorFactor = vec3 ( 1.0 ) ;
material . specularF90 = 1.0 ;
# endif
material . specularColor = mix ( min ( pow2 ( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor , vec3 ( 1.0 ) ) * specularIntensityFactor , diffuseColor . rgb , metalnessFactor ) ;
# else
material . specularColor = mix ( vec3 ( 0.04 ) , diffuseColor . rgb , metalnessFactor ) ;
material . specularF90 = 1.0 ;
# endif
# ifdef USE _CLEARCOAT
material . clearcoat = clearcoat ;
material . clearcoatRoughness = clearcoatRoughness ;
material . clearcoatF0 = vec3 ( 0.04 ) ;
material . clearcoatF90 = 1.0 ;
# ifdef USE _CLEARCOATMAP
material . clearcoat *= texture2D ( clearcoatMap , vUv ) . x ;
# endif
# ifdef USE _CLEARCOAT _ROUGHNESSMAP
material . clearcoatRoughness *= texture2D ( clearcoatRoughnessMap , vUv ) . y ;
# endif
material . clearcoat = saturate ( material . clearcoat ) ; material . clearcoatRoughness = max ( material . clearcoatRoughness , 0.0525 ) ;
material . clearcoatRoughness += geometryRoughness ;
material . clearcoatRoughness = min ( material . clearcoatRoughness , 1.0 ) ;
# endif
# ifdef USE _SHEEN
material . sheenColor = sheenColor ;
# ifdef USE _SHEENCOLORMAP
material . sheenColor *= texture2D ( sheenColorMap , vUv ) . rgb ;
# endif
material . sheenRoughness = clamp ( sheenRoughness , 0.07 , 1.0 ) ;
# ifdef USE _SHEENROUGHNESSMAP
material . sheenRoughness *= texture2D ( sheenRoughnessMap , vUv ) . a ;
# endif
# endif ` , $ g= ` struct PhysicalMaterial {
vec3 diffuseColor ;
float roughness ;
vec3 specularColor ;
float specularF90 ;
# ifdef USE _CLEARCOAT
float clearcoat ;
float clearcoatRoughness ;
vec3 clearcoatF0 ;
float clearcoatF90 ;
# endif
# ifdef USE _SHEEN
vec3 sheenColor ;
float sheenRoughness ;
# endif
} ;
vec3 clearcoatSpecular = vec3 ( 0.0 ) ;
vec3 sheenSpecular = vec3 ( 0.0 ) ;
float IBLSheenBRDF ( const in vec3 normal , const in vec3 viewDir , const in float roughness ) {
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float r2 = roughness * roughness ;
float a = roughness < 0.25 ? - 339.2 * r2 + 161.4 * roughness - 25.9 : - 8.48 * r2 + 14.3 * roughness - 9.95 ;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72 ;
float DG = exp ( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ) ;
return saturate ( DG * RECIPROCAL _PI ) ;
}
vec2 DFGApprox ( const in vec3 normal , const in vec3 viewDir , const in float roughness ) {
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
const vec4 c0 = vec4 ( - 1 , - 0.0275 , - 0.572 , 0.022 ) ;
const vec4 c1 = vec4 ( 1 , 0.0425 , 1.04 , - 0.04 ) ;
vec4 r = roughness * c0 + c1 ;
float a004 = min ( r . x * r . x , exp2 ( - 9.28 * dotNV ) ) * r . x + r . y ;
vec2 fab = vec2 ( - 1.04 , 1.04 ) * a004 + r . zw ;
return fab ;
}
vec3 EnvironmentBRDF ( const in vec3 normal , const in vec3 viewDir , const in vec3 specularColor , const in float specularF90 , const in float roughness ) {
vec2 fab = DFGApprox ( normal , viewDir , roughness ) ;
return specularColor * fab . x + specularF90 * fab . y ;
}
void computeMultiscattering ( const in vec3 normal , const in vec3 viewDir , const in vec3 specularColor , const in float specularF90 , const in float roughness , inout vec3 singleScatter , inout vec3 multiScatter ) {
vec2 fab = DFGApprox ( normal , viewDir , roughness ) ;
vec3 FssEss = specularColor * fab . x + specularF90 * fab . y ;
float Ess = fab . x + fab . y ;
float Ems = 1.0 - Ess ;
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619 ; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ) ;
singleScatter += FssEss ;
multiScatter += Fms * Ems ;
}
# if NUM _RECT _AREA _LIGHTS > 0
void RE _Direct _RectArea _Physical ( const in RectAreaLight rectAreaLight , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
vec3 normal = geometry . normal ;
vec3 viewDir = geometry . viewDir ;
vec3 position = geometry . position ;
vec3 lightPos = rectAreaLight . position ;
vec3 halfWidth = rectAreaLight . halfWidth ;
vec3 halfHeight = rectAreaLight . halfHeight ;
vec3 lightColor = rectAreaLight . color ;
float roughness = material . roughness ;
vec3 rectCoords [ 4 ] ;
rectCoords [ 0 ] = lightPos + halfWidth - halfHeight ; rectCoords [ 1 ] = lightPos - halfWidth - halfHeight ;
rectCoords [ 2 ] = lightPos - halfWidth + halfHeight ;
rectCoords [ 3 ] = lightPos + halfWidth + halfHeight ;
vec2 uv = LTC _Uv ( normal , viewDir , roughness ) ;
vec4 t1 = texture2D ( ltc _1 , uv ) ;
vec4 t2 = texture2D ( ltc _2 , uv ) ;
mat3 mInv = mat3 (
vec3 ( t1 . x , 0 , t1 . y ) ,
vec3 ( 0 , 1 , 0 ) ,
vec3 ( t1 . z , 0 , t1 . w )
) ;
vec3 fresnel = ( material . specularColor * t2 . x + ( vec3 ( 1.0 ) - material . specularColor ) * t2 . y ) ;
reflectedLight . directSpecular += lightColor * fresnel * LTC _Evaluate ( normal , viewDir , position , mInv , rectCoords ) ;
reflectedLight . directDiffuse += lightColor * material . diffuseColor * LTC _Evaluate ( normal , viewDir , position , mat3 ( 1.0 ) , rectCoords ) ;
}
# endif
void RE _Direct _Physical ( const in IncidentLight directLight , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
float dotNL = saturate ( dot ( geometry . normal , directLight . direction ) ) ;
vec3 irradiance = dotNL * directLight . color ;
# ifdef USE _CLEARCOAT
float dotNLcc = saturate ( dot ( geometry . clearcoatNormal , directLight . direction ) ) ;
vec3 ccIrradiance = dotNLcc * directLight . color ;
clearcoatSpecular += ccIrradiance * BRDF _GGX ( directLight . direction , geometry . viewDir , geometry . clearcoatNormal , material . clearcoatF0 , material . clearcoatF90 , material . clearcoatRoughness ) ;
# endif
# ifdef USE _SHEEN
sheenSpecular += irradiance * BRDF _Sheen ( directLight . direction , geometry . viewDir , geometry . normal , material . sheenColor , material . sheenRoughness ) ;
# endif
reflectedLight . directSpecular += irradiance * BRDF _GGX ( directLight . direction , geometry . viewDir , geometry . normal , material . specularColor , material . specularF90 , material . roughness ) ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectDiffuse _Physical ( const in vec3 irradiance , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectSpecular _Physical ( const in vec3 radiance , const in vec3 irradiance , const in vec3 clearcoatRadiance , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
# ifdef USE _CLEARCOAT
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF ( geometry . clearcoatNormal , geometry . viewDir , material . clearcoatF0 , material . clearcoatF90 , material . clearcoatRoughness ) ;
# endif
# ifdef USE _SHEEN
sheenSpecular += irradiance * material . sheenColor * IBLSheenBRDF ( geometry . normal , geometry . viewDir , material . sheenRoughness ) ;
# endif
vec3 singleScattering = vec3 ( 0.0 ) ;
vec3 multiScattering = vec3 ( 0.0 ) ;
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL _PI ;
computeMultiscattering ( geometry . normal , geometry . viewDir , material . specularColor , material . specularF90 , material . roughness , singleScattering , multiScattering ) ;
vec3 diffuse = material . diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ) ;
reflectedLight . indirectSpecular += radiance * singleScattering ;
reflectedLight . indirectSpecular += multiScattering * cosineWeightedIrradiance ;
reflectedLight . indirectDiffuse += diffuse * cosineWeightedIrradiance ;
}
# define RE _Direct RE _Direct _Physical
# define RE _Direct _RectArea RE _Direct _RectArea _Physical
# define RE _IndirectDiffuse RE _IndirectDiffuse _Physical
# define RE _IndirectSpecular RE _IndirectSpecular _Physical
float computeSpecularOcclusion ( const in float dotNV , const in float ambientOcclusion , const in float roughness ) {
return saturate ( pow ( dotNV + ambientOcclusion , exp2 ( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ) ;
} ` ,Jg= `
GeometricContext geometry ;
geometry . position = - vViewPosition ;
geometry . normal = normal ;
geometry . viewDir = ( isOrthographic ) ? vec3 ( 0 , 0 , 1 ) : normalize ( vViewPosition ) ;
# ifdef USE _CLEARCOAT
geometry . clearcoatNormal = clearcoatNormal ;
# endif
IncidentLight directLight ;
# if ( NUM _POINT _LIGHTS > 0 ) && defined ( RE _Direct )
PointLight pointLight ;
# if defined ( USE _SHADOWMAP ) && NUM _POINT _LIGHT _SHADOWS > 0
PointLightShadow pointLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHTS ; i ++ ) {
pointLight = pointLights [ i ] ;
getPointLightInfo ( pointLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _POINT _LIGHT _SHADOWS )
pointLightShadow = pointLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getPointShadow ( pointShadowMap [ i ] , pointLightShadow . shadowMapSize , pointLightShadow . shadowBias , pointLightShadow . shadowRadius , vPointShadowCoord [ i ] , pointLightShadow . shadowCameraNear , pointLightShadow . shadowCameraFar ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _SPOT _LIGHTS > 0 ) && defined ( RE _Direct )
SpotLight spotLight ;
# if defined ( USE _SHADOWMAP ) && NUM _SPOT _LIGHT _SHADOWS > 0
SpotLightShadow spotLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHTS ; i ++ ) {
spotLight = spotLights [ i ] ;
getSpotLightInfo ( spotLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _SPOT _LIGHT _SHADOWS )
spotLightShadow = spotLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getShadow ( spotShadowMap [ i ] , spotLightShadow . shadowMapSize , spotLightShadow . shadowBias , spotLightShadow . shadowRadius , vSpotShadowCoord [ i ] ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _DIR _LIGHTS > 0 ) && defined ( RE _Direct )
DirectionalLight directionalLight ;
# if defined ( USE _SHADOWMAP ) && NUM _DIR _LIGHT _SHADOWS > 0
DirectionalLightShadow directionalLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHTS ; i ++ ) {
directionalLight = directionalLights [ i ] ;
getDirectionalLightInfo ( directionalLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _DIR _LIGHT _SHADOWS )
directionalLightShadow = directionalLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getShadow ( directionalShadowMap [ i ] , directionalLightShadow . shadowMapSize , directionalLightShadow . shadowBias , directionalLightShadow . shadowRadius , vDirectionalShadowCoord [ i ] ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _RECT _AREA _LIGHTS > 0 ) && defined ( RE _Direct _RectArea )
RectAreaLight rectAreaLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _RECT _AREA _LIGHTS ; i ++ ) {
rectAreaLight = rectAreaLights [ i ] ;
RE _Direct _RectArea ( rectAreaLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if defined ( RE _IndirectDiffuse )
vec3 iblIrradiance = vec3 ( 0.0 ) ;
vec3 irradiance = getAmbientLightIrradiance ( ambientLightColor ) ;
irradiance += getLightProbeIrradiance ( lightProbe , geometry . normal ) ;
# if ( NUM _HEMI _LIGHTS > 0 )
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _HEMI _LIGHTS ; i ++ ) {
irradiance += getHemisphereLightIrradiance ( hemisphereLights [ i ] , geometry . normal ) ;
}
# pragma unroll _loop _end
# endif
# endif
# if defined ( RE _IndirectSpecular )
vec3 radiance = vec3 ( 0.0 ) ;
vec3 clearcoatRadiance = vec3 ( 0.0 ) ;
# endif ` ,Qg= ` # if defined ( RE _IndirectDiffuse )
# ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
# ifndef PHYSICALLY _CORRECT _LIGHTS
lightMapIrradiance *= PI ;
# endif
irradiance += lightMapIrradiance ;
# endif
# if defined ( USE _ENVMAP ) && defined ( STANDARD ) && defined ( ENVMAP _TYPE _CUBE _UV )
iblIrradiance += getIBLIrradiance ( geometry . normal ) ;
# endif
# endif
# if defined ( USE _ENVMAP ) && defined ( RE _IndirectSpecular )
radiance += getIBLRadiance ( geometry . viewDir , geometry . normal , material . roughness ) ;
# ifdef USE _CLEARCOAT
clearcoatRadiance += getIBLRadiance ( geometry . viewDir , geometry . clearcoatNormal , material . clearcoatRoughness ) ;
# endif
# endif ` ,Kg= ` # if defined ( RE _IndirectDiffuse )
RE _IndirectDiffuse ( irradiance , geometry , material , reflectedLight ) ;
# endif
# if defined ( RE _IndirectSpecular )
RE _IndirectSpecular ( radiance , iblIrradiance , clearcoatRadiance , geometry , material , reflectedLight ) ;
# endif ` ,ev= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
gl _FragDepthEXT = vIsPerspective == 0.0 ? gl _FragCoord . z : log2 ( vFragDepth ) * logDepthBufFC * 0.5 ;
# endif ` ,tv= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
uniform float logDepthBufFC ;
varying float vFragDepth ;
varying float vIsPerspective ;
# endif ` ,iv= ` # ifdef USE _LOGDEPTHBUF
# ifdef USE _LOGDEPTHBUF _EXT
varying float vFragDepth ;
varying float vIsPerspective ;
# else
uniform float logDepthBufFC ;
# endif
# endif ` ,nv= ` # ifdef USE _LOGDEPTHBUF
# ifdef USE _LOGDEPTHBUF _EXT
vFragDepth = 1.0 + gl _Position . w ;
vIsPerspective = float ( isPerspectiveMatrix ( projectionMatrix ) ) ;
# else
if ( isPerspectiveMatrix ( projectionMatrix ) ) {
gl _Position . z = log2 ( max ( EPSILON , gl _Position . w + 1.0 ) ) * logDepthBufFC - 1.0 ;
gl _Position . z *= gl _Position . w ;
}
# endif
# endif ` ,rv= ` # ifdef USE _MAP
vec4 sampledDiffuseColor = texture2D ( map , vUv ) ;
# ifdef DECODE _VIDEO _TEXTURE
sampledDiffuseColor = vec4 ( mix ( pow ( sampledDiffuseColor . rgb * 0.9478672986 + vec3 ( 0.0521327014 ) , vec3 ( 2.4 ) ) , sampledDiffuseColor . rgb * 0.0773993808 , vec3 ( lessThanEqual ( sampledDiffuseColor . rgb , vec3 ( 0.04045 ) ) ) ) , sampledDiffuseColor . w ) ;
# endif
diffuseColor *= sampledDiffuseColor ;
# endif ` ,sv= ` # ifdef USE _MAP
uniform sampler2D map ;
# endif ` ,av= ` # if defined ( USE _MAP ) || defined ( USE _ALPHAMAP )
vec2 uv = ( uvTransform * vec3 ( gl _PointCoord . x , 1.0 - gl _PointCoord . y , 1 ) ) . xy ;
# endif
# ifdef USE _MAP
diffuseColor *= texture2D ( map , uv ) ;
# endif
# ifdef USE _ALPHAMAP
diffuseColor . a *= texture2D ( alphaMap , uv ) . g ;
# endif ` ,ov= ` # if defined ( USE _MAP ) || defined ( USE _ALPHAMAP )
uniform mat3 uvTransform ;
# endif
# ifdef USE _MAP
uniform sampler2D map ;
# endif
# ifdef USE _ALPHAMAP
uniform sampler2D alphaMap ;
# endif ` ,cv= ` float metalnessFactor = metalness ;
# ifdef USE _METALNESSMAP
vec4 texelMetalness = texture2D ( metalnessMap , vUv ) ;
metalnessFactor *= texelMetalness . b ;
# endif ` ,lv= ` # ifdef USE _METALNESSMAP
uniform sampler2D metalnessMap ;
# endif ` ,hv= ` # ifdef USE _MORPHNORMALS
objectNormal *= morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
if ( morphTargetInfluences [ i ] != 0.0 ) objectNormal += getMorph ( gl _VertexID , i , 1 , 2 ) * morphTargetInfluences [ i ] ;
}
# else
objectNormal += morphNormal0 * morphTargetInfluences [ 0 ] ;
objectNormal += morphNormal1 * morphTargetInfluences [ 1 ] ;
objectNormal += morphNormal2 * morphTargetInfluences [ 2 ] ;
objectNormal += morphNormal3 * morphTargetInfluences [ 3 ] ;
# endif
# endif ` ,uv= ` # ifdef USE _MORPHTARGETS
uniform float morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
uniform float morphTargetInfluences [ MORPHTARGETS _COUNT ] ;
uniform sampler2DArray morphTargetsTexture ;
uniform vec2 morphTargetsTextureSize ;
vec3 getMorph ( const in int vertexIndex , const in int morphTargetIndex , const in int offset , const in int stride ) {
float texelIndex = float ( vertexIndex * stride + offset ) ;
float y = floor ( texelIndex / morphTargetsTextureSize . x ) ;
float x = texelIndex - y * morphTargetsTextureSize . x ;
vec3 morphUV = vec3 ( ( x + 0.5 ) / morphTargetsTextureSize . x , y / morphTargetsTextureSize . y , morphTargetIndex ) ;
return texture ( morphTargetsTexture , morphUV ) . xyz ;
}
# else
# ifndef USE _MORPHNORMALS
uniform float morphTargetInfluences [ 8 ] ;
# else
uniform float morphTargetInfluences [ 4 ] ;
# endif
# endif
# endif ` ,fv= ` # ifdef USE _MORPHTARGETS
transformed *= morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
# ifndef USE _MORPHNORMALS
if ( morphTargetInfluences [ i ] != 0.0 ) transformed += getMorph ( gl _VertexID , i , 0 , 1 ) * morphTargetInfluences [ i ] ;
# else
if ( morphTargetInfluences [ i ] != 0.0 ) transformed += getMorph ( gl _VertexID , i , 0 , 2 ) * morphTargetInfluences [ i ] ;
# endif
}
# else
transformed += morphTarget0 * morphTargetInfluences [ 0 ] ;
transformed += morphTarget1 * morphTargetInfluences [ 1 ] ;
transformed += morphTarget2 * morphTargetInfluences [ 2 ] ;
transformed += morphTarget3 * morphTargetInfluences [ 3 ] ;
# ifndef USE _MORPHNORMALS
transformed += morphTarget4 * morphTargetInfluences [ 4 ] ;
transformed += morphTarget5 * morphTargetInfluences [ 5 ] ;
transformed += morphTarget6 * morphTargetInfluences [ 6 ] ;
transformed += morphTarget7 * morphTargetInfluences [ 7 ] ;
# endif
# endif
# endif ` ,dv= ` float faceDirection = gl _FrontFacing ? 1.0 : - 1.0 ;
# ifdef FLAT _SHADED
vec3 fdx = vec3 ( dFdx ( vViewPosition . x ) , dFdx ( vViewPosition . y ) , dFdx ( vViewPosition . z ) ) ;
vec3 fdy = vec3 ( dFdy ( vViewPosition . x ) , dFdy ( vViewPosition . y ) , dFdy ( vViewPosition . z ) ) ;
vec3 normal = normalize ( cross ( fdx , fdy ) ) ;
# else
vec3 normal = normalize ( vNormal ) ;
# ifdef DOUBLE _SIDED
normal = normal * faceDirection ;
# endif
# ifdef USE _TANGENT
vec3 tangent = normalize ( vTangent ) ;
vec3 bitangent = normalize ( vBitangent ) ;
# ifdef DOUBLE _SIDED
tangent = tangent * faceDirection ;
bitangent = bitangent * faceDirection ;
# endif
# if defined ( TANGENTSPACE _NORMALMAP ) || defined ( USE _CLEARCOAT _NORMALMAP )
mat3 vTBN = mat3 ( tangent , bitangent , normal ) ;
# endif
# endif
# endif
vec3 geometryNormal = normal ; ` ,pv= ` # ifdef OBJECTSPACE _NORMALMAP
normal = texture2D ( normalMap , vUv ) . xyz * 2.0 - 1.0 ;
# ifdef FLIP _SIDED
normal = - normal ;
# endif
# ifdef DOUBLE _SIDED
normal = normal * faceDirection ;
# endif
normal = normalize ( normalMatrix * normal ) ;
# elif defined ( TANGENTSPACE _NORMALMAP )
vec3 mapN = texture2D ( normalMap , vUv ) . xyz * 2.0 - 1.0 ;
mapN . xy *= normalScale ;
# ifdef USE _TANGENT
normal = normalize ( vTBN * mapN ) ;
# else
normal = perturbNormal2Arb ( - vViewPosition , normal , mapN , faceDirection ) ;
# endif
# elif defined ( USE _BUMPMAP )
normal = perturbNormalArb ( - vViewPosition , normal , dHdxy _fwd ( ) , faceDirection ) ;
# endif ` ,mv= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,gv= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,vv= ` # ifndef FLAT _SHADED
vNormal = normalize ( transformedNormal ) ;
# ifdef USE _TANGENT
vTangent = normalize ( transformedTangent ) ;
vBitangent = normalize ( cross ( vNormal , vTangent ) * tangent . w ) ;
# endif
# endif ` ,xv= ` # ifdef USE _NORMALMAP
uniform sampler2D normalMap ;
uniform vec2 normalScale ;
# endif
# ifdef OBJECTSPACE _NORMALMAP
uniform mat3 normalMatrix ;
# endif
# if ! defined ( USE _TANGENT ) && ( defined ( TANGENTSPACE _NORMALMAP ) || defined ( USE _CLEARCOAT _NORMALMAP ) )
vec3 perturbNormal2Arb ( vec3 eye _pos , vec3 surf _norm , vec3 mapN , float faceDirection ) {
vec3 q0 = vec3 ( dFdx ( eye _pos . x ) , dFdx ( eye _pos . y ) , dFdx ( eye _pos . z ) ) ;
vec3 q1 = vec3 ( dFdy ( eye _pos . x ) , dFdy ( eye _pos . y ) , dFdy ( eye _pos . z ) ) ;
vec2 st0 = dFdx ( vUv . st ) ;
vec2 st1 = dFdy ( vUv . st ) ;
vec3 N = surf _norm ;
vec3 q1perp = cross ( q1 , N ) ;
vec3 q0perp = cross ( N , q0 ) ;
vec3 T = q1perp * st0 . x + q0perp * st1 . x ;
vec3 B = q1perp * st0 . y + q0perp * st1 . y ;
float det = max ( dot ( T , T ) , dot ( B , B ) ) ;
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt ( det ) ;
return normalize ( T * ( mapN . x * scale ) + B * ( mapN . y * scale ) + N * mapN . z ) ;
}
# endif ` ,yv= ` # ifdef USE _CLEARCOAT
vec3 clearcoatNormal = geometryNormal ;
# endif ` ,wv= ` # ifdef USE _CLEARCOAT _NORMALMAP
vec3 clearcoatMapN = texture2D ( clearcoatNormalMap , vUv ) . xyz * 2.0 - 1.0 ;
clearcoatMapN . xy *= clearcoatNormalScale ;
# ifdef USE _TANGENT
clearcoatNormal = normalize ( vTBN * clearcoatMapN ) ;
# else
clearcoatNormal = perturbNormal2Arb ( - vViewPosition , clearcoatNormal , clearcoatMapN , faceDirection ) ;
# endif
# endif ` ,bv= ` # ifdef USE _CLEARCOATMAP
uniform sampler2D clearcoatMap ;
# endif
# ifdef USE _CLEARCOAT _ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap ;
# endif
# ifdef USE _CLEARCOAT _NORMALMAP
uniform sampler2D clearcoatNormalMap ;
uniform vec2 clearcoatNormalScale ;
# endif ` ,Mv= ` # ifdef OPAQUE
diffuseColor . a = 1.0 ;
# endif
# ifdef USE _TRANSMISSION
diffuseColor . a *= transmissionAlpha + 0.1 ;
# endif
gl _FragColor = vec4 ( outgoingLight , diffuseColor . a ) ; ` ,zv= ` vec3 packNormalToRGB ( const in vec3 normal ) {
return normalize ( normal ) * 0.5 + 0.5 ;
}
vec3 unpackRGBToNormal ( const in vec3 rgb ) {
return 2.0 * rgb . xyz - 1.0 ;
}
const float PackUpscale = 256. / 255. ; const float UnpackDownscale = 255. / 256. ;
const vec3 PackFactors = vec3 ( 256. * 256. * 256. , 256. * 256. , 256. ) ;
const vec4 UnpackFactors = UnpackDownscale / vec4 ( PackFactors , 1. ) ;
const float ShiftRight8 = 1. / 256. ;
vec4 packDepthToRGBA ( const in float v ) {
vec4 r = vec4 ( fract ( v * PackFactors ) , v ) ;
r . yzw -= r . xyz * ShiftRight8 ; return r * PackUpscale ;
}
float unpackRGBAToDepth ( const in vec4 v ) {
return dot ( v , UnpackFactors ) ;
}
vec4 pack2HalfToRGBA ( vec2 v ) {
vec4 r = vec4 ( v . x , fract ( v . x * 255.0 ) , v . y , fract ( v . y * 255.0 ) ) ;
return vec4 ( r . x - r . y / 255.0 , r . y , r . z - r . w / 255.0 , r . w ) ;
}
vec2 unpackRGBATo2Half ( vec4 v ) {
return vec2 ( v . x + ( v . y / 255.0 ) , v . z + ( v . w / 255.0 ) ) ;
}
float viewZToOrthographicDepth ( const in float viewZ , const in float near , const in float far ) {
return ( viewZ + near ) / ( near - far ) ;
}
float orthographicDepthToViewZ ( const in float linearClipZ , const in float near , const in float far ) {
return linearClipZ * ( near - far ) - near ;
}
float viewZToPerspectiveDepth ( const in float viewZ , const in float near , const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ) ;
}
float perspectiveDepthToViewZ ( const in float invClipZ , const in float near , const in float far ) {
return ( near * far ) / ( ( far - near ) * invClipZ - far ) ;
} ` ,Cv= ` # ifdef PREMULTIPLIED _ALPHA
gl _FragColor . rgb *= gl _FragColor . a ;
# endif ` ,Av= ` vec4 mvPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _INSTANCING
mvPosition = instanceMatrix * mvPosition ;
# endif
mvPosition = modelViewMatrix * mvPosition ;
gl _Position = projectionMatrix * mvPosition ; ` ,Sv= ` # ifdef DITHERING
gl _FragColor . rgb = dithering ( gl _FragColor . rgb ) ;
# endif ` ,_v= ` # ifdef DITHERING
vec3 dithering ( vec3 color ) {
float grid _position = rand ( gl _FragCoord . xy ) ;
vec3 dither _shift _RGB = vec3 ( 0.25 / 255.0 , - 0.25 / 255.0 , 0.25 / 255.0 ) ;
dither _shift _RGB = mix ( 2.0 * dither _shift _RGB , - 2.0 * dither _shift _RGB , grid _position ) ;
return color + dither _shift _RGB ;
}
# endif ` ,Ev= ` float roughnessFactor = roughness ;
# ifdef USE _ROUGHNESSMAP
vec4 texelRoughness = texture2D ( roughnessMap , vUv ) ;
roughnessFactor *= texelRoughness . g ;
# endif ` ,Lv= ` # ifdef USE _ROUGHNESSMAP
uniform sampler2D roughnessMap ;
# endif ` ,Tv= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
uniform sampler2D directionalShadowMap [ NUM _DIR _LIGHT _SHADOWS ] ;
varying vec4 vDirectionalShadowCoord [ NUM _DIR _LIGHT _SHADOWS ] ;
struct DirectionalLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform DirectionalLightShadow directionalLightShadows [ NUM _DIR _LIGHT _SHADOWS ] ;
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
uniform sampler2D spotShadowMap [ NUM _SPOT _LIGHT _SHADOWS ] ;
varying vec4 vSpotShadowCoord [ NUM _SPOT _LIGHT _SHADOWS ] ;
struct SpotLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform SpotLightShadow spotLightShadows [ NUM _SPOT _LIGHT _SHADOWS ] ;
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
uniform sampler2D pointShadowMap [ NUM _POINT _LIGHT _SHADOWS ] ;
varying vec4 vPointShadowCoord [ NUM _POINT _LIGHT _SHADOWS ] ;
struct PointLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
float shadowCameraNear ;
float shadowCameraFar ;
} ;
uniform PointLightShadow pointLightShadows [ NUM _POINT _LIGHT _SHADOWS ] ;
# endif
float texture2DCompare ( sampler2D depths , vec2 uv , float compare ) {
return step ( compare , unpackRGBAToDepth ( texture2D ( depths , uv ) ) ) ;
}
vec2 texture2DDistribution ( sampler2D shadow , vec2 uv ) {
return unpackRGBATo2Half ( texture2D ( shadow , uv ) ) ;
}
float VSMShadow ( sampler2D shadow , vec2 uv , float compare ) {
float occlusion = 1.0 ;
vec2 distribution = texture2DDistribution ( shadow , uv ) ;
float hard _shadow = step ( compare , distribution . x ) ;
if ( hard _shadow != 1.0 ) {
float distance = compare - distribution . x ;
float variance = max ( 0.00000 , distribution . y * distribution . y ) ;
float softness _probability = variance / ( variance + distance * distance ) ; softness _probability = clamp ( ( softness _probability - 0.3 ) / ( 0.95 - 0.3 ) , 0.0 , 1.0 ) ; occlusion = clamp ( max ( hard _shadow , softness _probability ) , 0.0 , 1.0 ) ;
}
return occlusion ;
}
float getShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowBias , float shadowRadius , vec4 shadowCoord ) {
float shadow = 1.0 ;
shadowCoord . xyz /= shadowCoord . w ;
shadowCoord . z += shadowBias ;
bvec4 inFrustumVec = bvec4 ( shadowCoord . x >= 0.0 , shadowCoord . x <= 1.0 , shadowCoord . y >= 0.0 , shadowCoord . y <= 1.0 ) ;
bool inFrustum = all ( inFrustumVec ) ;
bvec2 frustumTestVec = bvec2 ( inFrustum , shadowCoord . z <= 1.0 ) ;
bool frustumTest = all ( frustumTestVec ) ;
if ( frustumTest ) {
# if defined ( SHADOWMAP _TYPE _PCF )
vec2 texelSize = vec2 ( 1.0 ) / shadowMapSize ;
float dx0 = - texelSize . x * shadowRadius ;
float dy0 = - texelSize . y * shadowRadius ;
float dx1 = + texelSize . x * shadowRadius ;
float dy1 = + texelSize . y * shadowRadius ;
float dx2 = dx0 / 2.0 ;
float dy2 = dy0 / 2.0 ;
float dx3 = dx1 / 2.0 ;
float dy3 = dy1 / 2.0 ;
shadow = (
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , dy1 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy1 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , dy1 ) , shadowCoord . z )
) * ( 1.0 / 17.0 ) ;
# elif defined ( SHADOWMAP _TYPE _PCF _SOFT )
vec2 texelSize = vec2 ( 1.0 ) / shadowMapSize ;
float dx = texelSize . x ;
float dy = texelSize . y ;
vec2 uv = shadowCoord . xy ;
vec2 f = fract ( uv * shadowMapSize + 0.5 ) ;
uv -= f * texelSize ;
shadow = (
texture2DCompare ( shadowMap , uv , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + vec2 ( dx , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , dy ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + texelSize , shadowCoord . z ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , 0.0 ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , 0.0 ) , shadowCoord . z ) ,
f . x ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , dy ) , shadowCoord . z ) ,
f . x ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , 2.0 * dy ) , shadowCoord . z ) ,
f . y ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( dx , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( dx , 2.0 * dy ) , shadowCoord . z ) ,
f . y ) +
mix ( mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , - dy ) , shadowCoord . z ) ,
f . x ) ,
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , 2.0 * dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , 2.0 * dy ) , shadowCoord . z ) ,
f . x ) ,
f . y )
) * ( 1.0 / 9.0 ) ;
# elif defined ( SHADOWMAP _TYPE _VSM )
shadow = VSMShadow ( shadowMap , shadowCoord . xy , shadowCoord . z ) ;
# else
shadow = texture2DCompare ( shadowMap , shadowCoord . xy , shadowCoord . z ) ;
# endif
}
return shadow ;
}
vec2 cubeToUV ( vec3 v , float texelSizeY ) {
vec3 absV = abs ( v ) ;
float scaleToCube = 1.0 / max ( absV . x , max ( absV . y , absV . z ) ) ;
absV *= scaleToCube ;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ) ;
vec2 planar = v . xy ;
float almostATexel = 1.5 * texelSizeY ;
float almostOne = 1.0 - almostATexel ;
if ( absV . z >= almostOne ) {
if ( v . z > 0.0 )
planar . x = 4.0 - v . x ;
} else if ( absV . x >= almostOne ) {
float signX = sign ( v . x ) ;
planar . x = v . z * signX + 2.0 * signX ;
} else if ( absV . y >= almostOne ) {
float signY = sign ( v . y ) ;
planar . x = v . x + 2.0 * signY + 2.0 ;
planar . y = v . z * signY - 2.0 ;
}
return vec2 ( 0.125 , 0.25 ) * planar + vec2 ( 0.375 , 0.75 ) ;
}
float getPointShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowBias , float shadowRadius , vec4 shadowCoord , float shadowCameraNear , float shadowCameraFar ) {
vec2 texelSize = vec2 ( 1.0 ) / ( shadowMapSize * vec2 ( 4.0 , 2.0 ) ) ;
vec3 lightToPosition = shadowCoord . xyz ;
float dp = ( length ( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ) ; dp += shadowBias ;
vec3 bd3D = normalize ( lightToPosition ) ;
# if defined ( SHADOWMAP _TYPE _PCF ) || defined ( SHADOWMAP _TYPE _PCF _SOFT ) || defined ( SHADOWMAP _TYPE _VSM )
vec2 offset = vec2 ( - 1 , 1 ) * shadowRadius * texelSize . y ;
return (
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xyy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yyy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xyx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yyx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xxy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yxy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xxx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yxx , texelSize . y ) , dp )
) * ( 1.0 / 9.0 ) ;
# else
return texture2DCompare ( shadowMap , cubeToUV ( bd3D , texelSize . y ) , dp ) ;
# endif
}
# endif ` ,Dv= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
uniform mat4 directionalShadowMatrix [ NUM _DIR _LIGHT _SHADOWS ] ;
varying vec4 vDirectionalShadowCoord [ NUM _DIR _LIGHT _SHADOWS ] ;
struct DirectionalLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform DirectionalLightShadow directionalLightShadows [ NUM _DIR _LIGHT _SHADOWS ] ;
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
uniform mat4 spotShadowMatrix [ NUM _SPOT _LIGHT _SHADOWS ] ;
varying vec4 vSpotShadowCoord [ NUM _SPOT _LIGHT _SHADOWS ] ;
struct SpotLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform SpotLightShadow spotLightShadows [ NUM _SPOT _LIGHT _SHADOWS ] ;
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
uniform mat4 pointShadowMatrix [ NUM _POINT _LIGHT _SHADOWS ] ;
varying vec4 vPointShadowCoord [ NUM _POINT _LIGHT _SHADOWS ] ;
struct PointLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
float shadowCameraNear ;
float shadowCameraFar ;
} ;
uniform PointLightShadow pointLightShadows [ NUM _POINT _LIGHT _SHADOWS ] ;
# endif
# endif ` ,Hv= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0 || NUM _SPOT _LIGHT _SHADOWS > 0 || NUM _POINT _LIGHT _SHADOWS > 0
vec3 shadowWorldNormal = inverseTransformDirection ( transformedNormal , viewMatrix ) ;
vec4 shadowWorldPosition ;
# endif
# if NUM _DIR _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * directionalLightShadows [ i ] . shadowNormalBias , 0 ) ;
vDirectionalShadowCoord [ i ] = directionalShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * spotLightShadows [ i ] . shadowNormalBias , 0 ) ;
vSpotShadowCoord [ i ] = spotShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * pointLightShadows [ i ] . shadowNormalBias , 0 ) ;
vPointShadowCoord [ i ] = pointShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# endif ` ,Vv= ` float getShadowMask ( ) {
float shadow = 1.0 ;
# ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
DirectionalLightShadow directionalLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHT _SHADOWS ; i ++ ) {
directionalLight = directionalLightShadows [ i ] ;
shadow *= receiveShadow ? getShadow ( directionalShadowMap [ i ] , directionalLight . shadowMapSize , directionalLight . shadowBias , directionalLight . shadowRadius , vDirectionalShadowCoord [ i ] ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
SpotLightShadow spotLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHT _SHADOWS ; i ++ ) {
spotLight = spotLightShadows [ i ] ;
shadow *= receiveShadow ? getShadow ( spotShadowMap [ i ] , spotLight . shadowMapSize , spotLight . shadowBias , spotLight . shadowRadius , vSpotShadowCoord [ i ] ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
PointLightShadow pointLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHT _SHADOWS ; i ++ ) {
pointLight = pointLightShadows [ i ] ;
shadow *= receiveShadow ? getPointShadow ( pointShadowMap [ i ] , pointLight . shadowMapSize , pointLight . shadowBias , pointLight . shadowRadius , vPointShadowCoord [ i ] , pointLight . shadowCameraNear , pointLight . shadowCameraFar ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# endif
return shadow ;
} ` ,Rv= ` # ifdef USE _SKINNING
mat4 boneMatX = getBoneMatrix ( skinIndex . x ) ;
mat4 boneMatY = getBoneMatrix ( skinIndex . y ) ;
mat4 boneMatZ = getBoneMatrix ( skinIndex . z ) ;
mat4 boneMatW = getBoneMatrix ( skinIndex . w ) ;
# endif ` ,Nv= ` # ifdef USE _SKINNING
uniform mat4 bindMatrix ;
uniform mat4 bindMatrixInverse ;
# ifdef BONE _TEXTURE
uniform highp sampler2D boneTexture ;
uniform int boneTextureSize ;
mat4 getBoneMatrix ( const in float i ) {
float j = i * 4.0 ;
float x = mod ( j , float ( boneTextureSize ) ) ;
float y = floor ( j / float ( boneTextureSize ) ) ;
float dx = 1.0 / float ( boneTextureSize ) ;
float dy = 1.0 / float ( boneTextureSize ) ;
y = dy * ( y + 0.5 ) ;
vec4 v1 = texture2D ( boneTexture , vec2 ( dx * ( x + 0.5 ) , y ) ) ;
vec4 v2 = texture2D ( boneTexture , vec2 ( dx * ( x + 1.5 ) , y ) ) ;
vec4 v3 = texture2D ( boneTexture , vec2 ( dx * ( x + 2.5 ) , y ) ) ;
vec4 v4 = texture2D ( boneTexture , vec2 ( dx * ( x + 3.5 ) , y ) ) ;
mat4 bone = mat4 ( v1 , v2 , v3 , v4 ) ;
return bone ;
}
# else
uniform mat4 boneMatrices [ MAX _BONES ] ;
mat4 getBoneMatrix ( const in float i ) {
mat4 bone = boneMatrices [ int ( i ) ] ;
return bone ;
}
# endif
# endif ` ,Fv= ` # ifdef USE _SKINNING
vec4 skinVertex = bindMatrix * vec4 ( transformed , 1.0 ) ;
vec4 skinned = vec4 ( 0.0 ) ;
skinned += boneMatX * skinVertex * skinWeight . x ;
skinned += boneMatY * skinVertex * skinWeight . y ;
skinned += boneMatZ * skinVertex * skinWeight . z ;
skinned += boneMatW * skinVertex * skinWeight . w ;
transformed = ( bindMatrixInverse * skinned ) . xyz ;
# endif ` ,Bv= ` # ifdef USE _SKINNING
mat4 skinMatrix = mat4 ( 0.0 ) ;
skinMatrix += skinWeight . x * boneMatX ;
skinMatrix += skinWeight . y * boneMatY ;
skinMatrix += skinWeight . z * boneMatZ ;
skinMatrix += skinWeight . w * boneMatW ;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix ;
objectNormal = vec4 ( skinMatrix * vec4 ( objectNormal , 0.0 ) ) . xyz ;
# ifdef USE _TANGENT
objectTangent = vec4 ( skinMatrix * vec4 ( objectTangent , 0.0 ) ) . xyz ;
# endif
# endif ` ,Pv= ` float specularStrength ;
# ifdef USE _SPECULARMAP
vec4 texelSpecular = texture2D ( specularMap , vUv ) ;
specularStrength = texelSpecular . r ;
# else
specularStrength = 1.0 ;
# endif ` ,Iv= ` # ifdef USE _SPECULARMAP
uniform sampler2D specularMap ;
# endif ` ,kv= ` # if defined ( TONE _MAPPING )
gl _FragColor . rgb = toneMapping ( gl _FragColor . rgb ) ;
# endif ` ,Ov= ` # ifndef saturate
# define saturate ( a ) clamp ( a , 0.0 , 1.0 )
# endif
uniform float toneMappingExposure ;
vec3 LinearToneMapping ( vec3 color ) {
return toneMappingExposure * color ;
}
vec3 ReinhardToneMapping ( vec3 color ) {
color *= toneMappingExposure ;
return saturate ( color / ( vec3 ( 1.0 ) + color ) ) ;
}
vec3 OptimizedCineonToneMapping ( vec3 color ) {
color *= toneMappingExposure ;
color = max ( vec3 ( 0.0 ) , color - 0.004 ) ;
return pow ( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ) , vec3 ( 2.2 ) ) ;
}
vec3 RRTAndODTFit ( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537 ;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081 ;
return a / b ;
}
vec3 ACESFilmicToneMapping ( vec3 color ) {
const mat3 ACESInputMat = mat3 (
vec3 ( 0.59719 , 0.07600 , 0.02840 ) , vec3 ( 0.35458 , 0.90834 , 0.13383 ) ,
vec3 ( 0.04823 , 0.01566 , 0.83777 )
) ;
const mat3 ACESOutputMat = mat3 (
vec3 ( 1.60475 , - 0.10208 , - 0.00327 ) , vec3 ( - 0.53108 , 1.10813 , - 0.07276 ) ,
vec3 ( - 0.07367 , - 0.00605 , 1.07602 )
) ;
color *= toneMappingExposure / 0.6 ;
color = ACESInputMat * color ;
color = RRTAndODTFit ( color ) ;
color = ACESOutputMat * color ;
return saturate ( color ) ;
}
vec3 CustomToneMapping ( vec3 color ) { return color ; } ` ,Uv= ` # ifdef USE _TRANSMISSION
float transmissionAlpha = 1.0 ;
float transmissionFactor = transmission ;
float thicknessFactor = thickness ;
# ifdef USE _TRANSMISSIONMAP
transmissionFactor *= texture2D ( transmissionMap , vUv ) . r ;
# endif
# ifdef USE _THICKNESSMAP
thicknessFactor *= texture2D ( thicknessMap , vUv ) . g ;
# endif
vec3 pos = vWorldPosition ;
vec3 v = normalize ( cameraPosition - pos ) ;
vec3 n = inverseTransformDirection ( normal , viewMatrix ) ;
vec4 transmission = getIBLVolumeRefraction (
n , v , roughnessFactor , material . diffuseColor , material . specularColor , material . specularF90 ,
pos , modelMatrix , viewMatrix , projectionMatrix , ior , thicknessFactor ,
attenuationColor , attenuationDistance ) ;
totalDiffuse = mix ( totalDiffuse , transmission . rgb , transmissionFactor ) ;
transmissionAlpha = mix ( transmissionAlpha , transmission . a , transmissionFactor ) ;
# endif ` ,qv= ` # ifdef USE _TRANSMISSION
uniform float transmission ;
uniform float thickness ;
uniform float attenuationDistance ;
uniform vec3 attenuationColor ;
# ifdef USE _TRANSMISSIONMAP
uniform sampler2D transmissionMap ;
# endif
# ifdef USE _THICKNESSMAP
uniform sampler2D thicknessMap ;
# endif
uniform vec2 transmissionSamplerSize ;
uniform sampler2D transmissionSamplerMap ;
uniform mat4 modelMatrix ;
uniform mat4 projectionMatrix ;
varying vec3 vWorldPosition ;
vec3 getVolumeTransmissionRay ( const in vec3 n , const in vec3 v , const in float thickness , const in float ior , const in mat4 modelMatrix ) {
vec3 refractionVector = refract ( - v , normalize ( n ) , 1.0 / ior ) ;
vec3 modelScale ;
modelScale . x = length ( vec3 ( modelMatrix [ 0 ] . xyz ) ) ;
modelScale . y = length ( vec3 ( modelMatrix [ 1 ] . xyz ) ) ;
modelScale . z = length ( vec3 ( modelMatrix [ 2 ] . xyz ) ) ;
return normalize ( refractionVector ) * thickness * modelScale ;
}
float applyIorToRoughness ( const in float roughness , const in float ior ) {
return roughness * clamp ( ior * 2.0 - 2.0 , 0.0 , 1.0 ) ;
}
vec4 getTransmissionSample ( const in vec2 fragCoord , const in float roughness , const in float ior ) {
float framebufferLod = log2 ( transmissionSamplerSize . x ) * applyIorToRoughness ( roughness , ior ) ;
# ifdef TEXTURE _LOD _EXT
return texture2DLodEXT ( transmissionSamplerMap , fragCoord . xy , framebufferLod ) ;
# else
return texture2D ( transmissionSamplerMap , fragCoord . xy , framebufferLod ) ;
# endif
}
vec3 applyVolumeAttenuation ( const in vec3 radiance , const in float transmissionDistance , const in vec3 attenuationColor , const in float attenuationDistance ) {
if ( attenuationDistance == 0.0 ) {
return radiance ;
} else {
vec3 attenuationCoefficient = - log ( attenuationColor ) / attenuationDistance ;
vec3 transmittance = exp ( - attenuationCoefficient * transmissionDistance ) ; return transmittance * radiance ;
}
}
vec4 getIBLVolumeRefraction ( const in vec3 n , const in vec3 v , const in float roughness , const in vec3 diffuseColor ,
const in vec3 specularColor , const in float specularF90 , const in vec3 position , const in mat4 modelMatrix ,
const in mat4 viewMatrix , const in mat4 projMatrix , const in float ior , const in float thickness ,
const in vec3 attenuationColor , const in float attenuationDistance ) {
vec3 transmissionRay = getVolumeTransmissionRay ( n , v , thickness , ior , modelMatrix ) ;
vec3 refractedRayExit = position + transmissionRay ;
vec4 ndcPos = projMatrix * viewMatrix * vec4 ( refractedRayExit , 1.0 ) ;
vec2 refractionCoords = ndcPos . xy / ndcPos . w ;
refractionCoords += 1.0 ;
refractionCoords /= 2.0 ;
vec4 transmittedLight = getTransmissionSample ( refractionCoords , roughness , ior ) ;
vec3 attenuatedColor = applyVolumeAttenuation ( transmittedLight . rgb , length ( transmissionRay ) , attenuationColor , attenuationDistance ) ;
vec3 F = EnvironmentBRDF ( n , v , specularColor , specularF90 , roughness ) ;
return vec4 ( ( 1.0 - F ) * attenuatedColor * diffuseColor , transmittedLight . a ) ;
}
# endif ` ,Gv= ` # if ( defined ( USE _UV ) && ! defined ( UVS _VERTEX _ONLY ) )
varying vec2 vUv ;
# endif ` ,Wv= ` # ifdef USE _UV
# ifdef UVS _VERTEX _ONLY
vec2 vUv ;
# else
varying vec2 vUv ;
# endif
uniform mat3 uvTransform ;
# endif ` ,jv= ` # ifdef USE _UV
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
# endif ` ,Zv= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
varying vec2 vUv2 ;
# endif ` ,Xv= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
attribute vec2 uv2 ;
varying vec2 vUv2 ;
uniform mat3 uv2Transform ;
# endif ` ,Yv= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
vUv2 = ( uv2Transform * vec3 ( uv2 , 1 ) ) . xy ;
# endif ` , $ v= ` # if defined ( USE _ENVMAP ) || defined ( DISTANCE ) || defined ( USE _SHADOWMAP ) || defined ( USE _TRANSMISSION )
vec4 worldPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _INSTANCING
worldPosition = instanceMatrix * worldPosition ;
# endif
worldPosition = modelMatrix * worldPosition ;
# endif ` ,Jv= ` varying vec2 vUv ;
uniform mat3 uvTransform ;
void main ( ) {
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
gl _Position = vec4 ( position . xy , 1.0 , 1.0 ) ;
} ` ,Qv= ` uniform sampler2D t2D ;
varying vec2 vUv ;
void main ( ) {
gl _FragColor = texture2D ( t2D , vUv ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,Kv= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
gl _Position . z = gl _Position . w ;
} ` ,ex= ` # include < envmap _common _pars _fragment >
uniform float opacity ;
varying vec3 vWorldDirection ;
# include < cube _uv _reflection _fragment >
void main ( ) {
vec3 vReflect = vWorldDirection ;
# include < envmap _fragment >
gl _FragColor = envColor ;
gl _FragColor . a *= opacity ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,tx= ` # include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
varying vec2 vHighPrecisionZW ;
void main ( ) {
# include < uv _vertex >
# include < skinbase _vertex >
# ifdef USE _DISPLACEMENTMAP
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinnormal _vertex >
# endif
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
vHighPrecisionZW = gl _Position . zw ;
} ` ,ix= ` # if DEPTH _PACKING == 3200
uniform float opacity ;
# endif
# include < common >
# include < packing >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
varying vec2 vHighPrecisionZW ;
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( 1.0 ) ;
# if DEPTH _PACKING == 3200
diffuseColor . a = opacity ;
# endif
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < logdepthbuf _fragment >
float fragCoordZ = 0.5 * vHighPrecisionZW [ 0 ] / vHighPrecisionZW [ 1 ] + 0.5 ;
# if DEPTH _PACKING == 3200
gl _FragColor = vec4 ( vec3 ( 1.0 - fragCoordZ ) , opacity ) ;
# elif DEPTH _PACKING == 3201
gl _FragColor = packDepthToRGBA ( fragCoordZ ) ;
# endif
} ` ,nx= ` # define DISTANCE
varying vec3 vWorldPosition ;
# include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < skinbase _vertex >
# ifdef USE _DISPLACEMENTMAP
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinnormal _vertex >
# endif
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < worldpos _vertex >
# include < clipping _planes _vertex >
vWorldPosition = worldPosition . xyz ;
} ` ,rx= ` # define DISTANCE
uniform vec3 referencePosition ;
uniform float nearDistance ;
uniform float farDistance ;
varying vec3 vWorldPosition ;
# include < common >
# include < packing >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( 1.0 ) ;
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
float dist = length ( vWorldPosition - referencePosition ) ;
dist = ( dist - nearDistance ) / ( farDistance - nearDistance ) ;
dist = saturate ( dist ) ;
gl _FragColor = packDepthToRGBA ( dist ) ;
} ` ,sx= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
} ` ,ax= ` uniform sampler2D tEquirect ;
varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vec3 direction = normalize ( vWorldDirection ) ;
vec2 sampleUV = equirectUv ( direction ) ;
gl _FragColor = texture2D ( tEquirect , sampleUV ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,ox= ` uniform float scale ;
attribute float lineDistance ;
varying float vLineDistance ;
# include < common >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
vLineDistance = scale * lineDistance ;
# include < color _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < fog _vertex >
} ` ,cx= ` uniform vec3 diffuse ;
uniform float opacity ;
uniform float dashSize ;
uniform float totalSize ;
varying float vLineDistance ;
# include < common >
# include < color _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
if ( mod ( vLineDistance , totalSize ) > dashSize ) {
discard ;
}
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < color _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
} ` ,lx= ` # include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < envmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# if defined ( USE _ENVMAP ) || defined ( USE _SKINNING )
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# endif
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < worldpos _vertex >
# include < envmap _vertex >
# include < fog _vertex >
} ` ,hx= ` uniform vec3 diffuse ;
uniform float opacity ;
# ifndef FLAT _SHADED
varying vec3 vNormal ;
# endif
# include < common >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < fog _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
# ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
reflectedLight . indirectDiffuse += lightMapTexel . rgb * lightMapIntensity ;
# else
reflectedLight . indirectDiffuse += vec3 ( 1.0 ) ;
# endif
# include < aomap _fragment >
reflectedLight . indirectDiffuse *= diffuseColor . rgb ;
vec3 outgoingLight = reflectedLight . indirectDiffuse ;
# include < envmap _fragment >
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,ux= ` # define LAMBERT
varying vec3 vLightFront ;
varying vec3 vIndirectFront ;
# ifdef DOUBLE _SIDED
varying vec3 vLightBack ;
varying vec3 vIndirectBack ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < envmap _pars _vertex >
# include < bsdfs >
# include < lights _pars _begin >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < worldpos _vertex >
# include < envmap _vertex >
# include < lights _lambert _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
} ` ,fx= ` uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
varying vec3 vLightFront ;
varying vec3 vIndirectFront ;
# ifdef DOUBLE _SIDED
varying vec3 vLightBack ;
varying vec3 vIndirectBack ;
# endif
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < fog _pars _fragment >
# include < shadowmap _pars _fragment >
# include < shadowmask _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
# include < emissivemap _fragment >
# ifdef DOUBLE _SIDED
reflectedLight . indirectDiffuse += ( gl _FrontFacing ) ? vIndirectFront : vIndirectBack ;
# else
reflectedLight . indirectDiffuse += vIndirectFront ;
# endif
# include < lightmap _fragment >
reflectedLight . indirectDiffuse *= BRDF _Lambert ( diffuseColor . rgb ) ;
# ifdef DOUBLE _SIDED
reflectedLight . directDiffuse = ( gl _FrontFacing ) ? vLightFront : vLightBack ;
# else
reflectedLight . directDiffuse = vLightFront ;
# endif
reflectedLight . directDiffuse *= BRDF _Lambert ( diffuseColor . rgb ) * getShadowMask ( ) ;
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + totalEmissiveRadiance ;
# include < envmap _fragment >
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,dx= ` # define MATCAP
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < color _pars _vertex >
# include < displacementmap _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < color _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < fog _vertex >
vViewPosition = - mvPosition . xyz ;
} ` ,px= ` # define MATCAP
uniform vec3 diffuse ;
uniform float opacity ;
uniform sampler2D matcap ;
varying vec3 vViewPosition ;
# include < common >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < normal _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
vec3 viewDir = normalize ( vViewPosition ) ;
vec3 x = normalize ( vec3 ( viewDir . z , 0.0 , - viewDir . x ) ) ;
vec3 y = cross ( viewDir , x ) ;
vec2 uv = vec2 ( dot ( x , normal ) , dot ( y , normal ) ) * 0.495 + 0.5 ;
# ifdef USE _MATCAP
vec4 matcapColor = texture2D ( matcap , uv ) ;
# else
vec4 matcapColor = vec4 ( vec3 ( mix ( 0.2 , 0.8 , uv . y ) ) , 1.0 ) ;
# endif
vec3 outgoingLight = diffuseColor . rgb * matcapColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,mx= ` # define NORMAL
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
varying vec3 vViewPosition ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
vViewPosition = - mvPosition . xyz ;
# endif
} ` ,gx= ` # define NORMAL
uniform float opacity ;
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
varying vec3 vViewPosition ;
# endif
# include < packing >
# include < uv _pars _fragment >
# include < normal _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
# include < logdepthbuf _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
gl _FragColor = vec4 ( packNormalToRGB ( normal ) , opacity ) ;
} ` ,vx= ` # define PHONG
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < envmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
vViewPosition = - mvPosition . xyz ;
# include < worldpos _vertex >
# include < envmap _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
} ` ,xx= ` # define PHONG
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform vec3 specular ;
uniform float shininess ;
uniform float opacity ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _phong _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _phong _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + reflectedLight . directSpecular + reflectedLight . indirectSpecular + totalEmissiveRadiance ;
# include < envmap _fragment >
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,yx= ` # define STANDARD
varying vec3 vViewPosition ;
# ifdef USE _TRANSMISSION
varying vec3 vWorldPosition ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
vViewPosition = - mvPosition . xyz ;
# include < worldpos _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
# ifdef USE _TRANSMISSION
vWorldPosition = worldPosition . xyz ;
# endif
} ` ,wx= ` # define STANDARD
# ifdef PHYSICAL
# define IOR
# define SPECULAR
# endif
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float roughness ;
uniform float metalness ;
uniform float opacity ;
# ifdef IOR
uniform float ior ;
# endif
# ifdef SPECULAR
uniform float specularIntensity ;
uniform vec3 specularColor ;
# ifdef USE _SPECULARINTENSITYMAP
uniform sampler2D specularIntensityMap ;
# endif
# ifdef USE _SPECULARCOLORMAP
uniform sampler2D specularColorMap ;
# endif
# endif
# ifdef USE _CLEARCOAT
uniform float clearcoat ;
uniform float clearcoatRoughness ;
# endif
# ifdef USE _SHEEN
uniform vec3 sheenColor ;
uniform float sheenRoughness ;
# ifdef USE _SHEENCOLORMAP
uniform sampler2D sheenColorMap ;
# endif
# ifdef USE _SHEENROUGHNESSMAP
uniform sampler2D sheenRoughnessMap ;
# endif
# endif
varying vec3 vViewPosition ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < bsdfs >
# include < cube _uv _reflection _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _physical _pars _fragment >
# include < fog _pars _fragment >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _physical _pars _fragment >
# include < transmission _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < clearcoat _pars _fragment >
# include < roughnessmap _pars _fragment >
# include < metalnessmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < roughnessmap _fragment >
# include < metalnessmap _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < clearcoat _normal _fragment _begin >
# include < clearcoat _normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _physical _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 totalDiffuse = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse ;
vec3 totalSpecular = reflectedLight . directSpecular + reflectedLight . indirectSpecular ;
# include < transmission _fragment >
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance ;
# ifdef USE _SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3 ( material . sheenColor ) ;
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular ;
# endif
# ifdef USE _CLEARCOAT
float dotNVcc = saturate ( dot ( geometry . clearcoatNormal , geometry . viewDir ) ) ;
vec3 Fcc = F _Schlick ( material . clearcoatF0 , material . clearcoatF90 , dotNVcc ) ;
outgoingLight = outgoingLight * ( 1.0 - material . clearcoat * Fcc ) + clearcoatSpecular * material . clearcoat ;
# endif
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,bx= ` # define TOON
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
vViewPosition = - mvPosition . xyz ;
# include < worldpos _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
} ` ,Mx= ` # define TOON
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < gradientmap _pars _fragment >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _toon _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _toon _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + totalEmissiveRadiance ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,zx= ` uniform float size ;
uniform float scale ;
# include < common >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < color _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < project _vertex >
gl _PointSize = size ;
# ifdef USE _SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix ( projectionMatrix ) ;
if ( isPerspective ) gl _PointSize *= ( scale / - mvPosition . z ) ;
# endif
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < worldpos _vertex >
# include < fog _vertex >
} ` ,Cx= ` uniform vec3 diffuse ;
uniform float opacity ;
# include < common >
# include < color _pars _fragment >
# include < map _particle _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _particle _fragment >
# include < color _fragment >
# include < alphatest _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
} ` ,Ax= ` # include < common >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
void main ( ) {
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < project _vertex >
# include < worldpos _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
} ` ,Sx= ` uniform vec3 color ;
uniform float opacity ;
# include < common >
# include < packing >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < shadowmap _pars _fragment >
# include < shadowmask _pars _fragment >
void main ( ) {
gl _FragColor = vec4 ( color , opacity * ( 1.0 - getShadowMask ( ) ) ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
} ` ,_x= ` uniform float rotation ;
uniform vec2 center ;
# include < common >
# include < uv _pars _vertex >
# include < fog _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
vec4 mvPosition = modelViewMatrix * vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
vec2 scale ;
scale . x = length ( vec3 ( modelMatrix [ 0 ] . x , modelMatrix [ 0 ] . y , modelMatrix [ 0 ] . z ) ) ;
scale . y = length ( vec3 ( modelMatrix [ 1 ] . x , modelMatrix [ 1 ] . y , modelMatrix [ 1 ] . z ) ) ;
# ifndef USE _SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix ( projectionMatrix ) ;
if ( isPerspective ) scale *= - mvPosition . z ;
# endif
vec2 alignedPosition = ( position . xy - ( center - vec2 ( 0.5 ) ) ) * scale ;
vec2 rotatedPosition ;
rotatedPosition . x = cos ( rotation ) * alignedPosition . x - sin ( rotation ) * alignedPosition . y ;
rotatedPosition . y = sin ( rotation ) * alignedPosition . x + cos ( rotation ) * alignedPosition . y ;
mvPosition . xy += rotatedPosition ;
gl _Position = projectionMatrix * mvPosition ;
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < fog _vertex >
} ` ,Ex= ` uniform vec3 diffuse ;
uniform float opacity ;
# include < common >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
} ` ,Be={alphamap_fragment:ng,alphamap_pars_fragment:rg,alphatest_fragment:sg,alphatest_pars_fragment:ag,aomap_fragment:og,aomap_pars_fragment:cg,begin_vertex:lg,beginnormal_vertex:hg,bsdfs:ug,bumpmap_pars_fragment:fg,clipping_planes_fragment:dg,clipping_planes_pars_fragment:pg,clipping_planes_pars_vertex:mg,clipping_planes_vertex:gg,color_fragment:vg,color_pars_fragment:xg,color_pars_vertex:yg,color_vertex:wg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:zg,displacementmap_pars_vertex:Cg,displacementmap_vertex:Ag,emissivemap_fragment:Sg,emissivemap_pars_fragment:_g,encodings_fragment:Eg,encodings_pars_fragment:Lg,envmap_fragment:Tg,envmap_common_pars_fragment:Dg,envmap_pars_fragment:Hg,envmap_pars_vertex:Vg,envmap_physical_pars_fragment:Gg,envmap_vertex:Rg,fog_vertex:Ng,fog_pars_vertex:Fg,fog_fragment:Bg,fog_pars_fragment:Pg,gradientmap_pars_fragment:Ig,lightmap_fragment:kg,lightmap_pars_fragment:Og,lights_lambert_vertex:Ug,lights_pars_begin:qg,lights_toon_fragment:Wg,lights_toon_pars_fragment:jg,lights_phong_fragment:Zg,lights_phong_pars_fragment:Xg,lights_physical_fragment:Yg,lights_physical_pars_fragment: $ g,lights_fragment_begin:Jg,lights_fragment_maps:Qg,lights_fragment_end:Kg,logdepthbuf_fragment:ev,logdepthbuf_pars_fragment:tv,logdepthbuf_pars_vertex:iv,logdepthbuf_vertex:nv,map_fragment:rv,map_pars_fragment:sv,map_particle_fragment:av,map_particle_pars_fragment:ov,metalnessmap_fragment:cv,metalnessmap_pars_fragment:lv,morphnormal_vertex:hv,morphtarget_pars_vertex:uv,morphtarget_vertex:fv,normal_fragment_begin:dv,normal_fragment_maps:pv,normal_pars_fragment:mv,normal_pars_vertex:gv,normal_vertex:vv,normalmap_pars_fragment:xv,clearcoat_normal_fragment_begin:yv,clearcoat_normal_fragment_maps:wv,clearcoat_pars_fragment:bv,output_fragment:Mv,packing:zv,premultiplied_alpha_fragment:Cv,project_vertex:Av,dithering_fragment:Sv,dithering_pars_fragment:_v,roughnessmap_fragment:Ev,roughnessmap_pars_fragment:Lv,shadowmap_pars_fragment:Tv,shadowmap_pars_vertex:Dv,shadowmap_vertex:Hv,shadowmask_pars_fragment:Vv,skinbase_vertex:Rv,skinning_pars_vertex:Nv,skinning_vertex:Fv,skinnormal_vertex:Bv,specularmap_fragment:Pv,specularmap_pars_fragment:Iv,tonemapping_fragment:kv,tonemapping_pars_fragment:Ov,transmission_fragment:Uv,transmission_pars_fragment:qv,uv_pars_fragment:Gv,uv_pars_vertex:Wv,uv_vertex:jv,uv2_pars_fragment:Zv,uv2_pars_vertex:Xv,uv2_vertex:Yv,worldpos_vertex: $ v,background_vert:Jv,background_frag:Qv,cube_vert:Kv,cube_frag:ex,depth_vert:tx,depth_frag:ix,distanceRGBA_vert:nx,distanceRGBA_frag:rx,equirect_vert:sx,equirect_frag:ax,linedashed_vert:ox,linedashed_frag:cx,meshbasic_vert:lx,meshbasic_frag:hx,meshlambert_vert:ux,meshlambert_frag:fx,meshmatcap_vert:dx,meshmatcap_frag:px,meshnormal_vert:mx,meshnormal_frag:gx,meshphong_vert:vx,meshphong_frag:xx,meshphysical_vert:yx,meshphysical_frag:wx,meshtoon_vert:bx,meshtoon_frag:Mx,points_vert:zx,points_frag:Cx,shadow_vert:Ax,shadow_frag:Sx,sprite_vert:_x,sprite_frag:Ex},oe={common:{diffuse:{value:new we(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new At},uv2Transform:{value:new At},alphaMap:{value:null},alphaTest:{value:0}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalScale:{value:new te(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new we(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{}
precision mediump float ;
precision mediump int ;
varying vec3 vOutputDirection ;
uniform sampler2D envMap ;
uniform int samples ;
uniform float weights [ n ] ;
uniform bool latitudinal ;
uniform float dTheta ;
uniform float mipInt ;
uniform vec3 poleAxis ;
# define ENVMAP _TYPE _CUBE _UV
# include < cube _uv _reflection _fragment >
vec3 getSample ( float theta , vec3 axis ) {
float cosTheta = cos ( theta ) ;
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross ( axis , vOutputDirection ) * sin ( theta )
+ axis * dot ( axis , vOutputDirection ) * ( 1.0 - cosTheta ) ;
return bilinearCubeUV ( envMap , sampleDirection , mipInt ) ;
}
void main ( ) {
vec3 axis = latitudinal ? poleAxis : cross ( poleAxis , vOutputDirection ) ;
if ( all ( equal ( axis , vec3 ( 0.0 ) ) ) ) {
axis = vec3 ( vOutputDirection . z , 0.0 , - vOutputDirection . x ) ;
}
axis = normalize ( axis ) ;
gl _FragColor = vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
gl _FragColor . rgb += weights [ 0 ] * getSample ( 0.0 , axis ) ;
for ( int i = 1 ; i < n ; i ++ ) {
if ( i >= samples ) {
break ;
}
float theta = dTheta * float ( i ) ;
gl _FragColor . rgb += weights [ i ] * getSample ( - 1.0 * theta , axis ) ;
gl _FragColor . rgb += weights [ i ] * getSample ( theta , axis ) ;
}
}
` ,blending:fi,depthTest:!1,depthWrite:!1})}function Rh(){let a=new te(1,1);return new dr({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:a}},vertexShader:Pc(),fragmentShader: `
precision mediump float ;
precision mediump int ;
varying vec3 vOutputDirection ;
uniform sampler2D envMap ;
uniform vec2 texelSize ;
# include < common >
void main ( ) {
gl _FragColor = vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
vec3 outputDirection = normalize ( vOutputDirection ) ;
vec2 uv = equirectUv ( outputDirection ) ;
vec2 f = fract ( uv / texelSize - 0.5 ) ;
uv -= f * texelSize ;
vec3 tl = texture2D ( envMap , uv ) . rgb ;
uv . x += texelSize . x ;
vec3 tr = texture2D ( envMap , uv ) . rgb ;
uv . y += texelSize . y ;
vec3 br = texture2D ( envMap , uv ) . rgb ;
uv . x -= texelSize . x ;
vec3 bl = texture2D ( envMap , uv ) . rgb ;
vec3 tm = mix ( tl , tr , f . x ) ;
vec3 bm = mix ( bl , br , f . x ) ;
gl _FragColor . rgb = mix ( tm , bm , f . y ) ;
}
` ,blending:fi,depthTest:!1,depthWrite:!1})}function Nh(){return new dr({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Pc(),fragmentShader: `
precision mediump float ;
precision mediump int ;
uniform float flipEnvMap ;
varying vec3 vOutputDirection ;
uniform samplerCube envMap ;
void main ( ) {
gl _FragColor = textureCube ( envMap , vec3 ( flipEnvMap * vOutputDirection . x , vOutputDirection . yz ) ) ;
}
` ,blending:fi,depthTest:!1,depthWrite:!1})}function Pc(){return `
precision mediump float ;
precision mediump int ;
attribute vec3 position ;
attribute vec2 uv ;
attribute float faceIndex ;
varying vec3 vOutputDirection ;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection ( vec2 uv , float face ) {
uv = 2.0 * uv - 1.0 ;
vec3 direction = vec3 ( uv , 1.0 ) ;
if ( face == 0.0 ) {
direction = direction . zyx ; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction . xzy ;
direction . xz *= - 1.0 ; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction . x *= - 1.0 ; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction . zyx ;
direction . xz *= - 1.0 ; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction . xzy ;
direction . xy *= - 1.0 ; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction . z *= - 1.0 ; // ( u, v, -1 ) neg z
}
return direction ;
}
void main ( ) {
vOutputDirection = getDirection ( uv , faceIndex ) ;
gl _Position = vec4 ( position , 1.0 ) ;
}
` }function Bx(a){let e=new WeakMap,t=null;function i(o){if(o&&o.isTexture){let c=o.mapping,l=c===w3||c===b3,h=c===ea||c===ta;if(l||h)if(o.isRenderTargetTexture&&o.needsPMREMUpdate===!0){o.needsPMREMUpdate=!1;let u=e.get(o);return t===null&&(t=new Ao(a)),u=l?t.fromEquirectangular(o,u):t.fromCubemap(o,u),e.set(o,u),u.texture}else{if(e.has(o))return e.get(o).texture;{let u=o.image;if(l&&u&&u.height>0||h&&u&&n(u)){t===null&&(t=new Ao(a));let f=l?t.fromEquirectangular(o):t.fromCubemap(o);return e.set(o,f),o.addEventListener("dispose",r),f.texture}else return null}}}return o}function n(o){let c=0,l=6;for(let h=0;h<l;h++)o[h]!==void 0&&c++;return c===l}function r(o){let c=o.target;c.removeEventListener("dispose",r);let l=e.get(c);l!==void 0&&(e.delete(c),l.dispose())}function s(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:s}}function Px(a){let e={};function t(i){if(e[i]!==void 0)return e[i];let n;switch(i){case"WEBGL_depth_texture":n=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=a.getExtension(i)}return e[i]=n,n}return{has:function(i){return t(i)!==null},init:function(i){i.isWebGL2?t("EXT_color_buffer_float"):(t("WEBGL_depth_texture"),t("OES_texture_float"),t("OES_texture_half_float"),t("OES_texture_half_float_linear"),t("OES_standard_derivatives"),t("OES_element_index_uint"),t("OES_vertex_array_object"),t("ANGLE_instanced_arrays")),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture")},get:function(i){let n=t(i);return n===null&&console.warn("THREE.WebGLRenderer: "+i+" extension not supported."),n}}}function Ix(a,e,t,i){let n={},r=new WeakMap;function s(u){let f=u.target;f.index!==null&&e.remove(f.index);for(let p in f.attributes)e.remove(f.attributes[p]);f.removeEventListener("dispose",s),delete n[f.id];let d=r.get(f);d&&(e.remove(d),r.delete(f)),i.releaseStatesOfGeometry(f),f.isInstancedBufferGeometry===!0&&delete f._maxInstanceCount,t.memory.geometries--}function o(u,f){return n[f.id]===!0||(f.addEventListener("dispose",s),n[f.id]=!0,t.memory.geometries++),f}function c(u){let f=u.attributes;for(let p in f)e.update(f[p],34962);let d=u.morphAttributes;for(let p in d){let v=d[p];for(let x=0,g=v.length;x<g;x++)e.update(v[x],34962)}}function l(u){let f=[],d=u.index,p=u.attributes.position,v=0;if(d!==null){let m=d.array;v=d.version;for(let M=0,y=m.length;M<y;M+=3){let b=m[M+0],C=m[M+1],_=m[M+2];f.push(b,C,C,_,_,b)}}else{let m=p.array;v=p.version;for(let M=0,y=m.length/3-1;M<y;M+=3){let b=M+0,C=M+1,_=M+2;f.push(b,C,C,_,_,b)}}let x=new(Lu(f)?zo:Mo)(f,1);x.version=v;let g=r.get(u);g&&e.remove(g),r.set(u,x)}function h(u){let f=r.get(u);if(f){let d=u.index;d!==null&&f.version<d.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function kx(a,e,t,i){let n=i.isWebGL2,r;function s(f){r=f}let o,c;function l(f){o=f.type,c=f.bytesPerElement}function h(f,d){a.drawElements(r,d,o,f*c),t.update(d,r,1)}function u(f,d,p){if(p===0)return;let v,x;if(n)v=a,x="drawElementsInstanced";else if(v=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",v===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}v[x](r,d,o,f*c,p),t.update(d,r,p)}this.setMode=s,this.setIndex=l,this.render=h,this.renderInstances=u}function Ox(a){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,poi
` );for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join( `
` )}function Fy(a){switch(a){case xi:return["Linear","( value )"];case nt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",a),["Linear","( value )"]}}function Gh(a,e,t){let i=a.getShaderParameter(e,35713),n=a.getShaderInfoLog(e).trim();return i&&n===""?"":t.toUpperCase()+ `
` +n+ `
` +Ny(a.getShaderSource(e))}function By(a,e){let t=Fy(e);return"vec4 "+a+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Py(a,e){let t;switch(e){case hm:t="Linear";break;case um:t="Reinhard";break;case fm:t="OptimizedCineon";break;case dm:t="ACESFilmic";break;case pm:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+a+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Iy(a){return[a.extensionDerivatives||a.envMapCubeUV||a.bumpMap||a.tangentSpaceNormalMap||a.clearcoatNormalMap||a.flatShading||a.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(a.extensionFragDepth||a.logarithmicDepthBuffer)&&a.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",a.extensionDrawBuffers&&a.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(a.extensionShaderTextureLOD||a.envMap||a.transmission)&&a.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ws).join( `
` )}function ky(a){let e=[];for(let t in a){let i=a[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join( `
` )}function Oy(a,e){let t={},i=a.getProgramParameter(e,35721);for(let n=0;n<i;n++){let r=a.getActiveAttrib(e,n),s=r.name,o=1;r.type===35674&&(o=2),r.type===35675&&(o=3),r.type===35676&&(o=4),t[s]={type:r.type,location:a.getAttribLocation(e,s),locationSize:o}}return t}function ws(a){return a!==""}function Wh(a,e){return a.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function jh(a,e){return a.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Uy=/^[ \t ]*#include +<([ \w \d ./]+)>/gm;function E3(a){return a.replace(Uy,qy)}function qy(a,e){let t=Be[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return E3(t)}var Gy=/#pragma unroll_loop[ \s ]+?for \( int i \= ( \d +) \; i < ( \d +) \; i \+ \+ \) \{ ([ \s \S ]+?)(?= \} ) \} /g,Wy=/#pragma unroll_loop_start \s +for \s * \( \s *int \s +i \s *= \s *( \d +) \s *; \s *i \s *< \s *( \d +) \s *; \s *i \s * \+ \+ \s * \) \s *{([ \s \S ]+?)} \s +#pragma unroll_loop_end/g;function Zh(a){return a.replace(Wy,ku).replace(Gy,jy)}function jy(a,e,t,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),ku(a,e,t,i)}function ku(a,e,t,i){let n="";for(let r=parseInt(e);r<parseInt(t);r++)n+=i.replace(/ \[ \s *i \s * \] /g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return n}function Xh(a){let e="precision "+a.precision+ ` float ;
precision ` +a.precision+" int;";return a.precision==="highp"?e+= `
# define HIGH _PRECISION ` :a.precision==="mediump"?e+= `
# define MEDIUM _PRECISION ` :a.precision==="lowp"&&(e+= `
# define LOW _PRECISION ` ),e}function Zy(a){let e="SHADOWMAP_TYPE_BASIC";return a.shadowMapType===zu?e="SHADOWMAP_TYPE_PCF":a.shadowMapType===Nc?e="SHADOWMAP_TYPE_PCF_SOFT":a.shadowMapType===ys&&(e="SHADOWMAP_TYPE_VSM"),e}function Xy(a){let e="ENVMAP_TYPE_CUBE";if(a.envMap)switch(a.envMapMode){case ea:case ta:e="ENVMAP_TYPE_CUBE";break;case Zo:case Fc:e="ENVMAP_TYPE_CUBE_UV";break}return e}function Yy(a){let e="ENVMAP_MODE_REFLECTION";if(a.envMap)switch(a.envMapMode){case ta:case Fc:e="ENVMAP_MODE_REFRACTION";break}return e}function $ y(a){let e="ENVMAP_BLENDING_NONE";if(a.envMap)switch(a.combine){case jo:e="ENVMAP_BLENDING_MULTIPLY";break;case cm:e="ENVMAP_BLENDING_MIX";break;case lm:e="ENVMAP_BLENDING_ADD";break}return e}function Jy(a,e,t,i){let n=a.getContext(),r=t.defines,s=t.vertexShader,o=t.fragmentShader,c=Zy(t),l=Xy(t),h=Yy(t),u= $ y(t),f=t.isWebGL2?"":Iy(t),d=ky(r),p=n.createProgram(),v,x,g=t.glslVersion?"#version "+t.glslVersion+ `
` :"";t.isRawShaderMaterial?(v=[d].filter(ws).join( `
` ),v.length>0&&(v+= `
` ),x=[f,d].filter(ws).join( `
` ),x.length>0&&(x+= `
` )):(v=[Xh(t),"#define SHADER_NAME "+t.shaderName,d,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+t.maxBones,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+h:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.displacementMap&&t.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.useVertexTexture?"#define BONE_TEXTURE":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargets&&t.isWebGL2?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#if ( defined( USE_MORPHTARGETS ) && ! defined( MORPHTARGETS_TEXTURE ) )"," attribute vec3 morphTarget0;"," attribute vec3 morphTarget1;"," attribute vec3 morphTarget2;"," attribute vec3 morphTarget3;"," #ifdef USE_MORPHNORMALS"," attribute vec3 morphNormal0;"," attribute vec3 morphNormal1;"," attribute vec3 morphNormal2;"," attribute vec3 morphNormal3;"," #else"," attribute vec3 morphTarget4;"," attribute vec3 morphTarget5;"," attribute vec3 morphTarget6;"," attribute vec3 morphTarget7;"," #endif","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif", `
` ].filter(ws).join( `
` ),x=[f,Xh(t),"#define SHADER_NAME "+t.shaderName,d,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+l:"",t.envMap?"#define "+h:"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMap&&t.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",t.normalMap&&t.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",t.specularColorMap?"#define USE_SPECULARCOLORMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEENCOLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.vertexTangents?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUvs?"#define USE_UV":"",t.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+c:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(t.extensionShaderTextureLOD||t.envMap)&&t.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==di?"#define TONE_MAPPING":"",t.toneMapping!==di?Be.tonemapping_pars_fragment:"",t.toneMapping!==di?Py("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.alphaWrite?"":"#define OPAQUE",Be.encodings_pars_fragment,By("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"", `
` ].filter(ws).join( `
` )),s=E3(s),s=Wh(s,t),s=jh(s,t),o=E3(o),o=Wh(o,t),o=jh(o,t),s=Zh(s),o=Zh(o),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(g= ` # version 300 es
` ,v=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join( `
` )+ `
` +v,x=["#define varying in",t.glslVersion===vh?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===vh?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join( `
` )+ `
` +x);let m=g+v+s,M=g+x+o,y=qh(n,35633,m),b=qh(n,35632,M);if(n.attachShader(p,y),n.attachShader(p,b),t.index0AttributeName!==void 0?n.bindAttribLocation(p,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(p,0,"position"),n.linkProgram(p),a.debug.checkShaderErrors){let S=n.getProgramInfoLog(p).trim(),P=n.getShaderInfoLog(y).trim(),H=n.getShaderInfoLog(b).trim(),w=!0,T=!0;if(n.getProgramParameter(p,35714)===!1){w=!1;let A=Gh(n,y,"vertex"),R=Gh(n,b,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(p,35715)+ `
Program Info Log : ` +S+ `
` +A+ `
` +R)}else S!==""?console.warn("THREE.WebGLProgram: Program Info Log:",S):(P===""||H==="")&&(T=!1);T&&(this.diagnostics={runnable:w,programLog:S,vertexShader:{log:P,prefix:v},fragmentShader:{log:H,prefix:x}})}n.deleteShader(y),n.deleteShader(b);let C;this.getUniforms=function(){return C===void 0&&(C=new gi(n,p)),C};let _;return this.getAttributes=function(){return _===void 0&&(_=Oy(n,p)),_},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(p),this.program=void 0},this.name=t.shaderName,this.id=Ry++,this.cacheKey=e,this.usedTimes=1,this.program=p,this.vertexShader=y,this.fragmentShader=b,this}var Qy=0,L3=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),r=this._getShaderStage(i),s=this._getShaderCacheForMaterial(e);return s.has(n)===!1&&(s.add(n),n.usedTimes++),s.has(r)===!1&&(s.add(r),r.usedTimes++),this}remove(e){let t=this.materialCache.get(e);for(let i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){let t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){let t=this.shaderCache;if(t.has(e)===!1){let i=new T3;t.set(e,i)}return t.get(e)}},T3=class{constructor(){this.id=Qy++,this.usedTimes=0}};function Ky(a,e,t,i,n,r,s){let o=new bo,c=new L3,l=[],h=n.isWebGL2,u=n.logarithmicDepthBuffer,f=n.floatVertexTextures,d=n.maxVertexUniforms,p=n.vertexTextures,v=n.precision,x={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(w){let A=w.skeleton.bones;if(f)return 1024;{let V=Math.floor((d-20)/4),L=Math.min(V,A.length);return L<A.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+A.length+" bones. This GPU supports "+L+"."),0):L}}function m(w,T,A,R,V){let L=R.fog,N=w.isMeshStandardMaterial?R.environment:null,I=(w.isMeshStandardMaterial?t:e).get(w.envMap||N),W=x[w.type],O=V.isSkinnedMesh?g(V):0;w.precision!==null&&(v=n.getMaxPrecision(w.precision),v!==w.precision&&console.warn("THREE.WebGLProgram.getParameters:",w.precision,"not supported, using",v,"instead."));let q,j,ie,ae;if(W){let le=J1[W];q=le.vertexShader,j=le.fragmentShader}else q=w.vertexShader,j=w.fragmentShader,c.update(w),ie=c.getVertexShaderID(w),ae=c.getFragmentShaderID(w);let U=a.getRenderTarget(),Ce=w.alphaTest>0,ce=w.clearcoat>0;return{isWebGL2:h,shaderID:W,shaderName:w.type,vertexShader:q,fragmentShader:j,defines:w.defines,customVertexShaderID:ie,customFragmentShaderID:ae,isRawShaderMaterial:w.isRawShaderMaterial===!0,glslVersion:w.glslVersion,precision:v,instancing:V.isInstancedMesh===!0,instancingColor:V.isInstancedMesh===!0&&V.instanceColor!==null,supportsVertexTextures:p,outputEncoding:U===null?a.outputEncoding:U.isXRRenderTarget===!0?U.texture.encoding:xi,map:!!w.map,matcap:!!w.matcap,envMap:!!I,envMapMode:I&&I.mapping,envMapCubeUV:!!I&&(I.mapping===Zo||I.mapping===Fc),lightMap:!!w.lightMap,aoMap:!!w.aoMap,emissiveMap:!!w.emissiveMap,bumpMap:!!w.bumpMap,normalMap:!!w.normalMap,objectSpaceNormalMap:w.normalMapType===Fm,tangentSpaceNormalMap:w.normalMapType===br,decodeVideoTexture:!!w.map&&w.map.isVideoTexture===!0&&w.map.encoding===nt,clearcoat:ce,clearcoatMap:ce&&!!w.clearcoatMap,clearcoatRoughnessMap:ce&&!!w.clearcoatRoughnessMap,clearcoatNormalMap:ce&&!!w.clearcoatNormalMap,displacementMap:!!w.displacementMap,roughnessMap:!!w.roughnessMap,metalnessMap:!!w.metalnessMap,specularMap:!!w.specularMap,specularIntensityMap:!!w.specularIntensityMap,specularCo
gl _Position = vec4 ( position , 1.0 ) ;
} ` ,hw= ` uniform sampler2D shadow _pass ;
uniform vec2 resolution ;
uniform float radius ;
# include < packing >
void main ( ) {
const float samples = float ( VSM _SAMPLES ) ;
float mean = 0.0 ;
float squared _mean = 0.0 ;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ) ;
float uvStart = samples <= 1.0 ? 0.0 : - 1.0 ;
for ( float i = 0.0 ; i < samples ; i ++ ) {
float uvOffset = uvStart + i * uvStride ;
# ifdef HORIZONTAL _PASS
vec2 distribution = unpackRGBATo2Half ( texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( uvOffset , 0.0 ) * radius ) / resolution ) ) ;
mean += distribution . x ;
squared _mean += distribution . y * distribution . y + distribution . x * distribution . x ;
# else
float depth = unpackRGBAToDepth ( texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( 0.0 , uvOffset ) * radius ) / resolution ) ) ;
mean += depth ;
squared _mean += depth * depth ;
# endif
}
mean = mean / samples ;
squared _mean = squared _mean / samples ;
float std _dev = sqrt ( squared _mean - mean * mean ) ;
gl _FragColor = pack2HalfToRGBA ( vec2 ( mean , std _dev ) ) ;
} ` ;function Ou(a,e,t){let i=new fr,n=new te,r=new te,s=new $ e,o=new _o({depthPacking:Nm}),c=new Eo,l={},h=t.maxTextureSize,u={0:zt,1:As,2:or},f=new N2({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new te},radius:{value:4}},vertexShader:lw,fragmentShader:hw}),d=f.clone();d.defines.HORIZONTAL_PASS=1;let p=new st;p.setAttribute("position",new mt(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let v=new Vt(p,f),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=zu,this.render=function(y,b,C){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||y.length===0)return;let _=a.getRenderTarget(),S=a.getActiveCubeFace(),P=a.getActiveMipmapLevel(),H=a.state;H.setBlending(fi),H.buffers.color.setClear(1,1,1,1),H.buffers.depth.setTest(!0),H.setScissorTest(!1);for(let w=0,T=y.length;w<T;w++){let A=y[w],R=A.shadow;if(R===void 0){console.warn("THREE.WebGLShadowMap:",A,"has no shadow.");continue}if(R.autoUpdate===!1&&R.needsUpdate===!1)continue;n.copy(R.mapSize);let V=R.getFrameExtents();if(n.multiply(V),r.copy(R.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(r.x=Math.floor(h/V.x),n.x=r.x*V.x,R.mapSize.x=r.x),n.y>h&&(r.y=Math.floor(h/V.y),n.y=r.y*V.y,R.mapSize.y=r.y)),R.map===null&&!R.isPointLightShadow&&this.type===ys){let N={minFilter:It,magFilter:It,format:Xt};R.map=new e1(n.x,n.y,N),R.map.texture.name=A.name+".shadowMap",R.mapPass=new e1(n.x,n.y,N),R.camera.updateProjectionMatrix()}if(R.map===null){let N={minFilter:Ct,magFilter:Ct,format:Xt};R.map=new e1(n.x,n.y,N),R.map.texture.name=A.name+".shadowMap",R.camera.updateProjectionMatrix()}a.setRenderTarget(R.map),a.clear();let L=R.getViewportCount();for(let N=0;N<L;N++){let I=R.getViewport(N);s.set(r.x*I.x,r.y*I.y,r.x*I.z,r.y*I.w),H.viewport(s),R.updateMatrices(A,N),i=R.getFrustum(),M(b,C,R.camera,A,this.type)}!R.isPointLightShadow&&this.type===ys&&g(R,C),R.needsUpdate=!1}x.needsUpdate=!1,a.setRenderTarget(_,S,P)};function g(y,b){let C=e.update(v);f.defines.VSM_SAMPLES!==y.blurSamples&&(f.defines.VSM_SAMPLES=y.blurSamples,d.defines.VSM_SAMPLES=y.blurSamples,f.needsUpdate=!0,d.needsUpdate=!0),f.uniforms.shadow_pass.value=y.map.texture,f.uniforms.resolution.value=y.mapSize,f.uniforms.radius.value=y.radius,a.setRenderTarget(y.mapPass),a.clear(),a.renderBufferDirect(b,null,C,f,v,null),d.uniforms.shadow_pass.value=y.mapPass.texture,d.uniforms.resolution.value=y.mapSize,d.uniforms.radius.value=y.radius,a.setRenderTarget(y.map),a.clear(),a.renderBufferDirect(b,null,C,d,v,null)}function m(y,b,C,_,S,P,H){let w=null,T=_.isPointLight===!0?y.customDistanceMaterial:y.customDepthMaterial;if(T!==void 0?w=T:w=_.isPointLight===!0?c:o,a.localClippingEnabled&&C.clipShadows===!0&&C.clippingPlanes.length!==0||C.displacementMap&&C.displacementScale!==0||C.alphaMap&&C.alphaTest>0){let A=w.uuid,R=C.uuid,V=l[A];V===void 0&&(V={},l[A]=V);let L=V[R];L===void 0&&(L=w.clone(),V[R]=L),w=L}return w.visible=C.visible,w.wireframe=C.wireframe,H===ys?w.side=C.shadowSide!==null?C.shadowSide:C.side:w.side=C.shadowSide!==null?C.shadowSide:u[C.side],w.alphaMap=C.alphaMap,w.alphaTest=C.alphaTest,w.clipShadows=C.clipShadows,w.clippingPlanes=C.clippingPlanes,w.clipIntersection=C.clipIntersection,w.displacementMap=C.displacementMap,w.displacementScale=C.displacementScale,w.displacementBias=C.displacementBias,w.wireframeLinewidth=C.wireframeLinewidth,w.linewidth=C.linewidth,_.isPointLight===!0&&w.isMeshDistanceMaterial===!0&&(w.referencePosition.setFromMatrixPosition(_.matrixWorld),w.nearDistance=S,w.farDistance=P),w}function M(y,b,C,_,S){if(y.visible===!1)return;if(y.layers.test(b.layers)&&(y.isMesh||y.isLine||y.isPoints)&&(y.castShadow||y.receiveShadow&&S===ys)&&(!y.frustumCulled||i.intersectsObject(y))){y.modelViewMatrix.multiplyMatrices(C.matrixWorldInverse,y.matrixWorld);let w=e.update(y),T=y.material;if(Array.isArray(T)){let A=w.groups;for(let R=0,V=A.length;R<V;R++){let L=A[R],N=T[L.materialIndex];if(N&&N.visible){let I=m(y,w,N,_,C.near,C.far,S);a.renderBufferDirect(C,null,w,I,y,L)}}}else if(T.visible){let A=m(y,w,T,_,C.near,C.far,S);a.renderBufferDirect(C,null,w,A,y,null)}}let
` ),u=!0);let[v,x]=p.innerText.match(/^dice \- mod: \s *([ \s \S ]+) \s *?/),g=this.data.displayFormulaForMod;x.includes("|noform")&&(g=!1),x.includes("|form")&&(g=!0),x=x.replace("|noform","").replace("|form","");let m=await this.getRoller(x,i.sourcePath);m instanceof Gt&&(m.shouldRender&&(m.hasRunOnce=!0),m.on("new-result",()=>{this.data.addToView&&this.view?.addResult(m)})),f.push(new Promise((M,y)=>{m.on("new-result",async()=>{let b=h.slice(s.lineStart,s.lineEnd+1),C=await m.getReplacer();if(!C){new ft.Notice("Dice Roller: There was an issue modifying the file.");return}let _=g? ` $ { m . inlineText } $ { C } ` : ` $ { C } ` ;this.data.escapeDiceMod?b=b.join( `
` ).replace( ` \ ` ${ v } \` ` , _ . replace ( /([\*\[\]])/g , "\\$1" ) ) . split ( `
` ):b=b.join( `
` ).replace( ` \ ` ${ v } \` ` , _ ) . split ( `
` ),h.splice(s.lineStart,s.lineEnd-s.lineStart+1,...b),M()})})),await m.roll();continue}catch(v){console.error(v)}}if(/^dice(?: \+ | \- | \- mod)?: \s *([ \s \S ]+) \s *?/.test(p.innerText))try{let[,v]=p.innerText.match(/^dice(?: \+ | \- | \- mod)?: \s *([ \s \S ]+) \s *?/),x=await this.getRoller(v,i.sourcePath),g=this.data.results?.[r]?.[o]?.[d]??null;(this.data.persistResults&&!/dice \- /.test(p.innerText)||/dice \+ /.test(p.innerText))&&(this.persistingFiles.add(i.sourcePath),l[d]=x,x.save=!0);let m=this.data.renderAllDice;v.includes("|render")&&(m=!0),v.includes("|norender")&&(m=!1);let M=async()=>{await x.roll(),x.save&&g&&await x.applyResult(g),x instanceof Gt&&(x.shouldRender=m,x.on("new-result",()=>{this.data.addToView&&this.view?.addResult(x)})),p.replaceWith(x.containerEl)};if(x.loaded?await M():x.on("loaded",async()=>{await M()}),!c||!(c instanceof ft.TFile))continue;this.addToFileMap(c,x);let y=this.app.workspace.getActiveViewOfType(ft.MarkdownView);if(y&&this.fileMap.has(c)&&this.fileMap.get(c).length===1){let b=this,C=g0(y,{onUnloadFile:function(_){return async function(S){return S==c&&(b.fileMap.delete(c),C()),await _.call(this,S)}}});y.register(C),y.register(()=>this.fileMap.delete(c))}}catch(v){console.error(v),new ft.Notice( ` There was an error parsing the dice string : $ { p . innerText } .
$ { v } ` ,5e3);continue}}if(!(!c||!(c instanceof ft.TFile))&&(u&&f.length&&(await Promise.all(f),sleep(500),await this.app.vault.modify(c,h.join( `
` ))),r in this.data.results&&(this.data.results[r][o]={}),Object.entries(l).length)){let d=this.app.workspace.getActiveViewOfType(ft.MarkdownView);if(d){let p=this,v=g0(d,{onUnloadFile:function(x){return async function(g){if(g=c){p.persistingFiles.has(r)&&(p.persistingFiles.delete(r),p.data.results[r]={});for(let m in l){let M=l[m],y=i.getSectionInfo(t)?.lineStart;if(y==null)continue;let b={[y]:{...p.data.results[r]?.[y]??{},[m]:M.toResult()}};p.data.results[r]={...p.data.results[r]??{},...b},await p.saveSettings()}}return v(),await x.call(this,g)}}});d.register(v),d.register(async()=>{this.persistingFiles.has(r)&&(this.persistingFiles.delete(r),this.data.results[r]={});for(let x in l){let g=l[x],m=i.getSectionInfo(t)?.lineStart;if(m==null)continue;let M={[m]:{...this.data.results[r]?.[m]??{},[x]:g.toResult()}};this.data.results[r]={...this.data.results[r]??{},...M},await this.saveSettings()}})}}}get canUseDataview(){return this.app.plugins.getPlugin("dataview")!=null}get dataview(){return this.app.plugins.getPlugin("dataview")}get dataviewAPI(){return(0,h7.getAPI)()}async dataviewReady(){return new Promise(t=>{this.canUseDataview||t(!1),this.dataview.api&&t(!0),this.registerEvent(this.app.metadataCache.on("dataview:api-ready",()=>{t(!0)}))})}get view(){let t=this.app.workspace.getLeavesOfType(Fi),i=t.length?t[0]:null;if(i&&i.view&&i.view instanceof xn)return i.view}async getArrayRoller(t,i=1){let n=new ya(this,t,i);return await n.roll(),n}async addDiceView(t=!1){t&&!this.data.showLeafOnStartup||this.app.workspace.getLeavesOfType(Fi).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:Fi})}async registerDataviewInlineFields(){if(!this.canUseDataview)return;await this.dataviewReady(),this.dataview.index.pages.forEach(({fields:i})=>{for(let[n,r]of i)typeof r!="number"||Number.isNaN(r)||r==null||this.inline.set(n,r)}),this.parser.setInlineFields(this.inline),this.registerEvent(this.app.metadataCache.on("dataview:metadata-change",(i,n)=>{if(i==="update"){let r=this.dataview.api.page(n.path);if(!r)return;for(let s in r){let o=r[s];typeof o!="number"||Number.isNaN(o)||o==null||this.inline.set(s,o)}this.parser.setInlineFields(this.inline)}}))}async renderRoll(t){await t.roll(!0)}async parseDice(t,i){let n=await this.getRoller(t,i);return{result:await n.roll(),roller:n}}parseDiceSync(t,i){let n=this.getRollerSync(t,i);if(n instanceof Gt)return{result:n.result,roller:n}}clearEmpties(t){for(var i in t)!t[i]||typeof t[i]!="object"||(this.clearEmpties(t[i]),Object.keys(t[i]).length===0&&delete t[i])}async saveSettings(){this.clearEmpties(this.data.results),await this.saveData(this.data)}get dataview_regex(){let t=Array.from(this.inline.keys());return t.length?new RegExp( ` ( $ { t . join ( "|" ) } ) ` ,"g"):null}getParametersForRoller(t,i){t=t.replace(/ \\ \| /g,"|");let n=i?.showDice??!0,r=i?.shouldRender??this.data.renderAllDice,s=i?.showFormula??this.data.displayResultsInline,o=i?.showParens??this.data.displayFormulaAfter,c=i?.expectedValue??this.data.initialDisplay,l=i?.text??"",h=i?.round??this.data.round,u=i?.signed??this.data.signed,f=/ \| text \( (.*) \) /;if(t.includes("|nodice")&&(n=!1),t.includes("|render")&&(r=!0),t.includes("|norender")&&(r=!1),t.includes("|form")&&(s=!0),t.includes("|noform")&&(s=!1),t.includes("|avg")&&(c="Average"),t.includes("|none")&&(c="None"),t.includes("|text(")){let[,d]=t.match(f)??[null,""];l=d}return t.includes("|paren")&&(o=!0),t.includes("|noparen")&&(o=!1),t.includes("|round")&&(h="Normal"),t.includes("|noround")&&(h="None"),t.includes("|ceil")&&(h="Up"),t.includes("|floor")&&(h="Down"),t.includes("|signed")&&(u=!0),t=(0,u7.decode)(t.replace("|nodice","").replace("|render","").replace("|norender","").replace("|noform","").replace("|form","").replace("|noparen","").replace("|paren","").replace("|avg","").replace("|none","").replace("|round","").replace("|noround","").replace("|ceil","").replace("|floor","").replace("|signed","").replace(f,"")),t in this.data.formulas&&(t=this.data.formulas[t]),{content:t,showDice:n,showParens:o,showFormula:s,expectedValue:c,shouldRender:r,text:l,round:h,signed:u
/ * ! B u n d l e d l i c e n s e i n f o r m a t i o n :
he / he . js :
( * ! https : //mths.be/he v1.2.0 by @mathias | MIT license *)
@ fortawesome / free - solid - svg - icons / index . es . js :
( * !
* Font Awesome Free 5.15 . 4 by @ fontawesome - https : //fontawesome.com
* License - https : //fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* )
@ fortawesome / free - regular - svg - icons / index . es . js :
( * !
* Font Awesome Free 5.15 . 4 by @ fontawesome - https : //fontawesome.com
* License - https : //fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* )
@ fortawesome / fontawesome - svg - core / index . es . js :
( * !
* Font Awesome Free 5.15 . 3 by @ fontawesome - https : //fontawesome.com
* License - https : //fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
* )
three / build / three . module . js :
( * *
* @ license
* Copyright 2010 - 2022 Three . js Authors
* SPDX - License - Identifier : MIT
* )
* /