/ *
THIS IS A GENERATED / BUNDLED FILE BY ESBUILD
if you want to view the source , please visit the github repository of this plugin
* /
var Tg = Object . create ; var Co = Object . defineProperty ; var Cg = Object . getOwnPropertyDescriptor ; var Rg = Object . getOwnPropertyNames ; var Fg = Object . getPrototypeOf , Lg = Object . prototype . hasOwnProperty ; var Kn = ( r , e ) => ( ) => ( e || r ( ( e = { exports : { } } ) . exports , e ) , e . exports ) , Bg = ( r , e ) => { for ( var t in e ) Co ( r , t , { get : e [ t ] , enumerable : ! 0 } ) } , rd = ( r , e , t , i ) => { if ( e && typeof e == "object" || typeof e == "function" ) for ( let n of Rg ( e ) ) ! Lg . call ( r , n ) && n !== t && Co ( r , n , { get : ( ) => e [ n ] , enumerable : ! ( i = Cg ( e , n ) ) || i . enumerable } ) ; return r } ; var Qn = ( r , e , t ) => ( t = r != null ? Tg ( Fg ( r ) ) : { } , rd ( e || ! r || ! r . _ _esModule ? Co ( t , "default" , { value : r , enumerable : ! 0 } ) : t , r ) ) , Pg = r => rd ( Co ( { } , "__esModule" , { value : ! 0 } ) , r ) ; var dm = Kn ( ( Ml , po ) => { ( function ( r ) { var e = typeof Ml == "object" && Ml , t = typeof po == "object" && po && po . exports == e && po , i = typeof global == "object" && global ; ( i . global === i || i . window === i ) && ( r = i ) ; var n = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g , s = /[\x01-\x7F]/g , o = /[\x01-\t\x0B\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g , a = /<\u20D2|=\u20E5|>\u20D2|\u205F\u200A|\u219D\u0338|\u2202\u0338|\u2220\u20D2|\u2229\uFE00|\u222A\uFE00|\u223C\u20D2|\u223D\u0331|\u223E\u0333|\u2242\u0338|\u224B\u0338|\u224D\u20D2|\u224E\u0338|\u224F\u0338|\u2250\u0338|\u2261\u20E5|\u2264\u20D2|\u2265\u20D2|\u2266\u0338|\u2267\u0338|\u2268\uFE00|\u2269\uFE00|\u226A\u0338|\u226A\u20D2|\u226B\u0338|\u226B\u20D2|\u227F\u0338|\u2282\u20D2|\u2283\u20D2|\u228A\uFE00|\u228B\uFE00|\u228F\u0338|\u2290\u0338|\u2293\uFE00|\u2294\uFE00|\u22B4\u20D2|\u22B5\u20D2|\u22D8\u0338|\u22D9\u0338|\u22DA\uFE00|\u22DB\uFE00|\u22F5\u0338|\u22F9\u0338|\u2933\u0338|\u29CF\u0338|\u29D0\u0338|\u2A6D\u0338|\u2A70\u0338|\u2A7D\u0338|\u2A7E\u0338|\u2AA1\u0338|\u2AA2\u0338|\u2AAC\uFE00|\u2AAD\uFE00|\u2AAF\u0338|\u2AB0\u0338|\u2AC5\u0338|\u2AC6\u0338|\u2ACB\uFE00|\u2ACC\uFE00|\u2AFD\u20E5|[\xA0-\u0113\u0116-\u0122\u0124-\u012B\u012E-\u014D\u0150-\u017E\u0192\u01B5\u01F5\u0237\u02C6\u02C7\u02D8-\u02DD\u0311\u0391-\u03A1\u03A3-\u03A9\u03B1-\u03C9\u03D1\u03D2\u03D5\u03D6\u03DC\u03DD\u03F0\u03F1\u03F5\u03F6\u0401-\u040C\u040E-\u044F\u0451-\u045C\u045E\u045F\u2002-\u2005\u2007-\u2010\u2013-\u2016\u2018-\u201A\u201C-\u201E\u2020-\u2022\u2025\u2026\u2030-\u2035\u2039\u203A\u203E\u2041\u2043\u2044\u204F\u2057\u205F-\u2063\u20AC\u20DB\u20DC\u2102\u2105\u210A-\u2113\u2115-\u211E\u2122\u2124\u2127-\u2129\u212C\u212D\u212F-\u2131\u2133-\u2138\u2145-\u2148\u2153-\u215E\u2190-\u219B\u219D-\u21A7\u21A9-\u21AE\u21B0-\u21B3\u21B5-\u21B7\u21BA-\u21DB\u21DD\u21E4\u21E5\u21F5\u21FD-\u2205\u2207-\u2209\u220B\u220C\u220F-\u2214\u2216-\u2218\u221A\u221D-\u2238\u223A-\u2257\u2259\u225A\u225C\u225F-\u2262\u2264-\u228B\u228D-\u229B\u229D-\u22A5\u22A7-\u22B0\u22B2-\u22BB\u22BD-\u22DB\u22DE-\u22E3\u22E6-\u22F7\u22F9-\u22FE\u2305\u2306\u2308-\u2310\u2312\u2313\u2315\u2316\u231C-\u231F\u2322\u2323\u232D\u232E\u2336\u233D\u233F\u237C\u23B0\u23B1\u23B4-\u23B6\u23DC-\u23DF\u23E2\u23E7\u2423\u24C8\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2550-\u256C\u2580\u2584\u2588\u2591-\u2593\u25A1\u25AA\u25AB\u25AD\u25AE\u25B1\u25B3-\u25B5\u25B8\u25B9\u25BD-\u25BF\u25C2\u25C3\u25CA\u25CB\u25EC\u25EF\u25F8-\u25FC\u2605\u2606\u260E\u2640\u2642\u2660\u2663\u2665\u2666\u266A\u266D-\u266F\u2713\u2717\u2720\u2736\u2758\u2772\u2773\u27C8\u27C9\u27E6-\u27ED\u27F5-\u27FA\u27FC\u27FF\u2902-\u2905\u290C-\u2913\u2916\u2919-\u2920\u2923-\u292A\u2933\u2935-\u2939\u293C\u293D\u2945\u2948-\u294B\u294E-\u2976\u2978\u2979\u297B-\u297F\u2985\u2986\u298B-\u2996\u299A\u299C\u299D\u29A4-\u29B7\u29B9\u29BB\u29BC\u29BE-\u29C5\u29C9\u29CD-\u29D0\u29DC-\u29DE\u29E3-\u29E5\u29EB\u29F4\u29F6\u2A00-\u2A02\u2A04\u2A06\u2A0C\u2A0D\u2A10-\u2A17\u2A22-\u2A27\u2A29\u2A2A\u2A2D-\u2A31\u2A33-\u2A3C\u2A3F\u2A40\u2A42-\u2A4D\u2A50\u2A53-\u2A58\u2A5A-\u2A5D\u2A5F\u2A66\u2A6A\u2A6D-\u2A75\u2A77-\u2A9A\u2A9D-\u2AA2\u2AA4-\u2AB0\u2AB3-\u2AC8\u2ACB\u2ACC\u2ACF-\u2ADB\u2AE4\u2AE6-\u2AE9\u2AEB-\u2AF3\u2AFD\uFB00-\uFB04]|\uD835[\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDD04\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDD6B]/g , l =
` ,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
` ,R-1);if(B===-1||(S++,R=B,S===v)||R===0)break}var L=S<v?0:R+1;return A.substring(L).split( `
` )}function d(A){for(var v=Object.getOwnPropertyNames(A),R=[],S=0;S<v.length;S++){var B=v[S],L=A[B],C=[].concat(L);if(B==="include"){for(var N=0;N<C.length;N++)R.push({include:C[N]});continue}var k=[];C.forEach(function(V){n(V)?(k.length&&R.push(m(B,k)),R.push(m(B,V)),k=[]):k.push(V)}),k.length&&R.push(m(B,k))}return R}function p(A){for(var v=[],R=0;R<A.length;R++){var S=A[R];if(S.include){for(var B=[].concat(S.include),L=0;L<B.length;L++)v.push({include:B[L]});continue}if(!S.type)throw new Error("Rule has no type: "+JSON.stringify(S));v.push(m(S.type,S))}return v}function m(A,v){if(n(v)||(v={match:v}),v.include)throw new Error("Matching rules cannot also include states");var R={defaultType:A,lineBreaks:!!v.error||!!v.fallback,pop:!1,next:null,push:null,error:!1,fallback:!1,value:null,type:null,shouldThrow:!1};for(var S in v)r.call(v,S)&&(R[S]=v[S]);if(typeof R.type=="string"&&A!==R.type)throw new Error("Type transform cannot be a string (type '"+R.type+"' for token '"+A+"')");var B=R.match;return R.match=Array.isArray(B)?B:B?[B]:[],R.match.sort(function(L,C){return i(L)&&i(C)?0:i(C)?-1:i(L)?1:C.length-L.length}),R}function y(A){return Array.isArray(A)?p(A):d(A)}var x=m("error",{lineBreaks:!0,shouldThrow:!0});function g(A,v){for(var R=null,S=Object.create(null),B=!0,L=null,C=[],N=[],k=0;k<A.length;k++)A[k].fallback&&(B=!1);for(var k=0;k<A.length;k++){var V=A[k];if(V.include)throw new Error("Inheritance is not allowed in stateless lexers");if(V.error||V.fallback){if(R)throw!V.fallback==!R.fallback?new Error("Multiple "+(V.fallback?"fallback":"error")+" rules not allowed (for token '"+V.defaultType+"')"):new Error("fallback and error are mutually exclusive (for token '"+V.defaultType+"')");R=V}var U=V.match.slice();if(B)for(;U.length&&typeof U[0]=="string"&&U[0].length===1;){var q=U.shift();S[q.charCodeAt(0)]=V}if(V.pop||V.push||V.next){if(!v)throw new Error("State-switching options are not allowed in stateless lexers (for token '"+V.defaultType+"')");if(V.fallback)throw new Error("State-switching options are not allowed on fallback tokens (for token '"+V.defaultType+"')")}if(U.length!==0){B=!1,C.push(V);for(var j=0;j<U.length;j++){var ne=U[j];if(i(ne)){if(L===null)L=ne.unicode;else if(L!==ne.unicode&&V.fallback===!1)throw new Error("If one rule is /u then all must be")}}var ae=l(U.map(c)),H=new RegExp(ae);if(H.test(""))throw new Error("RegExp matches empty string: "+H);var Te=o(ae);if(Te>0)throw new Error("RegExp has capture groups: "+H+ `
Use ( ? : \u2026 ) instead ` );if(!V.lineBreaks&&H.test( `
` ))throw new Error("Rule should declare lineBreaks: "+H);N.push(a(ae))}}var ue=R&&R.fallback,we=t&&!ue?"ym":"gm",oe=t||ue?"":"|";L===!0&&(we+="u");var Ce=new RegExp(l(N)+oe,we);return{regexp:Ce,groups:C,fast:S,error:R||x}}function f(A){var v=g(y(A));return new D({start:v},"start")}function E(A,v,R){var S=A&&(A.push||A.next);if(S&&!R[S])throw new Error("Missing state '"+S+"' (in token '"+A.defaultType+"' of state '"+v+"')");if(A&&A.pop&&+A.pop!=1)throw new Error("pop must be 1 (in token '"+A.defaultType+"' of state '"+v+"')")}function w(A,v){var R=A. $ all?y(A. $ all):[];delete A. $ all;var S=Object.getOwnPropertyNames(A);v||(v=S[0]);for(var B=Object.create(null),L=0;L<S.length;L++){var C=S[L];B[C]=y(A[C]).concat(R)}for(var L=0;L<S.length;L++)for(var C=S[L],N=B[C],k=Object.create(null),V=0;V<N.length;V++){var U=N[V];if(U.include){var q=[V,1];if(U.include!==C&&!k[U.include]){k[U.include]=!0;var j=B[U.include];if(!j)throw new Error("Cannot include nonexistent state '"+U.include+"' (in state '"+C+"')");for(var ne=0;ne<j.length;ne++){var ae=j[ne];N.indexOf(ae)===-1&&q.push(ae)}}N.splice.apply(N,q),V--}}for(var H=Object.create(null),L=0;L<S.length;L++){var C=S[L];H[C]=g(B[C],!0)}for(var L=0;L<S.length;L++){for(var Te=S[L],ue=H[Te],we=ue.groups,V=0;V<we.length;V++)E(we[V],Te,H);for(var oe=Object.getOwnPropertyNames(ue.fast),V=0;V<oe.length;V++)E(ue.fast[oe[V]],Te,H)}return new D(H,v)}function _(A){for(var v=typeof Map<"u",R=v?new Map:Object.create(null),S=Object.getOwnPropertyNames(A),B=0;B<S.length;B++){var L=S[B],C=A[L],N=Array.isArray(C)?C:[C];N.forEach(function(k){if(typeof k!="string")throw new Error("keyword must be string (in keyword '"+L+"')");v?R.set(k,L):R[k]=L})}return function(k){return v?R.get(k):R[k]}}var D=function(A,v){this.startState=v,this.states=A,this.buffer="",this.stack=[],this.reset()};D.prototype.reset=function(A,v){return this.buffer=A||"",this.index=0,this.line=v?v.line:1,this.col=v?v.col:1,this.queuedToken=v?v.queuedToken:null,this.queuedText=v?v.queuedText:"",this.queuedThrow=v?v.queuedThrow:null,this.setState(v?v.state:this.startState),this.stack=v&&v.stack?v.stack.slice():[],this},D.prototype.save=function(){return{line:this.line,col:this.col,state:this.state,stack:this.stack.slice(),queuedToken:this.queuedToken,queuedText:this.queuedText,queuedThrow:this.queuedThrow}},D.prototype.setState=function(A){if(!(!A||this.state===A)){this.state=A;var v=this.states[A];this.groups=v.groups,this.error=v.error,this.re=v.regexp,this.fast=v.fast}},D.prototype.popState=function(){this.setState(this.stack.pop())},D.prototype.pushState=function(A){this.stack.push(this.state),this.setState(A)};var T=t?function(A,v){return A.exec(v)}:function(A,v){var R=A.exec(v);return R[0].length===0?null:R};D.prototype._getGroup=function(A){for(var v=this.groups.length,R=0;R<v;R++)if(A[R+1]!==void 0)return this.groups[R];throw new Error("Cannot find token type for matched text")};function O(){return this.value}if(D.prototype.next=function(){var A=this.index;if(this.queuedGroup){var v=this._token(this.queuedGroup,this.queuedText,A);return this.queuedGroup=null,this.queuedText="",v}var R=this.buffer;if(A!==R.length){var C=this.fast[R.charCodeAt(A)];if(C)return this._token(C,R.charAt(A),A);var S=this.re;S.lastIndex=A;var B=T(S,R),L=this.error;if(B==null)return this._token(L,R.slice(A,R.length),A);var C=this._getGroup(B),N=B[0];return L.fallback&&B.index!==A?(this.queuedGroup=C,this.queuedText=N,this._token(L,R.slice(A,B.index),A)):this._token(C,N,A)}},D.prototype._token=function(A,v,R){var S=0;if(A.lineBreaks){var B=/ \n /g,L=1;if(v=== `
` )S=1;else for(;B.exec(v);)S++,L=B.lastIndex}var C={type:typeof A.type=="function"&&A.type(v)||A.defaultType,value:typeof A.value=="function"?A.value(v):v,text:v,toString:O,offset:R,lineBreaks:S,line:this.line,col:this.col},N=v.length;if(this.index+=N,this.line+=S,S!==0?this.col=N-L+1:this.col+=N,A.shouldThrow){var k=new Error(this.formatError(C,"invalid syntax"));throw k}return A.pop?this.popState():A.push?this.pushState(A.push):A.next&&this.setState(A.next),C},typeof Symbol<"u"&&Symbol.iterator){var W=function(A){this.lexer=A};W.prototype.next=function(){var A=this.lexer.next();return{value:A,done:!A}},W.prototype[Symbol.iterator]=function(){return this},D.prototype[Symbol.iterator]=function(){return new W(this)}}return D.prototype.formatError=function(A,v){if(A==null)var R=this.buffer.slice(this.index),A={text:R,offset:this.index,lineBreaks:R.indexOf( `
` )===-1?0:1,line:this.line,col:this.col};var S=2,B=Math.max(A.line-S,1),L=A.line+S,C=String(L).length,N=h(this.buffer,this.line-A.line+S+1).slice(0,5),k=[];k.push(v+" at line "+A.line+" col "+A.col+":"),k.push("");for(var V=0;V<N.length;V++){var U=N[V],q=B+V;k.push(u(String(q),C)+" "+U),q===A.line&&k.push(u("",C+A.col+1)+"^")}return k.join( `
` )},D.prototype.clone=function(){return new D(this.states,this.state)},D.prototype.has=function(A){return!0},{compile:f,states:w,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:_}})});var mm=Kn(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});require("obsidian");var y_=r=>{var e;return r?(e=r.plugins.plugins.dataview)===null||e===void 0?void 0:e.api:window.DataviewAPI},x_=r=>r.plugins.enabledPlugins.has("dataview");Tl.getAPI=y_;Tl.isPluginEnabled=x_});var Fm=Kn(qi=>{"use strict";var uE=qi&&qi.__values||function(r){var e=typeof Symbol=="function"&&Symbol.iterator,t=e&&r[e],i=0;if(t)return t.call(r);if(r&&typeof r.length=="number")return{next:function(){return r&&i>=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(qi,"__esModule",{value:!0});qi.getWordsByCategory=qi.wordList=void 0;qi.wordList={noun:[{word:"accountant",categories:["profession"]},{word:"ability",categories:["thing"]},{word:"accident",categories:["thing"]},{word:"account",categories:["thing"]},{word:"action",categories:["thing"]},{word:"activity",categories:["thing"]},{word:"actor",categories:["profession"]},{word:"ad",categories:["media"]},{word:"addition",categories:["thing"]},{word:"address",categories:["thing"]},{word:"adult",categories:["people"]},{word:"advantage",categories:["thing"]},{word:"advertisement",categories:["media"]},{word:"afternoon",categories:["time"]},{word:"agency",categories:["thing"]},{word:"agent",categories:["people"]},{word:"air",categories:["thing"]},{word:"airline",categories:["transportation"]},{word:"airplane",categories:["transportation"]},{word:"airport",categories:["transportation","place"]},{word:"alarm",categories:["thing"]},{word:"alligator",categories:["animals"]},{word:"ambulance",categories:["health"]},{word:"analyst",categories:["profession"]},{word:"angle",categories:["thing"]},{word:"animal",categories:["animals"]},{word:"answer",categories:["thing"]},{word:"apartment",categories:["place"]},{word:"apple",categories:["food"]},{word:"application",categories:["thing"]},{word:"appointment",categories:["thing"]},{word:"architect",categories:["profession"]},{word:"argument",categories:["thing"]},{word:"area",categories:["thing"]},{word:"arm",categories:["thing"]},{word:"army",categories:["thing"]},{word:"art",categories:["thing"]},{word:"article",categories:["thing"]},{word:"artist",categories:["profession"]},{word:"australia",categories:["place"]},{word:"author",categories:["profession"]},{word:"autumn",categories:["time"]},{word:"baby",categories:["people","family"]},{word:"baker",categories:["profession"]},{word:"balloon",categories:["thing"]},{word:"banana",categories:["food"]},{word:"barista",categories:["profession"]},{word:"battery",categories:["thing"]},{word:"beach",categories:["place"]},{word:"bear",categories:["animals"]},{word:"beard",categories:["thing"]},{word:"bed",categories:["thing"]},{word:"belgium",categories:["place"]},{word:"bird",categories:["animals"]},{word:"bit",categories:["thing","technology"]},{word:"book",categories:["thing","education"]},{word:"boots",categories:["thing"]},{word:"boy",categories:["people"]},{word:"branch",categories:["thing"]},{word:"breakfast",categories:["thing"]},{word:"brother",categories:["family"]},{word:"businessperson",categories:["people","business"]},{word:"butcher",categories:["profession"]},{word:"byte",categories:["thing","technology"]},{word:"camera",categories:["thing"]},{word:"candle",categories:["thing"]},{word:"car",categories:["transportation"]},{word:"caravan",categories:["transportation"]},{word:"carpenter",categories:["profession"]},{word:"carpet",categories:["thing"]},{word:"cartoon",categories:["media"]},{word:"cat",categories:["animals"]},{word:"chef",categories:["profession"]},{word:"child",categories:["people","family"]},{word:"china",categories:["place"]},{word:"church",categories:["religion"]},{word:"city",categories:["place"]},{word:"coat",categories:["thing"]},{word:"coffeeshop",categories:
` ).join(" -> ")} -> ` } } , Mn = class extends jl { } , rr = class extends Mn { constructor ( t , i , n , s , o , a = t . showDice ) { super ( t , i , [ n ] , a ) ; this . data = t ; this . original = i ; this . lexeme = n ; this . source = s ; this . app = o ; this . watch = ! 0 ; this . getPath ( ) , this . init = this . getFile ( ) } async getFile ( ) { if ( this . file = this . app . metadataCache . getFirstLinkpathDest ( this . path , this . source ) , ! this . file || ! ( this . file instanceof Mi . TFile ) ) throw new Error ( "Could not load file." ) ; await this . load ( ) } } , es = class extends rr { constructor ( t , i , n , s , o , a = ! 0 , l = t . showDice ) { super ( t , i , n , s , o , l ) ; this . data = t ; this . original = i ; this . lexeme = n ; this . app = o ; this . inline = a ; this . data . displayAsEmbed && ( this . containerEl . addClasses ( [ "has-embed" , "markdown-embed" ] ) , this . resultEl . addClass ( "internal-embed" ) ) , this . resultEl . setAttrs ( { src : s } ) , 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 Mi . Notice ( "Result copied to clipboard." ) } ) } ) , ( 0 , Mi . setIcon ) ( this . copy , "copy" ) } getEmbedClass ( ) { return this . data . displayAsEmbed ? "markdown-embed" : "" } } , Lo = class extends Fo { 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 Un=require("obsidian");var gi=class r{constructor(e=[0,0,0,0,0,0,0,0,0]){this.elements=void 0,this.elements=e}identity(){let e=this.elements;e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1}setZero(){let e=this.elements;e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0,e[6]=0,e[7]=0,e[8]=0}setTrace(e){let t=this.elements;t[0]=e.x,t[4]=e.y,t[8]=e.z}getTrace(e=new b){let t=this.elements;return e.x=t[0],e.y=t[4],e.z=t[8],e}vmult(e,t=new b){let i=this.elements,n=e.x,s=e.y,o=e.z;return t.x=i[0]*n+i[1]*s+i[2]*o,t.y=i[3]*n+i[4]*s+i[5]*o,t.z=i[6]*n+i[7]*s+i[8]*o,t}smult(e){for(let t=0;t<this.elements.length;t++)this.elements[t]*=e}mmult(e,t=new r){let i=this.elements,n=e.elements,s=t.elements,o=i[0],a=i[1],l=i[2],c=i[3],u=i[4],h=i[5],d=i[6],p=i[7],m=i[8],y=n[0],x=n[1],g=n[2],f=n[3],E=n[4],w=n[5],_=n[6],D=n[7],T=n[8];return s[0]=o*y+a*f+l*_,s[1]=o*x+a*E+l*D,s[2]=o*g+a*w+l*T,s[3]=c*y+u*f+h*_,s[4]=c*x+u*E+h*D,s[5]=c*g+u*w+h*T,s[6]=d*y+p*f+m*_,s[7]=d*x+p*E+m*D,s[8]=d*g+p*w+m*T,t}scale(e,t=new r){let i=this.elements,n=t.elements;for(let s=0;s!==3;s++)n[3*s+0]=e.x*i[3*s+0],n[3*s+1]=e.y*i[3*s+1],n[3*s+2]=e.z*i[3*s+2];return t}solve(e,t=new b){let s=[],o,a;for(o=0;o<3*4;o++)s.push(0);for(o=0;o<3;o++)for(a=0;a<3;a++)s[o+4*a]=this.elements[o+3*a];s[3+4*0]=e.x,s[3+4*1]=e.y,s[3+4*2]=e.z;let l=3,c=l,u,h=4,d;do{if(o=c-l,s[o+4*o]===0){for(a=o+1;a<c;a++)if(s[o+4*a]!==0){u=h;do d=h-u,s[d+4*o]+=s[d+4*a];while(--u);break}}if(s[o+4*o]!==0)for(a=o+1;a<c;a++){let p=s[o+4*a]/s[o+4*o];u=h;do d=h-u,s[d+4*a]=d<=o?0:s[d+4*a]-s[d+4*o]*p;while(--u)}}while(--l);if(t.z=s[2*4+3]/s[2*4+2],t.y=(s[1*4+3]-s[1*4+2]*t.z)/s[1*4+1],t.x=(s[0*4+3]-s[0*4+2]*t.z-s[0*4+1]*t.y)/s[0*4+0],isNaN(t.x)||isNaN(t.y)||isNaN(t.z)||t.x===1/0||t.y===1/0||t.z===1/0)throw"Could not solve equation! Got x=["+t.toString()+"], b=["+e.toString()+"], A=["+this.toString()+"]";return t}e(e,t,i){if(i===void 0)return this.elements[t+3*e];this.elements[t+3*e]=i}copy(e){for(let t=0;t<e.elements.length;t++)this.elements[t]=e.elements[t];return this}toString(){let e="",t=",";for(let i=0;i<9;i++)e+=this.elements[i]+t;return e}reverse(e=new r){let n=Ig,s,o;for(s=0;s<3;s++)for(o=0;o<3;o++)n[s+6*o]=this.elements[s+3*o];n[3+6*0]=1,n[3+6*1]=0,n[3+6*2]=0,n[4+6*0]=0,n[4+6*1]=1,n[4+6*2]=0,n[5+6*0]=0,n[5+6*1]=0,n[5+6*2]=1;let a=3,l=a,c,u=6,h;do{if(s=l-a,n[s+6*s]===0){for(o=s+1;o<l;o++)if(n[s+6*o]!==0){c=u;do h=u-c,n[h+6*s]+=n[h+6*o];while(--c);break}}if(n[s+6*s]!==0)for(o=s+1;o<l;o++){let d=n[s+6*o]/n[s+6*s];c=u;do h=u-c,n[h+6*o]=h<=s?0:n[h+6*o]-n[h+6*s]*d;while(--c)}}while(--a);s=2;do{o=s-1;do{let d=n[s+6*o]/n[s+6*s];c=6;do h=6-c,n[h+6*o]=n[h+6*o]-n[h+6*s]*d;while(--c)}while(o--)}while(--s);s=2;do{let d=1/n[s+6*s];c=6;do h=6-c,n[h+6*s]=n[h+6*s]*d;while(--c)}while(s--);s=2;do{o=2;do{if(h=n[3+o+6*s],isNaN(h)||h===1/0)throw"Could not reverse! A=["+this.toString()+"]";e.e(s,o,h)}while(o--)}while(s--);return e}setRotationFromQuaternion(e){let t=e.x,i=e.y,n=e.z,s=e.w,o=t+t,a=i+i,l=n+n,c=t*o,u=t*a,h=t*l,d=i*a,p=i*l,m=n*l,y=s*o,x=s*a,g=s*l,f=this.elements;return f[3*0+0]=1-(d+m),f[3*0+1]=u-g,f[3*0+2]=h+x,f[3*1+0]=u+g,f[3*1+1]=1-(c+m),f[3*1+2]=p-y,f[3*2+0]=h-x,f[3*2+1]=p+y,f[3*2+2]=1-(c+d),this}transpose(e=new r){let t=this.elements,i=e.elements,n;return i[0]=t[0],i[4]=t[4],i[8]=t[8],n=t[1],i[1]=t[3],i[3]=n,n=t[2],i[2]=t[6],i[6]=n,n=t[5],i[5]=t[7],i[7]=n,e}},Ig=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],b=class r{constructor(e=0,t=0,i=0){this.x=void 0,this.y=void 0,this.z=void 0,this.x=e,this.y=t,this.z=i}cross(e,t=new r){let i=e.x,n=e.y,s=e.z,o=this.x,a=this.y,l=this.z;return t.x=a*s-l*n,t.y=l*i-o*s,t.z=o*n-a*i,t}set(e,t,i){return this.x=e,this.y=t,this.z=i,this}setZero(){this.x=this.y=this.z=0}vadd(e,t){if(t)t.x=e.x+this.x,t.y=e.y+this.
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,cv= ` void main ( ) {
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
} ` ,Ui=class extends dt{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=lv,this.fragmentShader=cv,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=Ps(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 o=this.uniforms[n].value;o&&o.isTexture?t.uniforms[n]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[n]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[n]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[n]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[n]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[n]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[n]={type:"m4",value:o.toArray()}:t.uniforms[n]={value:o}}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}};Ui.prototype.isShaderMaterial=!0;var Nr=class extends Ge{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Ee,this.projectionMatrix=new Ee,this.projectionMatrixInverse=new Ee}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)}};Nr.prototype.isCamera=!0;var _t=class extends Nr{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=nu*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(xc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return nu*2*Math.atan(Math.tan(xc*.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,s,o){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=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){let e=this.near,t=e*Math.tan(xc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n,o=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 Ir(5,5,5),s=new Ui({name:"CubemapFromEquirect",uniforms:Ps(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:gt,blending:an});s.uniforms.tEquirect.value=t;let o=new ht(n,s),a=t.minFilter;return t.minFilter===il&&(t.minFilter=Dt),new kr(1,10,this).update(e,o),t.minFilter=a,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,i,n){let s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,i,n);e.setRenderTarget(s)}};La.prototype.isWebGLCubeRenderTarget=!0;var Vc=new P,uv=new P,hv=new xt,si=class{constructor(e=new P(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=Vc.subVectors(i,t).cross(uv.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(Vc),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;let s=-(e.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:t.copy(i).multiplyScalar(s).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||hv.getNormalMatrix(e),n=this.coplanarPoint(Vc).applyMatrix4(e),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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)}};si.prototype.isPlane=!0;var gs=new vi,la=new P,Ns=class{constructor(e=new si,t=new si,i=new si,n=new si,s=new si,o=new si){this.planes=[e,t,i,n,s,o]}set(e,t,i,n,s,o){let a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(o),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],s=i[1],o=i[2],a=i[3],l=i[4],c=i[5],u=i[6],h=i[7],d=i[8],p=i[9],m=i[10],y=i[11],x=i[12],g=i[13],f=i[14],E=i[15];return t[0].setComponents(a-n,h-l,y-d,E-x).normalize(),t[1].setComponents(a+n,h+l,y+d,E+x).normalize(),t[2].setComponents(a+s,h+c,y+p,E+g).normalize(),t[3].setComponents(a-s,h-c,y-p,E-g).normalize(),t[4].setComponents(a-o,h-u,y-m,E-f).normalize(),t[5].setComponents(a+o,h+u,y+m,E+f).normalize(),this}intersectsObject(e){let t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),gs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(gs)}intersectsSprite(e){return gs.center.set(0,0,0),gs.radius=.7071067811865476,gs.applyMatrix4(e.matrixWorld),this.intersectsSphere(gs)}intersectsSphere(e){let t=this.planes,i=e.center,n=-e.radius;for(let s=0;s<6;s++)if(t[s].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(la.x=n.normal.x>0?e.max.x:e.min.x,la.y=n.normal.y>0?e.max.y:e.min.y,la.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(la)<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 qf(){let r=null,e=!1,t=null,i=null;function n(s,o){t(s,o),i=r.requestAnimationFrame(n)}return{start:function(){e!==!0&&t!
diffuseColor . a *= texture2D ( alphaMap , vUv ) . g ;
# endif ` ,fv= ` # ifdef USE _ALPHAMAP
uniform sampler2D alphaMap ;
# endif ` ,mv= ` # ifdef USE _ALPHATEST
if ( diffuseColor . a < alphaTest ) discard ;
# endif ` ,gv= ` # ifdef USE _ALPHATEST
uniform float alphaTest ;
# endif ` ,yv= ` # 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 ` ,xv= ` # ifdef USE _AOMAP
uniform sampler2D aoMap ;
uniform float aoMapIntensity ;
# endif ` ,vv="vec3 transformed = vec3( position );",wv= ` vec3 objectNormal = vec3 ( normal ) ;
# ifdef USE _TANGENT
vec3 objectTangent = vec3 ( tangent . xyz ) ;
# endif ` ,bv= ` 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 ` ,_v= ` # 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 ` ,Ev= ` # 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 ` ,Av= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
uniform vec4 clippingPlanes [ NUM _CLIPPING _PLANES ] ;
# endif ` ,Sv= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
# endif ` ,Mv= ` # if NUM _CLIPPING _PLANES > 0
vClipPosition = - mvPosition . xyz ;
# endif ` ,Dv= ` # if defined ( USE _COLOR _ALPHA )
diffuseColor *= vColor ;
# elif defined ( USE _COLOR )
diffuseColor . rgb *= vColor ;
# endif ` ,Tv= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR )
varying vec3 vColor ;
# endif ` ,Cv= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR ) || defined ( USE _INSTANCING _COLOR )
varying vec3 vColor ;
# endif ` ,Rv= ` # 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 ` ,Fv= ` # 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 ) ;
} ` ,Lv= ` # 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 ` ,Bv= ` 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 ` ,Pv= ` # ifdef USE _DISPLACEMENTMAP
uniform sampler2D displacementMap ;
uniform float displacementScale ;
uniform float displacementBias ;
# endif ` ,Iv= ` # ifdef USE _DISPLACEMENTMAP
transformed += normalize ( objectNormal ) * ( texture2D ( displacementMap , vUv ) . x * displacementScale + displacementBias ) ;
# endif ` ,Nv= ` # ifdef USE _EMISSIVEMAP
vec4 emissiveColor = texture2D ( emissiveMap , vUv ) ;
totalEmissiveRadiance *= emissiveColor . rgb ;
# endif ` ,kv= ` # ifdef USE _EMISSIVEMAP
uniform sampler2D emissiveMap ;
# endif ` ,zv="gl_FragColor = linearToOutputTexel( gl_FragColor );",Ov= ` 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 ) ;
} ` ,Vv= ` # 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 ` ,Uv= ` # ifdef USE _ENVMAP
uniform float envMapIntensity ;
uniform float flipEnvMap ;
# ifdef ENVMAP _TYPE _CUBE
uniform samplerCube envMap ;
# else
uniform sampler2D envMap ;
# endif
# endif ` ,Hv= ` # 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 ` ,Gv= ` # 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 ` ,qv= ` # 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 ` ,Wv= ` # ifdef USE _FOG
vFogDepth = - mvPosition . z ;
# endif ` , $ v= ` # ifdef USE _FOG
varying float vFogDepth ;
# endif ` ,jv= ` # 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 ` ,Xv= ` # ifdef USE _FOG
uniform vec3 fogColor ;
varying float vFogDepth ;
# ifdef FOG _EXP2
uniform float fogDensity ;
# else
uniform float fogNear ;
uniform float fogFar ;
# endif
# endif ` ,Yv= ` # 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
} ` ,Zv= ` # ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
# ifndef PHYSICALLY _CORRECT _LIGHTS
lightMapIrradiance *= PI ;
# endif
reflectedLight . indirectDiffuse += lightMapIrradiance ;
# endif ` ,Jv= ` # ifdef USE _LIGHTMAP
uniform sampler2D lightMap ;
uniform float lightMapIntensity ;
# endif ` ,Kv= ` 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 ` ,Qv= ` 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 ` ,e2= ` # 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 ` ,t2= ` ToonMaterial material ;
material . diffuseColor = diffuseColor . rgb ; ` ,i2= ` 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 ) ` ,n2= ` BlinnPhongMaterial material ;
material . diffuseColor = diffuseColor . rgb ;
material . specularColor = specular ;
material . specularShininess = shininess ;
material . specularStrength = specularStrength ; ` ,s2= ` 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 ) ` ,r2= ` 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 ` ,o2= ` 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 ) ;
} ` ,a2= `
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 ` ,l2= ` # 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 ` ,c2= ` # if defined ( RE _IndirectDiffuse )
RE _IndirectDiffuse ( irradiance , geometry , material , reflectedLight ) ;
# endif
# if defined ( RE _IndirectSpecular )
RE _IndirectSpecular ( radiance , iblIrradiance , clearcoatRadiance , geometry , material , reflectedLight ) ;
# endif ` ,u2= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
gl _FragDepthEXT = vIsPerspective == 0.0 ? gl _FragCoord . z : log2 ( vFragDepth ) * logDepthBufFC * 0.5 ;
# endif ` ,h2= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
uniform float logDepthBufFC ;
varying float vFragDepth ;
varying float vIsPerspective ;
# endif ` ,d2= ` # ifdef USE _LOGDEPTHBUF
# ifdef USE _LOGDEPTHBUF _EXT
varying float vFragDepth ;
varying float vIsPerspective ;
# else
uniform float logDepthBufFC ;
# endif
# endif ` ,p2= ` # 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 ` ,f2= ` # 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 ` ,m2= ` # ifdef USE _MAP
uniform sampler2D map ;
# endif ` ,g2= ` # 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 ` ,y2= ` # 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 ` ,x2= ` float metalnessFactor = metalness ;
# ifdef USE _METALNESSMAP
vec4 texelMetalness = texture2D ( metalnessMap , vUv ) ;
metalnessFactor *= texelMetalness . b ;
# endif ` ,v2= ` # ifdef USE _METALNESSMAP
uniform sampler2D metalnessMap ;
# endif ` ,w2= ` # 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 ` ,b2= ` # 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 ` ,_2= ` # 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 ` ,E2= ` 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 ; ` ,A2= ` # 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 ` ,S2= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,M2= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,D2= ` # ifndef FLAT _SHADED
vNormal = normalize ( transformedNormal ) ;
# ifdef USE _TANGENT
vTangent = normalize ( transformedTangent ) ;
vBitangent = normalize ( cross ( vNormal , vTangent ) * tangent . w ) ;
# endif
# endif ` ,T2= ` # 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 ` ,C2= ` # ifdef USE _CLEARCOAT
vec3 clearcoatNormal = geometryNormal ;
# endif ` ,R2= ` # 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 ` ,F2= ` # 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 ` ,L2= ` # ifdef OPAQUE
diffuseColor . a = 1.0 ;
# endif
# ifdef USE _TRANSMISSION
diffuseColor . a *= transmissionAlpha + 0.1 ;
# endif
gl _FragColor = vec4 ( outgoingLight , diffuseColor . a ) ; ` ,B2= ` 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 ) ;
} ` ,P2= ` # ifdef PREMULTIPLIED _ALPHA
gl _FragColor . rgb *= gl _FragColor . a ;
# endif ` ,I2= ` vec4 mvPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _INSTANCING
mvPosition = instanceMatrix * mvPosition ;
# endif
mvPosition = modelViewMatrix * mvPosition ;
gl _Position = projectionMatrix * mvPosition ; ` ,N2= ` # ifdef DITHERING
gl _FragColor . rgb = dithering ( gl _FragColor . rgb ) ;
# endif ` ,k2= ` # 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 ` ,z2= ` float roughnessFactor = roughness ;
# ifdef USE _ROUGHNESSMAP
vec4 texelRoughness = texture2D ( roughnessMap , vUv ) ;
roughnessFactor *= texelRoughness . g ;
# endif ` ,O2= ` # ifdef USE _ROUGHNESSMAP
uniform sampler2D roughnessMap ;
# endif ` ,V2= ` # 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 ` ,U2= ` # 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 ` ,H2= ` # 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 ` ,G2= ` 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 ;
} ` ,q2= ` # ifdef USE _SKINNING
mat4 boneMatX = getBoneMatrix ( skinIndex . x ) ;
mat4 boneMatY = getBoneMatrix ( skinIndex . y ) ;
mat4 boneMatZ = getBoneMatrix ( skinIndex . z ) ;
mat4 boneMatW = getBoneMatrix ( skinIndex . w ) ;
# endif ` ,W2= ` # 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 ` , $ 2= ` # 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 ` ,j2= ` # 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 ` ,X2= ` float specularStrength ;
# ifdef USE _SPECULARMAP
vec4 texelSpecular = texture2D ( specularMap , vUv ) ;
specularStrength = texelSpecular . r ;
# else
specularStrength = 1.0 ;
# endif ` ,Y2= ` # ifdef USE _SPECULARMAP
uniform sampler2D specularMap ;
# endif ` ,Z2= ` # if defined ( TONE _MAPPING )
gl _FragColor . rgb = toneMapping ( gl _FragColor . rgb ) ;
# endif ` ,J2= ` # 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 ; } ` ,K2= ` # 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 ` ,Q2= ` # 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 ` ,ew= ` # if ( defined ( USE _UV ) && ! defined ( UVS _VERTEX _ONLY ) )
varying vec2 vUv ;
# endif ` ,tw= ` # ifdef USE _UV
# ifdef UVS _VERTEX _ONLY
vec2 vUv ;
# else
varying vec2 vUv ;
# endif
uniform mat3 uvTransform ;
# endif ` ,iw= ` # ifdef USE _UV
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
# endif ` ,nw= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
varying vec2 vUv2 ;
# endif ` ,sw= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
attribute vec2 uv2 ;
varying vec2 vUv2 ;
uniform mat3 uv2Transform ;
# endif ` ,rw= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
vUv2 = ( uv2Transform * vec3 ( uv2 , 1 ) ) . xy ;
# endif ` ,ow= ` # 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 ` ,aw= ` varying vec2 vUv ;
uniform mat3 uvTransform ;
void main ( ) {
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
gl _Position = vec4 ( position . xy , 1.0 , 1.0 ) ;
} ` ,lw= ` uniform sampler2D t2D ;
varying vec2 vUv ;
void main ( ) {
gl _FragColor = texture2D ( t2D , vUv ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,cw= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
gl _Position . z = gl _Position . w ;
} ` ,uw= ` # 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 >
} ` ,hw= ` # 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 ;
} ` ,dw= ` # 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
} ` ,pw= ` # 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 ;
} ` ,fw= ` # 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 ) ;
} ` ,mw= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
} ` ,gw= ` 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 >
} ` ,yw= ` 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 >
} ` ,xw= ` 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 >
} ` ,vw= ` # 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 >
} ` ,ww= ` 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 >
} ` ,bw= ` # 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 >
} ` ,_w= ` 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 >
} ` ,Ew= ` # 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 ;
} ` ,Aw= ` # 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 >
} ` ,Sw= ` # 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
} ` ,Mw= ` # 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 ) ;
# ifdef OPAQUE
gl _FragColor . a = 1.0 ;
# endif
} ` ,Dw= ` # 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 >
} ` ,Tw= ` # 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 >
} ` ,Cw= ` # 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
} ` ,Rw= ` # 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 >
} ` ,Fw= ` # 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 >
} ` ,Lw= ` # 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 >
} ` ,Bw= ` 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 >
} ` ,Pw= ` 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 >
} ` ,Iw= ` # 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 >
} ` ,Nw= ` 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 >
} ` ,kw= ` 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 >
} ` ,zw= ` 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 >
} ` ,Ne={alphamap_fragment:pv,alphamap_pars_fragment:fv,alphatest_fragment:mv,alphatest_pars_fragment:gv,aomap_fragment:yv,aomap_pars_fragment:xv,begin_vertex:vv,beginnormal_vertex:wv,bsdfs:bv,bumpmap_pars_fragment:_v,clipping_planes_fragment:Ev,clipping_planes_pars_fragment:Av,clipping_planes_pars_vertex:Sv,clipping_planes_vertex:Mv,color_fragment:Dv,color_pars_fragment:Tv,color_pars_vertex:Cv,color_vertex:Rv,common:Fv,cube_uv_reflection_fragment:Lv,defaultnormal_vertex:Bv,displacementmap_pars_vertex:Pv,displacementmap_vertex:Iv,emissivemap_fragment:Nv,emissivemap_pars_fragment:kv,encodings_fragment:zv,encodings_pars_fragment:Ov,envmap_fragment:Vv,envmap_common_pars_fragment:Uv,envmap_pars_fragment:Hv,envmap_pars_vertex:Gv,envmap_physical_pars_fragment:e2,envmap_vertex:qv,fog_vertex:Wv,fog_pars_vertex: $ v,fog_fragment:jv,fog_pars_fragment:Xv,gradientmap_pars_fragment:Yv,lightmap_fragment:Zv,lightmap_pars_fragment:Jv,lights_lambert_vertex:Kv,lights_pars_begin:Qv,lights_toon_fragment:t2,lights_toon_pars_fragment:i2,lights_phong_fragment:n2,lights_phong_pars_fragment:s2,lights_physical_fragment:r2,lights_physical_pars_fragment:o2,lights_fragment_begin:a2,lights_fragment_maps:l2,lights_fragment_end:c2,logdepthbuf_fragment:u2,logdepthbuf_pars_fragment:h2,logdepthbuf_pars_vertex:d2,logdepthbuf_vertex:p2,map_fragment:f2,map_pars_fragment:m2,map_particle_fragment:g2,map_particle_pars_fragment:y2,metalnessmap_fragment:x2,metalnessmap_pars_fragment:v2,morphnormal_vertex:w2,morphtarget_pars_vertex:b2,morphtarget_vertex:_2,normal_fragment_begin:E2,normal_fragment_maps:A2,normal_pars_fragment:S2,normal_pars_vertex:M2,normal_vertex:D2,normalmap_pars_fragment:T2,clearcoat_normal_fragment_begin:C2,clearcoat_normal_fragment_maps:R2,clearcoat_pars_fragment:F2,output_fragment:L2,packing:B2,premultiplied_alpha_fragment:P2,project_vertex:I2,dithering_fragment:N2,dithering_pars_fragment:k2,roughnessmap_fragment:z2,roughnessmap_pars_fragment:O2,shadowmap_pars_fragment:V2,shadowmap_pars_vertex:U2,shadowmap_vertex:H2,shadowmask_pars_fragment:G2,skinbase_vertex:q2,skinning_pars_vertex:W2,skinning_vertex: $ 2,skinnormal_vertex:j2,specularmap_fragment:X2,specularmap_pars_fragment:Y2,tonemapping_fragment:Z2,tonemapping_pars_fragment:J2,transmission_fragment:K2,transmission_pars_fragment:Q2,uv_pars_fragment:ew,uv_pars_vertex:tw,uv_vertex:iw,uv2_pars_fragment:nw,uv2_pars_vertex:sw,uv2_vertex:rw,worldpos_vertex:ow,background_vert:aw,background_frag:lw,cube_vert:cw,cube_frag:uw,depth_vert:hw,depth_frag:dw,distanceRGBA_vert:pw,distanceRGBA_frag:fw,equirect_vert:mw,equirect_frag:gw,linedashed_vert:yw,linedashed_frag:xw,meshbasic_vert:vw,meshbasic_frag:ww,meshlambert_vert:bw,meshlambert_frag:_w,meshmatcap_vert:Ew,meshmatcap_frag:Aw,meshnormal_vert:Sw,meshnormal_frag:Mw,meshphong_vert:Dw,meshphong_frag:Tw,meshphysical_vert:Cw,meshphysical_frag:Rw,meshtoon_vert:Fw,meshtoon_frag:Lw,points_vert:Bw,points_frag:Pw,shadow_vert:Iw,shadow_frag:Nw,sprite_vert:kw,sprite_frag:zw},re={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new xt},uv2Transform:{value:new xt},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 ee(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 ye(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:an,depthTest:!1,depthWrite:!1})}function $ p(){let r=new ee(1,1);return new ks({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:r}},vertexShader:mh(),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:an,depthTest:!1,depthWrite:!1})}function jp(){return new ks({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:mh(),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:an,depthTest:!1,depthWrite:!1})}function mh(){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 jw(r){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===Kc||l===Qc,u=l===so||l===ro;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new Ba(r)),h=c?t.fromEquirectangular(a,h):t.fromCubemap(a,h),e.set(a,h),h.texture}else{if(e.has(a))return e.get(a).texture;{let h=a.image;if(c&&h&&h.height>0||u&&h&&n(h)){t===null&&(t=new Ba(r));let d=c?t.fromEquirectangular(a):t.fromCubemap(a);return e.set(a,d),a.addEventListener("dispose",s),d.texture}else return null}}}return a}function n(a){let l=0,c=6;for(let u=0;u<c;u++)a[u]!==void 0&&l++;return l===c}function s(a){let l=a.target;l.removeEventListener("dispose",s);let c=e.get(l);c!==void 0&&(e.delete(l),c.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:i,dispose:o}}function Xw(r){let e={};function t(i){if(e[i]!==void 0)return e[i];let n;switch(i){case"WEBGL_depth_texture":n=r.getExtension("WEBGL_depth_texture")||r.getExtension("MOZ_WEBGL_depth_texture")||r.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":n=r.getExtension("EXT_texture_filter_anisotropic")||r.getExtension("MOZ_EXT_texture_filter_anisotropic")||r.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":n=r.getExtension("WEBGL_compressed_texture_s3tc")||r.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":n=r.getExtension("WEBGL_compressed_texture_pvrtc")||r.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:n=r.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 Yw(r,e,t,i){let n={},s=new WeakMap;function o(h){let d=h.target;d.index!==null&&e.remove(d.index);for(let m in d.attributes)e.remove(d.attributes[m]);d.removeEventListener("dispose",o),delete n[d.id];let p=s.get(d);p&&(e.remove(p),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,t.memory.geometries--}function a(h,d){return n[d.id]===!0||(d.addEventListener("dispose",o),n[d.id]=!0,t.memory.geometries++),d}function l(h){let d=h.attributes;for(let m in d)e.update(d[m],34962);let p=h.morphAttributes;for(let m in p){let y=p[m];for(let x=0,g=y.length;x<g;x++)e.update(y[x],34962)}}function c(h){let d=[],p=h.index,m=h.attributes.position,y=0;if(p!==null){let f=p.array;y=p.version;for(let E=0,w=f.length;E<w;E+=3){let _=f[E+0],D=f[E+1],T=f[E+2];d.push(_,D,D,T,T,_)}}else{let f=m.array;y=m.version;for(let E=0,w=f.length/3-1;E<w;E+=3){let _=E+0,D=E+1,T=E+2;d.push(_,D,D,T,T,_)}}let x=new(Hf(d)?Fa:Ra)(d,1);x.version=y;let g=s.get(h);g&&e.remove(g),s.set(h,x)}function u(h){let d=s.get(h);if(d){let p=h.index;p!==null&&d.version<p.version&&c(h)}else c(h);return s.get(h)}return{get:a,update:l,getWireframeAttribute:u}}function Zw(r,e,t,i){let n=i.isWebGL2,s;function o(d){s=d}let a,l;function c(d){a=d.type,l=d.bytesPerElement}function u(d,p){r.drawElements(s,p,a,d*l),t.update(p,s,1)}function h(d,p,m){if(m===0)return;let y,x;if(n)y=r,x="drawElementsInstanced";else if(y=e.get("ANGLE_instanced_arrays"),x="drawElementsInstancedANGLE",y===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}y[x](s,p,a,d*l,m),t.update(p,s,m)}this.setMode=o,this.setIndex=c,this.render=u,this.renderInstances=h}function Jw(r){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 $ b(r){switch(r){case pn:return["Linear","( value )"];case et:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function nf(r,e,t){let i=r.getShaderParameter(e,35713),n=r.getShaderInfoLog(e).trim();return i&&n===""?"":t.toUpperCase()+ `
` +n+ `
` +Wb(r.getShaderSource(e))}function jb(r,e){let t= $ b(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function Xb(r,e){let t;switch(e){case vx:t="Linear";break;case wx:t="Reinhard";break;case bx:t="OptimizedCineon";break;case _x:t="ACESFilmic";break;case Ex:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function Yb(r){return[r.extensionDerivatives||r.envMapCubeUV||r.bumpMap||r.tangentSpaceNormalMap||r.clearcoatNormalMap||r.flatShading||r.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(r.extensionFragDepth||r.logarithmicDepthBuffer)&&r.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",r.extensionDrawBuffers&&r.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(r.extensionShaderTextureLOD||r.envMap||r.transmission)&&r.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Ar).join( `
` )}function Zb(r){let e=[];for(let t in r){let i=r[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join( `
` )}function Jb(r,e){let t={},i=r.getProgramParameter(e,35721);for(let n=0;n<i;n++){let s=r.getActiveAttrib(e,n),o=s.name,a=1;s.type===35674&&(a=2),s.type===35675&&(a=3),s.type===35676&&(a=4),t[o]={type:s.type,location:r.getAttribLocation(e,o),locationSize:a}}return t}function Ar(r){return r!==""}function sf(r,e){return r.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 rf(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var Kb=/^[ \t ]*#include +<([ \w \d ./]+)>/gm;function ou(r){return r.replace(Kb,Qb)}function Qb(r,e){let t=Ne[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return ou(t)}var e1=/#pragma unroll_loop[ \s ]+?for \( int i \= ( \d +) \; i < ( \d +) \; i \+ \+ \) \{ ([ \s \S ]+?)(?= \} ) \} /g,t1=/#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 of(r){return r.replace(t1,Qf).replace(e1,i1)}function i1(r,e,t,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),Qf(r,e,t,i)}function Qf(r,e,t,i){let n="";for(let s=parseInt(e);s<parseInt(t);s++)n+=i.replace(/ \[ \s *i \s * \] /g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return n}function af(r){let e="precision "+r.precision+ ` float ;
precision ` +r.precision+" int;";return r.precision==="highp"?e+= `
# define HIGH _PRECISION ` :r.precision==="mediump"?e+= `
# define MEDIUM _PRECISION ` :r.precision==="lowp"&&(e+= `
# define LOW _PRECISION ` ),e}function n1(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===Nf?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===dh?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Er&&(e="SHADOWMAP_TYPE_VSM"),e}function s1(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case so:case ro:e="ENVMAP_TYPE_CUBE";break;case tl:case ph:e="ENVMAP_TYPE_CUBE_UV";break}return e}function r1(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case ro:case ph:e="ENVMAP_MODE_REFRACTION";break}return e}function o1(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case el:e="ENVMAP_BLENDING_MULTIPLY";break;case yx:e="ENVMAP_BLENDING_MIX";break;case xx:e="ENVMAP_BLENDING_ADD";break}return e}function a1(r,e,t,i){let n=r.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=n1(t),c=s1(t),u=r1(t),h=o1(t),d=t.isWebGL2?"":Yb(t),p=Zb(s),m=n.createProgram(),y,x,g=t.glslVersion?"#version "+t.glslVersion+ `
` :"";t.isRawShaderMaterial?(y=[p].filter(Ar).join( `
` ),y.length>0&&(y+= `
` ),x=[d,p].filter(Ar).join( `
` ),x.length>0&&(x+= `
` )):(y=[af(t),"#define SHADER_NAME "+t.shaderName,p,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 "+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.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 "+l:"",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(Ar).join( `
` ),x=[d,af(t),"#define SHADER_NAME "+t.shaderName,p,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 "+c:"",t.envMap?"#define "+u:"",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.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 "+l:"",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!==ln?"#define TONE_MAPPING":"",t.toneMapping!==ln?Ne.tonemapping_pars_fragment:"",t.toneMapping!==ln?Xb("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.transparent?"":"#define OPAQUE",Ne.encodings_pars_fragment,jb("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"", `
` ].filter(Ar).join( `
` )),o=ou(o),o=sf(o,t),o=rf(o,t),a=ou(a),a=sf(a,t),a=rf(a,t),o=of(o),a=of(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(g= ` # version 300 es
` ,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join( `
` )+ `
` +y,x=["#define varying in",t.glslVersion===Cp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Cp?"":"#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 f=g+y+o,E=g+x+a,w=tf(n,35633,f),_=tf(n,35632,E);if(n.attachShader(m,w),n.attachShader(m,_),t.index0AttributeName!==void 0?n.bindAttribLocation(m,0,t.index0AttributeName):t.morphTargets===!0&&n.bindAttribLocation(m,0,"position"),n.linkProgram(m),r.debug.checkShaderErrors){let O=n.getProgramInfoLog(m).trim(),W=n.getShaderInfoLog(w).trim(),A=n.getShaderInfoLog(_).trim(),v=!0,R=!0;if(n.getProgramParameter(m,35714)===!1){v=!1;let S=nf(n,w,"vertex"),B=nf(n,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,35715)+ `
Program Info Log : ` +O+ `
` +S+ `
` +B)}else O!==""?console.warn("THREE.WebGLProgram: Program Info Log:",O):(W===""||A==="")&&(R=!1);R&&(this.diagnostics={runnable:v,programLog:O,vertexShader:{log:W,prefix:y},fragmentShader:{log:A,prefix:x}})}n.deleteShader(w),n.deleteShader(_);let D;this.getUniforms=function(){return D===void 0&&(D=new hn(n,m)),D};let T;return this.getAttributes=function(){return T===void 0&&(T=Jb(n,m)),T},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=qb++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=_,this}var l1=0,au=class{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){let t=e.vertexShader,i=e.fragmentShader,n=this._getShaderStage(t),s=this._getShaderStage(i),o=this._getShaderCacheForMaterial(e);return o.has(n)===!1&&(o.add(n),n.usedTimes++),o.has(s)===!1&&(o.add(s),s.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 lu;t.set(e,i)}return t.get(e)}},lu=class{constructor(){this.id=l1++,this.usedTimes=0}};function c1(r,e,t,i,n,s,o){let a=new Ca,l=new au,c=[],u=n.isWebGL2,h=n.logarithmicDepthBuffer,d=n.floatVertexTextures,p=n.maxVertexUniforms,m=n.vertexTextures,y=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(v){let S=v.skeleton.bones;if(d)return 1024;{let L=Math.floor((p-20)/4),C=Math.min(L,S.length);return C<S.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+S.length+" bones. This GPU supports "+C+"."),0):C}}function f(v,R,S,B,L){let C=B.fog,N=v.isMeshStandardMaterial?B.environment:null,k=(v.isMeshStandardMaterial?t:e).get(v.envMap||N),V=x[v.type],U=L.isSkinnedMesh?g(L):0;v.precision!==null&&(y=n.getMaxPrecision(v.precision),y!==v.precision&&console.warn("THREE.WebGLProgram.getParameters:",v.precision,"not supported, using",y,"instead."));let q,j,ne,ae;if(V){let oe=xi[V];q=oe.vertexShader,j=oe.fragmentShader}else q=v.vertexShader,j=v.fragmentShader,l.update(v),ne=l.getVertexShaderID(v),ae=l.getFragmentShaderID(v);let H=r.getRenderTarget(),Te=v.alphaTest>0,ue=v.clearcoat>0;return{isWebGL2:u,shaderID:V,shaderName:v.type,vertexShader:q,fragmentShader:j,defines:v.defines,customVertexShaderID:ne,customFragmentShaderID:ae,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:y,instancing:L.isInstancedMesh===!0,instancingColor:L.isInstancedMesh===!0&&L.instanceColor!==null,supportsVertexTextures:m,outputEncoding:H===null?r.outputEncoding:H.isXRRenderTarget===!0?H.texture.encoding:pn,map:!!v.map,matcap:!!v.matcap,envMap:!!k,envMapMode:k&&k.mapping,envMapCubeUV:!!k&&(k.mapping===tl||k.mapping===ph),lightMap:!!v.lightMap,aoMap:!!v.aoMap,emissiveMap:!!v.emissiveMap,bumpMap:!!v.bumpMap,normalMap:!!v.normalMap,objectSpaceNormalMap:v.normalMapType=== $ x,tangentSpaceNormalMap:v.normalMapType=== $ s,decodeVideoTexture:!!v.map&&v.map.isVideoTexture===!0&&v.map.encoding===et,clearcoat:ue,clearcoatMap:ue&&!!v.clearcoatMap,clearcoatRoughnessMap:ue&&!!v.clearcoatRoughnessMap,clearcoatNormalMap:ue&&!!v.clearcoatNormalMap,displacementMap:!!v.displacementMap,roughnessMap:!!v.roughnessMap,metalnessMap:!!v.metalnessMap,specularMap:!!v.specularMap,specularIntensityMap:!!v.specularIntensityMap,specularCo
gl _Position = vec4 ( position , 1.0 ) ;
} ` ,w1= ` 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 em(r,e,t){let i=new Ns,n=new ee,s=new ee,o=new $ e,a=new Ia({depthPacking:Wx}),l=new Na,c={},u=t.maxTextureSize,h={0:gt,1:Cr,2:Fs},d=new Ui({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ee},radius:{value:4}},vertexShader:v1,fragmentShader:w1}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let m=new Ke;m.setAttribute("position",new ut(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new ht(m,d),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Nf,this.render=function(w,_,D){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||w.length===0)return;let T=r.getRenderTarget(),O=r.getActiveCubeFace(),W=r.getActiveMipmapLevel(),A=r.state;A.setBlending(an),A.buffers.color.setClear(1,1,1,1),A.buffers.depth.setTest(!0),A.setScissorTest(!1);for(let v=0,R=w.length;v<R;v++){let S=w[v],B=S.shadow;if(B===void 0){console.warn("THREE.WebGLShadowMap:",S,"has no shadow.");continue}if(B.autoUpdate===!1&&B.needsUpdate===!1)continue;n.copy(B.mapSize);let L=B.getFrameExtents();if(n.multiply(L),s.copy(B.mapSize),(n.x>u||n.y>u)&&(n.x>u&&(s.x=Math.floor(u/L.x),n.x=s.x*L.x,B.mapSize.x=s.x),n.y>u&&(s.y=Math.floor(u/L.y),n.y=s.y*L.y,B.mapSize.y=s.y)),B.map===null&&!B.isPointLightShadow&&this.type===Er){let N={minFilter:Dt,magFilter:Dt,format:Lt};B.map=new zt(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.mapPass=new zt(n.x,n.y,N),B.camera.updateProjectionMatrix()}if(B.map===null){let N={minFilter:yt,magFilter:yt,format:Lt};B.map=new zt(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.camera.updateProjectionMatrix()}r.setRenderTarget(B.map),r.clear();let C=B.getViewportCount();for(let N=0;N<C;N++){let k=B.getViewport(N);o.set(s.x*k.x,s.y*k.y,s.x*k.z,s.y*k.w),A.viewport(o),B.updateMatrices(S,N),i=B.getFrustum(),E(_,D,B.camera,S,this.type)}!B.isPointLightShadow&&this.type===Er&&g(B,D),B.needsUpdate=!1}x.needsUpdate=!1,r.setRenderTarget(T,O,W)};function g(w,_){let D=e.update(y);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,p.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),d.uniforms.shadow_pass.value=w.map.texture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,r.setRenderTarget(w.mapPass),r.clear(),r.renderBufferDirect(_,null,D,d,y,null),p.uniforms.shadow_pass.value=w.mapPass.texture,p.uniforms.resolution.value=w.mapSize,p.uniforms.radius.value=w.radius,r.setRenderTarget(w.map),r.clear(),r.renderBufferDirect(_,null,D,p,y,null)}function f(w,_,D,T,O,W,A){let v=null,R=T.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(R!==void 0?v=R:v=T.isPointLight===!0?l:a,r.localClippingEnabled&&D.clipShadows===!0&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0){let S=v.uuid,B=D.uuid,L=c[S];L===void 0&&(L={},c[S]=L);let C=L[B];C===void 0&&(C=v.clone(),L[B]=C),v=C}return v.visible=D.visible,v.wireframe=D.wireframe,A===Er?v.side=D.shadowSide!==null?D.shadowSide:D.side:v.side=D.shadowSide!==null?D.shadowSide:h[D.side],v.alphaMap=D.alphaMap,v.alphaTest=D.alphaTest,v.clipShadows=D.clipShadows,v.clippingPlanes=D.clippingPlanes,v.clipIntersection=D.clipIntersection,v.displacementMap=D.displacementMap,v.displacementScale=D.displacementScale,v.displacementBias=D.displacementBias,v.wireframeLinewidth=D.wireframeLinewidth,v.linewidth=D.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0&&(v.referencePosition.setFromMatrixPosition(T.matrixWorld),v.nearDistance=O,v.farDistance=W),v}function E(w,_,D,T,O){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&O===Er)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(D.matrixWorldInverse,w.matrixWorld);let v=e.update(w),R=w.material;if(Array.isArray(R)){let S=v.groups;for(let B=0,L=S.length;B<L;B++){let C=S[B],N=R[C.materialIndex];if(N&&N.visible){let k=f(w,v,N,T,D.near,D.far,O);r.renderBufferDirect(D,null,v,k,w,C)}}}else if(R.visible){let S=f(w,v,R,T,D.near,D.far,O);r.renderBufferDirect(D,null,v,S,w,null)}}let
` );c.length>1&&(a=a/c.length,o.font= ` $ { a } pt '${this.fontFace}' ` ,l=o.measureText("M").width*1.2,n-=l*c.length/2);for(let h=0,d=c.length;h<d;h++){let p=c[h].trim();o.fillText(c[h],s,n),(p=="6"||p=="9")&&o.fillText(" .",s,n),n+=l*1.5}let u=new at(i);return u.needsUpdate=!0,i.detach(),u}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 De({mass:this.mass,shape:this.shape}),geometry:this.geometry.clone(),values:this.values}}},rl=class extends Kt{constructor(t,i,n={diceColor:"#171120",textColor:"#FF0000"},s){super(t,i,n,s);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 o=(1+Math.sqrt(5))/2;this.vertices=[[-1,o,0],[1,o,0],[-1,-o,0],[1,-o,0],[0,-1,o],[0,1,o],[0,-1,-o],[0,1,-o],[o,0,-1],[o,0,1],[-o,0,-1],[-o,0,1]]}},ol=class extends Kt{constructor(t,i,n={diceColor:"#7339BE",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=(1+Math.sqrt(5))/2,a=1/o;this.vertices=[[0,a,o],[0,a,-o],[0,-a,o],[0,-a,-o],[o,0,a],[o,0,-a],[-o,0,a],[-o,0,-a],[a,o,0],[a,-o,0],[-a,o,0],[-a,-o,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]]}},al=class extends Kt{constructor(t,i,n={diceColor:"#c74749",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=0,a=0;o<10;++o,a+=Math.PI*2/10)this.vertices.push([Math.cos(a),Math.sin(a),.105*(o%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},ll=class extends Kt{constructor(t,i,n={diceColor:"#7a2c2d",textColor:"#FFFFFF"},s){super(t,i,n,s);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 o=0,a=0;o<10;++o,a+=Math.PI*2/10)this.vertices.push([Math.cos(a),Math.sin(a),.105*(o%2?1:-1)]);this.vertices.push([0,0,-1]),this.vertices.push([0,0,1])}},cl=class extends Kt{constructor(t,i,n={diceColor:"#5eb0c5",textColor:"#FFFFFF"},s){super(t,i,n,s);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}},ul=class extends Kt{constructor(t,i,n={diceColor:"#d68316",textColor:"#FFFFFF"},s){
a ` ,"a", ` a
a ` ,"x","s", ` s
a ` ,"s", ` s
a ` , ` s
s ` , ` s
a ` , ` s
s ` ,""];this.setColor({diceColor:"#FEF035",textColor:"#000000"})}},ml=class extends pl{constructor(t,i,n=xn,s){super(t,i,n,s);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"})}},gl=class extends oo{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}},yl=class extends gl{constructor(t,i,n=xn,s){super(t,i,n,s);this.labels=["","","s","a", ` s
a ` , ` s
s ` ,"a","s", ` a
a ` ,""];this.setColor({diceColor:"#46AC4E",textColor:"#000000"})}},xl=class extends gl{constructor(t,i,n=xn,s){super(t,i,n,s);this.labels=["","","t","f", ` f
t ` ,"t","", ` t
t ` , ` f
f ` ,"t",""];this.setColor({diceColor:"#52287E",textColor:"#FFFFFF"})}},vl=class extends oo{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]}},wl=class extends vl{constructor(t,i,n=xn,s){super(t,i,n,s);this.labels=["","","","","s", ` s
a ` , ` a
a ` ,"a","",""];this.setColor({diceColor:"#76CDDB",textColor:"#000000"})}},bl=class extends vl{constructor(t,i,n=xn,s){super(t,i,n,s);this.labels=["","","","t","f","",""];this.setColor({diceColor:"#000000",textColor:"#FFFFFF"})}};var f_={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()}},vn=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={...f_};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},s=this.makeRandomVector(n),o={x:this.w*(s.x>0?-1:1)*.9,y:this.h*(s.y>0?-1:1)*.9,z:Math.random()*200+200},a=Math.abs(s.x/s.y);a>1?o.y/=a:o.x*=a;let l=this.makeRandomVector(n),c={x:l.x*i,y:l.y*i,z:-10},u={x:-(Math.random()*s.y*5+this.inertia*s.y),y:Math.random()*s.x*5+this.inertia*s.x,z:0},h={x:Math.random(),y:Math.random(),z:Math.random(),w:Math.random()};return{pos:o,velocity:c,angular:u,axis:h}}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 P(0,0,this.sides==4?-1:1),t,i=Math.PI*2,n=this.buffer.getAttribute("normal").array;for(let o=0,a=this.buffer.groups.length;o<a;++o){let l=this.buffer.groups[o];if(l.materialIndex==0)continue;let c=o*9,h=new P(n[c],n[c+1],n[c+2]).clone().applyQuaternion(new mt(this.body.quaternion.x,this.body.quaternion.y,this.body.quaternion.z,this.body.quaternion.w)).angleTo(e);h<i&&(i=h,t=l)}let s=t.materialIndex-1;return this.sides==10&&s==0&&(s=10),this.data.values?.[s]??s}shiftUpperValue(e){let t=this.geometry.geometry.clone(),i=this.getUpsideValue();for(let n=0,s=t.groups.length;n<s;++n){let o=t.groups[n].materialIndex;if(o!==0){for(o+=e-i-1;o>this.sides;)o-=this.sides;for(;o<1;)o+=this.sides;t.groups[n].materialIndex=o+1}}this.updateMaterialsForValue(e-i),this.geometry.geometry=t}resetBody(){return this.body.vlambda=new b,this.body.position=new b,this.body.previousPosition=new b,this.body.initPosition=new b,this.body.velocity=new b,this.body.initVelocity=new b,this.body.force=new b,this.body.torque=new b,this.body.quaternion=new mt,this.body.initQuaternion=new mt,this.body.angularVelocity=new b,this.body.initAngularVelocity=new b,this.body.interpolatedPosition=new b,this.body.interpolatedQuaternion=new mt,this.body.inertia=new b,this.body.invInertia=new b,this.body.invInertiaWorld=new gi,this.body.invInertiaSolve=new b,this.body.invInertiaWorldSolve=new gi,this.body.wlambda=new b,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 b(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}},ao=class extends vn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=20;this.inertia=6;s&&(this.vector=this.generateVector(s)),this.create()}},lo=class extends vn{constructor(t,i,n,s){super(t,i,n);this.w=t;this.h=i;this.data=n;this.sides=12;this.inertia=8;s&&(this.vector=this.generateVector(s)),this.create()
$ { 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(){return this.dynamic.every(t=>t.allowAverage())}async build(){if(this.resultEl.empty(),this.expectedValue==="Average"&&!this.shouldRender){if(this.allowAverage()){for(let s of this.dynamic){let o=s.average(),a=new Map;for(let l=0;l<s.rolls;l++)a.set(l,o);s.setResults(a)}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,wn.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],s=i.value?Number(i.value):1;n.modifiers.set("u",{data:s,conditionals:[],value:i.text});break}case"kh":{let n=this.dice[t-1],s=i.value?Number(i.value):1;n.modifiers.set("kh",{data:s,conditionals:[],value:i.text});break}case"dl":{let n=this.dice[t-1],s=i.value?Number(i.value):1;s=n.rolls-s,n.modifiers.set("kh",{data:s,conditionals:[],value:i.text});break}case"kl":{let n=this.dice[t-1],s=i.value?Number(i.value):1;n.modifiers.set("kl",{data:s,conditionals:[],value:i.text});break}case"dh":{let n=this.dice[t-1],s=i.value?Number(i.value):1;s=n.rolls-s,n.modifiers.set("kl",{data:s,conditionals:[],value:i.text});break}case"!":{let n=this.dice[t-1],s=Number(i.value)||1;n.modifiers.set("!",{data:s,conditionals:i.conditions??[],value:i.text});break}case"!!":{let n=this.dice[t-1],s=Number(i.value)||1;n.modifiers.set("!!",{data:s,conditionals:i.conditions??[],value:i.text});break}case"r":{let n=this.dice[t-1],s=Number(i.value)||1;n.modifiers.set("r",{data:s,conditionals:i.conditions??[],value:i.text});break}case"sort":{let n=this.dice[t-1],s=Number(i.value);n.modifiers.set("sort",{data:s,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 oi(i.value,this.renderer,i)}this.dice[t]||(this.dice[t]=new oi(i.value,this.renderer,i)),t++;break}case"stunt":{this.dice[t]||(this.dice[t]=new _i(i.value,this.renderer,i)),t++;break}case"%":{this.dice[t]||(this.dice[t]=new El(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(),this.r
Result : $ { this . result } ` ),this.trigger("new-result"),this.app.workspace.trigger("dice-roller:new-result",this),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 s=this.stack.pop(),o=this.stack.pop();s instanceof _i&&s.doubles&&(this.stunted= ` - $ { s . results . get ( 0 ) . value } Stunt Points ` ),o instanceof _i&&o.doubles&&(this.stunted= ` - $ { o . results . get ( 0 ) . value } Stunt Points ` );let a=this.operators[n.value](o.result,s.result),l=this.operators[n.value](this.minStack.pop(),this.minStack.pop()),c=this.operators[n.value](this.maxStack.pop(),this.maxStack.pop());this.stackCopy.push(n.value),this.stack.push(new oi( ` $ { a } ` ,this.renderer,n)),this.minStack.push(l),this.maxStack.push(c);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 _i&&i.doubles&&(this.stunted= ` - $ { i . results . get ( 0 ) . value } Stunt Points ` ),this.result=i.result}};var bn=require("obsidian");var lm=/(?:(?<roll> \d +)[Dd])?#(?<query>[ \p {Letter} \p {Emoji_Presentation} \w /-]+)(?: \| (?<collapse>[ \+ -]))?(?: \| (?<types>[^ \+ -]+))?/u,cm=/(?:(?<roll> \d +)[Dd]?)?dv \( (?<query>.+) \) (?: \| (?<collapse>[ \+ -]))?(?: \| (?<types>[^ \+ -]+))?/u,um=/(?<diceRoll>.*)?(?: \[ .* \] \( | \[ \[ )(?<link>.+?)#? \^ (?<block>.+?)(?: \] \] | \) )(?: \| (?<header>.+))?/,Sl=/(?:(?<roll> \d +)[Dd])?(?: \[ .* \] \( | \[ \[ )(?<link>.+)(?: \] \] | \) ) \| ?(?<types>.+)?/;function m_(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789",i=t.length;for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*i));return e}function g_(r){return ` dice - $ { m _ ( 4 ) } ` }var Hn=class extends es{async getReplacer(){let e=await this.getBlockId();return e? ` ! [ [ $ { this . path } # ^ $ { e } ] ] ` :""}get tooltip(){return ` $ { this . original }
$ { this . path } ` }async build(){if(this.resultEl.empty(),this.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.data.copyContentButton&&this.copy.removeClass("no-show");for(let e of this.results){this.resultEl.onclick=async i=>{if(i&&i.getModifierState("Control")||i.getModifierState("Meta")){i.stopPropagation();return}};let t=this.resultEl.createDiv({cls:this.getEmbedClass()});if(!this.data.displayResultsInline){let i="type"in e?e.type:"List Item";t.setAttrs({"aria-label": ` $ { this . file . basename } : $ { i } ` })}if(!e){t.createDiv({cls:"dice-no-results",text:"No results."});continue}if(bn.MarkdownRenderer.render(app,this.displayFromCache(e),t.createDiv(),this.source,new bn.Component),this.data.copyContentButton&&this.results.length>1){let i=t.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});i.addEventListener("click",n=>{n.stopPropagation(),navigator.clipboard.writeText(this.displayFromCache(e).trim()).then(async()=>{new bn.Notice("Result copied to clipboard.")})}),(0,bn.setIcon)(i,"copy")}}}async load(){await this.getOptions()}displayFromCache(...e){let t=[];for(let i of e)t.push(this.content.slice(i.position.start.offset,i.position.end.offset));return t.join( `
` )}transformResultsToString(){return this.displayFromCache(...this.results)}async getBlockId(){this.result||await this.roll();let e=this.cache.blocks??{},t=Object.entries(e).find(([i,n])=>hm(n.position,this.result.position));if(!t){let i= ` $ { g _ ( 4 ) } ` ,n= ` $ { this . content . slice ( 0 , this . result . position . end . offset + 1 ) } ^ $ { i } $ { this . content . slice ( this . result . position . end . offset ) } ` ;return this.watch=!1,this.app.vault.modify(this.file,n),i}return t[0]}getPath(){let{groups:e}=this.lexeme.value.match(Sl)??{},{roll:t=1,link:i,types:n}=e??{};if(!i)throw new Error("Could not parse link.");this.rolls=(t&&!isNaN(Number(t))&&Number(t))??1,this.path=decodeURIComponent(i.replace(/( \[ | \] | \( | \) )/g,"")),this.types=n?.split(","),this.levels=n?.split(",").map(s=>/heading \- \d +/.test(s)?s.split("-").pop():null).filter(s=>s),this.types=n?.split(",").map(s=>/heading \- \d +/.test(s)?s.split("-").shift():s)}async getOptions(){if(this.cache=this.app.metadataCache.getFileCache(this.file),!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");this.content=await this.app.vault.cachedRead(this.file),this.options=this.cache.sections.filter(({type:e,position:t})=>this.types?e=="heading"&&this.types.includes(e)&&this.levels.length?(this.cache.headings??[]).filter(({level:n})=>this.levels.includes( ` $ { n } ` )).some(({position:n})=>hm(n,t)):this.types.includes(e):!["yaml","thematicBreak"].includes(e)),this.types&&this.types.includes("listItem")&&this.options.push(...this.cache.listItems),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.on("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])});else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),this.result=this.results[0],e(this.results[0])}})}},hm=(r,e)=>r.start.col==e.start.col&&r.start.line==e.start.line&&r.start.offset==e.start.offset;var Gi=require("obsidian");var xm=Qn(dm());var ym=Qn(fm());var gm=require("obsidian"),_h=Qn(mm());var Eh=class extends gm.Component{constructor(){super(...arguments);this.inline=new Map;this.ready=!1}initialize(t){return this.app=t,this.api=(0,_h.getAPI)(),this.dataviewReady().then(()=>this.ready=!0),this}getFieldValueFromActiveFile(t){let i=this.app.workspace.getActiveFile();return!i||!this.canUseDataview||!this.ready?null:this.api.index.pages.get(i.path)?.fields.get(t)??null}get canUseDataview(){return this.app.plugins.getPlugin("dataview")!=null}async dataviewReady(){return new Promise(t=>{this.canUseDataview||t(!1),this.api&&t(!0),this.registerEvent(this.app.metadataCache.on("dataview:api-ready",()=>{this.api=(0,_h.getAPI)(),t(!0)}))})}},Vt=new Eh;var v_=/(?: \d +[Dd])?#(?:[ \p {Letter} \p {Emoji_Presentation} \w /-]+)(?: \| (?:[+-]))?(?: \| (?:[^+-]+))?/u,w_=/(?: \d +[Dd]?)?dv \( (?:.+) \) (?: \| (?:[+-]))?(?: \| (?:[^+-]+))?/u,b_=/(?:.*)?(?: \[ .* \] \( | \[ \[ )(?:.+?)#? \^ (?:.+?)(?: \) | \] \] ) \| ?(?:.+)?/u,__=/(?: \d +[Dd])?(?: \[ .* \] \( | \[ \[ )(?:.+)(?: \) | \] \] ) \| ?(?:.+)?/u,E_=/(?: \d +[Dd])?(?: \[ .* \] \( | \[ \[ )(?:.+)(?: \) | \] \] ) \| line/u,A_=/[ \( \^ \+ \- \* \/ \) ]/u,S_=/(?: \d +| \b )[Dd](?:%|F|-? \d +| \[ \d +(?:[ \t ]*[,-][ \t ]* \d +)+ \] | \b )/u,M_=/(?:=|=!|<|>|<=|>=|=<|=>|-=|=-)(?: \d +(?:[Dd](?:%|F|-? \d +| \[ \d +(?:[ \t ]*[,-][ \t ]* \d +)+ \] | \b ))?)/u,Ah=class{constructor(e){this.table=e}parse(e){let t=e.length,i=this.table,n=[],s=[],o=0;for(;o<t;){let a=e[o++];switch(a.value){case"(":s.unshift(a);break;case")":for(e[o]&&e[o].type=="dice"&&/^d/.test(e[o].value)&&(e[o].parenedDice=!0);s.length&&(a=s.shift(),a.value!=="(");)n.push(a);if(a.value!=="(")throw new Error("Mismatched parentheses.");break;default:if(i.hasOwnProperty(a.value)){for(;s.length;){let l=s[0];if(l.value==="(")break;let c=i[a.value],u=c.precedence,h=i[l.value].precedence;if(u>h||u===h&&c.associativity==="right")break;n.push(s.shift())}s.unshift(a)}
` ,o+=n.repeat(s),o+=")"):(u=="("?(s++,o+="("):u==";"?o+=",":u=="||"&&(o+="|"),o+= `
` ,o+=n.repeat(s)),a=h}return o+=a,o}async getSubResult(t){let i=new Dh;typeof t=="number"?i.result=t.toString():i.result=t;let n=[];if(typeof t=="string"){let s=/(?: \` dice:)(.*?)(?: \` )/g,o=t.matchAll(s);for(let a of o){let l=a[1].trim(),c=await At.getRoller(l,this.source);await c.roll();let u=await this.getSubResult(c.result),h;if(u.result instanceof Gi.TFile?h=u.result.basename:h=u.result,i.result=i.result.replace(a[0],h),c instanceof r)n.push(c.combinedTooltip);else{let[d,p]=c.tooltip.split( `
` );n.push(d+" --> "+p)}}}return i.combinedTooltip=n.join(";"),i}async getResult(){let t=[],i=[],n=this.original;if(this.rollsFormula)try{let s=await At.getRoller(this.rollsFormula,this.source);if(!(s instanceof Pt))return this.prettyTooltip="TableRoller only supports dice rolls to select multiple elements.",new Gi.Notice(this.prettyTooltip),"ERROR";let o=s;await o.roll(),this.rolls=o.result,o.isStatic||(n=n.replace(this.rollsFormula, ` $ { this . rollsFormula . trim ( ) } -- > $ { o . resultText } > ` ))}catch{return this.prettyTooltip= ` TableRoller : '${this.rollsFormula}' is not a valid dice roll . ` ,new Gi.Notice(this.prettyTooltip),"ERROR"}for(let s=0;s<this.rolls;s++){let o="",a,l="";if(this.isLookup){let c=await this.lookupRoller.roll(),u=this.lookupRanges.find(([h])=>h[1]===void 0&&c===h[0]||c>=h[0]&&h[1]>=c);u&&(o=this.lookupRoller.original.trim()+" --> "+ ` $ { this . lookupRoller . resultText } $ { this . header ? " | " + this . header : "" } ` .trim(),l=u[1])}else{let c=[...this.options],u=this.getRandomBetween(0,c.length-1);o=c.length+" rows --> [row "+(u+1)+"]",l=c[u]}a=await this.getSubResult(l),t.push(a.result),a.combinedTooltip&&(o+=" > ("+a.combinedTooltip+")"),i.push(o)}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.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(s=>s.position==this.cache.blocks[this.block].position),i=this.cache.blocks[this.block].position,n=await this.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 s=T_(this.content);if(s.columns.size===2&&/dice: \s *([ \s \S ]+) \s *?/.test(Array.from(s.columns.keys())[0])){let o=await At.getRoller(Array.from(s.columns.keys())[0].split(":").pop().replace(/ \` /g,""),this.source);o instanceof Pt&&(this.lookupRoller=o,this.lookupRanges=s.rows.map(a=>{let[l,c]=a.replace(/ \\ \| /g,"{ESCAPED_PIPE}").split("|").map(d=>d.replace(/{ESCAPED_PIPE}/g," \\ |")).map(d=>d.trim()),[,u,h]=l.match(/( \d +)(?:[^ \d ]+?( \d +))?/)??[];if(!(!u&&!h))return[[Number(u),h?Number(h):void 0],c]}),this.isLookup=!0)}if(this.header==="xy"&&!s.columns.has("xy")){this.options=[];for(let o of Array.from(s.columns.values()).slice(1))this.options.push(...o)}else if(this.header&&s.columns.has(this.header))this.options=s.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=s.rows}}this.loaded=!0,this.trigger("loaded")}},D_=/^ \| ?([ \s \S ]+?) \| ? $ /,vm=/ \| /g;function T_(r){let e=r.split( `
` ),i=e.map(o=>(o.trim().match(D_)??[,o.trim()])[1])[0].replace(" \\ |","{ESCAPED_PIPE}").split(vm),n=[],s=[];for(let o in i){let a=i[o];a.trim().length||(a=o),s.push([a.trim(),[]])}for(let o of e.slice(2)){let a=o.trim().replace(/ \\ \| /g,"{ESCAPED_PIPE}").split(vm).map(l=>l.replace(/{ESCAPED_PIPE}/g," \\ |")).map(l=>l.trim()).filter(l=>l.length);n.push(a.join(" | "));for(let l in a){let c=a[l].trim();!c.length||!s[l]||s[l][1].push(c)}}return{columns:new Map(s),rows:n}}var _n=require("obsidian");var mo=class extends es{async getReplacer(){return this.result}get tooltip(){return ` $ { this . original }
$ { this . path } ` }async build(){if(this.resultEl.empty(),this.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.data.copyContentButton&&this.copy.removeClass("no-show");for(let e of this.results){this.resultEl.onclick=async i=>{if(i&&i.getModifierState("Control")||i.getModifierState("Meta")){i.stopPropagation();return}};let t=this.resultEl.createDiv({cls:this.getEmbedClass()});if(!e){t.createDiv({cls:"dice-no-results",text:"No results."});continue}if(_n.MarkdownRenderer.renderMarkdown(e,t.createDiv(),this.source,new _n.Component),this.data.copyContentButton&&this.results.length>1){let i=t.createDiv({cls:"dice-content-copy dice-roller-button",attr:{"aria-label":"Copy Contents"}});i.addEventListener("click",n=>{n.stopPropagation(),navigator.clipboard.writeText(e).then(async()=>{new _n.Notice("Result copied to clipboard.")})}),(0,_n.setIcon)(i,"copy")}}}transformResultsToString(){return this.results.join( `
` )}async load(){await this.getOptions()}getPath(){let{groups:e}=this.lexeme.value.match(Sl)??{},{roll:t=1,link:i,types:n}=e??{};if(!i)throw new Error("Could not parse link.");this.rolls=(t&&!isNaN(Number(t))&&Number(t))??1,this.path=i.replace(/( \[ | \] )/g,""),this.types=n?.split(",")}async getOptions(){if(this.content=await this.app.vault.cachedRead(this.file),!this.content)throw new Error("Could not read file cache.");this.options=this.content.trim().split( `
` ).map(e=>e.trim()).filter(e=>e&&e.length),this.loaded=!0,this.trigger("loaded")}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.on("loaded",()=>{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),e(this.results[0])});else{let i=[...this.options];this.results=[...Array(this.rolls)].map(()=>{let n=i[this.getRandomBetween(0,i.length-1)];return i.splice(i.indexOf(n),1),n}).filter(n=>n),this.render(),this.trigger("new-result"),e(this.results[0])}})}};var qn=require("obsidian");var Cl=class extends Mn{constructor(t,i,n,s,o,a=t.showDice){super(t,i,[n],a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.app=o;this.isLink=!1;this.loaded=!1}async getReplacer(){return this.isLink? ` [ [ $ { this . result . file . basename } ] ] ` :await this.result.getReplacer()}guardDataview(){if(!Vt.canUseDataview)throw new qn.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(){this.guardDataview();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.data.displayAsEmbed&&this.containerEl.addClasses(["has-embed","markdown-embed"]),this.getFiles()}get typeText(){return this.types?.length? ` | $ { this . types } ` :""}async getFiles(){if(!Vt.canUseDataview){new qn.Notice("Dice Roller: Dataview must be installed and enabled to use query rollers.");return}await Vt.dataviewReady();let t=await Vt.api.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((o,a)=>(a.type=="file"&&o.push(a.path),o),[]));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(o=> ` [ [ $ { o } ] ] $ { this . typeText } ` );this.results=[];let s=[];for(let o of n)s.push(new Promise(async a=>{let l=new Hn(this.data,o,{...this.lexeme,value:o,type:"section"},this.source,this.app,!1);this.results.push(l),a()}));await Promise.all(s),this.loaded=!0,this.trigger("loaded")}async build(){this.resultEl.empty(),this.data.displayResultsInline&&this.resultEl.createSpan({text:this.inlineText});let t=[],i=new Map(this.results.map((n,s)=>[s,n]));for(let n=0;n<this.rolls;n++){if(!i.size)continue;let s=this.getRandomBetween(0,i.size),o=i.get(s);await o.roll(),t.push(o),i.delete(s)}if(this.isLink){let n=t.reduce((s,o,a,l)=>(s.push( ` [ [ $ { o . file . basename } ] ] ` ),l.length>1&&a!=l.length-1&&s.push(","),s),[]);qn.MarkdownRenderer.render(this.app,n.join(" "),this.resultEl,this.app.workspace.getActiveFile()?.path,new qn.Component)}else for(let n of t){let s=this.resultEl.createDiv();s.createEl("h5",{cls:"dice-file-name",text:n.file.basename}),s.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}},go=class extends Cl{constructor(t,i,n,s,o,a=t.showDice){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=cm;this.initialize()}get query(){return this.base}},yo=class extends Cl{constructor(t,i,n,s,o,a=t.showDice){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=lm;this.initialize()}get query(){return ` list from # $ { this . base } ` }};var ce=require("obsidian");var Zs=require("obsidian"),C_=createSvg("svg",{attr:{viewBox:"0 0 500 500"}}),R_=createSvg("text",{attr:{class:"font",fill:"currentColor",x:"50%",y:"50%","text-anchor":"middle","dominant-baseline":"central"}}),Rl=(a=>(a.NONE="None",a.TRIANGLE="Triangle",a.SQUARE="Square",a.DIAMOND="Diamond",a.DODECAHEDRON="Dodecahedron",a.ICOSAHEDRON="Icosahedron",a.CIRCLE="Circle",a))(Rl||{}),wm=[{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:"%"}],Th=class extends Zs.Component{#e(){return C_.cloneNode(!0)}#t(){return R_.cloneNode()}#i=new Set;registerIcon(e,t,i){this.#i.add(e);let n=this.#e(),s=this.#t();s.textContent=i,n.appendChild(s);let o;switch(t){case"Triangle":o=this.getTriangle();break;case"Square":{o=this.getSquare();break}case"Diamond":{o=this.getDiamond();break}case"Dodecahedron":{o=this.getDodecahedron();break}case"Icosahedron":{o=this.getIcosahedron();break}case"Circle":{o=this.getCircle();break}case"None":o=createSvg("defs")}n.appendChild(o),(0,Zs.addIcon)(e,n.outerHTML),this.register(()=>(0,Zs.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.21-6.69l73.47-226.1A9.72,9.72,0,0,0,448,168.87L255.69,29.14A9.66,9.66,0,0,0,244.31,29.14Z"})}getIcosahedron(){return this.#n("path",{d:"M55.14,143.27V356.73a10,10,0,0,0,5,8.66L245,472.11a10,10,0,0,0,10,0L439.86,365.39a10,10,0,0,0,5-8.66V143.27a10,10,0,0,0-5-8.66L255,27.89a10,10,0,0,0-10,0L60.14,134.61A10,10,0,0,0,55.14,143.27Z"})}getCircle
` ),f=g.slice(a.lineStart,a.lineEnd+1);return this.data.escapeDiceMod?f=f.join( `
` ).replace( ` \ ` ${ d } \` ` , y . replace ( /([\*\[\]])/g , "\\$1" ) ) . split ( `
` ):f=f.join( `
` ).replace( ` \ ` ${ d } \` ` , y ) . split ( `
` ),g.splice(a.lineStart,a.lineEnd-a.lineStart+1,...f),g.join( `
` )});continue}try{let m=await At.getRoller(p,i.sourcePath);if(m.onLoad(async()=>{await m.roll(),h.replaceWith(m.containerEl)}),!o||!(o instanceof jt.TFile))continue;this.trackRoller(o,m);let y=this.app.workspace.getActiveViewOfType(jt.MarkdownView);if(y&&this.fileMap.has(o)&&this.fileMap.get(o).length===1){let x=this,g=xg(y,{onUnloadFile:function(f){return async function(E){return E==o&&(x.fileMap.delete(o),g()),await f.call(this,E)}}});y.register(g),y.register(()=>this.fileMap.delete(o))}}catch(m){console.error(m),new jt.Notice( ` There was an error parsing the dice string : $ { h . innerText } .
$ { m } ` ,5e3);continue}}}processContent(t){let i=this.data.displayFormulaForMod;return t.includes("|noform")&&(i=!1),t.includes("|form")&&(i=!0),i}};var eA=/^[v^~<>=]*?( \d +)(?: \. ([x*]| \d +)(?: \. ([x*]| \d +)(?: \. ([x*]| \d +))?(?:-([ \d a-z \- ]+(?: \. [ \d a-z \- ]+)*))?(?: \+ [ \d a-z \- ]+(?: \. [ \d a-z \- ]+)*)?)?)? $ /i,id=r=>{if(typeof r!="string")throw new TypeError("Invalid argument expected string");let e=r.match(eA);if(!e)throw new Error( ` Invalid argument not valid semver ( '${r}' received ) ` );return e.shift(),e},vg=r=>r==="*"||r==="x"||r==="X",wg=r=>{let e=parseInt(r,10);return isNaN(e)?r:e},tA=(r,e)=>typeof r!=typeof e?[String(r),String(e)]:[r,e],iA=(r,e)=>{if(vg(r)||vg(e))return 0;let[t,i]=tA(wg(r),wg(e));return t>i?1:t<i?-1:0},nd=(r,e)=>{for(let t=0;t<Math.max(r.length,e.length);t++){let i=iA(r[t]||"0",e[t]||"0");if(i!==0)return i}return 0};var bg=(r,e)=>{let t=id(r),i=id(e),n=t.pop(),s=i.pop(),o=nd(t,i);return o!==0?o:n&&s?nd(n.split("."),s.split(".")):n||s?n?-1:1:0};var Mo=(r,e,t)=>{nA(t);let i=bg(r,e);return Eg[t].includes(i)},Eg={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},_g=Object.keys(Eg),nA=r=>{if(typeof r!="string")throw new TypeError( ` Invalid operator type , expected string but got $ { typeof r } ` );if(_g.indexOf(r)===-1)throw new Error( ` Invalid operator , expected one of $ { _g . join ( "|" ) } ` )};var Wl=class extends Xi.Plugin{constructor(){super(...arguments);this.api=At}getRendererData(){return{diceColor:this.data.diceColor,textColor:this.data.textColor,colorfulDice:this.data.colorfulDice,scaler:this.data.scaler,renderTime:this.data.renderTime,textFont:this.data.textFont}}async onload(){console.log("DiceRoller plugin loaded"),await this.loadSettings(),this.renderer=new ho(this.getRendererData()),this.api.initialize(this.data,this.app,this.renderer),window.DiceRoller=this.api,this.register(()=>delete window.DiceRoller),this.addChild(Vt.initialize(this.app)),Gn.setDefaults(this.data.defaultRoll,this.data.defaultFace),this.addSettingTab(new xo(this.app,this)),this.registerView(Zn,t=>new tr(this,t)),this.registerEvent(this.app.workspace.on("dice-roller:render-dice",async t=>{let i=await At.getRoller(t,"external");if(!(i instanceof Pt)){new Xi.Notice("The Dice View only supports dice rolls.");return}if(await i.roll(),!i.dice.length){new Xi.Notice("Invalid formula.");return}try{await i.roll(!0)}catch(n){new Xi.Notice("There was an error rendering the roll."),console.error(n)}this.app.workspace.trigger("dice-roller:rendered-result",i.result)})),this.addCommand({id:"open-view",name:"Open Dice View",callback:()=>{this.view?this.app.workspace.revealLeaf(this.view.leaf):this.addDiceView()}}),this.processor=new So,this.processor.initialize(this),this.registerMarkdownPostProcessor((t,i)=>this.processor.postprocessor(t,i)),this.registerEditorExtension([yg(this)]),this.app.workspace.onLayoutReady(async()=>{this.addDiceView(!0)}),this.app.workspace.trigger("dice-roller:loaded")}get view(){let t=this.app.workspace.getLeavesOfType(Zn),i=t.length?t[0]:null;if(i&&i.view&&i.view instanceof tr)return i.view}async addDiceView(t=!1){t&&!this.data.showLeafOnStartup||this.app.workspace.getLeavesOfType(Zn).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:Zn})}async loadSettings(){let t=Object.assign({},Il,await this.loadData()),i=!1;console.log(Mo("11.0.0","0.0.0",">")),typeof t.version!="string"&&delete t.version,Mo("11.0.0",t.version??"0.0.0",">")&&(delete t.persistResults,delete t.results,i=!0),Mo(t.version??"0.0.0",this.manifest.version,"!=")&&(t.version=this.manifest.version,i=!0),this.data=Pl(t),i&&await this.saveSettings()}async saveSettings(){await this.saveData(this.data)}async getArrayRoller(t,i=1){return new Xi.Notice("Using the Dice Roller plugin directly will be deprecated in a future version. Please use ` window . DiceRoller ` instead."),this.api.getArrayRoller(t,i)}async getRoller(t,i="",n){return new Xi.Notice("Using the Dice Roller plugin directly will be deprecated in a future version. Please use ` window . DiceRoller ` instead."),this.api.getRoller(t,i,n)}getRollerSync(t,i,n){return new Xi.Notice("Using the Dice Roller
/ * ! 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 *)
three / build / three . module . js :
( * *
* @ license
* Copyright 2010 - 2022 Three . js Authors
* SPDX - License - Identifier : MIT
* )
* /