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

3095 lines
870 KiB

3 years ago
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
2 months ago
var e0=Object.create;var Bo=Object.defineProperty;var t0=Object.getOwnPropertyDescriptor;var i0=Object.getOwnPropertyNames;var n0=Object.getPrototypeOf,s0=Object.prototype.hasOwnProperty;var _i=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),r0=(r,e)=>{for(var t in e)Bo(r,t,{get:e[t],enumerable:!0})},Td=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of i0(e))!s0.call(r,n)&&n!==t&&Bo(r,n,{get:()=>e[n],enumerable:!(i=t0(e,n))||i.enumerable});return r};var nn=(r,e,t)=>(t=r!=null?e0(n0(r)):{},Td(e||!r||!r.__esModule?Bo(t,"default",{value:r,enumerable:!0}):t,r)),o0=r=>Td(Bo({},"__esModule",{value:!0}),r);var Hm=_i(Ji=>{"use strict";var _E=Ji&&Ji.__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(Ji,"__esModule",{value:!0});Ji.getWordsByCategory=Ji.wordList=void 0;Ji.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:"ch
7 months ago
`,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(`
2 months ago
`))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 M({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 M(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 M=function(A,v){this.startState=v,this.states=A,this.buffer="",this.stack=[],this.reset()};M.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},M.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}},M.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}},M.prototype.popState=function(){this.setState(this.stack.pop())},M.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};M.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 z(){return this.value}if(M.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)}},M.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:z,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},M.prototype[Symbol.iterator]=function(){return new W(this)}}return M.prototype.formatError=function(A,v){if(A==null)var R=this.buffer.slice(this.index),A={text:R,offset:this.index,lineBreaks:R.indexOf(`
7 months ago
`)===-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(`
2 months ago
`)},M.prototype.clone=function(){return new M(this.states,this.state)},M.prototype.has=function(A){return!0},{compile:f,states:w,error:Object.freeze({error:!0}),fallback:Object.freeze({fallback:!0}),keywords:_}})});var Gl=_i(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Wt.isNone=Wt.isSome=Wt.None=Wt.Some=Wt.OptionType=void 0;Wt.OptionType={Some:Symbol(":some"),None:Symbol(":none")};function OE(r){return typeof r>"u"?xo():eg(r)}Wt.Some=OE;Wt.None=xo();function eg(r){return{type:Wt.OptionType.Some,isSome(){return!0},isNone(){return!1},match(e){return e.some(r)},map(e){return eg(e(r))},andThen(e){return e(r)},or(e){return this},and(e){return e},unwrapOr(e){return r},unwrap(){return r}}}function xo(){return{type:Wt.OptionType.None,isSome(){return!1},isNone(){return!0},match(r){let{none:e}=r;return typeof e=="function"?e():e},map(r){return xo()},andThen(r){return xo()},or(r){return r},and(r){return xo()},unwrapOr(r){if(r==null)throw new Error("Cannot call unwrapOr with a missing value.");return r},unwrap(){throw new ReferenceError("Trying to unwrap None.")}}}function zE(r){return r.isSome()}Wt.isSome=zE;function VE(r){return r.isNone()}Wt.isNone=VE});var tg=_i($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.isRight=$t.isLeft=$t.Right=$t.Left=$t.EitherType=void 0;var ql=Gl();$t.EitherType={Left:Symbol(":left"),Right:Symbol(":right")};function vo(r){return{type:$t.EitherType.Left,isLeft(){return!0},isRight(){return!1},left(){return(0,ql.Some)(r)},leftAndThen(e){return e(r)},right(){return ql.None},rightAndThen(e){return vo(r)},unwrap(){return r},unwrapLeft(){return r},unwrapLeftOr(e){return r},unwrapLeftOrElse(e){return r},unwrapRight(){throw new ReferenceError("Cannot unwrap Right value of Either.Left")},unwrapRightOr(e){return e},unwrapRightOrElse(e){return e(r)},match(e){return e.left(r)},map(e){return vo(e(r))},mapLeft(e){return vo(e(r))},mapRight(e){return vo(r)}}}$t.Left=vo;function wo(r){return{type:$t.EitherType.Right,isLeft(){return!1},isRight(){return!0},left(){return ql.None},leftAndThen(e){return wo(r)},right(){return(0,ql.Some)(r)},rightAndThen(e){return e(r)},unwrap(){return r},unwrapLeft(){throw new ReferenceError("Cannot unwrap Left value of Either.Right")},unwrapLeftOr(e){return e},unwrapLeftOrElse(e){return e(r)},unwrapRight(){return r},unwrapRightOr(e){return r},unwrapRightOrElse(e){return r},match(e){return e.right(r)},map(e){return wo(e(r))},mapLeft(e){return wo(r)},mapRight(e){return wo(e(r))}}}$t.Right=wo;function UE(r){return r.isLeft()}$t.isLeft=UE;function HE(r){return r.isRight()}$t.isRight=HE});var ig=_i(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.isErr=jt.isOk=jt.Err=jt.Ok=jt.ResultType=void 0;var jl=Gl();jt.ResultType={Ok:Symbol(":ok"),Err:Symbol(":err")};function Wl(r){return{type:jt.ResultType.Ok,isOk(){return!0},isErr(){return!1},ok(){return(0,jl.Some)(r)},err(){return jl.None},unwrap(){return r},unwrapOr(e){return r},unwrapOrElse(e){return r},unwrapErr(){throw new ReferenceError("Cannot unwrap Err value of Result.Ok")},match(e){return e.ok(r)},map(e){return Wl(e(r))},mapErr(e){return Wl(r)},andThen(e){return e(r)},orElse(e){return Wl(r)}}}jt.Ok=Wl;function $l(r){return{type:jt.ResultType.Err,isOk(){return!1},isErr(){return!0},ok(){return jl.None},err(){return(0,jl.Some)(r)},unwrap(){throw new ReferenceError("Cannot unwrap Ok value of Result.Err")},unwrapOr(e){return e},unwrapOrElse(e){return e(r)},unwrapErr(){return r},match(e){return e.err(r)},map(e){return $l(r)},mapErr(e){return $l(e(r))},andThen(e){return $l(r)},orElse(e){return e(r)}}}jt.Err=$l;function GE(r){return r.isOk()}jt.isOk=GE;function qE(r){return r.isErr()}jt.isErr=qE});var td=_i(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.Ok=Qe.isOk=Qe.isErr=Qe.Err=Qe.Some=Qe.None=Qe.isSome=Qe.isNone=Qe.Right=Qe.Left=Qe.isRight=Qe.isLeft=void 0;var Xl=tg();Object.defineProperty(Qe,"isLeft",{enumerable:!0,get:function(){return Xl.isLeft}});Object.defineProperty(Qe,"isRight",{enumerable:!0,get:function(){return Xl.isRight}});Object.defineProperty(
`,nexist:"\u2204",nexists:"\u2204",nfr:"\u{1D52B}",Nfr:"\u{1D511}",nge:"\u2271",ngE:"\u2267\u0338",ngeq:"\u2271",ngeqq:"\u2267\u0338",ngeqslant:"\u2A7E\u0338",nges:"\u2A7E\u0338",nGg:"\u22D9\u0338",ngsim:"\u2275",ngt:"\u226F",nGt:"\u226B\u20D2",ngtr:"\u226F",nGtv:"\u226B\u0338",nharr:"\u21AE",nhArr:"\u21CE",nhpar:"\u2AF2",ni:"\u220B",nis:"\u22FC",nisd:"\u22FA",niv:"\u220B",njcy:"\u045A",NJcy:"\u040A",nlarr:"\u219A",nlArr:"\u21CD",nldr:"\u2025",nle:"\u2270",nlE:"\u2266\u0338",nleftarrow:"\u219A",nLeftarrow:"\u21CD",nleftrightarrow:"\u21AE",nLeftrightarrow:"\u21CE",nleq:"\u2270",nleqq:"\u2266\u0338",nleqslant:"\u2A7D\u0338",nles:"\u2A7D\u0338",nless:"\u226E",nLl:"\u22D8\u0338",nlsim:"\u2274",nlt:"\u226E",nLt:"\u226A\u20D2",nltri:"\u22EA",nltrie:"\u22EC",nLtv:"\u226A\u0338",nmid:"\u2224",NoBreak:"\u2060",NonBreakingSpace:"\xA0",nopf:"\u{1D55F}",Nopf:"\u2115",not:"\xAC",Not:"\u2AEC",NotCongruent:"\u2262",NotCupCap:"\u226D",NotDoubleVerticalBar:"\u2226",NotElement:"\u2209",NotEqual:"\u2260",NotEqualTilde:"\u2242\u0338",NotExists:"\u2204",NotGreater:"\u226F",NotGreaterEqual:"\u2271",NotGreaterFullEqual:"\u2267\u0338",NotGreaterGreater:"\u226B\u0338",NotGreaterLess:"\u2279",NotGreaterSlantEqual:"\u2A7E\u0338",NotGreaterTilde:"\u2275",NotHumpDownHump:"\u224E\u0338",NotHumpEqual:"\u224F\u0338",notin:"\u2209",notindot:"\u22F5\u0338",notinE:"\u22F9\u0338",notinva:"\u2209",notinvb:"\u22F7",notinvc:"\u22F6",NotLeftTriangle:"\u22EA",NotLeftTriangleBar:"\u29CF\u0338",NotLeftTriangleEqual:"\u22EC",NotLess:"\u226E",NotLessEqual:"\u2270",NotLessGreater:"\u2278",NotLessLess:"\u226A\u0338",NotLessSlantEqual:"\u2A7D\u0338",NotLessTilde:"\u2274",NotNestedGreaterGreater:"\u2AA2\u0338",NotNestedLessLess:"\u2AA1\u0338",notni:"\u220C",notniva:"\u220C",notnivb:"\u22FE",notnivc:"\u22FD",NotPrecedes:"\u2280",NotPrecedesEqual:"\u2AAF\u0338",NotPrecedesSlantEqual:"\u22E0",NotReverseElement:"\u220C",NotRightTriangle:"\u22EB",NotRightTriangleBar:"\u29D0\u0338",NotRightTriangleEqual:"\u22ED",NotSquareSubset:"\u228F\u0338",NotSquareSubsetEqual:"\u22E2",NotSquareSuperset:"\u2290\u0338",NotSquareSupersetEqual:"\u22E3",NotSubset:"\u2282\u20D2",NotSubsetEqual:"\u2288",NotSucceeds:"\u2281",NotSucceedsEqual:"\u2AB0\u0338",NotSucceedsSlantEqual:"\u22E1",NotSucceedsTilde:"\u227F\u0338",NotSuperset:"\u2283\u20D2",NotSupersetEqual:"\u2289",NotTilde:"\u2241",NotTildeEqual:"\u2244",NotTildeFullEqual:"\u2247",NotTildeTilde:"\u2249",NotVerticalBar:"\u2224",npar:"\u2226",nparallel:"\u2226",nparsl:"\u2AFD\u20E5",npart:"\u2202\u0338",npolint:"\u2A14",npr:"\u2280",nprcue:"\u22E0",npre:"\u2AAF\u0338",nprec:"\u2280",npreceq:"\u2AAF\u0338",nrarr:"\u219B",nrArr:"\u21CF",nrarrc:"\u2933\u0338",nrarrw:"\u219D\u0338",nrightarrow:"\u219B",nRightarrow:"\u21CF",nrtri:"\u22EB",nrtrie:"\u22ED",nsc:"\u2281",nsccue:"\u22E1",nsce:"\u2AB0\u0338",nscr:"\u{1D4C3}",Nscr:"\u{1D4A9}",nshortmid:"\u2224",nshortparallel:"\u2226",nsim:"\u2241",nsime:"\u2244",nsimeq:"\u2244",nsmid:"\u2224",nspar:"\u2226",nsqsube:"\u22E2",nsqsupe:"\u22E3",nsub:"\u2284",nsube:"\u2288",nsubE:"\u2AC5\u0338",nsubset:"\u2282\u20D2",nsubseteq:"\u2288",nsubseteqq:"\u2AC5\u0338",nsucc:"\u2281",nsucceq:"\u2AB0\u0338",nsup:"\u2285",nsupe:"\u2289",nsupE:"\u2AC6\u0338",nsupset:"\u2283\u20D2",nsupseteq:"\u2289",nsupseteqq:"\u2AC6\u0338",ntgl:"\u2279",ntilde:"\xF1",Ntilde:"\xD1",ntlg:"\u2278",ntriangleleft:"\u22EA",ntrianglelefteq:"\u22EC",ntriangleright:"\u22EB",ntrianglerighteq:"\u22ED",nu:"\u03BD",Nu:"\u039D",num:"#",numero:"\u2116",numsp:"\u2007",nvap:"\u224D\u20D2",nvdash:"\u22AC",nvDash:"\u22AD",nVdash:"\u22AE",nVDash:"\u22AF",nvge:"\u2265\u20D2",nvgt:">\u20D2",nvHarr:"\u2904",nvinfin:"\u29DE",nvlArr:"\u2902",nvle:"\u2264\u20D2",nvlt:"<\u20D2",nvltrie:"\u22B4\u20D2",nvrArr:"\u2903",nvrtrie:"\u22B5\u20D2",nvsim:"\u223C\u20D2",nwarhk:"\u2923",nwarr:"\u2196",nwArr:"\u21D6",nwarrow:"\u2196",nwnear:"\u2927",oacute:"\xF3",Oacute:"\xD3",oast:"\u229B",ocir:"\u229A",ocirc:"\xF4",Ocirc:"\xD4",ocy:"\u043E",Ocy:"\u041E",odash:"\u229D",odblac:"\u0151",Odblac:"\u0150",odiv:"\u2A38",odot:"\u2299",odsold:"\u29BC",oelig:"\u0153",OElig:"\u01
3 years ago
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
2 months ago
}`,Iv=`void main() {
3 years ago
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`,Zi=class extends ft{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=Pv,this.fragmentShader=Iv,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=Ns(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}};Zi.prototype.isShaderMaterial=!0;var Ur=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)}};Ur.prototype.isCamera=!0;var Et=class extends Ur{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=Au*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){let e=Math.tan(zc*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Au*2*Math.atan(Math.tan(zc*.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(zc*.5*this.fov)/this.zoom,i=2*t,n=this.aspect*i,s=-.5*n,o=this.view;if(this.view!==null&&this.vie
3 years ago
varying vec3 vWorldDirection;
3 years ago
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
3 years ago
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
3 years ago
}
3 years ago
void main() {
3 years ago
vWorldDirection = transformDirection( position, modelMatrix );
3 years ago
#include <begin_vertex>
#include <project_vertex>
3 years ago
}
`,fragmentShader:`
3 years ago
uniform sampler2D tEquirect;
3 years ago
varying vec3 vWorldDirection;
3 years ago
#include <common>
3 years ago
void main() {
3 years ago
vec3 direction = normalize( vWorldDirection );
3 years ago
vec2 sampleUV = equirectUv( direction );
3 years ago
gl_FragColor = texture2D( tEquirect, sampleUV );
3 years ago
}
`},n=new Vr(5,5,5),s=new Zi({name:"CubemapFromEquirect",uniforms:Ns(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:xt,blending:mn});s.uniforms.tEquirect.value=t;let o=new pt(n,s),a=t.minFilter;return t.minFilter===sl&&(t.minFilter=Rt),new Hr(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)}};Pa.prototype.isWebGLCubeRenderTarget=!0;var au=new P,Nv=new P,kv=new wt,di=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=au.subVectors(i,t).cross(Nv.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(au),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||kv.getNormalMatrix(e),n=this.coplanarPoint(au).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)}};di.prototype.isPlane=!0;var xs=new Ci,ua=new P,Os=class{constructor(e=new di,t=new di,i=new di,n=new di,s=new di,o=new di){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(),xs.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}intersectsSprite(e){return xs.center.set(0,0,0),xs.radius=.7071067811865476,xs.applyMatrix4(e.matrixWorld),this.intersectsSphere(xs)}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(ua.x=n.normal.x>0?e.max.x:e.min.x,ua.y=n.normal.y>0?e.max.y:e.min.y,ua.z=n.normal.z>0?e.max.z:e.min.z,n.distanceToPoint(ua)<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 pm(){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;
2 months ago
#endif`,Vv=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
2 months ago
#endif`,Uv=`#ifdef USE_ALPHATEST
if ( diffuseColor.a < alphaTest ) discard;
2 months ago
#endif`,Hv=`#ifdef USE_ALPHATEST
uniform float alphaTest;
2 months ago
#endif`,Gv=`#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
2 months ago
#endif`,qv=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
2 months ago
#endif`,Wv="vec3 transformed = vec3( position );",$v=`vec3 objectNormal = vec3( normal );
3 years ago
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
2 months ago
#endif`,jv=`vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
3 years ago
return RECIPROCAL_PI * diffuseColor;
}
3 years ago
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 );
}
3 years ago
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 );
3 years ago
}
3 years ago
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
3 years ago
return RECIPROCAL_PI * a2 / pow2( denom );
3 years ago
}
3 years ago
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 );
3 years ago
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 );
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
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 );
3 years ago
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( ) {
3 years ago
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 );
3 years ago
}
3 years ago
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( );
3 years ago
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
}
3 years ago
#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 );
3 years ago
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
3 years ago
}
3 years ago
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 );
3 years ago
}
2 months ago
#endif`,Xv=`#ifdef USE_BUMPMAP
3 years ago
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;
3 years ago
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 );
}
2 months ago
#endif`,Yv=`#if NUM_CLIPPING_PLANES > 0
3 years ago
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
2 months ago
#endif`,Zv=`#if NUM_CLIPPING_PLANES > 0
3 years ago
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
2 months ago
#endif`,Jv=`#if NUM_CLIPPING_PLANES > 0
3 years ago
varying vec3 vClipPosition;
2 months ago
#endif`,Kv=`#if NUM_CLIPPING_PLANES > 0
3 years ago
vClipPosition = - mvPosition.xyz;
2 months ago
#endif`,Qv=`#if defined( USE_COLOR_ALPHA )
3 years ago
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
2 months ago
#endif`,e2=`#if defined( USE_COLOR_ALPHA )
3 years ago
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
2 months ago
#endif`,t2=`#if defined( USE_COLOR_ALPHA )
3 years ago
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR )
varying vec3 vColor;
2 months ago
#endif`,i2=`#if defined( USE_COLOR_ALPHA )
3 years ago
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;
2 months ago
#endif`,n2=`#define PI 3.141592653589793
3 years ago
#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 );
3 years ago
}
3 years ago
#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 );
3 years ago
}
3 years ago
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
float linearToRelativeLuminance( const in vec3 color ) {
vec3 weights = vec3( 0.2126, 0.7152, 0.0722 );
return dot( weights, color.rgb );
3 years ago
}
3 years ago
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
3 years ago
}
3 years ago
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 );
2 months ago
}`,s2=`#ifdef ENVMAP_TYPE_CUBE_UV
3 years ago
#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 );
3 years ago
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
3 years ago
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
3 years ago
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
3 years ago
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
3 years ago
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
3 years ago
}
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 ); }
3 years ago
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 );
}
}
2 months ago
#endif`,r2=`vec3 transformedNormal = objectNormal;
3 years ago
#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
2 months ago
#endif`,o2=`#ifdef USE_DISPLACEMENTMAP
3 years ago
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
2 months ago
#endif`,a2=`#ifdef USE_DISPLACEMENTMAP
3 years ago
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );
2 months ago
#endif`,l2=`#ifdef USE_EMISSIVEMAP
3 years ago
vec4 emissiveColor = texture2D( emissiveMap, vUv );
totalEmissiveRadiance *= emissiveColor.rgb;
2 months ago
#endif`,c2=`#ifdef USE_EMISSIVEMAP
3 years ago
uniform sampler2D emissiveMap;
2 months ago
#endif`,u2="gl_FragColor = linearToOutputTexel( gl_FragColor );",h2=`vec4 LinearToLinear( in vec4 value ) {
3 years ago
return value;
3 years ago
}
3 years ago
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 );
2 months ago
}`,d2=`#ifdef USE_ENVMAP
3 years ago
#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
2 months ago
#endif`,p2=`#ifdef USE_ENVMAP
3 years ago
uniform float envMapIntensity;
uniform float flipEnvMap;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
2 months ago
#endif`,f2=`#ifdef USE_ENVMAP
3 years ago
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
2 months ago
#endif`,m2=`#ifdef USE_ENVMAP
3 years ago
#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
2 months ago
#endif`,g2=`#ifdef USE_ENVMAP
3 years ago
#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
2 months ago
#endif`,y2=`#ifdef USE_FOG
3 years ago
vFogDepth = - mvPosition.z;
2 months ago
#endif`,x2=`#ifdef USE_FOG
3 years ago
varying float vFogDepth;
2 months ago
#endif`,v2=`#ifdef USE_FOG
3 years ago
#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 );
2 months ago
#endif`,w2=`#ifdef USE_FOG
3 years ago
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
2 months ago
#endif`,b2=`#ifdef USE_GRADIENTMAP
3 years ago
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
2 months ago
}`,_2=`#ifdef USE_LIGHTMAP
3 years ago
vec4 lightMapTexel = texture2D( lightMap, vUv2 );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
#ifndef PHYSICALLY_CORRECT_LIGHTS
lightMapIrradiance *= PI;
#endif
reflectedLight.indirectDiffuse += lightMapIrradiance;
2 months ago
#endif`,E2=`#ifdef USE_LIGHTMAP
3 years ago
uniform sampler2D lightMap;
uniform float lightMapIntensity;
2 months ago
#endif`,A2=`vec3 diffuse = vec3( 1.0 );
3 years ago
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
2 months ago
#endif`,S2=`uniform bool receiveShadow;
3 years ago
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;
3 years ago
}
3 years ago
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
3 years ago
}
3 years ago
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
3 years ago
}
3 years ago
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
3 years ago
}
3 years ago
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
3 years ago
}
3 years ago
#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;
3 years ago
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;
}
2 months ago
#endif`,M2=`#if defined( USE_ENVMAP )
3 years ago
#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
}
2 months ago
#endif`,D2=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,T2=`varying vec3 vViewPosition;
3 years ago
struct ToonMaterial {
vec3 diffuseColor;
3 years ago
};
3 years ago
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 );
3 years ago
}
3 years ago
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 );
3 years ago
}
3 years ago
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon
2 months ago
#define Material_LightProbeLOD( material ) (0)`,C2=`BlinnPhongMaterial material;
3 years ago
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
2 months ago
material.specularStrength = specularStrength;`,R2=`varying vec3 vViewPosition;
3 years ago
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
3 years ago
};
3 years ago
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;
3 years ago
}
3 years ago
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 );
3 years ago
}
3 years ago
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong
2 months ago
#define Material_LightProbeLOD( material ) (0)`,F2=`PhysicalMaterial material;
3 years ago
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;
3 years ago
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 );
3 years ago
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
2 months ago
#endif`,L2=`struct PhysicalMaterial {
3 years ago
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 );
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
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 );
3 years ago
singleScatter += FssEss;
multiScatter += Fms * Ems;
3 years ago
}
3 years ago
#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;
3 years ago
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 );
3 years ago
}
3 years ago
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 );
3 years ago
}
3 years ago
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;
3 years ago
}
3 years ago
#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 );
2 months ago
}`,B2=`
3 years ago
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 );
2 months ago
#endif`,P2=`#if defined( RE_IndirectDiffuse )
3 years ago
#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
2 months ago
#endif`,I2=`#if defined( RE_IndirectDiffuse )
3 years ago
RE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );
2 months ago
#endif`,N2=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
3 years ago
gl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
2 months ago
#endif`,k2=`#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )
3 years ago
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
2 months ago
#endif`,O2=`#ifdef USE_LOGDEPTHBUF
3 years ago
#ifdef USE_LOGDEPTHBUF_EXT
varying float vFragDepth;
varying float vIsPerspective;
#else
uniform float logDepthBufFC;
#endif
2 months ago
#endif`,z2=`#ifdef USE_LOGDEPTHBUF
3 years ago
#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
2 months ago
#endif`,V2=`#ifdef USE_MAP
3 years ago
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;
2 months ago
#endif`,U2=`#ifdef USE_MAP
3 years ago
uniform sampler2D map;
2 months ago
#endif`,H2=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
3 years ago
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;
2 months ago
#endif`,G2=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
3 years ago
uniform mat3 uvTransform;
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
2 months ago
#endif`,q2=`float metalnessFactor = metalness;
3 years ago
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vUv );
metalnessFactor *= texelMetalness.b;
2 months ago
#endif`,W2=`#ifdef USE_METALNESSMAP
3 years ago
uniform sampler2D metalnessMap;
2 months ago
#endif`,$2=`#ifdef USE_MORPHNORMALS
3 years ago
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
2 months ago
#endif`,j2=`#ifdef USE_MORPHTARGETS
3 years ago
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
2 months ago
#endif`,X2=`#ifdef USE_MORPHTARGETS
3 years ago
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
2 months ago
#endif`,Y2=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
3 years ago
#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
2 months ago
vec3 geometryNormal = normal;`,Z2=`#ifdef OBJECTSPACE_NORMALMAP
normal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;
3 years ago
#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 );
2 months ago
#endif`,J2=`#ifndef FLAT_SHADED
3 years ago
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
2 months ago
#endif`,K2=`#ifndef FLAT_SHADED
3 years ago
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
2 months ago
#endif`,Q2=`#ifndef FLAT_SHADED
3 years ago
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
2 months ago
#endif`,ew=`#ifdef USE_NORMALMAP
3 years ago
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;
3 years ago
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 );
}
2 months ago
#endif`,tw=`#ifdef USE_CLEARCOAT
3 years ago
vec3 clearcoatNormal = geometryNormal;
2 months ago
#endif`,iw=`#ifdef USE_CLEARCOAT_NORMALMAP
3 years ago
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
2 months ago
#endif`,nw=`#ifdef USE_CLEARCOATMAP
3 years ago
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
2 months ago
#endif`,sw=`#ifdef OPAQUE
3 years ago
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= transmissionAlpha + 0.1;
#endif
2 months ago
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,rw=`vec3 packNormalToRGB( const in vec3 normal ) {
3 years ago
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.;
3 years ago
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;
3 years ago
}
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 );
2 months ago
}`,ow=`#ifdef PREMULTIPLIED_ALPHA
3 years ago
gl_FragColor.rgb *= gl_FragColor.a;
2 months ago
#endif`,aw=`vec4 mvPosition = vec4( transformed, 1.0 );
3 years ago
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
2 months ago
gl_Position = projectionMatrix * mvPosition;`,lw=`#ifdef DITHERING
3 years ago
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
2 months ago
#endif`,cw=`#ifdef DITHERING
3 years ago
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;
}
2 months ago
#endif`,uw=`float roughnessFactor = roughness;
3 years ago
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vUv );
roughnessFactor *= texelRoughness.g;
2 months ago
#endif`,hw=`#ifdef USE_ROUGHNESSMAP
3 years ago
uniform sampler2D roughnessMap;
2 months ago
#endif`,dw=`#ifdef USE_SHADOWMAP
3 years ago
#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 );
3 years ago
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 );
3 years ago
}
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
3 years ago
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;
3 years ago
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
3 years ago
return texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
2 months ago
#endif`,pw=`#ifdef USE_SHADOWMAP
3 years ago
#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
2 months ago
#endif`,fw=`#ifdef USE_SHADOWMAP
3 years ago
#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
2 months ago
#endif`,mw=`float getShadowMask() {
3 years ago
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;
2 months ago
}`,gw=`#ifdef USE_SKINNING
3 years ago
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
2 months ago
#endif`,yw=`#ifdef USE_SKINNING
3 years ago
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
2 months ago
#endif`,xw=`#ifdef USE_SKINNING
3 years ago
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;
2 months ago
#endif`,vw=`#ifdef USE_SKINNING
3 years ago
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
2 months ago
#endif`,ww=`float specularStrength;
3 years ago
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
2 months ago
#endif`,bw=`#ifdef USE_SPECULARMAP
3 years ago
uniform sampler2D specularMap;
2 months ago
#endif`,_w=`#if defined( TONE_MAPPING )
3 years ago
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
2 months ago
#endif`,Ew=`#ifndef saturate
3 years ago
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return toneMappingExposure * color;
3 years ago
}
3 years ago
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 ),
3 years ago
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 ),
3 years ago
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
3 years ago
}
2 months ago
vec3 CustomToneMapping( vec3 color ) { return color; }`,Aw=`#ifdef USE_TRANSMISSION
3 years ago
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 );
2 months ago
#endif`,Sw=`#ifdef USE_TRANSMISSION
3 years ago
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;
3 years ago
}
}
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 );
}
2 months ago
#endif`,Mw=`#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )
3 years ago
varying vec2 vUv;
2 months ago
#endif`,Dw=`#ifdef USE_UV
3 years ago
#ifdef UVS_VERTEX_ONLY
vec2 vUv;
#else
varying vec2 vUv;
#endif
uniform mat3 uvTransform;
2 months ago
#endif`,Tw=`#ifdef USE_UV
3 years ago
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
2 months ago
#endif`,Cw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
3 years ago
varying vec2 vUv2;
2 months ago
#endif`,Rw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
3 years ago
attribute vec2 uv2;
varying vec2 vUv2;
uniform mat3 uv2Transform;
2 months ago
#endif`,Fw=`#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )
3 years ago
vUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;
2 months ago
#endif`,Lw=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION )
3 years ago
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
2 months ago
#endif`,Bw=`varying vec2 vUv;
3 years ago
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
2 months ago
}`,Pw=`uniform sampler2D t2D;
3 years ago
varying vec2 vUv;
void main() {
gl_FragColor = texture2D( t2D, vUv );
#include <tonemapping_fragment>
#include <encodings_fragment>
2 months ago
}`,Iw=`varying vec3 vWorldDirection;
3 years ago
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
2 months ago
}`,Nw=`#include <envmap_common_pars_fragment>
3 years ago
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>
2 months ago
}`,kw=`#include <common>
3 years ago
#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;
2 months ago
}`,Ow=`#if DEPTH_PACKING == 3200
3 years ago
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
2 months ago
}`,zw=`#define DISTANCE
3 years ago
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;
2 months ago
}`,Vw=`#define DISTANCE
3 years ago
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 );
3 years ago
gl_FragColor = packDepthToRGBA( dist );
2 months ago
}`,Uw=`varying vec3 vWorldDirection;
3 years ago
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
2 months ago
}`,Hw=`uniform sampler2D tEquirect;
3 years ago
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>
2 months ago
}`,Gw=`uniform float scale;
3 years ago
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>
2 months ago
}`,qw=`uniform vec3 diffuse;
3 years ago
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;
3 years ago
#include <output_fragment>
#include <tonemapping_fragment>
#include <encodings_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
2 months ago
}`,Ww=`#include <common>
3 years ago
#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>
2 months ago
}`,$w=`uniform vec3 diffuse;
3 years ago
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>
2 months ago
}`,jw=`#define LAMBERT
3 years ago
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>
2 months ago
}`,Xw=`uniform vec3 diffuse;
3 years ago
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>
2 months ago
}`,Yw=`#define MATCAP
3 years ago
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;
2 months ago
}`,Zw=`#define MATCAP
3 years ago
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;
3 years ago
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
3 years ago
#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>
2 months ago
}`,Jw=`#define NORMAL
3 years ago
#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
2 months ago
}`,Kw=`#define NORMAL
3 years ago
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 );
7 months ago
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
2 months ago
}`,Qw=`#define PHONG
3 years ago
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>
2 months ago
}`,eb=`#define PHONG
3 years ago
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>
2 months ago
}`,tb=`#define STANDARD
3 years ago
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
2 months ago
}`,ib=`#define STANDARD
3 years ago
#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>
2 months ago
}`,nb=`#define TOON
3 years ago
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>
2 months ago
}`,sb=`#define TOON
3 years ago
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>
2 months ago
}`,rb=`uniform float size;
3 years ago
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>
2 months ago
}`,ob=`uniform vec3 diffuse;
3 years ago
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>
2 months ago
}`,ab=`#include <common>
3 years ago
#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>
2 months ago
}`,lb=`uniform vec3 color;
3 years ago
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>
2 months ago
}`,cb=`uniform float rotation;
3 years ago
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>
2 months ago
}`,ub=`uniform vec3 diffuse;
3 years ago
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:zv,alphamap_pars_fragment:Vv,alphatest_fragment:Uv,alphatest_pars_fragment:Hv,aomap_fragment:Gv,aomap_pars_fragment:qv,begin_vertex:Wv,beginnormal_vertex:$v,bsdfs:jv,bumpmap_pars_fragment:Xv,clipping_planes_fragment:Yv,clipping_planes_pars_fragment:Zv,clipping_planes_pars_vertex:Jv,clipping_planes_vertex:Kv,color_fragment:Qv,color_pars_fragment:e2,color_pars_vertex:t2,color_vertex:i2,common:n2,cube_uv_reflection_fragment:s2,defaultnormal_vertex:r2,displacementmap_pars_vertex:o2,displacementmap_vertex:a2,emissivemap_fragment:l2,emissivemap_pars_fragment:c2,encodings_fragment:u2,encodings_pars_fragment:h2,envmap_fragment:d2,envmap_common_pars_fragment:p2,envmap_pars_fragment:f2,envmap_pars_vertex:m2,envmap_physical_pars_fragment:M2,envmap_vertex:g2,fog_vertex:y2,fog_pars_vertex:x2,fog_fragment:v2,fog_pars_fragment:w2,gradientmap_pars_fragment:b2,lightmap_fragment:_2,lightmap_pars_fragment:E2,lights_lambert_vertex:A2,lights_pars_begin:S2,lights_toon_fragment:D2,lights_toon_pars_fragment:T2,lights_phong_fragment:C2,lights_phong_pars_fragment:R2,lights_physical_fragment:F2,lights_physical_pars_fragment:L2,lights_fragment_begin:B2,lights_fragment_maps:P2,lights_fragment_end:I2,logdepthbuf_fragment:N2,logdepthbuf_pars_fragment:k2,logdepthbuf_pars_vertex:O2,logdepthbuf_vertex:z2,map_fragment:V2,map_pars_fragment:U2,map_particle_fragment:H2,map_particle_pars_fragment:G2,metalnessmap_fragment:q2,metalnessmap_pars_fragment:W2,morphnormal_vertex:$2,morphtarget_pars_vertex:j2,morphtarget_vertex:X2,normal_fragment_begin:Y2,normal_fragment_maps:Z2,normal_pars_fragment:J2,normal_pars_vertex:K2,normal_vertex:Q2,normalmap_pars_fragment:ew,clearcoat_normal_fragment_begin:tw,clearcoat_normal_fragment_maps:iw,clearcoat_pars_fragment:nw,output_fragment:sw,packing:rw,premultiplied_alpha_fragment:ow,project_vertex:aw,dithering_fragment:lw,dithering_pars_fragment:cw,roughnessmap_fragment:uw,roughnessmap_pars_fragment:hw,shadowmap_pars_fragment:dw,shadowmap_pars_vertex:pw,shadowmap_vertex:fw,shadowmask_pars_fragment:mw,skinbase_vertex:gw,skinning_pars_vertex:yw,skinning_vertex:xw,skinnormal_vertex:vw,specularmap_fragment:ww,specularmap_pars_fragment:bw,tonemapping_fragment:_w,tonemapping_pars_fragment:Ew,transmission_fragment:Aw,transmission_pars_fragment:Sw,uv_pars_fragment:Mw,uv_pars_vertex:Dw,uv_vertex:Tw,uv2_pars_fragment:Cw,uv2_pars_vertex:Rw,uv2_vertex:Fw,worldpos_vertex:Lw,background_vert:Bw,background_frag:Pw,cube_vert:Iw,cube_frag:Nw,depth_vert:kw,depth_frag:Ow,distanceRGBA_vert:zw,distanceRGBA_frag:Vw,equirect_vert:Uw,equirect_frag:Hw,linedashed_vert:Gw,linedashed_frag:qw,meshbasic_vert:Ww,meshbasic_frag:$w,meshlambert_vert:jw,meshlambert_frag:Xw,meshmatcap_vert:Yw,meshmatcap_frag:Zw,meshnormal_vert:Jw,meshnormal_frag:Kw,meshphong_vert:Qw,meshphong_frag:eb,meshphysical_vert:tb,meshphysical_frag:ib,meshtoon_vert:nb,meshtoon_frag:sb,points_vert:rb,points_frag:ob,shadow_vert:ab,shadow_frag:lb,sprite_vert:cb,sprite_frag:ub},re={common:{diffuse:{value:new ye(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new wt},uv2Transform:{value:new wt},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:{}
3 years ago
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 );
}
}
2 months ago
`,blending:mn,depthTest:!1,depthWrite:!1})}function gf(){let r=new ee(1,1);return new zs({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:r}},vertexShader:Nh(),fragmentShader:`
3 years ago
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 );
}
2 months ago
`,blending:mn,depthTest:!1,depthWrite:!1})}function yf(){return new zs({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Nh(),fragmentShader:`
3 years ago
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 ) );
}
2 months ago
`,blending:mn,depthTest:!1,depthWrite:!1})}function Nh(){return`
3 years ago
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 vb(r){let e=new WeakMap,t=null;function i(a){if(a&&a.isTexture){let l=a.mapping,c=l===vu||l===wu,u=l===co||l===uo;if(c||u)if(a.isRenderTargetTexture&&a.needsPMREMUpdate===!0){a.needsPMREMUpdate=!1;let h=e.get(a);return t===null&&(t=new Ia(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 Ia(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 wb(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 bb(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],M=f[E+1],T=f[E+2];d.push(_,M,M,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,M=E+1,T=E+2;d.push(_,M,M,T,T,_)}}let x=new(hm(d)?Ba:La)(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 _b(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 Eb(r){let e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,poi
3 years ago
`);for(let t=0;t<e.length;t++)e[t]=t+1+": "+e[t];return e.join(`
2 months ago
`)}function x1(r){switch(r){case bn:return["Linear","( value )"];case tt:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",r),["Linear","( value )"]}}function Mf(r,e,t){let i=r.getShaderParameter(e,35713),n=r.getShaderInfoLog(e).trim();return i&&n===""?"":t.toUpperCase()+`
`+n+`
2 months ago
`+y1(r.getShaderSource(e))}function v1(r,e){let t=x1(e);return"vec4 "+r+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function w1(r,e){let t;switch(e){case Wx:t="Linear";break;case $x:t="Reinhard";break;case jx:t="OptimizedCineon";break;case Xx:t="ACESFilmic";break;case Yx:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+r+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function b1(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(Cr).join(`
`)}function _1(r){let e=[];for(let t in r){let i=r[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(`
`)}function E1(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 Cr(r){return r!==""}function Df(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 Tf(r,e){return r.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}var A1=/^[ \t]*#include +<([\w\d./]+)>/gm;function Du(r){return r.replace(A1,S1)}function S1(r,e){let t=Ne[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Du(t)}var M1=/#pragma unroll_loop[\s]+?for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,D1=/#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 Cf(r){return r.replace(D1,_m).replace(M1,T1)}function T1(r,e,t,i){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."),_m(r,e,t,i)}function _m(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 Rf(r){let e="precision "+r.precision+` float;
7 months ago
precision `+r.precision+" int;";return r.precision==="highp"?e+=`
#define HIGH_PRECISION`:r.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:r.precision==="lowp"&&(e+=`
2 months ago
#define LOW_PRECISION`),e}function C1(r){let e="SHADOWMAP_TYPE_BASIC";return r.shadowMapType===rm?e="SHADOWMAP_TYPE_PCF":r.shadowMapType===Bh?e="SHADOWMAP_TYPE_PCF_SOFT":r.shadowMapType===Tr&&(e="SHADOWMAP_TYPE_VSM"),e}function R1(r){let e="ENVMAP_TYPE_CUBE";if(r.envMap)switch(r.envMapMode){case co:case uo:e="ENVMAP_TYPE_CUBE";break;case nl:case Ph:e="ENVMAP_TYPE_CUBE_UV";break}return e}function F1(r){let e="ENVMAP_MODE_REFLECTION";if(r.envMap)switch(r.envMapMode){case uo:case Ph:e="ENVMAP_MODE_REFRACTION";break}return e}function L1(r){let e="ENVMAP_BLENDING_NONE";if(r.envMap)switch(r.combine){case il:e="ENVMAP_BLENDING_MULTIPLY";break;case Gx:e="ENVMAP_BLENDING_MIX";break;case qx:e="ENVMAP_BLENDING_ADD";break}return e}function B1(r,e,t,i){let n=r.getContext(),s=t.defines,o=t.vertexShader,a=t.fragmentShader,l=C1(t),c=R1(t),u=F1(t),h=L1(t),d=t.isWebGL2?"":b1(t),p=_1(s),m=n.createProgram(),y,x,g=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(y=[p].filter(Cr).join(`
7 months ago
`),y.length>0&&(y+=`
2 months ago
`),x=[d,p].filter(Cr).join(`
3 years ago
`),x.length>0&&(x+=`
2 months ago
`)):(y=[Rf(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(Cr).join(`
`),x=[d,Rf(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!==gn?"#define TONE_MAPPING":"",t.toneMapping!==gn?Ne.tonemapping_pars_fragment:"",t.toneMapping!==gn?w1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.transparent?"":"#define OPAQUE",Ne.encodings_pars_fragment,v1("linearToOutputTexel",t.outputEncoding),t.depthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(Cr).join(`
`)),o=Du(o),o=Df(o,t),o=Tf(o,t),a=Du(a),a=Df(a,t),a=Tf(a,t),o=Cf(o),a=Cf(a),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(g=`#version 300 es
7 months ago
`,y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join(`
3 years ago
`)+`
2 months ago
`+y,x=["#define varying in",t.glslVersion===Kp?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Kp?"":"#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(`
3 years ago
`)+`
2 months ago
`+x);let f=g+y+o,E=g+x+a,w=Sf(n,35633,f),_=Sf(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 z=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=Mf(n,w,"vertex"),B=Mf(n,_,"fragment");console.error("THREE.WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(m,35715)+`
3 years ago
2 months ago
Program Info Log: `+z+`
7 months ago
`+S+`
2 months ago
`+B)}else z!==""?console.warn("THREE.WebGLProgram: Program Info Log:",z):(W===""||A==="")&&(R=!1);R&&(this.diagnostics={runnable:v,programLog:z,vertexShader:{log:W,prefix:y},fragmentShader:{log:A,prefix:x}})}n.deleteShader(w),n.deleteShader(_);let M;this.getUniforms=function(){return M===void 0&&(M=new vn(n,m)),M};let T;return this.getAttributes=function(){return T===void 0&&(T=E1(n,m)),T},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(m),this.program=void 0},this.name=t.shaderName,this.id=g1++,this.cacheKey=e,this.usedTimes=1,this.program=m,this.vertexShader=w,this.fragmentShader=_,this}var P1=0,Tu=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 Cu;t.set(e,i)}return t.get(e)}},Cu=class{constructor(){this.id=P1++,this.usedTimes=0}};function I1(r,e,t,i,n,s,o){let a=new Fa,l=new Tu,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=Ti[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:bn,map:!!v.map,matcap:!!v.matcap,envMap:!!k,envMapMode:k&&k.mapping,envMapCubeUV:!!k&&(k.mapping===nl||k.mapping===Ph),lightMap:!!v.lightMap,aoMap:!!v.aoMap,emissiveMap:!!v.emissiveMap,bumpMap:!!v.bumpMap,normalMap:!!v.normalMap,objectSpaceNormalMap:v.normalMapType===xv,tangentSpaceNormalMap:v.normalMapType===Xs,decodeVideoTexture:!!v.map&&v.map.isVideoTexture===!0&&v.map.encoding===tt,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
3 years ago
gl_Position = vec4( position, 1.0 );
2 months ago
}`,$1=`uniform sampler2D shadow_pass;
3 years ago
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 Os,n=new ee,s=new ee,o=new $e,a=new ka({depthPacking:yv}),l=new Oa,c={},u=t.maxTextureSize,h={0:xt,1:Pr,2:Bs},d=new Zi({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ee},radius:{value:4}},vertexShader:W1,fragmentShader:$1}),p=d.clone();p.defines.HORIZONTAL_PASS=1;let m=new Ke;m.setAttribute("position",new ht(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));let y=new pt(m,d),x=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=rm,this.render=function(w,_,M){if(x.enabled===!1||x.autoUpdate===!1&&x.needsUpdate===!1||w.length===0)return;let T=r.getRenderTarget(),z=r.getActiveCubeFace(),W=r.getActiveMipmapLevel(),A=r.state;A.setBlending(mn),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===Tr){let N={minFilter:Rt,magFilter:Rt,format:Nt};B.map=new Ht(n.x,n.y,N),B.map.texture.name=S.name+".shadowMap",B.mapPass=new Ht(n.x,n.y,N),B.camera.updateProjectionMatrix()}if(B.map===null){let N={minFilter:vt,magFilter:vt,format:Nt};B.map=new Ht(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(_,M,B.camera,S,this.type)}!B.isPointLightShadow&&this.type===Tr&&g(B,M),B.needsUpdate=!1}x.needsUpdate=!1,r.setRenderTarget(T,z,W)};function g(w,_){let M=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,M,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,M,p,y,null)}function f(w,_,M,T,z,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&&M.clipShadows===!0&&M.clippingPlanes.length!==0||M.displacementMap&&M.displacementScale!==0||M.alphaMap&&M.alphaTest>0){let S=v.uuid,B=M.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=M.visible,v.wireframe=M.wireframe,A===Tr?v.side=M.shadowSide!==null?M.shadowSide:M.side:v.side=M.shadowSide!==null?M.shadowSide:h[M.side],v.alphaMap=M.alphaMap,v.alphaTest=M.alphaTest,v.clipShadows=M.clipShadows,v.clippingPlanes=M.clippingPlanes,v.clipIntersection=M.clipIntersection,v.displacementMap=M.displacementMap,v.displacementScale=M.displacementScale,v.displacementBias=M.displacementBias,v.wireframeLinewidth=M.wireframeLinewidth,v.linewidth=M.linewidth,T.isPointLight===!0&&v.isMeshDistanceMaterial===!0&&(v.referencePosition.setFromMatrixPosition(T.matrixWorld),v.nearDistance=z,v.farDistance=W),v}function E(w,_,M,T,z){if(w.visible===!1)return;if(w.layers.test(_.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&z===Tr)&&(!w.frustumCulled||i.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.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,M.near,M.far,z);r.renderBufferDirect(M,null,v,k,w,C)}}}else if(R.visible){let S=f(w,v,R,T,M.near,M.far,z);r.renderBufferDirect(M,null,v,S,w,null)}}let
2 months ago
`);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 lt(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}}},dl=class extends fi{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]]}},pl=class extends fi{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]]}},fl=class extends fi{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])}},ml=class extends fi{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])}},gl=class extends fi{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}},Ks=class extends fi{constructor(t,i,n={diceColor:"#d68316",textColor:"#FFFFFF"},s){
7 months ago
a`,"a",`a
a`,"x","s",`s
a`,"s",`s
a`,`s
s`,`s
a`,`s
2 months ago
s`,""];this.setColor({diceColor:"#FEF035",textColor:"#000000"})}},_l=class extends wl{constructor(t,i,n=Dn,s){super(t,i,n,s);this.labels=["","",`t
7 months ago
t`,"t",`t
t`,"t",`t
f`,"f",`t
f`,"f",`f
f`,"y",`f
2 months ago
f`,""];this.setColor({diceColor:"#751317",textColor:"#FFFFFF"})}},El=class extends po{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}},Al=class extends El{constructor(t,i,n=Dn,s){super(t,i,n,s);this.labels=["","","s","a",`s
7 months ago
a`,`s
s`,"a","s",`a
2 months ago
a`,""];this.setColor({diceColor:"#46AC4E",textColor:"#000000"})}},Sl=class extends El{constructor(t,i,n=Dn,s){super(t,i,n,s);this.labels=["","","t","f",`f
7 months ago
t`,"t","",`t
t`,`f
2 months ago
f`,"t",""];this.setColor({diceColor:"#52287E",textColor:"#FFFFFF"})}},Ml=class extends po{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]}},Dl=class extends Ml{constructor(t,i,n=Dn,s){super(t,i,n,s);this.labels=["","","","","s",`s
7 months ago
a`,`a
a`,"a","",""];this.setColor({diceColor:"#76CDDB",textColor:"#000000"})}},Tl=class extends Ml{constructor(t,i,n=Dn,s){super(t,i,n,s);this.labels=["","","","t","f","",""];this.setColor({diceColor:"#000000",textColor:"#FFFFFF"})}};var Cl=class{constructor(){this.resources=new Map}isTracking(e){return this.resources.has(e)}#e(e,t){if(Array.isArray(e))e.forEach(i=>{(this.resources.get(t)??[]).push(i),this.#e(i,t)});else{let i=this.resources.get(t??e)??[];this.resources.set(t??e,i)}}track(e){if("dispose"in e&&this.#e(e),e instanceof Ge&&this.#e(e),"geometry"in e&&this.#e(e.geometry,e),"material"in e&&this.#e(e.material,e),"children"in e&&this.#e(e.children,e),e instanceof ft)for(let t of Object.values(e))t instanceof lt&&this.#e(t);return e}untrack(e){this.resources.delete(e)}dispose(){for(let[e]of this.resources)this.disposeResource(e);this.resources.clear()}disposeResource(e){"parent"in e&&e.parent&&e.parent.remove(e),"dispose"in e&&e.dispose();for(let t of this.resources.get(e)??[])this.disposeResource(t);this.resources.delete(e)}};var Mt={D4:"4",D6:"6",D8:"8",D10:"10",D12:"12",D20:"20",D100:"100",FUDGE:"fudge",STUNT:"stunt",NONE:"none"};var Vh=class r extends Xn.Component{constructor(){super();this.event=new Xn.Events;this.tracker=new Cl;this.container=createDiv("renderer-container");this.#e=new Set;this.shadows=!0;this.iterations=0;this.frame_rate=1/60;this.loaded=!1;this.#t=!1;this.#i=new WeakMap;this.colors={ambient:16777215,spotlight:16777215};this.display={currentWidth:null,currentHeight:null,containerWidth:null,containerHeight:null,aspect:null,scale:null};this.cameraHeight={max:null,close:null,medium:null,far:null};this.#n=new WeakMap;this.extraFrames=r.DEFAULT_EXTRA_FRAMES;this.renderer=new qe({alpha:!0,antialias:!0})}#e;get WIDTH(){return this.container.clientWidth/2}get HEIGHT(){return this.container.clientHeight/2}get ASPECT(){return this.WIDTH/this.HEIGHT}get scale(){return(this.WIDTH*this.WIDTH+this.HEIGHT*this.HEIGHT)/13}get canvasEl(){return this.renderer?this.renderer.domElement:null}#t;setData(t){this.data=t,this.factory?(this.factory.width=this.WIDTH,this.factory.height=this.HEIGHT,this.factory.updateDice(this.data)):this.factory=new Hh(this.WIDTH,this.HEIGHT,{diceColor:this.data.diceColor,textColor:this.data.textColor,colorfulDice:this.data.colorfulDice,scaler:this.data.scaler,textFont:this.data.textFont})}getDiceForRoller(t){return this.factory.getDiceForRoller(t,this.getVector())}#i;async addDice(t){return new Promise(i=>{this.#t||this.start();for(let n of t)n.recreate(this.getVector(),this.WIDTH,this.HEIGHT),this.scene.add(this.tracker.track(n.geometry)),this.world.add(n);this.#e.add(t),this.#i.set(t,()=>{i()})})}onload(){this.loaded=!0,this.addChild(this.factory),this.container.empty(),this.container.style.opacity="1",this.renderer.shadowMap.enabled=this.shadows,this.renderer.shadowMap.type=Bh,this.container.appendChild(this.renderer.domElement),document.body.appendChild(this.container),this.renderer.setClearColor(0,0),this.scene=new Vs,this.initScene(),this.initWorld(),this.registerDomEvent(window,"resize",()=>{this.initScene()})}onunload(){this.stop(),this.loaded=!1,cancelAnimationFrame(this.animation),this.container.detach(),this.container.empty(),this.renderer.domElement.detach(),this.factory.dispose(),this.renderer.renderLists.dispose(),this.renderer.dispose(),this.tracker.dispose(),[...this.#e.values()].flat().forEach(t=>{this.world.world.removeBody(t.body)}),this.#e=new Set}start(){this.#t&&this.unload(),this.loaded||this.load(),this.#t=!0,this.extraFrames=r.DEFAULT_EXTRA_FRAMES,this.render()}static{this.DEFAULT_EXTRA_FRAMES=30}enableShadows(){this.shadows=!0,this.renderer&&(this.renderer.shadowMap.enabled=this.shadows),this.light&&(this.light.castShadow=this.shadows),this.desk&&(this.desk.receiveShadow=this.shadows)}disableShadows(){this.shadows=!1,this.renderer&&(this.renderer.shadowMap.enabled=this.shadows),this.light&&(this.light.castShadow=this.shadows),this.desk&&(this.desk.receiveShadow=this.shadows)}get mw(){return Math.max(this.WIDTH,this.HEIGHT)}setDimensions(t){this.display.curren
2 months ago
`).join(" -> ")} -> `}},mo=class extends Yn{constructor(t,i,n,s,o,a=t.position){super(t,i,[n],a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.app=o;this.dirtyEl=this.containerEl.createDiv({cls:"dice-roller-dirty dice-roller-button",attr:{"aria-label":"The underlying data source for this roller was modified"}});this.#t=!1;this.getPath()}async getFile(){if(this.file=this.app.metadataCache.getFirstLinkpathDest(this.path,this.source),!this.file||!(this.file instanceof ri.TFile))throw new Error("Could not load file.")}#e;async render(){super.render(),this.dirtyEl.empty()}async checkForDirtiness(t){let i=await this.hash(t);return i===this.#e?(this.dirtyEl.empty(),!1):(this.#e&&(0,ri.setIcon)(this.dirtyEl,"alert-triangle"),this.#e=i,!0)}async hash(t){return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(t))),i=>i.toString(16).padStart(2,"0")).join("")}#t;async onload(){if(this.#t)return;this.#t=!0,await this.getFile();let t=this.app.metadataCache.getFileCache(this.file),i=await this.app.vault.cachedRead(this.file);await this.getOptions(t,i),this.loaded=!0,this.trigger("loaded"),this.registerEvent(this.app.metadataCache.on("changed",async(n,s,o)=>{n===this.file&&await this.getOptions(o,s)}))}},er=class extends mo{constructor(t,i,n,s,o,a=t.position,l=!0){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.app=o;this.inline=l;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 ri.Notice("Result copied to clipboard.")})}),(0,ri.setIcon)(this.copy,"copy")}getEmbedClass(){return this.data.displayAsEmbed?"markdown-embed":""}},Fl=class extends Rl{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 go=class extends At{constructor(t,i){super(t,i);this.dice=t;this.stack=[];let n=`${this.faces.max}`.split("");for(let s=0;s<this.rolls;s++){let o=[];for(let a of n){let l=new At(`1d${a}`);o.push(l),l.roll()}this.stack.push(o)}}getType(){return Mt.NONE}canRender(){return!1}get result(){let t=0;for(let i of this.stack){let n=[];for(let s of i)s.rollSync(),n.push(s.result);t+=Number(n.join(""))}return t}get display(){return this.stack.map(t=>t.map(i=>i.result).join(",")).join("|")}async roll(){if(!this.stack||!this.stack.length)return super.roll();this.stack.forEach(t=>t.map(i=>i.roll()))}allowAverage(){return!1}};var Gh=class extends At{getType(){return Mt.STUNT}canRender(){return!0}constructor(){super("1d6")}allowAverage(){return!1}},mi=class extends At{constructor(t,i){super(t,i);this.dice=t;this.pair=new At("2d6");this.stunt=new Gh}async roll(){await Promise.all([new Promise(async t=>{this.pair.shouldRender=this.shouldRender,await this.pair.roll(),t()}),new Promise(async t=>{this.stunt.shouldRender=this.shouldRender,await this.stunt.roll(),t()})])}get doubles(){return new Set([...this.pair.resultArray,this.stunt.result]).size<3}get result(){return this.pair.result+this.stunt.result}get display(){return`${[this.pair.display,`${this.stunt.display}${this.doubles?"S":""}`].join(", ")}`}};var yo=class extends At{constructor(){super(...arguments);this.possibilities=[-1,0,1]}getType(){return Mt.FUDGE}canRender(){return!0}};var hl=class extends fo{constructor(t,i){super();this.original=t;this.lexemes=i;this.operators={"+":(t,i)=>t+i,"-":(t,i)=>t-i,"*":(t,i)=>t*i,"/":(t,i)=>t/i,"^":(t,i)=>Math.pow(t,i)};this.stack=[];this.stackCopy=[];this.stunted="";this.dice=[]}async roll(){return this.rollSync()}rollSync(){this.stunted="",this.parseLexemes();let t=this.stack.pop();return t.rollSync(),t instanceof mi&&t.doubles&&(this.stunted=` - ${t.results.get(0).value} Stunt Points`),this.result=t.result,this.result}parseLexemes(){let t=0;for(let i of this.lexemes)switch(i.type){case"+":case"-":case"*":case"/":case"^":case"math":let n=this.stack.pop(),s=this.stack.pop();n.rollSync(),n instanceof mi&&n.doubles&&(this.stunted=` - ${n.results.get(0).value} Stunt Points`),s.rollSync(),s instanceof mi&&s.doubles&&(this.stunted=` - ${s.results.get(0).value} Stunt Points`);let o=this.operators[i.value](s.result,n.result);this.stackCopy.push(i.value),this.stack.push(new At(`${o}`,i));break;case"u":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("u",{data:l,conditionals:[],value:i.text});break}case"kh":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("kh",{data:l,conditionals:[],value:i.text});break}case"dl":{let a=this.dice[t-1],l=i.value?Number(i.value):1;l=a.rolls-l,a.modifiers.set("kh",{data:l,conditionals:[],value:i.text});break}case"kl":{let a=this.dice[t-1],l=i.value?Number(i.value):1;a.modifiers.set("kl",{data:l,conditionals:[],value:i.text});break}case"dh":{let a=this.dice[t-1],l=i.value?Number(i.value):1;l=a.rolls-l,a.modifiers.set("kl",{data:l,conditionals:[],value:i.text});break}case"!":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("!",{data:l,conditionals:i.conditions??[],value:i.text});break}case"!!":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("!!",{data:l,conditionals:i.conditions??[],value:i.text});break}case"r":{let a=this.dice[t-1],l=Number(i.value)||1;a.modifiers.set("r",{data:l,conditionals:i.conditions??[],value:i.text});break}case"sort":{let a=this.dice[t-1],l=Number(i.value);a.modifiers.set("sort",{data:l,conditionals:i.conditions??[],value:i.value});break}case"dice":{if(i.parenedDice&&/^d/.test(i.value)&&this.stack.length){let a=this.stack.pop();i.value=`${a.result}${i.value}`,this.dic
7 months ago
${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.position!=Ot.NONE?n=[""]:n=["\xA0"],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,Bl.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 At(i.value,i)}this.dice[t]||(this.dice[t]=new At(i.value,i)),t++;break}case"fudge":{this.dice[t]||(this.dice[t]=new yo(i.value,i)),t++;break}case"stunt":{this.dice[t]||(this.dice[t]=new mi(i.value,i)),t++;break}case"%":{this.dice[t]||(this.dice[t]=new go(i.value,i)),t++;break}}}async roll(t){if(this.stunted="",this.stackCopy=[],this.dice.length||this.buildDiceTree(),Pt.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.calcul
11 months ago
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 mi&&s.doubles&&(this.stunted=` - ${s.results.get(0).value} Stunt Points`),o instanceof mi&&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 At(`${a}`,n)),this.minStack.push(l),this.maxStack.push(c);break}case"stunt":case"fudge":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 mi&&i.doubles&&(this.stunted=` - ${i.stunt.result} Stunt Points`),this.result=i.result}};var ce=require("obsidian");var ir=require("obsidian"),U_=createSvg("svg",{attr:{viewBox:"0 0 500 500"}}),H_=createSvg("text",{attr:{class:"font",fill:"currentColor",x:"50%",y:"50%","text-anchor":"middle","dominant-baseline":"central"}}),Pl=(a=>(a.NONE="None",a.TRIANGLE="Triangle",a.SQUARE="Square",a.DIAMOND="Diamond",a.DODECAHEDRON="Dodecahedron",a.ICOSAHEDRON="Icosahedron",a.CIRCLE="Circle",a))(Pl||{}),Fm=[{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:"%"}],qh=class extends ir.Component{#e(){return U_.cloneNode(!0)}#t(){return H_.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,ir.addIcon)(e,n.outerHTML),this.register(()=>(0,ir.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(){return this.#n("circle",{cx:"250",cy:"250",r:"190"})}#n(e,t){return createSvg(e,{cls:"shape",attr:{...t,stroke:"currentColor"}})}onunload(){}},Il=new qh;var G_=Function.prototype.toString,Wh=Object.create,q_=Object.prototype.toString,W_=function(){function r(){this._keys=[],this._values=[]}return r.prototype.has=function(e){return!!~this._keys.indexOf(e)},r.prototype.get=function(e){return this._values[this._keys.indexOf(e)]},r.prototype.set=function(e,t){this._keys.push(e),this._values.push(t)},r}();function
7 months ago
`,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 od;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 Dt.getRoller(l,this.source);if(c==null)continue;c.addContexts(...this.components),await c.roll();let u=await this.getSubResult(c.result),h;if(u.result instanceof Ki.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(`
1 week ago
`);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 Dt.getRoller(this.rollsFormula,this.source);if(s){if(!(s instanceof qt))return this.prettyTooltip="TableRoller only supports dice rolls to select multiple elements.",new Ki.Notice(this.prettyTooltip),"ERROR";let o=s;o.addContexts(...this.components),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 Ki.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.once("loaded",async()=>{this.result=await this.getResult(),this.render(),this.trigger("new-result"),t(this.result)}),this.load())})}async getOptions(t,i){if(this.cache=t,!this.cache||!this.cache.blocks||!(this.block in this.cache.blocks))throw new Error(`Could not read file cache. Does the block reference exist?
11 months ago
2 months ago
${this.path} > ${this.block}`);let n=this.cache.sections?.find(a=>a.position==this.cache.blocks[this.block].position),s=this.cache.blocks[this.block].position,o=i.slice(s.start.offset,s.end.offset);if(await this.checkForDirtiness(o))if(this.content=o,n&&n.type==="list")this.options=this.content.split(`
1 week ago
`);else{let a=iA(this.content);if(/dice:\s*([\s\S]+)\s*?/.test(Array.from(a.columns.keys())[0])||this.lookup){let l=this.lookup??Array.from(a.columns.keys())[0].split(":").pop().replace(/\`/g,""),c=await Dt.getRoller(l.replace(/{ESCAPED_PIPE}/g,"\\|"),this.source);c&&(c.addContexts(...this.components),c instanceof qt&&(this.lookupRoller=c,this.lookupRanges=a.rows.map(u=>{let[h,d]=u.replace(/\\\|/g,"{ESCAPED_PIPE}").split("|").map(y=>y.replace(/{ESCAPED_PIPE}/g,"\\|")).map(y=>y.trim()),[,p,m]=h.match(/(\d+)(?:[^\d]+?(\d+))?/)??[];if(!(!p&&!m))return[[Number(p),m?Number(m):void 0],d]}),this.isLookup=!0))}if(this.header==="xy"&&!a.columns.has("xy")){this.options=[];for(let l of Array.from(a.columns.values()).slice(1))this.options.push(...l)}else if(this.header&&a.columns.has(this.header))this.options=a.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=a.rows}}}},tA=/^\|?([\s\S]+?)\|?$/,dg=/\|/g;function iA(r){let e=r.split(`
2 months ago
`),i=e.map(o=>(o.trim().match(tA)??[,o.trim()])[1])[0].replace("\\|","{ESCAPED_PIPE}").split(dg),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(dg).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 Cn=require("obsidian");function nA(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 sA(r){return`dice-${nA(4)}`}var sr=class extends er{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(Cn.MarkdownRenderer.render(this.app,this.displayFromCache(e),t.createDiv(),this.source,new Cn.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 Cn.Notice("Result copied to clipboard.")})}),(0,Cn.setIcon)(i,"copy")}}}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(`
11 months ago
1 week ago
`)}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])=>pg(n.position,this.result.position));if(!t){let i=`${sA(4)}`,n=`${this.content.slice(0,this.result.position.end.offset+1)}^${i}${this.content.slice(this.result.position.end.offset)}`;return this.app.vault.modify(this.file,n),i}return t[0]}getPath(){let{groups:e}=this.lexeme.value.match(ec)??{},{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(e,t){if(this.cache=e,!this.cache||!this.cache.sections)throw new Error("Could not read file cache.");let i=t;await this.checkForDirtiness(i)&&(this.content=i,this.content=t,this.options=this.cache.sections.filter(({type:n,position:s})=>this.types?n=="heading"&&this.types.includes(n)&&this.levels.length?(this.cache.headings??[]).filter(({level:a})=>this.levels.includes(`${a}`)).some(({position:a})=>pg(a,s)):this.types.includes(n):!["yaml","thematicBreak"].includes(n)),this.types&&this.types.includes("listItem")&&this.options.push(...this.cache.listItems))}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.once("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])}),this.load();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])}})}},pg=(r,e)=>r.start.col==e.start.col&&r.start.line==e.start.line&&r.start.offset==e.start.offset;var Zn=require("obsidian");var ic=class extends Yn{constructor(t,i,n,s,o,a=t.position){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(!oi.canUseDataview)throw new Zn.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(!oi.canUseDataview){new Zn.Notice("Dice Roller: Dataview must be installed and enabled to use query rollers.");return}await oi.dataviewReady();let t=await oi.api.query(this.query);if(!t.successful)throw new Error(`No files found with that query. Is the query correct?
7 months ago
`+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?
1 week ago
`+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 sr(this.data,o,{...this.lexeme,value:o,type:"section"},this.source,this.app,this.position,!1);this.results.push(l),l.addContexts(...this.components),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-1),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),[]);Zn.MarkdownRenderer.render(this.app,n.join(" "),this.resultEl,this.app.workspace.getActiveFile()?.path,new Zn.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)}),this.load())})}get tooltip(){return this.original}},nc=class extends ic{constructor(t,i,n,s,o,a=t.position){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=ug;this.initialize()}get query(){return this.base}},sc=class extends ic{constructor(t,i,n,s,o,a=t.position){super(t,i,n,s,o,a);this.data=t;this.original=i;this.lexeme=n;this.source=s;this.regex=cg;this.initialize()}get query(){return`list from #${this.base}`}};var Rn=require("obsidian");var rc=class extends er{async getReplacer(){return this.result}get tooltip(){return`${this.original}
2 months ago
${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(Rn.MarkdownRenderer.render(this.app,e,t.createDiv(),this.source,new Rn.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 Rn.Notice("Result copied to clipboard.")})}),(0,Rn.setIcon)(i,"copy")}}}transformResultsToString(){return this.results.join(`
`)}getPath(){let{groups:e}=this.lexeme.value.match(ec)??{},{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(e,t){if(await this.checkForDirtiness(t)){if(this.content=t,!this.content)throw new Error("Could not read file cache.");this.options=this.content.trim().split(`
1 week ago
`).map(i=>i.trim()).filter(i=>i&&i.length)}}async roll(){return new Promise((e,t)=>{if(!this.loaded)this.once("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])}),this.load();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 ad=class{constructor(){this.sources=new Map}initialize(e,t){this.data=e,this.app=t}#e(e){return e.some(({type:t})=>t==="table")?"table":e.some(({type:t})=>t==="section")?"section":e.some(({type:t})=>t==="dataview")?"dataview":e.some(({type:t})=>t==="tag")?"tag":e.some(({type:t})=>t==="link")?"link":e.some(({type:t})=>t==="line")?"line":"dice"}getParametersForRoller(e,t){e=e.replace(/\\\|/g,"|");let i=t?.position??Ot.LEFT,n=t?.shouldRender??this.data.renderAllDice,s=t?.showFormula??this.data.displayResultsInline,o=t?.showParens??this.data.displayFormulaAfter,a=t?.expectedValue??this.data.initialDisplay,l=t?.text??"",c=t?.round??this.data.round,u=t?.signed??this.data.signed,h=t?.lookup,d=/\|text\((.*)\)/;if(e.includes("|nodice")&&(i=Ot.NONE),e.includes("|render")&&(n=!0),e.includes("|norender")&&(n=!1),e.includes("|form")&&(s=!0),e.includes("|noform")&&(s=!1),e.includes("|avg")&&(a="Average"),e.includes("|none")&&(a="None"),e.includes("|text(")){let[,p]=e.match(d)??[null,""];l=p}return e.includes("|paren")&&(o=!0),e.includes("|noparen")&&(o=!1),e.includes("|round")&&(c="Normal"),e.includes("|noround")&&(c="None"),e.includes("|ceil")&&(c="Up"),e.includes("|floor")&&(c="Down"),e.includes("|signed")&&(u=!0),e.includes("|lookup=")&&([,h]=e.match(/\|lookup=(.+?)(?:\||$)/)??[]),e=(0,fg.decode)(e.replace(/\|(no)?(dice|render|form|paren|avg|none|round|floor|ceil|signed)/g,"").replace(/\|lookup=.+?(\||$)/,"").replace(d,"")),e in this.data.formulas&&(e=this.data.formulas[e]),{content:e,position:i,showParens:o,showFormula:s,expectedValue:a,shouldRender:n,text:l,round:c,signed:u,lookup:h}}registerSource(e,t){this.sources.set(e,t)}getRoller(e,t="",i=this.getRollerOptions(this.data)){let{content:n,position:s,showParens:o,showFormula:a,expectedValue:l,round:c,shouldRender:u,text:h,signed:d,lookup:p}=this.getParametersForRoller(e,i),m=nr.parse(n);if(m.isErr())return console.error(m.unwrapErr()),null;let y=m.unwrap();switch(this.#e(y)){case"dice":{let g=new qt(this.data,n,y,this.app,s,h,l,o,c,d);return g.showFormula=a,g.shouldRender=u,g.showRenderNotice=this.data.showRenderNotice,g.setSource(t),g}case"table":return new tc(this.data,n,y[0],t,this.app,s,p);case"section":return new sr(this.data,n,y[0],t,this.app,s);case"dataview":{if(!oi.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new nc(this.data,n,y[0],t,this.app,s)}case"tag":{if(!oi.canUseDataview)throw new Error("Tags are only supported with the Dataview plugin installed.");return new sc(this.data,n,y[0],t,this.app,s)}case"line":return new rc(this.data,n,y[0],t,this.app,s)}}getRollerString(e,t){if(!t)return e;let i=this.sources.get(t)??this.getRollerOptions(this.data);if("position"in i&&(e+=i.position!==Ot.NONE?"":"|nodice"),"shouldRender"in i&&(e+=i.shouldRender?"|render":"|norender"),"showFormula"in i&&(e+=i.showFormula?"|form":"|noform"),"expectedValue"in i&&(i.expectedValue=="Average"&&(e+="|avg"),i.expectedValue=="None"&&(e+="|none")),"text"in i&&i.text&&(e+="|text("+i.text+")"),"showParens"in i&&(e+=i.showParens?"|paren":"|noparen"),"round"in i)switch(i.round){case"Down":{e+="|floor";break}case"Up":{e+="|ceil";break}case"Normal":{e+="|round";break}case"None":e+="|noround"}return i.signed&&(e+="|signed"),e}async getArrayRoller(e,t=1){let i=new Fl(this.data,e,t);return await i.roll(),i}async parseDice(e,t=""){let i=await this.getRoller(e,t);return{result:await i?.roll(),roller:i}}getRollerOptions(e){return{position:e.position,shouldRender:e.
2 months ago
`),x=y.slice(a.lineStart,a.lineEnd+1);return this.data.escapeDiceMod?x=x.join(`
`).replace(`\`${u}\``,p.replace(/([\*\[\]])/g,"\\$1")).split(`
`):x=x.join(`
`).replace(`\`${u}\``,p).split(`
`),y.splice(a.lineStart,a.lineEnd-a.lineStart+1,...x),y.join(`
`)});continue}try{let d=Dt.getRoller(h,i.sourcePath);if(d==null)return;if(d.onLoad(async()=>{await d.roll(),c.replaceWith(d.containerEl)}),d.addContexts(i,this.plugin),!o||!(o instanceof ei.TFile))continue;this.trackRoller(o,d);let p=this.app.workspace.getActiveViewOfType(ei.MarkdownView);if(p&&this.fileMap.has(o)&&this.fileMap.get(o).length===1){let m=this,y=qg(p,{onUnloadFile:function(x){return async function(g){return g==o&&(m.fileMap.delete(o),y()),await x.call(this,g)}}});p.register(y),p.register(()=>this.fileMap.delete(o))}}catch(d){console.error(d),new ei.Notice(`There was an error parsing the dice string: ${c.innerText}.
7 months ago
1 week ago
${d}`,5e3);continue}}}processContent(t){let i=this.data.displayFormulaForMod;return t.includes("|noform")&&(i=!1),t.includes("|form")&&(i=!0),i}};var BA=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Sd=r=>{if(typeof r!="string")throw new TypeError("Invalid argument expected string");let e=r.match(BA);if(!e)throw new Error(`Invalid argument not valid semver ('${r}' received)`);return e.shift(),e},Wg=r=>r==="*"||r==="x"||r==="X",$g=r=>{let e=parseInt(r,10);return isNaN(e)?r:e},PA=(r,e)=>typeof r!=typeof e?[String(r),String(e)]:[r,e],IA=(r,e)=>{if(Wg(r)||Wg(e))return 0;let[t,i]=PA($g(r),$g(e));return t>i?1:t<i?-1:0},Md=(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 jg=(r,e)=>{let t=Sd(r),i=Sd(e),n=t.pop(),s=i.pop(),o=Md(t,i);return o!==0?o:n&&s?Md(n.split("."),s.split(".")):n||s?n?-1:1:0};var Ro=(r,e,t)=>{NA(t);let i=jg(r,e);return Yg[t].includes(i)},Yg={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},Xg=Object.keys(Yg),NA=r=>{if(typeof r!="string")throw new TypeError(`Invalid operator type, expected string but got ${typeof r}`);if(Xg.indexOf(r)===-1)throw new Error(`Invalid operator, expected one of ${Xg.join("|")}`)};var pc=class extends is.Plugin{constructor(){super(...arguments);this.api=Dt}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(){await this.loadSettings(),console.log(`DiceRoller v${this.data.version} loaded`),Pt.setData(this.getRendererData()),this.api.initialize(this.data,this.app),window.DiceRoller=this.api,this.register(()=>delete window.DiceRoller),this.addChild(oi.initialize(this.app)),nr.setDefaults(this.data.defaultRoll,this.data.defaultFace),this.addSettingTab(new bo(this.app,this)),this.registerView(Li,t=>new cr(this,t)),this.registerEvent(this.app.workspace.on("dice-roller:render-dice",async t=>{let i=await Dt.getRoller(t,"external");if(i!=null){if(!(i instanceof qt)){new is.Notice("The Dice View only supports dice rolls.");return}if(await i.roll(),!i.dice.length){new is.Notice("Invalid formula.");return}try{await i.roll(!0)}catch(n){new is.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 Co,this.processor.initialize(this),this.registerMarkdownPostProcessor((t,i)=>this.processor.postprocessor(t,i)),this.registerEditorExtension([Gg(this)]),this.app.workspace.onLayoutReady(async()=>{this.addDiceView(!0)}),this.app.workspace.trigger("dice-roller:loaded")}get view(){let t=this.app.workspace.getLeavesOfType(Li),i=t.length?t[0]:null;if(i&&i.view&&i.view instanceof cr)return i.view}async addDiceView(t=!1){t&&!this.data.showLeafOnStartup||this.app.workspace.getLeavesOfType(Li).length||await this.app.workspace.getRightLeaf(!1).setViewState({type:Li})}async loadSettings(){let t=Object.assign({},zl,await this.loadData()),i=!1;typeof t.version!="string"&&delete t.version,Ro("11.2.0",t.version??"0.0.0",">")&&!("position"in t)&&(t.position=t.showDice?Ot.RIGHT:Ot.NONE,delete t.showDice,i=!0),Ro("11.0.0",t.version??"0.0.0",">")&&(delete t.persistResults,delete t.results,i=!0),Ro(t.version??"0.0.0",this.manifest.version,"!=")&&(t.version=this.manifest.version,i=!0),this.data=Ol(t),i&&await this.saveSettings()}async saveSettings(){await this.saveData(this.data)}async getArrayRoller(t,i=1){return new is.Notice("Using the Dice Roller plugin directly will be deprecated in a future version. Please use `window.DiceRoller` instead."),this.api.getArrayRoller(t,i)}onunload(){console.log("DiceRoller unloaded"),this.app.workspace.getLeavesOfType(Li).forEach(t=>t.detach()),"__THREE__"in window&&delete window.__THREE__,this.app.workspace.
7 months ago
/*! Bundled license information:
he/he.js:
(*! https://mths.be/he v1.2.0 by @mathias | MIT license *)
11 months ago
three/build/three.module.js:
(**
* @license
* Copyright 2010-2022 Three.js Authors
* SPDX-License-Identifier: MIT
*)
*/
1 week ago
/* nosourcemap */