2023-05-30 00:33:57 +08:00
import { a as rd , r as sd , ag as Rs , ah as Ih , o as SE , e as ME , f as e1 , H as Dm , ai as P4 , aj as EE , ak as TE , j as R4 , _ as $n , aa as L4 , L as N0 , G as D4 , u as zp } from "./entry.c3abd651.js" ; var I4 = Object . defineProperty , O4 = Object . defineProperties , k4 = Object . getOwnPropertyDescriptors , Jf = Object . getOwnPropertySymbols , AE = Object . prototype . hasOwnProperty , CE = Object . prototype . propertyIsEnumerable , By = ( i , e , t ) => e in i ? I4 ( i , e , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : t } ) : i [ e ] = t , Me = ( i , e ) => { for ( var t in e || ( e = { } ) ) AE . call ( e , t ) && By ( i , t , e [ t ] ) ; if ( Jf ) for ( var t of Jf ( e ) ) CE . call ( e , t ) && By ( i , t , e [ t ] ) ; return i } , bt = ( i , e ) => O4 ( i , k4 ( e ) ) , N4 = ( i , e ) => { var t = { } ; for ( var n in i ) AE . call ( i , n ) && e . indexOf ( n ) < 0 && ( t [ n ] = i [ n ] ) ; if ( i != null && Jf ) for ( var n of Jf ( i ) ) e . indexOf ( n ) < 0 && CE . call ( i , n ) && ( t [ n ] = i [ n ] ) ; return t } , B4 = ( i , e , t ) => ( By ( i , typeof e != "symbol" ? e + "" : e , t ) , t ) , rl = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : { } ; function d9 ( i ) { return i && i . _ _esModule && Object . prototype . hasOwnProperty . call ( i , "default" ) ? i . default : i } var rs = { exports : { } } ; / * *
2023-05-28 15:00:40 +08:00
* @ license
* Lodash < https : //lodash.com/>
* Copyright OpenJS Foundation and other contributors < https : //openjsf.org/>
* Released under MIT license < https : //lodash.com/license>
* Based on Underscore . js 1.8 . 3 < http : //underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas , DocumentCloud and Investigative Reporters & Editors
* /(function(i,e){(function(){var t,n="4.17.21",r=200,s="Unsupported core-js use. Try https:/ / npms . io / search ? q = ponyfill . ",o=" Expected a function ",l=" Invalid ` variable ` option passed into ` _.template ` ",h=" _ _lodash _hash _undefined _ _ ",d=500,f=" _ _lodash _placeholder _ _ ",g=1,y=2,_=4,w=1,S=2,b=1,T=2,E=4,C=8,A=16,D=32,I=64,F=128,P=256,k=512,j=30,G=" ... ",ne=800,ce=16,Z=1,$=2,K=3,pe=1/0,re=9007199254740991,se=17976931348623157e292,ue=0/0,Te=4294967295,fe=Te-1,Ce=Te>>>1,qe=[[" ary ",F],[" bind ",b],[" bindKey ",T],[" curry ",C],[" curryRight ",A],[" flip ",k],[" partial ",D],[" partialRight ",I],[" rearg ",P]],Ke=" [ object Arguments ] ",me=" [ object Array ] ",Ut=" [ object AsyncFunction ] ",nt=" [ object Boolean ] ",it=" [ object Date ] ",Le=" [ object DOMException ] ",vt=" [ object Error ] ",ve=" [ object Function ] ",xe=" [ object GeneratorFunction ] ",Ae=" [ object Map ] ",We=" [ object Number ] ",Be=" [ object Null ] ",rt=" [ object Object ] ",ot=" [ object Promise ] ",st=" [ object Proxy ] ",Ft=" [ object RegExp ] ",yt=" [ object Set ] ",H=" [ object String ] ",B=" [ object Symbol ] ",he=" [ object Undefined ] ",we=" [ object WeakMap ] ",Ne=" [ object WeakSet ] ",Ue=" [ object ArrayBuffer ] ",Xe=" [ object DataView ] ",U=" [ object Float32Array ] ",Ee=" [ object Float64Array ] ",Je=" [ object Int8Array ] ",ke=" [ object Int16Array ] ",X=" [ object Int32Array ] ",Re=" [ object Uint8Array ] ",De=" [ object Uint8ClampedArray ] ",at=" [ object Uint16Array ] ",ze=" [ object Uint32Array ] ",et=/\b__p \+= '';/g,Ie=/\b(__p \+=) '' \+/g,ct=/(__e\(.*?\)|\b__t\)) \+\n'';/g,wt=/&(?:amp|lt|gt|quot|#39);/g,Ct=/[&<>" ']/g,jn=RegExp(wt.source),Yi=RegExp(Ct.source),Us=/<%-([\s\S]+?)%>/g,Fs=/<%([\s\S]+?)%>/g,Vs=/<%=([\s\S]+?)%>/g,Hs=/\.|\[(?:[^[\]]*|(["' ] ) ( ? : ( ? ! \ 1 ) [ ^ \ \ ] | \ \ . ) * ? \ 1 ) \ ] / , Co = /^\w*$/ , gu = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g , Aa = /[\\^$.*+?()[\]{}|]/g , yu = RegExp ( Aa . source ) , V = /^\s+/ , te = /\s/ , de = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/ , oe = /\{\n\/\* \[wrapped with (.+)\] \*/ , ge = /,? & / , ht = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g , gt = /[()=,{}\[\]\/\s]/ , _t = /\\(\\)?/g , St = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g , Dt = /\w*$/ , Nt = /^[-+]0x[0-9a-f]+$/i , Vt = /^0b[01]+$/i , yn = /^\[object .+?Constructor\]$/ , Tr = /^0o[0-7]+$/i , ls = /^(?:0|[1-9]\d*)$/ , cs = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g , ci = /($^)/ , Pt = /['\n\r\u2028\u2029\\]/g , gi = "\\ud800-\\udfff" , Cn = "\\u0300-\\u036f" , Zi = "\\ufe20-\\ufe2f" , or = "\\u20d0-\\u20ff" , zr = Cn + Zi + or , Gs = "\\u2700-\\u27bf" , On = "a-z\\xdf-\\xf6\\xf8-\\xff" , Ws = "\\xac\\xb1\\xd7\\xf7" , Po = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf" , Ii = "\\u2000-\\u206f" , Hv = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000" , kd = "A-Z\\xc0-\\xd6\\xd8-\\xde" , Nd = "\\ufe0e\\ufe0f" , us = Ws + Po + Ii + Hv , Ki = "['’ ]" , Ca = "[" + gi + "]" , Si = "[" + us + "]" , Ar = "[" + zr + "]" , Pl = "\\d+" , Gv = "[" + Gs + "]" , Ro = "[" + On + "]" , _u = "[^" + gi + us + Pl + Gs + On + kd + "]" , xu = "\\ud83c[\\udffb-\\udfff]" , Bd = "(?:" + Ar + "|" + xu + ")" , bu = "[^" + gi + "]" , wu = "(?:\\ud83c[\\udde6-\\uddff]){2}" , Lo = "[\\ud800-\\udbff][\\udc00-\\udfff]" , Do = "[" + kd + "]" , Su = "\\u200d" , Mu = "(?:" + Ro + "|" + _u + ")" , Wv = "(?:" + Do + "|" + _u + ")" , zd = "(?:" + Ki + "(?:d|ll|m|re|s|t|ve))?" , Ud = "(?:" + Ki + "(?:D|LL|M|RE|S|T|VE))?" , Fd = Bd + "?" , Vd = "[" + Nd + "]?" , Eu = "(?:" + Su + "(?:" + [ bu , wu , Lo ] . join ( "|" ) + ")" + Vd + Fd + ")*" , Pa = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])" , jv = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])" , Io = Vd + Fd + Eu , Xv = "(?:" + [ Gv , wu , Lo ] . join ( "|" ) + ")" + Io , Tu = "(?:" + [ bu + Ar + "?" , Ar , wu , Lo , Ca ] . join ( "|" ) + ")" , Hd = RegExp ( Ki , "g" ) , qv = RegExp ( Ar , "g" ) , Au = RegExp ( xu + "(?=" + xu + ")|" + Tu + Io , "g" ) , Yv = RegExp ( [ Do + "?" + Ro + "+" + zd + "(?=" + [ Si , Do , "$" ] . join ( "|" ) + ")" , Wv + "+" + Ud + "(?=" + [ Si , Do + Mu , "$" ] . join ( "|" ) + ")" , Do + "?" + Mu + "+" + zd , Do + "+" + Ud , jv , Pa , Pl , Xv ] . join ( "|" ) , "g" ) , Zv = RegExp ( "[" + Su + gi + zr + Nd + "]" ) , Kv = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/ , Jv = [ "Array" , "Buffer" , "DataView" , "Date" , "Error" , "Float32Array" , "Float64Array" , "Function" , "Int8Array" , "Int16Array" , "Int32Array" , "Map" , "Math" , "Object" , "Promise" , "RegExp" , "Set" , "String" , "Symbol" , "TypeError" , "Uint8Array" , "Uint8ClampedArray" , "Uint16Array" , "Uint32Array" , "WeakMap" , "_" , "clearTimeout" , "isFinite" , "parseInt" , "setTimeout" ] , Qv = - 1 , vn = { } ; vn [ U ] =
/* [wrapped with `+u+`] */
` )}function aP(a){return Et(a)||qa(a)||!!(jl&&a&&a[jl])}function to(a,u){var v=typeof a;return u=u??re,!!u&&(v=="number"||v!="symbol"&&ls.test(a))&&a>-1&&a%1==0&&a<u}function zi(a,u,v){if(!Nn(v))return!1;var M=typeof u;return(M=="number"?tr(v)&&to(u,v.length):M=="string"&&u in v)?Xr(v[u],a):!1}function g0(a,u){if(Et(a))return!1;var v=typeof a;return v=="number"||v=="symbol"||v=="boolean"||a==null||dr(a)?!0:Co.test(a)||!Hs.test(a)||u!=null&&a in ln(u)}function lP(a){var u=typeof a;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?a!=="__proto__":a===null}function y0(a){var u=Ap(a),v=O[u];if(typeof v!="function"||!(u in Mt.prototype))return!1;if(a===v)return!0;var M=f0(v);return!!M&&a===M[0]}function cP(a){return!!Uo&&Uo in a}var uP=Nl?no:k0;function Ku(a){var u=a&&a.constructor,v=typeof u=="function"&&u.prototype||Fr;return a===v}function hw(a){return a===a&&!Nn(a)}function dw(a,u){return function(v){return v==null?!1:v[a]===u&&(u!==t||a in ln(v))}}function hP(a){var u=Ip(a,function(M){return v.size===d&&v.clear(),M}),v=u.cache;return u}function dP(a,u){var v=a[1],M=u[1],R=v|M,N=R<(b|T|F),W=M==F&&v==C||M==F&&v==P&&a[7].length<=u[8]||M==(F|P)&&u[7].length<=u[8]&&v==C;if(!(N||W))return a;M&b&&(a[2]=u[2],R|=v&b?0:E);var Y=u[3];if(Y){var Q=a[3];a[3]=Q?Yb(Q,Y,u[4]):Y,a[4]=Q?fs(a[3],f):u[4]}return Y=u[5],Y&&(Q=a[5],a[5]=Q?Zb(Q,Y,u[6]):Y,a[6]=Q?fs(a[5],f):u[6]),Y=u[7],Y&&(a[7]=Y),M&F&&(a[8]=a[8]==null?u[8]:ui(a[8],u[8])),a[9]==null&&(a[9]=u[9]),a[0]=u[0],a[1]=R,a}function pP(a){var u=[];if(a!=null)for(var v in ln(a))u.push(v);return u}function fP(a){return zl.call(a)}function pw(a,u,v){return u=Xn(u===t?a.length-1:u,0),function(){for(var M=arguments,R=-1,N=Xn(M.length-u,0),W=ie(N);++R<N;)W[R]=M[u+R];R=-1;for(var Y=ie(u+1);++R<u;)Y[R]=M[R];return Y[u]=v(W),Mi(a,this,Y)}}function fw(a,u){return u.length<2?a:xs(a,Rr(u,0,-1))}function mP(a,u){for(var v=a.length,M=ui(u.length,v),R=er(a);M--;){var N=u[M];a[M]=to(N,v)?R[N]:t}return a}function _0(a,u){if(!(u==="constructor"&&typeof a[u]=="function")&&u!="__proto__")return a[u]}var mw=gw(zb),Ju=_g||function(a,u){return ni.setTimeout(a,u)},x0=gw(z3);function vw(a,u,v){var M=u+"";return x0(a,oP(M,vP(iP(M),v)))}function gw(a){var u=0,v=0;return function(){var M=Sg(),R=ce-(M-v);if(v=M,R>0){if(++u>=ne)return arguments[0]}else u=0;return a.apply(t,arguments)}}function Pp(a,u){var v=-1,M=a.length,R=M-1;for(u=u===t?M:u;++v<u;){var N=n0(v,R),W=a[N];a[N]=a[v],a[v]=W}return a.length=u,a}var yw=hP(function(a){var u=[];return a.charCodeAt(0)===46&&u.push(""),a.replace(gu,function(v,M,R,N){u.push(R?N.replace(_t," $ 1"):M||v)}),u});function ws(a){if(typeof a=="string"||dr(a))return a;var u=a+"";return u=="0"&&1/a==-pe?"-0":u}function Xa(a){if(a!=null){try{return Bl.call(a)}catch{}try{return a+""}catch{}}return""}function vP(a,u){return Ji(qe,function(v){var M="_."+v[0];u&v[1]&&!ds(a,M)&&a.push(M)}),a.sort()}function _w(a){if(a instanceof Mt)return a.clone();var u=new Bi(a.__wrapped__,a.__chain__);return u.__actions__=er(a.__actions__),u.__index__=a.__index__,u.__values__=a.__values__,u}function gP(a,u,v){(v?zi(a,u,v):u===t)?u=1:u=Xn(Rt(u),0);var M=a==null?0:a.length;if(!M||u<1)return[];for(var R=0,N=0,W=ie(ql(M/u));R<M;)W[N++]=Rr(a,R,R+=u);return W}function yP(a){for(var u=-1,v=a==null?0:a.length,M=0,R=[];++u<v;){var N=a[u];N&&(R[M++]=N)}return R}function _P(){var a=arguments.length;if(!a)return[];for(var u=ie(a-1),v=arguments[0],M=a;M--;)u[M-1]=arguments[M];return Ur(Et(v)?er(v):[v],ii(u,1))}var xP=It(function(a,u){return qn(a)?Ga(a,ii(u,1,qn,!0)):[]}),bP=It(function(a,u){var v=Lr(u);return qn(v)&&(v=t),qn(a)?Ga(a,ii(u,1,qn,!0),ut(v,2)):[]}),wP=It(function(a,u){var v=Lr(u);return qn(v)&&(v=t),qn(a)?Ga(a,ii(u,1,qn,!0),t,v):[]});function SP(a,u,v){var M=a==null?0:a.length;return M?(u=v||u===t?1:Rt(u),Rr(a,u<0?0:u,M)):[]}function MP(a,u,v){var M=a==null?0:a.length;return M?(u=v||u===t?1:Rt(u),u=M-u,Rr(a,0,u<0?0:u)):[]}function EP(a,u){return a&&a.length?bp(a,ut(u,3),!0,!0):[]}function TP(a,u){return a&&a.length?bp(a,ut(u,3),!0):[]}function AP(a,u,v,M){var R=a==null?0:a.length;return R?(v&&typeof
` ;a.replace(Ve,function(pt,Ht,qt,pr,Ui,fr){return qt||(qt=pr),Se+=a.slice(_e,fr).replace(Pt,cg),Ht&&(Y=!0,Se+= ` ' +
_ _e ( ` +Ht+ ` ) +
'`),Ui&&(Q=!0,Se+=`' ;
` +Ui+ ` ;
_ _p += '`),qt&&(Se+=`' +
( ( _ _t = ( ` +qt+ ` ) ) == null ? '' : _ _t ) +
'`),_e=fr+pt.length,pt}),Se+=`' ;
` ;var dt=en.call(u,"variable")&&u.variable;if(!dt)Se= ` with ( obj ) {
` +Se+ `
}
` ;else if(gt.test(dt))throw new ft(l);Se=(Q?Se.replace(et,""):Se).replace(Ie," $ 1").replace(ct," $ 1;"),Se="function("+(dt||"obj")+ ` ) {
` +(dt?"": ` obj || ( obj = { } ) ;
` )+"var __t, __p = ''"+(Y?", __e = _.escape":"")+(Q? ` , _ _j = Array . prototype . join ;
function print ( ) { _ _p += _ _j . call ( arguments , '' ) }
` : ` ;
` )+Se+ ` return _ _p
} ` ;var Lt=Jw(function(){return Wt(N,tt+"return "+Se).apply(t,W)});if(Lt.source=Se,E0(Lt))throw Lt;return Lt}function ND(a){return sn(a).toLowerCase()}function BD(a){return sn(a).toUpperCase()}function zD(a,u,v){if(a=sn(a),a&&(v||u===t))return Ou(a);if(!a||!(u=hr(u)))return a;var M=cr(a),R=cr(u),N=Na(M,R),W=Xs(M,R)+1;return Qo(M,N,W).join("")}function UD(a,u,v){if(a=sn(a),a&&(v||u===t))return a.slice(0,Kd(a)+1);if(!a||!(u=hr(u)))return a;var M=cr(a),R=Xs(M,cr(u))+1;return Qo(M,0,R).join("")}function FD(a,u,v){if(a=sn(a),a&&(v||u===t))return a.replace(V,"");if(!a||!(u=hr(u)))return a;var M=cr(a),R=Na(M,cr(u));return Qo(M,R).join("")}function VD(a,u){var v=j,M=G;if(Nn(u)){var R="separator"in u?u.separator:R;v="length"in u?Rt(u.length):v,M="omission"in u?hr(u.omission):M}a=sn(a);var N=a.length;if(Bo(a)){var W=cr(a);N=W.length}if(v>=N)return a;var Y=v-Ys(M);if(Y<1)return M;var Q=W?Qo(W,0,Y).join(""):a.slice(0,Y);if(R===t)return Q+M;if(W&&(Y+=Q.length-Y),T0(R)){if(a.slice(Y).search(R)){var _e,be=Q;for(R.global||(R=Nu(R.source,sn(Dt.exec(R))+"g")),R.lastIndex=0;_e=R.exec(be);)var Se=_e.index;Q=Q.slice(0,Se===t?Y:Se)}}else if(a.indexOf(hr(R),Y)!=Y){var Ve=Q.lastIndexOf(R);Ve>-1&&(Q=Q.slice(0,Ve))}return Q+M}function HD(a){return a=sn(a),a&&jn.test(a)?a.replace(wt,fg):a}var GD=nc(function(a,u,v){return a+(v?" ":"")+u.toUpperCase()}),P0=Qb("toUpperCase");function Kw(a,u,v){return a=sn(a),u=v?t:u,u===t?qs(a)?ms(a):Lu(a):a.match(u)||[]}var Jw=It(function(a,u){try{return Mi(a,t,u)}catch(v){return E0(v)?v:new ft(v)}}),WD=eo(function(a,u){return Ji(u,function(v){v=ws(v),Gr(a,v,S0(a[v],a))}),a});function jD(a){var u=a==null?0:a.length,v=ut();return a=u?_n(a,function(M){if(typeof M[1]!="function")throw new Ei(o);return[v(M[0]),M[1]]}):[],It(function(M){for(var R=-1;++R<u;){var N=a[R];if(Mi(N[0],this,M))return Mi(N[1],this,M)}})}function XD(a){return qg( $ i(a,g))}function R0(a){return function(){return a}}function qD(a,u){return a==null||a!==a?u:a}var YD=ew(),ZD=ew(!0);function ir(a){return a}function L0(a){return mt(typeof a=="function"?a: $ i(a,g))}function KD(a){return Zo( $ i(a,g))}function JD(a,u){return Qs(a, $ i(u,g))}var QD=It(function(a,u){return function(v){return qo(v,a,u)}}), $ D=It(function(a,u){return function(v){return qo(a,v,u)}});function D0(a,u,v){var M=hi(u),R=Wa(u,M);v==null&&!(Nn(u)&&(R.length||!M.length))&&(v=u,u=a,a=this,R=Wa(u,hi(u)));var N=!(Nn(v)&&"chain"in v)||!!v.chain,W=no(a);return Ji(R,function(Y){var Q=u[Y];a[Y]=Q,W&&(a.prototype[Y]=function(){var _e=this.__chain__;if(N||_e){var be=a(this.__wrapped__),Se=be.__actions__=er(this.__actions__);return Se.push({func:Q,args:arguments,thisArg:a}),be.__chain__=_e,be}return Q.apply(a,Ur([this.value()],arguments))})}),a}function e4(){return ni._===this&&(ni._=Fo),this}function I0(){}function t4(a){return a=Rt(a),It(function(u){return Ob(u,a)})}var n4=u0(_n),i4=u0(Oo),r4=u0(hn);function Qw(a){return g0(a)?Da(ws(a)):O3(a)}function s4(a){return function(u){return a==null?t:xs(a,u)}}var o4=nw(),a4=nw(!0);function O0(){return[]}function k0(){return!1}function l4(){return{}}function c4(){return""}function u4(){return!0}function h4(a,u){if(a=Rt(a),a<1||a>re)return[];var v=Te,M=ui(a,Te);u=ut(u),a-=Te;for(var R=Il(M,u);++v<a;)u(v);return R}function d4(a){return Et(a)?_n(a,ws):dr(a)?[a]:er(yw(sn(a)))}function p4(a){var u=++ $ d;return sn(a)+u}var f4=Mp(function(a,u){return a+u},0),m4=h0("ceil"),v4=Mp(function(a,u){return a/u},1),g4=h0("floor");function y4(a){return a&&a.length? $ l(a,ir,Xu):t}function _4(a,u){return a&&a.length? $ l(a,ut(u,2),Xu):t}function x4(a){return Yd(a,ir)}function b4(a,u){return Yd(a,ut(u,2))}function w4(a){return a&&a.length? $ l(a,ir,jr):t}function S4(a,u){return a&&a.length? $ l(a,ut(u,2),jr):t}var M4=Mp(function(a,u){return a*u},1),E4=h0("round"),T4=Mp(function(a,u){return a-u},0);function A4(a){return a&&a.length?ko(a,ir):0}function C4(a,u){return a&&a.length?ko(a,ut(u,2)):0}return O.after=KR,O.ary=Pw,O.assign=BL,O.assignIn=Gw,O.assignInWith=Bp,O.assignWith=zL,O.at=UL,O.before=Rw,O.bind=S0,O.bindAll=WD,O.bindKey=Lw,O.castArray=lL,O.chain=Tw,O.chunk=gP,O.compact=yP,O.
* @ license
* Copyright 2010 - 2022 Three . js Authors
* SPDX - License - Identifier : MIT
* / c o n s t e x = " 1 4 0 " , o c = { L E F T : 0 , M I D D L E : 1 , R I G H T : 2 , R O T A T E : 0 , D O L L Y : 1 , P A N : 2 } , a c = { R O T A T E : 0 , P A N : 1 , D O L L Y _ P A N : 2 , D O L L Y _ R O T A T E : 3 } , X 4 = 0 , i 1 = 1 , q 4 = 2 , I E = 1 , Y 4 = 2 , d h = 3 , O h = 0 , x r = 1 , _ a = 2 , O E = 1 , r n = 0 , y o = 1 , Q f = 2 , r 1 = 3 , s 1 = 4 , F y = 5 , E s = 1 0 0 , Z 4 = 1 0 1 , K 4 = 1 0 2 , o 1 = 1 0 3 , a 1 = 1 0 4 , V y = 2 0 0 , J 4 = 2 0 1 , Q 4 = 2 0 2 , $ 4 = 2 0 3 , $ f = 2 0 4 , e m = 2 0 5 , k E = 2 0 6 , e I = 2 0 7 , N E = 2 0 8 , t I = 2 0 9 , n I = 2 1 0 , i I = 0 , r I = 1 , s I = 2 , H y = 3 , o I = 4 , a I = 5 , l I = 6 , c I = 7 , k m = 0 , u I = 1 , h I = 2 , A s = 0 , B E = 1 , d I = 2 , p I = 3 , f I = 4 , m I = 5 , z E = 3 0 0 , V c = 3 0 1 , H c = 3 0 2 , k h = 3 0 3 , G y = 3 0 4 , N m = 3 0 6 , N h = 1 e 3 , y r = 1 0 0 1 , W y = 1 0 0 2 , X t = 1 0 0 3 , l 1 = 1 0 0 4 , c 1 = 1 0 0 5 , H n = 1 0 0 6 , v I = 1 0 0 7 , o d = 1 0 0 8 , d l = 1 0 0 9 , g I = 1 0 1 0 , y I = 1 0 1 1 , p l = 1 0 1 2 , _ I = 1 0 1 3 , F f = 1 0 1 4 , i s = 1 0 1 5 , T s = 1 0 1 6 , x I = 1 0 1 7 , b I = 1 0 1 8 , z c = 1 0 2 0 , w I = 1 0 2 1 , S I = 1 0 2 2 , O r = 1 0 2 3 , M I = 1 0 2 4 , E I = 1 0 2 5 , c l = 1 0 2 6 , G c = 1 0 2 7 , T I = 1 0 2 8 , A I = 1 0 2 9 , C I = 1 0 3 0 , P I = 1 0 3 1 , R I = 1 0 3 3 , B 0 = 3 3 7 7 6 , z 0 = 3 3 7 7 7 , U 0 = 3 3 7 7 8 , F 0 = 3 3 7 7 9 , u 1 = 3 5 8 4 0 , h 1 = 3 5 8 4 1 , d 1 = 3 5 8 4 2 , p 1 = 3 5 8 4 3 , L I = 3 6 1 9 6 , f 1 = 3 7 4 9 2 , m 1 = 3 7 4 9 6 , v 1 = 3 7 8 0 8 , g 1 = 3 7 8 0 9 , y 1 = 3 7 8 1 0 , _ 1 = 3 7 8 1 1 , x 1 = 3 7 8 1 2 , b 1 = 3 7 8 1 3 , w 1 = 3 7 8 1 4 , S 1 = 3 7 8 1 5 , M 1 = 3 7 8 1 6 , E 1 = 3 7 8 1 7 , T 1 = 3 7 8 1 8 , A 1 = 3 7 8 1 9 , C 1 = 3 7 8 2 0 , P 1 = 3 7 8 2 1 , R 1 = 3 6 4 9 2 , j y = 2 2 0 0 , X y = 2 2 0 1 , D I = 2 2 0 2 , t m = 2 3 0 0 , n m = 2 3 0 1 , V 0 = 2 3 0 2 , I c = 2 4 0 0 , O c = 2 4 0 1 , i m = 2 4 0 2 , t x = 2 5 0 0 , U E = 2 5 0 1 , I I = 0 , p 9 = 1 , f 9 = 2 , D s = 3 e 3 , L n = 3 0 0 1 , O I = 3 2 0 0 , B m = 3 2 0 1 , _ l = 0 , F E = 1 , f o = " s r g b " , a l = " s r g b - l i n e a r " , H 0 = 7 6 8 0 , k I = 5 1 9 , B h = 3 5 0 4 4 , r m = 3 5 0 4 8 , L 1 = " 3 0 0 e s " , q y = 1 0 3 5 ; c l a s s E a { a d d E v e n t L i s t e n e r ( e , t ) { t h i s . _ l i s t e n e r s = = = v o i d 0 & & ( t h i s . _ l i s t e n e r s = { } ) ; c o n s t n = t h i s . _ l i s t e n e r s ; n [ e ] = = = v o i d 0 & & ( n [ e ] = [ ] ) , n [ e ] . i n d e x O f ( t ) = = = - 1 & & n [ e ] . p u s h ( t ) } h a s E v e n t L i s t e n e r ( e , t ) { i f ( t h i s . _ l i s t e n e r s = = = v o i d 0 ) r e t u r n ! 1 ; c o n s t n = t h i s . _ l i s t e n e r s ; r e t u r n n [ e ] ! = = v o i d 0 & & n [ e ] . i n d e x O f ( t ) ! = = - 1 } r e m o v e E v e n t L i s t e n e r ( e , t ) { i f ( t h i s . _ l i s t e n e r s = = = v o i d 0 ) r e t u r n ; c o n s t r = t h i s . _ l i s t e n e r s [ e ] ; i f ( r ! = = v o i d 0 ) { c o n s t s = r . i n d e x O f ( t ) ; s ! = = - 1 & & r . s p l i c e ( s , 1 ) } } d i s p a t c h E v e n t ( e ) { i f ( t h i s . _ l i s t e n e r s = = = v o i d 0 ) r e t u r n ; c o n s t n = t h i s . _ l i s t e n e r s [ e . t y p e ] ; i f ( n ! = = v o i d 0 ) { e . t a r g e t = t h i s ; c o n s t r = n . s l i c e ( 0 ) ; f o r ( l e t s = 0 , o = r . l e n g t h ; s < o ; s + + ) r [ s ] . c a l l ( t h i s , e ) ; e . t a r g e t = n u l l } } } c o n s t b i = [ ] ; f o r ( l e t i = 0 ; i < 2 5 6 ; i + + ) b i [ i ] = ( i < 1 6 ? " 0 " : " " ) + i . t o S t r i n g ( 1 6 ) ; l e t D 1 = 1 2 3 4 5 6 7 ; c o n s t y h = M a t h . P I / 1 8 0 , z h = 1 8 0 / M a t h . P I ; f u n c t i o n k r ( ) { c o n s t i = M a t h . r a n d o m ( ) * 4 2 9 4 9 6 7 2 9 5 | 0 , e = M a t h . r a n d o m ( ) * 4 2 9 4 9 6 7 2 9 5 | 0 , t = M a t h . r a n d o m ( ) * 4 2 9 4 9 6 7 2 9 5 | 0 , n = M a t h . r a n d o m ( ) * 4 2 9 4 9 6 7 2 9 5 | 0 ; r e t u r n ( b i [ i & 2 5 5 ] + b i [ i > > 8 & 2 5 5 ] + b i [ i > > 1 6 & 2 5 5 ] + b i [ i > > 2 4 & 2 5 5 ] + " - " + b i [ e & 2 5 5 ] + b i [ e > > 8 & 2 5 5 ] + " - " + b i [ e > > 1 6 & 1 5 | 6 4 ] + b i [ e > > 2 4 & 2 5 5 ] + " - " + b i [ t & 6 3 | 1 2 8 ] + b i [ t > > 8 & 2 5 5 ] + " - " + b i [ t > > 1 6 & 2 5 5 ] + b i [ t > > 2 4 & 2 5 5 ] + b i [ n & 2 5 5 ] + b i [ n > > 8 & 2 5 5 ] + b i [ n > > 1 6 & 2 5 5 ] + b i [ n > > 2 4 & 2 5 5 ] ) . t o L o w e r C a s e ( ) } f u n c t i o n J n ( i , e , t ) { r e t u r n M a t h . m a x ( e , M a t h . m i n ( t , i ) ) } f u n c t i o n n x ( i , e ) { r e t u r n ( i % e + e ) % e } f u n c t i o n N I ( i , e , t , n , r ) { r e t u r n n + ( i - e ) * ( r - n ) / ( t - e ) } f u n c t i o n B I ( i , e , t ) { r e t u r n i ! = = e ? ( t - i ) / ( e - i ) : 0 } f u n c t i o n _ h ( i , e , t ) { r e t u r n ( 1 - t ) * i + t * e } f u n c t i o n z I ( i , e , t , n ) { r e t u r n _ h ( i , e , 1 - M a t h . e x p ( - t * n ) ) } f u n c t i o n U I ( i , e = 1 ) { r e t u r n e - M a t h . a b s ( n x ( i , e * 2 ) - e ) } f u n c t i o n F I ( i , e , t ) { r e t u r n i < = e ? 0 : i > = t ? 1 : ( i = ( i - e ) / ( t - e ) , i * i * ( 3 - 2 * i ) ) } f u n c t i o n V I ( i , e , t ) { r e t u r n i < = e ? 0 : i > = t ? 1 : ( i = ( i - e ) / ( t - e ) , i * i * i * ( i * ( i * 6 - 1 5 ) + 1 0 ) ) } f u n c t i o n H I ( i , e ) { r e t u r n i + M a t h . f l o o r ( M a t h . r a n d o m ( ) * ( e - i + 1 ) ) } f u n c t i o n G I ( i , e ) { r e t u r n i + M a t h . r a n d o m ( ) * ( e - i ) } f u n c t i o n W I ( i ) { r e t u r n i * ( . 5 - M a t h . r a n d o m ( ) ) } f u n c t i o n j I ( i ) { i ! = = v o i d 0 & & ( D 1 = i ) ; l e t e = D 1 + = 1 8 3 1 5 6 5 8 1 3 ; r e t u r n e = M a t h . i m u l ( e ^ e > > > 1 5 , e | 1 ) , e ^ = e + M a t h . i m u l ( e ^ e > > > 7 , e | 6 1 ) , ( ( e ^ e > > > 1 4 ) > > > 0 ) / 4 2 9 4 9 6 7 2 9 6 } f u n c t i o n X I ( i ) { r e t u r n i * y h } f u n c t i o n q I ( i ) { r e t u r n i * z h } f u n c t i o n Y y ( i ) { r e t u r n ( i & i - 1 ) = = = 0 & & i ! = = 0 } f u n c t i o n V E ( i ) { r e t u r n M a t h . p o w ( 2 , M a t h . c e i l ( M a t h . l o g ( i ) / M a t h . L N 2 ) ) } f u n c t i o n s m ( i ) { r e t u r n M a t h . p o w ( 2 , M a t h . f l o o r ( M a t h . l o g ( i ) / M a t h . L N 2 ) ) } f u n c t i o n Y I ( i , e , t , n , r ) { c o n s t s = M a t h . c o s , o = M a t h . s i n , l = s ( t / 2 ) , h = o ( t / 2 ) , d = s ( ( e + n ) / 2 ) , f = o ( ( e + n ) / 2 ) , g = s ( ( e - n ) / 2 ) , y = o ( ( e - n ) / 2 ) , _ = s ( ( n - e ) / 2 ) , w = o ( ( n - e ) / 2 ) ; s w i t c h ( r ) { c a s e " X Y X " : i . s e t ( l * f , h * g , h * y , l * d ) ; b r e a k ; c a s e " Y Z Y " : i . s e t ( h * y , l * f , h * g , l * d ) ; b r e a k ; c a s e " Z X Z " : i . s e t ( h * g , h * y , l * f , l * d ) ; b r e a k ; c a s e " X Z X " : i . s e t ( l * f , h * w , h * _ , l * d ) ; b r e a k ; c a s e " Y X Y " : i . s e t ( h * _ , l * f , h * w , l * d ) ; b r e a k ; c a s e " Z Y Z " : i . s e t ( h * w , h * _ , l * f , l * d ) ; b r e a k ; d e f a u l t : c o n s o l e . w a r n ( " T H R E E . M a t h U t i l s : . s e t Q u a t e r n i o n F r o m P r o p e r E u l e r ( ) e n c o u n t e r e d a n u n k n o w n o r d e r : " + r ) } } f u n c t i o n Z I ( i , e ) { s w i t c h ( e . c o n s t r u c t o r ) { c a s e F l o a t 3 2 A r r a y : r e t u r n i ; c a s e U i n t 1 6 A r r a y : r e t u r n i / 6 5 5 3 5 ; c a s e U i n t 8 A r r a y : r e t u r n i / 2 5 5 ; c a s e I n t 1 6 A r r a y : r e t u r n M a t h . m a x ( i / 3 2 7 6 7 , - 1 ) ; c a s e I n t 8 A r r a y : r e t u r n M a t h . m a x ( i / 1 2 7 , - 1 ) ; d e f a u l t : t h r o w n e w E r r o r ( " I n v a l i d c o m p o n e n t t y p e . " ) } } f u n c t i o n K I ( i , e ) { s w i t c h ( e . c o n s t r u c t o r ) { c a s e F l o a t 3 2 A r r a y : r e t u r
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,pO= ` void main ( ) {
gl _FragColor = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) ;
} ` ;class kt extends li{constructor(e){super(),this.type="ShaderMaterial",this.defines={},this.uniforms={},this.vertexShader=dO,this.fragmentShader=pO,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=Wc(e.uniforms),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const o=this.uniforms[r].value;o&&o.isTexture?t.uniforms[r]={type:"t",value:o.toJSON(e).uuid}:o&&o.isColor?t.uniforms[r]={type:"c",value:o.getHex()}:o&&o.isVector2?t.uniforms[r]={type:"v2",value:o.toArray()}:o&&o.isVector3?t.uniforms[r]={type:"v3",value:o.toArray()}:o&&o.isVector4?t.uniforms[r]={type:"v4",value:o.toArray()}:o&&o.isMatrix3?t.uniforms[r]={type:"m3",value:o.toArray()}:o&&o.isMatrix4?t.uniforms[r]={type:"m4",value:o.toArray()}:t.uniforms[r]={value:o}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}kt.prototype.isShaderMaterial=!0;class Um extends $ t{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new Qe,this.projectionMatrix=new Qe,this.projectionMatrixInverse=new Qe}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);const 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)}}Um.prototype.isCamera=!0;class fi extends Um{constructor(e=50,t=1,n=.1,r=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,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){const t=.5*this.getFilmHeight()/e;this.fov=zh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(yh*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return zh*2*Math.atan(Math.tan(yh*.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,n,r,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=n,this.view.offsetY=r,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(yh*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,s=-.5*r;const o=this.v
varying vec3 vWorldDirection ;
vec3 transformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir , 0.0 ) ) . xyz ) ;
}
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
}
` ,fragmentShader: `
uniform sampler2D tEquirect ;
varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vec3 direction = normalize ( vWorldDirection ) ;
vec2 sampleUV = equirectUv ( direction ) ;
gl _FragColor = texture2D ( tEquirect , sampleUV ) ;
}
` },r=new bl(5,5,5),s=new kt({name:"CubemapFromEquirect",uniforms:Wc(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:xr,blending:rn});s.uniforms.tEquirect.value=t;const o=new In(r,s),l=t.minFilter;return t.minFilter===od&&(t.minFilter=Hn),new ox(1,10,this).update(e,o),t.minFilter=l,o.geometry.dispose(),o.material.dispose(),this}clear(e,t,n,r){const s=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,r);e.setRenderTarget(s)}}XE.prototype.isWebGLCubeRenderTarget=!0;const uy=new z,fO=new z,mO=new Gn;class mo{constructor(e=new z(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,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=uy.subVectors(n,t).cross(fO.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const 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){const n=e.delta(uy),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const s=-(e.start.dot(this.normal)+this.constant)/r;return s<0||s>1?null:t.copy(n).multiplyScalar(s).add(e.start)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<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){const n=t||mO.getNormalMatrix(e),r=this.coplanarPoint(uy).applyMatrix4(e),s=this.normal.applyMatrix3(n).normalize();return this.constant=-r.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)}}mo.prototype.isPlane=!0;const xc=new su,rf=new z;class ad{constructor(e=new mo,t=new mo,n=new mo,r=new mo,s=new mo,o=new mo){this.planes=[e,t,n,r,s,o]}set(e,t,n,r,s,o){const l=this.planes;return l[0].copy(e),l[1].copy(t),l[2].copy(n),l[3].copy(r),l[4].copy(s),l[5].copy(o),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e){const t=this.planes,n=e.elements,r=n[0],s=n[1],o=n[2],l=n[3],h=n[4],d=n[5],f=n[6],g=n[7],y=n[8],_=n[9],w=n[10],S=n[11],b=n[12],T=n[13],E=n[14],C=n[15];return t[0].setComponents(l-r,g-h,S-y,C-b).normalize(),t[1].setComponents(l+r,g+h,S+y,C+b).normalize(),t[2].setComponents(l+s,g+d,S+_,C+T).normalize(),t[3].setComponents(l-s,g-d,S-_,C-T).normalize(),t[4].setComponents(l-o,g-f,S-w,C-E).normalize(),t[5].setComponents(l+o,g+f,S+w,C+E).normalize(),this}intersectsObject(e){const t=e.geometry;return t.boundingSphere===null&&t.computeBoundingSphere(),xc.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(xc)}intersectsSprite(e){return xc.center.set(0,0,0),xc.radius=.7071067811865476,xc.applyMatrix4(e.matrixWorld),this.intersectsSphere(xc)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let s=0;s<6;s++)if(t[s].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(rf.x=r.normal.x>0?e.max.x:e.min.x,rf.y=r.normal.y>0?e.max.y:e.min.y,rf.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(rf)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}function qE(){let i=null,e=!1,t=null,n=null;function r(s,o){t(s,o),n=i.requestAnimationFrame(r)}r
diffuseColor . a *= texture2D ( alphaMap , vUv ) . g ;
# endif ` ,yO= ` # ifdef USE _ALPHAMAP
uniform sampler2D alphaMap ;
# endif ` ,_O= ` # ifdef USE _ALPHATEST
if ( diffuseColor . a < alphaTest ) discard ;
# endif ` ,xO= ` # ifdef USE _ALPHATEST
uniform float alphaTest ;
# endif ` ,bO= ` # ifdef USE _AOMAP
float ambientOcclusion = ( texture2D ( aoMap , vUv2 ) . r - 1.0 ) * aoMapIntensity + 1.0 ;
reflectedLight . indirectDiffuse *= ambientOcclusion ;
# if defined ( USE _ENVMAP ) && defined ( STANDARD )
float dotNV = saturate ( dot ( geometry . normal , geometry . viewDir ) ) ;
reflectedLight . indirectSpecular *= computeSpecularOcclusion ( dotNV , ambientOcclusion , material . roughness ) ;
# endif
# endif ` ,wO= ` # ifdef USE _AOMAP
uniform sampler2D aoMap ;
uniform float aoMapIntensity ;
# endif ` ,SO="vec3 transformed = vec3( position );",MO= ` vec3 objectNormal = vec3 ( normal ) ;
# ifdef USE _TANGENT
vec3 objectTangent = vec3 ( tangent . xyz ) ;
# endif ` ,EO= ` vec3 BRDF _Lambert ( const in vec3 diffuseColor ) {
return RECIPROCAL _PI * diffuseColor ;
}
vec3 F _Schlick ( const in vec3 f0 , const in float f90 , const in float dotVH ) {
float fresnel = exp2 ( ( - 5.55473 * dotVH - 6.98316 ) * dotVH ) ;
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel ) ;
}
float V _GGX _SmithCorrelated ( const in float alpha , const in float dotNL , const in float dotNV ) {
float a2 = pow2 ( alpha ) ;
float gv = dotNL * sqrt ( a2 + ( 1.0 - a2 ) * pow2 ( dotNV ) ) ;
float gl = dotNV * sqrt ( a2 + ( 1.0 - a2 ) * pow2 ( dotNL ) ) ;
return 0.5 / max ( gv + gl , EPSILON ) ;
}
float D _GGX ( const in float alpha , const in float dotNH ) {
float a2 = pow2 ( alpha ) ;
float denom = pow2 ( dotNH ) * ( a2 - 1.0 ) + 1.0 ;
return RECIPROCAL _PI * a2 / pow2 ( denom ) ;
}
vec3 BRDF _GGX ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , const in vec3 f0 , const in float f90 , const in float roughness ) {
float alpha = pow2 ( roughness ) ;
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNL = saturate ( dot ( normal , lightDir ) ) ;
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float dotVH = saturate ( dot ( viewDir , halfDir ) ) ;
vec3 F = F _Schlick ( f0 , f90 , dotVH ) ;
float V = V _GGX _SmithCorrelated ( alpha , dotNL , dotNV ) ;
float D = D _GGX ( alpha , dotNH ) ;
return F * ( V * D ) ;
}
vec2 LTC _Uv ( const in vec3 N , const in vec3 V , const in float roughness ) {
const float LUT _SIZE = 64.0 ;
const float LUT _SCALE = ( LUT _SIZE - 1.0 ) / LUT _SIZE ;
const float LUT _BIAS = 0.5 / LUT _SIZE ;
float dotNV = saturate ( dot ( N , V ) ) ;
vec2 uv = vec2 ( roughness , sqrt ( 1.0 - dotNV ) ) ;
uv = uv * LUT _SCALE + LUT _BIAS ;
return uv ;
}
float LTC _ClippedSphereFormFactor ( const in vec3 f ) {
float l = length ( f ) ;
return max ( ( l * l + f . z ) / ( l + 1.0 ) , 0.0 ) ;
}
vec3 LTC _EdgeVectorFormFactor ( const in vec3 v1 , const in vec3 v2 ) {
float x = dot ( v1 , v2 ) ;
float y = abs ( x ) ;
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y ;
float b = 3.4175940 + ( 4.1616724 + y ) * y ;
float v = a / b ;
float theta _sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt ( max ( 1.0 - x * x , 1e-7 ) ) - v ;
return cross ( v1 , v2 ) * theta _sintheta ;
}
vec3 LTC _Evaluate ( const in vec3 N , const in vec3 V , const in vec3 P , const in mat3 mInv , const in vec3 rectCoords [ 4 ] ) {
vec3 v1 = rectCoords [ 1 ] - rectCoords [ 0 ] ;
vec3 v2 = rectCoords [ 3 ] - rectCoords [ 0 ] ;
vec3 lightNormal = cross ( v1 , v2 ) ;
if ( dot ( lightNormal , P - rectCoords [ 0 ] ) < 0.0 ) return vec3 ( 0.0 ) ;
vec3 T1 , T2 ;
T1 = normalize ( V - N * dot ( V , N ) ) ;
T2 = - cross ( N , T1 ) ;
mat3 mat = mInv * transposeMat3 ( mat3 ( T1 , T2 , N ) ) ;
vec3 coords [ 4 ] ;
coords [ 0 ] = mat * ( rectCoords [ 0 ] - P ) ;
coords [ 1 ] = mat * ( rectCoords [ 1 ] - P ) ;
coords [ 2 ] = mat * ( rectCoords [ 2 ] - P ) ;
coords [ 3 ] = mat * ( rectCoords [ 3 ] - P ) ;
coords [ 0 ] = normalize ( coords [ 0 ] ) ;
coords [ 1 ] = normalize ( coords [ 1 ] ) ;
coords [ 2 ] = normalize ( coords [ 2 ] ) ;
coords [ 3 ] = normalize ( coords [ 3 ] ) ;
vec3 vectorFormFactor = vec3 ( 0.0 ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 0 ] , coords [ 1 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 1 ] , coords [ 2 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 2 ] , coords [ 3 ] ) ;
vectorFormFactor += LTC _EdgeVectorFormFactor ( coords [ 3 ] , coords [ 0 ] ) ;
float result = LTC _ClippedSphereFormFactor ( vectorFormFactor ) ;
return vec3 ( result ) ;
}
float G _BlinnPhong _Implicit ( ) {
return 0.25 ;
}
float D _BlinnPhong ( const in float shininess , const in float dotNH ) {
return RECIPROCAL _PI * ( shininess * 0.5 + 1.0 ) * pow ( dotNH , shininess ) ;
}
vec3 BRDF _BlinnPhong ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , const in vec3 specularColor , const in float shininess ) {
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float dotVH = saturate ( dot ( viewDir , halfDir ) ) ;
vec3 F = F _Schlick ( specularColor , 1.0 , dotVH ) ;
float G = G _BlinnPhong _Implicit ( ) ;
float D = D _BlinnPhong ( shininess , dotNH ) ;
return F * ( G * D ) ;
}
# if defined ( USE _SHEEN )
float D _Charlie ( float roughness , float dotNH ) {
float alpha = pow2 ( roughness ) ;
float invAlpha = 1.0 / alpha ;
float cos2h = dotNH * dotNH ;
float sin2h = max ( 1.0 - cos2h , 0.0078125 ) ;
return ( 2.0 + invAlpha ) * pow ( sin2h , invAlpha * 0.5 ) / ( 2.0 * PI ) ;
}
float V _Neubelt ( float dotNV , float dotNL ) {
return saturate ( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ) ;
}
vec3 BRDF _Sheen ( const in vec3 lightDir , const in vec3 viewDir , const in vec3 normal , vec3 sheenColor , const in float sheenRoughness ) {
vec3 halfDir = normalize ( lightDir + viewDir ) ;
float dotNL = saturate ( dot ( normal , lightDir ) ) ;
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float dotNH = saturate ( dot ( normal , halfDir ) ) ;
float D = D _Charlie ( sheenRoughness , dotNH ) ;
float V = V _Neubelt ( dotNV , dotNL ) ;
return sheenColor * ( D * V ) ;
}
# endif ` ,TO= ` # ifdef USE _BUMPMAP
uniform sampler2D bumpMap ;
uniform float bumpScale ;
vec2 dHdxy _fwd ( ) {
vec2 dSTdx = dFdx ( vUv ) ;
vec2 dSTdy = dFdy ( vUv ) ;
float Hll = bumpScale * texture2D ( bumpMap , vUv ) . x ;
float dBx = bumpScale * texture2D ( bumpMap , vUv + dSTdx ) . x - Hll ;
float dBy = bumpScale * texture2D ( bumpMap , vUv + dSTdy ) . x - Hll ;
return vec2 ( dBx , dBy ) ;
}
vec3 perturbNormalArb ( vec3 surf _pos , vec3 surf _norm , vec2 dHdxy , float faceDirection ) {
vec3 vSigmaX = vec3 ( dFdx ( surf _pos . x ) , dFdx ( surf _pos . y ) , dFdx ( surf _pos . z ) ) ;
vec3 vSigmaY = vec3 ( dFdy ( surf _pos . x ) , dFdy ( surf _pos . y ) , dFdy ( surf _pos . z ) ) ;
vec3 vN = surf _norm ;
vec3 R1 = cross ( vSigmaY , vN ) ;
vec3 R2 = cross ( vN , vSigmaX ) ;
float fDet = dot ( vSigmaX , R1 ) * faceDirection ;
vec3 vGrad = sign ( fDet ) * ( dHdxy . x * R1 + dHdxy . y * R2 ) ;
return normalize ( abs ( fDet ) * surf _norm - vGrad ) ;
}
# endif ` ,AO= ` # if NUM _CLIPPING _PLANES > 0
vec4 plane ;
# pragma unroll _loop _start
for ( int i = 0 ; i < UNION _CLIPPING _PLANES ; i ++ ) {
plane = clippingPlanes [ i ] ;
if ( dot ( vClipPosition , plane . xyz ) > plane . w ) discard ;
}
# pragma unroll _loop _end
# if UNION _CLIPPING _PLANES < NUM _CLIPPING _PLANES
bool clipped = true ;
# pragma unroll _loop _start
for ( int i = UNION _CLIPPING _PLANES ; i < NUM _CLIPPING _PLANES ; i ++ ) {
plane = clippingPlanes [ i ] ;
clipped = ( dot ( vClipPosition , plane . xyz ) > plane . w ) && clipped ;
}
# pragma unroll _loop _end
if ( clipped ) discard ;
# endif
# endif ` ,CO= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
uniform vec4 clippingPlanes [ NUM _CLIPPING _PLANES ] ;
# endif ` ,PO= ` # if NUM _CLIPPING _PLANES > 0
varying vec3 vClipPosition ;
# endif ` ,RO= ` # if NUM _CLIPPING _PLANES > 0
vClipPosition = - mvPosition . xyz ;
# endif ` ,LO= ` # if defined ( USE _COLOR _ALPHA )
diffuseColor *= vColor ;
# elif defined ( USE _COLOR )
diffuseColor . rgb *= vColor ;
# endif ` ,DO= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR )
varying vec3 vColor ;
# endif ` ,IO= ` # if defined ( USE _COLOR _ALPHA )
varying vec4 vColor ;
# elif defined ( USE _COLOR ) || defined ( USE _INSTANCING _COLOR )
varying vec3 vColor ;
# endif ` ,OO= ` # if defined ( USE _COLOR _ALPHA )
vColor = vec4 ( 1.0 ) ;
# elif defined ( USE _COLOR ) || defined ( USE _INSTANCING _COLOR )
vColor = vec3 ( 1.0 ) ;
# endif
# ifdef USE _COLOR
vColor *= color ;
# endif
# ifdef USE _INSTANCING _COLOR
vColor . xyz *= instanceColor . xyz ;
# endif ` ,kO= ` # define PI 3.141592653589793
# define PI2 6.283185307179586
# define PI _HALF 1.5707963267948966
# define RECIPROCAL _PI 0.3183098861837907
# define RECIPROCAL _PI2 0.15915494309189535
# define EPSILON 1e-6
# ifndef saturate
# define saturate ( a ) clamp ( a , 0.0 , 1.0 )
# endif
# define whiteComplement ( a ) ( 1.0 - saturate ( a ) )
float pow2 ( const in float x ) { return x * x ; }
float pow3 ( const in float x ) { return x * x * x ; }
float pow4 ( const in float x ) { float x2 = x * x ; return x2 * x2 ; }
float max3 ( const in vec3 v ) { return max ( max ( v . x , v . y ) , v . z ) ; }
float average ( const in vec3 color ) { return dot ( color , vec3 ( 0.3333 ) ) ; }
highp float rand ( const in vec2 uv ) {
const highp float a = 12.9898 , b = 78.233 , c = 43758.5453 ;
highp float dt = dot ( uv . xy , vec2 ( a , b ) ) , sn = mod ( dt , PI ) ;
return fract ( sin ( sn ) * c ) ;
}
# ifdef HIGH _PRECISION
float precisionSafeLength ( vec3 v ) { return length ( v ) ; }
# else
float precisionSafeLength ( vec3 v ) {
float maxComponent = max3 ( abs ( v ) ) ;
return length ( v / maxComponent ) * maxComponent ;
}
# endif
struct IncidentLight {
vec3 color ;
vec3 direction ;
bool visible ;
} ;
struct ReflectedLight {
vec3 directDiffuse ;
vec3 directSpecular ;
vec3 indirectDiffuse ;
vec3 indirectSpecular ;
} ;
struct GeometricContext {
vec3 position ;
vec3 normal ;
vec3 viewDir ;
# ifdef USE _CLEARCOAT
vec3 clearcoatNormal ;
# endif
} ;
vec3 transformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( matrix * vec4 ( dir , 0.0 ) ) . xyz ) ;
}
vec3 inverseTransformDirection ( in vec3 dir , in mat4 matrix ) {
return normalize ( ( vec4 ( dir , 0.0 ) * matrix ) . xyz ) ;
}
mat3 transposeMat3 ( const in mat3 m ) {
mat3 tmp ;
tmp [ 0 ] = vec3 ( m [ 0 ] . x , m [ 1 ] . x , m [ 2 ] . x ) ;
tmp [ 1 ] = vec3 ( m [ 0 ] . y , m [ 1 ] . y , m [ 2 ] . y ) ;
tmp [ 2 ] = vec3 ( m [ 0 ] . z , m [ 1 ] . z , m [ 2 ] . z ) ;
return tmp ;
}
float linearToRelativeLuminance ( const in vec3 color ) {
vec3 weights = vec3 ( 0.2126 , 0.7152 , 0.0722 ) ;
return dot ( weights , color . rgb ) ;
}
bool isPerspectiveMatrix ( mat4 m ) {
return m [ 2 ] [ 3 ] == - 1.0 ;
}
vec2 equirectUv ( in vec3 dir ) {
float u = atan ( dir . z , dir . x ) * RECIPROCAL _PI2 + 0.5 ;
float v = asin ( clamp ( dir . y , - 1.0 , 1.0 ) ) * RECIPROCAL _PI + 0.5 ;
return vec2 ( u , v ) ;
} ` ,NO= ` # ifdef ENVMAP _TYPE _CUBE _UV
# define cubeUV _minMipLevel 4.0
# define cubeUV _minTileSize 16.0
float getFace ( vec3 direction ) {
vec3 absDirection = abs ( direction ) ;
float face = - 1.0 ;
if ( absDirection . x > absDirection . z ) {
if ( absDirection . x > absDirection . y )
face = direction . x > 0.0 ? 0.0 : 3.0 ;
else
face = direction . y > 0.0 ? 1.0 : 4.0 ;
} else {
if ( absDirection . z > absDirection . y )
face = direction . z > 0.0 ? 2.0 : 5.0 ;
else
face = direction . y > 0.0 ? 1.0 : 4.0 ;
}
return face ;
}
vec2 getUV ( vec3 direction , float face ) {
vec2 uv ;
if ( face == 0.0 ) {
uv = vec2 ( direction . z , direction . y ) / abs ( direction . x ) ;
} else if ( face == 1.0 ) {
uv = vec2 ( - direction . x , - direction . z ) / abs ( direction . y ) ;
} else if ( face == 2.0 ) {
uv = vec2 ( - direction . x , direction . y ) / abs ( direction . z ) ;
} else if ( face == 3.0 ) {
uv = vec2 ( - direction . z , direction . y ) / abs ( direction . x ) ;
} else if ( face == 4.0 ) {
uv = vec2 ( - direction . x , direction . z ) / abs ( direction . y ) ;
} else {
uv = vec2 ( direction . x , direction . y ) / abs ( direction . z ) ;
}
return 0.5 * ( uv + 1.0 ) ;
}
vec3 bilinearCubeUV ( sampler2D envMap , vec3 direction , float mipInt ) {
float face = getFace ( direction ) ;
float filterInt = max ( cubeUV _minMipLevel - mipInt , 0.0 ) ;
mipInt = max ( mipInt , cubeUV _minMipLevel ) ;
float faceSize = exp2 ( mipInt ) ;
vec2 uv = getUV ( direction , face ) * ( faceSize - 2.0 ) + 1.0 ;
if ( face > 2.0 ) {
uv . y += faceSize ;
face -= 3.0 ;
}
uv . x += face * faceSize ;
uv . x += filterInt * 3.0 * cubeUV _minTileSize ;
uv . y += 4.0 * ( exp2 ( CUBEUV _MAX _MIP ) - faceSize ) ;
uv . x *= CUBEUV _TEXEL _WIDTH ;
uv . y *= CUBEUV _TEXEL _HEIGHT ;
# ifdef texture2DGradEXT
return texture2DGradEXT ( envMap , uv , vec2 ( 0.0 ) , vec2 ( 0.0 ) ) . rgb ;
# else
return texture2D ( envMap , uv ) . rgb ;
# endif
}
# define r0 1.0
# define v0 0.339
# define m0 - 2.0
# define r1 0.8
# define v1 0.276
# define m1 - 1.0
# define r4 0.4
# define v4 0.046
# define m4 2.0
# define r5 0.305
# define v5 0.016
# define m5 3.0
# define r6 0.21
# define v6 0.0038
# define m6 4.0
float roughnessToMip ( float roughness ) {
float mip = 0.0 ;
if ( roughness >= r1 ) {
mip = ( r0 - roughness ) * ( m1 - m0 ) / ( r0 - r1 ) + m0 ;
} else if ( roughness >= r4 ) {
mip = ( r1 - roughness ) * ( m4 - m1 ) / ( r1 - r4 ) + m1 ;
} else if ( roughness >= r5 ) {
mip = ( r4 - roughness ) * ( m5 - m4 ) / ( r4 - r5 ) + m4 ;
} else if ( roughness >= r6 ) {
mip = ( r5 - roughness ) * ( m6 - m5 ) / ( r5 - r6 ) + m5 ;
} else {
mip = - 2.0 * log2 ( 1.16 * roughness ) ; }
return mip ;
}
vec4 textureCubeUV ( sampler2D envMap , vec3 sampleDir , float roughness ) {
float mip = clamp ( roughnessToMip ( roughness ) , m0 , CUBEUV _MAX _MIP ) ;
float mipF = fract ( mip ) ;
float mipInt = floor ( mip ) ;
vec3 color0 = bilinearCubeUV ( envMap , sampleDir , mipInt ) ;
if ( mipF == 0.0 ) {
return vec4 ( color0 , 1.0 ) ;
} else {
vec3 color1 = bilinearCubeUV ( envMap , sampleDir , mipInt + 1.0 ) ;
return vec4 ( mix ( color0 , color1 , mipF ) , 1.0 ) ;
}
}
# endif ` ,BO= ` vec3 transformedNormal = objectNormal ;
# ifdef USE _INSTANCING
mat3 m = mat3 ( instanceMatrix ) ;
transformedNormal /= vec3 ( dot ( m [ 0 ] , m [ 0 ] ) , dot ( m [ 1 ] , m [ 1 ] ) , dot ( m [ 2 ] , m [ 2 ] ) ) ;
transformedNormal = m * transformedNormal ;
# endif
transformedNormal = normalMatrix * transformedNormal ;
# ifdef FLIP _SIDED
transformedNormal = - transformedNormal ;
# endif
# ifdef USE _TANGENT
vec3 transformedTangent = ( modelViewMatrix * vec4 ( objectTangent , 0.0 ) ) . xyz ;
# ifdef FLIP _SIDED
transformedTangent = - transformedTangent ;
# endif
# endif ` ,zO= ` # ifdef USE _DISPLACEMENTMAP
uniform sampler2D displacementMap ;
uniform float displacementScale ;
uniform float displacementBias ;
# endif ` ,UO= ` # ifdef USE _DISPLACEMENTMAP
transformed += normalize ( objectNormal ) * ( texture2D ( displacementMap , vUv ) . x * displacementScale + displacementBias ) ;
# endif ` ,FO= ` # ifdef USE _EMISSIVEMAP
vec4 emissiveColor = texture2D ( emissiveMap , vUv ) ;
totalEmissiveRadiance *= emissiveColor . rgb ;
# endif ` ,VO= ` # ifdef USE _EMISSIVEMAP
uniform sampler2D emissiveMap ;
# endif ` ,HO="gl_FragColor = linearToOutputTexel( gl_FragColor );",GO= ` vec4 LinearToLinear ( in vec4 value ) {
return value ;
}
vec4 LinearTosRGB ( in vec4 value ) {
return vec4 ( mix ( pow ( value . rgb , vec3 ( 0.41666 ) ) * 1.055 - vec3 ( 0.055 ) , value . rgb * 12.92 , vec3 ( lessThanEqual ( value . rgb , vec3 ( 0.0031308 ) ) ) ) , value . a ) ;
} ` ,WO= ` # ifdef USE _ENVMAP
# ifdef ENV _WORLDPOS
vec3 cameraToFrag ;
if ( isOrthographic ) {
cameraToFrag = normalize ( vec3 ( - viewMatrix [ 0 ] [ 2 ] , - viewMatrix [ 1 ] [ 2 ] , - viewMatrix [ 2 ] [ 2 ] ) ) ;
} else {
cameraToFrag = normalize ( vWorldPosition - cameraPosition ) ;
}
vec3 worldNormal = inverseTransformDirection ( normal , viewMatrix ) ;
# ifdef ENVMAP _MODE _REFLECTION
vec3 reflectVec = reflect ( cameraToFrag , worldNormal ) ;
# else
vec3 reflectVec = refract ( cameraToFrag , worldNormal , refractionRatio ) ;
# endif
# else
vec3 reflectVec = vReflect ;
# endif
# ifdef ENVMAP _TYPE _CUBE
vec4 envColor = textureCube ( envMap , vec3 ( flipEnvMap * reflectVec . x , reflectVec . yz ) ) ;
# elif defined ( ENVMAP _TYPE _CUBE _UV )
vec4 envColor = textureCubeUV ( envMap , reflectVec , 0.0 ) ;
# else
vec4 envColor = vec4 ( 0.0 ) ;
# endif
# ifdef ENVMAP _BLENDING _MULTIPLY
outgoingLight = mix ( outgoingLight , outgoingLight * envColor . xyz , specularStrength * reflectivity ) ;
# elif defined ( ENVMAP _BLENDING _MIX )
outgoingLight = mix ( outgoingLight , envColor . xyz , specularStrength * reflectivity ) ;
# elif defined ( ENVMAP _BLENDING _ADD )
outgoingLight += envColor . xyz * specularStrength * reflectivity ;
# endif
# endif ` ,jO= ` # ifdef USE _ENVMAP
uniform float envMapIntensity ;
uniform float flipEnvMap ;
# ifdef ENVMAP _TYPE _CUBE
uniform samplerCube envMap ;
# else
uniform sampler2D envMap ;
# endif
# endif ` ,XO= ` # ifdef USE _ENVMAP
uniform float reflectivity ;
# if defined ( USE _BUMPMAP ) || defined ( USE _NORMALMAP ) || defined ( PHONG )
# define ENV _WORLDPOS
# endif
# ifdef ENV _WORLDPOS
varying vec3 vWorldPosition ;
uniform float refractionRatio ;
# else
varying vec3 vReflect ;
# endif
# endif ` ,qO= ` # ifdef USE _ENVMAP
# if defined ( USE _BUMPMAP ) || defined ( USE _NORMALMAP ) || defined ( PHONG )
# define ENV _WORLDPOS
# endif
# ifdef ENV _WORLDPOS
varying vec3 vWorldPosition ;
# else
varying vec3 vReflect ;
uniform float refractionRatio ;
# endif
# endif ` ,YO= ` # ifdef USE _ENVMAP
# ifdef ENV _WORLDPOS
vWorldPosition = worldPosition . xyz ;
# else
vec3 cameraToVertex ;
if ( isOrthographic ) {
cameraToVertex = normalize ( vec3 ( - viewMatrix [ 0 ] [ 2 ] , - viewMatrix [ 1 ] [ 2 ] , - viewMatrix [ 2 ] [ 2 ] ) ) ;
} else {
cameraToVertex = normalize ( worldPosition . xyz - cameraPosition ) ;
}
vec3 worldNormal = inverseTransformDirection ( transformedNormal , viewMatrix ) ;
# ifdef ENVMAP _MODE _REFLECTION
vReflect = reflect ( cameraToVertex , worldNormal ) ;
# else
vReflect = refract ( cameraToVertex , worldNormal , refractionRatio ) ;
# endif
# endif
# endif ` ,ZO= ` # ifdef USE _FOG
vFogDepth = - mvPosition . z ;
# endif ` ,KO= ` # ifdef USE _FOG
varying float vFogDepth ;
# endif ` ,JO= ` # ifdef USE _FOG
# ifdef FOG _EXP2
float fogFactor = 1.0 - exp ( - fogDensity * fogDensity * vFogDepth * vFogDepth ) ;
# else
float fogFactor = smoothstep ( fogNear , fogFar , vFogDepth ) ;
# endif
gl _FragColor . rgb = mix ( gl _FragColor . rgb , fogColor , fogFactor ) ;
# endif ` ,QO= ` # ifdef USE _FOG
uniform vec3 fogColor ;
varying float vFogDepth ;
# ifdef FOG _EXP2
uniform float fogDensity ;
# else
uniform float fogNear ;
uniform float fogFar ;
# endif
# endif ` , $ O= ` # ifdef USE _GRADIENTMAP
uniform sampler2D gradientMap ;
# endif
vec3 getGradientIrradiance ( vec3 normal , vec3 lightDirection ) {
float dotNL = dot ( normal , lightDirection ) ;
vec2 coord = vec2 ( dotNL * 0.5 + 0.5 , 0.0 ) ;
# ifdef USE _GRADIENTMAP
return vec3 ( texture2D ( gradientMap , coord ) . r ) ;
# else
return ( coord . x < 0.7 ) ? vec3 ( 0.7 ) : vec3 ( 1.0 ) ;
# endif
} ` ,e5= ` # ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
reflectedLight . indirectDiffuse += lightMapIrradiance ;
# endif ` ,t5= ` # ifdef USE _LIGHTMAP
uniform sampler2D lightMap ;
uniform float lightMapIntensity ;
# endif ` ,n5= ` vec3 diffuse = vec3 ( 1.0 ) ;
GeometricContext geometry ;
geometry . position = mvPosition . xyz ;
geometry . normal = normalize ( transformedNormal ) ;
geometry . viewDir = ( isOrthographic ) ? vec3 ( 0 , 0 , 1 ) : normalize ( - mvPosition . xyz ) ;
GeometricContext backGeometry ;
backGeometry . position = geometry . position ;
backGeometry . normal = - geometry . normal ;
backGeometry . viewDir = geometry . viewDir ;
vLightFront = vec3 ( 0.0 ) ;
vIndirectFront = vec3 ( 0.0 ) ;
# ifdef DOUBLE _SIDED
vLightBack = vec3 ( 0.0 ) ;
vIndirectBack = vec3 ( 0.0 ) ;
# endif
IncidentLight directLight ;
float dotNL ;
vec3 directLightColor _Diffuse ;
vIndirectFront += getAmbientLightIrradiance ( ambientLightColor ) ;
vIndirectFront += getLightProbeIrradiance ( lightProbe , geometry . normal ) ;
# ifdef DOUBLE _SIDED
vIndirectBack += getAmbientLightIrradiance ( ambientLightColor ) ;
vIndirectBack += getLightProbeIrradiance ( lightProbe , backGeometry . normal ) ;
# endif
# if NUM _POINT _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHTS ; i ++ ) {
getPointLightInfo ( pointLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHTS ; i ++ ) {
getSpotLightInfo ( spotLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _DIR _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHTS ; i ++ ) {
getDirectionalLightInfo ( directionalLights [ i ] , geometry , directLight ) ;
dotNL = dot ( geometry . normal , directLight . direction ) ;
directLightColor _Diffuse = directLight . color ;
vLightFront += saturate ( dotNL ) * directLightColor _Diffuse ;
# ifdef DOUBLE _SIDED
vLightBack += saturate ( - dotNL ) * directLightColor _Diffuse ;
# endif
}
# pragma unroll _loop _end
# endif
# if NUM _HEMI _LIGHTS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _HEMI _LIGHTS ; i ++ ) {
vIndirectFront += getHemisphereLightIrradiance ( hemisphereLights [ i ] , geometry . normal ) ;
# ifdef DOUBLE _SIDED
vIndirectBack += getHemisphereLightIrradiance ( hemisphereLights [ i ] , backGeometry . normal ) ;
# endif
}
# pragma unroll _loop _end
# endif ` ,i5= ` uniform bool receiveShadow ;
uniform vec3 ambientLightColor ;
uniform vec3 lightProbe [ 9 ] ;
vec3 shGetIrradianceAt ( in vec3 normal , in vec3 shCoefficients [ 9 ] ) {
float x = normal . x , y = normal . y , z = normal . z ;
vec3 result = shCoefficients [ 0 ] * 0.886227 ;
result += shCoefficients [ 1 ] * 2.0 * 0.511664 * y ;
result += shCoefficients [ 2 ] * 2.0 * 0.511664 * z ;
result += shCoefficients [ 3 ] * 2.0 * 0.511664 * x ;
result += shCoefficients [ 4 ] * 2.0 * 0.429043 * x * y ;
result += shCoefficients [ 5 ] * 2.0 * 0.429043 * y * z ;
result += shCoefficients [ 6 ] * ( 0.743125 * z * z - 0.247708 ) ;
result += shCoefficients [ 7 ] * 2.0 * 0.429043 * x * z ;
result += shCoefficients [ 8 ] * 0.429043 * ( x * x - y * y ) ;
return result ;
}
vec3 getLightProbeIrradiance ( const in vec3 lightProbe [ 9 ] , const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection ( normal , viewMatrix ) ;
vec3 irradiance = shGetIrradianceAt ( worldNormal , lightProbe ) ;
return irradiance ;
}
vec3 getAmbientLightIrradiance ( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor ;
return irradiance ;
}
float getDistanceAttenuation ( const in float lightDistance , const in float cutoffDistance , const in float decayExponent ) {
# if defined ( PHYSICALLY _CORRECT _LIGHTS )
float distanceFalloff = 1.0 / max ( pow ( lightDistance , decayExponent ) , 0.01 ) ;
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2 ( saturate ( 1.0 - pow4 ( lightDistance / cutoffDistance ) ) ) ;
}
return distanceFalloff ;
# else
if ( cutoffDistance > 0.0 && decayExponent > 0.0 ) {
return pow ( saturate ( - lightDistance / cutoffDistance + 1.0 ) , decayExponent ) ;
}
return 1.0 ;
# endif
}
float getSpotAttenuation ( const in float coneCosine , const in float penumbraCosine , const in float angleCosine ) {
return smoothstep ( coneCosine , penumbraCosine , angleCosine ) ;
}
# if NUM _DIR _LIGHTS > 0
struct DirectionalLight {
vec3 direction ;
vec3 color ;
} ;
uniform DirectionalLight directionalLights [ NUM _DIR _LIGHTS ] ;
void getDirectionalLightInfo ( const in DirectionalLight directionalLight , const in GeometricContext geometry , out IncidentLight light ) {
light . color = directionalLight . color ;
light . direction = directionalLight . direction ;
light . visible = true ;
}
# endif
# if NUM _POINT _LIGHTS > 0
struct PointLight {
vec3 position ;
vec3 color ;
float distance ;
float decay ;
} ;
uniform PointLight pointLights [ NUM _POINT _LIGHTS ] ;
void getPointLightInfo ( const in PointLight pointLight , const in GeometricContext geometry , out IncidentLight light ) {
vec3 lVector = pointLight . position - geometry . position ;
light . direction = normalize ( lVector ) ;
float lightDistance = length ( lVector ) ;
light . color = pointLight . color ;
light . color *= getDistanceAttenuation ( lightDistance , pointLight . distance , pointLight . decay ) ;
light . visible = ( light . color != vec3 ( 0.0 ) ) ;
}
# endif
# if NUM _SPOT _LIGHTS > 0
struct SpotLight {
vec3 position ;
vec3 direction ;
vec3 color ;
float distance ;
float decay ;
float coneCos ;
float penumbraCos ;
} ;
uniform SpotLight spotLights [ NUM _SPOT _LIGHTS ] ;
void getSpotLightInfo ( const in SpotLight spotLight , const in GeometricContext geometry , out IncidentLight light ) {
vec3 lVector = spotLight . position - geometry . position ;
light . direction = normalize ( lVector ) ;
float angleCos = dot ( light . direction , spotLight . direction ) ;
float spotAttenuation = getSpotAttenuation ( spotLight . coneCos , spotLight . penumbraCos , angleCos ) ;
if ( spotAttenuation > 0.0 ) {
float lightDistance = length ( lVector ) ;
light . color = spotLight . color * spotAttenuation ;
light . color *= getDistanceAttenuation ( lightDistance , spotLight . distance , spotLight . decay ) ;
light . visible = ( light . color != vec3 ( 0.0 ) ) ;
} else {
light . color = vec3 ( 0.0 ) ;
light . visible = false ;
}
}
# endif
# if NUM _RECT _AREA _LIGHTS > 0
struct RectAreaLight {
vec3 color ;
vec3 position ;
vec3 halfWidth ;
vec3 halfHeight ;
} ;
uniform sampler2D ltc _1 ; uniform sampler2D ltc _2 ;
uniform RectAreaLight rectAreaLights [ NUM _RECT _AREA _LIGHTS ] ;
# endif
# if NUM _HEMI _LIGHTS > 0
struct HemisphereLight {
vec3 direction ;
vec3 skyColor ;
vec3 groundColor ;
} ;
uniform HemisphereLight hemisphereLights [ NUM _HEMI _LIGHTS ] ;
vec3 getHemisphereLightIrradiance ( const in HemisphereLight hemiLight , const in vec3 normal ) {
float dotNL = dot ( normal , hemiLight . direction ) ;
float hemiDiffuseWeight = 0.5 * dotNL + 0.5 ;
vec3 irradiance = mix ( hemiLight . groundColor , hemiLight . skyColor , hemiDiffuseWeight ) ;
return irradiance ;
}
# endif ` ,r5= ` # if defined ( USE _ENVMAP )
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 = reflect ( - viewDir , normal ) ;
reflectVec = normalize ( mix ( reflectVec , normal , roughness * roughness ) ) ;
reflectVec = inverseTransformDirection ( reflectVec , viewMatrix ) ;
vec4 envMapColor = textureCubeUV ( envMap , reflectVec , roughness ) ;
return envMapColor . rgb * envMapIntensity ;
# else
return vec3 ( 0.0 ) ;
# endif
}
# endif ` ,s5= ` ToonMaterial material ;
material . diffuseColor = diffuseColor . rgb ; ` ,o5= ` varying vec3 vViewPosition ;
struct ToonMaterial {
vec3 diffuseColor ;
} ;
void RE _Direct _Toon ( const in IncidentLight directLight , const in GeometricContext geometry , const in ToonMaterial material , inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance ( geometry . normal , directLight . direction ) * directLight . color ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectDiffuse _Toon ( const in vec3 irradiance , const in GeometricContext geometry , const in ToonMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
# define RE _Direct RE _Direct _Toon
# define RE _IndirectDiffuse RE _IndirectDiffuse _Toon
# define Material _LightProbeLOD ( material ) ( 0 ) ` ,a5= ` BlinnPhongMaterial material ;
material . diffuseColor = diffuseColor . rgb ;
material . specularColor = specular ;
material . specularShininess = shininess ;
material . specularStrength = specularStrength ; ` ,l5= ` varying vec3 vViewPosition ;
struct BlinnPhongMaterial {
vec3 diffuseColor ;
vec3 specularColor ;
float specularShininess ;
float specularStrength ;
} ;
void RE _Direct _BlinnPhong ( const in IncidentLight directLight , const in GeometricContext geometry , const in BlinnPhongMaterial material , inout ReflectedLight reflectedLight ) {
float dotNL = saturate ( dot ( geometry . normal , directLight . direction ) ) ;
vec3 irradiance = dotNL * directLight . color ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
reflectedLight . directSpecular += irradiance * BRDF _BlinnPhong ( directLight . direction , geometry . viewDir , geometry . normal , material . specularColor , material . specularShininess ) * material . specularStrength ;
}
void RE _IndirectDiffuse _BlinnPhong ( const in vec3 irradiance , const in GeometricContext geometry , const in BlinnPhongMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
# define RE _Direct RE _Direct _BlinnPhong
# define RE _IndirectDiffuse RE _IndirectDiffuse _BlinnPhong
# define Material _LightProbeLOD ( material ) ( 0 ) ` ,c5= ` PhysicalMaterial material ;
material . diffuseColor = diffuseColor . rgb * ( 1.0 - metalnessFactor ) ;
vec3 dxy = max ( abs ( dFdx ( geometryNormal ) ) , abs ( dFdy ( geometryNormal ) ) ) ;
float geometryRoughness = max ( max ( dxy . x , dxy . y ) , dxy . z ) ;
material . roughness = max ( roughnessFactor , 0.0525 ) ; material . roughness += geometryRoughness ;
material . roughness = min ( material . roughness , 1.0 ) ;
# ifdef IOR
# ifdef SPECULAR
float specularIntensityFactor = specularIntensity ;
vec3 specularColorFactor = specularColor ;
# ifdef USE _SPECULARINTENSITYMAP
specularIntensityFactor *= texture2D ( specularIntensityMap , vUv ) . a ;
# endif
# ifdef USE _SPECULARCOLORMAP
specularColorFactor *= texture2D ( specularColorMap , vUv ) . rgb ;
# endif
material . specularF90 = mix ( specularIntensityFactor , 1.0 , metalnessFactor ) ;
# else
float specularIntensityFactor = 1.0 ;
vec3 specularColorFactor = vec3 ( 1.0 ) ;
material . specularF90 = 1.0 ;
# endif
material . specularColor = mix ( min ( pow2 ( ( ior - 1.0 ) / ( ior + 1.0 ) ) * specularColorFactor , vec3 ( 1.0 ) ) * specularIntensityFactor , diffuseColor . rgb , metalnessFactor ) ;
# else
material . specularColor = mix ( vec3 ( 0.04 ) , diffuseColor . rgb , metalnessFactor ) ;
material . specularF90 = 1.0 ;
# endif
# ifdef USE _CLEARCOAT
material . clearcoat = clearcoat ;
material . clearcoatRoughness = clearcoatRoughness ;
material . clearcoatF0 = vec3 ( 0.04 ) ;
material . clearcoatF90 = 1.0 ;
# ifdef USE _CLEARCOATMAP
material . clearcoat *= texture2D ( clearcoatMap , vUv ) . x ;
# endif
# ifdef USE _CLEARCOAT _ROUGHNESSMAP
material . clearcoatRoughness *= texture2D ( clearcoatRoughnessMap , vUv ) . y ;
# endif
material . clearcoat = saturate ( material . clearcoat ) ; material . clearcoatRoughness = max ( material . clearcoatRoughness , 0.0525 ) ;
material . clearcoatRoughness += geometryRoughness ;
material . clearcoatRoughness = min ( material . clearcoatRoughness , 1.0 ) ;
# endif
# ifdef USE _SHEEN
material . sheenColor = sheenColor ;
# ifdef USE _SHEENCOLORMAP
material . sheenColor *= texture2D ( sheenColorMap , vUv ) . rgb ;
# endif
material . sheenRoughness = clamp ( sheenRoughness , 0.07 , 1.0 ) ;
# ifdef USE _SHEENROUGHNESSMAP
material . sheenRoughness *= texture2D ( sheenRoughnessMap , vUv ) . a ;
# endif
# endif ` ,u5= ` struct PhysicalMaterial {
vec3 diffuseColor ;
float roughness ;
vec3 specularColor ;
float specularF90 ;
# ifdef USE _CLEARCOAT
float clearcoat ;
float clearcoatRoughness ;
vec3 clearcoatF0 ;
float clearcoatF90 ;
# endif
# ifdef USE _SHEEN
vec3 sheenColor ;
float sheenRoughness ;
# endif
} ;
vec3 clearcoatSpecular = vec3 ( 0.0 ) ;
vec3 sheenSpecular = vec3 ( 0.0 ) ;
float IBLSheenBRDF ( const in vec3 normal , const in vec3 viewDir , const in float roughness ) {
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
float r2 = roughness * roughness ;
float a = roughness < 0.25 ? - 339.2 * r2 + 161.4 * roughness - 25.9 : - 8.48 * r2 + 14.3 * roughness - 9.95 ;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72 ;
float DG = exp ( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) ) ;
return saturate ( DG * RECIPROCAL _PI ) ;
}
vec2 DFGApprox ( const in vec3 normal , const in vec3 viewDir , const in float roughness ) {
float dotNV = saturate ( dot ( normal , viewDir ) ) ;
const vec4 c0 = vec4 ( - 1 , - 0.0275 , - 0.572 , 0.022 ) ;
const vec4 c1 = vec4 ( 1 , 0.0425 , 1.04 , - 0.04 ) ;
vec4 r = roughness * c0 + c1 ;
float a004 = min ( r . x * r . x , exp2 ( - 9.28 * dotNV ) ) * r . x + r . y ;
vec2 fab = vec2 ( - 1.04 , 1.04 ) * a004 + r . zw ;
return fab ;
}
vec3 EnvironmentBRDF ( const in vec3 normal , const in vec3 viewDir , const in vec3 specularColor , const in float specularF90 , const in float roughness ) {
vec2 fab = DFGApprox ( normal , viewDir , roughness ) ;
return specularColor * fab . x + specularF90 * fab . y ;
}
void computeMultiscattering ( const in vec3 normal , const in vec3 viewDir , const in vec3 specularColor , const in float specularF90 , const in float roughness , inout vec3 singleScatter , inout vec3 multiScatter ) {
vec2 fab = DFGApprox ( normal , viewDir , roughness ) ;
vec3 FssEss = specularColor * fab . x + specularF90 * fab . y ;
float Ess = fab . x + fab . y ;
float Ems = 1.0 - Ess ;
vec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619 ; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ) ;
singleScatter += FssEss ;
multiScatter += Fms * Ems ;
}
# if NUM _RECT _AREA _LIGHTS > 0
void RE _Direct _RectArea _Physical ( const in RectAreaLight rectAreaLight , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
vec3 normal = geometry . normal ;
vec3 viewDir = geometry . viewDir ;
vec3 position = geometry . position ;
vec3 lightPos = rectAreaLight . position ;
vec3 halfWidth = rectAreaLight . halfWidth ;
vec3 halfHeight = rectAreaLight . halfHeight ;
vec3 lightColor = rectAreaLight . color ;
float roughness = material . roughness ;
vec3 rectCoords [ 4 ] ;
rectCoords [ 0 ] = lightPos + halfWidth - halfHeight ; rectCoords [ 1 ] = lightPos - halfWidth - halfHeight ;
rectCoords [ 2 ] = lightPos - halfWidth + halfHeight ;
rectCoords [ 3 ] = lightPos + halfWidth + halfHeight ;
vec2 uv = LTC _Uv ( normal , viewDir , roughness ) ;
vec4 t1 = texture2D ( ltc _1 , uv ) ;
vec4 t2 = texture2D ( ltc _2 , uv ) ;
mat3 mInv = mat3 (
vec3 ( t1 . x , 0 , t1 . y ) ,
vec3 ( 0 , 1 , 0 ) ,
vec3 ( t1 . z , 0 , t1 . w )
) ;
vec3 fresnel = ( material . specularColor * t2 . x + ( vec3 ( 1.0 ) - material . specularColor ) * t2 . y ) ;
reflectedLight . directSpecular += lightColor * fresnel * LTC _Evaluate ( normal , viewDir , position , mInv , rectCoords ) ;
reflectedLight . directDiffuse += lightColor * material . diffuseColor * LTC _Evaluate ( normal , viewDir , position , mat3 ( 1.0 ) , rectCoords ) ;
}
# endif
void RE _Direct _Physical ( const in IncidentLight directLight , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
float dotNL = saturate ( dot ( geometry . normal , directLight . direction ) ) ;
vec3 irradiance = dotNL * directLight . color ;
# ifdef USE _CLEARCOAT
float dotNLcc = saturate ( dot ( geometry . clearcoatNormal , directLight . direction ) ) ;
vec3 ccIrradiance = dotNLcc * directLight . color ;
clearcoatSpecular += ccIrradiance * BRDF _GGX ( directLight . direction , geometry . viewDir , geometry . clearcoatNormal , material . clearcoatF0 , material . clearcoatF90 , material . clearcoatRoughness ) ;
# endif
# ifdef USE _SHEEN
sheenSpecular += irradiance * BRDF _Sheen ( directLight . direction , geometry . viewDir , geometry . normal , material . sheenColor , material . sheenRoughness ) ;
# endif
reflectedLight . directSpecular += irradiance * BRDF _GGX ( directLight . direction , geometry . viewDir , geometry . normal , material . specularColor , material . specularF90 , material . roughness ) ;
reflectedLight . directDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectDiffuse _Physical ( const in vec3 irradiance , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
reflectedLight . indirectDiffuse += irradiance * BRDF _Lambert ( material . diffuseColor ) ;
}
void RE _IndirectSpecular _Physical ( const in vec3 radiance , const in vec3 irradiance , const in vec3 clearcoatRadiance , const in GeometricContext geometry , const in PhysicalMaterial material , inout ReflectedLight reflectedLight ) {
# ifdef USE _CLEARCOAT
clearcoatSpecular += clearcoatRadiance * EnvironmentBRDF ( geometry . clearcoatNormal , geometry . viewDir , material . clearcoatF0 , material . clearcoatF90 , material . clearcoatRoughness ) ;
# endif
# ifdef USE _SHEEN
sheenSpecular += irradiance * material . sheenColor * IBLSheenBRDF ( geometry . normal , geometry . viewDir , material . sheenRoughness ) ;
# endif
vec3 singleScattering = vec3 ( 0.0 ) ;
vec3 multiScattering = vec3 ( 0.0 ) ;
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL _PI ;
computeMultiscattering ( geometry . normal , geometry . viewDir , material . specularColor , material . specularF90 , material . roughness , singleScattering , multiScattering ) ;
vec3 diffuse = material . diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) ) ;
reflectedLight . indirectSpecular += radiance * singleScattering ;
reflectedLight . indirectSpecular += multiScattering * cosineWeightedIrradiance ;
reflectedLight . indirectDiffuse += diffuse * cosineWeightedIrradiance ;
}
# define RE _Direct RE _Direct _Physical
# define RE _Direct _RectArea RE _Direct _RectArea _Physical
# define RE _IndirectDiffuse RE _IndirectDiffuse _Physical
# define RE _IndirectSpecular RE _IndirectSpecular _Physical
float computeSpecularOcclusion ( const in float dotNV , const in float ambientOcclusion , const in float roughness ) {
return saturate ( pow ( dotNV + ambientOcclusion , exp2 ( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ) ;
} ` ,h5= `
GeometricContext geometry ;
geometry . position = - vViewPosition ;
geometry . normal = normal ;
geometry . viewDir = ( isOrthographic ) ? vec3 ( 0 , 0 , 1 ) : normalize ( vViewPosition ) ;
# ifdef USE _CLEARCOAT
geometry . clearcoatNormal = clearcoatNormal ;
# endif
IncidentLight directLight ;
# if ( NUM _POINT _LIGHTS > 0 ) && defined ( RE _Direct )
PointLight pointLight ;
# if defined ( USE _SHADOWMAP ) && NUM _POINT _LIGHT _SHADOWS > 0
PointLightShadow pointLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHTS ; i ++ ) {
pointLight = pointLights [ i ] ;
getPointLightInfo ( pointLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _POINT _LIGHT _SHADOWS )
pointLightShadow = pointLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getPointShadow ( pointShadowMap [ i ] , pointLightShadow . shadowMapSize , pointLightShadow . shadowBias , pointLightShadow . shadowRadius , vPointShadowCoord [ i ] , pointLightShadow . shadowCameraNear , pointLightShadow . shadowCameraFar ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _SPOT _LIGHTS > 0 ) && defined ( RE _Direct )
SpotLight spotLight ;
# if defined ( USE _SHADOWMAP ) && NUM _SPOT _LIGHT _SHADOWS > 0
SpotLightShadow spotLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHTS ; i ++ ) {
spotLight = spotLights [ i ] ;
getSpotLightInfo ( spotLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _SPOT _LIGHT _SHADOWS )
spotLightShadow = spotLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getShadow ( spotShadowMap [ i ] , spotLightShadow . shadowMapSize , spotLightShadow . shadowBias , spotLightShadow . shadowRadius , vSpotShadowCoord [ i ] ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _DIR _LIGHTS > 0 ) && defined ( RE _Direct )
DirectionalLight directionalLight ;
# if defined ( USE _SHADOWMAP ) && NUM _DIR _LIGHT _SHADOWS > 0
DirectionalLightShadow directionalLightShadow ;
# endif
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHTS ; i ++ ) {
directionalLight = directionalLights [ i ] ;
getDirectionalLightInfo ( directionalLight , geometry , directLight ) ;
# if defined ( USE _SHADOWMAP ) && ( UNROLLED _LOOP _INDEX < NUM _DIR _LIGHT _SHADOWS )
directionalLightShadow = directionalLightShadows [ i ] ;
directLight . color *= all ( bvec2 ( directLight . visible , receiveShadow ) ) ? getShadow ( directionalShadowMap [ i ] , directionalLightShadow . shadowMapSize , directionalLightShadow . shadowBias , directionalLightShadow . shadowRadius , vDirectionalShadowCoord [ i ] ) : 1.0 ;
# endif
RE _Direct ( directLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if ( NUM _RECT _AREA _LIGHTS > 0 ) && defined ( RE _Direct _RectArea )
RectAreaLight rectAreaLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _RECT _AREA _LIGHTS ; i ++ ) {
rectAreaLight = rectAreaLights [ i ] ;
RE _Direct _RectArea ( rectAreaLight , geometry , material , reflectedLight ) ;
}
# pragma unroll _loop _end
# endif
# if defined ( RE _IndirectDiffuse )
vec3 iblIrradiance = vec3 ( 0.0 ) ;
vec3 irradiance = getAmbientLightIrradiance ( ambientLightColor ) ;
irradiance += getLightProbeIrradiance ( lightProbe , geometry . normal ) ;
# if ( NUM _HEMI _LIGHTS > 0 )
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _HEMI _LIGHTS ; i ++ ) {
irradiance += getHemisphereLightIrradiance ( hemisphereLights [ i ] , geometry . normal ) ;
}
# pragma unroll _loop _end
# endif
# endif
# if defined ( RE _IndirectSpecular )
vec3 radiance = vec3 ( 0.0 ) ;
vec3 clearcoatRadiance = vec3 ( 0.0 ) ;
# endif ` ,d5= ` # if defined ( RE _IndirectDiffuse )
# ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
vec3 lightMapIrradiance = lightMapTexel . rgb * lightMapIntensity ;
irradiance += lightMapIrradiance ;
# endif
# if defined ( USE _ENVMAP ) && defined ( STANDARD ) && defined ( ENVMAP _TYPE _CUBE _UV )
iblIrradiance += getIBLIrradiance ( geometry . normal ) ;
# endif
# endif
# if defined ( USE _ENVMAP ) && defined ( RE _IndirectSpecular )
radiance += getIBLRadiance ( geometry . viewDir , geometry . normal , material . roughness ) ;
# ifdef USE _CLEARCOAT
clearcoatRadiance += getIBLRadiance ( geometry . viewDir , geometry . clearcoatNormal , material . clearcoatRoughness ) ;
# endif
# endif ` ,p5= ` # if defined ( RE _IndirectDiffuse )
RE _IndirectDiffuse ( irradiance , geometry , material , reflectedLight ) ;
# endif
# if defined ( RE _IndirectSpecular )
RE _IndirectSpecular ( radiance , iblIrradiance , clearcoatRadiance , geometry , material , reflectedLight ) ;
# endif ` ,f5= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
gl _FragDepthEXT = vIsPerspective == 0.0 ? gl _FragCoord . z : log2 ( vFragDepth ) * logDepthBufFC * 0.5 ;
# endif ` ,m5= ` # if defined ( USE _LOGDEPTHBUF ) && defined ( USE _LOGDEPTHBUF _EXT )
uniform float logDepthBufFC ;
varying float vFragDepth ;
varying float vIsPerspective ;
# endif ` ,v5= ` # ifdef USE _LOGDEPTHBUF
# ifdef USE _LOGDEPTHBUF _EXT
varying float vFragDepth ;
varying float vIsPerspective ;
# else
uniform float logDepthBufFC ;
# endif
# endif ` ,g5= ` # ifdef USE _LOGDEPTHBUF
# ifdef USE _LOGDEPTHBUF _EXT
vFragDepth = 1.0 + gl _Position . w ;
vIsPerspective = float ( isPerspectiveMatrix ( projectionMatrix ) ) ;
# else
if ( isPerspectiveMatrix ( projectionMatrix ) ) {
gl _Position . z = log2 ( max ( EPSILON , gl _Position . w + 1.0 ) ) * logDepthBufFC - 1.0 ;
gl _Position . z *= gl _Position . w ;
}
# endif
# endif ` ,y5= ` # ifdef USE _MAP
vec4 sampledDiffuseColor = texture2D ( map , vUv ) ;
# ifdef DECODE _VIDEO _TEXTURE
sampledDiffuseColor = vec4 ( mix ( pow ( sampledDiffuseColor . rgb * 0.9478672986 + vec3 ( 0.0521327014 ) , vec3 ( 2.4 ) ) , sampledDiffuseColor . rgb * 0.0773993808 , vec3 ( lessThanEqual ( sampledDiffuseColor . rgb , vec3 ( 0.04045 ) ) ) ) , sampledDiffuseColor . w ) ;
# endif
diffuseColor *= sampledDiffuseColor ;
# endif ` ,_5= ` # ifdef USE _MAP
uniform sampler2D map ;
# endif ` ,x5= ` # if defined ( USE _MAP ) || defined ( USE _ALPHAMAP )
vec2 uv = ( uvTransform * vec3 ( gl _PointCoord . x , 1.0 - gl _PointCoord . y , 1 ) ) . xy ;
# endif
# ifdef USE _MAP
diffuseColor *= texture2D ( map , uv ) ;
# endif
# ifdef USE _ALPHAMAP
diffuseColor . a *= texture2D ( alphaMap , uv ) . g ;
# endif ` ,b5= ` # if defined ( USE _MAP ) || defined ( USE _ALPHAMAP )
uniform mat3 uvTransform ;
# endif
# ifdef USE _MAP
uniform sampler2D map ;
# endif
# ifdef USE _ALPHAMAP
uniform sampler2D alphaMap ;
# endif ` ,w5= ` float metalnessFactor = metalness ;
# ifdef USE _METALNESSMAP
vec4 texelMetalness = texture2D ( metalnessMap , vUv ) ;
metalnessFactor *= texelMetalness . b ;
# endif ` ,S5= ` # ifdef USE _METALNESSMAP
uniform sampler2D metalnessMap ;
# endif ` ,M5= ` # if defined ( USE _MORPHCOLORS ) && defined ( MORPHTARGETS _TEXTURE )
vColor *= morphTargetBaseInfluence ;
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
# if defined ( USE _COLOR _ALPHA )
if ( morphTargetInfluences [ i ] != 0.0 ) vColor += getMorph ( gl _VertexID , i , 2 ) * morphTargetInfluences [ i ] ;
# elif defined ( USE _COLOR )
if ( morphTargetInfluences [ i ] != 0.0 ) vColor += getMorph ( gl _VertexID , i , 2 ) . rgb * morphTargetInfluences [ i ] ;
# endif
}
# endif ` ,E5= ` # ifdef USE _MORPHNORMALS
objectNormal *= morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
if ( morphTargetInfluences [ i ] != 0.0 ) objectNormal += getMorph ( gl _VertexID , i , 1 ) . xyz * morphTargetInfluences [ i ] ;
}
# else
objectNormal += morphNormal0 * morphTargetInfluences [ 0 ] ;
objectNormal += morphNormal1 * morphTargetInfluences [ 1 ] ;
objectNormal += morphNormal2 * morphTargetInfluences [ 2 ] ;
objectNormal += morphNormal3 * morphTargetInfluences [ 3 ] ;
# endif
# endif ` ,T5= ` # ifdef USE _MORPHTARGETS
uniform float morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
uniform float morphTargetInfluences [ MORPHTARGETS _COUNT ] ;
uniform sampler2DArray morphTargetsTexture ;
uniform ivec2 morphTargetsTextureSize ;
vec4 getMorph ( const in int vertexIndex , const in int morphTargetIndex , const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS _TEXTURE _STRIDE + offset ;
int y = texelIndex / morphTargetsTextureSize . x ;
int x = texelIndex - y * morphTargetsTextureSize . x ;
ivec3 morphUV = ivec3 ( x , y , morphTargetIndex ) ;
return texelFetch ( morphTargetsTexture , morphUV , 0 ) ;
}
# else
# ifndef USE _MORPHNORMALS
uniform float morphTargetInfluences [ 8 ] ;
# else
uniform float morphTargetInfluences [ 4 ] ;
# endif
# endif
# endif ` ,A5= ` # ifdef USE _MORPHTARGETS
transformed *= morphTargetBaseInfluence ;
# ifdef MORPHTARGETS _TEXTURE
for ( int i = 0 ; i < MORPHTARGETS _COUNT ; i ++ ) {
if ( morphTargetInfluences [ i ] != 0.0 ) transformed += getMorph ( gl _VertexID , i , 0 ) . xyz * morphTargetInfluences [ i ] ;
}
# else
transformed += morphTarget0 * morphTargetInfluences [ 0 ] ;
transformed += morphTarget1 * morphTargetInfluences [ 1 ] ;
transformed += morphTarget2 * morphTargetInfluences [ 2 ] ;
transformed += morphTarget3 * morphTargetInfluences [ 3 ] ;
# ifndef USE _MORPHNORMALS
transformed += morphTarget4 * morphTargetInfluences [ 4 ] ;
transformed += morphTarget5 * morphTargetInfluences [ 5 ] ;
transformed += morphTarget6 * morphTargetInfluences [ 6 ] ;
transformed += morphTarget7 * morphTargetInfluences [ 7 ] ;
# endif
# endif
# endif ` ,C5= ` float faceDirection = gl _FrontFacing ? 1.0 : - 1.0 ;
# ifdef FLAT _SHADED
vec3 fdx = vec3 ( dFdx ( vViewPosition . x ) , dFdx ( vViewPosition . y ) , dFdx ( vViewPosition . z ) ) ;
vec3 fdy = vec3 ( dFdy ( vViewPosition . x ) , dFdy ( vViewPosition . y ) , dFdy ( vViewPosition . z ) ) ;
vec3 normal = normalize ( cross ( fdx , fdy ) ) ;
# else
vec3 normal = normalize ( vNormal ) ;
# ifdef DOUBLE _SIDED
normal = normal * faceDirection ;
# endif
# ifdef USE _TANGENT
vec3 tangent = normalize ( vTangent ) ;
vec3 bitangent = normalize ( vBitangent ) ;
# ifdef DOUBLE _SIDED
tangent = tangent * faceDirection ;
bitangent = bitangent * faceDirection ;
# endif
# if defined ( TANGENTSPACE _NORMALMAP ) || defined ( USE _CLEARCOAT _NORMALMAP )
mat3 vTBN = mat3 ( tangent , bitangent , normal ) ;
# endif
# endif
# endif
vec3 geometryNormal = normal ; ` ,P5= ` # ifdef OBJECTSPACE _NORMALMAP
normal = texture2D ( normalMap , vUv ) . xyz * 2.0 - 1.0 ;
# ifdef FLIP _SIDED
normal = - normal ;
# endif
# ifdef DOUBLE _SIDED
normal = normal * faceDirection ;
# endif
normal = normalize ( normalMatrix * normal ) ;
# elif defined ( TANGENTSPACE _NORMALMAP )
vec3 mapN = texture2D ( normalMap , vUv ) . xyz * 2.0 - 1.0 ;
mapN . xy *= normalScale ;
# ifdef USE _TANGENT
normal = normalize ( vTBN * mapN ) ;
# else
normal = perturbNormal2Arb ( - vViewPosition , normal , mapN , faceDirection ) ;
# endif
# elif defined ( USE _BUMPMAP )
normal = perturbNormalArb ( - vViewPosition , normal , dHdxy _fwd ( ) , faceDirection ) ;
# endif ` ,R5= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,L5= ` # ifndef FLAT _SHADED
varying vec3 vNormal ;
# ifdef USE _TANGENT
varying vec3 vTangent ;
varying vec3 vBitangent ;
# endif
# endif ` ,D5= ` # ifndef FLAT _SHADED
vNormal = normalize ( transformedNormal ) ;
# ifdef USE _TANGENT
vTangent = normalize ( transformedTangent ) ;
vBitangent = normalize ( cross ( vNormal , vTangent ) * tangent . w ) ;
# endif
# endif ` ,I5= ` # ifdef USE _NORMALMAP
uniform sampler2D normalMap ;
uniform vec2 normalScale ;
# endif
# ifdef OBJECTSPACE _NORMALMAP
uniform mat3 normalMatrix ;
# endif
# if ! defined ( USE _TANGENT ) && ( defined ( TANGENTSPACE _NORMALMAP ) || defined ( USE _CLEARCOAT _NORMALMAP ) )
vec3 perturbNormal2Arb ( vec3 eye _pos , vec3 surf _norm , vec3 mapN , float faceDirection ) {
vec3 q0 = vec3 ( dFdx ( eye _pos . x ) , dFdx ( eye _pos . y ) , dFdx ( eye _pos . z ) ) ;
vec3 q1 = vec3 ( dFdy ( eye _pos . x ) , dFdy ( eye _pos . y ) , dFdy ( eye _pos . z ) ) ;
vec2 st0 = dFdx ( vUv . st ) ;
vec2 st1 = dFdy ( vUv . st ) ;
vec3 N = surf _norm ;
vec3 q1perp = cross ( q1 , N ) ;
vec3 q0perp = cross ( N , q0 ) ;
vec3 T = q1perp * st0 . x + q0perp * st1 . x ;
vec3 B = q1perp * st0 . y + q0perp * st1 . y ;
float det = max ( dot ( T , T ) , dot ( B , B ) ) ;
float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt ( det ) ;
return normalize ( T * ( mapN . x * scale ) + B * ( mapN . y * scale ) + N * mapN . z ) ;
}
# endif ` ,O5= ` # ifdef USE _CLEARCOAT
vec3 clearcoatNormal = geometryNormal ;
# endif ` ,k5= ` # ifdef USE _CLEARCOAT _NORMALMAP
vec3 clearcoatMapN = texture2D ( clearcoatNormalMap , vUv ) . xyz * 2.0 - 1.0 ;
clearcoatMapN . xy *= clearcoatNormalScale ;
# ifdef USE _TANGENT
clearcoatNormal = normalize ( vTBN * clearcoatMapN ) ;
# else
clearcoatNormal = perturbNormal2Arb ( - vViewPosition , clearcoatNormal , clearcoatMapN , faceDirection ) ;
# endif
# endif ` ,N5= ` # ifdef USE _CLEARCOATMAP
uniform sampler2D clearcoatMap ;
# endif
# ifdef USE _CLEARCOAT _ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap ;
# endif
# ifdef USE _CLEARCOAT _NORMALMAP
uniform sampler2D clearcoatNormalMap ;
uniform vec2 clearcoatNormalScale ;
# endif ` ,B5= ` # ifdef OPAQUE
diffuseColor . a = 1.0 ;
# endif
# ifdef USE _TRANSMISSION
diffuseColor . a *= transmissionAlpha + 0.1 ;
# endif
gl _FragColor = vec4 ( outgoingLight , diffuseColor . a ) ; ` ,z5= ` vec3 packNormalToRGB ( const in vec3 normal ) {
return normalize ( normal ) * 0.5 + 0.5 ;
}
vec3 unpackRGBToNormal ( const in vec3 rgb ) {
return 2.0 * rgb . xyz - 1.0 ;
}
const float PackUpscale = 256. / 255. ; const float UnpackDownscale = 255. / 256. ;
const vec3 PackFactors = vec3 ( 256. * 256. * 256. , 256. * 256. , 256. ) ;
const vec4 UnpackFactors = UnpackDownscale / vec4 ( PackFactors , 1. ) ;
const float ShiftRight8 = 1. / 256. ;
vec4 packDepthToRGBA ( const in float v ) {
vec4 r = vec4 ( fract ( v * PackFactors ) , v ) ;
r . yzw -= r . xyz * ShiftRight8 ; return r * PackUpscale ;
}
float unpackRGBAToDepth ( const in vec4 v ) {
return dot ( v , UnpackFactors ) ;
}
vec4 pack2HalfToRGBA ( vec2 v ) {
vec4 r = vec4 ( v . x , fract ( v . x * 255.0 ) , v . y , fract ( v . y * 255.0 ) ) ;
return vec4 ( r . x - r . y / 255.0 , r . y , r . z - r . w / 255.0 , r . w ) ;
}
vec2 unpackRGBATo2Half ( vec4 v ) {
return vec2 ( v . x + ( v . y / 255.0 ) , v . z + ( v . w / 255.0 ) ) ;
}
float viewZToOrthographicDepth ( const in float viewZ , const in float near , const in float far ) {
return ( viewZ + near ) / ( near - far ) ;
}
float orthographicDepthToViewZ ( const in float linearClipZ , const in float near , const in float far ) {
return linearClipZ * ( near - far ) - near ;
}
float viewZToPerspectiveDepth ( const in float viewZ , const in float near , const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ) ;
}
float perspectiveDepthToViewZ ( const in float invClipZ , const in float near , const in float far ) {
return ( near * far ) / ( ( far - near ) * invClipZ - far ) ;
} ` ,U5= ` # ifdef PREMULTIPLIED _ALPHA
gl _FragColor . rgb *= gl _FragColor . a ;
# endif ` ,F5= ` vec4 mvPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _INSTANCING
mvPosition = instanceMatrix * mvPosition ;
# endif
mvPosition = modelViewMatrix * mvPosition ;
gl _Position = projectionMatrix * mvPosition ; ` ,V5= ` # ifdef DITHERING
gl _FragColor . rgb = dithering ( gl _FragColor . rgb ) ;
# endif ` ,H5= ` # ifdef DITHERING
vec3 dithering ( vec3 color ) {
float grid _position = rand ( gl _FragCoord . xy ) ;
vec3 dither _shift _RGB = vec3 ( 0.25 / 255.0 , - 0.25 / 255.0 , 0.25 / 255.0 ) ;
dither _shift _RGB = mix ( 2.0 * dither _shift _RGB , - 2.0 * dither _shift _RGB , grid _position ) ;
return color + dither _shift _RGB ;
}
# endif ` ,G5= ` float roughnessFactor = roughness ;
# ifdef USE _ROUGHNESSMAP
vec4 texelRoughness = texture2D ( roughnessMap , vUv ) ;
roughnessFactor *= texelRoughness . g ;
# endif ` ,W5= ` # ifdef USE _ROUGHNESSMAP
uniform sampler2D roughnessMap ;
# endif ` ,j5= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
uniform sampler2D directionalShadowMap [ NUM _DIR _LIGHT _SHADOWS ] ;
varying vec4 vDirectionalShadowCoord [ NUM _DIR _LIGHT _SHADOWS ] ;
struct DirectionalLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform DirectionalLightShadow directionalLightShadows [ NUM _DIR _LIGHT _SHADOWS ] ;
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
uniform sampler2D spotShadowMap [ NUM _SPOT _LIGHT _SHADOWS ] ;
varying vec4 vSpotShadowCoord [ NUM _SPOT _LIGHT _SHADOWS ] ;
struct SpotLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform SpotLightShadow spotLightShadows [ NUM _SPOT _LIGHT _SHADOWS ] ;
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
uniform sampler2D pointShadowMap [ NUM _POINT _LIGHT _SHADOWS ] ;
varying vec4 vPointShadowCoord [ NUM _POINT _LIGHT _SHADOWS ] ;
struct PointLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
float shadowCameraNear ;
float shadowCameraFar ;
} ;
uniform PointLightShadow pointLightShadows [ NUM _POINT _LIGHT _SHADOWS ] ;
# endif
float texture2DCompare ( sampler2D depths , vec2 uv , float compare ) {
return step ( compare , unpackRGBAToDepth ( texture2D ( depths , uv ) ) ) ;
}
vec2 texture2DDistribution ( sampler2D shadow , vec2 uv ) {
return unpackRGBATo2Half ( texture2D ( shadow , uv ) ) ;
}
float VSMShadow ( sampler2D shadow , vec2 uv , float compare ) {
float occlusion = 1.0 ;
vec2 distribution = texture2DDistribution ( shadow , uv ) ;
float hard _shadow = step ( compare , distribution . x ) ;
if ( hard _shadow != 1.0 ) {
float distance = compare - distribution . x ;
float variance = max ( 0.00000 , distribution . y * distribution . y ) ;
float softness _probability = variance / ( variance + distance * distance ) ; softness _probability = clamp ( ( softness _probability - 0.3 ) / ( 0.95 - 0.3 ) , 0.0 , 1.0 ) ; occlusion = clamp ( max ( hard _shadow , softness _probability ) , 0.0 , 1.0 ) ;
}
return occlusion ;
}
float getShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowBias , float shadowRadius , vec4 shadowCoord ) {
float shadow = 1.0 ;
shadowCoord . xyz /= shadowCoord . w ;
shadowCoord . z += shadowBias ;
bvec4 inFrustumVec = bvec4 ( shadowCoord . x >= 0.0 , shadowCoord . x <= 1.0 , shadowCoord . y >= 0.0 , shadowCoord . y <= 1.0 ) ;
bool inFrustum = all ( inFrustumVec ) ;
bvec2 frustumTestVec = bvec2 ( inFrustum , shadowCoord . z <= 1.0 ) ;
bool frustumTest = all ( frustumTestVec ) ;
if ( frustumTest ) {
# if defined ( SHADOWMAP _TYPE _PCF )
vec2 texelSize = vec2 ( 1.0 ) / shadowMapSize ;
float dx0 = - texelSize . x * shadowRadius ;
float dy0 = - texelSize . y * shadowRadius ;
float dx1 = + texelSize . x * shadowRadius ;
float dy1 = + texelSize . y * shadowRadius ;
float dx2 = dx0 / 2.0 ;
float dy2 = dy0 / 2.0 ;
float dx3 = dx1 / 2.0 ;
float dy3 = dy1 / 2.0 ;
shadow = (
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , dy0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , dy2 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx2 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx3 , dy3 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx0 , dy1 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( 0.0 , dy1 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , shadowCoord . xy + vec2 ( dx1 , dy1 ) , shadowCoord . z )
) * ( 1.0 / 17.0 ) ;
# elif defined ( SHADOWMAP _TYPE _PCF _SOFT )
vec2 texelSize = vec2 ( 1.0 ) / shadowMapSize ;
float dx = texelSize . x ;
float dy = texelSize . y ;
vec2 uv = shadowCoord . xy ;
vec2 f = fract ( uv * shadowMapSize + 0.5 ) ;
uv -= f * texelSize ;
shadow = (
texture2DCompare ( shadowMap , uv , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + vec2 ( dx , 0.0 ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , dy ) , shadowCoord . z ) +
texture2DCompare ( shadowMap , uv + texelSize , shadowCoord . z ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , 0.0 ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , 0.0 ) , shadowCoord . z ) ,
f . x ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , dy ) , shadowCoord . z ) ,
f . x ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 0.0 , 2.0 * dy ) , shadowCoord . z ) ,
f . y ) +
mix ( texture2DCompare ( shadowMap , uv + vec2 ( dx , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( dx , 2.0 * dy ) , shadowCoord . z ) ,
f . y ) +
mix ( mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , - dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , - dy ) , shadowCoord . z ) ,
f . x ) ,
mix ( texture2DCompare ( shadowMap , uv + vec2 ( - dx , 2.0 * dy ) , shadowCoord . z ) ,
texture2DCompare ( shadowMap , uv + vec2 ( 2.0 * dx , 2.0 * dy ) , shadowCoord . z ) ,
f . x ) ,
f . y )
) * ( 1.0 / 9.0 ) ;
# elif defined ( SHADOWMAP _TYPE _VSM )
shadow = VSMShadow ( shadowMap , shadowCoord . xy , shadowCoord . z ) ;
# else
shadow = texture2DCompare ( shadowMap , shadowCoord . xy , shadowCoord . z ) ;
# endif
}
return shadow ;
}
vec2 cubeToUV ( vec3 v , float texelSizeY ) {
vec3 absV = abs ( v ) ;
float scaleToCube = 1.0 / max ( absV . x , max ( absV . y , absV . z ) ) ;
absV *= scaleToCube ;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY ) ;
vec2 planar = v . xy ;
float almostATexel = 1.5 * texelSizeY ;
float almostOne = 1.0 - almostATexel ;
if ( absV . z >= almostOne ) {
if ( v . z > 0.0 )
planar . x = 4.0 - v . x ;
} else if ( absV . x >= almostOne ) {
float signX = sign ( v . x ) ;
planar . x = v . z * signX + 2.0 * signX ;
} else if ( absV . y >= almostOne ) {
float signY = sign ( v . y ) ;
planar . x = v . x + 2.0 * signY + 2.0 ;
planar . y = v . z * signY - 2.0 ;
}
return vec2 ( 0.125 , 0.25 ) * planar + vec2 ( 0.375 , 0.75 ) ;
}
float getPointShadow ( sampler2D shadowMap , vec2 shadowMapSize , float shadowBias , float shadowRadius , vec4 shadowCoord , float shadowCameraNear , float shadowCameraFar ) {
vec2 texelSize = vec2 ( 1.0 ) / ( shadowMapSize * vec2 ( 4.0 , 2.0 ) ) ;
vec3 lightToPosition = shadowCoord . xyz ;
float dp = ( length ( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ) ; dp += shadowBias ;
vec3 bd3D = normalize ( lightToPosition ) ;
# if defined ( SHADOWMAP _TYPE _PCF ) || defined ( SHADOWMAP _TYPE _PCF _SOFT ) || defined ( SHADOWMAP _TYPE _VSM )
vec2 offset = vec2 ( - 1 , 1 ) * shadowRadius * texelSize . y ;
return (
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xyy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yyy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xyx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yyx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xxy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yxy , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . xxx , texelSize . y ) , dp ) +
texture2DCompare ( shadowMap , cubeToUV ( bd3D + offset . yxx , texelSize . y ) , dp )
) * ( 1.0 / 9.0 ) ;
# else
return texture2DCompare ( shadowMap , cubeToUV ( bd3D , texelSize . y ) , dp ) ;
# endif
}
# endif ` ,X5= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
uniform mat4 directionalShadowMatrix [ NUM _DIR _LIGHT _SHADOWS ] ;
varying vec4 vDirectionalShadowCoord [ NUM _DIR _LIGHT _SHADOWS ] ;
struct DirectionalLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform DirectionalLightShadow directionalLightShadows [ NUM _DIR _LIGHT _SHADOWS ] ;
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
uniform mat4 spotShadowMatrix [ NUM _SPOT _LIGHT _SHADOWS ] ;
varying vec4 vSpotShadowCoord [ NUM _SPOT _LIGHT _SHADOWS ] ;
struct SpotLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
} ;
uniform SpotLightShadow spotLightShadows [ NUM _SPOT _LIGHT _SHADOWS ] ;
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
uniform mat4 pointShadowMatrix [ NUM _POINT _LIGHT _SHADOWS ] ;
varying vec4 vPointShadowCoord [ NUM _POINT _LIGHT _SHADOWS ] ;
struct PointLightShadow {
float shadowBias ;
float shadowNormalBias ;
float shadowRadius ;
vec2 shadowMapSize ;
float shadowCameraNear ;
float shadowCameraFar ;
} ;
uniform PointLightShadow pointLightShadows [ NUM _POINT _LIGHT _SHADOWS ] ;
# endif
# endif ` ,q5= ` # ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0 || NUM _SPOT _LIGHT _SHADOWS > 0 || NUM _POINT _LIGHT _SHADOWS > 0
vec3 shadowWorldNormal = inverseTransformDirection ( transformedNormal , viewMatrix ) ;
vec4 shadowWorldPosition ;
# endif
# if NUM _DIR _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * directionalLightShadows [ i ] . shadowNormalBias , 0 ) ;
vDirectionalShadowCoord [ i ] = directionalShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * spotLightShadows [ i ] . shadowNormalBias , 0 ) ;
vSpotShadowCoord [ i ] = spotShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHT _SHADOWS ; i ++ ) {
shadowWorldPosition = worldPosition + vec4 ( shadowWorldNormal * pointLightShadows [ i ] . shadowNormalBias , 0 ) ;
vPointShadowCoord [ i ] = pointShadowMatrix [ i ] * shadowWorldPosition ;
}
# pragma unroll _loop _end
# endif
# endif ` ,Y5= ` float getShadowMask ( ) {
float shadow = 1.0 ;
# ifdef USE _SHADOWMAP
# if NUM _DIR _LIGHT _SHADOWS > 0
DirectionalLightShadow directionalLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _DIR _LIGHT _SHADOWS ; i ++ ) {
directionalLight = directionalLightShadows [ i ] ;
shadow *= receiveShadow ? getShadow ( directionalShadowMap [ i ] , directionalLight . shadowMapSize , directionalLight . shadowBias , directionalLight . shadowRadius , vDirectionalShadowCoord [ i ] ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# if NUM _SPOT _LIGHT _SHADOWS > 0
SpotLightShadow spotLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _SPOT _LIGHT _SHADOWS ; i ++ ) {
spotLight = spotLightShadows [ i ] ;
shadow *= receiveShadow ? getShadow ( spotShadowMap [ i ] , spotLight . shadowMapSize , spotLight . shadowBias , spotLight . shadowRadius , vSpotShadowCoord [ i ] ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# if NUM _POINT _LIGHT _SHADOWS > 0
PointLightShadow pointLight ;
# pragma unroll _loop _start
for ( int i = 0 ; i < NUM _POINT _LIGHT _SHADOWS ; i ++ ) {
pointLight = pointLightShadows [ i ] ;
shadow *= receiveShadow ? getPointShadow ( pointShadowMap [ i ] , pointLight . shadowMapSize , pointLight . shadowBias , pointLight . shadowRadius , vPointShadowCoord [ i ] , pointLight . shadowCameraNear , pointLight . shadowCameraFar ) : 1.0 ;
}
# pragma unroll _loop _end
# endif
# endif
return shadow ;
} ` ,Z5= ` # ifdef USE _SKINNING
mat4 boneMatX = getBoneMatrix ( skinIndex . x ) ;
mat4 boneMatY = getBoneMatrix ( skinIndex . y ) ;
mat4 boneMatZ = getBoneMatrix ( skinIndex . z ) ;
mat4 boneMatW = getBoneMatrix ( skinIndex . w ) ;
# endif ` ,K5= ` # ifdef USE _SKINNING
uniform mat4 bindMatrix ;
uniform mat4 bindMatrixInverse ;
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 ;
}
# endif ` ,J5= ` # ifdef USE _SKINNING
vec4 skinVertex = bindMatrix * vec4 ( transformed , 1.0 ) ;
vec4 skinned = vec4 ( 0.0 ) ;
skinned += boneMatX * skinVertex * skinWeight . x ;
skinned += boneMatY * skinVertex * skinWeight . y ;
skinned += boneMatZ * skinVertex * skinWeight . z ;
skinned += boneMatW * skinVertex * skinWeight . w ;
transformed = ( bindMatrixInverse * skinned ) . xyz ;
# endif ` ,Q5= ` # ifdef USE _SKINNING
mat4 skinMatrix = mat4 ( 0.0 ) ;
skinMatrix += skinWeight . x * boneMatX ;
skinMatrix += skinWeight . y * boneMatY ;
skinMatrix += skinWeight . z * boneMatZ ;
skinMatrix += skinWeight . w * boneMatW ;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix ;
objectNormal = vec4 ( skinMatrix * vec4 ( objectNormal , 0.0 ) ) . xyz ;
# ifdef USE _TANGENT
objectTangent = vec4 ( skinMatrix * vec4 ( objectTangent , 0.0 ) ) . xyz ;
# endif
# endif ` , $ 5= ` float specularStrength ;
# ifdef USE _SPECULARMAP
vec4 texelSpecular = texture2D ( specularMap , vUv ) ;
specularStrength = texelSpecular . r ;
# else
specularStrength = 1.0 ;
# endif ` ,ek= ` # ifdef USE _SPECULARMAP
uniform sampler2D specularMap ;
# endif ` ,tk= ` # if defined ( TONE _MAPPING )
gl _FragColor . rgb = toneMapping ( gl _FragColor . rgb ) ;
# endif ` ,nk= ` # ifndef saturate
# define saturate ( a ) clamp ( a , 0.0 , 1.0 )
# endif
uniform float toneMappingExposure ;
vec3 LinearToneMapping ( vec3 color ) {
return toneMappingExposure * color ;
}
vec3 ReinhardToneMapping ( vec3 color ) {
color *= toneMappingExposure ;
return saturate ( color / ( vec3 ( 1.0 ) + color ) ) ;
}
vec3 OptimizedCineonToneMapping ( vec3 color ) {
color *= toneMappingExposure ;
color = max ( vec3 ( 0.0 ) , color - 0.004 ) ;
return pow ( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ) , vec3 ( 2.2 ) ) ;
}
vec3 RRTAndODTFit ( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537 ;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081 ;
return a / b ;
}
vec3 ACESFilmicToneMapping ( vec3 color ) {
const mat3 ACESInputMat = mat3 (
vec3 ( 0.59719 , 0.07600 , 0.02840 ) , vec3 ( 0.35458 , 0.90834 , 0.13383 ) ,
vec3 ( 0.04823 , 0.01566 , 0.83777 )
) ;
const mat3 ACESOutputMat = mat3 (
vec3 ( 1.60475 , - 0.10208 , - 0.00327 ) , vec3 ( - 0.53108 , 1.10813 , - 0.07276 ) ,
vec3 ( - 0.07367 , - 0.00605 , 1.07602 )
) ;
color *= toneMappingExposure / 0.6 ;
color = ACESInputMat * color ;
color = RRTAndODTFit ( color ) ;
color = ACESOutputMat * color ;
return saturate ( color ) ;
}
vec3 CustomToneMapping ( vec3 color ) { return color ; } ` ,ik= ` # ifdef USE _TRANSMISSION
float transmissionAlpha = 1.0 ;
float transmissionFactor = transmission ;
float thicknessFactor = thickness ;
# ifdef USE _TRANSMISSIONMAP
transmissionFactor *= texture2D ( transmissionMap , vUv ) . r ;
# endif
# ifdef USE _THICKNESSMAP
thicknessFactor *= texture2D ( thicknessMap , vUv ) . g ;
# endif
vec3 pos = vWorldPosition ;
vec3 v = normalize ( cameraPosition - pos ) ;
vec3 n = inverseTransformDirection ( normal , viewMatrix ) ;
vec4 transmission = getIBLVolumeRefraction (
n , v , roughnessFactor , material . diffuseColor , material . specularColor , material . specularF90 ,
pos , modelMatrix , viewMatrix , projectionMatrix , ior , thicknessFactor ,
attenuationColor , attenuationDistance ) ;
totalDiffuse = mix ( totalDiffuse , transmission . rgb , transmissionFactor ) ;
transmissionAlpha = mix ( transmissionAlpha , transmission . a , transmissionFactor ) ;
# endif ` ,rk= ` # ifdef USE _TRANSMISSION
uniform float transmission ;
uniform float thickness ;
uniform float attenuationDistance ;
uniform vec3 attenuationColor ;
# ifdef USE _TRANSMISSIONMAP
uniform sampler2D transmissionMap ;
# endif
# ifdef USE _THICKNESSMAP
uniform sampler2D thicknessMap ;
# endif
uniform vec2 transmissionSamplerSize ;
uniform sampler2D transmissionSamplerMap ;
uniform mat4 modelMatrix ;
uniform mat4 projectionMatrix ;
varying vec3 vWorldPosition ;
vec3 getVolumeTransmissionRay ( const in vec3 n , const in vec3 v , const in float thickness , const in float ior , const in mat4 modelMatrix ) {
vec3 refractionVector = refract ( - v , normalize ( n ) , 1.0 / ior ) ;
vec3 modelScale ;
modelScale . x = length ( vec3 ( modelMatrix [ 0 ] . xyz ) ) ;
modelScale . y = length ( vec3 ( modelMatrix [ 1 ] . xyz ) ) ;
modelScale . z = length ( vec3 ( modelMatrix [ 2 ] . xyz ) ) ;
return normalize ( refractionVector ) * thickness * modelScale ;
}
float applyIorToRoughness ( const in float roughness , const in float ior ) {
return roughness * clamp ( ior * 2.0 - 2.0 , 0.0 , 1.0 ) ;
}
vec4 getTransmissionSample ( const in vec2 fragCoord , const in float roughness , const in float ior ) {
float framebufferLod = log2 ( transmissionSamplerSize . x ) * applyIorToRoughness ( roughness , ior ) ;
# ifdef texture2DLodEXT
return texture2DLodEXT ( transmissionSamplerMap , fragCoord . xy , framebufferLod ) ;
# else
return texture2D ( transmissionSamplerMap , fragCoord . xy , framebufferLod ) ;
# endif
}
vec3 applyVolumeAttenuation ( const in vec3 radiance , const in float transmissionDistance , const in vec3 attenuationColor , const in float attenuationDistance ) {
if ( attenuationDistance == 0.0 ) {
return radiance ;
} else {
vec3 attenuationCoefficient = - log ( attenuationColor ) / attenuationDistance ;
vec3 transmittance = exp ( - attenuationCoefficient * transmissionDistance ) ; return transmittance * radiance ;
}
}
vec4 getIBLVolumeRefraction ( const in vec3 n , const in vec3 v , const in float roughness , const in vec3 diffuseColor ,
const in vec3 specularColor , const in float specularF90 , const in vec3 position , const in mat4 modelMatrix ,
const in mat4 viewMatrix , const in mat4 projMatrix , const in float ior , const in float thickness ,
const in vec3 attenuationColor , const in float attenuationDistance ) {
vec3 transmissionRay = getVolumeTransmissionRay ( n , v , thickness , ior , modelMatrix ) ;
vec3 refractedRayExit = position + transmissionRay ;
vec4 ndcPos = projMatrix * viewMatrix * vec4 ( refractedRayExit , 1.0 ) ;
vec2 refractionCoords = ndcPos . xy / ndcPos . w ;
refractionCoords += 1.0 ;
refractionCoords /= 2.0 ;
vec4 transmittedLight = getTransmissionSample ( refractionCoords , roughness , ior ) ;
vec3 attenuatedColor = applyVolumeAttenuation ( transmittedLight . rgb , length ( transmissionRay ) , attenuationColor , attenuationDistance ) ;
vec3 F = EnvironmentBRDF ( n , v , specularColor , specularF90 , roughness ) ;
return vec4 ( ( 1.0 - F ) * attenuatedColor * diffuseColor , transmittedLight . a ) ;
}
# endif ` ,sk= ` # if ( defined ( USE _UV ) && ! defined ( UVS _VERTEX _ONLY ) )
varying vec2 vUv ;
# endif ` ,ok= ` # ifdef USE _UV
# ifdef UVS _VERTEX _ONLY
vec2 vUv ;
# else
varying vec2 vUv ;
# endif
uniform mat3 uvTransform ;
# endif ` ,ak= ` # ifdef USE _UV
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
# endif ` ,lk= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
varying vec2 vUv2 ;
# endif ` ,ck= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
attribute vec2 uv2 ;
varying vec2 vUv2 ;
uniform mat3 uv2Transform ;
# endif ` ,uk= ` # if defined ( USE _LIGHTMAP ) || defined ( USE _AOMAP )
vUv2 = ( uv2Transform * vec3 ( uv2 , 1 ) ) . xy ;
# endif ` ,hk= ` # if defined ( USE _ENVMAP ) || defined ( DISTANCE ) || defined ( USE _SHADOWMAP ) || defined ( USE _TRANSMISSION )
vec4 worldPosition = vec4 ( transformed , 1.0 ) ;
# ifdef USE _INSTANCING
worldPosition = instanceMatrix * worldPosition ;
# endif
worldPosition = modelMatrix * worldPosition ;
# endif ` ;const dk= ` varying vec2 vUv ;
uniform mat3 uvTransform ;
void main ( ) {
vUv = ( uvTransform * vec3 ( uv , 1 ) ) . xy ;
gl _Position = vec4 ( position . xy , 1.0 , 1.0 ) ;
} ` ,pk= ` uniform sampler2D t2D ;
varying vec2 vUv ;
void main ( ) {
gl _FragColor = texture2D ( t2D , vUv ) ;
# ifdef DECODE _VIDEO _TEXTURE
gl _FragColor = vec4 ( mix ( pow ( gl _FragColor . rgb * 0.9478672986 + vec3 ( 0.0521327014 ) , vec3 ( 2.4 ) ) , gl _FragColor . rgb * 0.0773993808 , vec3 ( lessThanEqual ( gl _FragColor . rgb , vec3 ( 0.04045 ) ) ) ) , gl _FragColor . w ) ;
# endif
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,fk= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
gl _Position . z = gl _Position . w ;
} ` ,mk= ` # include < envmap _common _pars _fragment >
uniform float opacity ;
varying vec3 vWorldDirection ;
# include < cube _uv _reflection _fragment >
void main ( ) {
vec3 vReflect = vWorldDirection ;
# include < envmap _fragment >
gl _FragColor = envColor ;
gl _FragColor . a *= opacity ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,vk= ` # include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
varying vec2 vHighPrecisionZW ;
void main ( ) {
# include < uv _vertex >
# include < skinbase _vertex >
# ifdef USE _DISPLACEMENTMAP
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinnormal _vertex >
# endif
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
vHighPrecisionZW = gl _Position . zw ;
} ` ,gk= ` # if DEPTH _PACKING == 3200
uniform float opacity ;
# endif
# include < common >
# include < packing >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
varying vec2 vHighPrecisionZW ;
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( 1.0 ) ;
# if DEPTH _PACKING == 3200
diffuseColor . a = opacity ;
# endif
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < logdepthbuf _fragment >
float fragCoordZ = 0.5 * vHighPrecisionZW [ 0 ] / vHighPrecisionZW [ 1 ] + 0.5 ;
# if DEPTH _PACKING == 3200
gl _FragColor = vec4 ( vec3 ( 1.0 - fragCoordZ ) , opacity ) ;
# elif DEPTH _PACKING == 3201
gl _FragColor = packDepthToRGBA ( fragCoordZ ) ;
# endif
} ` ,yk= ` # define DISTANCE
varying vec3 vWorldPosition ;
# include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < skinbase _vertex >
# ifdef USE _DISPLACEMENTMAP
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinnormal _vertex >
# endif
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < worldpos _vertex >
# include < clipping _planes _vertex >
vWorldPosition = worldPosition . xyz ;
} ` ,_k= ` # define DISTANCE
uniform vec3 referencePosition ;
uniform float nearDistance ;
uniform float farDistance ;
varying vec3 vWorldPosition ;
# include < common >
# include < packing >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( 1.0 ) ;
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
float dist = length ( vWorldPosition - referencePosition ) ;
dist = ( dist - nearDistance ) / ( farDistance - nearDistance ) ;
dist = saturate ( dist ) ;
gl _FragColor = packDepthToRGBA ( dist ) ;
} ` ,xk= ` varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vWorldDirection = transformDirection ( position , modelMatrix ) ;
# include < begin _vertex >
# include < project _vertex >
} ` ,bk= ` uniform sampler2D tEquirect ;
varying vec3 vWorldDirection ;
# include < common >
void main ( ) {
vec3 direction = normalize ( vWorldDirection ) ;
vec2 sampleUV = equirectUv ( direction ) ;
gl _FragColor = texture2D ( tEquirect , sampleUV ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` ,wk= ` uniform float scale ;
attribute float lineDistance ;
varying float vLineDistance ;
# include < common >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
vLineDistance = scale * lineDistance ;
# include < color _vertex >
# include < morphcolor _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < fog _vertex >
} ` ,Sk= ` uniform vec3 diffuse ;
uniform float opacity ;
uniform float dashSize ;
uniform float totalSize ;
varying float vLineDistance ;
# include < common >
# include < color _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
if ( mod ( vLineDistance , totalSize ) > dashSize ) {
discard ;
}
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < color _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
} ` ,Mk= ` # include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < envmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < morphcolor _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 >
} ` ,Ek= ` uniform vec3 diffuse ;
uniform float opacity ;
# ifndef FLAT _SHADED
varying vec3 vNormal ;
# endif
# include < common >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < fog _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
# ifdef USE _LIGHTMAP
vec4 lightMapTexel = texture2D ( lightMap , vUv2 ) ;
reflectedLight . indirectDiffuse += lightMapTexel . rgb * lightMapIntensity * RECIPROCAL _PI ;
# 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 >
} ` ,Tk= ` # define LAMBERT
varying vec3 vLightFront ;
varying vec3 vIndirectFront ;
# ifdef DOUBLE _SIDED
varying vec3 vLightBack ;
varying vec3 vIndirectBack ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < envmap _pars _vertex >
# include < bsdfs >
# include < lights _pars _begin >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < morphcolor _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 >
} ` ,Ak= ` uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
varying vec3 vLightFront ;
varying vec3 vIndirectFront ;
# ifdef DOUBLE _SIDED
varying vec3 vLightBack ;
varying vec3 vIndirectBack ;
# endif
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < fog _pars _fragment >
# include < shadowmap _pars _fragment >
# include < shadowmask _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
# include < emissivemap _fragment >
# ifdef DOUBLE _SIDED
reflectedLight . indirectDiffuse += ( gl _FrontFacing ) ? vIndirectFront : vIndirectBack ;
# else
reflectedLight . indirectDiffuse += vIndirectFront ;
# endif
# include < lightmap _fragment >
reflectedLight . indirectDiffuse *= BRDF _Lambert ( diffuseColor . rgb ) ;
# ifdef DOUBLE _SIDED
reflectedLight . directDiffuse = ( gl _FrontFacing ) ? vLightFront : vLightBack ;
# else
reflectedLight . directDiffuse = vLightFront ;
# endif
reflectedLight . directDiffuse *= BRDF _Lambert ( diffuseColor . rgb ) * getShadowMask ( ) ;
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + totalEmissiveRadiance ;
# include < envmap _fragment >
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,Ck= ` # define MATCAP
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < color _pars _vertex >
# include < displacementmap _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < color _vertex >
# include < morphcolor _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 ;
} ` ,Pk= ` # define MATCAP
uniform vec3 diffuse ;
uniform float opacity ;
uniform sampler2D matcap ;
varying vec3 vViewPosition ;
# include < common >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < normal _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
vec3 viewDir = normalize ( vViewPosition ) ;
vec3 x = normalize ( vec3 ( viewDir . z , 0.0 , - viewDir . x ) ) ;
vec3 y = cross ( viewDir , x ) ;
vec2 uv = vec2 ( dot ( x , normal ) , dot ( y , normal ) ) * 0.495 + 0.5 ;
# ifdef USE _MATCAP
vec4 matcapColor = texture2D ( matcap , uv ) ;
# else
vec4 matcapColor = vec4 ( vec3 ( mix ( 0.2 , 0.8 , uv . y ) ) , 1.0 ) ;
# endif
vec3 outgoingLight = diffuseColor . rgb * matcapColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,Rk= ` # define NORMAL
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
varying vec3 vViewPosition ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < displacementmap _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < normal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < displacementmap _vertex >
# include < project _vertex >
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
vViewPosition = - mvPosition . xyz ;
# endif
} ` ,Lk= ` # define NORMAL
uniform float opacity ;
# if defined ( FLAT _SHADED ) || defined ( USE _BUMPMAP ) || defined ( TANGENTSPACE _NORMALMAP )
varying vec3 vViewPosition ;
# endif
# include < packing >
# include < uv _pars _fragment >
# include < normal _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
# include < logdepthbuf _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
gl _FragColor = vec4 ( packNormalToRGB ( normal ) , opacity ) ;
# ifdef OPAQUE
gl _FragColor . a = 1.0 ;
# endif
} ` ,Dk= ` # define PHONG
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < envmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < morphcolor _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 >
} ` ,Ik= ` # define PHONG
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform vec3 specular ;
uniform float shininess ;
uniform float opacity ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _pars _fragment >
# include < cube _uv _reflection _fragment >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _phong _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < specularmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < specularmap _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _phong _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + reflectedLight . directSpecular + reflectedLight . indirectSpecular + totalEmissiveRadiance ;
# include < envmap _fragment >
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,Ok= ` # define STANDARD
varying vec3 vViewPosition ;
# ifdef USE _TRANSMISSION
varying vec3 vWorldPosition ;
# endif
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < morphcolor _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
} ` ,kk= ` # define STANDARD
# ifdef PHYSICAL
# define IOR
# define SPECULAR
# endif
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float roughness ;
uniform float metalness ;
uniform float opacity ;
# ifdef IOR
uniform float ior ;
# endif
# ifdef SPECULAR
uniform float specularIntensity ;
uniform vec3 specularColor ;
# ifdef USE _SPECULARINTENSITYMAP
uniform sampler2D specularIntensityMap ;
# endif
# ifdef USE _SPECULARCOLORMAP
uniform sampler2D specularColorMap ;
# endif
# endif
# ifdef USE _CLEARCOAT
uniform float clearcoat ;
uniform float clearcoatRoughness ;
# endif
# ifdef USE _SHEEN
uniform vec3 sheenColor ;
uniform float sheenRoughness ;
# ifdef USE _SHEENCOLORMAP
uniform sampler2D sheenColorMap ;
# endif
# ifdef USE _SHEENROUGHNESSMAP
uniform sampler2D sheenRoughnessMap ;
# endif
# endif
varying vec3 vViewPosition ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < bsdfs >
# include < cube _uv _reflection _fragment >
# include < envmap _common _pars _fragment >
# include < envmap _physical _pars _fragment >
# include < fog _pars _fragment >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _physical _pars _fragment >
# include < transmission _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < clearcoat _pars _fragment >
# include < roughnessmap _pars _fragment >
# include < metalnessmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < roughnessmap _fragment >
# include < metalnessmap _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < clearcoat _normal _fragment _begin >
# include < clearcoat _normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _physical _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 totalDiffuse = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse ;
vec3 totalSpecular = reflectedLight . directSpecular + reflectedLight . indirectSpecular ;
# include < transmission _fragment >
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance ;
# ifdef USE _SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3 ( material . sheenColor ) ;
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular ;
# endif
# ifdef USE _CLEARCOAT
float dotNVcc = saturate ( dot ( geometry . clearcoatNormal , geometry . viewDir ) ) ;
vec3 Fcc = F _Schlick ( material . clearcoatF0 , material . clearcoatF90 , dotNVcc ) ;
outgoingLight = outgoingLight * ( 1.0 - material . clearcoat * Fcc ) + clearcoatSpecular * material . clearcoat ;
# endif
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,Nk= ` # define TOON
varying vec3 vViewPosition ;
# include < common >
# include < uv _pars _vertex >
# include < uv2 _pars _vertex >
# include < displacementmap _pars _vertex >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < normal _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
# include < uv2 _vertex >
# include < color _vertex >
# include < morphcolor _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 >
} ` ,Bk= ` # define TOON
uniform vec3 diffuse ;
uniform vec3 emissive ;
uniform float opacity ;
# include < common >
# include < packing >
# include < dithering _pars _fragment >
# include < color _pars _fragment >
# include < uv _pars _fragment >
# include < uv2 _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < aomap _pars _fragment >
# include < lightmap _pars _fragment >
# include < emissivemap _pars _fragment >
# include < gradientmap _pars _fragment >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < normal _pars _fragment >
# include < lights _toon _pars _fragment >
# include < shadowmap _pars _fragment >
# include < bumpmap _pars _fragment >
# include < normalmap _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
ReflectedLight reflectedLight = ReflectedLight ( vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) , vec3 ( 0.0 ) ) ;
vec3 totalEmissiveRadiance = emissive ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < color _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
# include < normal _fragment _begin >
# include < normal _fragment _maps >
# include < emissivemap _fragment >
# include < lights _toon _fragment >
# include < lights _fragment _begin >
# include < lights _fragment _maps >
# include < lights _fragment _end >
# include < aomap _fragment >
vec3 outgoingLight = reflectedLight . directDiffuse + reflectedLight . indirectDiffuse + totalEmissiveRadiance ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
# include < dithering _fragment >
} ` ,zk= ` uniform float size ;
uniform float scale ;
# include < common >
# include < color _pars _vertex >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < color _vertex >
# include < morphcolor _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 >
} ` ,Uk= ` uniform vec3 diffuse ;
uniform float opacity ;
# include < common >
# include < color _pars _fragment >
# include < map _particle _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _particle _fragment >
# include < color _fragment >
# include < alphatest _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
# include < premultiplied _alpha _fragment >
} ` ,Fk= ` # include < common >
# include < fog _pars _vertex >
# include < morphtarget _pars _vertex >
# include < skinning _pars _vertex >
# include < shadowmap _pars _vertex >
void main ( ) {
# include < beginnormal _vertex >
# include < morphnormal _vertex >
# include < skinbase _vertex >
# include < skinnormal _vertex >
# include < defaultnormal _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < project _vertex >
# include < worldpos _vertex >
# include < shadowmap _vertex >
# include < fog _vertex >
} ` ,Vk= ` uniform vec3 color ;
uniform float opacity ;
# include < common >
# include < packing >
# include < fog _pars _fragment >
# include < bsdfs >
# include < lights _pars _begin >
# include < shadowmap _pars _fragment >
# include < shadowmask _pars _fragment >
void main ( ) {
gl _FragColor = vec4 ( color , opacity * ( 1.0 - getShadowMask ( ) ) ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
} ` ,Hk= ` uniform float rotation ;
uniform vec2 center ;
# include < common >
# include < uv _pars _vertex >
# include < fog _pars _vertex >
# include < logdepthbuf _pars _vertex >
# include < clipping _planes _pars _vertex >
void main ( ) {
# include < uv _vertex >
vec4 mvPosition = modelViewMatrix * vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
vec2 scale ;
scale . x = length ( vec3 ( modelMatrix [ 0 ] . x , modelMatrix [ 0 ] . y , modelMatrix [ 0 ] . z ) ) ;
scale . y = length ( vec3 ( modelMatrix [ 1 ] . x , modelMatrix [ 1 ] . y , modelMatrix [ 1 ] . z ) ) ;
# ifndef USE _SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix ( projectionMatrix ) ;
if ( isPerspective ) scale *= - mvPosition . z ;
# endif
vec2 alignedPosition = ( position . xy - ( center - vec2 ( 0.5 ) ) ) * scale ;
vec2 rotatedPosition ;
rotatedPosition . x = cos ( rotation ) * alignedPosition . x - sin ( rotation ) * alignedPosition . y ;
rotatedPosition . y = sin ( rotation ) * alignedPosition . x + cos ( rotation ) * alignedPosition . y ;
mvPosition . xy += rotatedPosition ;
gl _Position = projectionMatrix * mvPosition ;
# include < logdepthbuf _vertex >
# include < clipping _planes _vertex >
# include < fog _vertex >
} ` ,Gk= ` uniform vec3 diffuse ;
uniform float opacity ;
# include < common >
# include < uv _pars _fragment >
# include < map _pars _fragment >
# include < alphamap _pars _fragment >
# include < alphatest _pars _fragment >
# include < fog _pars _fragment >
# include < logdepthbuf _pars _fragment >
# include < clipping _planes _pars _fragment >
void main ( ) {
# include < clipping _planes _fragment >
vec3 outgoingLight = vec3 ( 0.0 ) ;
vec4 diffuseColor = vec4 ( diffuse , opacity ) ;
# include < logdepthbuf _fragment >
# include < map _fragment >
# include < alphamap _fragment >
# include < alphatest _fragment >
outgoingLight = diffuseColor . rgb ;
# include < output _fragment >
# include < tonemapping _fragment >
# include < encodings _fragment >
# include < fog _fragment >
} ` ,Gt={alphamap_fragment:gO,alphamap_pars_fragment:yO,alphatest_fragment:_O,alphatest_pars_fragment:xO,aomap_fragment:bO,aomap_pars_fragment:wO,begin_vertex:SO,beginnormal_vertex:MO,bsdfs:EO,bumpmap_pars_fragment:TO,clipping_planes_fragment:AO,clipping_planes_pars_fragment:CO,clipping_planes_pars_vertex:PO,clipping_planes_vertex:RO,color_fragment:LO,color_pars_fragment:DO,color_pars_vertex:IO,color_vertex:OO,common:kO,cube_uv_reflection_fragment:NO,defaultnormal_vertex:BO,displacementmap_pars_vertex:zO,displacementmap_vertex:UO,emissivemap_fragment:FO,emissivemap_pars_fragment:VO,encodings_fragment:HO,encodings_pars_fragment:GO,envmap_fragment:WO,envmap_common_pars_fragment:jO,envmap_pars_fragment:XO,envmap_pars_vertex:qO,envmap_physical_pars_fragment:r5,envmap_vertex:YO,fog_vertex:ZO,fog_pars_vertex:KO,fog_fragment:JO,fog_pars_fragment:QO,gradientmap_pars_fragment: $ O,lightmap_fragment:e5,lightmap_pars_fragment:t5,lights_lambert_vertex:n5,lights_pars_begin:i5,lights_toon_fragment:s5,lights_toon_pars_fragment:o5,lights_phong_fragment:a5,lights_phong_pars_fragment:l5,lights_physical_fragment:c5,lights_physical_pars_fragment:u5,lights_fragment_begin:h5,lights_fragment_maps:d5,lights_fragment_end:p5,logdepthbuf_fragment:f5,logdepthbuf_pars_fragment:m5,logdepthbuf_pars_vertex:v5,logdepthbuf_vertex:g5,map_fragment:y5,map_pars_fragment:_5,map_particle_fragment:x5,map_particle_pars_fragment:b5,metalnessmap_fragment:w5,metalnessmap_pars_fragment:S5,morphcolor_vertex:M5,morphnormal_vertex:E5,morphtarget_pars_vertex:T5,morphtarget_vertex:A5,normal_fragment_begin:C5,normal_fragment_maps:P5,normal_pars_fragment:R5,normal_pars_vertex:L5,normal_vertex:D5,normalmap_pars_fragment:I5,clearcoat_normal_fragment_begin:O5,clearcoat_normal_fragment_maps:k5,clearcoat_pars_fragment:N5,output_fragment:B5,packing:z5,premultiplied_alpha_fragment:U5,project_vertex:F5,dithering_fragment:V5,dithering_pars_fragment:H5,roughnessmap_fragment:G5,roughnessmap_pars_fragment:W5,shadowmap_pars_fragment:j5,shadowmap_pars_vertex:X5,shadowmap_vertex:q5,shadowmask_pars_fragment:Y5,skinbase_vertex:Z5,skinning_pars_vertex:K5,skinning_vertex:J5,skinnormal_vertex:Q5,specularmap_fragment: $ 5,specularmap_pars_fragment:ek,tonemapping_fragment:tk,tonemapping_pars_fragment:nk,transmission_fragment:ik,transmission_pars_fragment:rk,uv_pars_fragment:sk,uv_pars_vertex:ok,uv_vertex:ak,uv2_pars_fragment:lk,uv2_pars_vertex:ck,uv2_vertex:uk,worldpos_vertex:hk,background_vert:dk,background_frag:pk,cube_vert:fk,cube_frag:mk,depth_vert:vk,depth_frag:gk,distanceRGBA_vert:yk,distanceRGBA_frag:_k,equirect_vert:xk,equirect_frag:bk,linedashed_vert:wk,linedashed_frag:Sk,meshbasic_vert:Mk,meshbasic_frag:Ek,meshlambert_vert:Tk,meshlambert_frag:Ak,meshmatcap_vert:Ck,meshmatcap_frag:Pk,meshnormal_vert:Rk,meshnormal_frag:Lk,meshphong_vert:Dk,meshphong_frag:Ik,meshphysical_vert:Ok,meshphysical_frag:kk,meshtoon_vert:Nk,meshtoon_frag:Bk,points_vert:zk,points_frag:Uk,shadow_vert:Fk,shadow_frag:Vk,sprite_vert:Hk,sprite_frag:Gk},He={common:{diffuse:{value:new Pe(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new Gn},uv2Transform:{value:new Gn},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 ae(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 Pe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],prop
precision mediump float ;
precision mediump int ;
varying vec3 vOutputDirection ;
uniform sampler2D envMap ;
uniform int samples ;
uniform float weights [ n ] ;
uniform bool latitudinal ;
uniform float dTheta ;
uniform float mipInt ;
uniform vec3 poleAxis ;
# define ENVMAP _TYPE _CUBE _UV
# include < cube _uv _reflection _fragment >
vec3 getSample ( float theta , vec3 axis ) {
float cosTheta = cos ( theta ) ;
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross ( axis , vOutputDirection ) * sin ( theta )
+ axis * dot ( axis , vOutputDirection ) * ( 1.0 - cosTheta ) ;
return bilinearCubeUV ( envMap , sampleDirection , mipInt ) ;
}
void main ( ) {
vec3 axis = latitudinal ? poleAxis : cross ( poleAxis , vOutputDirection ) ;
if ( all ( equal ( axis , vec3 ( 0.0 ) ) ) ) {
axis = vec3 ( vOutputDirection . z , 0.0 , - vOutputDirection . x ) ;
}
axis = normalize ( axis ) ;
gl _FragColor = vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ) ;
gl _FragColor . rgb += weights [ 0 ] * getSample ( 0.0 , axis ) ;
for ( int i = 1 ; i < n ; i ++ ) {
if ( i >= samples ) {
break ;
}
float theta = dTheta * float ( i ) ;
gl _FragColor . rgb += weights [ i ] * getSample ( - 1.0 * theta , axis ) ;
gl _FragColor . rgb += weights [ i ] * getSample ( theta , axis ) ;
}
}
` ,blending:rn,depthTest:!1,depthWrite:!1})}function Z1(){return new kt({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:ax(),fragmentShader: `
precision mediump float ;
precision mediump int ;
varying vec3 vOutputDirection ;
uniform sampler2D envMap ;
# include < common >
void main ( ) {
vec3 outputDirection = normalize ( vOutputDirection ) ;
vec2 uv = equirectUv ( outputDirection ) ;
gl _FragColor = vec4 ( texture2D ( envMap , uv ) . rgb , 1.0 ) ;
}
` ,blending:rn,depthTest:!1,depthWrite:!1})}function K1(){return new kt({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:ax(),fragmentShader: `
precision mediump float ;
precision mediump int ;
uniform float flipEnvMap ;
varying vec3 vOutputDirection ;
uniform samplerCube envMap ;
void main ( ) {
gl _FragColor = textureCube ( envMap , vec3 ( flipEnvMap * vOutputDirection . x , vOutputDirection . yz ) ) ;
}
` ,blending:rn,depthTest:!1,depthWrite:!1})}function ax(){return `
precision mediump float ;
precision mediump int ;
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 Qk(i){let e=new WeakMap,t=null;function n(l){if(l&&l.isTexture){const h=l.mapping,d=h===kh||h===Gy,f=h===Vc||h===Hc;if(d||f)if(l.isRenderTargetTexture&&l.needsPMREMUpdate===!0){l.needsPMREMUpdate=!1;let g=e.get(l);return t===null&&(t=new q1(i)),g=d?t.fromEquirectangular(l,g):t.fromCubemap(l,g),e.set(l,g),g.texture}else{if(e.has(l))return e.get(l).texture;{const g=l.image;if(d&&g&&g.height>0||f&&g&&r(g)){t===null&&(t=new q1(i));const y=d?t.fromEquirectangular(l):t.fromCubemap(l);return e.set(l,y),l.addEventListener("dispose",s),y.texture}else return null}}}return l}function r(l){let h=0;const d=6;for(let f=0;f<d;f++)l[f]!==void 0&&h++;return h===d}function s(l){const h=l.target;h.removeEventListener("dispose",s);const d=e.get(h);d!==void 0&&(e.delete(h),d.dispose())}function o(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:o}}function $ k(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:r=i.getExtension(n)}return e[n]=r,r}return{has:function(n){return t(n)!==null},init:function(n){n.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(n){const r=t(n);return r===null&&console.warn("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function eN(i,e,t,n){const r={},s=new WeakMap;function o(g){const y=g.target;y.index!==null&&e.remove(y.index);for(const w in y.attributes)e.remove(y.attributes[w]);y.removeEventListener("dispose",o),delete r[y.id];const _=s.get(y);_&&(e.remove(_),s.delete(y)),n.releaseStatesOfGeometry(y),y.isInstancedBufferGeometry===!0&&delete y._maxInstanceCount,t.memory.geometries--}function l(g,y){return r[y.id]===!0||(y.addEventListener("dispose",o),r[y.id]=!0,t.memory.geometries++),y}function h(g){const y=g.attributes;for(const w in y)e.update(y[w],34962);const _=g.morphAttributes;for(const w in _){const S=_[w];for(let b=0,T=S.length;b<T;b++)e.update(S[b],34962)}}function d(g){const y=[],_=g.index,w=g.attributes.position;let S=0;if(_!==null){const E=_.array;S=_.version;for(let C=0,A=E.length;C<A;C+=3){const D=E[C+0],I=E[C+1],F=E[C+2];y.push(D,I,I,F,F,D)}}else{const E=w.array;S=w.version;for(let C=0,A=E.length/3-1;C<A;C+=3){const D=C+0,I=C+1,F=C+2;y.push(D,I,I,F,F,D)}}const b=new(HE(y)?jE:WE)(y,1);b.version=S;const T=s.get(g);T&&e.remove(T),s.set(g,b)}function f(g){const y=s.get(g);if(y){const _=g.index;_!==null&&y.version<_.version&&d(g)}else d(g);return s.get(g)}return{get:l,update:h,getWireframeAttribute:f}}function tN(i,e,t,n){const r=n.isWebGL2;let s;function o(y){s=y}let l,h;function d(y){l=y.type,h=y.bytesPerElement}function f(y,_){i.drawElements(s,_,l,y*h),t.update(_,s,1)}function g(y,_,w){if(w===0)return;let S,b;if(r)S=i,b="drawElementsInstanced";else if(S=e.get("ANGLE_instanced_arrays"),b="drawElementsInstancedANGLE",S===null){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}S[b](s,_,l,y*h,w),t.update(_,s,w)}this.setMode=o,this.setIndex=d,this.render=f,this.renderInstances=g}function nN(i){
` ),n=[],r=Math.max(e-6,0),s=Math.min(e+6,t.length);for(let o=r;o<s;o++)n.push(o+1+": "+t[o]);return n.join( `
` )}function QN(i){switch(i){case Ds:return["Linear","( value )"];case Ln:return["sRGB","( value )"];default:return console.warn("THREE.WebGLProgram: Unsupported encoding:",i),["Linear","( value )"]}}function rS(i,e,t){const n=i.getShaderParameter(e,35713),r=i.getShaderInfoLog(e).trim();if(n&&r==="")return"";const s=/ERROR: 0:( \d +)/.exec(r);if(s){const o=parseInt(s[0]);return t.toUpperCase()+ `
` +r+ `
` +JN(i.getShaderSource(e),o)}else return r}function $ N(i,e){const t=QN(e);return"vec4 "+i+"( vec4 value ) { return LinearTo"+t[0]+t[1]+"; }"}function eB(i,e){let t;switch(e){case BE:t="Linear";break;case dI:t="Reinhard";break;case pI:t="OptimizedCineon";break;case fI:t="ACESFilmic";break;case mI:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}function tB(i){return[i.extensionDerivatives||i.envMapCubeUVHeight||i.bumpMap||i.tangentSpaceNormalMap||i.clearcoatNormalMap||i.flatShading||i.shaderID==="physical"?"#extension GL_OES_standard_derivatives : enable":"",(i.extensionFragDepth||i.logarithmicDepthBuffer)&&i.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",i.extensionDrawBuffers&&i.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(i.extensionShaderTextureLOD||i.envMap||i.transmission)&&i.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(ph).join( `
` )}function nB(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join( `
` )}function iB(i,e){const t={},n=i.getProgramParameter(e,35721);for(let r=0;r<n;r++){const s=i.getActiveAttrib(e,r),o=s.name;let l=1;s.type===35674&&(l=2),s.type===35675&&(l=3),s.type===35676&&(l=4),t[o]={type:s.type,location:i.getAttribLocation(e,o),locationSize:l}}return t}function ph(i){return i!==""}function sS(i,e){return i.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 oS(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const rB=/^[ \t ]*#include +<([ \w \d ./]+)>/gm;function Zy(i){return i.replace(rB,sB)}function sB(i,e){const t=Gt[e];if(t===void 0)throw new Error("Can not resolve #include <"+e+">");return Zy(t)}const oB=/#pragma unroll_loop[ \s ]+?for \( int i \= ( \d +) \; i < ( \d +) \; i \+ \+ \) \{ ([ \s \S ]+?)(?= \} ) \} /g,aB=/#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 aS(i){return i.replace(aB, $ E).replace(oB,lB)}function lB(i,e,t,n){return console.warn("WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead."), $ E(i,e,t,n)}function $ E(i,e,t,n){let r="";for(let s=parseInt(e);s<parseInt(t);s++)r+=n.replace(/ \[ \s *i \s * \] /g,"[ "+s+" ]").replace(/UNROLLED_LOOP_INDEX/g,s);return r}function lS(i){let e="precision "+i.precision+ ` float ;
precision ` +i.precision+" int;";return i.precision==="highp"?e+= `
# define HIGH _PRECISION ` :i.precision==="mediump"?e+= `
# define MEDIUM _PRECISION ` :i.precision==="lowp"&&(e+= `
# define LOW _PRECISION ` ),e}function cB(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===IE?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Y4?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===dh&&(e="SHADOWMAP_TYPE_VSM"),e}function uB(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Vc:case Hc:e="ENVMAP_TYPE_CUBE";break;case Nm:e="ENVMAP_TYPE_CUBE_UV";break}return e}function hB(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Hc:e="ENVMAP_MODE_REFRACTION";break}return e}function dB(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case km:e="ENVMAP_BLENDING_MULTIPLY";break;case uI:e="ENVMAP_BLENDING_MIX";break;case hI:e="ENVMAP_BLENDING_ADD";break}return e}function pB(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function fB(i,e,t,n){const r=i.getContext(),s=t.defines;let o=t.vertexShader,l=t.fragmentShader;const h=cB(t),d=uB(t),f=hB(t),g=dB(t),y=pB(t),_=t.isWebGL2?"":tB(t),w=nB(s),S=r.createProgram();let b,T,E=t.glslVersion?"#version "+t.glslVersion+ `
` :"";t.isRawShaderMaterial?(b=[w].filter(ph).join( `
` ),b.length>0&&(b+= `
` ),T=[_,w].filter(ph).join( `
` ),T.length>0&&(T+= `
` )):(b=[lS(t),"#define SHADER_NAME "+t.shaderName,w,t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.supportsVertexTextures?"#define VERTEX_TEXTURES":"",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 "+f:"",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.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors&&t.isWebGL2?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",t.morphTargetsCount>0&&t.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0&&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 "+h:"",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(ph).join( `
` ),T=[_,lS(t),"#define SHADER_NAME "+t.shaderName,w,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 "+d:"",t.envMap?"#define "+f:"",t.envMap?"#define "+g:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.maxMip+".0":"",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 "+h:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",t.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",t.logarithmicDepthBuffer&&t.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==As?"#define TONE_MAPPING":"",t.toneMapping!==As?Gt.tonemapping_pars_fragment:"",t.toneMapping!==As?eB("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Gt.encodings_pars_fragment, $ N("linearToOutputTexel",t.outputEncoding),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"", `
` ].filter(ph).join( `
` )),o=Zy(o),o=sS(o,t),o=oS(o,t),l=Zy(l),l=sS(l,t),l=oS(l,t),o=aS(o),l=aS(l),t.isWebGL2&&t.isRawShaderMaterial!==!0&&(E= ` # version 300 es
` ,b=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join( `
` )+ `
` +b,T=["#define varying in",t.glslVersion===L1?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===L1?"":"#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( `
` )+ `
` +T);const C=E+b+o,A=E+T+l,D=iS(r,35633,C),I=iS(r,35632,A);if(r.attachShader(S,D),r.attachShader(S,I),t.index0AttributeName!==void 0?r.bindAttribLocation(S,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(S,0,"position"),r.linkProgram(S),i.debug.checkShaderErrors){const k=r.getProgramInfoLog(S).trim(),j=r.getShaderInfoLog(D).trim(),G=r.getShaderInfoLog(I).trim();let ne=!0,ce=!0;if(r.getProgramParameter(S,35714)===!1){ne=!1;const Z=rS(r,D,"vertex"), $ =rS(r,I,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(S,35715)+ `
Program Info Log : ` +k+ `
` +Z+ `
` + $ )}else k!==""?console.warn("THREE.WebGLProgram: Program Info Log:",k):(j===""||G==="")&&(ce=!1);ce&&(this.diagnostics={runnable:ne,programLog:k,vertexShader:{log:j,prefix:b},fragmentShader:{log:G,prefix:T}})}r.deleteShader(D),r.deleteShader(I);let F;this.getUniforms=function(){return F===void 0&&(F=new ma(r,S)),F};let P;return this.getAttributes=function(){return P===void 0&&(P=iB(r,S)),P},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(S),this.program=void 0},this.name=t.shaderName,this.id=KN++,this.cacheKey=e,this.usedTimes=1,this.program=S,this.vertexShader=D,this.fragmentShader=I,this}let mB=0;class vB{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),s=this._getShaderStage(n),o=this._getShaderCacheForMaterial(e);return o.has(r)===!1&&(o.add(r),r.usedTimes++),o.has(s)===!1&&(o.add(s),s.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);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){const t=this.materialCache;return t.has(e)===!1&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(t.has(e)===!1){const n=new gB(e);t.set(e,n)}return t.get(e)}}class gB{constructor(e){this.id=mB++,this.code=e,this.usedTimes=0}}function yB(i,e,t,n,r,s,o){const l=new sx,h=new vB,d=[],f=r.isWebGL2,g=r.logarithmicDepthBuffer,y=r.vertexTextures;let _=r.precision;const w={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 S(P,k,j,G,ne){const ce=G.fog,Z=ne.geometry, $ =P.isMeshStandardMaterial?G.environment:null,K=(P.isMeshStandardMaterial?t:e).get(P.envMap|| $ ),pe=K&&K.mapping===Nm?K.image.height:null,re=w[P.type];P.precision!==null&&(_=r.getMaxPrecision(P.precision),_!==P.precision&&console.warn("THREE.WebGLProgram.getParameters:",P.precision,"not supported, using",_,"instead."));const se=Z.morphAttributes.position||Z.morphAttributes.normal||Z.morphAttributes.color,ue=se!==void 0?se.length:0;let Te=0;Z.morphAttributes.position!==void 0&&(Te=1),Z.morphAttributes.normal!==void 0&&(Te=2),Z.morphAttributes.color!==void 0&&(Te=3);let fe,Ce,qe,Ke;if(re){const Le=Ms[re];fe=Le.vertexShader,Ce=Le.fragmentShader}else fe=P.vertexShader,Ce=P.fragmentShader,h.update(P),qe=h.getVertexShaderID(P),Ke=h.getFragmentShaderID(P);const me=i.getRenderTarget(),Ut=P.alphaTest>0,nt=P.clearcoat>0;return{isWebGL2:f,shaderID:re,shaderName:P.type,vertexShader:fe,fragmentShader:Ce,defines:P.defines,customVertexShaderID:qe,customFragmentShaderID:Ke,isRawShaderMaterial:P.isRawShaderMaterial===!0,glslVersion:P.glslVersion,precision:_,instancing:ne.isInstancedMesh===!0,instancingColor:ne.isInstancedMesh===!0&&ne.instanceColor!==null,supportsVertexTextures:y,outputEncoding:me===null?i.outputEncoding:me.isXRRenderTarget===!0?me.texture.encoding:Ds,map:!!P.map,matcap:!!P.matcap,envMap:!!K,envMapMode:K&&K.mapping,envMapCubeUVHeight:pe,lightMap:!!P.lightMap,aoMap:!!P.aoMap,emissiveMap:!!P.emissiveMap,bumpMap:!!P.bumpMap,normalMap:!!P.normalMap,objectSpaceNormalMap:P.normalMapType===FE,tangentSpaceNormalMap:P.normalMapType===_l,decodeVideoTexture:!!P.map&&P.map.isVideoTexture===!0&&P.map.encoding===Ln,clearcoat:nt,clearcoatMap:nt&&!!P.clearcoatMap,clearcoatRoughnessMap:nt&&!!P.clearcoatRoughnessMap,clearcoatNormalMap:nt&&!!P.clearcoatNormalMap,displacementMap:!!P.displacementMap,roughnessMap:!!P.roughnessMap,metalnessMap:!!P.metalnessMap,specularMap:!!P.specularMap,spe
gl _Position = vec4 ( position , 1.0 ) ;
} ` ,PB= ` uniform sampler2D shadow _pass ;
uniform vec2 resolution ;
uniform float radius ;
# include < packing >
void main ( ) {
const float samples = float ( VSM _SAMPLES ) ;
float mean = 0.0 ;
float squared _mean = 0.0 ;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ) ;
float uvStart = samples <= 1.0 ? 0.0 : - 1.0 ;
for ( float i = 0.0 ; i < samples ; i ++ ) {
float uvOffset = uvStart + i * uvStride ;
# ifdef HORIZONTAL _PASS
vec2 distribution = unpackRGBATo2Half ( texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( uvOffset , 0.0 ) * radius ) / resolution ) ) ;
mean += distribution . x ;
squared _mean += distribution . y * distribution . y + distribution . x * distribution . x ;
# else
float depth = unpackRGBAToDepth ( texture2D ( shadow _pass , ( gl _FragCoord . xy + vec2 ( 0.0 , uvOffset ) * radius ) / resolution ) ) ;
mean += depth ;
squared _mean += depth * depth ;
# endif
}
mean = mean / samples ;
squared _mean = squared _mean / samples ;
float std _dev = sqrt ( squared _mean - mean * mean ) ;
gl _FragColor = pack2HalfToRGBA ( vec2 ( mean , std _dev ) ) ;
} ` ;function e2(i,e,t){let n=new ad;const r=new ae,s=new ae,o=new dn,l=new lu({depthPacking:Bm}),h=new lx,d={},f=t.maxTextureSize,g={0:xr,1:Oh,2:_a},y=new kt({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ae},radius:{value:4}},vertexShader:CB,fragmentShader:PB}),_=y.clone();_.defines.HORIZONTAL_PASS=1;const w=new zt;w.setAttribute("position",new Wn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const S=new In(w,y),b=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=IE,this.render=function(A,D,I){if(b.enabled===!1||b.autoUpdate===!1&&b.needsUpdate===!1||A.length===0)return;const F=i.getRenderTarget(),P=i.getActiveCubeFace(),k=i.getActiveMipmapLevel(),j=i.state;j.setBlending(rn),j.buffers.color.setClear(1,1,1,1),j.buffers.depth.setTest(!0),j.setScissorTest(!1);for(let G=0,ne=A.length;G<ne;G++){const ce=A[G],Z=ce.shadow;if(Z===void 0){console.warn("THREE.WebGLShadowMap:",ce,"has no shadow.");continue}if(Z.autoUpdate===!1&&Z.needsUpdate===!1)continue;r.copy(Z.mapSize);const $ =Z.getFrameExtents();if(r.multiply( $ ),s.copy(Z.mapSize),(r.x>f||r.y>f)&&(r.x>f&&(s.x=Math.floor(f/ $ .x),r.x=s.x* $ .x,Z.mapSize.x=s.x),r.y>f&&(s.y=Math.floor(f/ $ .y),r.y=s.y* $ .y,Z.mapSize.y=s.y)),Z.map===null&&!Z.isPointLightShadow&&this.type===dh&&(Z.map=new Yt(r.x,r.y),Z.map.texture.name=ce.name+".shadowMap",Z.mapPass=new Yt(r.x,r.y),Z.camera.updateProjectionMatrix()),Z.map===null){const pe={minFilter:Xt,magFilter:Xt,format:Or};Z.map=new Yt(r.x,r.y,pe),Z.map.texture.name=ce.name+".shadowMap",Z.camera.updateProjectionMatrix()}i.setRenderTarget(Z.map),i.clear();const K=Z.getViewportCount();for(let pe=0;pe<K;pe++){const re=Z.getViewport(pe);o.set(s.x*re.x,s.y*re.y,s.x*re.z,s.y*re.w),j.viewport(o),Z.updateMatrices(ce,pe),n=Z.getFrustum(),C(D,I,Z.camera,ce,this.type)}!Z.isPointLightShadow&&this.type===dh&&T(Z,I),Z.needsUpdate=!1}b.needsUpdate=!1,i.setRenderTarget(F,P,k)};function T(A,D){const I=e.update(S);y.defines.VSM_SAMPLES!==A.blurSamples&&(y.defines.VSM_SAMPLES=A.blurSamples,_.defines.VSM_SAMPLES=A.blurSamples,y.needsUpdate=!0,_.needsUpdate=!0),y.uniforms.shadow_pass.value=A.map.texture,y.uniforms.resolution.value=A.mapSize,y.uniforms.radius.value=A.radius,i.setRenderTarget(A.mapPass),i.clear(),i.renderBufferDirect(D,null,I,y,S,null),_.uniforms.shadow_pass.value=A.mapPass.texture,_.uniforms.resolution.value=A.mapSize,_.uniforms.radius.value=A.radius,i.setRenderTarget(A.map),i.clear(),i.renderBufferDirect(D,null,I,_,S,null)}function E(A,D,I,F,P,k){let j=null;const G=I.isPointLight===!0?A.customDistanceMaterial:A.customDepthMaterial;if(G!==void 0?j=G:j=I.isPointLight===!0?h:l,i.localClippingEnabled&&D.clipShadows===!0&&D.clippingPlanes.length!==0||D.displacementMap&&D.displacementScale!==0||D.alphaMap&&D.alphaTest>0){const ne=j.uuid,ce=D.uuid;let Z=d[ne];Z===void 0&&(Z={},d[ne]=Z);let $ =Z[ce]; $ ===void 0&&( $ =j.clone(),Z[ce]= $ ),j= $ }return j.visible=D.visible,j.wireframe=D.wireframe,k===dh?j.side=D.shadowSide!==null?D.shadowSide:D.side:j.side=D.shadowSide!==null?D.shadowSide:g[D.side],j.alphaMap=D.alphaMap,j.alphaTest=D.alphaTest,j.clipShadows=D.clipShadows,j.clippingPlanes=D.clippingPlanes,j.clipIntersection=D.clipIntersection,j.displacementMap=D.displacementMap,j.displacementScale=D.displacementScale,j.displacementBias=D.displacementBias,j.wireframeLinewidth=D.wireframeLinewidth,j.linewidth=D.linewidth,I.isPointLight===!0&&j.isMeshDistanceMaterial===!0&&(j.referencePosition.setFromMatrixPosition(I.matrixWorld),j.nearDistance=F,j.farDistance=P),j}function C(A,D,I,F,P){if(A.visible===!1)return;if(A.layers.test(D.layers)&&(A.isMesh||A.isLine||A.isPoints)&&(A.castShadow||A.receiveShadow&&P===dh)&&(!A.frustumCulled||n.intersectsObject(A))){A.modelViewMatrix.multiplyMatrices(I.matrixWorldInverse,A.matrixWorld);const G=e.update(A),ne=A.material;if(Array.isArray(ne)){const ce=G.groups;for(let Z=0, $ =ce.length;Z< $ ;Z++){const K=ce[Z],pe=ne[K.materialIndex];if(pe&&pe.visible){const re=E(A,pe,F,I.near,I.far,P);i.renderBufferDirect(I,null,G,re,A,K)}}}else if(ne.visible){const ce=E(A,ne,F,I.near,I.far,P);i.renderBuff
` ,y=function(C,A,D){A=A||1024;let F=C.pos,P=-1,k=0,j="",G=String.fromCharCode.apply(null,new Uint16Array(C.subarray(F,F+128)));for(;0>(P=G.indexOf(g))&&k<A&&F<C.byteLength;)j+=G,k+=G.length,F+=128,G+=String.fromCharCode.apply(null,new Uint16Array(C.subarray(F,F+128)));return-1<P?(D!==!1&&(C.pos+=k+P+1),j+G.slice(0,P)):!1},_=function(C){const A=/^# \? ( \S +)/,D=/^ \s *GAMMA \s *= \s *( \d +( \. \d +)?) \s * $ /,I=/^ \s *EXPOSURE \s *= \s *( \d +( \. \d +)?) \s * $ /,F=/^ \s *FORMAT=( \S +) \s * $ /,P=/^ \s * \- Y \s +( \d +) \s + \+ X \s +( \d +) \s * $ /,k={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let j,G;if(C.pos>=C.byteLength||!(j=y(C)))return l(1,"no header found");if(!(G=j.match(A)))return l(3,"bad initial token");for(k.valid|=1,k.programtype=G[1],k.string+=j+ `
` ;j=y(C),j!==!1;){if(k.string+=j+ `
` ,j.charAt(0)==="#"){k.comments+=j+ `
` ;continue}if((G=j.match(D))&&(k.gamma=parseFloat(G[1])),(G=j.match(I))&&(k.exposure=parseFloat(G[1])),(G=j.match(F))&&(k.valid|=2,k.format=G[1]),(G=j.match(P))&&(k.valid|=4,k.height=parseInt(G[1],10),k.width=parseInt(G[2],10)),k.valid&2&&k.valid&4)break}return k.valid&2?k.valid&4?k:l(3,"missing image size specifier"):l(3,"missing format specifier")},w=function(C,A,D){const I=A;if(I<8||I>32767||C[0]!==2||C[1]!==2||C[2]&128)return new Uint8Array(C);if(I!==(C[2]<<8|C[3]))return l(3,"wrong scanline width");const F=new Uint8Array(4*A*D);if(!F.length)return l(4,"unable to allocate buffer space");let P=0,k=0;const j=4*I,G=new Uint8Array(4),ne=new Uint8Array(j);let ce=D;for(;ce>0&&k<C.byteLength;){if(k+4>C.byteLength)return l(1);if(G[0]=C[k++],G[1]=C[k++],G[2]=C[k++],G[3]=C[k++],G[0]!=2||G[1]!=2||(G[2]<<8|G[3])!=I)return l(3,"bad rgbe scanline format");let Z=0, $ ;for(;Z<j&&k<C.byteLength;){ $ =C[k++];const pe= $ >128;if(pe&&( $ -=128), $ ===0||Z+ $ >j)return l(3,"bad scanline data");if(pe){const re=C[k++];for(let se=0;se< $ ;se++)ne[Z++]=re}else ne.set(C.subarray(k,k+ $ ),Z),Z+= $ ,k+= $ }const K=I;for(let pe=0;pe<K;pe++){let re=0;F[P]=ne[pe+re],re+=I,F[P+1]=ne[pe+re],re+=I,F[P+2]=ne[pe+re],re+=I,F[P+3]=ne[pe+re],P+=4}ce--}return F},S=function(C,A,D,I){const F=C[A+3],P=Math.pow(2,F-128)/255;D[I+0]=C[A+0]*P,D[I+1]=C[A+1]*P,D[I+2]=C[A+2]*P,D[I+3]=1},b=function(C,A,D,I){const F=C[A+3],P=Math.pow(2,F-128)/255;D[I+0]=wf.toHalfFloat(Math.min(C[A+0]*P,65504)),D[I+1]=wf.toHalfFloat(Math.min(C[A+1]*P,65504)),D[I+2]=wf.toHalfFloat(Math.min(C[A+2]*P,65504)),D[I+3]=wf.toHalfFloat(1)},T=new Uint8Array(e);T.pos=0;const E=_(T);if(E!==-1){const C=E.width,A=E.height,D=w(T.subarray(T.pos),C,A);if(D!==-1){let I,F,P,k;switch(this.type){case is:k=D.length/4;const j=new Float32Array(k*4);for(let ne=0;ne<k;ne++)S(D,ne*4,j,ne*4);I=j,P=is;break;case Ts:k=D.length/4;const G=new Uint16Array(k*4);for(let ne=0;ne<k;ne++)b(D,ne*4,G,ne*4);I=G,P=Ts;break;default:console.error("THREE.RGBELoader: unsupported type: ",this.type);break}return{width:C,height:A,data:I,header:E.string,gamma:E.gamma,exposure:E.exposure,format:F,type:P}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,r){function s(o,l){switch(o.type){case is:o.encoding=Ds,o.minFilter=Hn,o.magFilter=Hn,o.generateMipmaps=!1,o.flipY=!0;break;case Ts:o.encoding=Ds,o.minFilter=Hn,o.magFilter=Hn,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,l)}return super.load(e,s,n,r)}}const gz=new Map,oT=new T2,yz=new vz,Sy=new LE;var Gi=(i,e)=>(e&&Sy.once(i,()=>queueMicrotask(e)),Ma(gz,i,()=>(rT(),(i.toLowerCase().toLowerCase().endsWith(".hdr")?yz:oT).load(i,r=>{r.wrapS=r.wrapT=Nh,Sy.setState(i),lm()},sT,()=>{Sy.setState(i),lm()}))));const[aT,qc]=Ge("default"),[_z,cm]=Ge(1);var $ e=new cx;const Hf=new pd;Li.delete(Hf);Kt(()=>{var i;const e=(i=RE(qh()))===null||i===void 0?void 0:i.texture;if(!e)return;const t=Gi(e);return t.mapping=kh, $ e.environment=t,()=>{ $ e.environment=null}},[qh]);Kt(()=>{const i=qc();if(!i)return;if(typeof i=="string"&&i!=="default")return i==="studio"?Hf.texture="https://unpkg.com/lingo3d-textures@1.0.0/assets/studio.jpg":Hf.texture=i,()=>{Hf.texture=void 0};const e=new Mx(16777215,6710886); $ e.add(e);const t=new Tx(16777215,.5);t.position.set(0,1,1), $ e.add(t);const n=cm(r=>{e.intensity=r,t.intensity=r*.5});return()=>{e.dispose(), $ e.remove(e),t.dispose(), $ e.remove(t),n.cancel()}},[qc]);const[lT,um]=Ge(void 0);Kt(()=>{const i=um();if(i)return $ e.fog=new Gm(i,0,100),()=>{ $ e.fog=null}},[um]);const xz=new Map,bz=new E2;var wz=i=>Ma(xz,i.join(","),()=>(rT(),bz.load(i,lm,sT,lm)));const[Sz,i_]=Ge(void 0),[Nx,Yh]=Ge([]),Mz=Im(Nx,Yh),Ez=Om(Nx,Yh);Kt(()=>{var i;const e=i_(),t=Xh(),n=(i=RE(Yh()))===null||i===void 0?void 0:i.texture;if(n)if(Array.isArray(n)) $ e.background=wz(n);else{const r=Gi(n);r.mapping=kh, $ e.background=r}else e? $ e.background=Gi(e):t?t==="transparent"? $ e.background=null: $ e.background=new Pe(t): $ e.background=new Pe("black")},[Xh,i_,Yh]);Kt(()=>{var i;const e=vi();if(!e||Ze()!==bn)return;const t=new V2((i=e.object3d)!==null&&i!==void 0?i:e.outerObject3d),n=requestAnimationFrame(()=> $ e.add(t)),r=wi(()=
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
uniform float opacity ;
uniform sampler2D tDiffuse ;
varying vec2 vUv ;
void main ( ) {
gl _FragColor = texture2D ( tDiffuse , vUv ) ;
gl _FragColor . a *= opacity ;
} ` };class zs{constructor(){this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}}const uU=new ou(-1,1,1,-1,0,1),Hx=new zt;Hx.setAttribute("position",new xt([-1,3,0,-1,-1,0,3,-1,0],3));Hx.setAttribute("uv",new xt([0,2,0,0,2,0],2));class Ml{constructor(e){this._mesh=new In(Hx,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,uU)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class vm extends zs{constructor(e,t){super(),this.textureID=t!==void 0?t:"tDiffuse",e instanceof kt?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Qn.clone(e.uniforms),this.material=new kt({defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Ml(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}}class lM extends zs{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,l;this.inverse?(o=0,l=1):(o=1,l=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),s.buffers.stencil.setFunc(r.ALWAYS,o,4294967295),s.buffers.stencil.setClear(l),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(r.EQUAL,1,4294967295),s.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),s.buffers.stencil.setLocked(!0)}}class hU extends zs{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class S_{constructor(e,t){if(this.renderer=e,t===void 0){const n=e.getSize(new ae);this._pixelRatio=e.getPixelRatio(),this._width=n.width,this._height=n.height,t=new Yt(this._width*this._pixelRatio,this._height*this._pixelRatio),t.texture.name="EffectComposer.rt1"}else this._pixelRatio=1,this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],_r===void 0&&console.error("THREE.EffectComposer relies on CopyShader"),vm===void 0&&console.error("THREE.EffectComposer relies on ShaderPass"),this.copyPass=new vm(_r),this.clock=new k2}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let r=0,s=this.passes.length;r<s;r++){const o=this.passes[r];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const l=this.renderer.getContext(),h=this.renderer.state.buffers.stencil;h.setFunc(l.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),h.setFunc(l.EQUAL,1,4294967295)}this.swapBuffers()}lM!==void 0&&(o instanceof lM?n=!0:o instanceof hU&&(n=!1))}}t
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
uniform sampler2D tDiffuse ;
uniform vec3 defaultColor ;
uniform float defaultOpacity ;
uniform float luminosityThreshold ;
uniform float smoothWidth ;
varying vec2 vUv ;
void main ( ) {
vec4 texel = texture2D ( tDiffuse , vUv ) ;
vec3 luma = vec3 ( 0.299 , 0.587 , 0.114 ) ;
float v = dot ( texel . xyz , luma ) ;
vec4 outputColor = vec4 ( defaultColor . rgb , defaultOpacity ) ;
float alpha = smoothstep ( luminosityThreshold , luminosityThreshold + smoothWidth , v ) ;
gl _FragColor = mix ( outputColor , texel , alpha ) ;
} ` };class eu extends zs{constructor(e,t,n,r){super(),this.strength=t!==void 0?t:1,this.radius=n,this.threshold=r,this.resolution=e!==void 0?new ae(e.x,e.y):new ae(256,256),this.clearColor=new Pe(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let s=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new Yt(s,o),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let g=0;g<this.nMips;g++){const y=new Yt(s,o);y.texture.name="UnrealBloomPass.h"+g,y.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(y);const _=new Yt(s,o);_.texture.name="UnrealBloomPass.v"+g,_.texture.generateMipmaps=!1,this.renderTargetsVertical.push(_),s=Math.round(s/2),o=Math.round(o/2)}cM===void 0&&console.error("THREE.UnrealBloomPass relies on LuminosityHighPassShader");const l=cM;this.highPassUniforms=Qn.clone(l.uniforms),this.highPassUniforms.luminosityThreshold.value=r,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new kt({uniforms:this.highPassUniforms,vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,defines:{}}),this.separableBlurMaterials=[];const h=[3,5,7,9,11];s=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);for(let g=0;g<this.nMips;g++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(h[g])),this.separableBlurMaterials[g].uniforms.texSize.value=new ae(s,o),s=Math.round(s/2),o=Math.round(o/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;const d=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=d,this.bloomTintColors=[new z(1,1,1),new z(1,1,1),new z(1,1,1),new z(1,1,1),new z(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,_r===void 0&&console.error("THREE.UnrealBloomPass relies on CopyShader");const f=_r;this.copyUniforms=Qn.clone(f.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new kt({uniforms:this.copyUniforms,vertexShader:f.vertexShader,fragmentShader:f.fragmentShader,blending:Qf,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new Pe,this.oldClearAlpha=1,this.basic=new ss,this.fsQuad=new Ml(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()}setSize(e,t){let n=Math.round(e/2),r=Math.round(t/2);this.renderTargetBright.setSize(n,r);for(let s=0;s<this.nMips;s++)this.renderTargetsHorizontal[s].setSize(n,r),this.renderTargetsVertical[s].setSize(n,r),this.separableBlurMaterials[s].uniforms.texSize.value=new ae(n,r),n=Math.round(n/2),r=Math.round(r/2)}render(e,t,n,r,s){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const o=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),s&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);let l=this.renderTargetBright;for(let h=0;h<this.nMips;h++)this.fsQuad.material=this.separableBlurMaterials[h],this.separableBlurMateri
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: ` # include < common >
varying vec2 vUv ;
uniform sampler2D colorTexture ;
uniform vec2 texSize ;
uniform vec2 direction ;
float gaussianPdf ( in float x , in float sigma ) {
return 0.39894 * exp ( - 0.5 * x * x / ( sigma * sigma ) ) / sigma ;
}
void main ( ) {
vec2 invSize = 1.0 / texSize ;
float fSigma = float ( SIGMA ) ;
float weightSum = gaussianPdf ( 0.0 , fSigma ) ;
vec3 diffuseSum = texture2D ( colorTexture , vUv ) . rgb * weightSum ;
for ( int i = 1 ; i < KERNEL _RADIUS ; i ++ ) {
float x = float ( i ) ;
float w = gaussianPdf ( x , fSigma ) ;
vec2 uvOffset = direction * invSize * x ;
vec3 sample1 = texture2D ( colorTexture , vUv + uvOffset ) . rgb ;
vec3 sample2 = texture2D ( colorTexture , vUv - uvOffset ) . rgb ;
diffuseSum += ( sample1 + sample2 ) * w ;
weightSum += 2.0 * w ;
}
gl _FragColor = vec4 ( diffuseSum / weightSum , 1.0 ) ;
} ` })}getCompositeMaterial(e){return new kt({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader: ` varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: ` varying vec2 vUv ;
uniform sampler2D blurTexture1 ;
uniform sampler2D blurTexture2 ;
uniform sampler2D blurTexture3 ;
uniform sampler2D blurTexture4 ;
uniform sampler2D blurTexture5 ;
uniform float bloomStrength ;
uniform float bloomRadius ;
uniform float bloomFactors [ NUM _MIPS ] ;
uniform vec3 bloomTintColors [ NUM _MIPS ] ;
float lerpBloomFactor ( const in float factor ) {
float mirrorFactor = 1.2 - factor ;
return mix ( factor , mirrorFactor , bloomRadius ) ;
}
void main ( ) {
gl _FragColor = bloomStrength * ( lerpBloomFactor ( bloomFactors [ 0 ] ) * vec4 ( bloomTintColors [ 0 ] , 1.0 ) * texture2D ( blurTexture1 , vUv ) +
lerpBloomFactor ( bloomFactors [ 1 ] ) * vec4 ( bloomTintColors [ 1 ] , 1.0 ) * texture2D ( blurTexture2 , vUv ) +
lerpBloomFactor ( bloomFactors [ 2 ] ) * vec4 ( bloomTintColors [ 2 ] , 1.0 ) * texture2D ( blurTexture3 , vUv ) +
lerpBloomFactor ( bloomFactors [ 3 ] ) * vec4 ( bloomTintColors [ 3 ] , 1.0 ) * texture2D ( blurTexture4 , vUv ) +
lerpBloomFactor ( bloomFactors [ 4 ] ) * vec4 ( bloomTintColors [ 4 ] , 1.0 ) * texture2D ( blurTexture5 , vUv ) ) ;
} ` })}}eu.BlurDirectionX=new ae(1,0);eu.BlurDirectionY=new ae(0,1);const gd=new eu(new ae,1.5,0,0);vT(i=>gd.radius=i);gT(i=>gd.strength=i);yT(i=>gd.threshold=i);const ya=new S_(Sn());ya.renderToScreen=!1;Kt(()=>{ya.renderer=Sn();const[i,e]=mi();ya.setSize(i,e),ya.setPixelRatio(Zc())},[Sn,mi,Zc]);ya.addPass(Gx);ya.addPass(gd);const BT=[!1],Wx=i=>{i.userData.bloom=!0,BT[0]=!0},jx=i=>{i.userData.bloom=!1};let M_;const zT=i=>{for(const e of i){if(e.userData.bloom){e.renderOrder=1;continue}e.visible&&(zT(e.children),e.material&&(e.material.colorWrite=!1),e.renderOrder=0)}},pU=()=>{zT( $ e.children), $ e.background&&(M_= $ e.background, $ e.background=null)},fU=i=>i.material&&(i.material.colorWrite=!0),mU=()=>{ $ e.traverse(fU),M_&&( $ e.background=M_)};var vU=()=>{pU(),ya.render(),mU()};const Mf=new WeakMap;var uM=i=>{if(Mf.has(i))return Mf.get(i);fd(i);const e=Ze();Ot.project(e);const t=(Ot.x*.5+.5)*wn.clientWidth,n=(Ot.y*-.5+.5)*wn.clientHeight,r={x:t,y:n};return Mf.set(i,r),setTimeout(()=>Mf.delete(i)),r};const $ r={defines:{MAX_STEP:0,PERSPECTIVE_CAMERA:!0,DISTANCE_ATTENUATION:!0,FRESNEL:!0,INFINITE_THICK:!1,SELECTIVE:!1},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tMetalness:{value:null},tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new ae},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},opacity:{value:.5},maxDistance:{value:180},cameraRange:{value:0},thickness:{value:.018}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
}
` ,fragmentShader: `
// precision highp float;
precision highp sampler2D ;
varying vec2 vUv ;
uniform sampler2D tDepth ;
uniform sampler2D tNormal ;
uniform sampler2D tMetalness ;
uniform sampler2D tDiffuse ;
uniform float cameraRange ;
uniform vec2 resolution ;
uniform float opacity ;
uniform float cameraNear ;
uniform float cameraFar ;
uniform float maxDistance ;
uniform float thickness ;
uniform mat4 cameraProjectionMatrix ;
uniform mat4 cameraInverseProjectionMatrix ;
# include < packing >
float pointToLineDistance ( vec3 x0 , vec3 x1 , vec3 x2 ) {
//x0: point, x1: linePointA, x2: linePointB
//https://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
return length ( cross ( x0 - x1 , x0 - x2 ) ) / length ( x2 - x1 ) ;
}
float pointPlaneDistance ( vec3 point , vec3 planePoint , vec3 planeNormal ) {
// https://mathworld.wolfram.com/Point-PlaneDistance.html
//// https://en.wikipedia.org/wiki/Plane_(geometry)
//// http://paulbourke.net/geometry/pointlineplane/
float a = planeNormal . x , b = planeNormal . y , c = planeNormal . z ;
float x0 = point . x , y0 = point . y , z0 = point . z ;
float x = planePoint . x , y = planePoint . y , z = planePoint . z ;
float d = - ( a * x + b * y + c * z ) ;
float distance = ( a * x0 + b * y0 + c * z0 + d ) / sqrt ( a * a + b * b + c * c ) ;
return distance ;
}
float getDepth ( const in vec2 uv ) {
return texture2D ( tDepth , uv ) . x ;
}
float getViewZ ( const in float depth ) {
# ifdef PERSPECTIVE _CAMERA
return perspectiveDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# else
return orthographicDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# endif
}
vec3 getViewPosition ( const in vec2 uv , const in float depth /*clip space*/ , const in float clipW ) {
vec4 clipPosition = vec4 ( ( vec3 ( uv , depth ) - 0.5 ) * 2.0 , 1.0 ) ; //ndc
clipPosition *= clipW ; //clip
return ( cameraInverseProjectionMatrix * clipPosition ) . xyz ; //view
}
vec3 getViewNormal ( const in vec2 uv ) {
return unpackRGBToNormal ( texture2D ( tNormal , uv ) . xyz ) ;
}
vec2 viewPositionToXY ( vec3 viewPosition ) {
vec2 xy ;
vec4 clip = cameraProjectionMatrix * vec4 ( viewPosition , 1 ) ;
xy = clip . xy ; //clip
float clipW = clip . w ;
xy /= clipW ; //NDC
xy = ( xy + 1. ) / 2. ; //uv
xy *= resolution ; //screen
return xy ;
}
void main ( ) {
# ifdef SELECTIVE
float metalness = texture2D ( tMetalness , vUv ) . r ;
if ( metalness == 0. ) return ;
# endif
float depth = getDepth ( vUv ) ;
float viewZ = getViewZ ( depth ) ;
if ( - viewZ >= cameraFar ) return ;
float clipW = cameraProjectionMatrix [ 2 ] [ 3 ] * viewZ + cameraProjectionMatrix [ 3 ] [ 3 ] ;
vec3 viewPosition = getViewPosition ( vUv , depth , clipW ) ;
vec2 d0 = gl _FragCoord . xy ;
vec2 d1 ;
vec3 viewNormal = getViewNormal ( vUv ) ;
# ifdef PERSPECTIVE _CAMERA
vec3 viewIncidentDir = normalize ( viewPosition ) ;
vec3 viewReflectDir = reflect ( viewIncidentDir , viewNormal ) ;
# else
vec3 viewIncidentDir = vec3 ( 0 , 0 , - 1 ) ;
vec3 viewReflectDir = reflect ( viewIncidentDir , viewNormal ) ;
# endif
float maxReflectRayLen = maxDistance / dot ( - viewIncidentDir , viewNormal ) ;
// dot(a,b)==length(a)*length(b)*cos(theta) // https://www.mathsisfun.com/algebra/vectors-dot-product.html
// if(a.isNormalized&&b.isNormalized) dot(a,b)==cos(theta)
// maxDistance/maxReflectRayLen=cos(theta)
// maxDistance/maxReflectRayLen==dot(a,b)
// maxReflectRayLen==maxDistance/dot(a,b)
vec3 d1viewPosition = viewPosition + viewReflectDir * maxReflectRayLen ;
# ifdef PERSPECTIVE _CAMERA
if ( d1viewPosition . z > - cameraNear ) {
//https://tutorial.math.lamar.edu/Classes/CalcIII/EqnsOfLines.aspx
float t = ( - cameraNear - viewPosition . z ) / viewReflectDir . z ;
d1viewPosition = viewPosition + viewReflectDir * t ;
}
# endif
d1 = viewPositionToXY ( d1viewPosition ) ;
float totalLen = length ( d1 - d0 ) ;
float xLen = d1 . x - d0 . x ;
float yLen = d1 . y - d0 . y ;
float totalStep = max ( abs ( xLen ) , abs ( yLen ) ) ;
float xSpan = xLen / totalStep ;
float ySpan = yLen / totalStep ;
for ( float i = 0. ; i < float ( MAX _STEP ) ; i ++ ) {
if ( i >= totalStep ) break ;
vec2 xy = vec2 ( d0 . x + i * xSpan , d0 . y + i * ySpan ) ;
if ( xy . x < 0. || xy . x > resolution . x || xy . y < 0. || xy . y > resolution . y ) break ;
float s = length ( xy - d0 ) / totalLen ;
vec2 uv = xy / resolution ;
float d = getDepth ( uv ) ;
float vZ = getViewZ ( d ) ;
if ( - vZ >= cameraFar ) continue ;
float cW = cameraProjectionMatrix [ 2 ] [ 3 ] * vZ + cameraProjectionMatrix [ 3 ] [ 3 ] ;
vec3 vP = getViewPosition ( uv , d , cW ) ;
# ifdef PERSPECTIVE _CAMERA
// https://comp.nus.edu.sg/~lowkl/publications/lowk_persp_interp_techrep.pdf
float recipVPZ = 1. / viewPosition . z ;
float viewReflectRayZ = 1. / ( recipVPZ + s * ( 1. / d1viewPosition . z - recipVPZ ) ) ;
# else
float viewReflectRayZ = viewPosition . z + s * ( d1viewPosition . z - viewPosition . z ) ;
# endif
// if(viewReflectRayZ>vZ) continue; // will cause "npm run make-screenshot webgl_postprocessing_ssr" high probability hang.
// https://github.com/mrdoob/three.js/pull/21539#issuecomment-821061164
if ( viewReflectRayZ <= vZ ) {
bool hit ;
# ifdef INFINITE _THICK
hit = true ;
# else
float away = pointToLineDistance ( vP , viewPosition , d1viewPosition ) ;
float minThickness ;
vec2 xyNeighbor = xy ;
xyNeighbor . x += 1. ;
vec2 uvNeighbor = xyNeighbor / resolution ;
vec3 vPNeighbor = getViewPosition ( uvNeighbor , d , cW ) ;
minThickness = vPNeighbor . x - vP . x ;
minThickness *= 3. ;
float tk = max ( minThickness , thickness ) ;
hit = away <= tk ;
# endif
if ( hit ) {
vec3 vN = getViewNormal ( uv ) ;
if ( dot ( viewReflectDir , vN ) >= 0. ) continue ;
float distance = pointPlaneDistance ( vP , viewPosition , viewNormal ) ;
if ( distance > maxDistance ) break ;
float op = opacity ;
# ifdef DISTANCE _ATTENUATION
float ratio = 1. - ( distance / maxDistance ) ;
float attenuation = ratio * ratio ;
op = opacity * attenuation ;
# endif
# ifdef FRESNEL
float fresnelCoe = ( dot ( viewIncidentDir , viewReflectDir ) + 1. ) / 2. ;
op *= fresnelCoe ;
# endif
vec4 reflectColor = texture2D ( tDiffuse , uv ) ;
gl _FragColor . xyz = reflectColor . xyz ;
gl _FragColor . a = op ;
break ;
}
}
}
}
` },Ef={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
}
` ,fragmentShader: `
uniform sampler2D tDepth ;
uniform float cameraNear ;
uniform float cameraFar ;
varying vec2 vUv ;
# include < packing >
float getLinearDepth ( const in vec2 uv ) {
# if PERSPECTIVE _CAMERA == 1
float fragCoordZ = texture2D ( tDepth , uv ) . x ;
float viewZ = perspectiveDepthToViewZ ( fragCoordZ , cameraNear , cameraFar ) ;
return viewZToOrthographicDepth ( viewZ , cameraNear , cameraFar ) ;
# else
return texture2D ( tDepth , uv ) . x ;
# endif
}
void main ( ) {
float depth = getLinearDepth ( vUv ) ;
float d = 1.0 - depth ;
// d=(d-.999)*1000.;
gl _FragColor = vec4 ( vec3 ( d ) , 1.0 ) ;
}
` },la={uniforms:{tDiffuse:{value:null},resolution:{value:new ae},opacity:{value:.5}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
}
` ,fragmentShader: `
uniform sampler2D tDiffuse ;
uniform vec2 resolution ;
varying vec2 vUv ;
void main ( ) {
//reverse engineering from PhotoShop blur filter, then change coefficient
vec2 texelSize = ( 1.0 / resolution ) ;
vec4 c = texture2D ( tDiffuse , vUv ) ;
vec2 offset ;
offset = ( vec2 ( - 1 , 0 ) ) * texelSize ;
vec4 cl = texture2D ( tDiffuse , vUv + offset ) ;
offset = ( vec2 ( 1 , 0 ) ) * texelSize ;
vec4 cr = texture2D ( tDiffuse , vUv + offset ) ;
offset = ( vec2 ( 0 , - 1 ) ) * texelSize ;
vec4 cb = texture2D ( tDiffuse , vUv + offset ) ;
offset = ( vec2 ( 0 , 1 ) ) * texelSize ;
vec4 ct = texture2D ( tDiffuse , vUv + offset ) ;
// float coeCenter=.5;
// float coeSide=.125;
float coeCenter = . 2 ;
float coeSide = . 2 ;
float a = c . a * coeCenter + cl . a * coeSide + cr . a * coeSide + cb . a * coeSide + ct . a * coeSide ;
vec3 rgb = ( c . rgb * c . a * coeCenter + cl . rgb * cl . a * coeSide + cr . rgb * cr . a * coeSide + cb . rgb * cb . a * coeSide + ct . rgb * ct . a * coeSide ) / a ;
gl _FragColor = vec4 ( rgb , a ) ;
}
` };class vo extends zs{constructor({renderer:e,scene:t,camera:n,width:r,height:s,selects:o,bouncing:l=!1,groundReflector:h}){super(),this.width=r!==void 0?r:512,this.height=s!==void 0?s:512,this.clear=!0,this.renderer=e,this.scene=t,this.camera=n,this.groundReflector=h,this.opacity= $ r.uniforms.opacity.value,this.output=0,this.maxDistance= $ r.uniforms.maxDistance.value,this.thickness= $ r.uniforms.thickness.value,this.tempColor=new Pe,this._selects=o,this.selective=Array.isArray(this._selects),Object.defineProperty(this,"selects",{get(){return this._selects},set(f){this._selects!==f&&(this._selects=f,Array.isArray(f)?(this.selective=!0,this.ssrMaterial.defines.SELECTIVE=!0,this.ssrMaterial.needsUpdate=!0):(this.selective=!1,this.ssrMaterial.defines.SELECTIVE=!1,this.ssrMaterial.needsUpdate=!0))}}),this._bouncing=l,Object.defineProperty(this,"bouncing",{get(){return this._bouncing},set(f){this._bouncing!==f&&(this._bouncing=f,f?this.ssrMaterial.uniforms.tDiffuse.value=this.prevRenderTarget.texture:this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture)}}),this.blur=!0,this._distanceAttenuation= $ r.defines.DISTANCE_ATTENUATION,Object.defineProperty(this,"distanceAttenuation",{get(){return this._distanceAttenuation},set(f){this._distanceAttenuation!==f&&(this._distanceAttenuation=f,this.ssrMaterial.defines.DISTANCE_ATTENUATION=f,this.ssrMaterial.needsUpdate=!0)}}),this._fresnel= $ r.defines.FRESNEL,Object.defineProperty(this,"fresnel",{get(){return this._fresnel},set(f){this._fresnel!==f&&(this._fresnel=f,this.ssrMaterial.defines.FRESNEL=f,this.ssrMaterial.needsUpdate=!0)}}),this._infiniteThick= $ r.defines.INFINITE_THICK,Object.defineProperty(this,"infiniteThick",{get(){return this._infiniteThick},set(f){this._infiniteThick!==f&&(this._infiniteThick=f,this.ssrMaterial.defines.INFINITE_THICK=f,this.ssrMaterial.needsUpdate=!0)}});const d=new Hm;d.type=pl,d.minFilter=Xt,d.magFilter=Xt,this.beautyRenderTarget=new Yt(this.width,this.height,{minFilter:Xt,magFilter:Xt,depthTexture:d,depthBuffer:!0}),this.prevRenderTarget=new Yt(this.width,this.height,{minFilter:Xt,magFilter:Xt}),this.normalRenderTarget=new Yt(this.width,this.height,{minFilter:Xt,magFilter:Xt,type:Ts}),this.metalnessRenderTarget=new Yt(this.width,this.height,{minFilter:Xt,magFilter:Xt}),this.ssrRenderTarget=new Yt(this.width,this.height,{minFilter:Xt,magFilter:Xt}),this.blurRenderTarget=this.ssrRenderTarget.clone(),this.blurRenderTarget2=this.ssrRenderTarget.clone(), $ r===void 0&&console.error("THREE.SSRPass: The pass relies on SSRShader."),this.ssrMaterial=new kt({defines:Object.assign({}, $ r.defines,{MAX_STEP:Math.sqrt(this.width*this.width+this.height*this.height)}),uniforms:Qn.clone( $ r.uniforms),vertexShader: $ r.vertexShader,fragmentShader: $ r.fragmentShader,blending:rn}),this.ssrMaterial.uniforms.tDiffuse.value=this.beautyRenderTarget.texture,this.ssrMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.ssrMaterial.defines.SELECTIVE=this.selective,this.ssrMaterial.needsUpdate=!0,this.ssrMaterial.uniforms.tMetalness.value=this.metalnessRenderTarget.texture,this.ssrMaterial.uniforms.tDepth.value=this.beautyRenderTarget.depthTexture,this.ssrMaterial.uniforms.cameraNear.value=this.camera.near,this.ssrMaterial.uniforms.cameraFar.value=this.camera.far,this.ssrMaterial.uniforms.thickness.value=this.thickness,this.ssrMaterial.uniforms.resolution.value.set(this.width,this.height),this.ssrMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.ssrMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.normalMaterial=new Jm,this.normalMaterial.blending=rn,this.metalnessOnMaterial=new ss({color:"white"}),this.metalnessOffMaterial=new ss({color:"black"}),this.blurMaterial=new kt({defines:Object.assign({},la.defines),uniforms:Qn.clone(la.uniforms),vertexShader:la.vertexShader,fragmentShader:la.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssrRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.blurMaterial2=new kt(
# include < skinning _pars _vertex >
varying vec4 projTexCoord ;
varying vec4 vPosition ;
uniform mat4 textureMatrix ;
void main ( ) {
# include < skinbase _vertex >
# include < begin _vertex >
# include < morphtarget _vertex >
# include < skinning _vertex >
# include < project _vertex >
vPosition = mvPosition ;
vec4 worldPosition = modelMatrix * vec4 ( transformed , 1.0 ) ;
projTexCoord = textureMatrix * worldPosition ;
} ` ,fragmentShader: ` # include < packing >
varying vec4 vPosition ;
varying vec4 projTexCoord ;
uniform sampler2D depthTexture ;
uniform vec2 cameraNearFar ;
void main ( ) {
float depth = unpackRGBAToDepth ( texture2DProj ( depthTexture , projTexCoord ) ) ;
float viewZ = - DEPTH _TO _VIEW _Z ( depth , cameraNearFar . x , cameraNearFar . y ) ;
float depthTest = ( - vPosition . z > viewZ ) ? 1.0 : 0.0 ;
gl _FragColor = vec4 ( 0.0 , depthTest , 1.0 , 1.0 ) ;
} ` })}getEdgeDetectionMaterial(){return new kt({uniforms:{maskTexture:{value:null},texSize:{value:new ae(.5,.5)},visibleEdgeColor:{value:new z(1,1,1)},hiddenEdgeColor:{value:new z(1,1,1)}},vertexShader: ` varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: ` varying vec2 vUv ;
uniform sampler2D maskTexture ;
uniform vec2 texSize ;
uniform vec3 visibleEdgeColor ;
uniform vec3 hiddenEdgeColor ;
void main ( ) {
vec2 invSize = 1.0 / texSize ;
vec4 uvOffset = vec4 ( 1.0 , 0.0 , 0.0 , 1.0 ) * vec4 ( invSize , invSize ) ;
vec4 c1 = texture2D ( maskTexture , vUv + uvOffset . xy ) ;
vec4 c2 = texture2D ( maskTexture , vUv - uvOffset . xy ) ;
vec4 c3 = texture2D ( maskTexture , vUv + uvOffset . yw ) ;
vec4 c4 = texture2D ( maskTexture , vUv - uvOffset . yw ) ;
float diff1 = ( c1 . r - c2 . r ) * 0.5 ;
float diff2 = ( c3 . r - c4 . r ) * 0.5 ;
float d = length ( vec2 ( diff1 , diff2 ) ) ;
float a1 = min ( c1 . g , c2 . g ) ;
float a2 = min ( c3 . g , c4 . g ) ;
float visibilityFactor = min ( a1 , a2 ) ;
vec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor ;
gl _FragColor = vec4 ( edgeColor , 1.0 ) * vec4 ( d ) ;
} ` })}getSeperableBlurMaterial(e){return new kt({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new ae(.5,.5)},direction:{value:new ae(.5,.5)},kernelRadius:{value:1}},vertexShader: ` varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: ` # include < common >
varying vec2 vUv ;
uniform sampler2D colorTexture ;
uniform vec2 texSize ;
uniform vec2 direction ;
uniform float kernelRadius ;
float gaussianPdf ( in float x , in float sigma ) {
return 0.39894 * exp ( - 0.5 * x * x / ( sigma * sigma ) ) / sigma ;
}
void main ( ) {
vec2 invSize = 1.0 / texSize ;
float weightSum = gaussianPdf ( 0.0 , kernelRadius ) ;
vec4 diffuseSum = texture2D ( colorTexture , vUv ) * weightSum ;
vec2 delta = direction * invSize * kernelRadius / float ( MAX _RADIUS ) ;
vec2 uvOffset = delta ;
for ( int i = 1 ; i <= MAX _RADIUS ; i ++ ) {
float w = gaussianPdf ( uvOffset . x , kernelRadius ) ;
vec4 sample1 = texture2D ( colorTexture , vUv + uvOffset ) ;
vec4 sample2 = texture2D ( colorTexture , vUv - uvOffset ) ;
diffuseSum += ( ( sample1 + sample2 ) * w ) ;
weightSum += ( 2.0 * w ) ;
uvOffset += delta ;
}
gl _FragColor = diffuseSum / weightSum ;
} ` })}getOverlayMaterial(){return new kt({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader: ` varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: ` varying vec2 vUv ;
uniform sampler2D maskTexture ;
uniform sampler2D edgeTexture1 ;
uniform sampler2D edgeTexture2 ;
uniform sampler2D patternTexture ;
uniform float edgeStrength ;
uniform float edgeGlow ;
uniform bool usePatternTexture ;
void main ( ) {
vec4 edgeValue1 = texture2D ( edgeTexture1 , vUv ) ;
vec4 edgeValue2 = texture2D ( edgeTexture2 , vUv ) ;
vec4 maskColor = texture2D ( maskTexture , vUv ) ;
vec4 patternColor = texture2D ( patternTexture , 6.0 * vUv ) ;
float visibilityFactor = 1.0 - maskColor . g > 0.0 ? 1.0 : 0.5 ;
vec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow ;
vec4 finalColor = edgeStrength * maskColor . r * edgeValue ;
if ( usePatternTexture )
finalColor += + visibilityFactor * ( 1.0 - maskColor . r ) * ( 1.0 - patternColor . r ) ;
gl _FragColor = finalColor ;
2023-05-30 00:33:57 +08:00
} ` ,blending:Qf,depthTest:!1,depthWrite:!1,transparent:!0})}}pa.BlurDirectionX=new ae(1,0);pa.BlurDirectionY=new ae(0,1);const VT=[!1],Yx=[],HT=i=>{i.userData.outline||(i.userData.outline=!0,Yx.push(i),VT[0]=!0)},GT=i=>{i.userData.outline&&(i.userData.outline=!1,PE(Yx,i))},Ps=new pa(new ae, $ e,Ze(),Yx);Ze(i=>Ps.renderCamera=i);Kt(()=>{var i;const e=d_(),t=(i=p_())!==null&&i!==void 0?i:e;Ps.visibleEdgeColor=new Pe(e),Ps.hiddenEdgeColor=new Pe(t)},[d_,p_]);Kt(()=>{const i=f_();if(i)return Ps.patternTexture=Gi(i),Ps.usePatternTexture=!0,()=>{Ps.usePatternTexture=!1}},[f_]);bT(i=>Ps.pulsePeriod=i*.001);wT(i=>Ps.edgeStrength=i);ST(i=>Ps.edgeThickness=i);const gU=new WeakMap,hM=new WeakMap,Ey=new WeakMap;class $ h extends $ _{constructor(e,t){super(),this.mixer=Ma(gU,t,()=>new N2(t)),typeof e=="string"?this.name=e:(this.name=e.name,this.loadClip(e))}retarget(e){const t=this.clip.clone(),n=e.name+".";return t.tracks=t.tracks.filter(r=>r.name.startsWith(n)),new $ h(t,e)}dispose(){return super.dispose(),this.stop(),this}get duration(){var e,t;return(t=(e=this.clip)===null||e===void 0?void 0:e.duration)!==null&&t!==void 0?t:0}loadClip(e){this.clip=e,this.action=this.mixer.clipAction(e)}setTracks(e){const t=Object.entries(e).map(([n,r])=>new Wh("."+n,Object.keys(r).map(s=>Number(s)),Object.values(r)));this.clip&&this.mixer.uncacheClip(this.clip),this.loadClip(new e_(this.name,-1,t))}play({crossFade:e=.25,repeat:t=!0,onFinish:n}={}){var r,s;const[o,l]=(r=hM.get(this.mixer))!==null&&r!==void 0?r:[];if(o!=null&&o.isRunning()&&this.action===o){t!==l&&o.setLoop(t?Xy:jy,1/0);return}(s=Ey.get(this.mixer))===null||s===void 0||s.cancel();const h=this.watch(wi(()=>this.mixer.update(Dx[0])));Ey.set(this.mixer,h);const{action:d}=this;if(!d)return;o&&e?(d.time=0,d.enabled=!0,d.crossFadeFrom(o,e,!0)):this.mixer.stopAllAction(),hM.set(this.mixer,[d,t]),d.setLoop(t?Xy:jy,1/0),d.clampWhenFinished=!0;const f=()=>n==null?void 0:n();this.mixer.addEventListener("finished",f),h.then(()=>this.mixer.removeEventListener("finished",f)),d.paused&&d.stop(),d.play()}stop(){var e;this.action&&(this.action.paused=!0),(e=Ey.get(this.mixer))===null||e===void 0||e.cancel()}getPaused(){var e;return(e=this.action)===null||e===void 0?void 0:e.paused}setPaused(e){this.action&&(this.action.paused=e)}update(e){this.mixer.time=0,this.action&&(this.action.time=0),this.mixer.update(e)}}const yU=Mr(i=>{const e=Object.entries(i);let t=0;for(const[,{length:o}]of e)o>t&&(t=o);const r=1e3*.001/t,s={};for(const[o,l]of e)s[o]=Object.fromEntries(l.map((h,d)=>[(d*r).toFixed(2),h]));return s},0,"trailingPromise");class _U extends Bs{get animations(){var e;return(e=this.animationManagers)!==null&&e!==void 0?e:this.animationManagers={}}set animations(e){this.animationManagers=e}createAnimation(e){if(e in this.animations){const n=this.animations[e];if(typeof n!="string")return n}const t=this.watch(new $ h(e,this));return this.animations[e]=t,t}buildAnimation(e){yU(e).then(t=>{const n="lingo3d-animation";this.createAnimation(n).setTracks(t),this.playAnimation(n)})}makeAnimationProxy(e){return new Proxy(e,{get:(t,n)=>t[n],set:(t,n,r)=>(t[n]=r,this.buildAnimation(t),!0)})}async playAnimation(e,t){var n;await Promise.resolve(),this.loadingAnims&&(await Promise.all(this.loadingAnims),this.loadingAnims=void 0),!this.done&&(this.animationManager=typeof e=="string"?this.animations[e]:Object.values(this.animations)[e??0],(n=this.animationManager)===null||n===void 0||n.play(t))}stopAnimation(){var e;(e=this.animationManager)===null||e===void 0||e.stop()}get animationPaused(){var e;return!!(!((e=this.animationManager)===null||e===void 0)&&e.getPaused())}set animationPaused(e){(async()=>{var t;await Promise.resolve(),this.loadingAnims&&await Promise.all(this.loadingAnims),!this.done&&((t=this.animationManager)===null||t===void 0||t.setPaused(e))})()}setAnimation(e,t){if(this._animation=e,typeof e=="string"||typeof e=="number"){this.animationName=e,this.playAnimation(e,t);return}if(typeof e=="boolean"){e?this.playAnimation(void 0,t):this.stopAnimation();return}if(!e){this.stopAnimation();return}this.
2023-05-28 15:00:40 +08:00
uniform vec3 sunPosition ;
uniform float rayleigh ;
uniform float turbidity ;
uniform float mieCoefficient ;
uniform vec3 up ;
varying vec3 vWorldPosition ;
varying vec3 vSunDirection ;
varying float vSunfade ;
varying vec3 vBetaR ;
varying vec3 vBetaM ;
varying float vSunE ;
// constants for atmospheric scattering
const float e = 2.71828182845904523536028747135266249775724709369995957 ;
const float pi = 3.141592653589793238462643383279502884197169 ;
// wavelength of used primaries, according to preetham
const vec3 lambda = vec3 ( 680E-9 , 550E-9 , 450E-9 ) ;
// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
const vec3 totalRayleigh = vec3 ( 5.804542996261093 E - 6 , 1.3562911419845635 E - 5 , 3.0265902468824876 E - 5 ) ;
// mie stuff
// K coefficient for the primaries
const float v = 4.0 ;
const vec3 K = vec3 ( 0.686 , 0.678 , 0.666 ) ;
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
const vec3 MieConst = vec3 ( 1.8399918514433978 E14 , 2.7798023919660528 E14 , 4.0790479543861094 E14 ) ;
// earth shadow hack
// cutoffAngle = pi / 1.95;
const float cutoffAngle = 1.6110731556870734 ;
const float steepness = 1.5 ;
const float EE = 1000.0 ;
float sunIntensity ( float zenithAngleCos ) {
zenithAngleCos = clamp ( zenithAngleCos , - 1.0 , 1.0 ) ;
return EE * max ( 0.0 , 1.0 - pow ( e , - ( ( cutoffAngle - acos ( zenithAngleCos ) ) / steepness ) ) ) ;
}
vec3 totalMie ( float T ) {
float c = ( 0.2 * T ) * 10E-18 ;
return 0.434 * c * MieConst ;
}
void main ( ) {
vec4 worldPosition = modelMatrix * vec4 ( position , 1.0 ) ;
vWorldPosition = worldPosition . xyz ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
gl _Position . z = gl _Position . w ; // set z to camera.far
vSunDirection = normalize ( sunPosition ) ;
vSunE = sunIntensity ( dot ( vSunDirection , up ) ) ;
vSunfade = 1.0 - clamp ( 1.0 - exp ( ( sunPosition . y / 450000.0 ) ) , 0.0 , 1.0 ) ;
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) ) ;
// extinction (absorbtion + out scattering)
// rayleigh coefficients
vBetaR = totalRayleigh * rayleighCoefficient ;
// mie coefficients
vBetaM = totalMie ( turbidity ) * mieCoefficient ;
} ` ,fragmentShader: `
varying vec3 vWorldPosition ;
varying vec3 vSunDirection ;
varying float vSunfade ;
varying vec3 vBetaR ;
varying vec3 vBetaM ;
varying float vSunE ;
uniform float mieDirectionalG ;
uniform vec3 up ;
const vec3 cameraPos = vec3 ( 0.0 , 0.0 , 0.0 ) ;
// constants for atmospheric scattering
const float pi = 3.141592653589793238462643383279502884197169 ;
const float n = 1.0003 ; // refractive index of air
const float N = 2.545 E25 ; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
// optical length at zenith for molecules
const float rayleighZenithLength = 8.4 E3 ;
const float mieZenithLength = 1.25 E3 ;
// 66 arc seconds -> degrees, and the cosine of that
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324 ;
// 3.0 / ( 16.0 * pi )
const float THREE _OVER _SIXTEENPI = 0.05968310365946075 ;
// 1.0 / ( 4.0 * pi )
const float ONE _OVER _FOURPI = 0.07957747154594767 ;
float rayleighPhase ( float cosTheta ) {
return THREE _OVER _SIXTEENPI * ( 1.0 + pow ( cosTheta , 2.0 ) ) ;
}
float hgPhase ( float cosTheta , float g ) {
float g2 = pow ( g , 2.0 ) ;
float inverse = 1.0 / pow ( 1.0 - 2.0 * g * cosTheta + g2 , 1.5 ) ;
return ONE _OVER _FOURPI * ( ( 1.0 - g2 ) * inverse ) ;
}
void main ( ) {
vec3 direction = normalize ( vWorldPosition - cameraPos ) ;
// optical length
// cutoff angle at 90 to avoid singularity in next formula.
float zenithAngle = acos ( max ( 0.0 , dot ( up , direction ) ) ) ;
float inverse = 1.0 / ( cos ( zenithAngle ) + 0.15 * pow ( 93.885 - ( ( zenithAngle * 180.0 ) / pi ) , - 1.253 ) ) ;
float sR = rayleighZenithLength * inverse ;
float sM = mieZenithLength * inverse ;
// combined extinction factor
vec3 Fex = exp ( - ( vBetaR * sR + vBetaM * sM ) ) ;
// in scattering
float cosTheta = dot ( direction , vSunDirection ) ;
float rPhase = rayleighPhase ( cosTheta * 0.5 + 0.5 ) ;
vec3 betaRTheta = vBetaR * rPhase ;
float mPhase = hgPhase ( cosTheta , mieDirectionalG ) ;
vec3 betaMTheta = vBetaM * mPhase ;
vec3 Lin = pow ( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ) , vec3 ( 1.5 ) ) ;
Lin *= mix ( vec3 ( 1.0 ) , pow ( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex , vec3 ( 1.0 / 2.0 ) ) , clamp ( pow ( 1.0 - dot ( up , vSunDirection ) , 5.0 ) , 0.0 , 1.0 ) ) ;
// nightsky
float theta = acos ( direction . y ) ; // elevation --> y-axis, [-pi/2, pi/2]
float phi = atan ( direction . z , direction . x ) ; // azimuth --> x-axis [-pi/2, pi/2]
vec2 uv = vec2 ( phi , theta ) / vec2 ( 2.0 * pi , pi ) + vec2 ( 0.5 , 0.0 ) ;
vec3 L0 = vec3 ( 0.1 ) * Fex ;
// composition + solar disc
float sundisk = smoothstep ( sunAngularDiameterCos , sunAngularDiameterCos + 0.00002 , cosTheta ) ;
L0 += ( vSunE * 19000.0 * Fex ) * sundisk ;
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3 ( 0.0 , 0.0003 , 0.00075 ) ;
vec3 retColor = pow ( texColor , vec3 ( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) ) ;
gl _FragColor = vec4 ( retColor , 1.0 ) ;
# include < tonemapping _fragment >
# include < encodings _fragment >
} ` };const[nF,iF]=Ge(!1),EM=yl(()=>{const i=new _d;return i.scale.setScalar(45e4),tF(e=>{const{uniforms:t}=i.material;t.turbidity.value=e.turbidity,t.rayleigh.value=e.rayleigh,t.mieCoefficient.value=e.mieCoefficient,t.mieDirectionalG.value=e.mieDirectionalG;const n=Math.PI*(e.inclination-.5),r=2*Math.PI*(e.azimuth-.5);Ot.x=Math.cos(r),Ot.y=Math.sin(r)*Math.sin(n),Ot.z=Math.sin(r)*Math.cos(n),t.sunPosition.value.copy(Ot)}),i});let TM=!1;iF(i=>{TM!==i&&(TM=i,i? $ e.add(EM()): $ e.remove(EM()))});const[Cf,T9]=Er(),[rF,AM]=Ge(!1),[sF,CM]=Ge(!1),[oF,PM]=Ge(!1),RM={defines:{DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tColor:{value:null},tDepth:{value:null},focus:{value:1},aspect:{value:1},aperture:{value:.025},maxblur:{value:.01},nearClip:{value:1},farClip:{value:1e3}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
# include < common >
varying vec2 vUv ;
uniform sampler2D tColor ;
uniform sampler2D tDepth ;
uniform float maxblur ; // max blur amount
uniform float aperture ; // aperture - bigger values for shallower depth of field
uniform float nearClip ;
uniform float farClip ;
uniform float focus ;
uniform float aspect ;
# include < packing >
float getDepth ( const in vec2 screenPosition ) {
# if DEPTH _PACKING == 1
return unpackRGBAToDepth ( texture2D ( tDepth , screenPosition ) ) ;
# else
return texture2D ( tDepth , screenPosition ) . x ;
# endif
}
float getViewZ ( const in float depth ) {
# if PERSPECTIVE _CAMERA == 1
return perspectiveDepthToViewZ ( depth , nearClip , farClip ) ;
# else
return orthographicDepthToViewZ ( depth , nearClip , farClip ) ;
# endif
}
void main ( ) {
vec2 aspectcorrect = vec2 ( 1.0 , aspect ) ;
float viewZ = getViewZ ( getDepth ( vUv ) ) ;
float factor = ( focus + viewZ ) ; // viewZ is <= 0, so this is a difference equation
vec2 dofblur = vec2 ( clamp ( factor * aperture , - maxblur , maxblur ) ) ;
vec2 dofblur9 = dofblur * 0.9 ;
vec2 dofblur7 = dofblur * 0.7 ;
vec2 dofblur4 = dofblur * 0.4 ;
vec4 col = vec4 ( 0.0 ) ;
col += texture2D ( tColor , vUv . xy ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , 0.4 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.15 , 0.37 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , 0.29 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.37 , 0.15 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.40 , 0.0 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.37 , - 0.15 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , - 0.29 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.15 , - 0.37 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , - 0.4 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.15 , 0.37 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , 0.29 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.37 , 0.15 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.4 , 0.0 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.37 , - 0.15 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , - 0.29 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.15 , - 0.37 ) * aspectcorrect ) * dofblur ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.15 , 0.37 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.37 , 0.15 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.37 , - 0.15 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.15 , - 0.37 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.15 , 0.37 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.37 , 0.15 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.37 , - 0.15 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.15 , - 0.37 ) * aspectcorrect ) * dofblur9 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , 0.29 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.40 , 0.0 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , - 0.29 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , - 0.4 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , 0.29 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.4 , 0.0 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , - 0.29 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , 0.4 ) * aspectcorrect ) * dofblur7 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , 0.29 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.4 , 0.0 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.29 , - 0.29 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , - 0.4 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , 0.29 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.4 , 0.0 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( - 0.29 , - 0.29 ) * aspectcorrect ) * dofblur4 ) ;
col += texture2D ( tColor , vUv . xy + ( vec2 ( 0.0 , 0.4 ) * aspectcorrect ) * dofblur4 ) ;
gl _FragColor = col / 41.0 ;
gl _FragColor . a = 1.0 ;
} ` };class aF extends zs{constructor(e,t,n){super(),this.scene=e,this.camera=t;const r=n.focus!==void 0?n.focus:1,s=n.aspect!==void 0?n.aspect:t.aspect,o=n.aperture!==void 0?n.aperture:.025,l=n.maxblur!==void 0?n.maxblur:1,h=n.width||window.innerWidth||1,d=n.height||window.innerHeight||1;this.renderTargetDepth=new Yt(h,d,{minFilter:Xt,magFilter:Xt}),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new lu,this.materialDepth.depthPacking=Bm,this.materialDepth.blending=rn,RM===void 0&&console.error("THREE.BokehPass relies on BokehShader");const f=RM,g=Qn.clone(f.uniforms);g.tDepth.value=this.renderTargetDepth.texture,g.focus.value=r,g.aspect.value=s,g.aperture.value=o,g.maxblur.value=l,g.nearClip.value=t.near,g.farClip.value=t.far,this.materialBokeh=new kt({defines:Object.assign({},f.defines),uniforms:g,vertexShader:f.vertexShader,fragmentShader:f.fragmentShader}),this.uniforms=g,this.needsSwap=!1,this.fsQuad=new Ml(this.materialBokeh),this._oldClearColor=new Pe}render(e,t,n){this.scene.overrideMaterial=this.materialDepth,e.getClearColor(this._oldClearColor);const r=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.tColor.value=n.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),e.clear(),this.fsQuad.render(e)),this.scene.overrideMaterial=null,e.setClearColor(this._oldClearColor),e.setClearAlpha(r),e.autoClear=s}}const ib=new aF( $ e,Ze(),{});Ze(i=>ib.camera=i);const rb=ib.uniforms;jU(i=>rb.focus.value=i);WU(i=>rb.aperture.value=i);XU(i=>rb.maxblur.value=i);const lF=new vm(new kt({uniforms:{baseTexture:{value:null},bloomTexture:{value:ya.renderTarget2.texture}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
}
` ,fragmentShader: `
uniform sampler2D baseTexture ;
uniform sampler2D bloomTexture ;
varying vec2 vUv ;
void main ( ) {
gl _FragColor = texture2D ( baseTexture , vUv ) + texture2D ( bloomTexture , vUv ) ;
}
` ,defines:{}}),"baseTexture"),lh={defines:{NUM_SAMPLES:7,NUM_RINGS:4,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:0,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},tDiffuse:{value:null},tNormal:{value:null},size:{value:new ae(512,512)},cameraNear:{value:1},cameraFar:{value:100},cameraProjectionMatrix:{value:new Qe},cameraInverseProjectionMatrix:{value:new Qe},scale:{value:1},intensity:{value:.1},bias:{value:.5},minResolution:{value:0},kernelRadius:{value:100},randomSeed:{value:0}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
# include < common >
varying vec2 vUv ;
# if DIFFUSE _TEXTURE == 1
uniform sampler2D tDiffuse ;
# endif
uniform sampler2D tDepth ;
# if NORMAL _TEXTURE == 1
uniform sampler2D tNormal ;
# endif
uniform float cameraNear ;
uniform float cameraFar ;
uniform mat4 cameraProjectionMatrix ;
uniform mat4 cameraInverseProjectionMatrix ;
uniform float scale ;
uniform float intensity ;
uniform float bias ;
uniform float kernelRadius ;
uniform float minResolution ;
uniform vec2 size ;
uniform float randomSeed ;
// RGBA depth
# include < packing >
vec4 getDefaultColor ( const in vec2 screenPosition ) {
# if DIFFUSE _TEXTURE == 1
return texture2D ( tDiffuse , vUv ) ;
# else
return vec4 ( 1.0 ) ;
# endif
}
float getDepth ( const in vec2 screenPosition ) {
# if DEPTH _PACKING == 1
return unpackRGBAToDepth ( texture2D ( tDepth , screenPosition ) ) ;
# else
return texture2D ( tDepth , screenPosition ) . x ;
# endif
}
float getViewZ ( const in float depth ) {
# if PERSPECTIVE _CAMERA == 1
return perspectiveDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# else
return orthographicDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# endif
}
vec3 getViewPosition ( const in vec2 screenPosition , const in float depth , const in float viewZ ) {
float clipW = cameraProjectionMatrix [ 2 ] [ 3 ] * viewZ + cameraProjectionMatrix [ 3 ] [ 3 ] ;
vec4 clipPosition = vec4 ( ( vec3 ( screenPosition , depth ) - 0.5 ) * 2.0 , 1.0 ) ;
clipPosition *= clipW ; // unprojection.
return ( cameraInverseProjectionMatrix * clipPosition ) . xyz ;
}
vec3 getViewNormal ( const in vec3 viewPosition , const in vec2 screenPosition ) {
# if NORMAL _TEXTURE == 1
return unpackRGBToNormal ( texture2D ( tNormal , screenPosition ) . xyz ) ;
# else
return normalize ( cross ( dFdx ( viewPosition ) , dFdy ( viewPosition ) ) ) ;
# endif
}
float scaleDividedByCameraFar ;
float minResolutionMultipliedByCameraFar ;
float getOcclusion ( const in vec3 centerViewPosition , const in vec3 centerViewNormal , const in vec3 sampleViewPosition ) {
vec3 viewDelta = sampleViewPosition - centerViewPosition ;
float viewDistance = length ( viewDelta ) ;
float scaledScreenDistance = scaleDividedByCameraFar * viewDistance ;
return max ( 0.0 , ( dot ( centerViewNormal , viewDelta ) - minResolutionMultipliedByCameraFar ) / scaledScreenDistance - bias ) / ( 1.0 + pow2 ( scaledScreenDistance ) ) ;
}
// moving costly divides into consts
const float ANGLE _STEP = PI2 * float ( NUM _RINGS ) / float ( NUM _SAMPLES ) ;
const float INV _NUM _SAMPLES = 1.0 / float ( NUM _SAMPLES ) ;
float getAmbientOcclusion ( const in vec3 centerViewPosition ) {
// precompute some variables require in getOcclusion.
scaleDividedByCameraFar = scale / cameraFar ;
minResolutionMultipliedByCameraFar = minResolution * cameraFar ;
vec3 centerViewNormal = getViewNormal ( centerViewPosition , vUv ) ;
// jsfiddle that shows sample pattern: https://jsfiddle.net/a16ff1p7/
float angle = rand ( vUv + randomSeed ) * PI2 ;
vec2 radius = vec2 ( kernelRadius * INV _NUM _SAMPLES ) / size ;
vec2 radiusStep = radius ;
float occlusionSum = 0.0 ;
float weightSum = 0.0 ;
for ( int i = 0 ; i < NUM _SAMPLES ; i ++ ) {
vec2 sampleUv = vUv + vec2 ( cos ( angle ) , sin ( angle ) ) * radius ;
radius += radiusStep ;
angle += ANGLE _STEP ;
float sampleDepth = getDepth ( sampleUv ) ;
if ( sampleDepth >= ( 1.0 - EPSILON ) ) {
continue ;
}
float sampleViewZ = getViewZ ( sampleDepth ) ;
vec3 sampleViewPosition = getViewPosition ( sampleUv , sampleDepth , sampleViewZ ) ;
occlusionSum += getOcclusion ( centerViewPosition , centerViewNormal , sampleViewPosition ) ;
weightSum += 1.0 ;
}
if ( weightSum == 0.0 ) discard ;
return occlusionSum * ( intensity / weightSum ) ;
}
void main ( ) {
float centerDepth = getDepth ( vUv ) ;
if ( centerDepth >= ( 1.0 - EPSILON ) ) {
discard ;
}
float centerViewZ = getViewZ ( centerDepth ) ;
vec3 viewPosition = getViewPosition ( vUv , centerDepth , centerViewZ ) ;
float ambientOcclusion = getAmbientOcclusion ( viewPosition ) ;
gl _FragColor = getDefaultColor ( vUv ) ;
gl _FragColor . xyz *= 1.0 - ambientOcclusion ;
} ` },ho={defines:{KERNEL_RADIUS:4,DEPTH_PACKING:1,PERSPECTIVE_CAMERA:1},uniforms:{tDiffuse:{value:null},size:{value:new ae(512,512)},sampleUvOffsets:{value:[new ae(0,0)]},sampleWeights:{value:[1]},tDepth:{value:null},cameraNear:{value:10},cameraFar:{value:1e3},depthCutoff:{value:10}},vertexShader: `
# include < common >
uniform vec2 size ;
varying vec2 vUv ;
varying vec2 vInvSize ;
void main ( ) {
vUv = uv ;
vInvSize = 1.0 / size ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
# include < common >
# include < packing >
uniform sampler2D tDiffuse ;
uniform sampler2D tDepth ;
uniform float cameraNear ;
uniform float cameraFar ;
uniform float depthCutoff ;
uniform vec2 sampleUvOffsets [ KERNEL _RADIUS + 1 ] ;
uniform float sampleWeights [ KERNEL _RADIUS + 1 ] ;
varying vec2 vUv ;
varying vec2 vInvSize ;
float getDepth ( const in vec2 screenPosition ) {
# if DEPTH _PACKING == 1
return unpackRGBAToDepth ( texture2D ( tDepth , screenPosition ) ) ;
# else
return texture2D ( tDepth , screenPosition ) . x ;
# endif
}
float getViewZ ( const in float depth ) {
# if PERSPECTIVE _CAMERA == 1
return perspectiveDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# else
return orthographicDepthToViewZ ( depth , cameraNear , cameraFar ) ;
# endif
}
void main ( ) {
float depth = getDepth ( vUv ) ;
if ( depth >= ( 1.0 - EPSILON ) ) {
discard ;
}
float centerViewZ = - getViewZ ( depth ) ;
bool rBreak = false , lBreak = false ;
float weightSum = sampleWeights [ 0 ] ;
vec4 diffuseSum = texture2D ( tDiffuse , vUv ) * weightSum ;
for ( int i = 1 ; i <= KERNEL _RADIUS ; i ++ ) {
float sampleWeight = sampleWeights [ i ] ;
vec2 sampleUvOffset = sampleUvOffsets [ i ] * vInvSize ;
vec2 sampleUv = vUv + sampleUvOffset ;
float viewZ = - getViewZ ( getDepth ( sampleUv ) ) ;
if ( abs ( viewZ - centerViewZ ) > depthCutoff ) rBreak = true ;
if ( ! rBreak ) {
diffuseSum += texture2D ( tDiffuse , sampleUv ) * sampleWeight ;
weightSum += sampleWeight ;
}
sampleUv = vUv - sampleUvOffset ;
viewZ = - getViewZ ( getDepth ( sampleUv ) ) ;
if ( abs ( viewZ - centerViewZ ) > depthCutoff ) lBreak = true ;
if ( ! lBreak ) {
diffuseSum += texture2D ( tDiffuse , sampleUv ) * sampleWeight ;
weightSum += sampleWeight ;
}
}
gl _FragColor = diffuseSum / weightSum ;
} ` },_m={createSampleWeights:function(i,e){const t=[];for(let n=0;n<=i;n++)t.push(cF(n,e));return t},createSampleOffsets:function(i,e){const t=[];for(let n=0;n<=i;n++)t.push(e.clone().multiplyScalar(n));return t},configure:function(i,e,t,n){i.defines.KERNEL_RADIUS=e,i.uniforms.sampleUvOffsets.value=_m.createSampleOffsets(e,n),i.uniforms.sampleWeights.value=_m.createSampleWeights(e,t),i.needsUpdate=!0}};function cF(i,e){return Math.exp(-(i*i)/(2*(e*e)))/(Math.sqrt(2*Math.PI)*e)}const Pf={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader: `
varying vec2 vUv ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
uniform float opacity ;
uniform sampler2D tDiffuse ;
varying vec2 vUv ;
# include < packing >
void main ( ) {
float depth = 1.0 - unpackRGBAToDepth ( texture2D ( tDiffuse , vUv ) ) ;
gl _FragColor = vec4 ( vec3 ( depth ) , opacity ) ;
} ` };class fA extends zs{constructor(e,t,n=!1,r=!1,s=new ae(256,256)){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.supportsDepthTextureExtension=n,this.supportsNormalTexture=r,this.originalClearColor=new Pe,this._oldClearColor=new Pe,this.oldClearAlpha=1,this.params={output:0,saoBias:.5,saoIntensity:.18,saoScale:1,saoKernelRadius:100,saoMinResolution:0,saoBlur:!0,saoBlurRadius:8,saoBlurStdDev:4,saoBlurDepthCutoff:.01},this.resolution=new ae(s.x,s.y),this.saoRenderTarget=new Yt(this.resolution.x,this.resolution.y),this.blurIntermediateRenderTarget=this.saoRenderTarget.clone(),this.beautyRenderTarget=this.saoRenderTarget.clone(),this.normalRenderTarget=new Yt(this.resolution.x,this.resolution.y,{minFilter:Xt,magFilter:Xt}),this.depthRenderTarget=this.normalRenderTarget.clone();let o;this.supportsDepthTextureExtension&&(o=new Hm,o.type=pl,this.beautyRenderTarget.depthTexture=o,this.beautyRenderTarget.depthBuffer=!0),this.depthMaterial=new lu,this.depthMaterial.depthPacking=Bm,this.depthMaterial.blending=rn,this.normalMaterial=new Jm,this.normalMaterial.blending=rn,lh===void 0&&console.error("THREE.SAOPass relies on SAOShader"),this.saoMaterial=new kt({defines:Object.assign({},lh.defines),fragmentShader:lh.fragmentShader,vertexShader:lh.vertexShader,uniforms:Qn.clone(lh.uniforms)}),this.saoMaterial.extensions.derivatives=!0,this.saoMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.saoMaterial.defines.NORMAL_TEXTURE=this.supportsNormalTexture?1:0,this.saoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.saoMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?o:this.depthRenderTarget.texture,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.copy(this.camera.projectionMatrixInverse),this.saoMaterial.uniforms.cameraProjectionMatrix.value=this.camera.projectionMatrix,this.saoMaterial.blending=rn,ho===void 0&&console.error("THREE.SAOPass relies on DepthLimitedBlurShader"),this.vBlurMaterial=new kt({uniforms:Qn.clone(ho.uniforms),defines:Object.assign({},ho.defines),vertexShader:ho.vertexShader,fragmentShader:ho.fragmentShader}),this.vBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.vBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.vBlurMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.vBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?o:this.depthRenderTarget.texture,this.vBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.vBlurMaterial.blending=rn,this.hBlurMaterial=new kt({uniforms:Qn.clone(ho.uniforms),defines:Object.assign({},ho.defines),vertexShader:ho.vertexShader,fragmentShader:ho.fragmentShader}),this.hBlurMaterial.defines.DEPTH_PACKING=this.supportsDepthTextureExtension?0:1,this.hBlurMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.hBlurMaterial.uniforms.tDiffuse.value=this.blurIntermediateRenderTarget.texture,this.hBlurMaterial.uniforms.tDepth.value=this.supportsDepthTextureExtension?o:this.depthRenderTarget.texture,this.hBlurMaterial.uniforms.size.value.set(this.resolution.x,this.resolution.y),this.hBlurMaterial.blending=rn,_r===void 0&&console.error("THREE.SAOPass relies on CopyShader"),this.materialCopy=new kt({uniforms:Qn.clone(_r.uniforms),vertexShader:_r.vertexShader,fragmentShader:_r.fragmentShader,blending:rn}),this.materialCopy.transparent=!0,this.materialCopy.depthTest=!1,this.materialCopy.depthWrite=!1,this.materialCopy.blending=Fy,this.materialCopy.blendSrc=NE,this.materialCopy.blendDst=Vy,this.materialCopy.blendEquation=Es,this.materialCopy.blendSrcAlpha=kE,this.materialCopy.blendDstAlpha=Vy,this.materialCopy.blendEquationAlpha=Es,Pf===void 0&&console.error("THREE.SAOPass relies on UnpackDepthRGBAShader"),this.depthCopy=new kt({uniforms:Qn.clone(Pf.uniforms),vertexShader:Pf.vertexShader,fragmentShader:Pf.
uniform vec2 resolution ;
varying vec2 vUv ;
varying vec4 vOffset [ 3 ] ;
void SMAAEdgeDetectionVS ( vec2 texcoord ) {
vOffset [ 0 ] = texcoord . xyxy + resolution . xyxy * vec4 ( - 1.0 , 0.0 , 0.0 , 1.0 ) ; // WebGL port note: Changed sign in W component
vOffset [ 1 ] = texcoord . xyxy + resolution . xyxy * vec4 ( 1.0 , 0.0 , 0.0 , - 1.0 ) ; // WebGL port note: Changed sign in W component
vOffset [ 2 ] = texcoord . xyxy + resolution . xyxy * vec4 ( - 2.0 , 0.0 , 0.0 , 2.0 ) ; // WebGL port note: Changed sign in W component
}
void main ( ) {
vUv = uv ;
SMAAEdgeDetectionVS ( vUv ) ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
uniform sampler2D tDiffuse ;
varying vec2 vUv ;
varying vec4 vOffset [ 3 ] ;
vec4 SMAAColorEdgeDetectionPS ( vec2 texcoord , vec4 offset [ 3 ] , sampler2D colorTex ) {
vec2 threshold = vec2 ( SMAA _THRESHOLD , SMAA _THRESHOLD ) ;
// Calculate color deltas:
vec4 delta ;
vec3 C = texture2D ( colorTex , texcoord ) . rgb ;
vec3 Cleft = texture2D ( colorTex , offset [ 0 ] . xy ) . rgb ;
vec3 t = abs ( C - Cleft ) ;
delta . x = max ( max ( t . r , t . g ) , t . b ) ;
vec3 Ctop = texture2D ( colorTex , offset [ 0 ] . zw ) . rgb ;
t = abs ( C - Ctop ) ;
delta . y = max ( max ( t . r , t . g ) , t . b ) ;
// We do the usual threshold:
vec2 edges = step ( threshold , delta . xy ) ;
// Then discard if there is no edge:
if ( dot ( edges , vec2 ( 1.0 , 1.0 ) ) == 0.0 )
discard ;
// Calculate right and bottom deltas:
vec3 Cright = texture2D ( colorTex , offset [ 1 ] . xy ) . rgb ;
t = abs ( C - Cright ) ;
delta . z = max ( max ( t . r , t . g ) , t . b ) ;
vec3 Cbottom = texture2D ( colorTex , offset [ 1 ] . zw ) . rgb ;
t = abs ( C - Cbottom ) ;
delta . w = max ( max ( t . r , t . g ) , t . b ) ;
// Calculate the maximum delta in the direct neighborhood:
float maxDelta = max ( max ( max ( delta . x , delta . y ) , delta . z ) , delta . w ) ;
// Calculate left-left and top-top deltas:
vec3 Cleftleft = texture2D ( colorTex , offset [ 2 ] . xy ) . rgb ;
t = abs ( C - Cleftleft ) ;
delta . z = max ( max ( t . r , t . g ) , t . b ) ;
vec3 Ctoptop = texture2D ( colorTex , offset [ 2 ] . zw ) . rgb ;
t = abs ( C - Ctoptop ) ;
delta . w = max ( max ( t . r , t . g ) , t . b ) ;
// Calculate the final maximum delta:
maxDelta = max ( max ( maxDelta , delta . z ) , delta . w ) ;
// Local contrast adaptation in action:
edges . xy *= step ( 0.5 * maxDelta , delta . xy ) ;
return vec4 ( edges , 0.0 , 0.0 ) ;
}
void main ( ) {
gl _FragColor = SMAAColorEdgeDetectionPS ( vUv , vOffset , tDiffuse ) ;
} ` },Rf={defines:{SMAA_MAX_SEARCH_STEPS:"8",SMAA_AREATEX_MAX_DISTANCE:"16",SMAA_AREATEX_PIXEL_SIZE:"( 1.0 / vec2( 160.0, 560.0 ) )",SMAA_AREATEX_SUBTEX_SIZE:"( 1.0 / 7.0 )"},uniforms:{tDiffuse:{value:null},tArea:{value:null},tSearch:{value:null},resolution:{value:new ae(1/1024,1/512)}},vertexShader: `
uniform vec2 resolution ;
varying vec2 vUv ;
varying vec4 vOffset [ 3 ] ;
varying vec2 vPixcoord ;
void SMAABlendingWeightCalculationVS ( vec2 texcoord ) {
vPixcoord = texcoord / resolution ;
// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
vOffset [ 0 ] = texcoord . xyxy + resolution . xyxy * vec4 ( - 0.25 , 0.125 , 1.25 , 0.125 ) ; // WebGL port note: Changed sign in Y and W components
vOffset [ 1 ] = texcoord . xyxy + resolution . xyxy * vec4 ( - 0.125 , 0.25 , - 0.125 , - 1.25 ) ; // WebGL port note: Changed sign in Y and W components
// And these for the searches, they indicate the ends of the loops:
vOffset [ 2 ] = vec4 ( vOffset [ 0 ] . xz , vOffset [ 1 ] . yw ) + vec4 ( - 2.0 , 2.0 , - 2.0 , 2.0 ) * resolution . xxyy * float ( SMAA _MAX _SEARCH _STEPS ) ;
}
void main ( ) {
vUv = uv ;
SMAABlendingWeightCalculationVS ( vUv ) ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
# define SMAASampleLevelZeroOffset ( tex , coord , offset ) texture2D ( tex , coord + float ( offset ) * resolution , 0.0 )
uniform sampler2D tDiffuse ;
uniform sampler2D tArea ;
uniform sampler2D tSearch ;
uniform vec2 resolution ;
varying vec2 vUv ;
varying vec4 vOffset [ 3 ] ;
varying vec2 vPixcoord ;
# if _ _VERSION _ _ == 100
vec2 round ( vec2 x ) {
return sign ( x ) * floor ( abs ( x ) + 0.5 ) ;
}
# endif
float SMAASearchLength ( sampler2D searchTex , vec2 e , float bias , float scale ) {
// Not required if searchTex accesses are set to point:
// float2 SEARCH_TEX_PIXEL_SIZE = 1.0 / float2(66.0, 33.0);
// e = float2(bias, 0.0) + 0.5 * SEARCH_TEX_PIXEL_SIZE +
// e * float2(scale, 1.0) * float2(64.0, 32.0) * SEARCH_TEX_PIXEL_SIZE;
e . r = bias + e . r * scale ;
return 255.0 * texture2D ( searchTex , e , 0.0 ) . r ;
}
float SMAASearchXLeft ( sampler2D edgesTex , sampler2D searchTex , vec2 texcoord , float end ) {
/ * *
* @ PSEUDO _GATHER4
* This texcoord has been offset by ( - 0.25 , - 0.125 ) in the vertex shader to
* sample between edge , thus fetching four edges in a row .
* Sampling with different offsets in each direction allows to disambiguate
* which edges are active from the four fetched ones .
* /
vec2 e = vec2 ( 0.0 , 1.0 ) ;
for ( int i = 0 ; i < SMAA _MAX _SEARCH _STEPS ; i ++ ) { // WebGL port note: Changed while to for
e = texture2D ( edgesTex , texcoord , 0.0 ) . rg ;
texcoord -= vec2 ( 2.0 , 0.0 ) * resolution ;
if ( ! ( texcoord . x > end && e . g > 0.8281 && e . r == 0.0 ) ) break ;
}
// We correct the previous (-0.25, -0.125) offset we applied:
texcoord . x += 0.25 * resolution . x ;
// The searches are bias by 1, so adjust the coords accordingly:
texcoord . x += resolution . x ;
// Disambiguate the length added by the last step:
texcoord . x += 2.0 * resolution . x ; // Undo last step
texcoord . x -= resolution . x * SMAASearchLength ( searchTex , e , 0.0 , 0.5 ) ;
return texcoord . x ;
}
float SMAASearchXRight ( sampler2D edgesTex , sampler2D searchTex , vec2 texcoord , float end ) {
vec2 e = vec2 ( 0.0 , 1.0 ) ;
for ( int i = 0 ; i < SMAA _MAX _SEARCH _STEPS ; i ++ ) { // WebGL port note: Changed while to for
e = texture2D ( edgesTex , texcoord , 0.0 ) . rg ;
texcoord += vec2 ( 2.0 , 0.0 ) * resolution ;
if ( ! ( texcoord . x < end && e . g > 0.8281 && e . r == 0.0 ) ) break ;
}
texcoord . x -= 0.25 * resolution . x ;
texcoord . x -= resolution . x ;
texcoord . x -= 2.0 * resolution . x ;
texcoord . x += resolution . x * SMAASearchLength ( searchTex , e , 0.5 , 0.5 ) ;
return texcoord . x ;
}
float SMAASearchYUp ( sampler2D edgesTex , sampler2D searchTex , vec2 texcoord , float end ) {
vec2 e = vec2 ( 1.0 , 0.0 ) ;
for ( int i = 0 ; i < SMAA _MAX _SEARCH _STEPS ; i ++ ) { // WebGL port note: Changed while to for
e = texture2D ( edgesTex , texcoord , 0.0 ) . rg ;
texcoord += vec2 ( 0.0 , 2.0 ) * resolution ; // WebGL port note: Changed sign
if ( ! ( texcoord . y > end && e . r > 0.8281 && e . g == 0.0 ) ) break ;
}
texcoord . y -= 0.25 * resolution . y ; // WebGL port note: Changed sign
texcoord . y -= resolution . y ; // WebGL port note: Changed sign
texcoord . y -= 2.0 * resolution . y ; // WebGL port note: Changed sign
texcoord . y += resolution . y * SMAASearchLength ( searchTex , e . gr , 0.0 , 0.5 ) ; // WebGL port note: Changed sign
return texcoord . y ;
}
float SMAASearchYDown ( sampler2D edgesTex , sampler2D searchTex , vec2 texcoord , float end ) {
vec2 e = vec2 ( 1.0 , 0.0 ) ;
for ( int i = 0 ; i < SMAA _MAX _SEARCH _STEPS ; i ++ ) { // WebGL port note: Changed while to for
e = texture2D ( edgesTex , texcoord , 0.0 ) . rg ;
texcoord -= vec2 ( 0.0 , 2.0 ) * resolution ; // WebGL port note: Changed sign
if ( ! ( texcoord . y < end && e . r > 0.8281 && e . g == 0.0 ) ) break ;
}
texcoord . y += 0.25 * resolution . y ; // WebGL port note: Changed sign
texcoord . y += resolution . y ; // WebGL port note: Changed sign
texcoord . y += 2.0 * resolution . y ; // WebGL port note: Changed sign
texcoord . y -= resolution . y * SMAASearchLength ( searchTex , e . gr , 0.5 , 0.5 ) ; // WebGL port note: Changed sign
return texcoord . y ;
}
vec2 SMAAArea ( sampler2D areaTex , vec2 dist , float e1 , float e2 , float offset ) {
// Rounding prevents precision errors of bilinear filtering:
vec2 texcoord = float ( SMAA _AREATEX _MAX _DISTANCE ) * round ( 4.0 * vec2 ( e1 , e2 ) ) + dist ;
// We do a scale and bias for mapping to texel space:
texcoord = SMAA _AREATEX _PIXEL _SIZE * texcoord + ( 0.5 * SMAA _AREATEX _PIXEL _SIZE ) ;
// Move to proper place, according to the subpixel offset:
texcoord . y += SMAA _AREATEX _SUBTEX _SIZE * offset ;
return texture2D ( areaTex , texcoord , 0.0 ) . rg ;
}
vec4 SMAABlendingWeightCalculationPS ( vec2 texcoord , vec2 pixcoord , vec4 offset [ 3 ] , sampler2D edgesTex , sampler2D areaTex , sampler2D searchTex , ivec4 subsampleIndices ) {
vec4 weights = vec4 ( 0.0 , 0.0 , 0.0 , 0.0 ) ;
vec2 e = texture2D ( edgesTex , texcoord ) . rg ;
if ( e . g > 0.0 ) { // Edge at north
vec2 d ;
// Find the distance to the left:
vec2 coords ;
coords . x = SMAASearchXLeft ( edgesTex , searchTex , offset [ 0 ] . xy , offset [ 2 ] . x ) ;
coords . y = offset [ 1 ] . y ; // offset[1].y = texcoord.y - 0.25 * resolution.y (@CROSSING_OFFSET)
d . x = coords . x ;
// Now fetch the left crossing edges, two at a time using bilinear
// filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
// discern what value each edge has:
float e1 = texture2D ( edgesTex , coords , 0.0 ) . r ;
// Find the distance to the right:
coords . x = SMAASearchXRight ( edgesTex , searchTex , offset [ 0 ] . zw , offset [ 2 ] . y ) ;
d . y = coords . x ;
// We want the distances to be in pixel units (doing this here allow to
// better interleave arithmetic and memory accesses):
d = d / resolution . x - pixcoord . x ;
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
vec2 sqrt _d = sqrt ( abs ( d ) ) ;
// Fetch the right crossing edges:
coords . y -= 1.0 * resolution . y ; // WebGL port note: Added
float e2 = SMAASampleLevelZeroOffset ( edgesTex , coords , ivec2 ( 1 , 0 ) ) . r ;
// Ok, we know how this pattern looks like, now it is time for getting
// the actual area:
weights . rg = SMAAArea ( areaTex , sqrt _d , e1 , e2 , float ( subsampleIndices . y ) ) ;
}
if ( e . r > 0.0 ) { // Edge at west
vec2 d ;
// Find the distance to the top:
vec2 coords ;
coords . y = SMAASearchYUp ( edgesTex , searchTex , offset [ 1 ] . xy , offset [ 2 ] . z ) ;
coords . x = offset [ 0 ] . x ; // offset[1].x = texcoord.x - 0.25 * resolution.x;
d . x = coords . y ;
// Fetch the top crossing edges:
float e1 = texture2D ( edgesTex , coords , 0.0 ) . g ;
// Find the distance to the bottom:
coords . y = SMAASearchYDown ( edgesTex , searchTex , offset [ 1 ] . zw , offset [ 2 ] . w ) ;
d . y = coords . y ;
// We want the distances to be in pixel units:
d = d / resolution . y - pixcoord . y ;
// SMAAArea below needs a sqrt, as the areas texture is compressed
// quadratically:
vec2 sqrt _d = sqrt ( abs ( d ) ) ;
// Fetch the bottom crossing edges:
coords . y -= 1.0 * resolution . y ; // WebGL port note: Added
float e2 = SMAASampleLevelZeroOffset ( edgesTex , coords , ivec2 ( 0 , 1 ) ) . g ;
// Get the area for this direction:
weights . ba = SMAAArea ( areaTex , sqrt _d , e1 , e2 , float ( subsampleIndices . x ) ) ;
}
return weights ;
}
void main ( ) {
gl _FragColor = SMAABlendingWeightCalculationPS ( vUv , vPixcoord , vOffset , tDiffuse , tArea , tSearch , ivec4 ( 0.0 ) ) ;
} ` },Cy={uniforms:{tDiffuse:{value:null},tColor:{value:null},resolution:{value:new ae(1/1024,1/512)}},vertexShader: `
uniform vec2 resolution ;
varying vec2 vUv ;
varying vec4 vOffset [ 2 ] ;
void SMAANeighborhoodBlendingVS ( vec2 texcoord ) {
vOffset [ 0 ] = texcoord . xyxy + resolution . xyxy * vec4 ( - 1.0 , 0.0 , 0.0 , 1.0 ) ; // WebGL port note: Changed sign in W component
vOffset [ 1 ] = texcoord . xyxy + resolution . xyxy * vec4 ( 1.0 , 0.0 , 0.0 , - 1.0 ) ; // WebGL port note: Changed sign in W component
}
void main ( ) {
vUv = uv ;
SMAANeighborhoodBlendingVS ( vUv ) ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
} ` ,fragmentShader: `
uniform sampler2D tDiffuse ;
uniform sampler2D tColor ;
uniform vec2 resolution ;
varying vec2 vUv ;
varying vec4 vOffset [ 2 ] ;
vec4 SMAANeighborhoodBlendingPS ( vec2 texcoord , vec4 offset [ 2 ] , sampler2D colorTex , sampler2D blendTex ) {
// Fetch the blending weights for current pixel:
vec4 a ;
a . xz = texture2D ( blendTex , texcoord ) . xz ;
a . y = texture2D ( blendTex , offset [ 1 ] . zw ) . g ;
a . w = texture2D ( blendTex , offset [ 1 ] . xy ) . a ;
// Is there any blending weight with a value greater than 0.0?
if ( dot ( a , vec4 ( 1.0 , 1.0 , 1.0 , 1.0 ) ) < 1e-5 ) {
return texture2D ( colorTex , texcoord , 0.0 ) ;
} else {
// Up to 4 lines can be crossing a pixel (one through each edge). We
// favor blending by choosing the line with the maximum weight for each
// direction:
vec2 offset ;
offset . x = a . a > a . b ? a . a : - a . b ; // left vs. right
offset . y = a . g > a . r ? - a . g : a . r ; // top vs. bottom // WebGL port note: Changed signs
// Then we go in the direction that has the maximum weight:
if ( abs ( offset . x ) > abs ( offset . y ) ) { // horizontal vs. vertical
offset . y = 0.0 ;
} else {
offset . x = 0.0 ;
}
// Fetch the opposite color and lerp by hand:
vec4 C = texture2D ( colorTex , texcoord , 0.0 ) ;
texcoord += sign ( offset ) * resolution ;
vec4 Cop = texture2D ( colorTex , texcoord , 0.0 ) ;
float s = abs ( offset . x ) > abs ( offset . y ) ? abs ( offset . x ) : abs ( offset . y ) ;
// WebGL port note: Added gamma correction
C . xyz = pow ( C . xyz , vec3 ( 2.2 ) ) ;
Cop . xyz = pow ( Cop . xyz , vec3 ( 2.2 ) ) ;
vec4 mixed = mix ( C , Cop , s ) ;
mixed . xyz = pow ( mixed . xyz , vec3 ( 1.0 / 2.2 ) ) ;
return mixed ;
}
}
void main ( ) {
gl _FragColor = SMAANeighborhoodBlendingPS ( vUv , vOffset , tColor , tDiffuse ) ;
} ` };class uF extends zs{constructor(e,t){super(),this.edgesRT=new Yt(e,t,{depthBuffer:!1}),this.edgesRT.texture.name="SMAAPass.edges",this.weightsRT=new Yt(e,t,{depthBuffer:!1}),this.weightsRT.texture.name="SMAAPass.weights";const n=this,r=new Image;r.src=this.getAreaTexture(),r.onload=function(){n.areaTexture.needsUpdate=!0},this.areaTexture=new ti,this.areaTexture.name="SMAAPass.area",this.areaTexture.image=r,this.areaTexture.minFilter=Hn,this.areaTexture.generateMipmaps=!1,this.areaTexture.flipY=!1;const s=new Image;s.src=this.getSearchTexture(),s.onload=function(){n.searchTexture.needsUpdate=!0},this.searchTexture=new ti,this.searchTexture.name="SMAAPass.search",this.searchTexture.image=s,this.searchTexture.magFilter=Xt,this.searchTexture.minFilter=Xt,this.searchTexture.generateMipmaps=!1,this.searchTexture.flipY=!1,ch===void 0&&console.error("THREE.SMAAPass relies on SMAAShader"),this.uniformsEdges=Qn.clone(ch.uniforms),this.uniformsEdges.resolution.value.set(1/e,1/t),this.materialEdges=new kt({defines:Object.assign({},ch.defines),uniforms:this.uniformsEdges,vertexShader:ch.vertexShader,fragmentShader:ch.fragmentShader}),this.uniformsWeights=Qn.clone(Rf.uniforms),this.uniformsWeights.resolution.value.set(1/e,1/t),this.uniformsWeights.tDiffuse.value=this.edgesRT.texture,this.uniformsWeights.tArea.value=this.areaTexture,this.uniformsWeights.tSearch.value=this.searchTexture,this.materialWeights=new kt({defines:Object.assign({},Rf.defines),uniforms:this.uniformsWeights,vertexShader:Rf.vertexShader,fragmentShader:Rf.fragmentShader}),this.uniformsBlend=Qn.clone(Cy.uniforms),this.uniformsBlend.resolution.value.set(1/e,1/t),this.uniformsBlend.tDiffuse.value=this.weightsRT.texture,this.materialBlend=new kt({uniforms:this.uniformsBlend,vertexShader:Cy.vertexShader,fragmentShader:Cy.fragmentShader}),this.needsSwap=!1,this.fsQuad=new Ml(null)}render(e,t,n){this.uniformsEdges.tDiffuse.value=n.texture,this.fsQuad.material=this.materialEdges,e.setRenderTarget(this.edgesRT),this.clear&&e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialWeights,e.setRenderTarget(this.weightsRT),this.clear&&e.clear(),this.fsQuad.render(e),this.uniformsBlend.tColor.value=n.texture,this.fsQuad.material=this.materialBlend,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.fsQuad.render(e))}setSize(e,t){this.edgesRT.setSize(e,t),this.weightsRT.setSize(e,t),this.materialEdges.uniforms.resolution.value.set(1/e,1/t),this.materialWeights.uniforms.resolution.value.set(1/e,1/t),this.materialBlend.uniforms.resolution.value.set(1/e,1/t)}getAreaTexture(){return"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAIAAACOVPcQAACBeklEQVR42u39W4xlWXrnh/3WWvuciIzMrKxrV8/0rWbY0+SQFKcb4owIkSIFCjY9AC1BT/LYBozRi+EX+cV+8IMsYAaCwRcBwjzMiw2jAWtgwC8WR5Q8mDFHZLNHTarZGrLJJllt1W2qKrsumZWZcTvn7L3W54e1vrXX3vuciLPPORFR1XE2EomorB0nVuz//r71re/y/1eMvb4Cb3N11xV/PP/2v4UBAwJG/7H8urx6/25/Gf8O5hypMQ0EEEQwAqLfoN/Z+97f/SW+/NvcgQk4sGBJK6H7N4PFVL+K+e0N11yNfkKvwUdwdlUAXPHHL38oa15f/i/46Ih6SuMSPmLAYAwyRKn7dfMGH97jaMFBYCJUgotIC2YAdu+LyW9vvubxAP8kAL8H/koAuOKP3+q6+xGnd5kdYCeECnGIJViwGJMAkQKfDvB3WZxjLKGh8VSCCzhwEWBpMc5/kBbjawT4HnwJfhr+pPBIu7uu+OOTo9vsmtQcniMBGkKFd4jDWMSCRUpLjJYNJkM+IRzQ+PQvIeAMTrBS2LEiaiR9b/5PuT6Ap/AcfAFO4Y3dA3DFH7/VS+M8k4baEAQfMI4QfbVDDGIRg7GKaIY52qAjTAgTvGBAPGIIghOCYAUrGFNgzA7Q3QhgCwfwAnwe5vDejgG44o/fbm1C5ZlYQvQDARPAIQGxCWBM+wWl37ZQESb4gImexGMDouhGLx1Cst0Saa4b4AqO4Hk4gxo+3DHAV/nx27p3JziPM2pVgoiia5MdEzCGULprIN7gEEeQ5IQxEBBBQnxhsDb5auGmAAYcHMA9eAAz8PBol8/xij9+C4Djlim4gJjWcwZBhCBgMIIYxGAVIkH3ZtcBuLdtRFMWsPGoY9rN+HoBji9VBYdwD2ZQg4cnO7OSq/z4rU5KKdwVbFAjNojCQzTlCLPFSxtamwh2jMUcEgg2Wm/6XgErIBhBckQtGN3CzbVacERgCnfgLswhnvqf7QyAq/z4rRZm1YglYE3affGITaZsdIe2FmMIpnOCap25I6jt2kCwCW0D1uAD9sZctNGXcQIHCkINDQgc78aCr+zjtw3BU/ijdpw3zhCwcaONwBvdeS2YZKkJNJsMPf2JKEvC28RXxxI0ASJyzQCjCEQrO4Q7sFArEzjZhaFc4cdv+/JFdKULM4px0DfUBI2hIsy06BqLhGTQEVdbfAIZXYMPesq6VoCHICzUyjwInO4Y411//LYLs6TDa9wvg2CC2rElgAnpTBziThxaL22MYhzfkghz6GAs2VHbbdM91VZu1MEEpupMMwKyVTb5ij9+u4VJG/5EgEMMmFF01cFai3isRbKbzb+YaU/MQbAm2XSMoUPAmvZzbuKYRIFApbtlrfFuU
varying vec2 vUv ;
varying vec3 viewDir ;
void main ( ) {
vUv = uv ;
gl _Position = projectionMatrix * modelViewMatrix * vec4 ( position , 1.0 ) ;
viewDir = normalize ( ( modelViewMatrix * vec4 ( position , 1.0 ) ) . xyz ) ;
}
` ,fragmentShader: `
varying vec2 vUv ;
varying vec3 viewDir ;
uniform float baseIor ;
uniform float bandOffset ;
uniform float jitterIntensity ;
uniform float jitterOffset ;
uniform sampler2D tDiffuse ;
# include < common >
void main ( ) {
vec3 normal = vec3 ( ( 2.0 * vUv - vec2 ( 1.0 ) ) , 1.0 ) ;
normal . z = 1.0 ;
normal = normalize ( normal ) ;
vec3 color ;
// if NO BANDS
# if BAND _MODE == 0
vec3 refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor ) ;
color = texture2D ( tDiffuse , vUv + refracted . xy ) . rgb ;
// if RGB or RYGCBV BANDS
# else
float index , randValue , offsetValue ;
float r , g , b , r _ior , g _ior , b _ior ;
vec3 r _refracted , g _refracted , b _refracted ;
vec4 r _sample , g _sample , b _sample ;
# if BAND _MODE == 2
float y , c , v , y _ior , c _ior , v _ior ;
vec3 y _refracted , c _refracted , v _refracted ;
vec4 y _sample , c _sample , v _sample ;
# endif
for ( int i = 0 ; i < CHROMA _SAMPLES ; i ++ ) {
index = float ( i ) ;
randValue = rand ( sin ( index + 1. ) * gl _FragCoord . xy + vec2 ( jitterOffset , - jitterOffset ) ) - 0.5 ;
offsetValue = index / float ( CHROMA _SAMPLES ) + randValue * jitterIntensity ;
# if BAND _MODE == 1
randValue *= 2.0 ;
# endif
// Paper describing functions for creating yellow, cyan, and violet bands and reforming
// them into RGB:
// https://web.archive.org/web/20061108181225/http://home.iitk.ac.in/~shankars/reports/dispersionraytrace.pdf
r _ior = 1.0 + bandOffset * ( 0.0 + offsetValue ) ;
g _ior = 1.0 + bandOffset * ( 2.0 + offsetValue ) ;
b _ior = 1.0 + bandOffset * ( 4.0 + offsetValue ) ;
r _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / r _ior ) ;
g _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / g _ior ) ;
b _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / b _ior ) ;
r _sample = texture2D ( tDiffuse , vUv + r _refracted . xy ) ;
g _sample = texture2D ( tDiffuse , vUv + g _refracted . xy ) ;
b _sample = texture2D ( tDiffuse , vUv + b _refracted . xy ) ;
# if BAND _MODE == 2
y _ior = 1.0 + bandOffset * ( 1.0 + offsetValue ) ;
c _ior = 1.0 + bandOffset * ( 3.0 + offsetValue ) ;
v _ior = 1.0 + bandOffset * ( 5.0 + offsetValue ) ;
y _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / y _ior ) ;
c _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / c _ior ) ;
v _refracted = refract ( vec3 ( 0.0 , 0.0 , - 1.0 ) , normal , baseIor / v _ior ) ;
y _sample = texture2D ( tDiffuse , vUv + y _refracted . xy ) ;
c _sample = texture2D ( tDiffuse , vUv + c _refracted . xy ) ;
v _sample = texture2D ( tDiffuse , vUv + v _refracted . xy ) ;
r = r _sample . r / 2.0 ;
y = ( 2.0 * y _sample . r + 2.0 * y _sample . g - y _sample . b ) / 6.0 ;
g = g _sample . g / 2.0 ;
c = ( 2.0 * c _sample . g + 2.0 * c _sample . b - c _sample . r ) / 6.0 ;
b = b _sample . b / 2.0 ;
v = ( 2.0 * v _sample . b + 2.0 * v _sample . r - v _sample . g ) / 6.0 ;
color . r += r + ( 2.0 * v + 2.0 * y - c ) / 3.0 ;
color . g += g + ( 2.0 * y + 2.0 * c - v ) / 3.0 ;
color . b += b + ( 2.0 * c + 2.0 * v - y ) / 3.0 ;
# else
color . r += r _sample . r ;
color . g += g _sample . g ;
color . b += b _sample . b ;
# endif
}
color /= float ( CHROMA _SAMPLES ) ;
# endif
gl _FragColor = vec4 ( color , 1.0 ) ;
}
2023-05-30 00:33:57 +08:00
` })),{uniforms:vA}=mA;xT(i=>vA.baseIor.value=i);_T(i=>vA.bandOffset.value=i);var dF=!!window.safari;const gA=dF,Uc=(()=>{if(gA)return new S_(Sn());const i=new Yt(iv,rv,{samples:4});return mi(([e,t])=>i.setSize(e,t)),new S_(Sn(),i)})();Kt(()=>{Uc.renderer=Sn();const[i,e]=mi();Uc.setSize(i,e),Uc.setPixelRatio(Zc())},[Sn,mi,Zc]);Kt(()=>{const i=[Gx];PM()&&i.push(qx),dm()&&i.push(xd),u_()&&i.push(gd),CM()&&i.push(lF),xM()&&i.push(ib),AM()&&i.push(Ps),h_()&&i.push(mA),gA&&i.push(hF);for(const e of i)Uc.addPass(e);return()=>{for(const e of i)Uc.removePass(e)}},[PM,dm,u_,CM,xM,AM,h_]);async function pF(){const{Sphere:i,Cylinder:e,Vec3:t}=await pu(),{x:n,y:r}=El(this),s=n*.5,o=r*.5,l=new i(s),h=new i(s),d=new e(s,s,Math.abs(r-n));this.cannonBody.addShape(l,new t(0,-o+s,0)),this.cannonBody.addShape(h,new t(0,o-s,0)),this.cannonBody.addShape(d)}const LM=Math.PI*.5;class yA extends To{constructor(e){super(new ei),this._physicsShape=pF,this.updatePolarAngle=Mr(()=>this.gyrate(0,0),0,"trailing"),this._minPolarAngle=Bx*xn,this._maxPolarAngle=zx*xn,this.mouseControlState=new Tn(!1),this.camera=e,this.object3d.add(e),this.initCamera()}getRay(){return dT.set(this.camera.getWorldPosition(bo),this.camera.getWorldDirection(Ot))}append(e){this._append(e),this.camera.add(e.outerObject3d)}attach(e){this._append(e),this.camera.attach(e.outerObject3d)}get width(){return this.object3d.scale.x*pn}set width(e){const t=e*Ye;this.object3d.scale.x=t,this.camera.scale.x=1/t}get height(){return this.object3d.scale.y*pn}set height(e){const t=e*Ye;this.object3d.scale.y=t,this.camera.scale.y=1/t}get depth(){return this.object3d.scale.z*pn}set depth(e){const t=e*Ye;this.object3d.scale.z=t,this.camera.scale.z=1/t}lookAt(e){super.lookAt(e),this.rotationY+=180}_gyrate(e,t,n){const r=n?this.object3d:this.outerObject3d;Wi.setFromQuaternion(r.quaternion),Wi.y-=e*.002,Wi.x-=t*.002,Wi.x=Math.max(LM-this._maxPolarAngle,Math.min(LM-this._minPolarAngle,Wi.x)),r.setRotationFromEuler(Wi),!n&&this.physicsRotate()}gyrate(e,t){this.mouseControlMode==="orbit"?this._gyrate(e,t):(this._gyrate(e,0),this._gyrate(0,t,!0))}get minPolarAngle(){return this._minPolarAngle*pi}set minPolarAngle(e){this._minPolarAngle=e*xn,this.updatePolarAngle()}get maxPolarAngle(){return this._maxPolarAngle*pi}set maxPolarAngle(e){this._maxPolarAngle=e*xn,this.updatePolarAngle()}get mouseControl(){return this.mouseControlState.get()}set mouseControl(e){this.mouseControlState.set(e),!(!e||this.mouseControlInit)&&(this.mouseControlInit=!0, $ n(()=>import("./enableMouseControl.f708247b.js"),["./enableMouseControl.f708247b.js","./entry.c3abd651.js","./entry.f74844d6.css"],import.meta.url).then(t=>t.default.call(this)))}getCenter(){return this.getWorldPosition()}}ks(yA,[aA]);const Lf=5.7,DM=(i,e)=>Math.abs(i*.5/Math.cos(e.fov*.6*xn));Kt(()=>{var i;const[e,t]=mi(),[n,r]=(i=Jc())!==null&&i!==void 0?i:mi(),s=Ze(),o=e/t;s instanceof fi&&!Kc()?(s.aspect=o,s.updateProjectionMatrix()):s instanceof ou&&([s.left,s.right,s.top,s.bottom]=[o*Lf*-.5,o*Lf*.5,Lf*.5,Lf*-.5],s.updateProjectionMatrix());const l={width:e,height:r-(n-e)*r/n},h={width:n-(r-t)*n/r,height:t},d=Math.min(e-l.width,t-l.height),f=Math.min(e-h.width,t-h.height);d>f?(bM(DM(n/o,bn)*Ye),Object.assign(Jh.style,{width:l.width+"px",height:l.height+"px"})):(bM(DM(r,bn)*Ye),Object.assign(Jh.style,{width:h.width+"px",height:h.height+"px"}))},[mi,Jc,Ze,Kc]);Kt(()=>{const i=Kc(),e=Ze(),t=Qc(),n=Sn();if(t){const[h,d]=mi(),f=h*1,g=d*.5;t.aspect=e.aspect=f/g,e.updateProjectionMatrix(),t.updateProjectionMatrix();const y=wi(()=>{Af(),n.setViewport(0,0,f,g),n.setScissor(0,0,f,g),n.setScissorTest(!0),n.render( $ e,t),n.setViewport(0,g,f,g),n.setScissor(0,g,f,g),n.render( $ e,e),Cf()});return()=>{y.cancel(),n.setViewport(0,0,h,d),n.setScissor(0,0,h,d),n.setScissorTest(!1),e.aspect=h/d,e.updateProjectionMatrix()}}if(Kh()==="speed"||i==="webxr"){const h=wi(()=>{Af(),n.render( $ e,e),Cf()});return()=>{h.cancel()}}if(i){const h=new dv;h.scale=.5,h.visible=!1;const d=1e3,f=-d*.5,[g,y]=mi(),_=g*.5,w=y*1;e.aspect=_/w,e.updateProjectionMatrix();const S=new Sa(e),b=wi(()=>{Af(),n.se
2023-05-28 15:00:40 +08:00
Copyright ( c ) Microsoft Corporation .
Permission to use , copy , modify , and / or distribute this software for any
purpose with or without fee is hereby granted .
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS . IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL , DIRECT ,
INDIRECT , OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE , DATA OR PROFITS , WHETHER IN AN ACTION OF CONTRACT , NEGLIGENCE OR
OTHER TORTIOUS ACTION , ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / v a r F e = f u n c t i o n ( ) { r e t u r n F e = O b j e c t . a s s i g n | | f u n c t i o n ( e ) { f o r ( v a r t , n = 1 , r = a r g u m e n t s . l e n g t h ; n < r ; n + + ) { t = a r g u m e n t s [ n ] ; f o r ( v a r s i n t ) O b j e c t . p r o t o t y p e . h a s O w n P r o p e r t y . c a l l ( t , s ) & & ( e [ s ] = t [ s ] ) } r e t u r n e } , F e . a p p l y ( t h i s , a r g u m e n t s ) } ; f u n c t i o n c b ( i , e ) { v a r t = { } ; f o r ( v a r n i n i ) O b j e c t . p r o t o t y p e . h a s O w n P r o p e r t y . c a l l ( i , n ) & & e . i n d e x O f ( n ) < 0 & & ( t [ n ] = i [ n ] ) ; i f ( i ! = n u l l & & t y p e o f O b j e c t . g e t O w n P r o p e r t y S y m b o l s = = " f u n c t i o n " ) f o r ( v a r r = 0 , n = O b j e c t . g e t O w n P r o p e r t y S y m b o l s ( i ) ; r < n . l e n g t h ; r + + ) e . i n d e x O f ( n [ r ] ) < 0 & & O b j e c t . p r o t o t y p e . p r o p e r t y I s E n u m e r a b l e . c a l l ( i , n [ r ] ) & & ( t [ n [ r ] ] = i [ n [ r ] ] ) ; r e t u r n t } f u n c t i o n Q t ( i ) { v a r e = t y p e o f S y m b o l = = " f u n c t i o n " & & S y m b o l . i t e r a t o r , t = e & & i [ e ] , n = 0 ; i f ( t ) r e t u r n t . c a l l ( i ) ; i f ( i & & t y p e o f i . l e n g t h = = " n u m b e r " ) r e t u r n { n e x t : f u n c t i o n ( ) { r e t u r n i & & n > = i . l e n g t h & & ( i = v o i d 0 ) , { v a l u e : i & & i [ n + + ] , d o n e : ! i } } } ; t h r o w n e w T y p e E r r o r ( e ? " O b j e c t i s n o t i t e r a b l e . " : " S y m b o l . i t e r a t o r i s n o t d e f i n e d . " ) } f u n c t i o n o n ( i , e ) { v a r t = t y p e o f S y m b o l = = " f u n c t i o n " & & i [ S y m b o l . i t e r a t o r ] ; i f ( ! t ) r e t u r n i ; v a r n = t . c a l l ( i ) , r , s = [ ] , o ; t r y { f o r ( ; ( e = = = v o i d 0 | | e - - > 0 ) & & ! ( r = n . n e x t ( ) ) . d o n e ; ) s . p u s h ( r . v a l u e ) } c a t c h ( l ) { o = { e r r o r : l } } f i n a l l y { t r y { r & & ! r . d o n e & & ( t = n . r e t u r n ) & & t . c a l l ( n ) } f i n a l l y { i f ( o ) t h r o w o . e r r o r } } r e t u r n s } f u n c t i o n V n ( i , e , t ) { i f ( t | | a r g u m e n t s . l e n g t h = = = 2 ) f o r ( v a r n = 0 , r = e . l e n g t h , s ; n < r ; n + + ) ( s | | ! ( n i n e ) ) & & ( s | | ( s = A r r a y . p r o t o t y p e . s l i c e . c a l l ( e , 0 , n ) ) , s [ n ] = e [ n ] ) ; r e t u r n i . c o n c a t ( s | | A r r a y . p r o t o t y p e . s l i c e . c a l l ( e ) ) } v a r m n ; ( f u n c t i o n ( i ) { i . S t a r t = " x s t a t e . s t a r t " , i . S t o p = " x s t a t e . s t o p " , i . R a i s e = " x s t a t e . r a i s e " , i . S e n d = " x s t a t e . s e n d " , i . C a n c e l = " x s t a t e . c a n c e l " , i . N u l l E v e n t = " " , i . A s s i g n = " x s t a t e . a s s i g n " , i . A f t e r = " x s t a t e . a f t e r " , i . D o n e S t a t e = " d o n e . s t a t e " , i . D o n e I n v o k e = " d o n e . i n v o k e " , i . L o g = " x s t a t e . l o g " , i . I n i t = " x s t a t e . i n i t " , i . I n v o k e = " x s t a t e . i n v o k e " , i . E r r o r E x e c u t i o n = " e r r o r . e x e c u t i o n " , i . E r r o r C o m m u n i c a t i o n = " e r r o r . c o m m u n i c a t i o n " , i . E r r o r P l a t f o r m = " e r r o r . p l a t f o r m " , i . E r r o r C u s t o m = " x s t a t e . e r r o r " , i . U p d a t e = " x s t a t e . u p d a t e " , i . P u r e = " x s t a t e . p u r e " , i . C h o o s e = " x s t a t e . c h o o s e " } ) ( m n | | ( m n = { } ) ) ; v a r e d ; ( f u n c t i o n ( i ) { i . P a r e n t = " # _ p a r e n t " , i . I n t e r n a l = " # _ i n t e r n a l " } ) ( e d | | ( e d = { } ) ) ; v a r D _ = m n . S t a r t , u b = m n . S t o p , b v = m n . R a i s e , w v = m n . S e n d , R A = m n . C a n c e l , O F = m n . N u l l E v e n t , N M = m n . A s s i g n ; m n . A f t e r ; m n . D o n e S t a t e ; v a r L A = m n . L o g , k F = m n . I n i t , I _ = m n . I n v o k e ; m n . E r r o r E x e c u t i o n ; v a r B M = m n . E r r o r P l a t f o r m , N F = m n . E r r o r C u s t o m , D A = m n . U p d a t e , B F = m n . C h o o s e , z F = m n . P u r e , I A = " . " , z M = { } , O _ = " x s t a t e . g u a r d " , U F = " " , P y ; f u n c t i o n h b ( i , e , t ) { t = = = v o i d 0 & & ( t = I A ) ; v a r n = T h ( i , t ) , r = T h ( e , t ) ; r e t u r n a n ( r ) ? a n ( n ) ? r = = = n : ! 1 : a n ( n ) ? n i n r : O b j e c t . k e y s ( n ) . e v e r y ( f u n c t i o n ( s ) { r e t u r n s i n r ? h b ( n [ s ] , r [ s ] ) : ! 1 } ) } f u n c t i o n O A ( i ) { t r y { r e t u r n a n ( i ) | | t y p e o f i = = " n u m b e r " ? " " . c o n c a t ( i ) : i . t y p e } c a t c h { t h r o w n e w E r r o r ( " E v e n t s m u s t b e s t r i n g s o r o b j e c t s w i t h a s t r i n g e v e n t . t y p e p r o p e r t y . " ) } } f u n c t i o n k _ ( i , e ) { t r y { r e t u r n m u ( i ) ? i : i . t o S t r i n g ( ) . s p l i t ( e ) } c a t c h { t h r o w n e w E r r o r ( " ' " . c o n c a t ( i , " ' i s n o t a v a l i d s t a t e p a t h . " ) ) } } f u n c t i o n F F ( i ) { r e t u r n t y p e o f i = = " o b j e c t " & & " v a l u e " i n i & & " c o n t e x t " i n i & & " e v e n t " i n i & & " _ e v e n t " i n i } f u n c t i o n T h ( i , e ) { i f ( F F ( i ) ) r e t u r n i . v a l u e ; i f ( m u ( i ) ) r e t u r n x m ( i ) ; i f ( t y p e o f i ! = " s t r i n g " ) r e t u r n i ; v a r t = k _ ( i , e ) ; r e t u r n x m ( t ) } f u n c t i o n x m ( i ) { i f ( i . l e n g t h = = = 1 ) r e t u r n i [ 0 ] ; f o r ( v a r e = { } , t = e , n = 0 ; n < i . l e n g t h - 1 ; n + + ) n = = = i . l e n g t h - 2 ? t [ i [ n ] ] = i [ n + 1 ] : ( t [ i [ n ] ] = { } , t = t [ i [ n ] ] ) ; r e t u r n e } f u n c t i o n m h ( i , e ) { f o r ( v a r t = { } , n = O b j e c t . k e y s ( i ) , r = 0 ; r < n . l e n g t h ; r + + ) { v a r s = n [ r ] ; t [ s ] = e ( i [ s ] , s , i , r ) } r e t u r n t } f u n c t i o n U M ( i , e , t ) { v a r n , r , s = { } ; t r y { f o r ( v a r o = Q t ( O b j e c t . k e y s ( i ) ) , l = o . n e x t ( ) ; ! l . d o n e ; l = o . n e x t ( ) ) { v a r h = l . v a l u e , d = i [ h ] ; t ( d ) & & ( s [ h ] = e ( d , h , i ) ) } } c a t c h ( f ) { n = { e r r o r : f } } f i n a l l y { t r y { l & & ! l . d o n e & & ( r = o . r e t u r n ) & & r . c a l l ( o ) } f i n a l l y { i f ( n ) t h r o w n . e r r o r } } r e t u r n s } v a r V F = f u n c t i o n ( i ) { r e t u r n f u n c t i o n ( e ) { v a r t , n , r = e ; t r y { f o r ( v a r s = Q t ( i ) , o = s . n e x t ( ) ; ! o . d o n e ; o = s . n e x t ( ) ) { v a r l = o . v a l u e ; r = r [ l ] } } c a t c h ( h ) { t = { e r r o r : h } } f i n a l l y { t r y { o & & ! o . d o n e & & ( n = s . r e t u r n ) & & n . c a l l ( s ) } f i n a l l y { i f ( t ) t h r o w t . e r r o r } } r e t u r n r } } ; f u n c t i o n H F ( i , e ) { r e t u r n f u n c t i o n ( t ) { v a r n , r , s = t ; t r y { f o r ( v a r o = Q t ( i ) , l = o . n e x t ( ) ; ! l . d o n e ; l = o . n e x t ( ) ) { v a r h = l . v a l u e ; s = s [ e ] [ h ] } } c a t c h ( d ) { n = { e r r o r : d } } f i n a l l y { t r y { l & & ! l . d o n e & & ( r = o . r e t u r n ) & & r . c a l l ( o ) } f i n a l l y { i f ( n ) t h r o w n . e r r o r } } r e t u r n s } } f u n c t i o n W f ( i ) { i f ( ! i ) r e t u r n [ [ ] ] ; i f ( a n ( i ) ) r e t u r n [ [ i ] ] ; v a r e = R n ( O b j e c t . k e y s ( i ) . m a p ( f u n c t i o n ( t ) { v a r n = i [ t ] ; r e t u r n t y p e o f n ! = " s t r i n g " & & ( ! n | | ! O b j e c
Event : ` ).concat(JSON.stringify(y.data)));return n.scheduler.schedule(function(){n.forward(y);var _=n.nextState(y);n.update(_,y)}),n._state},this.sendTo=function(f,g){var y=n.parent&&(g===ed.Parent||n.parent.id===g),_=y?n.parent:an(g)?n.children.get(g)||kf.get(g):YF(g)?g:void 0;if(!_){if(!y)throw new Error("Unable to send event to child '".concat(g,"' from service '").concat(n.id,"'."));return}"machine"in _?_.send(Fe(Fe({},f),{name:f.name===NF?"".concat(vh(n.id)):f.name,origin:n.sessionId})):_.send(f.data)};var r=Fe(Fe({},i.defaultOptions),t),s=r.clock,o=r.logger,l=r.parent,h=r.id,d=h!==void 0?h:e.id;this.id=d,this.logger=o,this.clock=s,this.parent=l,this.options=r,this.scheduler=new GM({deferEvents:this.options.deferEvents}),this.sessionId=kf.bookId()}return Object.defineProperty(i.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:gh(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(i.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),i.prototype.execute=function(e,t){var n,r;try{for(var s=Qt(e.actions),o=s.next();!o.done;o=s.next()){var l=o.value;this.exec(l,e,t)}}catch(h){n={error:h}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},i.prototype.update=function(e,t){var n,r,s,o,l,h,d,f,g=this;if(e._sessionid=this.sessionId,this._state=e,this.options.execute&&this.execute(this.state),this.children.forEach(function(k){g.state.children[k.id]=k}),this.devTools&&this.devTools.send(t.data,e),e.event)try{for(var y=Qt(this.eventListeners),_=y.next();!_.done;_=y.next()){var w=_.value;w(e.event)}}catch(k){n={error:k}}finally{try{_&&!_.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}try{for(var S=Qt(this.listeners),b=S.next();!b.done;b=S.next()){var w=b.value;w(e,e.event)}}catch(k){s={error:k}}finally{try{b&&!b.done&&(o=S.return)&&o.call(S)}finally{if(s)throw s.error}}try{for(var T=Qt(this.contextListeners),E=T.next();!E.done;E=T.next()){var C=E.value;C(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(k){l={error:k}}finally{try{E&&!E.done&&(h=T.return)&&h.call(T)}finally{if(l)throw l.error}}var A=Ah(e.configuration||[],this.machine);if(this.state.configuration&&A){var D=e.configuration.find(function(k){return k.type==="final"&&k.parent===g.machine}),I=D&&D.doneData?bm(D.doneData,e.context,t):void 0;try{for(var F=Qt(this.doneListeners),P=F.next();!P.done;P=F.next()){var w=P.value;w(jf(this.id,I))}}catch(k){d={error:k}}finally{try{P&&!P.done&&(f=F.return)&&f.call(F)}finally{if(d)throw d.error}}this.stop()}},i.prototype.onTransition=function(e){return this.listeners.add(e),this.status===Vi.Running&&e(this.state,this.state.event),this},i.prototype.subscribe=function(e,t,n){var r=this;if(!e)return{unsubscribe:function(){}};var s,o=n;return typeof e=="function"?s=e:(s=e.next.bind(e),o=e.complete.bind(e)),this.listeners.add(s),this.status!==Vi.NotStarted&&s(this.state),o&&(this.status===Vi.Stopped?o():this.onDone(o)),{unsubscribe:function(){s&&r.listeners.delete(s),o&&r.doneListeners.delete(o)}}},i.prototype.onEvent=function(e){return this.eventListeners.add(e),this},i.prototype.onSend=function(e){return this.sendListeners.add(e),this},i.prototype.onChange=function(e){return this.contextListeners.add(e),this},i.prototype.onStop=function(e){return this.stopListeners.add(e),this},i.prototype.onDone=function(e){return this.doneListeners.add(e),this},i.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},i.prototype.start=function(e){var t=this;if(this.status===Vi.Running)return this;this.machine._init(),kf.register(this.sessionId,this),this.initialized=!0,this.status=Vi.Running;var n=e===void 0?this.initialState:gh(this,function(){return pV(e)?t.machine.resolveState(e):t.machine.resolveState(po.from(e,t.machine.context))});return this.options.devTool
` ).concat(D.message))}if(T&&b){y.target!==void 0&&(h=y.target),l.push.apply(l,Vn([],on(y.actions),!1)),d=y;break}}}catch(D){n={error:D}}finally{try{g&&!g.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}if(d){if(!h.length)return{transitions:[d],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:l};var E=Rn(h.map(function(D){return s.getRelativeStateNodes(D,e.historyValue)})),C=!!d.internal,A=C?[]:Rn(E.map(function(D){return s.nodesFromChild(D)}));return{transitions:[d],entrySet:A,exitSet:C?[]:[this],configuration:E,source:e,actions:l}}},i.prototype.nodesFromChild=function(e){if(e.escapes(this))return[];for(var t=[],n=e;n&&n!==this;)t.push(n),n=n.parent;return t.push(this),t},i.prototype.escapes=function(e){if(this===e)return!1;for(var t=this.parent;t;){if(t===e)return!1;t=t.parent}return!0},i.prototype.getActions=function(e,t,n,r){var s,o,l,h,d=Dc([],r?this.getStateNodes(r.value):[this]),f=e.configuration.length?Dc(d,e.configuration):d;try{for(var g=Qt(f),y=g.next();!y.done;y=g.next()){var _=y.value;Xf(d,_)||e.entrySet.push(_)}}catch(F){s={error:F}}finally{try{y&&!y.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}try{for(var w=Qt(d),S=w.next();!S.done;S=w.next()){var _=S.value;(!Xf(f,_)||Xf(e.exitSet,_.parent))&&e.exitSet.push(_)}}catch(F){l={error:F}}finally{try{S&&!S.done&&(h=w.return)&&h.call(w)}finally{if(l)throw l.error}}var b=Rn(e.entrySet.map(function(F){var P=[];if(F.type!=="final")return P;var k=F.parent;if(!k.parent)return P;P.push(Of(F.id,F.doneData),Of(k.id,F.doneData?bm(F.doneData,t,n):void 0));var j=k.parent;return j.type==="parallel"&&iu(j).every(function(G){return Ah(e.configuration,G)})&&P.push(Of(j.id)),P}));e.exitSet.sort(function(F,P){return P.order-F.order}),e.entrySet.sort(function(F,P){return F.order-P.order});var T=new Set(e.entrySet),E=new Set(e.exitSet),C=on([Rn(Array.from(T).map(function(F){return Vn(Vn([],on(F.activities.map(function(P){return tV(P)})),!1),on(F.onEntry),!1)})).concat(b.map(KF)),Rn(Array.from(E).map(function(F){return Vn(Vn([],on(F.onExit),!1),on(F.activities.map(function(P){return nV(P)})),!1)}))],2),A=C[0],D=C[1],I=Sm(D.concat(e.actions).concat(A),this.machine.options.actions);return I},i.prototype.transition=function(e,t,n){e===void 0&&(e=this.initialState);var r=Ri(t),s;if(e instanceof po)s=n===void 0?e:this.resolveState(po.from(e,n));else{var o=an(e)?this.resolve(xm(this.getResolvedPath(e))):this.resolve(e),l=n??this.machine.context;s=this.resolveState(po.from(o,l))}if(this.strict&&!this.events.includes(r.name)&&!GF(r.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(r.name,"'"));var h=this._transition(s.value,s,r)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:s,actions:[]},d=Dc([],this.getStateNodes(s.value)),f=h.configuration.length?Dc(d,h.configuration):d;return h.configuration=Vn([],on(f),!1),this.resolveTransition(h,s,s.context,r)},i.prototype.resolveRaisedTransition=function(e,t,n){var r,s=e.actions;return e=this.transition(e,t),e._event=n,e.event=n.data,(r=e.actions).unshift.apply(r,Vn([],on(s),!1)),e},i.prototype.resolveTransition=function(e,t,n,r){var s,o,l=this;r===void 0&&(r=wm);var h=e.configuration,d=!t||e.transitions.length>0,f=d?uV(this.machine,h):void 0,g=t?t.historyValue?t.historyValue:e.source?this.machine.historyValue(t.value):void 0:void 0,y=this.getActions(e,n,r,t),_=t?Fe({},t.activities):{};try{for(var w=Qt(y),S=w.next();!S.done;S=w.next()){var b=S.value;b.type===D_?_[b.activity.id||b.activity.type]=b:b.type===ub&&(_[b.activity.id||b.activity.type]=!1)}}catch(re){s={error:re}}finally{try{S&&!S.done&&(o=w.return)&&o.call(w)}finally{if(s)throw s.error}}var T=on(z_(this,t,n,r,y,this.machine.config.preserveActionOrder),2),E=T[0],C=T[1],A=on(NA(E,function(re){return re.type===bv||re.type===wv&&re.to===ed.Internal}),2),D=A[0],I=A[1],F=E.filter(function(re){var se;return re.type===D_&&((se=re.activity)===null||se===void 0?void 0:se.type)===I_}),P=F.reduce(function(re,se){return re[se.activity.id]=sV(se.activity,l.machine,C,r),re},t?Fe({},t.children):{}),k=d?e.config
2023-05-30 00:33:57 +08:00
` ).concat(l.message))}else return t.getStateNodeByPath(s)})},i.prototype.formatTransition=function(e){var t=this,n=ZF(e.target),r="internal"in e?e.internal:n?n.some(function(h){return an(h)&&h[0]===t.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),l=Fe(Fe({},e),{actions:Sm(ns(e.actions)),cond:zA(e.cond,s),target:o,source:this,internal:r,eventType:e.event,toJSON:function(){return Fe(Fe({},l),{target:l.target?l.target.map(function(h){return"#".concat(h.id)}):void 0,source:"#".concat(t.id)})}});return l},i.prototype.formatTransitions=function(){var e,t,n=this,r;if(!this.config.on)r=[];else if(Array.isArray(this.config.on))r=this.config.on;else{var s=this.config.on,o=Ly,l=s[o],h=l===void 0?[]:l,d=cb(s,[typeof o=="symbol"?o:o+""]);r=Rn(Object.keys(d).map(function(E){var C=Cc(E,d[E]);return C}).concat(Cc(Ly,h)))}var f=this.config.always?Cc("",this.config.always):[],g=this.config.onDone?Cc(String(Of(this.id)),this.config.onDone):[],y=Rn(this.invoke.map(function(E){var C=[];return E.onDone&&C.push.apply(C,Vn([],on(Cc(String(jf(E.id)),E.onDone)),!1)),E.onError&&C.push.apply(C,Vn([],on(Cc(String(vh(E.id)),E.onError)),!1)),C})),_=this.after,w=Rn(Vn(Vn(Vn(Vn([],on(g),!1),on(y),!1),on(r),!1),on(f),!1).map(function(E){return ns(E).map(function(C){return n.formatTransition(C)})}));try{for(var S=Qt(_),b=S.next();!b.done;b=S.next()){var T=b.value;w.push(T)}}catch(E){e={error:E}}finally{try{b&&!b.done&&(t=S.return)&&t.call(S)}finally{if(e)throw e.error}}return w},i}();function EV(i,e){return new MV(i,e)}const mb=bt(Me({},ab),{preset:String,strideForward:Number,strideRight:Number,strideMove:Boolean}),qA=bt(Me({},lb),{preset:"default",strideForward:0,strideRight:0,strideMove:!1});var TV=EV({states:{idle:{on:{RUN_START:"running",RUN_BACKWARDS_START:"runningBackwards",JUMP_START:"jumping"}},running:{on:{RUN_STOP:"idle",RUN_BACKWARDS_START:"runningBackwards",JUMP_START:"jumping"}},runningBackwards:{on:{RUN_STOP:"idle",RUN_START:"running",JUMP_START:"jumping"}},jumping:{on:{JUMP_STOP:"idle"}}},initial:"idle"});const hh="https://unpkg.com/lingo3d-dummy@1.0.1/assets/";class Sv extends Ao{constructor(){super(),this.poseService=XA(TV),this.srcState=new Tn(hh+"ybot.fbx"),this.presetState=new Tn("default"),this.strideForwardState=new Tn(0),this.strideRightState=new Tn(0),this.strideMoveState=new Tn(!1),this.jumpHeight=10,this.width=20,this.depth=20,this.pbr=!0,this.createEffect(()=>{super.src=this.srcState.get();const l=this.presetState.get()==="rifle"?"rifle-":"";this.animations={idle:hh+l+"idle.fbx",running:hh+l+"running.fbx",runningBackwards:hh+l+"running-backwards.fbx",jumping:hh+l+"falling.fbx"},this.animation="idle"},[this.presetState.get,this.srcState.get]);const{poseService:e}=this,[t,n]=Ge("idle");this.createEffect(()=>{if((this.animation=n())!=="jumping")return;this.velocity.y=this.jumpHeight;const l=wi(()=>{this.velocity.y===0&&e.send("JUMP_STOP")});return()=>{l.cancel()}},[n]),e.onTransition(o=>o.changed&&t(o.value)).start(),this.then(()=>e.stop());const[r,s]=Ge(void 0);this.loadedResolvable.then(()=>r({spine:this.find("mixamorigSpine",!0)})),this.createEffect(()=>{const o=s();if(!o)return;const{spine:l}=o,{strideForward:h,strideRight:d,strideMove:f}=this;if(!h&&!d){const b=this.pointAt(1e3);this.loadedGroup.lookAt(Mh(b)),e.send("RUN_STOP");return}const g=h>0,y=g?-h:h,_=g?-d:d,w=90-Math.atan2(-y,-_)*pi,S=nb(()=>{e.send(g?"RUN_BACKWARDS_START":"RUN_START");const b=this.pointAt(1e3);this.loadedGroup.lookAt(Mh(b));const T=l.pointAt(1e3),E=this.getWorldPosition(),C=Tz({x:b.x,y:b.z},{x:E.x,y:E.z},w),A=new Sh(C.x,b.y,C.y);if(this.loadedGroup.lookAt(Mh(A)),l.lookAt(T),!f)return;const{x:D,y:I}=Az(0,0,w+90,Math.max(Math.abs(h),Math.abs(d)));this.moveForward(g?I:-I),this.moveRight(g?-D:D)});return()=>{S.cancel()}},[this.strideMoveState.get,this.strideForwardState.get,this.strideRightState.get,s])}get src(){return this.srcState.get()}set src(e){this.srcState.set(e)}get preset(){return this.presetState.get()}set preset(e){this.presetState.set(e)}get strideForward(){return this.strideForwardState.get()}set strideForward(e){this.s
2023-05-28 15:00:40 +08:00
position : absolute ;
width : 100 % ;
height : 100 % ;
top : 0 px ;
left : 0 px ;
display : flex ;
} ` ,document.head.appendChild(n),(r,s)=>(SE(),ME("div",{class:"lingo3d",style:P4({position:e.position})},[e1("div",KV,[Dm(r. $ slots,"default")]),e1("div",{ref_key:"divRef",ref:t,style:{height:"100%","flex-grow":"1",position:"relative","z-index":"0"}},null,512)],4))}});var Ld,At,PC,Ch,RC, $ M,Em={},LC=[],QV=/acit|ex(?:s|g|n|p| $ )|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function go(i,e){for(var t in e)i[t]=e[t];return i}function DC(i){var e=i.parentNode;e&&e.removeChild(i)}function Bc(i,e,t){var n,r,s,o={};for(s in e)s=="key"?n=e[s]:s=="ref"?r=e[s]:o[s]=e[s];if(arguments.length>2&&(o.children=arguments.length>3?Ld.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(s in i.defaultProps)o[s]===void 0&&(o[s]=i.defaultProps[s]);return Ph(i,o,n,r,null)}function Ph(i,e,t,n,r){var s={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:r??++PC};return r==null&&At.vnode!=null&&At.vnode(s),s}function vu(i){return i.children}function qf(i,e){this.props=i,this.context=e}function ru(i,e){if(e==null)return i.__?ru(i.__,i.__.__k.indexOf(i)+1):null;for(var t;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null)return t.__e;return typeof i.type=="function"?ru(i):null}function IC(i){var e,t;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,e=0;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null){i.__e=i.__c.base=t.__e;break}return IC(i)}}function eE(i){(!i.__d&&(i.__d=!0)&&Ch.push(i)&&!Tm.__r++|| $ M!==At.debounceRendering)&&(( $ M=At.debounceRendering)||RC)(Tm)}function Tm(){for(var i;Tm.__r=Ch.length;)i=Ch.sort(function(e,t){return e.__v.__b-t.__v.__b}),Ch=[],i.some(function(e){var t,n,r,s,o,l;e.__d&&(o=(s=(t=e).__v).__e,(l=t.__P)&&(n=[],(r=go({},s)).__v=s.__v+1,wb(l,s,r,t.__n,l.ownerSVGElement!==void 0,s.__h!=null?[o]:null,n,o??ru(s),s.__h),BC(n,s),s.__e!=o&&IC(s)))})}function OC(i,e,t,n,r,s,o,l,h,d){var f,g,y,_,w,S,b,T=n&&n.__k||LC,E=T.length;for(t.__k=[],f=0;f<e.length;f++)if((_=t.__k[f]=(_=e[f])==null||typeof _=="boolean"?null:typeof _=="string"||typeof _=="number"||typeof _=="bigint"?Ph(null,_,null,null,_):Array.isArray(_)?Ph(vu,{children:_},null,null,null):_.__b>0?Ph(_.type,_.props,_.key,null,_.__v):_)!=null){if(_.__=t,_.__b=t.__b+1,(y=T[f])===null||y&&_.key==y.key&&_.type===y.type)T[f]=void 0;else for(g=0;g<E;g++){if((y=T[g])&&_.key==y.key&&_.type===y.type){T[g]=void 0;break}y=null}wb(i,_,y=y||Em,r,s,o,l,h,d),w=_.__e,(g=_.ref)&&y.ref!=g&&(b||(b=[]),y.ref&&b.push(y.ref,null,_),b.push(g,_.__c||w,_)),w!=null?(S==null&&(S=w),typeof _.type=="function"&&_.__k===y.__k?_.__d=h=kC(_,h,i):h=NC(i,_,y,T,w,h),typeof t.type=="function"&&(t.__d=h)):h&&y.__e==h&&h.parentNode!=i&&(h=ru(y))}for(t.__e=S,f=E;f--;)T[f]!=null&&(typeof t.type=="function"&&T[f].__e!=null&&T[f].__e==t.__d&&(t.__d=ru(n,f+1)),UC(T[f],T[f]));if(b)for(f=0;f<b.length;f++)zC(b[f],b[++f],b[++f])}function kC(i,e,t){for(var n,r=i.__k,s=0;r&&s<r.length;s++)(n=r[s])&&(n.__=i,e=typeof n.type=="function"?kC(n,e,t):NC(t,n,n,r,n.__e,e));return e}function NC(i,e,t,n,r,s){var o,l,h;if(e.__d!==void 0)o=e.__d,e.__d=void 0;else if(t==null||r!=s||r.parentNode==null)e:if(s==null||s.parentNode!==i)i.appendChild(r),o=null;else{for(l=s,h=0;(l=l.nextSibling)&&h<n.length;h+=2)if(l==r)break e;i.insertBefore(r,s),o=s}return o!==void 0?o:r.nextSibling}function $ V(i,e,t,n,r){var s;for(s in t)s==="children"||s==="key"||s in e||Am(i,s,null,t[s],n);for(s in e)r&&typeof e[s]!="function"||s==="children"||s==="key"||s==="value"||s==="checked"||t[s]===e[s]||Am(i,s,e[s],t[s],n)}function tE(i,e,t){e[0]==="-"?i.setProperty(e,t):i[e]=t==null?"":typeof t!="number"||QV.test(e)?t:t+"px"}function Am(i,e,t,n,r){var s;e:if(e==="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||tE(i.style,e,"");if(t)for(e in t)n&&t[e]===n[e]||tE(i.style,e,t[e])}else if(e[0]==="o"&&e[1]==="n")s=e!==(e=e.replace(/Capture $ /,"")),e=e.toLowerCase()in i?e.toLowerCase().slice(2):e.slice(2),i.l||(i.l={}),i.l[e+s]=t,t?n||i.addEventListener(e,s?iE:nE,s):i.removeEventListener(e,s?iE:nE,s);else i
` ).map(L=>m.createTextNode(L)).forEach((L,q)=>{q>0&&p.appendChild(m.createElement("br")),p.appendChild(L)}),p}class we{constructor(c,p){this.element=c.createElement("div"),this.element.classList.add(B()),p.viewProps.bindClassModifiers(this.element);const x=c.createElement("div");x.classList.add(B("l")),I(p.props,"label",q=>{f(q)?this.element.classList.add(B(void 0,"nol")):(this.element.classList.remove(B(void 0,"nol")),yt(x),x.appendChild(he(c,q)))}),this.element.appendChild(x),this.labelElement=x;const L=c.createElement("div");L.classList.add(B("v")),this.element.appendChild(L),this.valueElement=L}}class Ne extends nt{constructor(c,p){const x=p.valueController.viewProps;super(Object.assign(Object.assign({},p),{view:new we(c,{props:p.props,viewProps:x}),viewProps:x})),this.props=p.props,this.valueController=p.valueController,this.view.valueElement.appendChild(this.valueController.view.element)}}const Ue={id:"button",type:"blade",accept(m){const c=fe,p=Ce(m,{title:c.required.string,view:c.required.constant("button"),label:c.optional.string});return p?{params:p}:null},controller(m){return new Ne(m.document,{blade:m.blade,props:K.fromObject({label:m.params.label}),valueController:new ne(m.document,{props:K.fromObject({title:m.params.title}),viewProps:m.viewProps})})},api(m){return!(m.controller instanceof Ne)||!(m.controller.valueController instanceof ne)?null:new S(m.controller)}};class Xe extends nt{constructor(c){super(c),this.value=c.value}}function U(){return new K({positions: $ ([],{equals:g})})}class Ee extends K{constructor(c){super(c)}static create(c){const p={completed:!0,expanded:c,expandedHeight:null,shouldFixHeight:!1,temporaryExpanded:null},x=K.createCore(p);return new Ee(x)}get styleExpanded(){var c;return(c=this.get("temporaryExpanded"))!==null&&c!==void 0?c:this.get("expanded")}get styleHeight(){if(!this.styleExpanded)return"0";const c=this.get("expandedHeight");return this.get("shouldFixHeight")&&!f(c)? ` $ { c } px ` :"auto"}bindExpandedClass(c,p){const x=()=>{this.styleExpanded?c.classList.add(p):c.classList.remove(p)};I(this,"expanded",x),I(this,"temporaryExpanded",x)}cleanUpTransition(){this.set("shouldFixHeight",!1),this.set("expandedHeight",null),this.set("completed",!0)}}function Je(m,c){let p=0;return vt(c,()=>{m.set("expandedHeight",null),m.set("temporaryExpanded",!0),Le(c),p=c.clientHeight,m.set("temporaryExpanded",null),Le(c)}),p}function ke(m,c){c.style.height=m.styleHeight}function X(m,c){m.value("expanded").emitter.on("beforechange",()=>{m.set("completed",!1),f(m.get("expandedHeight"))&&m.set("expandedHeight",Je(m,c)),m.set("shouldFixHeight",!0),Le(c)}),m.emitter.on("change",()=>{ke(m,c)}),ke(m,c),c.addEventListener("transitionend",p=>{p.propertyName==="height"&&m.cleanUpTransition()})}class Re extends r{constructor(c,p){super(c),this.rackApi_=p}}function De(m,c){return m.addBlade(Object.assign(Object.assign({},c),{view:"button"}))}function at(m,c){return m.addBlade(Object.assign(Object.assign({},c),{view:"folder"}))}function ze(m,c){const p=c||{};return m.addBlade(Object.assign(Object.assign({},p),{view:"separator"}))}function et(m,c){return m.addBlade(Object.assign(Object.assign({},c),{view:"tab"}))}class Ie{constructor(c){this.emitter=new b,this.items_=[],this.cache_=new Set,this.onSubListAdd_=this.onSubListAdd_.bind(this),this.onSubListRemove_=this.onSubListRemove_.bind(this),this.extract_=c}get items(){return this.items_}allItems(){return Array.from(this.cache_)}find(c){for(const p of this.allItems())if(c(p))return p;return null}includes(c){return this.cache_.has(c)}add(c,p){if(this.includes(c))throw _.shouldNeverHappen();const x=p!==void 0?p:this.items_.length;this.items_.splice(x,0,c),this.cache_.add(c);const L=this.extract_(c);L&&(L.emitter.on("add",this.onSubListAdd_),L.emitter.on("remove",this.onSubListRemove_),L.allItems().forEach(q=>{this.cache_.add(q)})),this.emitter.emit("add",{index:x,item:c,root:this,target:this})}remove(c){const p=this.items_.indexOf(c);if(p<0)return;this.items_.splice(p,1),this.cache_.delete(c);const x=this.extract_(c);x&&(x.emitter.off("add",this.onSubListAdd_),x.em
2023-05-30 00:33:57 +08:00
` ),p&&(c.scrollTop=c.scrollHeight)}onValueUpdate_(){this.update_()}}class Xo{constructor(c,p){this.value=p.value,this.viewProps=p.viewProps,this.view=new Ha(c,{formatter:p.formatter,lineCount:p.lineCount,value:this.value,viewProps:this.viewProps})}}const hp=E("sgl");class dp{constructor(c,p){this.onValueUpdate_=this.onValueUpdate_.bind(this),this.formatter_=p.formatter,this.element=c.createElement("div"),this.element.classList.add(hp()),p.viewProps.bindClassModifiers(this.element);const x=c.createElement("input");x.classList.add(hp("i")),x.readOnly=!0,x.type="text",p.viewProps.bindDisabled(x),this.element.appendChild(x),this.inputElement=x,p.value.emitter.on("change",this.onValueUpdate_),this.value=p.value,this.update_()}update_(){const c=this.value.rawValue,p=c[c.length-1];this.inputElement.value=p!==void 0?this.formatter_(p):""}onValueUpdate_(){this.update_()}}class Gu{constructor(c,p){this.value=p.value,this.viewProps=p.viewProps,this.view=new dp(c,{formatter:p.formatter,value:this.value,viewProps:this.viewProps})}}const Gr={id:"monitor-bool",type:"monitor",accept:(m,c)=>{if(typeof m!="boolean")return null;const x=Ce(c,{lineCount:fe.optional.number});return x?{initialValue:m,params:x}:null},binding:{reader:m=>Su},controller:m=>{var c;return m.value.rawValue.length===1?new Gu(m.document,{formatter:Mu,value:m.value,viewProps:m.viewProps}):new Xo(m.document,{formatter:Mu,lineCount:(c=m.params.lineCount)!==null&&c!==void 0?c:Va.monitor.defaultLineCount,value:m.value,viewProps:m.viewProps})}};class Wu{constructor(){this.emitter=new b,this.index_=-1}get index(){return this.index_}set index(c){this.index_!==c&&(this.index_=c,this.emitter.emit("change",{index:c,sender:this}))}}const Ai=E("grl");class $ i{constructor(c,p){this.onCursorChange_=this.onCursorChange_.bind(this),this.onValueUpdate_=this.onValueUpdate_.bind(this),this.element=c.createElement("div"),this.element.classList.add(Ai()),p.viewProps.bindClassModifiers(this.element),this.formatter_=p.formatter,this.minValue_=p.minValue,this.maxValue_=p.maxValue,this.cursor_=p.cursor,this.cursor_.emitter.on("change",this.onCursorChange_);const x=c.createElementNS(it,"svg");x.classList.add(Ai("g")),x.style.height= ` calc ( var ( -- bld - us ) * $ { p . lineCount } ) ` ,this.element.appendChild(x),this.svgElem_=x;const L=c.createElementNS(it,"polyline");this.svgElem_.appendChild(L),this.lineElem_=L;const q=c.createElement("div");q.classList.add(Ai("t"),E("tt")()),this.element.appendChild(q),this.tooltipElem_=q,p.value.emitter.on("change",this.onValueUpdate_),this.value=p.value,this.update_()}get graphElement(){return this.svgElem_}update_(){const c=this.svgElem_.getBoundingClientRect(),p=this.value.rawValue.length-1,x=this.minValue_,L=this.maxValue_,q=[];this.value.rawValue.forEach((jt,Jt)=>{if(jt===void 0)return;const jr=hn(Jt,0,p,0,c.width),Yo=hn(jt,x,L,c.height,0);q.push([jr,Yo].join(","))}),this.lineElem_.setAttributeNS(null,"points",q.join(" "));const ee=this.tooltipElem_,Oe=this.value.rawValue[this.cursor_.index];if(Oe===void 0){ee.classList.remove(Ai("t","a"));return}const lt=hn(this.cursor_.index,0,p,0,c.width),mt=hn(Oe,x,L,c.height,0);ee.style.left= ` $ { lt } px ` ,ee.style.top= ` $ { mt } px ` ,ee.textContent= ` $ { this . formatter _ ( Oe ) } ` ,ee.classList.contains(Ai("t","a"))||(ee.classList.add(Ai("t","a"),Ai("t","in")),Le(ee),ee.classList.remove(Ai("t","in")))}onValueUpdate_(){this.update_()}onCursorChange_(){this.update_()}}class qg{constructor(c,p){if(this.onGraphMouseMove_=this.onGraphMouseMove_.bind(this),this.onGraphMouseLeave_=this.onGraphMouseLeave_.bind(this),this.onGraphPointerDown_=this.onGraphPointerDown_.bind(this),this.onGraphPointerMove_=this.onGraphPointerMove_.bind(this),this.onGraphPointerUp_=this.onGraphPointerUp_.bind(this),this.value=p.value,this.viewProps=p.viewProps,this.cursor_=new Wu,this.view=new $ i(c,{cursor:this.cursor_,formatter:p.formatter,lineCount:p.lineCount,maxValue:p.maxValue,minValue:p.minValue,value:this.value,viewProps:this.viewProps}),!ve(c))this.view.element.addEventListener("mousemove",this.onGraphMouseMove_),this.view.element.addEventListener("mouseleave",this.onGra
2023-05-28 15:00:40 +08:00
const App = ( ) => {
return (
< World >
$ { r3 ( Dv ( ) ) }
< / W o r l d >
)
}
` ,{parser:"babel",plugins:[e]});Rb("App.jsx",t)};const s3=i=>{let e="";for(const t of i){const n=rs.exports.upperFirst(t.type);let r="";for(let[s,o]of Object.entries(t))s==="children"||s==="type"||!o||(s=rs.exports.kebabCase(s),typeof o=="string"?r+= ` $ { s } = '${o}' ` :o===!0?r+= ` $ { s } ` :typeof o=="object"?r+= ` : $ { s } = '${JSON.stringify(o)}' ` :r+= ` : $ { s } = '${o}' ` );e+="children"in t&&t.children? ` < $ { n } $ { r } >
$ { s3 ( t . children ) } < / $ { n } >
` : ` < $ { n } $ { r } / >
2023-05-30 00:33:57 +08:00
` }return e};var tH=async()=>{const i=(await $ n(()=>import("./standalone.536d1d41.js"),["./standalone.536d1d41.js","./entry.c3abd651.js","./entry.f74844d6.css"],import.meta.url).then(function(n){return n.s})).default,e=(await $ n(()=>import("./parser-html.51027de1.js"),["./parser-html.51027de1.js","./entry.c3abd651.js","./entry.f74844d6.css"],import.meta.url).then(function(n){return n.p})).default,t=i.format( `
2023-05-28 15:00:40 +08:00
< template >
< World >
$ { s3 ( Dv ( ) ) }
< / W o r l d >
< / t e m p l a t e >
2023-05-30 00:33:57 +08:00
` ,{parser:"vue",plugins:[e]});Rb("App.vue",t)};const nH=async()=>{const i=(await $ n(()=>import("./standalone.536d1d41.js"),["./standalone.536d1d41.js","./entry.c3abd651.js","./entry.f74844d6.css"],import.meta.url).then(function(n){return n.s})).default,e=(await $ n(()=>import("./parser-babel.96f1b09f.js"),["./parser-babel.96f1b09f.js","./entry.c3abd651.js","./entry.f74844d6.css"],import.meta.url).then(function(n){return n.p})).default,t=i.format(JSON.stringify(Dv()),{parser:"json",plugins:[e]});Rb("scene.json",t)},iH=async()=>{const e=await(await z8({extensions:[".json"]})).text();for(const t of Li)t.dispose();try{AC(JSON.parse(e))}catch{}},rH=()=>{const[i,e]=p8();let[t,n]=f8();i==="scale"&&(t="local");const[r]=zv(),s=r&&!(r instanceof Sa);return Sb(()=>{s&&i==="scale"&&e("translate")},[s]),ye("div",{className:"lingo3d-ui",style:{width:50,height:"100%",background:"rgb(40, 41, 46)",borderRight:"1px solid rgba(255, 255, 255, 0.05)",overflow:"hidden"},children:ye("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",opacity:.75,paddingTop:12},children:[ye(Ss,{active:i==="select",onClick:()=>e("select"),children:ye(O8,{})}),ye(Ss,{active:i==="translate",onClick:()=>e("translate"),children:ye(P8,{})}),ye(Ss,{active:i==="rotate",onClick:()=>e("rotate"),children:ye(R8,{})}),ye(Ss,{active:i==="scale",disabled:s,onClick:()=>e("scale"),children:ye(L8,{})}),ye(Iy,{}),ye(Ss,{active:t==="world",onClick:()=>n("world"),disabled:i==="scale"||i==="select",children:ye(D8,{})}),ye(Ss,{active:t==="local",onClick:()=>n("local"),disabled:i==="select",children:ye(I8,{})}),ye(Iy,{}),ye(Ss,{onClick:iH,children:ye(N8,{})}),ye(Ss,{onClick:nH,children:ye(k8,{})}),ye(Iy,{}),ye(Ss,{onClick:eH,children:ye(Q8,{})}),ye(Ss,{onClick:tH,children:ye( $ 8,{})})]})})};Nv(rH,"lingo3d-toolbar");let Rm;wn.addEventListener("dragover",i=>i.preventDefault());wn.addEventListener("dragenter",i=>i.preventDefault());wn.addEventListener("drop",i=>{if(!Rm||!Qh())return;const e=EC(Rm),{x:t,y:n,z:r}=PT(i,!0);e.outerObject3d.position.set(t,n,r),Di(e)});const pE=({name:i,iconName:e=i})=>ye("div",{onDragStart:()=>Rm=i,onDragEnd:()=>Rm=void 0,style:{width:"50%",display:"flex",flexDirection:"column",alignItems:"center",paddingTop:20,paddingBottom:20},children:[ye("img",{style:{width:50},src: ` https : //unpkg.com/lingo3d-editor@1.0.1/assets/${e}.png`}),ye("div",{style:{marginTop:6,opacity:.75,overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:rs.exports.upperFirst(i)})]}),fE=i=>typeof i=="string"?i.endsWith("Camera")?"camera":i.endsWith("Light")?"light":i:Object.values(i)[0],mE=i=>typeof i=="string"?i:Object.keys(i)[0],sH=({names:i})=>{const e=[];let t=[],n=0;for(const r of i)n===0&&e.push(t=[]),t.push(r),++n===2&&(n=0);return ye(vu,{children:e.map(([r,s],o)=>ye("div",{style:{display:"flex"},children:[ye(pE,{name:mE(r),iconName:fE(r)}),s&&ye(pE,{name:mE(s),iconName:fE(s)})]},o))})},oH=()=>ye("div",{className:"lingo3d-ui",style:{width:200,height:"100%",background:"rgb(40, 41, 46)",padding:10},children:ye(sH,{names:["model","dummy","svgMesh","trigger","reflector","cube","sphere","cone","cylinder","octahedron","tetrahedron","torus","plane","circle","areaLight","ambientLight","skyLight","directionalLight","pointLight","spotLight","camera","thirdPersonCamera","firstPersonCamera","orbitCamera"]})});Nv(oH,"lingo3d-library");const o3=document.createElement("style");document.head.appendChild(o3);o3.innerHTML=`.lingo3d-ui * {
2023-05-28 15:00:40 +08:00
user - select : none ;
- webkit - user - select : none ;
position : relative ;
box - sizing : border - box ;
font - family : ui - sans - serif , system - ui , - apple - system , BlinkMacSystemFont , "Segoe UI" , Roboto , "Helvetica Neue" , Arial , "Noto Sans" , sans - serif , "Apple Color Emoji" , "Segoe UI Emoji" , "Segoe UI Symbol" , "Noto Color Emoji" ! important ;
}
. lingo3d - ui {
position : relative ;
box - sizing : border - box ;
overflow - x : hidden ;
overflow - y : scroll ;
float : left ;
color : white ;
font - size : 11 px ;
}
. lingo3d - ui : : - webkit - scrollbar {
display : none ;
}
. tp - rotv {
box - shadow : none ! important ;
background - color : transparent ! important ;
}
. tp - brkv {
border - left : none ! important ;
}
` ;var aH={exports:{}};(function(i,e){(function(t,n){i.exports=n()})(rl,function(){var t=function(){function n(_){return o.appendChild(_.dom),_}function r(_){for(var w=0;w<o.children.length;w++)o.children[w].style.display=w===_?"block":"none";s=_}var s=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(_){_.preventDefault(),r(++s%o.children.length)},!1);var l=(performance||Date).now(),h=l,d=0,f=n(new t.Panel("FPS","#0ff","#002")),g=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var y=n(new t.Panel("MB","#f08","#201"));return r(0),{REVISION:16,dom:o,addPanel:n,showPanel:r,begin:function(){l=(performance||Date).now()},end:function(){d++;var _=(performance||Date).now();if(g.update(_-l,200),_>h+1e3&&(f.update(1e3*d/(_-h),100),h=_,d=0,y)){var w=performance.memory;y.update(w.usedJSHeapSize/1048576,w.jsHeapSizeLimit/1048576)}return _},update:function(){l=this.end()},domElement:o,setMode:r}};return t.Panel=function(n,r,s){var o=1/0,l=0,h=Math.round,d=h(window.devicePixelRatio||1),f=80*d,g=48*d,y=3*d,_=2*d,w=3*d,S=15*d,b=74*d,T=30*d,E=document.createElement("canvas");E.width=f,E.height=g,E.style.cssText="width:80px;height:48px";var C=E.getContext("2d");return C.font="bold "+9*d+"px Helvetica,Arial,sans-serif",C.textBaseline="top",C.fillStyle=s,C.fillRect(0,0,f,g),C.fillStyle=r,C.fillText(n,y,_),C.fillRect(w,S,b,T),C.fillStyle=s,C.globalAlpha=.9,C.fillRect(w,S,b,T),{dom:E,update:function(A,D){o=Math.min(o,A),l=Math.max(l,A),C.fillStyle=s,C.globalAlpha=1,C.fillRect(0,0,f,S),C.fillStyle=r,C.fillText(h(A)+" "+n+" ("+h(o)+"-"+h(l)+")",y,_),C.drawImage(E,w+d,S,b-d,T,w,S,b-d,T),C.fillRect(w+b-d,S,d,T),C.fillStyle=s,C.globalAlpha=.9,C.fillRect(w+b-d,S,d,h((1-A/D)*T))}}},t})})(aH);var a3=(i,e,t)=>{let n=e;const r=sd([]);return Rs(()=>{if(t!=null&&t.value)return;const s=r.value=[];for(const[o,l]of Object.entries(i)){const h=n[o];h!==l&&(l&&typeof l=="object"?JSON.stringify(l)!==JSON.stringify(h)&&s.push([o,l]):s.push([o,l]))}n=Me({},i)}),r};const l3=new WeakMap,lH=()=>new Map,c3=(i,e,t,n)=>{Rs(()=>{var r;if(e??(e=Ih(i==null?void 0:i.value)),!e)return;const s=Ma(l3,e,lH);for(const[o,l]of Ih(t.value)){if((r=s.get(o))==null||r.cancel(),l instanceof Tn){s.set(o,l.get(h=>e[o]=h));continue}e[o]=l??n[o]}})};var u3=(i,e)=>{const t=new e,n=sd(t);TE("parent",n);const r=EE("parent",void 0);Rs(()=>{var o;(o=Ih(r==null?void 0:r.value))==null||o.append(t)}),e.defaults||console.error("ManagerClass has no defaults",e);const s=a3(i,e.defaults);return c3(void 0,t,s,e.defaults),L4(()=>{const o=l3.get(t);if(o)for(const l of o.values())l.cancel();t.dispose()}),t};An(yC,_C);An(AT,CT);An(gC,ol);An(xC,bC);An(QA, $ A);var cH=An(ab,lb);const uH=rd({name:"Model",props:cH,setup(i,{expose:e}){const n=u3(i,Ao);return e(n),(r,s)=>Dm(r. $ slots,"default")}});An(mb,qA);An(YA,ZA);An(KA,JA);An(MT,ET);An(eT,tT);An(sA,oA);An(vb,gb);var hH=An(uA,hA);const dH=rd({name:"OrbitCamera",props:hH,setup(i,{expose:e}){const n=u3(i,Cl);return e(n),(r,s)=>Dm(r. $ slots,"default")}});An(yb,_b);An(yb,_b);An(sC,oC);An(aC,ha);An(lC,cC);An(dC,pC);An(uC,hC);An(mC,vC);An(uv,hv);var pH=An(KT,ym);bt(Me({},pH),{onLoad:Function});function h3(i,e){var t={};for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&e.indexOf(n)<0&&(t[n]=i[n]);if(i!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,n=Object.getOwnPropertySymbols(i);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(i,n[r])&&(t[n[r]]=i[n[r]]);return t}var vE=function(){};const j_=(i,e,t)=>Math.min(Math.max(t,i),e),Oy=.001,fH=.01,mH=10,vH=.05,gH=1;function yH({duration:i=800,bounce:e=.25,velocity:t=0,mass:n=1}){let r,s,o=1-e;o=j_(vH,gH,o),i=j_(fH,mH,i/1e3),o<1?(r=d=>{const f=d*o,g=f*i,y=f-t,_=X_(d,o),w=Math.exp(-g);return Oy-y/_*w},s=d=>{const g=d*o*i,y=g*t+t,_=Math.pow(o,2)*Math.pow(d,2)*i,w=Math.exp(-g),S=X_(Math.pow(d,2),o);return(-r(d)+Oy>0?-1:1)*((y-_)*w)/S}):(r=d=>{const f=Math.exp(-d*i),g=(d-t)*i+1;return-Oy+f*g},s=d=>{const f=Math.exp(-d*i),g=(t-d)*(i*i);ret