function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t>8&255]+Pe[e>>16&255]+Pe[e>>24&255]+"-"+Pe[255&t]+Pe[t>>8&255]+"-"+Pe[t>>16&15|64]+Pe[t>>24&255]+"-"+Pe[63&n|128]+Pe[n>>8&255]+"-"+Pe[n>>16&255]+Pe[n>>24&255]+Pe[255&i]+Pe[i>>8&255]+Pe[i>>16&255]+Pe[i>>24&255]).toUpperCase()}function Ue(e,t,n){return Math.max(t,Math.min(n,e))}function ze(e,t){return(e%t+t)%t}function Ve(e,t,n){return(1-n)*e+n*t}function Ge(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function ke(e){return e*Ne}function Qe(e){return e*Oe}function We(e){return 0==(e&e-1)&&0!==e}function He(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function je(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function Ye(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return t>>>0}function Xe(e,t,n,i){let o=Math.exp(-n/i);return e*o+(1-o)*t}function Ke(e,t,n,i,o){let r=Xe(e,t,n,i);return Math.abs(e-t)o&&(i=i=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:Ge,randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){return void 0!==e&&(De=e%2147483647),De=16807*De%2147483647,(De-1)/2147483646},degToRad:ke,radToDeg:Qe,isPowerOfTwo:We,ceilPowerOfTwo:He,floorPowerOfTwo:je,setQuaternionFromProperEuler:function(e,t,n,i,o){const r=Math.cos,a=Math.sin,s=r(n/2),l=a(n/2),c=r((t+i)/2),u=a((t+i)/2),d=r((t-i)/2),h=a((t-i)/2),p=r((i-t)/2),f=a((i-t)/2);switch(o){case"XYX":e.set(s*u,l*d,l*h,s*c);break;case"YZY":e.set(l*h,s*u,l*d,s*c);break;case"ZXZ":e.set(l*d,l*h,s*u,s*c);break;case"XZX":e.set(s*u,l*f,l*p,s*c);break;case"YXY":e.set(l*p,s*u,l*f,s*c);break;case"ZYZ":e.set(l*f,l*p,s*u,s*c);break;default:console.warn("v3d.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+o)}},hashString:Ye,expAverage:Xe,expAverageClamp:Ke,angleToRange_0_2Pi:qe,angleToRange_mPi_Pi:Ze,clampAngle:Je});class et{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector2: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector2: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,i=e.elements;return this.x=i[0]*t+i[3]*n+i[6],this.y=i[1]*t+i[4]*n+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("v3d.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),i=Math.sin(t),o=this.x-e.x,r=this.y-e.y;return this.x=o*n-r*i+e.x,this.y=o*i+r*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}et.prototype.isVector2=!0;class tt{constructor(){this.elements=[1,0,0,0,1,0,0,0,1],arguments.length>0&&console.error("v3d.Matrix3: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,o,r,a,s,l){const c=this.elements;return c[0]=e,c[1]=i,c[2]=a,c[3]=t,c[4]=o,c[5]=s,c[6]=n,c[7]=r,c[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,o=this.elements,r=n[0],a=n[3],s=n[6],l=n[1],c=n[4],u=n[7],d=n[2],h=n[5],p=n[8],f=i[0],m=i[3],g=i[6],v=i[1],A=i[4],_=i[7],x=i[2],y=i[5],b=i[8];return o[0]=r*f+a*v+s*x,o[3]=r*m+a*A+s*y,o[6]=r*g+a*_+s*b,o[1]=l*f+c*v+u*x,o[4]=l*m+c*A+u*y,o[7]=l*g+c*_+u*b,o[2]=d*f+h*v+p*x,o[5]=d*m+h*A+p*y,o[8]=d*g+h*_+p*b,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],r=e[4],a=e[5],s=e[6],l=e[7],c=e[8];return t*r*c-t*a*l-n*o*c+n*a*s+i*o*l-i*r*s}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],r=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=c*r-a*l,d=a*s-c*o,h=l*o-r*s,p=t*u+n*d+i*h;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const f=1/p;return e[0]=u*f,e[1]=(i*l-c*n)*f,e[2]=(a*n-i*r)*f,e[3]=d*f,e[4]=(c*t-i*s)*f,e[5]=(i*o-a*t)*f,e[6]=h*f,e[7]=(n*s-l*t)*f,e[8]=(r*t-n*o)*f,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,i,o,r,a){const s=Math.cos(o),l=Math.sin(o);return this.set(n*s,n*l,-n*(s*r+l*a)+r+e,-i*l,i*s,-i*(-l*r+s*a)+a+t,0,0,1),this}scale(e,t){const n=this.elements;return n[0]*=e,n[3]*=e,n[6]*=e,n[1]*=t,n[4]*=t,n[7]*=t,this}rotate(e){const t=Math.cos(e),n=Math.sin(e),i=this.elements,o=i[0],r=i[3],a=i[6],s=i[1],l=i[4],c=i[7];return i[0]=t*o+n*s,i[3]=t*r+n*l,i[6]=t*a+n*c,i[1]=-n*o+t*s,i[4]=-n*r+t*l,i[7]=-n*a+t*c,this}translate(e,t){const n=this.elements;return n[0]+=e*n[2],n[3]+=e*n[5],n[6]+=e*n[8],n[1]+=t*n[2],n[4]+=t*n[5],n[7]+=t*n[8],this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<9;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}function nt(e){if(0===e.length)return-1/0;let t=e[0];for(let n=1,i=e.length;nt&&(t=e[n]);return t}function it(e){for(let t=e.length-1;t>=0;--t)if(e[t]>65535)return!0;return!1}tt.prototype.isMatrix3=!0;const ot={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function rt(e,t){return new ot[e](t)}function at(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function st(e){return void 0!==e}function lt(e,t,n){for(let i=0;i=0;--i){const o=t[i].src,r=o.search(/\/v3d[\w.]+js/);r>-1&&(n=o.substr(0,r)+"/"+e)}return n}function pt(e,t=function(e){},n=function(e){}){dt[e]=dt[e]||{status:0,loadCallbacks:[],errorCallbacks:[]};const i=dt[e];if(4==i.status)return void t(e);if(i.loadCallbacks.push(t),i.errorCallbacks.push(n),i.status>0)return;let o=ht(e);const r=document.createElement("script");r.type="text/javascript",r.src=o,function(e){r.onload=function(){dt[e].loadCallbacks.forEach((function(t){t(e)})),dt[e].status=4},r.onerror=function(){dt[e].errorCallbacks.forEach((function(t){t(e)})),dt[e].status=0}}(e),document.getElementsByTagName("head")[0].appendChild(r),i.status=3}function ft(e,t,n=0){const i=function(e,i,o,r){const a=performance.now();return t(e,i,o),a-r>n?(r=a,new Promise((function(e){setTimeout((function(){e(r)}),1)}))):r};let o=Promise.resolve(performance.now());return e.forEach((function(e,t,n){o=o.then(i.bind(null,e,t,n))})),o}const mt={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},gt={h:0,s:0,l:0},vt={h:0,s:0,l:0};function At(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+6*(t-e)*n:n<.5?t:n<2/3?e+6*(t-e)*(2/3-n):e}function _t(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function xt(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}class yt{constructor(e,t,n){return void 0===t&&void 0===n?this.set(e):this.setRGB(e,t,n)}set(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this}setRGB(e,t,n){return this.r=e,this.g=t,this.b=n,this}setHSL(e,t,n){if(e=ze(e,1),t=Ue(t,0,1),n=Ue(n,0,1),0===t)this.r=this.g=this.b=n;else{const i=n<=.5?n*(1+t):n+t-n*t,o=2*n-i;this.r=At(o,i,e+1/3),this.g=At(o,i,e),this.b=At(o,i,e-1/3)}return this}setStyle(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("v3d.Color: Alpha component of "+e+" will be ignored.")}let n;if(n=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const i=n[1],o=n[2];switch(i){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(255,parseInt(e[1],10))/255,this.g=Math.min(255,parseInt(e[2],10))/255,this.b=Math.min(255,parseInt(e[3],10))/255,t(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return this.r=Math.min(100,parseInt(e[1],10))/100,this.g=Math.min(100,parseInt(e[2],10))/100,this.b=Math.min(100,parseInt(e[3],10))/100,t(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o)){const n=parseFloat(e[1])/360,i=parseInt(e[2],10)/100,o=parseInt(e[3],10)/100;return t(e[4]),this.setHSL(n,i,o)}}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=n[1],t=e.length;if(3===t)return this.r=parseInt(e.charAt(0)+e.charAt(0),16)/255,this.g=parseInt(e.charAt(1)+e.charAt(1),16)/255,this.b=parseInt(e.charAt(2)+e.charAt(2),16)/255,this;if(6===t)return this.r=parseInt(e.charAt(0)+e.charAt(1),16)/255,this.g=parseInt(e.charAt(2)+e.charAt(3),16)/255,this.b=parseInt(e.charAt(4)+e.charAt(5),16)/255,this}return e&&e.length>0?this.setColorName(e):this}setColorName(e){const t=mt[e.toLowerCase()];return void 0!==t?this.setHex(t):console.warn("v3d.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=_t(e.r),this.g=_t(e.g),this.b=_t(e.b),this}copyLinearToSRGB(e){return this.r=xt(e.r),this.g=xt(e.g),this.b=xt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0}getHexString(){return("000000"+this.getHex().toString(16)).slice(-6)}getHSL(e){const t=this.r,n=this.g,i=this.b,o=Math.max(t,n,i),r=Math.min(t,n,i);let a,s;const l=(r+o)/2;if(r===o)a=0,s=0;else{const e=o-r;switch(s=l<=.5?e/(o+r):e/(2-o-r),o){case t:a=(n-i)/e+(n2048||t.height>2048?(console.warn("v3d.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=at("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const i=n.getImageData(0,0,e.width,e.height),o=i.data;for(let e=0;e1)switch(this.wrapS){case m:e.x=e.x-Math.floor(e.x);break;case g:e.x=e.x<0?0:1;break;case v:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case m:e.y=e.y-Math.floor(e.y);break;case g:e.y=e.y<0?0:1;break;case v:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&this.version++}}function wt(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Mt.getDataURL(e):e.data?{data:Array.prototype.slice.call(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("v3d.Texture: Unable to serialize Texture."),{})}St.DEFAULT_IMAGE=void 0,St.DEFAULT_MAPPING=l,St.prototype.isTexture=!0;class Et{constructor(e=0,t=0,n=0,i=1){this.x=e,this.y=t,this.z=n,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector4: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector4: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,o=this.w,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*i+r[12]*o,this.y=r[1]*t+r[5]*n+r[9]*i+r[13]*o,this.z=r[2]*t+r[6]*n+r[10]*i+r[14]*o,this.w=r[3]*t+r[7]*n+r[11]*i+r[15]*o,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,i,o;const r=.01,a=.1,s=e.elements,l=s[0],c=s[4],u=s[8],d=s[1],h=s[5],p=s[9],f=s[2],m=s[6],g=s[10];if(Math.abs(c-d)s&&e>v?ev?s=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const o=Math.sqrt(i),r=Math.atan2(o,t*n);e=Math.sin(e*r)/o,a=Math.sin(a*r)/o}const o=a*n;if(s=s*e+d*o,l=l*e+h*o,c=c*e+p*o,u=u*e+f*o,e===1-a){const e=1/Math.sqrt(s*s+l*l+c*c+u*u);s*=e,l*=e,c*=e,u*=e}}e[t]=s,e[t+1]=l,e[t+2]=c,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,i,o,r){const a=n[i],s=n[i+1],l=n[i+2],c=n[i+3],u=o[r],d=o[r+1],h=o[r+2],p=o[r+3];return e[t]=a*p+c*u+s*h-l*d,e[t+1]=s*p+c*d+l*u-a*h,e[t+2]=l*p+c*h+a*d-s*u,e[t+3]=c*p-a*u-s*d-l*h,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,i){return this._x=e,this._y=t,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t){if(!e||!e.isEuler)throw new Error("v3d.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");const n=e._x,i=e._y,o=e._z,r=e._order,a=Math.cos,s=Math.sin,l=a(n/2),c=a(i/2),u=a(o/2),d=s(n/2),h=s(i/2),p=s(o/2);switch(r){case"XYZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"YXZ":this._x=d*c*u+l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"ZXY":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u-d*h*p;break;case"ZYX":this._x=d*c*u-l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u+d*h*p;break;case"YZX":this._x=d*c*u+l*h*p,this._y=l*h*u+d*c*p,this._z=l*c*p-d*h*u,this._w=l*c*u-d*h*p;break;case"XZY":this._x=d*c*u-l*h*p,this._y=l*h*u-d*c*p,this._z=l*c*p+d*h*u,this._w=l*c*u+d*h*p;break;default:console.warn("v3d.Quaternion: .setFromEuler() encountered an unknown order: "+r)}return!1!==t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,i=Math.sin(n);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],i=t[4],o=t[8],r=t[1],a=t[5],s=t[9],l=t[2],c=t[6],u=t[10],d=n+a+u;if(d>0){const e=.5/Math.sqrt(d+1);this._w=.25/e,this._x=(c-s)*e,this._y=(o-l)*e,this._z=(r-i)*e}else if(n>a&&n>u){const e=2*Math.sqrt(1+n-a-u);this._w=(c-s)/e,this._x=.25*e,this._y=(i+r)/e,this._z=(o+l)/e}else if(a>u){const e=2*Math.sqrt(1+a-n-u);this._w=(o-l)/e,this._x=(i+r)/e,this._y=.25*e,this._z=(s+c)/e}else{const e=2*Math.sqrt(1+u-n-a);this._w=(r-i)/e,this._x=(o+l)/e,this._y=(s+c)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return nMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ue(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(0===n)return this;const i=Math.min(1,t/n);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e,t){return void 0!==t?(console.warn("v3d.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions(a, b) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,i=e._y,o=e._z,r=e._w,a=t._x,s=t._y,l=t._z,c=t._w;return this._x=n*c+r*a+i*l-o*s,this._y=i*c+r*s+o*a-n*l,this._z=o*c+r*l+n*s-i*a,this._w=r*c-n*a-i*s-o*l,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const n=this._x,i=this._y,o=this._z,r=this._w;let a=r*e._w+n*e._x+i*e._y+o*e._z;if(a<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,a=-a):this.copy(e),a>=1)return this._w=r,this._x=n,this._y=i,this._z=o,this;const s=1-a*a;if(s<=Number.EPSILON){const e=1-t;return this._w=e*r+t*this._w,this._x=e*n+t*this._x,this._y=e*i+t*this._y,this._z=e*o+t*this._z,this.normalize(),this._onChangeCallback(),this}const l=Math.sqrt(s),c=Math.atan2(l,a),u=Math.sin((1-t)*c)/l,d=Math.sin(t*c)/l;return this._w=r*u+this._w*d,this._x=n*u+this._x*d,this._y=i*u+this._y*d,this._z=o*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=Math.random(),t=Math.sqrt(1-e),n=Math.sqrt(e),i=2*Math.PI*Math.random(),o=2*Math.PI*Math.random();return this.set(t*Math.cos(i),n*Math.sin(o),n*Math.cos(o),t*Math.sin(i))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}}Lt.prototype.isQuaternion=!0;class Bt{constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return void 0===n&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e,t){return void 0!==t?(console.warn("v3d.Vector3: .add() now only accepts one argument. Use .addVectors(a, b) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e,t){return void 0!==t?(console.warn("v3d.Vector3: .sub() now only accepts one argument. Use .subVectors(a, b) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e,t){return void 0!==t?(console.warn("v3d.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors(a, b) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return e&&e.isEuler||console.error("v3d.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),this.applyQuaternion(Dt.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Dt.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*i,this.y=o[1]*t+o[4]*n+o[7]*i,this.z=o[2]*t+o[5]*n+o[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,i=this.z,o=e.elements,r=1/(o[3]*t+o[7]*n+o[11]*i+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*i+o[12])*r,this.y=(o[1]*t+o[5]*n+o[9]*i+o[13])*r,this.z=(o[2]*t+o[6]*n+o[10]*i+o[14])*r,this}applyQuaternion(e){const t=this.x,n=this.y,i=this.z,o=e.x,r=e.y,a=e.z,s=e.w,l=s*t+r*i-a*n,c=s*n+a*t-o*i,u=s*i+o*n-r*t,d=-o*t-r*n-a*i;return this.x=l*s+d*-o+c*-a-u*-r,this.y=c*s+d*-r+u*-o-l*-a,this.z=u*s+d*-a+l*-r-c*-o,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,i=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*i,this.y=o[1]*t+o[5]*n+o[9]*i,this.z=o[2]*t+o[6]*n+o[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(e,Math.min(t,n)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e,t){return void 0!==t?(console.warn("v3d.Vector3: .cross() now only accepts one argument. Use .crossVectors(a, b) instead."),this.crossVectors(e,t)):this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,i=e.y,o=e.z,r=t.x,a=t.y,s=t.z;return this.x=i*s-o*a,this.y=o*r-n*s,this.z=n*a-i*r,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Pt.copy(this).projectOnVector(e),this.sub(Pt)}reflect(e){return this.sub(Pt.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ue(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,i=this.z-e.z;return t*t+n*n+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const i=Math.sin(t)*e;return this.x=i*Math.sin(n),this.y=Math.cos(t)*e,this.z=i*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t,n){return void 0!==n&&console.warn("v3d.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=2*(Math.random()-.5),t=Math.random()*Math.PI*2,n=Math.sqrt(1-e**2);return this.x=n*Math.cos(t),this.y=n*Math.sin(t),this.z=e,this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}Bt.prototype.isVector3=!0;const Pt=new Bt,Dt=new Lt;class Nt{constructor(e=new Bt(1/0,1/0,1/0),t=new Bt(-1/0,-1/0,-1/0)){this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){let t=1/0,n=1/0,i=1/0,o=-1/0,r=-1/0,a=-1/0;for(let s=0,l=e.length;so&&(o=l),c>r&&(r=c),u>a&&(a=u)}return this.min.set(t,n,i),this.max.set(o,r,a),this}setFromBufferAttribute(e){let t=1/0,n=1/0,i=1/0,o=-1/0,r=-1/0,a=-1/0;for(let s=0,l=e.count;so&&(o=l),c>r&&(r=c),u>a&&(a=u)}return this.min.set(t,n,i),this.max.set(o,r,a),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)}intersectsSphere(e){return this.clampPoint(e.center,Ft),Ft.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ht),jt.subVectors(this.max,Ht),zt.subVectors(e.a,Ht),Vt.subVectors(e.b,Ht),Gt.subVectors(e.c,Ht),kt.subVectors(Vt,zt),Qt.subVectors(Gt,Vt),Wt.subVectors(zt,Gt);let t=[0,-kt.z,kt.y,0,-Qt.z,Qt.y,0,-Wt.z,Wt.y,kt.z,0,-kt.x,Qt.z,0,-Qt.x,Wt.z,0,-Wt.x,-kt.y,kt.x,0,-Qt.y,Qt.x,0,-Wt.y,Wt.x,0];return!!Kt(t,zt,Vt,Gt,jt)&&(t=[1,0,0,0,1,0,0,0,1],!!Kt(t,zt,Vt,Gt,jt)&&(Yt.crossVectors(kt,Qt),t=[Yt.x,Yt.y,Yt.z],Kt(t,zt,Vt,Gt,jt)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return Ft.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(Ft).length(),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Ot[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Ot[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Ot[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Ot[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Ot[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Ot[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Ot[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Ot[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Ot)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}Nt.prototype.isBox3=!0;const Ot=[new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt],Ft=new Bt,Ut=new Nt,zt=new Bt,Vt=new Bt,Gt=new Bt,kt=new Bt,Qt=new Bt,Wt=new Bt,Ht=new Bt,jt=new Bt,Yt=new Bt,Xt=new Bt;function Kt(e,t,n,i,o){for(let r=0,a=e.length-3;r<=a;r+=3){Xt.fromArray(e,r);const a=o.x*Math.abs(Xt.x)+o.y*Math.abs(Xt.y)+o.z*Math.abs(Xt.z),s=t.dot(Xt),l=n.dot(Xt),c=i.dot(Xt);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const qt=new Nt,Zt=new Bt,Jt=new Bt,$t=new Bt;class en{constructor(e=new Bt,t=-1){this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;void 0!==t?n.copy(t):qt.setFromPoints(e).getCenter(n);let i=0;for(let t=0,o=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){$t.subVectors(e,this.center);const t=$t.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.add($t.multiplyScalar(n/e)),this.radius+=n}return this}union(e){return!0===this.center.equals(e.center)?Jt.set(0,0,1).multiplyScalar(e.radius):Jt.subVectors(e.center,this.center).normalize().multiplyScalar(e.radius),this.expandByPoint(Zt.copy(e.center).add(Jt)),this.expandByPoint(Zt.copy(e.center).sub(Jt)),this}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const tn=new Bt,nn=new Bt,on=new Bt,rn=new Bt,an=new Bt,sn=new Bt,ln=new Bt;class cn{constructor(e=new Bt,t=new Bt(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.direction).multiplyScalar(e).add(this.origin)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,tn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.direction).multiplyScalar(n).add(this.origin)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=tn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(tn.copy(this.direction).multiplyScalar(t).add(this.origin),tn.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){nn.copy(e).add(t).multiplyScalar(.5),on.copy(t).sub(e).normalize(),rn.copy(this.origin).sub(nn);const o=.5*e.distanceTo(t),r=-this.direction.dot(on),a=rn.dot(this.direction),s=-rn.dot(on),l=rn.lengthSq(),c=Math.abs(1-r*r);let u,d,h,p;if(c>0)if(u=r*s-a,d=r*a-s,p=o*c,u>=0)if(d>=-p)if(d<=p){const e=1/c;u*=e,d*=e,h=u*(u+r*d+2*a)+d*(r*u+d+2*s)+l}else d=o,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*s)+l;else d=-o,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*s)+l;else d<=-p?(u=Math.max(0,-(-r*o+a)),d=u>0?-o:Math.min(Math.max(-o,-s),o),h=-u*u+d*(d+2*s)+l):d<=p?(u=0,d=Math.min(Math.max(-o,-s),o),h=d*(d+2*s)+l):(u=Math.max(0,-(r*o+a)),d=u>0?o:Math.min(Math.max(-o,-s),o),h=-u*u+d*(d+2*s)+l);else d=r>0?-o:o,u=Math.max(0,-(r*d+a)),h=-u*u+d*(d+2*s)+l;return n&&n.copy(this.direction).multiplyScalar(u).add(this.origin),i&&i.copy(on).multiplyScalar(d).add(nn),h}intersectSphere(e,t){tn.subVectors(e.center,this.origin);const n=tn.dot(this.direction),i=tn.dot(tn)-n*n,o=e.radius*e.radius;if(i>o)return null;const r=Math.sqrt(o-i),a=n-r,s=n+r;return a<0&&s<0?null:a<0?this.at(s,t):this.at(a,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return null===n?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,i,o,r,a,s;const l=1/this.direction.x,c=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(e.min.x-d.x)*l,i=(e.max.x-d.x)*l):(n=(e.max.x-d.x)*l,i=(e.min.x-d.x)*l),c>=0?(o=(e.min.y-d.y)*c,r=(e.max.y-d.y)*c):(o=(e.max.y-d.y)*c,r=(e.min.y-d.y)*c),n>r||o>i?null:((o>n||n!=n)&&(n=o),(r=0?(a=(e.min.z-d.z)*u,s=(e.max.z-d.z)*u):(a=(e.max.z-d.z)*u,s=(e.min.z-d.z)*u),n>s||a>i?null:((a>n||n!=n)&&(n=a),(s=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,tn)}intersectTriangle(e,t,n,i,o){an.subVectors(t,e),sn.subVectors(n,e),ln.crossVectors(an,sn);let r,a=this.direction.dot(ln);if(a>0){if(i)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}rn.subVectors(this.origin,e);const s=r*this.direction.dot(sn.crossVectors(rn,sn));if(s<0)return null;const l=r*this.direction.dot(an.cross(rn));if(l<0)return null;if(s+l>a)return null;const c=-r*rn.dot(ln);return c<0?null:this.at(c/a,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class un{constructor(){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],arguments.length>0&&console.error("v3d.Matrix4: the constructor no longer reads arguments. use .set() instead.")}set(e,t,n,i,o,r,a,s,l,c,u,d,h,p,f,m){const g=this.elements;return g[0]=e,g[4]=t,g[8]=n,g[12]=i,g[1]=o,g[5]=r,g[9]=a,g[13]=s,g[2]=l,g[6]=c,g[10]=u,g[14]=d,g[3]=h,g[7]=p,g[11]=f,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new un).fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,n=e.elements,i=1/dn.setFromMatrixColumn(e,0).length(),o=1/dn.setFromMatrixColumn(e,1).length(),r=1/dn.setFromMatrixColumn(e,2).length();return t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*r,t[9]=n[9]*r,t[10]=n[10]*r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){e&&e.isEuler||console.error("v3d.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");const t=this.elements,n=e.x,i=e.y,o=e.z,r=Math.cos(n),a=Math.sin(n),s=Math.cos(i),l=Math.sin(i),c=Math.cos(o),u=Math.sin(o);if("XYZ"===e.order){const e=r*c,n=r*u,i=a*c,o=a*u;t[0]=s*c,t[4]=-s*u,t[8]=l,t[1]=n+i*l,t[5]=e-o*l,t[9]=-a*s,t[2]=o-e*l,t[6]=i+n*l,t[10]=r*s}else if("YXZ"===e.order){const e=s*c,n=s*u,i=l*c,o=l*u;t[0]=e+o*a,t[4]=i*a-n,t[8]=r*l,t[1]=r*u,t[5]=r*c,t[9]=-a,t[2]=n*a-i,t[6]=o+e*a,t[10]=r*s}else if("ZXY"===e.order){const e=s*c,n=s*u,i=l*c,o=l*u;t[0]=e-o*a,t[4]=-r*u,t[8]=i+n*a,t[1]=n+i*a,t[5]=r*c,t[9]=o-e*a,t[2]=-r*l,t[6]=a,t[10]=r*s}else if("ZYX"===e.order){const e=r*c,n=r*u,i=a*c,o=a*u;t[0]=s*c,t[4]=i*l-n,t[8]=e*l+o,t[1]=s*u,t[5]=o*l+e,t[9]=n*l-i,t[2]=-l,t[6]=a*s,t[10]=r*s}else if("YZX"===e.order){const e=r*s,n=r*l,i=a*s,o=a*l;t[0]=s*c,t[4]=o-e*u,t[8]=i*u+n,t[1]=u,t[5]=r*c,t[9]=-a*c,t[2]=-l*c,t[6]=n*u+i,t[10]=e-o*u}else if("XZY"===e.order){const e=r*s,n=r*l,i=a*s,o=a*l;t[0]=s*c,t[4]=-u,t[8]=l*c,t[1]=e*u+o,t[5]=r*c,t[9]=n*u-i,t[2]=i*u-n,t[6]=a*c,t[10]=o*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(pn,e,fn)}lookAt(e,t,n){const i=this.elements;return vn.subVectors(e,t),0===vn.lengthSq()&&(vn.z=1),vn.normalize(),mn.crossVectors(n,vn),0===mn.lengthSq()&&(1===Math.abs(n.z)?vn.x+=1e-4:vn.z+=1e-4,vn.normalize(),mn.crossVectors(n,vn)),mn.normalize(),gn.crossVectors(vn,mn),i[0]=mn.x,i[4]=gn.x,i[8]=vn.x,i[1]=mn.y,i[5]=gn.y,i[9]=vn.y,i[2]=mn.z,i[6]=gn.z,i[10]=vn.z,this}multiply(e,t){return void 0!==t?(console.warn("v3d.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices(a, b) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,i=t.elements,o=this.elements,r=n[0],a=n[4],s=n[8],l=n[12],c=n[1],u=n[5],d=n[9],h=n[13],p=n[2],f=n[6],m=n[10],g=n[14],v=n[3],A=n[7],_=n[11],x=n[15],y=i[0],b=i[4],M=i[8],C=i[12],S=i[1],w=i[5],E=i[9],T=i[13],I=i[2],R=i[6],L=i[10],B=i[14],P=i[3],D=i[7],N=i[11],O=i[15];return o[0]=r*y+a*S+s*I+l*P,o[4]=r*b+a*w+s*R+l*D,o[8]=r*M+a*E+s*L+l*N,o[12]=r*C+a*T+s*B+l*O,o[1]=c*y+u*S+d*I+h*P,o[5]=c*b+u*w+d*R+h*D,o[9]=c*M+u*E+d*L+h*N,o[13]=c*C+u*T+d*B+h*O,o[2]=p*y+f*S+m*I+g*P,o[6]=p*b+f*w+m*R+g*D,o[10]=p*M+f*E+m*L+g*N,o[14]=p*C+f*T+m*B+g*O,o[3]=v*y+A*S+_*I+x*P,o[7]=v*b+A*w+_*R+x*D,o[11]=v*M+A*E+_*L+x*N,o[15]=v*C+A*T+_*B+x*O,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],i=e[8],o=e[12],r=e[1],a=e[5],s=e[9],l=e[13],c=e[2],u=e[6],d=e[10],h=e[14];return e[3]*(+o*s*u-i*l*u-o*a*d+n*l*d+i*a*h-n*s*h)+e[7]*(+t*s*h-t*l*d+o*r*d-i*r*h+i*l*c-o*s*c)+e[11]*(+t*l*u-t*a*h-o*r*u+n*r*h+o*a*c-n*l*c)+e[15]*(-i*a*c-t*s*u+t*a*d+i*r*u-n*r*d+n*s*c)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],i=e[2],o=e[3],r=e[4],a=e[5],s=e[6],l=e[7],c=e[8],u=e[9],d=e[10],h=e[11],p=e[12],f=e[13],m=e[14],g=e[15],v=u*m*l-f*d*l+f*s*h-a*m*h-u*s*g+a*d*g,A=p*d*l-c*m*l-p*s*h+r*m*h+c*s*g-r*d*g,_=c*f*l-p*u*l+p*a*h-r*f*h-c*a*g+r*u*g,x=p*u*s-c*f*s-p*a*d+r*f*d+c*a*m-r*u*m,y=t*v+n*A+i*_+o*x;if(0===y)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const b=1/y;return e[0]=v*b,e[1]=(f*d*o-u*m*o-f*i*h+n*m*h+u*i*g-n*d*g)*b,e[2]=(a*m*o-f*s*o+f*i*l-n*m*l-a*i*g+n*s*g)*b,e[3]=(u*s*o-a*d*o-u*i*l+n*d*l+a*i*h-n*s*h)*b,e[4]=A*b,e[5]=(c*m*o-p*d*o+p*i*h-t*m*h-c*i*g+t*d*g)*b,e[6]=(p*s*o-r*m*o-p*i*l+t*m*l+r*i*g-t*s*g)*b,e[7]=(r*d*o-c*s*o+c*i*l-t*d*l-r*i*h+t*s*h)*b,e[8]=_*b,e[9]=(p*u*o-c*f*o-p*n*h+t*f*h+c*n*g-t*u*g)*b,e[10]=(r*f*o-p*a*o+p*n*l-t*f*l-r*n*g+t*a*g)*b,e[11]=(c*a*o-r*u*o-c*n*l+t*u*l+r*n*h-t*a*h)*b,e[12]=x*b,e[13]=(c*f*i-p*u*i+p*n*d-t*f*d-c*n*m+t*u*m)*b,e[14]=(p*a*i-r*f*i-p*n*s+t*f*s+r*n*m-t*a*m)*b,e[15]=(r*u*i-c*a*i+c*n*s-t*u*s-r*n*d+t*a*d)*b,this}scale(e){const t=this.elements,n=e.x,i=e.y,o=e.z;return t[0]*=n,t[4]*=i,t[8]*=o,t[1]*=n,t[5]*=i,t[9]*=o,t[2]*=n,t[6]*=i,t[10]*=o,t[3]*=n,t[7]*=i,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,i))}makeTranslation(e,t,n){return this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),i=Math.sin(t),o=1-n,r=e.x,a=e.y,s=e.z,l=o*r,c=o*a;return this.set(l*r+n,l*a-i*s,l*s+i*a,0,l*a+i*s,c*a+n,c*s-i*r,0,l*s-i*a,c*s+i*r,o*s*s+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,i,o,r){return this.set(1,n,o,0,e,1,r,0,t,i,1,0,0,0,0,1),this}compose(e,t,n){const i=this.elements,o=t._x,r=t._y,a=t._z,s=t._w,l=o+o,c=r+r,u=a+a,d=o*l,h=o*c,p=o*u,f=r*c,m=r*u,g=a*u,v=s*l,A=s*c,_=s*u,x=n.x,y=n.y,b=n.z;return i[0]=(1-(f+g))*x,i[1]=(h+_)*x,i[2]=(p-A)*x,i[3]=0,i[4]=(h-_)*y,i[5]=(1-(d+g))*y,i[6]=(m+v)*y,i[7]=0,i[8]=(p+A)*b,i[9]=(m-v)*b,i[10]=(1-(d+f))*b,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,n){const i=this.elements;let o=dn.set(i[0],i[1],i[2]).length();const r=dn.set(i[4],i[5],i[6]).length(),a=dn.set(i[8],i[9],i[10]).length();this.determinant()<0&&(o=-o),e.x=i[12],e.y=i[13],e.z=i[14],hn.copy(this);const s=1/o,l=1/r,c=1/a;return hn.elements[0]*=s,hn.elements[1]*=s,hn.elements[2]*=s,hn.elements[4]*=l,hn.elements[5]*=l,hn.elements[6]*=l,hn.elements[8]*=c,hn.elements[9]*=c,hn.elements[10]*=c,t.setFromRotationMatrix(hn),n.x=o,n.y=r,n.z=a,this}makePerspective(e,t,n,i,o,r){void 0===r&&console.warn("v3d.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");const a=this.elements,s=2*o/(t-e),l=2*o/(n-i),c=(t+e)/(t-e),u=(n+i)/(n-i),d=-(r+o)/(r-o),h=-2*r*o/(r-o);return a[0]=s,a[4]=0,a[8]=c,a[12]=0,a[1]=0,a[5]=l,a[9]=u,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=h,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,n,i,o,r){const a=this.elements,s=1/(t-e),l=1/(n-i),c=1/(r-o),u=(t+e)*s,d=(n+i)*l,h=(r+o)*c;return a[0]=2*s,a[4]=0,a[8]=0,a[12]=-u,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=-2*c,a[14]=-h,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let e=0;e<16;e++)if(t[e]!==n[e])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}composeE(e,t,n){const i=this.elements;this.makeRotationFromEuler(t);const o=n.x,r=n.y,a=n.z;return i[0]*=o,i[1]*=o,i[2]*=o,i[3]=0,i[4]*=r,i[5]*=r,i[6]*=r,i[7]=0,i[8]*=a,i[9]*=a,i[10]*=a,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decomposeE(e,t,n,i=t.order){const o=this.elements;let r=dn.set(o[0],o[1],o[2]).length();const a=dn.set(o[4],o[5],o[6]).length(),s=dn.set(o[8],o[9],o[10]).length();this.determinant()<0&&(r=-r),e.x=o[12],e.y=o[13],e.z=o[14],hn.copy(this);const l=1/r,c=1/a,u=1/s;return hn.elements[0]*=l,hn.elements[1]*=l,hn.elements[2]*=l,hn.elements[4]*=c,hn.elements[5]*=c,hn.elements[6]*=c,hn.elements[8]*=u,hn.elements[9]*=u,hn.elements[10]*=u,t.setFromRotationMatrix(hn,i),n.x=r,n.y=a,n.z=s,this}}un.prototype.isMatrix4=!0;const dn=new Bt,hn=new un,pn=new Bt(0,0,0),fn=new Bt(1,1,1),mn=new Bt,gn=new Bt,vn=new Bt,An=new un,_n=new Lt;class xn{constructor(e=0,t=0,n=0,i=xn.DefaultOrder){this._x=e,this._y=t,this._z=n,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,i=this._order){return this._x=e,this._y=t,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const i=e.elements,o=i[0],r=i[4],a=i[8],s=i[1],l=i[5],c=i[9],u=i[2],d=i[6],h=i[10];switch(t){case"XYZ":this._y=Math.asin(Ue(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-r,o)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Ue(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(a,h),this._z=Math.atan2(s,l)):(this._y=Math.atan2(-u,o),this._z=0);break;case"ZXY":this._x=Math.asin(Ue(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,h),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(s,o));break;case"ZYX":this._y=Math.asin(-Ue(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,h),this._z=Math.atan2(s,o)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Ue(s,-1,1)),Math.abs(s)<.9999999?(this._x=Math.atan2(-c,l),this._y=Math.atan2(-u,o)):(this._x=0,this._y=Math.atan2(a,h));break;case"XZY":this._z=Math.asin(-Ue(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,o)):(this._x=Math.atan2(-c,h),this._y=0);break;default:console.warn("v3d.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===n&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return An.makeRotationFromQuaternion(e),this.setFromRotationMatrix(An,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return _n.setFromEuler(this),this.setFromQuaternion(_n,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}toVector3(e){return e?e.set(this._x,this._y,this._z):new Bt(this._x,this._y,this._z)}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}makeAlternative(){var e="X"===this._order[1]?-1:1,t="Y"===this._order[1]?-1:1,n="Z"===this._order[1]?-1:1;return this._x=Ze(e*(this._x+Math.PI)),this._y=Ze(t*(this._y+Math.PI)),this._z=Ze(n*(this._z+Math.PI)),this}equalsEps(e,t){return Math.abs(this._x-e._x)>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(n.geometries=t),i.length>0&&(n.materials=i),o.length>0&&(n.textures=o),a.length>0&&(n.images=a),s.length>0&&(n.shapes=s),l.length>0&&(n.skeletons=l),c.length>0&&(n.animations=c)}return n.object=i,n;function r(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.disableChildRendering=e.disableChildRendering,this.hidpiCompositing=e.hidpiCompositing,this.objectIndex=e.objectIndex,this.objectColor.copy(e.objectColor),this.objectAlpha=e.objectAlpha,this.constraints=[];for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}static getBarycoord(e,t,n,i,o){On.subVectors(i,t),Fn.subVectors(n,t),Un.subVectors(e,t);const r=On.dot(On),a=On.dot(Fn),s=On.dot(Un),l=Fn.dot(Fn),c=Fn.dot(Un),u=r*l-a*a;if(0===u)return o.set(-2,-1,-1);const d=1/u,h=(l*s-a*c)*d,p=(r*c-a*s)*d;return o.set(1-h-p,p,h)}static containsPoint(e,t,n,i){return this.getBarycoord(e,t,n,i,zn),zn.x>=0&&zn.y>=0&&zn.x+zn.y<=1}static getUV(e,t,n,i,o,r,a,s){return this.getBarycoord(e,t,n,i,zn),s.set(0,0),s.addScaledVector(o,zn.x),s.addScaledVector(r,zn.y),s.addScaledVector(a,zn.z),s}static isFrontFacing(e,t,n,i){return On.subVectors(n,t),Fn.subVectors(e,t),On.cross(Fn).dot(i)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,i){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,n,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return On.subVectors(this.c,this.b),Fn.subVectors(this.a,this.b),.5*On.cross(Fn).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return jn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return jn.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,o){return jn.getUV(e,this.a,this.b,this.c,t,n,i,o)}containsPoint(e){return jn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return jn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,i=this.b,o=this.c;let r,a;Vn.subVectors(i,n),Gn.subVectors(o,n),Qn.subVectors(e,n);const s=Vn.dot(Qn),l=Gn.dot(Qn);if(s<=0&&l<=0)return t.copy(n);Wn.subVectors(e,i);const c=Vn.dot(Wn),u=Gn.dot(Wn);if(c>=0&&u<=c)return t.copy(i);const d=s*u-c*l;if(d<=0&&s>=0&&c<=0)return r=s/(s-c),t.copy(n).addScaledVector(Vn,r);Hn.subVectors(e,o);const h=Vn.dot(Hn),p=Gn.dot(Hn);if(p>=0&&h<=p)return t.copy(o);const f=h*l-s*p;if(f<=0&&l>=0&&p<=0)return a=l/(l-p),t.copy(n).addScaledVector(Gn,a);const m=c*p-h*u;if(m<=0&&u-c>=0&&h-p>=0)return kn.subVectors(o,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(kn,a);const g=1/(m+f+d);return r=f*g,a=d*g,t.copy(n).addScaledVector(Vn,r).addScaledVector(Gn,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Yn=0;class Xn extends Be{constructor(){super(),Object.defineProperty(this,"id",{value:Yn++}),this.uuid=Fe(),this.name="",this.type="Material",this.fog=!0,this.blending=1,this.side=0,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=a,this.blendDst=s,this.blendEquation=i,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=3,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=be,this.stencilZFail=be,this.stencilZPass=be,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0,this.receiveShadow=!1,this.castShadow=!1,this.useHDR=!1,this.profile="",this.defines={},this.DefaultEnvMapAutoAssign=!0,this.envMapAutoAssign=this.DefaultEnvMapAutoAssign,this.gtaoVisible=!0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const n=e[t];if(void 0===n){console.warn("v3d.Material: '"+t+"' parameter is undefined.");continue}if("shading"===t){console.warn("v3d."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===n;continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(n):i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[t]=n:console.warn("v3d."+this.type+": '"+t+"' is not a property of this material.")}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const n={metadata:{version:4.5,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const n in e){const i=e[n];delete i.metadata,t.push(i)}return t}if(n.uuid=this.uuid,n.type=this.type,""!==this.name&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),void 0!==this.roughness&&(n.roughness=this.roughness),void 0!==this.metalness&&(n.metalness=this.metalness),void 0!==this.sheen&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity&&1!==this.emissiveIntensity&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(n.shininess=this.shininess),void 0!==this.clearcoat&&(n.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&!this.isMeshNodeMaterial&&(n.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(n.combine=this.combine)),void 0!==this.envMapIntensity&&(n.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(n.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&(n.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(n.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(n.size=this.size),null!==this.shadowSide&&(n.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(n.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(n.blending=this.blending),0!==this.side&&(n.side=this.side),this.vertexColors&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),!0===this.transparent&&(n.transparent=this.transparent),n.depthFunc=this.depthFunc,n.depthTest=this.depthTest,n.depthWrite=this.depthWrite,n.colorWrite=this.colorWrite,n.stencilWrite=this.stencilWrite,n.stencilWriteMask=this.stencilWriteMask,n.stencilFunc=this.stencilFunc,n.stencilRef=this.stencilRef,n.stencilFuncMask=this.stencilFuncMask,n.stencilFail=this.stencilFail,n.stencilZFail=this.stencilZFail,n.stencilZPass=this.stencilZPass,this.rotation&&0!==this.rotation&&(n.rotation=this.rotation),!0===this.polygonOffset&&(n.polygonOffset=!0),0!==this.polygonOffsetFactor&&(n.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth&&1!==this.linewidth&&(n.linewidth=this.linewidth),void 0!==this.dashSize&&(n.dashSize=this.dashSize),void 0!==this.gapSize&&(n.gapSize=this.gapSize),void 0!==this.scale&&(n.scale=this.scale),!0===this.dithering&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),!0===this.alphaToCoverage&&(n.alphaToCoverage=this.alphaToCoverage),!0===this.premultipliedAlpha&&(n.premultipliedAlpha=this.premultipliedAlpha),!0===this.wireframe&&(n.wireframe=this.wireframe),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(n.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(n.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(n.flatShading=this.flatShading),!1===this.visible&&(n.visible=!1),!1===this.toneMapped&&(n.toneMapped=!1),"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),t){const t=i(e.textures),o=i(e.images);t.length>0&&(n.textures=t),o.length>0&&(n.images=o)}return n}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.fog=e.fog,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(null!==t){const e=t.length;n=new Array(e);for(let i=0;i!==e;++i)n[i]=t[i].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this.defines=Object.assign({},e.defines),this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,this.useHDR=e.useHDR,this.profile=e.profile,this.envMapAutoAssign=e.envMapAutoAssign,this.gtaoVisible=e.gtaoVisible,this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}get needsUpdate(){return 0!=this.version}}Xn.prototype.isMaterial=!0;class Kn extends Xn{constructor(e){super(),this.type="MeshBasicMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Kn.prototype.isMeshBasicMaterial=!0;const qn=new Bt,Zn=new et;class Jn{constructor(e,t,n){if(Array.isArray(e))throw new TypeError("v3d.BufferAttribute: array should be a Typed Array.");this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=!0===n,this.usage=we,this.updateRange={offset:0,count:-1},this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let i=0,o=this.itemSize;i0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const n in t)void 0!==t[n]&&(e[n]=t[n]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const t in n){const i=n[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let o=!1;for(const t in this.morphAttributes){const n=this.morphAttributes[t],r=[];for(let t=0,i=n.length;t0&&(i[t]=r,o=!0)}o&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(e.data.groups=JSON.parse(JSON.stringify(r)));const a=this.boundingSphere;return null!==a&&(e.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;null!==n&&this.setIndex(n.clone(t));const i=e.attributes;for(const e in i){const n=i[e];this.setAttribute(e,n.clone(t))}const o=e.morphAttributes;for(const e in o){const n=[],i=o[e];for(let e=0,o=i.length;e0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("v3d.Mesh.updateMorphTargets() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}}raycast(e,t){if(this.isAuxClippingMesh)return;const n=this.geometry,i=this.material,o=this.matrixWorld;if(void 0===i)return;if(null===n.boundingSphere&&n.computeBoundingSphere(),_i.copy(n.boundingSphere),_i.applyMatrix4(o),!1===e.ray.intersectsSphere(_i))return;if(vi.copy(o).invert(),Ai.copy(e.ray).applyMatrix4(vi),null!==n.boundingBox&&!1===Ai.intersectsBox(n.boundingBox))return;let r;if(n.isBufferGeometry){const o=n.index,a=n.attributes.position,s=n.morphAttributes.position,l=n.morphTargetsRelative,c=n.attributes.uv,u=n.attributes.uv2,d=n.groups,h=n.drawRange;if(null!==o)if(Array.isArray(i))for(let n=0,p=d.length;nn.far?null:{distance:c,point:Pi.clone(),object:e}}(e,t,n,i,xi,yi,bi,Bi);if(p){s&&(Ii.fromBufferAttribute(s,c),Ri.fromBufferAttribute(s,u),Li.fromBufferAttribute(s,d),p.uv=jn.getUV(Bi,xi,yi,bi,Ii,Ri,Li,new et)),l&&(Ii.fromBufferAttribute(l,c),Ri.fromBufferAttribute(l,u),Li.fromBufferAttribute(l,d),p.uv2=jn.getUV(Bi,xi,yi,bi,Ii,Ri,Li,new et));const e={a:c,b:u,c:d,normal:new Bt,materialIndex:0};jn.getNormal(xi,yi,bi,e.normal),p.face=e}return p}Di.prototype.isMesh=!0;class Oi extends gi{constructor(e=1,t=1,n=1,i=1,o=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:i,heightSegments:o,depthSegments:r};const a=this;i=Math.floor(i),o=Math.floor(o),r=Math.floor(r);const s=[],l=[],c=[],u=[];let d=0,h=0;function p(e,t,n,i,o,r,p,f,m,g,v){const A=r/m,_=p/g,x=r/2,y=p/2,b=f/2,M=m+1,C=g+1;let S=0,w=0;const E=new Bt;for(let r=0;r0?1:-1,c.push(E.x,E.y,E.z),u.push(s/m),u.push(1-r/g),S+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader;const n={};for(const e in this.extensions)!0===this.extensions[e]&&(n[e]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}Vi.prototype.isShaderMaterial=!0;class Gi extends Nn{constructor(){super(),this.type="Camera",this.matrixWorldInverse=new un,this.projectionMatrix=new un,this.projectionMatrixInverse=new un,this.controls=null,this.viewportFit={type:0,initialAspect:1},this.ignoreShadowLayers=!1}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),e.controls&&(this.controls=e.controls.clone()),this.viewportFit.type=e.viewportFit.type,this.viewportFit.initialAspect=e.viewportFit.initialAspect,this.ignoreShadowLayers=e.ignoreShadowLayers,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(e){return(new this.constructor).copy(this,e)}}Gi.prototype.isCamera=!0;class ki extends Gi{constructor(e=50,t=1,n=.1,i=2e3){super(),this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=i,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=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*Oe*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Ne*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*Oe*Math.atan(Math.tan(.5*Ne*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,i,o,r){this.aspect=e/t,null===this.view&&(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=i,this.view.width=o,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Ne*this.fov)/this.zoom,n=2*t,i=this.aspect*n,o=-.5*i;const r=this.view;if(null!==this.view&&this.view.enabled){const e=r.fullWidth,a=r.fullHeight;o+=r.offsetX*i/e,t-=r.offsetY*n/a,i*=r.width/e,n*=r.height/a}const a=this.filmOffset;0!==a&&(o+=e*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+i,t,t-n,e,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}ki.prototype.isPerspectiveCamera=!0;const Qi=90;class Wi extends Nn{constructor(e,t,n){if(super(),this.type="CubeCamera",!0!==n.isWebGLCubeRenderTarget)return void console.error("v3d.CubeCamera: The constructor now expects an instance of WebGLCubeRenderTarget as third parameter.");this.renderTarget=n;const i=new ki(Qi,1,e,t);i.layers=this.layers,i.up.set(0,-1,0),i.lookAt(new Bt(1,0,0)),this.add(i);const o=new ki(Qi,1,e,t);o.layers=this.layers,o.up.set(0,-1,0),o.lookAt(new Bt(-1,0,0)),this.add(o);const r=new ki(Qi,1,e,t);r.layers=this.layers,r.up.set(0,0,1),r.lookAt(new Bt(0,1,0)),this.add(r);const a=new ki(Qi,1,e,t);a.layers=this.layers,a.up.set(0,0,-1),a.lookAt(new Bt(0,-1,0)),this.add(a);const s=new ki(Qi,1,e,t);s.layers=this.layers,s.up.set(0,-1,0),s.lookAt(new Bt(0,0,1)),this.add(s);const l=new ki(Qi,1,e,t);l.layers=this.layers,l.up.set(0,-1,0),l.lookAt(new Bt(0,0,-1)),this.add(l)}update(e,t){null===this.parent&&this.updateMatrixWorld();const n=this.renderTarget,[i,o,r,a,s,l]=this.children,c=e.xr.enabled,u=e.getRenderTarget();e.xr.enabled=!1;const d=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0),e.render(t,i),e.setRenderTarget(n,1),e.render(t,o),e.setRenderTarget(n,2),e.render(t,r),e.setRenderTarget(n,3),e.render(t,a),e.setRenderTarget(n,4),e.render(t,s),n.texture.generateMipmaps=d,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(u),e.xr.enabled=c,n.texture.needsPMREMUpdate=!0}}class Hi extends St{constructor(e,t,n,i,o,r,a,s,l,u){super(e=void 0!==e?e:[],t=void 0!==t?t:c,n,i,o,r,a,s,l,u),this.flipY=!1}get images(){return this.image}set images(e){this.image=e}copy(e){return super.copy(e),this.image=e.image.slice(),this}}Hi.prototype.isCubeTexture=!0;class ji extends Tt{constructor(e,t,n){Number.isInteger(t)&&(console.warn("v3d.WebGLCubeRenderTarget: constructor signature is now WebGLCubeRenderTarget(size, options)"),t=n),super(e,e,t),t=t||{},this.texture=new Hi(void 0,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.encoding),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:y,this.texture._needsFlipEnvMap=!1}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.format=R,this.texture.encoding=t.encoding,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n varying vec3 vWorldDirection;\n\n vec3 transformDirection(in vec3 dir, in mat4 matrix) {\n\n return normalize((matrix * vec4(dir, 0.0)).xyz);\n\n }\n\n void main() {\n\n vWorldDirection = transformDirection(position, modelMatrix);\n\n #include \n #include \n\n }\n ",fragmentShader:"\n\n uniform sampler2D tEquirect;\n\n varying vec3 vWorldDirection;\n\n #include \n\n void main() {\n\n vec3 direction = normalize(vWorldDirection);\n\n vec2 sampleUV = equirectUv(direction);\n\n gl_FragColor = texture2D(tEquirect, sampleUV);\n\n }\n "},i=new Oi(5,5,5),o=new Vi({name:"CubemapFromEquirect",uniforms:Fi(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:1,blending:0});o.uniforms.tEquirect.value=t;const r=new Di(i,o),a=t.minFilter;t.minFilter===M&&(t.minFilter=y);return new Wi(1,10,this).update(e,r),t.minFilter=a,r.geometry.dispose(),r.material.dispose(),this}clear(e,t,n,i){const o=e.getRenderTarget();for(let o=0;o<6;o++)e.setRenderTarget(this,o),e.clear(t,n,i);e.setRenderTarget(o)}}ji.prototype.isWebGLCubeRenderTarget=!0;const Yi=new Bt,Xi=new Bt,Ki=new tt;class qi{constructor(e=new Bt(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,i){return this.normal.set(e,t,n),this.constant=i,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const i=Yi.subVectors(n,t).cross(Xi.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(i,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(Yi),i=this.normal.dot(n);if(0===i)return 0===this.distanceToPoint(e.start)?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/i;return o<0||o>1?null:t.copy(n).multiplyScalar(o).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||Ki.getNormalMatrix(e),i=this.coplanarPoint(Yi).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(o),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)}}qi.prototype.isPlane=!0;const Zi=new en,Ji=new Bt;class $i{constructor(e=new qi,t=new qi,n=new qi,i=new qi,o=new qi,r=new qi){this.planes=[e,t,n,i,o,r]}set(e,t,n,i,o,r){const a=this.planes;return a[0].copy(e),a[1].copy(t),a[2].copy(n),a[3].copy(i),a[4].copy(o),a[5].copy(r),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,i=n[0],o=n[1],r=n[2],a=n[3],s=n[4],l=n[5],c=n[6],u=n[7],d=n[8],h=n[9],p=n[10],f=n[11],m=n[12],g=n[13],v=n[14],A=n[15];return t[0].setComponents(a-i,u-s,f-d,A-m).normalize(),t[1].setComponents(a+i,u+s,f+d,A+m).normalize(),t[2].setComponents(a+o,u+l,f+h,A+g).normalize(),t[3].setComponents(a-o,u-l,f-h,A-g).normalize(),t[4].setComponents(a-r,u-c,f-p,A-v).normalize(),t[5].setComponents(a+r,u+c,f+p,A+v).normalize(),this}intersectsObject(e){const t=e.geometry;return null===t.boundingSphere&&t.computeBoundingSphere(),Zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)}intersectsSprite(e){return Zi.center.set(0,0,0),Zi.radius=.7071067811865476,Zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)0?e.max.x:e.min.x,Ji.y=i.normal.y>0?e.max.y:e.min.y,Ji.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(Ji)<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 eo(){let e=null,t=!1,n=null,i=null;function o(t,r){n(t,r),i=e.requestAnimationFrame(o)}return{start:function(){!0!==t&&null!==n&&(i=e.requestAnimationFrame(o),t=!0)},stop:function(){e.cancelAnimationFrame(i),t=!1},setAnimationLoop:function(e){n=e},setContext:function(t){e=t}}}function to(e,t){const n=t.isWebGL2;let i=new WeakMap;return{get:function(e){return e.isInterleavedBufferAttribute&&(e=e.data),i.get(e)},remove:function(t){t.isInterleavedBufferAttribute&&(t=t.data);const n=i.get(t);n&&(e.deleteBuffer(n.buffer),i.delete(t))},update:function(t,o){if(t.isGLBufferAttribute){const e=i.get(t);return void((!e||e.version 0.0) ? v : 0.5 * inversesqrt(max(1.0 - x * x, 1e-7)) - v;\nreturn cross(v1, v2) * theta_sintheta;\n}\nvec3 LTC_Evaluate(const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[4]) {\nvec3 v1 = rectCoords[1] - rectCoords[0];\nvec3 v2 = rectCoords[3] - rectCoords[0];\nvec3 lightNormal = cross(v1, v2);\nif(dot(lightNormal, P - rectCoords[0]) < 0.0) return vec3(0.0);\nvec3 T1, T2;\nT1 = normalize(V - N * dot(V, N));\nT2 = -cross(N, T1);\nmat3 mat = mInv * transposeMat3(mat3(T1, T2, N));\nvec3 coords[4];\ncoords[0] = mat * (rectCoords[0] - P);\ncoords[1] = mat * (rectCoords[1] - P);\ncoords[2] = mat * (rectCoords[2] - P);\ncoords[3] = mat * (rectCoords[3] - P);\ncoords[0] = normalize(coords[0]);\ncoords[1] = normalize(coords[1]);\ncoords[2] = normalize(coords[2]);\ncoords[3] = normalize(coords[3]);\nvec3 vectorFormFactor = vec3(0.0);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[0], coords[1]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[1], coords[2]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[2], coords[3]);\nvectorFormFactor += LTC_EdgeVectorFormFactor(coords[3], coords[0]);\nfloat result = LTC_ClippedSphereFormFactor(vectorFormFactor);\nreturn vec3(result);\n}\nvec2 get_BRDF_SpecCoeffsBlender(float x, float y) {\nvec3 xyFactors0 = vec3(x * x, y * y, x * y);\nvec3 xyFactors1 = vec3(x, y, 1);\nvec3 a0a1a2 = vec3(0.33749372, 0.15167605, 1.09684597);\nvec3 a3a4a5 = vec3(-1.26123466, -0.927699, 0.9199188);\nvec3 b0b1b2 = vec3(0.41699717, 0.44675109, 0.79947684);\nvec3 b3b4b5 = vec3(-1.19307849, -0.89813958, 0.89305222);\nvec3 c0c1c2 = vec3(0.29920727, 0.09505591, -0.9136233);\nvec3 c3c4c5 = vec3(0.77055201, 0.13006674, -0.23085581);\nvec3 d0d1d2 = vec3(15.05004149, 7.98517355, 13.30473726);\nvec3 d3d4d5 = vec3(-32.00353547, -12.97743434, 17.83646751);\nfloat coeff0 = (dot(xyFactors0, a0a1a2) + dot(xyFactors1, a3a4a5))\n/ (dot(xyFactors0, b0b1b2) + dot(xyFactors1, b3b4b5));\nfloat coeff1 = (dot(xyFactors0, c0c1c2) + dot(xyFactors1, c3c4c5))\n/ (dot(xyFactors0, d0d1d2) + dot(xyFactors1, d3d4d5));\ncoeff1 = clamp(coeff1, 0.0, 1.0);\nreturn vec2(coeff0, coeff1);\n}\nvec3 BRDF_Specular_GGX_Environment(const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nreturn specularColor * brdf.x + brdf.y;\n}\nvec3 BRDF_Specular_GGX_Environment_Blender_Approx(const in GeometricContext geometry,\nconst in vec3 fresnelRefl0, const in vec3 fresnelRefl90,\nconst in float roughness, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef USE_CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\nfloat dotNV = saturate(dot(normal, geometry.viewDir));\nfloat angle = acos(abs(dotNV)) / PI_HALF;\nvec2 specCoeffs = get_BRDF_SpecCoeffsBlender(angle, roughness);\nvec3 specular = specCoeffs.x * fresnelRefl0\n+ specCoeffs.y * fresnelRefl90\n* vec3(saturate(50.0 * linearToRelativeLuminance(fresnelRefl0)));\n#if defined (COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX)\nspecular = saturate(specular);\n#endif\nreturn specular;\n}\nvoid BRDF_Specular_Multiscattering_Environment(const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 F = F_Schlick_RoughnessDependent(specularColor, dotNV, roughness);\nvec2 brdf = integrateSpecularBRDF(dotNV, roughness);\nvec3 FssEss = F * brdf.x + brdf.y;\nfloat Ess = brdf.x + brdf.y;\nfloat Ems = 1.0 - Ess;\nvec3 Favg = specularColor + (1.0 - specularColor) * 0.047619;\nvec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\nsingleScatter += FssEss;\nmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit() {\nreturn 0.25;\n}\nfloat D_BlinnPhong(const in float shininess, const in float dotNH) {\nreturn RECIPROCAL_PI * (shininess * 0.5 + 1.0) * pow(dotNH, shininess);\n}\nvec3 BRDF_BlinnPhong(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess) {\nvec3 halfDir = normalize(lightDir + viewDir);\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotVH = saturate(dot(viewDir, halfDir));\nvec3 F = F_Schlick(specularColor, 1.0, dotVH);\nfloat G = G_BlinnPhong_Implicit();\nfloat D = D_BlinnPhong(shininess, dotNH);\nreturn F * (G * D);\n}\nfloat GGXRoughnessToBlinnExponent(const in float ggxRoughness) {\nreturn (2.0 / pow2(ggxRoughness + 0.0001) - 2.0);\n}\nfloat BlinnExponentToGGXRoughness(const in float blinnExponent) {\nreturn sqrt(2.0 / (blinnExponent + 2.0));\n}\n#if defined(USE_SHEEN)\nfloat D_Charlie(float roughness, float dotNH) {\nfloat alpha = pow2(roughness);\nfloat invAlpha = 1.0 / alpha;\nfloat cos2h = dotNH * dotNH;\nfloat sin2h = max(1.0 - cos2h, 0.0078125);\nreturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float dotNV, float dotNL) {\nreturn saturate(1.0 / (4.0 * (dotNL + dotNV - dotNL * dotNV)));\n}\nvec3 BRDF_Sheen(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness) {\nvec3 halfDir = normalize(lightDir + viewDir);\nfloat dotNL = saturate(dot(normal, lightDir));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat D = D_Charlie(sheenRoughness, dotNH);\nfloat V = V_Neubelt(dotNV, dotNL);\nreturn sheenColor * (D * V);\n}\n#endif",bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\nuniform sampler2D bumpMap;\nuniform float bumpScale;\nvec2 dHdxy_fwd() {\nvec2 dSTdx = dFdx(vUv);\nvec2 dSTdy = dFdy(vUv);\nfloat Hll = bumpScale * texture2D(bumpMap, vUv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, vUv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, vUv + dSTdy).x - Hll;\nreturn vec2(dBx, dBy);\n}\nvec3 perturbNormalArb(vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection) {\nvec3 vSigmaX = vec3(dFdx(surf_pos.x), dFdx(surf_pos.y), dFdx(surf_pos.z));\nvec3 vSigmaY = vec3(dFdy(surf_pos.x), dFdy(surf_pos.y), dFdy(surf_pos.z));\nvec3 vN = surf_norm;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1) * faceDirection;\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nreturn normalize(abs(fDet) * surf_norm - vGrad);\n}\n#endif",clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\nvec4 plane;\n#pragma unroll_loop_start\nfor (int i = 0; i < UNION_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nif (dot(vClipPosition, plane.xyz) > plane.w) discard;\n}\n#pragma unroll_loop_end\n#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\nbool clipped = true;\n#pragma unroll_loop_start\nfor (int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i++) {\nplane = clippingPlanes[i];\nclipped = (dot(vClipPosition, plane.xyz) > plane.w) && clipped;\n}\n#pragma unroll_loop_end\nif (clipped) discard;\n#endif\n#endif",clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\nvarying vec3 vClipPosition;\nuniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0\nvarying vec3 vClipPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0\nvClipPosition = -mvPosition.xyz;\n#endif",color_fragment:"#if defined(USE_COLOR_ALPHA)\ndiffuseColor *= vColor;\n#elif defined(USE_COLOR)\ndiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#if defined(USE_COLOR_ALPHA)\nvarying vec4 vColor;\n#elif defined(USE_COLOR)\nvarying vec3 vColor;\n#endif",color_pars_vertex:"#if defined(USE_COLOR_ALPHA)\nvarying vec4 vColor;\n#elif defined(USE_COLOR) || defined(USE_INSTANCING_COLOR)\nvarying vec3 vColor;\n#endif",color_vertex:"#if defined(USE_COLOR_ALPHA)\nvColor = vec4(1.0);\n#elif defined(USE_COLOR) || defined(USE_INSTANCING_COLOR)\nvColor = vec3(1.0);\n#endif\n#ifdef USE_COLOR\nvColor *= color;\n#endif\n#ifdef USE_INSTANCING_COLOR\nvColor.xyz *= instanceColor.xyz;\n#endif",common:"#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\n#define whiteComplement(a) (1.0 - saturate(a))\n#define RECIPROCAL_3 0.333333333333\nfloat pow2(const in float x) { return x*x; }\nfloat pow3(const in float x) { return x*x*x; }\nfloat pow4(const in float x) { float x2 = x*x; return x2*x2; }\nfloat max3(const in vec3 v) { return max(max(v.x, v.y), v.z); }\nfloat average(const in vec3 color) { return dot(color, vec3(0.3333)); }\nhighp float rand(const in vec2 uv) {\nconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\nhighp float dt = dot(uv.xy, vec2(a,b)), sn = mod(dt, PI);\nreturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\nfloat precisionSafeLength(vec3 v) { return length(v); }\n#else\nfloat precisionSafeLength(vec3 v) {\nfloat maxComponent = max3(abs(v));\nreturn length(v / maxComponent) * maxComponent;\n}\n#endif\nstruct IncidentLight {\nvec3 color;\nvec3 direction;\nbool visible;\n};\nstruct ReflectedLight {\nvec3 directDiffuse;\nvec3 directSpecular;\nvec3 indirectDiffuse;\nvec3 indirectSpecular;\n};\nstruct GeometricContext {\nvec3 position;\nvec3 normal;\nvec3 viewDir;\nvec3 probeNormal;\n#ifdef USE_CLEARCOAT\nvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((matrix * vec4(dir, 0.0)).xyz);\n}\nvec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\nreturn normalize((vec4(dir, 0.0) * matrix).xyz);\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nfloat distance = dot(planeNormal, point - pointOnPlane);\nreturn - distance * planeNormal + point;\n}\nfloat sideOfPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn sign(dot(point - pointOnPlane, planeNormal));\n}\nvec3 linePlaneIntersect(in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal) {\nreturn lineDirection * (dot(planeNormal, pointOnPlane - pointOnLine) / dot(planeNormal, lineDirection)) + pointOnLine;\n}\nmat3 transposeMat3(const in mat3 m) {\nmat3 tmp;\ntmp[0] = vec3(m[0].x, m[1].x, m[2].x);\ntmp[1] = vec3(m[0].y, m[1].y, m[2].y);\ntmp[2] = vec3(m[0].z, m[1].z, m[2].z);\nreturn tmp;\n}\nfloat linearToRelativeLuminance(const in vec3 color) {\nvec3 weights = vec3(0.2126, 0.7152, 0.0722);\nreturn dot(weights, color.rgb);\n}\nbool isPerspectiveMatrix(mat4 m) {\nreturn m[2][3] == - 1.0;\n}\nvec2 equirectUv(in vec3 dir) {\nfloat u = atan(dir.z, dir.x) * RECIPROCAL_PI2 + 0.5;\nfloat v = asin(clamp(dir.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nreturn vec2(u, v);\n}\nfloat smootherstep(float edge0, float edge1, float x) {\nfloat t = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\nreturn t * t * t * (t * (t * 6.0 - 15.0) + 10.0);\n}\nvec3 smootherstep(vec3 x) {\nvec3 t = clamp(x, 0.0, 1.0);\nreturn (t * (t * 6.0 - 15.0) + 10.0) * t * t * t;\n}\nhighp vec3 rand3(const in vec3 v) {\nconst highp float c = 43758.5453;\nconst highp mat3 coeffs = mat3(\n165.15, 253.34, 323.22,\n241.49, 329.07, 147.79,\n376.31, 143.45, 281.63\n);\nhighp vec3 sn = mod(coeffs * v, PI);\nreturn fract(sin(sn) * c);\n}\nfloat powCompat(const in float val, const in float power) {\nif (power == 0.0)\nreturn 1.0;\nelse if (val < 0.0) {\nif (mod(-power, 2.0) == 0.0)\nreturn pow(abs(val), power);\nelse\nreturn -pow(abs(val), power);\n} else if (val == 0.0)\nreturn 0.0;\nreturn pow(abs(val), power);\n}\nfloat maxFromRGB(vec3 rgb) {\nreturn max(max(rgb.r, rgb.g), rgb.b);\n}\nbool isOrtho(const in mat4 m) {\nif (m[3][3] != 0.0)\nreturn true;\nelse\nreturn false;\n}\nvec3 swizzleUpZ(const vec3 vec) {\nreturn vec3(vec[0], -vec[2], vec[1]);\n}\nvec3 swizzleUpY(const vec3 vec) {\nreturn vec3(vec[0], vec[2], -vec[1]);\n}\nvec3 xyz_to_sRGB(vec3 xyz) {\nmat3 convMat = mat3(\n3.2406, -0.9689, 0.0557,\n-1.5372, 1.8758, -0.2040,\n-0.4986, 0.0415, 1.0570\n);\nreturn convMat * xyz;\n}\nvec3 xyY_to_XYZ(float x, float y, float Y) {\nfloat X = 0.0;\nfloat Z = 0.0;\nif (y != 0.0) {\nX = (Y / y) * x;\nZ = (Y / y) * (1.0 - x - y);\n}\nreturn vec3(X, Y, Z);\n}\nvec3 octUVToCubeVec(vec2 octUV, vec2 texelSize) {\noctUV = (1.0 + 2.0 * texelSize) * octUV - texelSize;\noctUV = octUV * 2.0 - 1.0;\nfloat x = octUV.x;\nfloat z = -octUV.y;\nfloat absX = abs(x);\nfloat absZ = abs(z);\nvec3 cubeVec = vec3(x, 1.0 - absX - absZ, z);\nif (absX + absZ > 1.0) {\ncubeVec.xz = -(vec2(absZ, absX) - 1.0) * sign(vec2(x, z));\n}\nreturn cubeVec;\n}\nvec2 cubeVecToOctUV(vec3 cubeVec, vec2 texelSize) {\ncubeVec /= dot(vec3(1.0), abs(cubeVec));\nvec2 octUV = vec2(cubeVec.x, -cubeVec.z);\nif (cubeVec.y < 0.0) {\noctUV = sign(octUV) * (1.0 - abs(octUV.ts));\n}\noctUV = (octUV + 1.0) / 2.0;\noctUV = (1.0 - 2.0 * texelSize) * octUV + texelSize;\nreturn octUV;\n}\n#if __VERSION__ == 100\nfloat cosh(float x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec2 cosh(vec2 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec3 cosh(vec3 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nvec4 cosh(vec4 x) {\nreturn (exp(x) + exp(-x)) / 2.0;\n}\nfloat sinh(float x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec2 sinh(vec2 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec3 sinh(vec3 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nvec4 sinh(vec4 x) {\nreturn (exp(x) - exp(-x)) / 2.0;\n}\nfloat tanh(float x) {\nfloat exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec2 tanh(vec2 x) {\nvec2 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec3 tanh(vec3 x) {\nvec3 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nvec4 tanh(vec4 x) {\nvec4 exp2x = exp(2.0 * x);\nreturn (exp2x - 1.0) / (exp2x + 1.0);\n}\nfloat trunc(float x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec2 trunc(vec2 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec3 trunc(vec3 x) {\nreturn floor(abs(x)) * sign(x);\n}\nvec4 trunc(vec4 x) {\nreturn floor(abs(x)) * sign(x);\n}\n#endif\nfloat getSmoothFactor(float a, float b, float smoothness) {\nreturn max(smoothness - abs(a - b), 0.0) / smoothness;\n}\nfloat smoothMin(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn min(a, b) - smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nfloat smoothMax(float a, float b, float smoothness) {\nfloat smoothFac = getSmoothFactor(a, b, smoothness);\nreturn max(a, b) + smoothFac * smoothFac * smoothFac * smoothness * (1.0 / 6.0);\n}\nvec3 vec3RotateAxisAngle(vec3 vector, vec3 axis, float angle) {\nvec3 axisNorm = normalize(axis);\nfloat x = axisNorm.x, y = axisNorm.y, z = axisNorm.z;\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(\nx * x * (1.0 - c) + c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s,\nx * y * (1.0 - c) - z * s, y * y * (1.0 - c) + c, y * z * (1.0 - c) + x * s,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z * (1.0 - c) + c\n) * vector;\n}\nmat3 mat3RotateX(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(1.0, 0.0, 0.0,\n0.0, c, s,\n0.0, -s, c);\n}\nmat3 mat3RotateY(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(c, 0.0, -s,\n0.0, 1.0, 0.0,\ns, 0.0, c);\n}\nmat3 mat3RotateZ(float angle) {\nfloat s = sin(angle), c = cos(angle);\nreturn mat3(c, s, 0.0,\n-s, c, 0.0,\n0.0, 0.0, 1.0);\n}\nvec3 vec3RotateXAngle(vec3 vector, float angle) {\nreturn mat3RotateX(angle) * vector;\n}\nvec3 vec3RotateYAngle(vec3 vector, float angle) {\nreturn mat3RotateY(angle) * vector;\n}\nvec3 vec3RotateZAngle(vec3 vector, float angle) {\nreturn mat3RotateZ(angle) * vector;\n}\nvec4 eulerToAxisAngle(vec3 euler) {\nfloat c1 = cos(euler.x / 2.0), c2 = cos(euler.y / 2.0), c3 = cos(euler.z / 2.0);\nfloat s1 = sin(euler.x / 2.0), s2 = sin(euler.y / 2.0), s3 = sin(euler.z / 2.0);\nvec4 axisAngle = vec4(\ns1 * c2 * c3 - c1 * s2 * s3,\nc1 * s2 * c3 + s1 * c2 * s3,\nc1 * c2 * s3 - s1 * s2 * c3,\n2.0 * acos(c1 * c2 * c3 + s1 * s2 * s3)\n);\naxisAngle.xyz = length(axisAngle.xyz) > 0.0 ? normalize(axisAngle.xyz) : vec3(1.0, 0.0, 0.0);\nreturn axisAngle;\n}\nfloat mat3GetDeterminant(mat3 mat) {\nreturn mat[0][0] * mat[1][1] * mat[2][2]\n+ mat[0][2] * mat[1][0] * mat[2][1]\n+ mat[0][1] * mat[1][2] * mat[2][0]\n- mat[0][2] * mat[1][1] * mat[2][0]\n- mat[0][0] * mat[1][2] * mat[2][1]\n- mat[0][1] * mat[1][0] * mat[2][2];\n}\nmat3 mat3GetInverseTransposed(mat3 mat) {\nfloat det = mat3GetDeterminant(mat);\nfloat a00 = (mat[1][1] * mat[2][2] - mat[1][2] * mat[2][1]) / det;\nfloat a01 = - (mat[1][0] * mat[2][2] - mat[1][2] * mat[2][0]) / det;\nfloat a02 = (mat[1][0] * mat[2][1] - mat[1][1] * mat[2][0]) / det;\nfloat a10 = - (mat[0][1] * mat[2][2] - mat[0][2] * mat[2][1]) / det;\nfloat a11 = (mat[0][0] * mat[2][2] - mat[0][2] * mat[2][0]) / det;\nfloat a12 = - (mat[0][0] * mat[2][1] - mat[0][1] * mat[2][0]) / det;\nfloat a20 = (mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]) / det;\nfloat a21 = - (mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]) / det;\nfloat a22 = (mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]) / det;\nreturn mat3(\na00, a01, a02,\na10, a11, a12,\na20, a21, a22\n);\n}\nmat3 toMat3(mat4 mat) {\nreturn mat3(mat[0][0], mat[0][1], mat[0][2],\nmat[1][0], mat[1][1], mat[1][2],\nmat[2][0], mat[2][1], mat[2][2]);\n}\nmat4 toMat4(mat3 mat) {\nreturn mat4(mat[0][0], mat[0][1], mat[0][2], 0.0,\nmat[1][0], mat[1][1], mat[1][2], 0.0,\nmat[2][0], mat[2][1], mat[2][2], 0.0,\n0.0, 0.0, 0.0, 1.0);\n}",cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\nfloat getFace(vec3 direction) {\nvec3 absDirection = abs(direction);\nfloat face = -1.0;\nif (absDirection.x > absDirection.z) {\nif (absDirection.x > absDirection.y) {\nface = direction.x > 0.0 ? 0.0 : 3.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n} else {\nif (absDirection.z > absDirection.y) {\nface = direction.z > 0.0 ? 2.0 : 5.0;\n} else {\nface = direction.y > 0.0 ? 1.0 : 4.0;\n}\n}\nreturn face;\n}\nvec2 getUV(vec3 direction, float face) {\nvec2 uv;\nif (face == 0.0) {\nuv = vec2(-direction.z, direction.y) / abs(direction.x);\n} else if (face == 1.0) {\nuv = vec2(direction.x, -direction.z) / abs(direction.y);\n} else if (face == 2.0) {\nuv = direction.xy / abs(direction.z);\n} else if (face == 3.0) {\nuv = vec2(direction.z, direction.y) / abs(direction.x);\n} else if (face == 4.0) {\nuv = direction.xz / abs(direction.y);\n} else {\nuv = vec2(-direction.x, direction.y) / abs(direction.z);\n}\nreturn 0.5 * (uv + 1.0);\n}\n#ifndef cubeUV_maxTileSize\n#define cubeUV_maxTileSize 256.0\n#endif\n#define cubeUV_lodIdxMin 0.0\n#define cubeUV_lodIdxLastDownscaled 4.0\n#define cubeUV_lodIdxMax 10.0\n#define cubeUV_minTileSize (cubeUV_maxTileSize / exp2(cubeUV_lodIdxLastDownscaled))\nfloat getLodTileSize(float lodIdx) {\nreturn cubeUV_maxTileSize / exp2(min(lodIdx, cubeUV_lodIdxLastDownscaled));\n}\nfloat getLodFilterLevel(float lodIdx) {\nreturn max(lodIdx - cubeUV_lodIdxLastDownscaled, 0.0);\n}\nvec2 fixCubeUVSeams(vec2 uv, float faceSize) {\nfloat BORDER_WIDTH_PX = max(cubeUV_maxTileSize / 256.0 - 1.0, 0.0);\nfloat scale = (faceSize - BORDER_WIDTH_PX) / faceSize;\nfloat offset = 0.5 * BORDER_WIDTH_PX / faceSize;\nreturn uv * scale + offset;\n}\nvec2 getUVPixels(vec3 direction, float lodIdx) {\nfloat face = getFace(direction);\nfloat faceSize = getLodTileSize(lodIdx);\nfloat filterLevel = getLodFilterLevel(lodIdx);\nvec2 uv = getUV(direction, face);\nuv = fixCubeUVSeams(uv, faceSize);\nuv *= (faceSize - 1.0);\nif (face > 2.0) {\nuv.y += faceSize;\nface -= 3.0;\n}\nuv.x += face * faceSize;\nif (lodIdx > 0.0) {\nuv.y += 2.0 * cubeUV_maxTileSize;\n}\nuv.y += filterLevel * 2.0 * cubeUV_minTileSize;\nuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\nreturn uv;\n}\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUVPixels(direction, lodIdx);\nvec2 f = fract(uv);\nuv += 0.5 - f;\nuv *= texelSize;\nvec3 tl = texture2D(envMap, uv).rgb;\nuv.x += texelSize;\nvec3 tr = texture2D(envMap, uv).rgb;\nuv.y += texelSize;\nvec3 br = texture2D(envMap, uv).rgb;\nuv.x -= texelSize;\nvec3 bl = texture2D(envMap, uv).rgb;\nvec3 tm = mix(tl, tr, f.x);\nvec3 bm = mix(bl, br, f.x);\nreturn mix(tm, bm, f.y);\n}\nvec3 sampleCubeUV(sampler2D envMap, vec3 direction, float lodIdx) {\nfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\nvec2 uv = getUVPixels(direction, lodIdx);\nuv += 0.5;\nuv *= texelSize;\nreturn texture2D(envMap, uv).rgb;\n}\n#define cubeUV_r0 1.0\n#define cubeUV_v0 0.339\n#define cubeUV_m0 -2.0\n#define cubeUV_r1 0.8\n#define cubeUV_v1 0.276\n#define cubeUV_m1 -1.0\n#define cubeUV_r4 0.4\n#define cubeUV_v4 0.046\n#define cubeUV_m4 2.0\n#define cubeUV_r5 0.305\n#define cubeUV_v5 0.016\n#define cubeUV_m5 3.0\n#define cubeUV_r6 0.21\n#define cubeUV_v6 0.0038\n#define cubeUV_m6 4.0\nfloat roughnessToMip(float roughness) {\nfloat r = roughness;\nfloat r2 = r * r;\nfloat r3 = r2 * r;\nroughness = -1.20278049 * r3 + 1.86860137 * r2 + 0.32478081 * r + 0.0098139;\nreturn roughness * (cubeUV_lodIdxMax - cubeUV_lodIdxMin);\n}\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\nfloat lodIdx = clamp(roughnessToMip(roughness), cubeUV_lodIdxMin,\ncubeUV_lodIdxMax);\nfloat lodIdxF = fract(lodIdx);\nfloat lodIdxI = floor(lodIdx);\nvec3 color0 = sampleCubeUV(envMap, sampleDir, lodIdxI);\nif (lodIdxF == 0.0) {\nreturn vec4(color0, 1.0);\n} else {\nvec3 color1 = sampleCubeUV(envMap, sampleDir, lodIdxI + 1.0);\nreturn vec4(mix(color0, color1, lodIdxF), 1.0);\n}\n}\n#endif",defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\nmat3 m = mat3(instanceMatrix);\ntransformedNormal /= vec3(dot(m[0], m[0]), dot(m[1], m[1]), dot(m[2], m[2]));\ntransformedNormal = m * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\ntransformedNormal = -transformedNormal;\n#endif\n#ifdef USE_TANGENT\nvec3 transformedTangent = (modelViewMatrix * vec4(objectTangent, 0.0)).xyz;\n#ifdef FLIP_SIDED\ntransformedTangent = -transformedTangent;\n#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\nuniform sampler2D displacementMap;\nuniform float displacementScale;\nuniform float displacementBias;\n#endif",displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\ntransformed += normalize(objectNormal) * (texture2D(displacementMap, vUv).x * displacementScale + displacementBias);\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\nvec4 emissiveColor = texture2D(emissiveMap, vUv);\ntotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\nuniform sampler2D emissiveMap;\n#endif",encodings_fragment:"gl_FragColor = linearToOutputTexel(gl_FragColor);",encodings_pars_fragment:"vec4 LinearToLinear(in vec4 value) {\nreturn value;\n}\nvec4 LinearTosRGB(in vec4 value) {\nreturn 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);\n}",envmap_fragment:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvec3 cameraToFrag;\nif (isOrthographic) {\ncameraToFrag = normalize(vec3(-viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToFrag = normalize(vWorldPosition - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 reflectVec = reflect(cameraToFrag, worldNormal);\n#else\nvec3 reflectVec = refract(cameraToFrag, worldNormal, refractionRatio);\n#endif\n#else\nvec3 reflectVec = vReflect;\n#endif\n#ifdef ENVMAP_TYPE_CUBE\nvec4 envColor = textureCube(envMap, vec3(flipEnvMap * reflectVec.x, reflectVec.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 envColor = textureCubeUV(envMap, reflectVec, 0.0);\n#else\nvec4 envColor = vec4(0.0);\n#endif\n#ifdef ENVMAP_BLENDING_MULTIPLY\noutgoingLight = mix(outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_MIX)\noutgoingLight = mix(outgoingLight, envColor.xyz, specularStrength * reflectivity);\n#elif defined(ENVMAP_BLENDING_ADD)\noutgoingLight += envColor.xyz * specularStrength * reflectivity;\n#endif\n#endif",envmap_common_pars_fragment:"#ifdef USE_ENVMAP\nuniform float envMapIntensity;\nuniform float flipEnvMap;\nuniform int maxMipLevel;\n#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#else\nuniform sampler2D envMap;\n#endif\n#if defined(ENVMAP_TYPE_CUBE) && defined(NODE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat calcGeometryRoughness(vec3 geometryNormal) {\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nreturn max(max(dxy.x, dxy.y), dxy.z);\n}\nfloat calcCubeUVAdjustedRoughness(float origRoughness, float geomRoughness) {\nreturn min(max(origRoughness, 0.0525) + geomRoughness, 1.0);\n}\n#endif\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nuniform float reflectivity;\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) || defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\nvarying vec3 vWorldPosition;\nuniform float refractionRatio;\n#else\nvarying vec3 vReflect;\n#endif\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\n#if defined(USE_BUMPMAP) || defined(USE_NORMALMAP) ||defined(PHONG)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\n\nvarying vec3 vWorldPosition;\n#else\nvarying vec3 vReflect;\nuniform float refractionRatio;\n#endif\n#endif",envmap_physical_pars_fragment:"#if defined(USE_ENVMAP)\n#define ENVMAP_PARALLAX_INFINITE 0\n#define ENVMAP_PARALLAX_SPHERE 1\n#define ENVMAP_PARALLAX_BOX 2\n#ifdef ENVMAP_MODE_REFRACTION\nuniform float refractionRatio;\n#endif\nuniform int envMapParallaxType;\nuniform mat4 envMapParallaxMatrix;\nuniform mat4 envMapParallaxMatrixInv;\nvec3 correctParallax(vec3 directionVecWorld, vec3 posWorld, int parallaxType) {\nvec3 posProbe = (envMapParallaxMatrix * vec4(posWorld, 1.0)).xyz;\nvec3 reflectVecProbe = transformDirection(directionVecWorld, envMapParallaxMatrix);\nif (parallaxType == ENVMAP_PARALLAX_SPHERE) {\nfloat b = 2.0 * dot(reflectVecProbe, posProbe);\nfloat c = dot(posProbe, posProbe) - 1.0;\nfloat D = b * b - 4.0 * c;\nif (D >= 0.0) {\nfloat x = (sqrt(D) - b) / 2.0;\nreflectVecProbe = posProbe + x * reflectVecProbe;\n}\n} else if (parallaxType == ENVMAP_PARALLAX_BOX) {\nvec3 scalePos = (vec3(1.0) - posProbe) / reflectVecProbe;\nvec3 scaleNeg = (vec3(-1.0) - posProbe) / reflectVecProbe;\nvec3 scalePosNeg = mix(scaleNeg, scalePos, step(vec3(0.0), reflectVecProbe));\nfloat x = min(scalePosNeg.x, min(scalePosNeg.y, scalePosNeg.z));\nreflectVecProbe = posProbe + x * reflectVecProbe;\n}\nvec3 directionVecWorldCorrected = transformDirection(reflectVecProbe,\nenvMapParallaxMatrixInv);\nreturn directionVecWorldCorrected;\n}\nvec3 getIBLIrradiance(const in GeometricContext geometry, const in int maxMIPLevel) {\nvec3 worldNormal = inverseTransformDirection(geometry.probeNormal, viewMatrix);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, float(maxMIPLevel));\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, float(maxMIPLevel));\n#endif\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * worldNormal.x, worldNormal.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec, 1.0);\n#else\nvec4 envMapColor = vec4(0.0);\n#endif\nreturn PI * envMapColor.rgb * envMapIntensity;\n}\nfloat getSpecularMIPLevel(const in float blinnShininessExponent, const in int maxMIPLevel) {\nfloat maxMIPLevelScalar = float(maxMIPLevel);\nfloat clapmedBlinnShininessExponent = min(blinnShininessExponent, 30000.0);\nfloat desiredMIPLevel = maxMIPLevelScalar + 0.79248\n- 0.5 * log2(pow2(clapmedBlinnShininessExponent) + 1.0);\nreturn clamp(desiredMIPLevel, 0.0, maxMIPLevelScalar);\n}\nvec3 _getIBL(const float blinnShininessExponent, const int maxMIPLevel, vec3 directionVec) {\nfloat specularMIPLevel = getSpecularMIPLevel(blinnShininessExponent, maxMIPLevel);\n#ifdef ENVMAP_TYPE_CUBE\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\n#ifdef TEXTURE_LOD_EXT\nvec4 envMapColor = textureCubeLodEXT(envMap, queryVec, specularMIPLevel);\n#else\nvec4 envMapColor = textureCube(envMap, queryVec, specularMIPLevel);\n#endif\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec3 queryVec = vec3(flipEnvMap * directionVec.x, directionVec.yz);\nvec4 envMapColor = textureCubeUV(envMap, queryVec,\nBlinnExponentToGGXRoughness(blinnShininessExponent));\n#else\nvec4 envMapColor = return vec3(0.0);\n#endif\nreturn envMapColor.rgb * envMapIntensity;\n}\nvec3 getIBLRadiance(const GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const int useCoat) {\nvec3 normal = geometry.normal;\n#ifdef USE_CLEARCOAT\nif (useCoat == 1) {\nnormal = geometry.clearcoatNormal;\n}\n#endif\n#ifdef ENVMAP_MODE_REFLECTION\nvec3 directionVec = reflect(-geometry.viewDir, normal);\n#else\nvec3 directionVec = refract(-geometry.viewDir, normal, refractionRatio);\n#endif\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nvec3 posWorld = (invViewMatrix * vec4(geometry.position, 1.0)).xyz;\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\ndirectionVec = correctParallax(directionVec, posWorld, envMapParallaxType);\n}\nreturn _getIBL(blinnShininessExponent, maxMIPLevel, directionVec);\n}\nvec3 getIBLRefraction(const GeometricContext geometry, const float blinnShininessExponent,\nconst int maxMIPLevel, const float refrRatio) {\nvec3 directionVec = refract(-geometry.viewDir, geometry.normal, refrRatio);\ndirectionVec = inverseTransformDirection(directionVec, viewMatrix);\nvec3 posWorld = (invViewMatrix * vec4(geometry.position, 1.0)).xyz;\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\ndirectionVec = correctParallax(directionVec, posWorld, envMapParallaxType);\n}\nreturn _getIBL(blinnShininessExponent, maxMIPLevel, directionVec);\n}\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\n#ifdef ENV_WORLDPOS\nvWorldPosition = worldPosition.xyz;\n#else\nvec3 cameraToVertex;\nif (isOrthographic) {\ncameraToVertex = normalize(vec3(-viewMatrix[0][2], - viewMatrix[1][2], - viewMatrix[2][2]));\n} else {\ncameraToVertex = normalize(worldPosition.xyz - cameraPosition);\n}\nvec3 worldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\n#ifdef ENVMAP_MODE_REFLECTION\nvReflect = reflect(cameraToVertex, worldNormal);\n#else\nvReflect = refract(cameraToVertex, worldNormal, refractionRatio);\n#endif\n#endif\n#endif",fog_vertex:"#ifdef USE_FOG\nvFogDepth = -mvPosition.z;\n#endif",fog_pars_vertex:"#ifdef USE_FOG\nvarying float vFogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n#ifdef FOG_EXP2\nfloat fogFactor = 1.0 - exp(-fogDensity * fogDensity * vFogDepth * vFogDepth);\n#else\nfloat fogFactor = smoothstep(fogNear, fogFar, vFogDepth);\n#endif\ngl_FragColor.rgb = mix(gl_FragColor.rgb, fogColor, fogFactor);\n#endif",fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\nvarying float vFogDepth;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",gradientmap_pars_fragment:"#ifdef USE_GRADIENTMAP\nuniform sampler2D gradientMap;\n#endif\nvec3 getGradientIrradiance(vec3 normal, vec3 lightDirection) {\nfloat dotNL = dot(normal, lightDirection);\nvec2 coord = vec2(dotNL * 0.5 + 0.5, 0.0);\n#ifdef USE_GRADIENTMAP\nreturn vec3(texture2D(gradientMap, coord).r);\n#else\nreturn (coord.x < 0.7) ? vec3(0.7) : vec3(1.0);\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel = texture2D(lightMap, vUv2);\nvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nlightMapIrradiance *= PI;\n#endif\nreflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;\nuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3(1.0);\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize(transformedNormal);\ngeometry.probeNormal = geometry.normal;\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(-mvPosition.xyz);\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.probeNormal = backGeometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3(0.0);\nvIndirectFront = vec3(0.0);\n#ifdef DOUBLE_SIDED\nvLightBack = vec3(0.0);\nvIndirectBack = vec3(0.0);\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\nvIndirectFront += getAmbientLightIrradiance(ambientLightColor);\nvIndirectFront += getLightProbeIrradiance(lightProbe, geometry.probeNormal);\n#ifdef DOUBLE_SIDED\nvIndirectBack += getAmbientLightIrradiance(ambientLightColor);\nvIndirectBack += getLightProbeIrradiance(lightProbe, backGeometry.probeNormal);\n#endif\n#if NUM_POINT_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointLightInfo(pointLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotLightInfo(spotLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_DIR_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalLightInfo(directionalLights[i], geometry, directLight);\ndotNL = dot(geometry.normal, directLight.direction);\ndirectLightColor_Diffuse = directLight.color;\nvLightFront += saturate(dotNL) * directLightColor_Diffuse;\n#ifdef DOUBLE_SIDED\nvLightBack += saturate(-dotNL) * directLightColor_Diffuse;\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_HEMI_LIGHTS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nvIndirectFront += getHemisphereLightIrradiance(hemisphereLights[i], geometry.probeNormal);\n#ifdef DOUBLE_SIDED\nvIndirectBack += getHemisphereLightIrradiance(hemisphereLights[i], backGeometry.probeNormal);\n#endif\n}\n#pragma unroll_loop_end\n#endif",lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[9];\nvec3 shGetIrradianceAt(in vec3 normal, in vec3 shCoefficients[9]) {\nfloat x = normal.x, y = normal.y, z = normal.z;\nvec3 result = shCoefficients[0] * 0.886227;\nresult += shCoefficients[1] * 2.0 * 0.511664 * y;\nresult += shCoefficients[2] * 2.0 * 0.511664 * z;\nresult += shCoefficients[3] * 2.0 * 0.511664 * x;\nresult += shCoefficients[4] * 2.0 * 0.429043 * x * y;\nresult += shCoefficients[5] * 2.0 * 0.429043 * y * z;\nresult += shCoefficients[6] * (0.743125 * z * z - 0.247708);\nresult += shCoefficients[7] * 2.0 * 0.429043 * x * z;\nresult += shCoefficients[8] * 0.429043 * (x * x - y * y);\nreturn result;\n}\nvec3 getLightProbeIrradiance(const in vec3 lightProbe[9], const in vec3 normal) {\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 irradiance = shGetIrradianceAt(worldNormal, lightProbe);\nreturn irradiance;\n}\nvec3 getAmbientLightIrradiance(const in vec3 ambientLightColor) {\nvec3 irradiance = ambientLightColor;\nreturn irradiance;\n}\nfloat getDistanceAttenuation(float lightDistance, const in float cutoffDistance, const in float decayExponent) {\n#if defined (PHYSICALLY_CORRECT_LIGHTS)\nlightDistance = UNITS_SCALE_FACTOR * lightDistance;\n#ifdef MT_MAYA\nfloat distanceFalloff = 1.0 / pow(lightDistance + 1.0, decayExponent);\n#else\nfloat distanceFalloff = 1.0 / max(pow(lightDistance, decayExponent), 0.01);\n#endif\nif (cutoffDistance > 0.0) {\ndistanceFalloff *= pow2(saturate(1.0 - pow4(lightDistance / cutoffDistance)));\n}\nreturn distanceFalloff;\n#else\nif (cutoffDistance > 0.0 && decayExponent > 0.0) {\nreturn pow(saturate(-lightDistance / cutoffDistance + 1.0), decayExponent);\n}\nreturn 1.0;\n#endif\n}\nfloat getSpotAttenuation(const in float coneCosine, const in float penumbraCosine, const in float angleCosine) {\nreturn smoothstep(coneCosine, penumbraCosine, angleCosine);\n}\n#if NUM_DIR_LIGHTS > 0\nstruct DirectionalLight {\nvec3 direction;\nvec3 color;\n};\nuniform DirectionalLight directionalLights[NUM_DIR_LIGHTS];\nvoid getDirectionalLightInfo(const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight light) {\nlight.color = directionalLight.color;\nlight.direction = directionalLight.direction;\nlight.visible = true;\n}\n#endif\n#if NUM_POINT_LIGHTS > 0\nstruct PointLight {\nvec3 position;\nvec3 color;\nfloat distance;\nfloat decay;\n};\nuniform PointLight pointLights[NUM_POINT_LIGHTS];\nvoid getPointLightInfo(const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight light) {\nvec3 lVector = pointLight.position - geometry.position;\nlight.direction = normalize(lVector);\nfloat lightDistance = length(lVector);\nlight.color = pointLight.color;\nlight.color *= getDistanceAttenuation(lightDistance, pointLight.distance, pointLight.decay);\nlight.visible = (light.color != vec3(0.0));\n}\n#endif\n#if NUM_SPOT_LIGHTS > 0\nstruct SpotLight {\nvec3 position;\nvec3 direction;\nvec3 color;\nfloat distance;\nfloat decay;\nfloat coneCos;\nfloat penumbraCos;\n};\nuniform SpotLight spotLights[NUM_SPOT_LIGHTS];\nvoid getSpotLightInfo(const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight light) {\nvec3 lVector = spotLight.position - geometry.position;\nlight.direction = normalize(lVector);\nfloat angleCos = dot(light.direction, spotLight.direction);\n#if defined(MT_MAX) && defined(PHYSICALLY_CORRECT_LIGHTS)\nfloat coneCosDecayed = 2.0 * spotLight.coneCos - spotLight.penumbraCos;\nif (angleCos > coneCosDecayed) {\nfloat spotAttenuation = pow(max(angleCos, 0.0), log(0.5) / log(spotLight.penumbraCos) - 1.0);\nif (angleCos < spotLight.coneCos) {\nfloat decayFac = 1.0 + (spotLight.coneCos - angleCos)\n/ (spotLight.coneCos - spotLight.penumbraCos);\nspotAttenuation *= pow2(decayFac) * (3.0 - 2.0 * decayFac);\n}\nfloat lightDistance = length(lVector);\nlight.color = spotLight.color * spotAttenuation;\nlight.color *= getDistanceAttenuation(lightDistance, spotLight.distance, spotLight.decay);\nlight.visible = true;\n} else {\nlight.color = vec3(0.0);\nlight.visible = false;\n}\n#else\nfloat spotAttenuation = getSpotAttenuation(spotLight.coneCos, spotLight.penumbraCos, angleCos);\nif (spotAttenuation > 0.0) {\nfloat lightDistance = length(lVector);\nlight.color = spotLight.color * spotAttenuation;\nlight.color *= getDistanceAttenuation(lightDistance, spotLight.distance, spotLight.decay);\nlight.visible = true;\n} else {\nlight.color = vec3(0.0);\nlight.visible = false;\n}\n#endif\n}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\nstruct RectAreaLight {\nvec3 color;\nvec3 position;\nvec3 halfWidth;\nvec3 halfHeight;\n};\nuniform sampler2D ltc_1;\nuniform sampler2D ltc_2;\nuniform RectAreaLight rectAreaLights[NUM_RECT_AREA_LIGHTS];\n#endif\n#if NUM_HEMI_LIGHTS > 0\nstruct HemisphereLight {\nvec3 direction;\nvec3 skyColor;\nvec3 groundColor;\n};\nuniform HemisphereLight hemisphereLights[NUM_HEMI_LIGHTS];\nvec3 getHemisphereLightIrradiance(const in HemisphereLight hemiLight, const in vec3 normal) {\nfloat dotNL = dot(normal, hemiLight.direction);\nfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\nvec3 irradiance = mix(hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight);\nreturn irradiance;\n}\n#endif",lights_toon_fragment:"ToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;",lights_toon_pars_fragment:"varying vec3 vViewPosition;\nstruct ToonMaterial {\nvec3 diffuseColor;\n};\nvoid RE_Direct_Toon(const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\nvec3 irradiance = getGradientIrradiance(geometry.normal, directLight.direction) * directLight.color;\nreflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Toon(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in ToonMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon\n#define Material_LightProbeLOD(material) (0)",lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\nstruct BlinnPhongMaterial {\nvec3 diffuseColor;\nvec3 specularColor;\nfloat specularShininess;\nfloat specularStrength;\n};\nvoid RE_Direct_BlinnPhong(const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\nreflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\nreflectedLight.directSpecular += irradiance * BRDF_BlinnPhong(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularShininess) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong(const in vec3 irradiance, const in vec3 iblIrradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_BlinnPhong\n#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD(material) (0)",lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * (1.0 - metalnessFactor);\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.roughness = max(roughnessFactor, 0.0525);\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min(material.roughness, 1.0);\n#ifdef IOR\n#ifdef SPECULAR\nfloat specularIntensityFactor = specularIntensity;\nvec3 specularColorFactor = specularColor;\n#ifdef USE_SPECULARINTENSITYMAP\nspecularIntensityFactor *= texture2D(specularIntensityMap, vUv).a;\n#endif\n#ifdef USE_SPECULARCOLORMAP\nspecularColorFactor *= texture2D(specularColorMap, vUv).rgb;\n#endif\nmaterial.specularF90 = mix(specularIntensityFactor, 1.0, metalnessFactor);\n#else\nfloat specularIntensityFactor = 1.0;\nvec3 specularColorFactor = vec3(1.0);\nmaterial.specularF90 = 1.0;\n#endif\nmaterial.specularColor = mix(min(pow2((ior - 1.0) / (ior + 1.0)) * specularColorFactor, vec3(1.0)) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor);\n#else\nmaterial.specularColor = mix(vec3(0.04), diffuseColor.rgb, metalnessFactor);\nmaterial.specularF90 = 1.0;\n#endif\n#ifdef USE_CLEARCOAT\nmaterial.clearcoat = clearcoat;\nmaterial.clearcoatRoughness = clearcoatRoughness;\nmaterial.clearcoatF0 = vec3(0.04);\nmaterial.clearcoatF90 = 1.0;\n#ifdef USE_CLEARCOATMAP\nmaterial.clearcoat *= texture2D(clearcoatMap, vUv).x;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\nmaterial.clearcoatRoughness *= texture2D(clearcoatRoughnessMap, vUv).y;\n#endif\nmaterial.clearcoat = saturate(material.clearcoat);\nmaterial.clearcoatRoughness = max(material.clearcoatRoughness, 0.0525);\nmaterial.clearcoatRoughness += geometryRoughness;\nmaterial.clearcoatRoughness = min(material.clearcoatRoughness, 1.0);\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheenColor;\n#ifdef USE_SHEENCOLORMAP\nmaterial.sheenColor *= texture2D(sheenColorMap, vUv).rgb;\n#endif\nmaterial.sheenRoughness = clamp(sheenRoughness, 0.07, 1.0);\n#ifdef USE_SHEENROUGHNESSMAP\nmaterial.sheenRoughness *= texture2D(sheenRoughnessMap, vUv).a;\n#endif\n#endif",lights_physical_pars_fragment:"struct PhysicalMaterial {\nvec3 diffuseColor;\nfloat roughness;\nvec3 specularColor;\nfloat specularF90;\n#ifdef USE_CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\nvec3 clearcoatF0;\nfloat clearcoatF90;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\nfloat sheenRoughness;\n#endif\n};\nvec3 clearcoatSpecular = vec3(0.0);\nvec3 sheenSpecular = vec3(0.0);\nfloat IBLSheenBRDF(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat r2 = roughness * roughness;\nfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\nfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\nfloat DG = exp(a * dotNV + b) + (roughness < 0.25 ? 0.0 : 0.1 * (roughness - 0.25));\nreturn saturate(DG * RECIPROCAL_PI);\n}\nvec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nconst vec4 c0 = vec4(- 1, - 0.0275, - 0.572, 0.022);\nconst vec4 c1 = vec4(1, 0.0425, 1.04, - 0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(- 9.28 * dotNV)) * r.x + r.y;\nvec2 fab = vec2(- 1.04, 1.04) * a004 + r.zw;\nreturn fab;\n}\nvec3 EnvironmentBRDF(const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness) {\nvec2 fab = DFGApprox(normal, viewDir, roughness);\nreturn specularColor * fab.x + specularF90 * fab.y;\n}\nvoid 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) {\nvec2 fab = DFGApprox(normal, viewDir, roughness);\nvec3 FssEss = specularColor * fab.x + specularF90 * fab.y;\nfloat Ess = fab.x + fab.y;\nfloat Ems = 1.0 - Ess;\nvec3 Favg = specularColor + (1.0 - specularColor) * 0.047619;\nvec3 Fms = FssEss * Favg / (1.0 - Ems * Favg);\nsingleScatter += FssEss;\nmultiScatter += Fms * Ems;\n}\n#if NUM_RECT_AREA_LIGHTS > 0\nvoid RE_Direct_RectArea_Physical(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.roughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_Direct_Physical(const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifdef USE_CLEARCOAT\nfloat dotNLcc = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = dotNLcc * directLight.color;\nclearcoatSpecular += ccIrradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness);\n#endif\n#ifdef USE_SHEEN\nsheenSpecular += irradiance * BRDF_Sheen(directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness);\n#endif\nreflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);\nreflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, const in vec3 iblIrradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid 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) {\n#ifdef USE_CLEARCOAT\nclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF(geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness);\n#endif\n#ifdef USE_SHEEN\nsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF(geometry.normal, geometry.viewDir, material.sheenRoughness);\n#endif\nvec3 singleScattering = vec3(0.0);\nvec3 multiScattering = vec3(0.0);\nvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\ncomputeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);\nvec3 diffuse = material.diffuseColor * (1.0 - (singleScattering + multiScattering));\nreflectedLight.indirectSpecular += radiance * singleScattering;\nreflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\nreflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct RE_Direct_Physical\n#define RE_Direct_RectArea RE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular RE_IndirectSpecular_Physical\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.roughness)\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}",lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = -vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = (isOrthographic) ? vec3(0, 0, 1) : normalize(vViewPosition);\n#ifdef USE_CLEARCOAT\ngeometry.clearcoatNormal = clearcoatNormal;\n#endif\n#ifdef PROBE_NORMAL\ngeometry.probeNormal = PROBE_NORMAL;\n#else\ngeometry.probeNormal = normal;\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nPointLight pointLight;\n#if defined(USE_SHADOWMAP) && NUM_POINT_LIGHT_SHADOWS > 0\nPointLightShadow pointLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\npointLight = pointLights[i];\ngetPointLightInfo(pointLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_POINT_LIGHT_SHADOWS)\npointLightShadow = pointLightShadows[i];\ndirectLight.color *= all(bvec2(directLight.visible, receiveShadow)) ?\ngetPointShadow(pointLightShadow, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nSpotLight spotLight;\n#if defined(USE_SHADOWMAP) && NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLightShadow spotLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\nspotLight = spotLights[i];\ngetSpotLightInfo(spotLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_SPOT_LIGHT_SHADOWS)\nspotLightShadow = spotLightShadows[i];\nif (all(bvec2(directLight.visible, receiveShadow))) {\nif (spotLightShadow.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= getSpotShadow(spotLightShadow, spotShadowMap[i],\nvSpotShadowCoord[i], distWorld);\n} else if (spotLightShadow.shadow == 2) {\ndirectLight.color *= getSpotOmniShadow(spotLightShadow,\nspotShadowMap[i], vSpotShadowCoord[i]);\n}\n}\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_DIR_LIGHTS > 0) && (defined(RE_Direct) || defined(RE_DirectDiffuse) || defined(RE_DirectSpecular))\nDirectionalLight directionalLight;\n#if defined(USE_SHADOWMAP) && NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLightShadow directionalLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ndirectionalLight = directionalLights[i];\ngetDirectionalLightInfo(directionalLight, geometry, directLight);\n#if defined(USE_SHADOWMAP) && ((i) < NUM_DIR_LIGHT_SHADOWS)\ndirectionalLightShadow = directionalLightShadows[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLightShadow.position\n- directionalLight.direction * directionalLightShadow.shadowCameraNear\n- geometry.position, 0.0)).xyz);\n#endif\ndirectLight.color *= all(bvec3(directLight.visible, receiveShadow,\nvViewPosition.z < directionalLightShadow.maxDistance))\n? getDirShadow(directionalLightShadow, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\n#if defined(RE_Direct)\nRE_Direct(directLight, geometry, material, reflectedLight);\n#else\n#if defined(RE_DirectDiffuse)\nRE_DirectDiffuse(directLight, geometry, material, reflectedLight);\n#endif\n#if defined(RE_DirectSpecular)\nRE_DirectSpecular(directLight, geometry, material, reflectedLight);\n#endif\n#endif\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_RECT_AREA_LIGHTS > 0) && defined(RE_Direct_RectArea)\nRectAreaLight rectAreaLight;\n#if defined(USE_SHADOWMAP) && NUM_RECT_AREA_LIGHT_SHADOWS > 0\nRectAreaLightShadow rectAreaLightShadow;\n#endif\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHTS; i++) {\nrectAreaLight = rectAreaLights[i];\n#if defined(USE_SHADOWMAP) && ((i) < NUM_RECT_AREA_LIGHT_SHADOWS)\nrectAreaLightShadow = rectAreaLightShadows[i];\nrectAreaLight.color *= receiveShadow ?\ngetRectAreaShadow(rectAreaLightShadow, rectAreaShadowMap[i], vRectAreaShadowCoord[i]) : 1.0;\n#endif\nRE_Direct_RectArea(rectAreaLight, geometry, material, reflectedLight);\n}\n#pragma unroll_loop_end\n#endif\n#if defined(RE_IndirectDiffuse) || defined(RE_IndirectSpecular)\nvec3 iblIrradiance = vec3(0.0);\n#endif\n#if defined(RE_IndirectDiffuse)\nvec3 irradiance = getAmbientLightIrradiance(ambientLightColor);\nirradiance += getLightProbeIrradiance(lightProbe, geometry.probeNormal);\n#if (NUM_HEMI_LIGHTS > 0)\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_HEMI_LIGHTS; i++) {\nirradiance += getHemisphereLightIrradiance(hemisphereLights[i], geometry.probeNormal);\n}\n#pragma unroll_loop_end\n#endif\n#endif\n#if defined(RE_IndirectSpecular)\nvec3 radiance = vec3(0.0);\nvec3 clearcoatRadiance = vec3(0.0);\n#endif\n#if defined(RE_Refraction)\nvec3 refraction = vec3(0.0);\n#endif",lights_fragment_maps:"#if defined(RE_IndirectDiffuse)\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel = texture2D(lightMap, vUv2);\nvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\n#ifndef PHYSICALLY_CORRECT_LIGHTS\nlightMapIrradiance *= PI;\n#endif\nirradiance += lightMapIrradiance;\n#endif\n#if defined(USE_ENVMAP) && defined(STANDARD) && defined(ENVMAP_TYPE_CUBE_UV)\niblIrradiance += getIBLIrradiance(geometry, maxMipLevel);\n#endif\n#endif\n#if defined(USE_ENVMAP) && (defined(STANDARD) || defined(PHYSICAL)) && defined(RE_IndirectSpecular)\nradiance += getIBLRadiance(geometry, Material_BlinnShininessExponent(material), maxMipLevel, 0);\n#if defined(USE_SSR) && !defined(USE_SSR_REFRACT)\nradiance = computeSSR(radiance, geometry.normal, 0.0);\n#endif\n#if defined(USE_PLANE_REFLECTION)\nradiance = computePlaneReflection(radiance, material.roughness, geometry.position, geometry.normal, modelMatrix);\n#endif\n#ifdef USE_CLEARCOAT\nclearcoatRadiance += getIBLRadiance(geometry, Material_ClearCoat_BlinnShininessExponent(material), maxMipLevel, 1);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction)\nrefraction += getIBLRefraction(geometry,\nMaterial_Refraction_BlinnShininessExponent(material), maxMipLevel,\n1.0 / material.refractionIOR);\n#ifdef USE_SSR_REFRACT\nrefraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n#endif\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\nRE_IndirectDiffuse(irradiance, iblIrradiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_IndirectSpecular)\nRE_IndirectSpecular(radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight);\n#endif\n#if defined(RE_Refraction)\nRE_Refraction(refraction, material, refractedLight);\n#endif",logdepthbuf_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\ngl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif",logdepthbuf_pars_fragment:"#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\nuniform float logDepthBufFC;\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#endif",logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvarying float vFragDepth;\nvarying float vIsPerspective;\n#else\nuniform float logDepthBufFC;\n#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n#ifdef USE_LOGDEPTHBUF_EXT\nvFragDepth = 1.0 + gl_Position.w;\nvIsPerspective = float(isPerspectiveMatrix(projectionMatrix));\n#else\nif (isPerspectiveMatrix(projectionMatrix)) {\ngl_Position.z = log2(max(EPSILON, gl_Position.w + 1.0)) * logDepthBufFC - 1.0;\ngl_Position.z *= gl_Position.w;\n}\n#endif\n#endif",map_fragment:"#ifdef USE_MAP\nvec4 sampledDiffuseColor = texture2D(map, vUv);\n#ifdef DECODE_VIDEO_TEXTURE\nsampledDiffuseColor = 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);\n#endif\ndiffuseColor *= sampledDiffuseColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nvec2 uv = (uvTransform * vec3(gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1)).xy;\n#endif\n#ifdef USE_MAP\ndiffuseColor *= texture2D(map, uv);\n#endif\n#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, uv).g;\n#endif",map_particle_pars_fragment:"#if defined(USE_MAP) || defined(USE_ALPHAMAP)\nuniform mat3 uvTransform;\n#endif\n#ifdef USE_MAP\nuniform sampler2D map;\n#endif\n#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\nvec4 texelMetalness = texture2D(metalnessMap, vUv);\nmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\nuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nobjectNormal *= morphTargetBaseInfluence;\n#ifdef MORPHTARGETS_TEXTURE\nfor (int i = 0; i < MORPHTARGETS_COUNT; i++) {\nif (morphTargetInfluences[i] != 0.0) objectNormal += getMorph(gl_VertexID, i, 1).xyz * morphTargetInfluences[i];\n}\n#else\n#if MORPHTARGETS_COUNT > 0\nobjectNormal += morphNormal0 * morphTargetInfluences[0];\n#endif\n#if MORPHTARGETS_COUNT > 1\nobjectNormal += morphNormal1 * morphTargetInfluences[1];\n#endif\n#if MORPHTARGETS_COUNT > 2\nobjectNormal += morphNormal2 * morphTargetInfluences[2];\n#endif\n#if MORPHTARGETS_COUNT > 3\nobjectNormal += morphNormal3 * morphTargetInfluences[3];\n#endif\n#if MORPHTARGETS_COUNT > 4\nobjectNormal += morphNormal4 * morphTargetInfluences[4];\n#endif\n#if MORPHTARGETS_COUNT > 5\nobjectNormal += morphNormal5 * morphTargetInfluences[5];\n#endif\n#endif\n#endif",morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetBaseInfluence;\n#ifdef MORPHTARGETS_TEXTURE\nuniform float morphTargetInfluences[MORPHTARGETS_COUNT];\nuniform sampler2DArray morphTargetsTexture;\nuniform ivec2 morphTargetsTextureSize;\nvec4 getMorph(const in int vertexIndex, const in int morphTargetIndex, const in int offset) {\nint texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;\nint y = texelIndex / morphTargetsTextureSize.x;\nint x = texelIndex - y * morphTargetsTextureSize.x;\nivec3 morphUV = ivec3(x, y, morphTargetIndex);\nreturn texelFetch(morphTargetsTexture, morphUV, 0);\n}\n#else\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[12];\n#else\nuniform float morphTargetInfluences[6];\n#endif\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\ntransformed *= morphTargetBaseInfluence;\n#ifdef MORPHTARGETS_TEXTURE\nfor (int i = 0; i < MORPHTARGETS_COUNT; i++) {\nif (morphTargetInfluences[i] != 0.0) transformed += getMorph(gl_VertexID, i, 0).xyz * morphTargetInfluences[i];\n}\n#else\n#if MORPHTARGETS_COUNT > 0\ntransformed += morphTarget0 * morphTargetInfluences[0];\n#endif\n#if MORPHTARGETS_COUNT > 1\ntransformed += morphTarget1 * morphTargetInfluences[1];\n#endif\n#if MORPHTARGETS_COUNT > 2\ntransformed += morphTarget2 * morphTargetInfluences[2];\n#endif\n#if MORPHTARGETS_COUNT > 3\ntransformed += morphTarget3 * morphTargetInfluences[3];\n#endif\n#if MORPHTARGETS_COUNT > 4\ntransformed += morphTarget4 * morphTargetInfluences[4];\n#endif\n#if MORPHTARGETS_COUNT > 5\ntransformed += morphTarget5 * morphTargetInfluences[5];\n#endif\n#ifndef USE_MORPHNORMALS\n#if MORPHTARGETS_COUNT > 6\ntransformed += morphTarget6 * morphTargetInfluences[6];\n#endif\n#if MORPHTARGETS_COUNT > 7\ntransformed += morphTarget7 * morphTargetInfluences[7];\n#endif\n#if MORPHTARGETS_COUNT > 8\ntransformed += morphTarget8 * morphTargetInfluences[8];\n#endif\n#if MORPHTARGETS_COUNT > 9\ntransformed += morphTarget9 * morphTargetInfluences[9];\n#endif\n#if MORPHTARGETS_COUNT > 10\ntransformed += morphTarget10 * morphTargetInfluences[10];\n#endif\n#if MORPHTARGETS_COUNT > 11\ntransformed += morphTarget1 * morphTargetInfluences[11];\n#endif\n#endif\n#endif\n#endif",normal_fragment_begin:"float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;\n#ifdef FLAT_SHADED\nvec3 fdx = vec3(dFdx(vViewPosition.x), dFdx(vViewPosition.y), dFdx(vViewPosition.z));\nvec3 fdy = vec3(dFdy(vViewPosition.x), dFdy(vViewPosition.y), dFdy(vViewPosition.z));\nvec3 normal = normalize(cross(fdx, fdy));\n#else\nvec3 normal = normalize(vNormal);\n#ifdef DOUBLE_SIDED\n#ifdef FRONT_FACING_VALUE\nbool frontFacing = FRONT_FACING_VALUE;\n#else\nbool frontFacing = gl_FrontFacing;\n#endif\nnormal = normal * (float(frontFacing) * 2.0 - 1.0);\n#endif\n#ifdef USE_TANGENT\nvec3 tangent = normalize(vTangent);\nvec3 bitangent = normalize(vBitangent);\n#ifdef DOUBLE_SIDED\ntangent = tangent * faceDirection;\nbitangent = bitangent * faceDirection;\n#endif\n#if defined(TANGENTSPACE_NORMALMAP) || defined(USE_CLEARCOAT_NORMALMAP)\nmat3 vTBN = mat3(tangent, bitangent, normal);\n#endif\n#endif\n#endif\nvec3 geometryNormal = normal;",normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\nnormal = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\n#ifdef FLIP_SIDED\nnormal = -normal;\n#endif\n#ifdef DOUBLE_SIDED\nnormal = normal * faceDirection;\n#endif\nnormal = normalize(normalMatrix * normal);\n#elif defined(TANGENTSPACE_NORMALMAP)\nvec3 mapN = texture2D(normalMap, vUv).xyz * 2.0 - 1.0;\nmapN.xy *= normalScale;\n#ifdef USE_TANGENT\nnormal = normalize(vTBN * mapN);\n#else\nnormal = perturbNormal2Arb(-vViewPosition, normal, mapN, faceDirection);\n#endif\n#elif defined(USE_BUMPMAP)\nnormal = perturbNormalArb(-vViewPosition, normal, dHdxy_fwd(), faceDirection);\n#endif",normal_pars_fragment:"#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif",normal_pars_vertex:"#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#ifdef USE_TANGENT\nvarying vec3 vTangent;\nvarying vec3 vBitangent;\n#endif\n#endif",normal_vertex:"#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#ifdef USE_TANGENT\nvTangent = normalize(transformedTangent);\nvBitangent = normalize(cross(vNormal, vTangent) * tangent.w);\n#endif\n#endif",normalmap_pars_fragment:"#ifdef USE_NORMALMAP\nuniform sampler2D normalMap;\nuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat3 normalMatrix;\n#endif\n#if !defined (USE_TANGENT) && (defined (TANGENTSPACE_NORMALMAP) || defined (USE_CLEARCOAT_NORMALMAP))\nvec3 perturbNormal2Arb(vec3 eye_pos, vec3 surf_norm, vec3 mapN, float faceDirection) {\nvec3 q0 = vec3(dFdx(eye_pos.x), dFdx(eye_pos.y), dFdx(eye_pos.z));\nvec3 q1 = vec3(dFdy(eye_pos.x), dFdy(eye_pos.y), dFdy(eye_pos.z));\nvec2 st0 = dFdx(vUv.st);\nvec2 st1 = dFdy(vUv.st);\nvec3 N = surf_norm;\nvec3 q1perp = cross(q1, N);\nvec3 q0perp = cross(N, q0);\nvec3 T = q1perp * st0.x + q0perp * st1.x;\nvec3 B = q1perp * st0.y + q0perp * st1.y;\nfloat det = max(dot(T, T), dot(B, B));\nfloat scale = (det == 0.0) ? 0.0 : faceDirection * inversesqrt(det);\nreturn normalize(T * (mapN.x * scale) + B * (mapN.y * scale) + N * mapN.z);\n}\n#endif",clearcoat_normal_fragment_begin:"#ifdef USE_CLEARCOAT\nvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\nvec3 clearcoatMapN = texture2D(clearcoatNormalMap, vUv).xyz * 2.0 - 1.0;\nclearcoatMapN.xy *= clearcoatNormalScale;\n#ifdef USE_TANGENT\nclearcoatNormal = normalize(vTBN * clearcoatMapN);\n#else\nclearcoatNormal = perturbNormal2Arb(-vViewPosition, clearcoatNormal, clearcoatMapN, faceDirection);\n#endif\n#endif",clearcoat_pars_fragment:"#ifdef USE_CLEARCOATMAP\nuniform sampler2D clearcoatMap;\n#endif\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\nuniform sampler2D clearcoatRoughnessMap;\n#endif\n#ifdef USE_CLEARCOAT_NORMALMAP\nuniform sampler2D clearcoatNormalMap;\nuniform vec2 clearcoatNormalScale;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= transmissionAlpha + 0.1;\n#endif\ngl_FragColor = vec4(outgoingLight, diffuseColor.a);",packing:"vec3 packNormalToRGB(const in vec3 normal) {\nreturn normalize(normal) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal(const in vec3 rgb) {\nreturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;\nconst float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\nconst vec4 UnpackFactors = UnpackDownscale / vec4(PackFactors, 1.);\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA(const in float v) {\nvec4 r = vec4(fract(v * PackFactors), v);\nr.yzw -= r.xyz * ShiftRight8;\nreturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth(const in vec4 v) {\nreturn dot(v, UnpackFactors);\n}\nvec4 pack2HalfToRGBA(vec2 v) {\nvec4 r = vec4(v.x, fract(v.x * 255.0), v.y, fract(v.y * 255.0));\nreturn vec4(r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half(vec4 v) {\nreturn vec2(v.x + (v.y / 255.0), v.z + (v.w / 255.0));\n}\nfloat viewZToOrthographicDepth(const in float viewZ, const in float near, const in float far) {\nreturn (viewZ + near) / (near - far);\n}\nfloat orthographicDepthToViewZ(const in float linearClipZ, const in float near, const in float far) {\nreturn linearClipZ * (near - far) - near;\n}\nfloat viewZToPerspectiveDepth(const in float viewZ, const in float near, const in float far) {\nreturn ((near + viewZ) * far) / ((far - near) * viewZ);\n}\nfloat perspectiveDepthToViewZ(const in float invClipZ, const in float near, const in float far) {\nreturn (near * far) / ((far - near) * invClipZ - far);\n}",premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\ngl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;\n#if defined(BACKGROUND_DEPTH)\ngl_Position.z = gl_Position.w;\n#endif",dithering_fragment:"#ifdef DITHERING\ngl_FragColor.rgb = dithering(gl_FragColor.rgb);\n#endif",dithering_pars_fragment:"#ifdef DITHERING\nvec3 dithering(vec3 color) {\nfloat grid_position = rand(gl_FragCoord.xy);\nvec3 dither_shift_RGB = vec3(0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0);\ndither_shift_RGB = mix(2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position);\nreturn color + dither_shift_RGB;\n}\n#endif",roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\nvec4 texelRoughness = texture2D(roughnessMap, vUv);\nroughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\nuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"\n#define BIAS_FRUSTUM_SCALE_COEFF 30.0\n#define ESM_SPOT_SINGLE_BLUR_COEFF 0.25\n#define PCF_POISSON_SPOT_OMNI_BLUR_COEFF 4.0\n#define PCF_POISSON_POINT_BLUR_COEFF 2.5\n#define PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF 0.5\n#define ESM_BIAS_COEFF 100.0\n#ifndef ESM_DISTANCE_SCALE\n#define ESM_DISTANCE_SCALE 1.0\n#endif\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform sampler2D directionalShadowMap[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\nstruct DirectionalLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat shadowCameraNear;\nfloat maxDistance;\nfloat expBias;\n};\nuniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform sampler2D spotShadowMap[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\nstruct SpotLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nint shadow;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform sampler2D pointShadowMap[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\nstruct PointLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nuniform sampler2D rectAreaShadowMap[NUM_RECT_AREA_LIGHT_SHADOWS];\nvarying vec4 vRectAreaShadowCoord[NUM_RECT_AREA_LIGHT_SHADOWS];\nstruct RectAreaLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform RectAreaLightShadow rectAreaLightShadows[NUM_RECT_AREA_LIGHT_SHADOWS];\n#endif\nconst vec3 PERMUTE_DIR_X = vec3(1.0, 0.0, 0.0);\nconst vec3 PERMUTE_DIR_Y = vec3(0.0, 1.0, 0.0);\nconst vec3 PERMUTE_DIR_Z = vec3(0.0, 0.0, 1.0);\nconst mat4 POISSON_DISK_0 = mat4(\n0.954845, 0.242214, -0.623893, -0.235473,\n-0.173288, 0.799228, 0.605969, -0.548050,\n-0.560406, 0.327647, -0.448307, -0.774344,\n0.308258, 0.417332, -0.125623, -0.056098\n);\nconst mat4 POISSON_DISK_1 = mat4(\n0.145585, -0.305634, 0.264060, -0.661648,\n0.617942, 0.652121, -0.041412, -0.893582,\n0.463911, 0.039752, 0.212664, 0.810727,\n-0.955989, -0.014390, -0.652588, 0.671204\n);\nfloat texture2DCompare(sampler2D depths, vec2 uv, float compare) {\nreturn step(compare, unpackRGBAToDepth(texture2D(depths, uv)));\n}\nvec2 texture2DDistribution(sampler2D shadow, vec2 uv) {\nreturn unpackRGBATo2Half(texture2D(shadow, uv));\n}\nfloat VSMShadow (sampler2D shadow, vec2 uv, float compare){\nfloat occlusion = 1.0;\nvec2 distribution = texture2DDistribution(shadow, uv);\nfloat hard_shadow = step(compare , distribution.x);\nif (hard_shadow != 1.0) {\nfloat distance = compare - distribution.x ;\nfloat variance = max(0.00000, distribution.y * distribution.y);\nfloat softness_probability = variance / (variance + distance * distance);\nsoftness_probability = clamp((softness_probability - 0.3) / (0.95 - 0.3), 0.0, 1.0);\nocclusion = clamp(max(hard_shadow, softness_probability), 0.0, 1.0);\n}\nreturn occlusion;\n}\nfloat texture2DShadowLerp(sampler2D depths, vec2 size, vec2 uv, float compare) {\nconst vec2 offset = vec2(0.0, 1.0);\nvec2 texelSize = vec2(1.0) / size;\nvec2 centroidUV = floor(uv * size + 0.5) / size;\nfloat lb = texture2DCompare(depths, centroidUV + texelSize * offset.xx, compare);\nfloat lt = texture2DCompare(depths, centroidUV + texelSize * offset.xy, compare);\nfloat rb = texture2DCompare(depths, centroidUV + texelSize * offset.yx, compare);\nfloat rt = texture2DCompare(depths, centroidUV + texelSize * offset.yy, compare);\nvec2 f = fract(uv * size + 0.5);\nfloat a = mix(lb, lt, f.y);\nfloat b = mix(rb, rt, f.y);\nfloat c = mix(a, b, f.x);\nreturn c;\n}\nvec2 cubeToUV(vec3 v, float texelSizeY) {\nvec3 absV = abs(v);\nfloat scaleToCube = 1.0 / max(absV.x, max(absV.y, absV.z));\nabsV *= scaleToCube;\nv *= scaleToCube * (1.0 - 2.0 * texelSizeY);\nvec2 planar = v.xy;\nfloat almostATexel = 1.5 * texelSizeY;\nfloat almostOne = 1.0 - almostATexel;\nif (absV.z >= almostOne) {\nif (v.z > 0.0)\nplanar.x = 4.0 - v.x;\n} else if (absV.x >= almostOne) {\nfloat signX = sign(v.x);\nplanar.x = v.z * signX + 2.0 * signX;\n} else if (absV.y >= almostOne) {\nfloat signY = sign(v.y);\nplanar.x = v.x + 2.0 * signY + 2.0;\nplanar.y = v.z * signY - 2.0;\n}\nreturn vec2(0.125, 0.25) * planar + vec2(0.375, 0.75);\n}\nfloat texture2DShadowAvgCube(sampler2D depths, vec2 size, vec3 bd3D, float compare) {\nvec2 texelSize = vec2(1.0) / size;\nvec3 dirX = normalize(abs(bd3D.y) < 0.99999 ? vec3(bd3D.z, 0.0, -bd3D.x)\n: vec3(0.0, -bd3D.z, bd3D.y));\nvec3 dirY = cross(bd3D, dirX);\nfloat theta = PI_HALF * texelSize.y;\nvec3 sX = sin(theta) * dirX;\nvec3 sY = sin(theta) * dirY;\nfloat cosT = cos(theta);\nvec3 sampleVec[4];\nsampleVec[0] = bd3D;\nsampleVec[1] = bd3D * cosT + sY;\nsampleVec[2] = bd3D * cosT + sX;\nsampleVec[3] = sampleVec[2] * cosT + sY;\nfloat avg = 0.0;\nfor (int i = 0; i < 4; i++) {\navg += texture2DCompare(depths, cubeToUV(sampleVec[i], texelSize.y), compare);\n}\navg /= 4.0;\nreturn avg;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord,\nfloat expBias, float distWorld) {\nfloat shadow = 1.0;\nshadowCoord.xyz /= shadowCoord.w;\nbvec4 inFrustumVec = bvec4 (shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0);\nbool inFrustum = all(inFrustumVec);\nbvec3 frustumTestVec = bvec3(inFrustum, shadowCoord.z <= 1.0, shadowCoord.z >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadowCoord.z += shadowBias;\nshadow = texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy, shadowCoord.z);\n#elif defined(SHADOWMAP_TYPE_PCF)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat dx0 = - texelSize.x * shadowRadius;\nfloat dy0 = - texelSize.y * shadowRadius;\nfloat dx1 = + texelSize.x * shadowRadius;\nfloat dy1 = + texelSize.y * shadowRadius;\nvec2 offsetVec[9];\noffsetVec[0] = vec2(dx0, dy0);\noffsetVec[1] = vec2(0.0, dy0);\noffsetVec[2] = vec2(dx1, dy0);\noffsetVec[3] = vec2(dx0, 0.0);\noffsetVec[4] = vec2(0.0);\noffsetVec[5] = vec2(dx1, 0.0);\noffsetVec[6] = vec2(dx0, dy1);\noffsetVec[7] = vec2(0.0, dy1);\noffsetVec[8] = vec2(dx1, dy1);\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DShadowLerp(shadowMap, shadowMapSize,\nshadowCoord.xy + offsetVec[i], shadowCoord.z);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowCoord.z += shadowBias;\nvec2 texelSize = vec2(1.0) / shadowMapSize;\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.x, 0.0, 0.0, shadowRadius * texelSize.y);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, shadowCoord.xy\n+ sampleMat * sampleVec[i], shadowCoord.z);\n}\nshadow /= 16.0;\n#elif defined(SHADOWMAP_TYPE_VSM)\nshadow = VSMShadow(shadowMap, shadowCoord.xy, shadowCoord.z);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap, shadowCoord.xy).x\n- length(distWorld) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#else\nshadowCoord.z += shadowBias;\nshadow = texture2DCompare(shadowMap, shadowCoord.xy, shadowCoord.z);\n#endif\n}\nreturn shadow;\n}\nfloat getShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord) {\nreturn getShadow(shadowMap, shadowMapSize, shadowBias, shadowRadius, shadowCoord, 0.0, 0.0);\n}\nfloat getOmniShadow(sampler2D shadowMap, vec2 shadowMapSize, float shadowBias,\nfloat expBias, float shadowRadius, vec4 shadowCoord,\nfloat shadowCameraNear, float shadowCameraFar) {\nfloat shadow = 1.0;\nvec3 lightToPosition = shadowCoord.xyz;\nfloat dp = (length(lightToPosition) - shadowCameraNear)\n/ (shadowCameraFar - shadowCameraNear);\nbvec2 frustumTestVec = bvec2(dp <= 1.0, dp >= 0.0);\nbool frustumTest = all(frustumTestVec);\nif (frustumTest) {\nfloat biasScaleCoeff = BIAS_FRUSTUM_SCALE_COEFF\n/ (shadowCameraFar - shadowCameraNear);\ndp += shadowBias * biasScaleCoeff;\nvec3 bd3D = normalize(lightToPosition);\nvec2 texelSize = 1.0 / shadowMapSize;\n#if defined(SHADOWMAP_TYPE_BILINEAR)\nshadow = texture2DShadowAvgCube(shadowMap, shadowMapSize, bd3D, dp);\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadow = saturate(exp(expBias * (texture2D(shadowMap,\ncubeVecToOctUV(bd3D, texelSize)).x\n- length(lightToPosition) * ESM_DISTANCE_SCALE\n- ESM_BIAS_COEFF * shadowBias)));\n#elif defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nvec2 offset = vec2(-1, 1) * shadowRadius * texelSize.y;\nvec3 offsetVec[9];\noffsetVec[0] = offset.xyy;\noffsetVec[1] = offset.yyy;\noffsetVec[2] = offset.xyx;\noffsetVec[3] = offset.yyx;\noffsetVec[4] = vec3(0.0);\noffsetVec[5] = offset.xxy;\noffsetVec[6] = offset.yxy;\noffsetVec[7] = offset.xxx;\noffsetVec[8] = offset.yxx;\nshadow = 0.0;\nfor (int i = 0; i < 9; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + offsetVec[i], texelSize.y), dp);\n}\nshadow /= 9.0;\n#elif defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nfloat randAngle = rand(gl_FragCoord.xy) * PI2;\nfloat c = cos(randAngle), s = sin(randAngle);\nmat2 sampleMat = mat2(c, s, -s, c)\n* mat2(shadowRadius * texelSize.y, 0.0, 0.0, shadowRadius * texelSize.y);\nvec3 absBd3D = abs(bd3D);\nabsBd3D /= max(absBd3D.x, max(absBd3D.y, absBd3D.z));\nbvec2 isPointingCubeFace = greaterThan(absBd3D.xy, vec2(0.999));\nmat3 permuteMat = mat3(\nisPointingCubeFace.x ? PERMUTE_DIR_Y : PERMUTE_DIR_X,\nisPointingCubeFace.x || isPointingCubeFace.y ? PERMUTE_DIR_Z : PERMUTE_DIR_Y,\nisPointingCubeFace.x ? PERMUTE_DIR_X : isPointingCubeFace.y ? PERMUTE_DIR_Y : PERMUTE_DIR_Z\n);\nvec2 sampleVec[16];\nsampleVec[0] = POISSON_DISK_0[0].xy;\nsampleVec[1] = POISSON_DISK_0[0].zw;\nsampleVec[2] = POISSON_DISK_0[1].xy;\nsampleVec[3] = POISSON_DISK_0[1].zw;\nsampleVec[4] = POISSON_DISK_0[2].xy;\nsampleVec[5] = POISSON_DISK_0[2].zw;\nsampleVec[6] = POISSON_DISK_0[3].xy;\nsampleVec[7] = POISSON_DISK_0[3].zw;\nsampleVec[8] = POISSON_DISK_1[0].xy;\nsampleVec[9] = POISSON_DISK_1[0].zw;\nsampleVec[10] = POISSON_DISK_1[1].xy;\nsampleVec[11] = POISSON_DISK_1[1].zw;\nsampleVec[12] = POISSON_DISK_1[2].xy;\nsampleVec[13] = POISSON_DISK_1[2].zw;\nsampleVec[14] = POISSON_DISK_1[3].xy;\nsampleVec[15] = POISSON_DISK_1[3].zw;\nshadow = 0.0;\nfor (int i = 0; i < 16; i++) {\nshadow += texture2DCompare(shadowMap, cubeToUV(bd3D + permuteMat * vec3(sampleMat * sampleVec[i], 0.0), texelSize.y), dp);\n}\nshadow /= 16.0;\n#else\nshadow = texture2DCompare(shadowMap, cubeToUV(bd3D, texelSize.y), dp);\n#endif\n}\nreturn shadow;\n}\n#if NUM_DIR_LIGHT_SHADOWS > 0\nfloat getDirShadow(DirectionalLightShadow light, sampler2D shadowMap,\nvec4 shadowCoord, float distWorld) {\nfloat shadowRadius = light.shadowRadius;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, light.shadowBias, shadowRadius, shadowCoord, \nlight.expBias, distWorld);\n}\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nfloat getPointShadow(PointLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nfloat getRectAreaShadow(RectAreaLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\nmapSize *= 2.0;\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_POINT_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nfloat getSpotOmniShadow(SpotLightShadow light, sampler2D shadowMap, vec4 shadowCoord) {\nfloat shadowRadius = light.shadowRadius;\nvec2 mapSize = light.shadowMapSize;\n#if defined(SHADOWMAP_TYPE_ESM)\n#else\nmapSize *= vec2(4.0, 2.0);\n#if defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowRadius *= PCF_POISSON_SPOT_OMNI_BLUR_COEFF;\n#endif\n#endif\nreturn getOmniShadow(shadowMap, mapSize, light.shadowBias, light.expBias,\nshadowRadius, shadowCoord, light.shadowCameraNear,\nlight.shadowCameraFar);\n}\nfloat biasLinearNormalizedToNonlinear(float bias, float near, float far,\nfloat projZ, float projW) {\nreturn (bias * (far + near) + 2.0 * projZ) / (bias * (far - near) + 2.0 * projW)\n- projZ / projW;\n}\nfloat getSpotShadow(SpotLightShadow light, sampler2D shadowMap, vec4 shadowCoord,\nfloat distWorld) {\nfloat shadowRadius = light.shadowRadius;\nfloat shadowBias = light.shadowBias;\n#if defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT)\nshadowRadius *= PCF_PCF_SOFT_DIR_SPOT_BLUR_COEFF;\n#elif defined(SHADOWMAP_TYPE_ESM)\nshadowRadius *= ESM_SPOT_SINGLE_BLUR_COEFF;\n#endif\nshadowBias *= BIAS_FRUSTUM_SCALE_COEFF\n/ (light.shadowCameraFar - light.shadowCameraNear);\n#if defined(SHADOWMAP_TYPE_BASIC) || defined(SHADOWMAP_TYPE_BILINEAR) || defined(SHADOWMAP_TYPE_PCF) || defined(SHADOWMAP_TYPE_PCF_SOFT) || defined(SHADOWMAP_TYPE_PCF_POISSON_DISK)\nshadowBias = biasLinearNormalizedToNonlinear(shadowBias,\nlight.shadowCameraNear, light.shadowCameraFar, shadowCoord.z,\nshadowCoord.w);\n#endif\nreturn getShadow(shadowMap, light.shadowMapSize, shadowBias, shadowRadius, shadowCoord,\nlight.expBias, distWorld);\n}\n#endif\n#endif",shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nuniform mat4 directionalShadowMatrix[NUM_DIR_LIGHT_SHADOWS];\nvarying vec4 vDirectionalShadowCoord[NUM_DIR_LIGHT_SHADOWS];\nstruct DirectionalLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nvec3 position;\nfloat shadowCameraNear;\nfloat maxDistance;\nfloat expBias;\n};\nuniform DirectionalLightShadow directionalLightShadows[NUM_DIR_LIGHT_SHADOWS];\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nuniform mat4 spotShadowMatrix[NUM_SPOT_LIGHT_SHADOWS];\nvarying vec4 vSpotShadowCoord[NUM_SPOT_LIGHT_SHADOWS];\nstruct SpotLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nint shadow;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform SpotLightShadow spotLightShadows[NUM_SPOT_LIGHT_SHADOWS];\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nuniform mat4 pointShadowMatrix[NUM_POINT_LIGHT_SHADOWS];\nvarying vec4 vPointShadowCoord[NUM_POINT_LIGHT_SHADOWS];\nstruct PointLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform PointLightShadow pointLightShadows[NUM_POINT_LIGHT_SHADOWS];\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nuniform mat4 rectAreaShadowMatrix[NUM_RECT_AREA_LIGHT_SHADOWS];\nvarying vec4 vRectAreaShadowCoord[NUM_RECT_AREA_LIGHT_SHADOWS];\nstruct RectAreaLightShadow {\nfloat shadowBias;\nfloat shadowNormalBias;\nfloat shadowRadius;\nvec2 shadowMapSize;\nfloat shadowCameraNear;\nfloat shadowCameraFar;\nfloat expBias;\n};\nuniform RectAreaLightShadow rectAreaLightShadows[NUM_RECT_AREA_LIGHT_SHADOWS];\n#endif\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 || NUM_RECT_AREA_LIGHT_SHADOWS > 0\nvec3 shadowWorldNormal = inverseTransformDirection(transformedNormal, viewMatrix);\nvec4 shadowWorldPosition;\n#endif\n#if NUM_DIR_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * directionalLightShadows[i].shadowNormalBias, 0);\nvDirectionalShadowCoord[i] = directionalShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * spotLightShadows[i].shadowNormalBias, 0);\nvSpotShadowCoord[i] = spotShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * pointLightShadows[i].shadowNormalBias, 0);\nvPointShadowCoord[i] = pointShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHT_SHADOWS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * rectAreaLightShadows[i].shadowNormalBias, 0);\nvRectAreaShadowCoord[i] = rectAreaShadowMatrix[i] * shadowWorldPosition;\n}\n#pragma unroll_loop_end\n#endif\n#endif",shadowmask_pars_fragment:"float getShadowMask() {\nfloat shadow = 1.0;\n#ifdef USE_SHADOWMAP\n#if NUM_DIR_LIGHT_SHADOWS > 0\nDirectionalLightShadow directionalLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i++) {\ndirectionalLight = directionalLightShadows[i];\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(directionalLight.position\n- directionalLight.direction * directionalLight.shadowCameraNear\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= all(bvec2(vViewPosition.z < directionalLight.maxDistance,\nreceiveShadow)) ? getDirShadow(directionalLight,\ndirectionalShadowMap[i], vDirectionalShadowCoord[i], distWorld)\n: 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_SPOT_LIGHT_SHADOWS > 0\nSpotLightShadow spotLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i++) {\nspotLight = spotLightShadows[i];\nif (receiveShadow) {\nif (spotLight.shadow == 1) {\nfloat distWorld = 0.0;\n#if defined(SHADOWMAP_TYPE_ESM)\ndistWorld = length((invViewMatrix * vec4(spotLight.position\n+ vViewPosition, 0.0)).xyz);\n#endif\nshadow *= getSpotShadow(spotLight, spotShadowMap[i], vSpotShadowCoord[i],\ndistWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\nvSpotShadowCoord[i]);\n}\n}\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_POINT_LIGHT_SHADOWS > 0\nPointLightShadow pointLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i++) {\npointLight = pointLightShadows[i];\nshadow *= receiveShadow ? getPointShadow(pointLight, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#if NUM_RECT_AREA_LIGHT_SHADOWS > 0\nRectAreaLightShadow rectAreaLight;\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_RECT_AREA_LIGHT_SHADOWS; i++) {\nrectAreaLight = rectAreaLightShadows[i];\nshadow *= receiveShadow ? getRectAreaShadow(rectAreaLight, rectAreaShadowMap[i], vRectAreaShadowCoord[i]) : 1.0;\n}\n#pragma unroll_loop_end\n#endif\n#endif\nreturn shadow;\n}",skinbase_vertex:"#ifdef USE_SKINNING\nmat4 boneMatX = getBoneMatrix(skinIndex.x);\nmat4 boneMatY = getBoneMatrix(skinIndex.y);\nmat4 boneMatZ = getBoneMatrix(skinIndex.z);\nmat4 boneMatW = getBoneMatrix(skinIndex.w);\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 bindMatrix;\nuniform mat4 bindMatrixInverse;\n#ifdef BONE_TEXTURE\nuniform highp sampler2D boneTexture;\nuniform int boneTextureSize;\nmat4 getBoneMatrix(const in float i) {\nfloat j = i * 4.0;\nfloat x = mod(j, float(boneTextureSize));\nfloat y = floor(j / float(boneTextureSize));\nfloat dx = 1.0 / float(boneTextureSize);\nfloat dy = 1.0 / float(boneTextureSize);\ny = dy * (y + 0.5);\nvec4 v1 = texture2D(boneTexture, vec2(dx * (x + 0.5), y));\nvec4 v2 = texture2D(boneTexture, vec2(dx * (x + 1.5), y));\nvec4 v3 = texture2D(boneTexture, vec2(dx * (x + 2.5), y));\nvec4 v4 = texture2D(boneTexture, vec2(dx * (x + 3.5), y));\nmat4 bone = mat4(v1, v2, v3, v4);\nreturn bone;\n}\n#else\nuniform mat4 boneMatrices[MAX_BONES];\nmat4 getBoneMatrix(const in float i) {\nmat4 bone = boneMatrices[int(i)];\nreturn bone;\n}\n#endif\n#endif",skinning_vertex:"#ifdef USE_SKINNING\nvec4 skinVertex = bindMatrix * vec4(transformed, 1.0);\nvec4 skinned = vec4(0.0);\nskinned += boneMatX * skinVertex * skinWeight.x;\nskinned += boneMatY * skinVertex * skinWeight.y;\nskinned += boneMatZ * skinVertex * skinWeight.z;\nskinned += boneMatW * skinVertex * skinWeight.w;\ntransformed = (bindMatrixInverse * skinned).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\nmat4 skinMatrix = mat4(0.0);\nskinMatrix += skinWeight.x * boneMatX;\nskinMatrix += skinWeight.y * boneMatY;\nskinMatrix += skinWeight.z * boneMatZ;\nskinMatrix += skinWeight.w * boneMatW;\nskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\nobjectNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;\n#ifdef USE_TANGENT\nobjectTangent = vec4(skinMatrix * vec4(objectTangent, 0.0)).xyz;\n#endif\n#endif",specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\nvec4 texelSpecular = texture2D(specularMap, vUv);\nspecularStrength = texelSpecular.r;\n#else\nspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\nuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined(TONE_MAPPING)\ngl_FragColor.rgb = toneMapping(gl_FragColor.rgb);\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp(a, 0.0, 1.0)\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingMidTones;\nuniform float toneMappingPhysicalScale;\nuniform float toneMappingBrightness;\nuniform float toneMappingContrast;\nuniform bool toneMappingChromaticAdaptation;\nuniform vec3 toneMappingWhiteColor;\nuniform bool toneMappingColorDifferentiation;\nuniform bool toneMappingExteriorDaylight;\nuniform vec3 toneMappingWhiteBalance;\nuniform float toneMappingHighlights;\nuniform float toneMappingShadows;\nuniform float toneMappingSaturation;\nuniform float toneMappingAperture;\nuniform float toneMappingShutter;\nuniform float toneMappingISO;\nuniform float toneMappingVignetting;\nuniform vec2 toneMappingResolution;\nconst float FILMIC_BLENDER_LOG_MIN = -12.473931188;\nconst float FILMIC_BLENDER_LOG_MAX = 12.526068812;\nconst float FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO = 0.66;\nvec3 LinearToneMapping(vec3 color) {\nreturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\nreturn saturate(color / (vec3(1.0) + color));\n}\nvec3 OptimizedCineonToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(vec3(0.0), color - 0.004);\nreturn pow((color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7) + 0.06), vec3(2.2));\n}\nvec3 RRTAndODTFit(vec3 v) {\nvec3 a = v * (v + 0.0245786) - 0.000090537;\nvec3 b = v * (0.983729 * v + 0.4329510) + 0.238081;\nreturn a / b;\n}\nvec3 ACESFilmicToneMapping(vec3 color) {\nconst mat3 ACESInputMat = mat3(\nvec3(0.59719, 0.07600, 0.02840),\nvec3(0.35458, 0.90834, 0.13383),\nvec3(0.04823, 0.01566, 0.83777)\n);\nconst mat3 ACESOutputMat = mat3(\nvec3( 1.60475, -0.10208, -0.00327),\nvec3(-0.53108, 1.10813, -0.07276),\nvec3(-0.07367, -0.00605, 1.07602)\n);\ncolor *= toneMappingExposure / 0.6;\ncolor = ACESInputMat * color;\ncolor = RRTAndODTFit(color);\ncolor = ACESOutputMat * color;\nreturn saturate(color);\n}\nvec3 CustomToneMapping(vec3 color) { return color; }\n#define ORDERS_OF_MAG 5.0\n#define PI_TONE 3.14159265359\nfloat toneCalcBrightness(in vec3 color)\n{\nreturn (abs(color.r) * 0.263 + abs(color.g) * 0.655 + abs(color.b) * 0.082);\n}\nfloat toneApproximateScotopicLuminance(vec3 color)\n{\nreturn (0.062 * color.r + 0.608 * color.g + 0.330 * color.b);\n}\nvec3 LogarithmicMaxToneMapping(vec3 color) {\nfloat inputScaleFactor = toneMappingPhysicalScale / PI_TONE;\nfloat brightness = (toneMappingBrightness < 0.0) ? 0.0 : (toneMappingBrightness * 0.7);\nfloat powerBot = toneMappingExteriorDaylight ? 4.0 : 2.0;\nfloat res = 100.0 / ORDERS_OF_MAG;\nfloat mag = floor((50.0 / res));\nfloat power = ((brightness / 20.0 - ORDERS_OF_MAG) - powerBot) + mag;\nfloat stepsize = 9.0 / res;\nfloat step = 50.0 - (mag * res);\nfloat param_c = (0.02 * toneMappingContrast) * 2.0;\nfloat param_b = pow(10.0, power) * (1.0 + (stepsize * step));\nfloat param_a = param_b * (1.0 + param_c);\nparam_c /= pow(2.0, toneMappingMidTones - 1.0);\nparam_b *= PI_TONE;\nvec3 whiteConstancyFactor = toneMappingWhiteColor;\nif (toneMappingChromaticAdaptation) {\nfloat luminance = toneCalcBrightness(whiteConstancyFactor);\nwhiteConstancyFactor.r = (whiteConstancyFactor.r > 0.001) ? luminance / whiteConstancyFactor.r : luminance / 0.001;\nwhiteConstancyFactor.g = (whiteConstancyFactor.g > 0.001) ? luminance / whiteConstancyFactor.g : luminance / 0.001;\nwhiteConstancyFactor.b = (whiteConstancyFactor.b > 0.001) ? luminance / whiteConstancyFactor.b : luminance / 0.001;\n}\nvec3 outColor = inputScaleFactor * color;\nif (toneMappingChromaticAdaptation) {\noutColor *= whiteConstancyFactor.rgb;\n}\nfloat luminance = toneCalcBrightness(outColor);\nif (toneMappingColorDifferentiation && (luminance < 5.62)) {\nfloat sLuminance = toneApproximateScotopicLuminance(outColor);\nif (luminance <= 5.62e-3) {\noutColor = vec3(sLuminance);\n} else {\nfloat w = (luminance - 5.62e-3) / 5.61438;\noutColor = outColor * w + sLuminance * (1.0 - w);\n}\n}\noutColor = outColor * (param_a / (param_b * outColor + param_c));\nreturn outColor;\n}\nfloat maxExposurePhotographic(in vec4 color1, in vec4 color2)\n{\nreturn ((color1.r * color2.r) + (color1.g * color2.g)) + (color1.b * color2.b);\n}\nvec3 PhysicalMaxToneMapping(vec3 color) {\nfloat vignettingInfluence = 1.0;\nif (toneMappingVignetting > 0.0) {\nvec3 vignettingCoords = vec3(0.0, 0.0, 0.0);\nfloat aspect = toneMappingResolution.x / toneMappingResolution.y;\nvignettingCoords.x = gl_FragCoord.x / toneMappingResolution.x - 0.5;\nvignettingCoords.y = (gl_FragCoord.y / toneMappingResolution.y - 0.5) / aspect;\nvignettingCoords.z = 1.0;\nvignettingCoords = normalize(vignettingCoords);\nvignettingInfluence = pow(vignettingCoords.z, toneMappingVignetting);\n}\nfloat inputScaleFactor = toneMappingPhysicalScale / PI_TONE;\nfloat filmISO = toneMappingISO;\nfloat camShutter = 1.0 / toneMappingShutter;\nfloat fNumber = toneMappingAperture;\nfloat cm2 = 1.0;\nfloat burnHighlights = toneMappingHighlights;\nfloat crushBlacks = toneMappingShadows;\nfloat saturation = toneMappingSaturation;\nvec3 whitePointInfluence = toneMappingWhiteBalance;\nif (whitePointInfluence.r > 0.0) {\nwhitePointInfluence.r = 1.0 / whitePointInfluence.r;\n} else {\nwhitePointInfluence.r = 1.0;\n}\nif (whitePointInfluence.g > 0.0) {\nwhitePointInfluence.g = 1.0 / whitePointInfluence.g;\n} else {\nwhitePointInfluence.g = 1.0;\n}\nif (whitePointInfluence.b > 0.0) {\nwhitePointInfluence.b = 1.0 / whitePointInfluence.b;\n} else {\nwhitePointInfluence.b = 1.0;\n}\nvec4 lumFactor = vec4(0.212671, 0.715160, 0.072169, 0.0);\nfloat whiteLumFactor = maxExposurePhotographic(lumFactor, vec4(whitePointInfluence, 0.0));\nwhitePointInfluence.r /= whiteLumFactor;\nwhitePointInfluence.g /= whiteLumFactor;\nwhitePointInfluence.b /= whiteLumFactor;\nfloat isoInfluence = 0.0;\nfloat camShutterInv = 1.0 / camShutter;\nif (filmISO > 0.0) {\nisoInfluence = ((cm2 * 0.169811) * (filmISO * camShutterInv)) / ((15.4 * fNumber) * fNumber);\n} else {\nisoInfluence = cm2;\n}\nvec3 outColor = inputScaleFactor * color;\noutColor.r = outColor.r * whitePointInfluence.r * isoInfluence * vignettingInfluence;\noutColor.g = outColor.g * whitePointInfluence.g * isoInfluence * vignettingInfluence;\noutColor.b = outColor.b * whitePointInfluence.b * isoInfluence * vignettingInfluence;\noutColor.r = (outColor.r * (1.0 + (outColor.r * burnHighlights))) / (1.0 + outColor.r);\noutColor.g = (outColor.g * (1.0 + (outColor.g * burnHighlights))) / (1.0 + outColor.g);\noutColor.b = (outColor.b * (1.0 + (outColor.b * burnHighlights))) / (1.0 + outColor.b);\nfloat lumFactor2 = maxExposurePhotographic(lumFactor, vec4(outColor, 0.0));\nfloat tmpFloat = 1.0 - saturation;\noutColor.r = outColor.r * saturation + lumFactor2 * tmpFloat;\noutColor.g = outColor.g * saturation + lumFactor2 * tmpFloat;\noutColor.b = outColor.b * saturation + lumFactor2 * tmpFloat;\noutColor = max(vec3(0.0), outColor);\nfloat crushBlacksFac = crushBlacks * 2.0 + 1.0;\nfloat crushBlacksFac2 = pow(maxExposurePhotographic(lumFactor, vec4(outColor, 0.0)), 0.5);\ntmpFloat = (1.0 - crushBlacksFac2);\nif (crushBlacksFac2 < 1.0) {\noutColor.r = outColor.r * crushBlacksFac2 + pow(outColor.r, crushBlacksFac) * tmpFloat;\noutColor.g = outColor.g * crushBlacksFac2 + pow(outColor.g, crushBlacksFac) * tmpFloat;\noutColor.b = outColor.b * crushBlacksFac2 + pow(outColor.b, crushBlacksFac) * tmpFloat;\n}\nreturn outColor;\n}\nfloat filmicBlenderDesaturationMinIntensity(vec3 color) {\nfloat maxChannel = max(color.r, max(color.g, color.b));\nfloat x = max(maxChannel, 0.6251);\nreturn (1.2192868 * x - 0.63221059)\n* ((x - 0.65069831) / (abs(x - 0.65069831) + 0.00952982) + 0.73015231);\n}\nvec3 filmicBlenderDesaturationTransform(vec3 color) {\nconst float CURVE_SMOOTHNESS = 0.03;\nfloat minIntensity = filmicBlenderDesaturationMinIntensity(color);\nvec4 x = vec4(color, 1.0) - minIntensity;\nx = pow(x, vec4(2.0)) / (abs(x) + CURVE_SMOOTHNESS);\nreturn (x.rgb - x.a + color + 1.0) / 2.0;\n}\nvec3 filmicBlenderDynamicRangeTransform(vec3 color) {\nreturn pow(\n(0.28882259 * color - 0.15880336)\n/ (pow(color - 0.6229693, vec3(2.0)) + 0.16965022)\n+ 0.20453365 * color + 0.37847142,\nvec3(3.0)\n);\n}\nvec3 FilmicBlenderToneMapping(vec3 color) {\ncolor *= toneMappingExposure;\ncolor = max(color, 0.000175);\ncolor = clamp((log2(color) - FILMIC_BLENDER_LOG_MIN)\n/ (FILMIC_BLENDER_LOG_MAX - FILMIC_BLENDER_LOG_MIN), 0.0, 1.0);\ncolor = filmicBlenderDesaturationTransform(color);\ncolor = clamp(color / FILMIC_BLENDER_EXPOSURE_LATITUDE_RATIO, 0.0, 1.0);\ncolor = filmicBlenderDynamicRangeTransform(color);\nreturn color;\n}",transmission_fragment:"#ifdef USE_TRANSMISSION\nfloat transmissionAlpha = 1.0;\nfloat transmissionFactor = transmission;\nfloat thicknessFactor = thickness;\n#ifdef USE_TRANSMISSIONMAP\ntransmissionFactor *= texture2D(transmissionMap, vUv).r;\n#endif\n#ifdef USE_THICKNESSMAP\nthicknessFactor *= texture2D(thicknessMap, vUv).g;\n#endif\nvec3 pos = vWorldPosition;\nvec3 v = normalize(cameraPosition - pos);\nvec3 n = inverseTransformDirection(normal, viewMatrix);\nvec4 transmission = getIBLVolumeRefraction(\nn, v, roughnessFactor, material.diffuseColor, material.specularColor, material.specularF90,\npos, modelMatrix, viewMatrix, projectionMatrix, ior, thicknessFactor,\nattenuationColor, attenuationDistance);\ntotalDiffuse = mix(totalDiffuse, transmission.rgb, transmissionFactor);\ntransmissionAlpha = mix(transmissionAlpha, transmission.a, transmissionFactor);\n#endif",transmission_pars_fragment:"#ifdef USE_TRANSMISSION\nuniform float transmission;\nuniform float thickness;\nuniform float attenuationDistance;\nuniform vec3 attenuationColor;\n#ifdef USE_TRANSMISSIONMAP\nuniform sampler2D transmissionMap;\n#endif\n#ifdef USE_THICKNESSMAP\nuniform sampler2D thicknessMap;\n#endif\nuniform vec2 transmissionSamplerSize;\nuniform sampler2D transmissionSamplerMap;\nuniform mat4 modelMatrix;\nuniform mat4 projectionMatrix;\nvarying vec3 vWorldPosition;\nvec3 getVolumeTransmissionRay(const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix) {\nvec3 refractionVector = refract(- v, normalize(n), 1.0 / ior);\nvec3 modelScale;\nmodelScale.x = length(vec3(modelMatrix[0].xyz));\nmodelScale.y = length(vec3(modelMatrix[1].xyz));\nmodelScale.z = length(vec3(modelMatrix[2].xyz));\nreturn normalize(refractionVector) * thickness * modelScale;\n}\nfloat applyIorToRoughness(const in float roughness, const in float ior) {\nreturn roughness * clamp(ior * 2.0 - 2.0, 0.0, 1.0);\n}\nvec4 getTransmissionSample(const in vec2 fragCoord, const in float roughness, const in float ior) {\nfloat framebufferLod = log2(transmissionSamplerSize.x) * applyIorToRoughness(roughness, ior);\n#ifdef TEXTURE_LOD_EXT\nreturn texture2DLodEXT(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n#else\nreturn texture2D(transmissionSamplerMap, fragCoord.xy, framebufferLod);\n#endif\n}\nvec3 applyVolumeAttenuation(const in vec3 radiance, const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance) {\nif (attenuationDistance == 0.0) {\nreturn radiance;\n} else {\nvec3 attenuationCoefficient = -log(attenuationColor) / attenuationDistance;\nvec3 transmittance = exp(-attenuationCoefficient * transmissionDistance);\nreturn transmittance * radiance;\n}\n}\nvec4 getIBLVolumeRefraction(const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,\nconst in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,\nconst in mat4 viewMatrix, const in mat4 projMatrix, const in float ior, const in float thickness,\nconst in vec3 attenuationColor, const in float attenuationDistance) {\nvec3 transmissionRay = getVolumeTransmissionRay(n, v, thickness, ior, modelMatrix);\nvec3 refractedRayExit = position + transmissionRay;\nvec4 ndcPos = projMatrix * viewMatrix * vec4(refractedRayExit, 1.0);\nvec2 refractionCoords = ndcPos.xy / ndcPos.w;\nrefractionCoords += 1.0;\nrefractionCoords /= 2.0;\nvec4 transmittedLight = getTransmissionSample(refractionCoords, roughness, ior);\nvec3 attenuatedColor = applyVolumeAttenuation(transmittedLight.rgb, length(transmissionRay), attenuationColor, attenuationDistance);\nvec3 F = EnvironmentBRDF(n, v, specularColor, specularF90, roughness);\nreturn vec4((1.0 - F) * attenuatedColor * diffuseColor, transmittedLight.a);\n}\n#endif",uv_pars_fragment:"#if (defined(USE_UV) && !defined(UVS_VERTEX_ONLY))\nvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n#ifdef UVS_VERTEX_ONLY\nvec2 vUv;\n#else\nvarying vec2 vUv;\n#endif\nuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\nvUv = (uvTransform * vec3(uv, 1)).xy;\n#endif",uv2_pars_fragment:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nattribute vec2 uv2;\nvarying vec2 vUv2;\nuniform mat3 uv2Transform;\n#endif",uv2_vertex:"#if defined(USE_LIGHTMAP) || defined(USE_AOMAP)\nvUv2 = (uv2Transform * vec3(uv2, 1)).xy;\n#endif",worldpos_vertex:"#if defined(USE_ENVMAP) || defined(DISTANCE) || defined (USE_SHADOWMAP) || defined (USE_TRANSMISSION) || defined(MASK) || defined(NODE)\nvec4 worldPosition = vec4(transformed, 1.0);\n#ifdef USE_INSTANCING\nworldPosition = instanceMatrix * worldPosition;\n#endif\nworldPosition = modelMatrix * worldPosition;\n#endif",background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\nvUv = (uvTransform * vec3(uv, 1)).xy;\ngl_Position = vec4(position.xy, 1.0, 1.0);\n}",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\ngl_FragColor = texture2D(t2D, vUv);\n#include \n#include \n}",cube_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include \n#include \ngl_Position.z = gl_Position.w;\n}",cube_frag:"#include \nuniform float opacity;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\nvec3 vReflect = vWorldDirection;\n#include \ngl_FragColor = envColor;\ngl_FragColor.a *= opacity;\n#include \n#include \n}",depth_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\nvoid main() {\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = mvPosition.xyz;\nvProjectedPosZW = mat2(\nprojectionMatrix[2][2], projectionMatrix[2][3],\nprojectionMatrix[3][2], projectionMatrix[3][3]\n) * mvPosition.zw;\n}",depth_frag:"#if DEPTH_PACKING == 3200\nuniform float opacity;\n#endif\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst float ONE_MINUS_EPS = 0.9999999;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\nvoid main() {\n#include \nvec4 diffuseColor = vec4(1.0);\n#if DEPTH_PACKING == 3200\ndiffuseColor.a = opacity;\n#endif\n#include \n#include \n#include \n#include \n#if DEPTH_PACKING != 3202\nfloat depth = vProjectedPosZW.x / vProjectedPosZW.y;\ndepth = (depth + 1.0) / 2.0;\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(depth), dFdy(depth)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndepth = clamp(depth + max(bias, 1e-6), 0.0, ONE_MINUS_EPS);\n#endif\n#if DEPTH_PACKING == 3200\ngl_FragColor = vec4(vec3(1.0 - depth), opacity);\n#elif DEPTH_PACKING == 3201\ngl_FragColor = packDepthToRGBA(depth);\n#endif\n#else\ngl_FragColor = vec4(vViewPosition.z);\n#endif\n}",distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvWorldPosition = worldPosition.xyz;\n}",distanceRGBA_frag:"#define DISTANCE\n#ifdef USE_SLOPE_SCALED_BIAS\nuniform float slopeScaledBias;\nconst float ONE_MINUS_EPS = 0.9999999;\n#endif\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifndef DISTANCE_SCALE\n#define DISTANCE_SCALE 1.0\n#endif\nvoid main () {\n#include \nvec4 diffuseColor = vec4(1.0);\n#include \n#include \n#include \nfloat dist = length(vWorldPosition - referencePosition);\n#if DISTANCE_PACKING == 3301\ndist = (dist - nearDistance) / (farDistance - nearDistance);\ndist = saturate(dist);\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\nfloat bias = slopeScaledBias * max(dxdy.x, dxdy.y);\ndist = clamp(dist + bias, 0.0, ONE_MINUS_EPS);\n#endif\ngl_FragColor = packDepthToRGBA(dist);\n#elif DISTANCE_PACKING == 3302\n#ifdef USE_SLOPE_SCALED_BIAS\nvec2 dxdy = abs(vec2(dFdx(dist), dFdy(dist)));\ndist += slopeScaledBias * max(dxdy.x, dxdy.y);\n#endif\ngl_FragColor = vec4(dist * DISTANCE_SCALE, 0.0, 0.0, 1.0);\n#endif\n}",equirect_vert:"varying vec3 vWorldDirection;\n#include \nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include \n#include \n}",equirect_frag:"uniform sampler2D tEquirect;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec3 vWorldDirection;\n#include \nvoid main() {\nvec3 direction = normalize(vWorldDirection);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\nsampleUV.x += offsetU;\ngl_FragColor = texture2D(tEquirect, sampleUV);\n#include \n#include \n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\nvLineDistance = scale * lineDistance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nif (mod(vLineDistance, totalSize) > dashSize) {\ndiscard;\n}\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \noutgoingLight = diffuseColor.rgb;\n#include \n#include \n#include \n#include \n#include \n}",meshbasic_vert:"#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#if defined (USE_ENVMAP) || defined (USE_SKINNING)\n#include \n#include \n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \n#include \n#include \nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_LIGHTMAP\nvec4 lightMapTexel= texture2D(lightMap, vUv2);\nreflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity;\n#else\nreflectedLight.indirectDiffuse += vec3(1.0);\n#endif\n#include \nreflectedLight.indirectDiffuse *= diffuseColor.rgb;\nvec3 outgoingLight = reflectedLight.indirectDiffuse;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \n#include \n#include \n#include \n#include \n}",meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\nvarying vec3 vIndirectBack;\n#endif\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef DOUBLE_SIDED\nreflectedLight.indirectDiffuse += (gl_FrontFacing) ? vIndirectFront : vIndirectBack;\n#else\nreflectedLight.indirectDiffuse += vIndirectFront;\n#endif\n#include \nreflectedLight.indirectDiffuse *= BRDF_Lambert(diffuseColor.rgb);\n#ifdef DOUBLE_SIDED\nreflectedLight.directDiffuse = (gl_FrontFacing) ? vLightFront : vLightBack;\n#else\nreflectedLight.directDiffuse = vLightFront;\n#endif\nreflectedLight.directDiffuse *= BRDF_Lambert(diffuseColor.rgb) * getShadowMask();\n#include \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 viewDir = normalize(vViewPosition);\nvec3 x = normalize(vec3(viewDir.z, 0.0, - viewDir.x));\nvec3 y = cross(viewDir, x);\nvec2 uv = vec2(dot(x, normal), dot(y, normal)) * 0.495 + 0.5;\n#ifdef USE_MATCAP\nvec4 matcapColor = texture2D(matcap, uv);\n#else\nvec4 matcapColor = vec4(vec3(mix(0.2, 0.8, uv.y)), 1.0);\n#endif\nvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n#include \n#include \n#include \n#include \n#include \n#include \n}",meshnormal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvViewPosition = -mvPosition.xyz;\n#endif\n}",meshnormal_frag:"#define NORMAL\nuniform float opacity;\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \ngl_FragColor = vec4(packNormalToRGB(normal), opacity);\n#ifdef OPAQUE\ngl_FragColor.a = 1.0;\n#endif\n}",meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \n#include \n#include \n#include \n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\nvarying vec3 vWorldPosition;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \n#include \n#include \n#ifdef USE_TRANSMISSION\nvWorldPosition = worldPosition.xyz;\n#endif\n}",meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n#define IOR\n#define SPECULAR\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef IOR\nuniform float ior;\n#endif\n#ifdef SPECULAR\nuniform float specularIntensity;\nuniform vec3 specularColor;\n#ifdef USE_SPECULARINTENSITYMAP\nuniform sampler2D specularIntensityMap;\n#endif\n#ifdef USE_SPECULARCOLORMAP\nuniform sampler2D specularColorMap;\n#endif\n#endif\n#ifdef USE_CLEARCOAT\nuniform float clearcoat;\nuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\nuniform vec3 sheenColor;\nuniform float sheenRoughness;\n#ifdef USE_SHEENCOLORMAP\nuniform sampler2D sheenColorMap;\n#endif\n#ifdef USE_SHEENROUGHNESSMAP\nuniform sampler2D sheenRoughnessMap;\n#endif\n#endif\n#if defined(SHADOWMAP_TYPE_ESM) || defined(USE_ENVMAP)\nuniform mat4 invViewMatrix;\n#endif\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n#include \nvec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;\n#ifdef USE_SHEEN\nfloat sheenEnergyComp = 1.0 - 0.157 * max3(material.sheenColor);\noutgoingLight = outgoingLight * sheenEnergyComp + sheenSpecular;\n#endif\n#ifdef USE_CLEARCOAT\nfloat dotNVcc = saturate(dot(geometry.clearcoatNormal, geometry.viewDir));\nvec3 Fcc = F_Schlick(material.clearcoatF0, material.clearcoatF90, dotNVcc);\noutgoingLight = outgoingLight * (1.0 - material.clearcoat * Fcc) + clearcoatSpecular * material.clearcoat;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \n#include \n#include \n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 diffuseColor = vec4(diffuse, opacity);\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 totalEmissiveRadiance = emissive;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include \n#include \n#include \n#include \n#include \n#include \n}",points_vert:"uniform float size;\nuniform float scale;\n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \ngl_PointSize = size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) gl_PointSize *= (scale / - mvPosition.z);\n#endif\n#include \n#include \n#include \n#include \n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \noutgoingLight = diffuseColor.rgb;\n#include \n#include \n#include \n#include \n#include \n}",shadow_vert:"#include \n#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#endif\n#include \n#include \n#include \n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#ifdef USE_SHADOWMAP\nvViewPosition = -mvPosition.xyz;\n#endif\n}",shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#ifdef SHADOWMAP_TYPE_ESM\nuniform mat4 invViewMatrix;\n#endif\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\ngl_FragColor = vec4(color, opacity * (1.0 - getShadowMask()));\n#include \n#include \n#include \n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec4 mvPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\nvec2 scale;\nscale.x = length(vec3(modelMatrix[0].x, modelMatrix[0].y, modelMatrix[0].z));\nscale.y = length(vec3(modelMatrix[1].x, modelMatrix[1].y, modelMatrix[1].z));\n#ifndef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) scale *= -mvPosition.z;\n#endif\nvec2 alignedPosition = (position.xy - (center - vec2(0.5))) * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos(rotation) * alignedPosition.x - sin(rotation) * alignedPosition.y;\nrotatedPosition.y = sin(rotation) * alignedPosition.x + cos(rotation) * alignedPosition.y;\nmvPosition.xy += rotatedPosition;\ngl_Position = projectionMatrix * mvPosition;\n#include \n#include \n#include \n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvoid main() {\n#include \nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include \n#include \n#include \n#include \noutgoingLight = diffuseColor.rgb;\n#include \n#include \n#include \n#include \n}",equicube_vert:"varying vec2 vUv;\n#include \nvoid main() {\nvUv = uv;\n#include \n#include \n}",equicube_frag:"uniform sampler2D tEquirect;\nuniform int faceIndex;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec2 vUv;\n#include \nvoid main() {\nvec3 direction;\nvec2 uv = vUv * 2.0 - 1.0;\nif (faceIndex==0) {\ndirection = vec3(1.0, -uv.y, -uv.x);\n} else if (faceIndex==1) {\ndirection = vec3(-1.0, -uv.y, uv.x);\n} else if (faceIndex==2) {\ndirection = vec3(uv.x, 1.0, uv.y);\n} else if (faceIndex==3) {\ndirection = vec3(uv.x, -1.0, -uv.y);\n} else if (faceIndex==4) {\ndirection = vec3(uv.x, -uv.y, 1.0);\n} else {\ndirection = vec3(-uv.x, -uv.y, -1.0);\n}\ndirection = normalize(direction);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\nif (invertU) {\nsampleUV.x = 1.0 - sampleUV.x;\n}\nsampleUV.x += offsetU;\ngl_FragColor = texture2D(tEquirect, sampleUV);\n}",mask_vert:"#define MASK\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuniform mat4 textureMatrix;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include \n#include \n#ifdef USE_DISPLACEMENTMAP\n#include \n#include \n#include \n#endif\n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \nprojTexCoord = textureMatrix * worldPosition;\n#include \n#include \n}",mask_frag:"#define MASK\n#include \n#include \n#include \n#include \n#include \n#include \n#include \nuniform mat4 projectionMatrix;\nuniform float opacity;\nuniform sampler2D depthTexture;\nuniform vec2 cameraNearFar;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include \nvec4 diffuseColor = vec4(1.0);\ndiffuseColor.a = opacity;\n#include \n#include \n#include \n#include \nfloat depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\nfloat viewZ;\nif (isOrtho(projectionMatrix))\nviewZ = -orthographicDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nelse\nviewZ = -perspectiveDepthToViewZ(depth,\ncameraNearFar.x, cameraNearFar.y);\nfloat depthTest = (vViewPosition.z > viewZ) ? 1.0 : 0.0;\ngl_FragColor = vec4(0.0, depthTest, 1.0, 0.0);\n}",meshnode_vert:"#define NODE\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_SKYDOME_LIGHT_AR) || defined(NODE_ENV_SPHERE_MY)\nvarying vec3 vWorldPosition;\n#endif\n#include \nvoid main() {\n#include \n#include \n#include \n#include \n#include \n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \nvViewPosition = -mvPosition.xyz;\n#include \n#include \n#include \n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_SKYDOME_LIGHT_AR) || defined(NODE_ENV_SPHERE_MY)\nvWorldPosition = worldPosition.xyz;\n#endif\n#include \n}",meshnode_frag:"#define NODE\n#define STANDARD\n#define PHYSICAL\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BUMP_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(NODE_TANGENT_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_NOISE_MX) || defined(NODE_SAMPLER_INFO_MY) || defined(NODE_INCIDENT) || defined(NODE_POSITION) || defined(NODE_NORMAL) || defined(USE_OSL) || defined(USE_ENVMAP) || defined(SHADOWMAP_TYPE_ESM) && (defined(NODE_BSDF_DIFFUSE_BL) || defined(NODE_EEVEE_SPECULAR_BL) || defined(NODE_BSDF_GLOSSY_BL) || defined(NODE_BSDF_REFRACTION_BL) || defined(NODE_MATERIAL_MX) || defined(NODE_PHYSICAL_MX) || defined(NODE_STANDARD_SURFACE_AR) || defined(NODE_SHADOW_MATTE_AR))\nuniform mat4 invViewMatrix;\n#endif\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#if defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FRESNEL_BL) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL) || defined(USE_SSR) || (defined(NODE_NORMAL) && defined(MT_BLENDER)) || defined(USE_OSL)\nuniform mat4 projectionMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL) || defined(NODE_OBJECT_INFO_BL) || defined(NODE_BITMAP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_NOISE_MX) || defined(NODE_SAMPLER_INFO_MY) || defined(NODE_TRANSFORM_MY) || defined(USE_OSL) || defined(USE_PLANE_REFLECTION)\nuniform mat4 modelMatrix;\nuniform mat4 invModelMatrix;\n#endif\n#if defined(NODE_VECT_TRANSFORM_BL) || defined(NODE_NORMAL_MAP_BL) || defined(NODE_NORMAL_BUMP_MX) || defined(NODE_BUMP_2D_MY) || defined(NODE_SAMPLER_INFO_MY)\nuniform mat4 modelViewMatrix;\n#endif\n#if defined(NODE_TEX_IMAGE_BL)\nuniform mat3 normalMatrix;\n#endif\n#if defined(NODE_TEX_COORD_BL) || defined(NODE_NEW_GEOMETRY_BL) || defined(NODE_TANGENT_BL)\nuniform vec3 boundingBoxMin;\nuniform vec3 boundingBoxMax;\n#endif\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_BL) || defined(NODE_PHY_SUN_SKY_ENV_MX) || defined(NODE_SKYDOME_LIGHT_AR) || defined(NODE_ENV_SPHERE_MY)\nvarying vec3 vWorldPosition;\n#endif\n#if defined(NODE_TEX_COORD_BL)\nuniform vec2 viewWidthHeight;\n#endif\n#include \n#include \n#include \n#include \nvoid main() {\nbool _frontFacingValue = gl_FrontFacing;\n#define FRONT_FACING_VALUE _frontFacingValue\n#include \n#include \n#include \nvec4 outgoingLight = vec4(0.0);\n#include \n#if WORLD_NODES == 1\noutgoingLight.a = 1.0;\n#endif\n#ifdef USE_ALPHATEST\nif (outgoingLight.a < alphaTest)\ndiscard;\nelse\noutgoingLight.a = 1.0;\n#endif\n#if defined(OPAQUE) && !(defined(NODE_MATTE_SHADOW_MX) || defined(NODE_SHADOW_MATTE_AR) || defined(NODE_AI_SHADOW_MATTE_MY))\noutgoingLight.a = 1.0;\n#endif\ngl_FragColor = vec4(outgoingLight);\n#include \n#include \n#include \n#include \n#include \n#include \n}",lights_node_pars_fragment:"\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\nstruct NodeMaterial {\nvec3 diffuseColor;\nfloat roughness;\nvec3 specularColor;\nfloat specularF90;\nvec3 fresnelRefl90;\nvec3 refractionColor;\nfloat refractionRoughness;\nfloat refractionIOR;\n#ifdef USE_CLEARCOAT\nfloat clearcoat;\nfloat clearcoatRoughness;\nvec3 clearcoatF0;\nfloat clearcoatF90;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\nfloat sheenRoughness;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n#define BLENDER_SPECULAR_COEFFICIENT 0.08\nvec3 clearcoatSpecular = vec3(0.0);\nvec3 sheenSpecular = vec3(0.0);\nfloat IBLSheenBRDF(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat r2 = roughness * roughness;\nfloat a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;\nfloat b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;\nfloat DG = exp(a * dotNV + b) + (roughness < 0.25 ? 0.0 : 0.1 * (roughness - 0.25));\nreturn saturate(DG * RECIPROCAL_PI);\n}\nvec2 DFGApprox(const in vec3 normal, const in vec3 viewDir, const in float roughness) {\nfloat dotNV = saturate(dot(normal, viewDir));\nconst vec4 c0 = vec4(- 1, - 0.0275, - 0.572, 0.022);\nconst vec4 c1 = vec4(1, 0.0425, 1.04, - 0.04);\nvec4 r = roughness * c0 + c1;\nfloat a004 = min(r.x * r.x, exp2(- 9.28 * dotNV)) * r.x + r.y;\nvec2 fab = vec2(- 1.04, 1.04) * a004 + r.zw;\nreturn fab;\n}\nvec3 EnvironmentBRDF(const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness) {\nvec2 fab = DFGApprox(normal, viewDir, roughness);\nreturn specularColor * fab.x + specularF90 * fab.y;\n}\nfloat clearcoatDHRApprox(const in float roughness, const in float dotNL) {\nreturn DEFAULT_SPECULAR_COEFFICIENT + (1.0 - DEFAULT_SPECULAR_COEFFICIENT) * (pow(1.0 - dotNL, 5.0) * pow(1.0 - roughness, 2.0));\n}\n#if NUM_RECT_AREA_LIGHTS > 0\nvoid RE_Direct_RectArea_Node(const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nvec3 normal = geometry.normal;\nvec3 viewDir = geometry.viewDir;\nvec3 position = geometry.position;\nvec3 lightPos = rectAreaLight.position;\nvec3 halfWidth = rectAreaLight.halfWidth;\nvec3 halfHeight = rectAreaLight.halfHeight;\nvec3 lightColor = rectAreaLight.color;\nfloat roughness = material.roughness;\nvec3 rectCoords[4];\nrectCoords[0] = lightPos + halfWidth - halfHeight;\nrectCoords[1] = lightPos - halfWidth - halfHeight;\nrectCoords[2] = lightPos - halfWidth + halfHeight;\nrectCoords[3] = lightPos + halfWidth + halfHeight;\nvec2 uv = LTC_Uv(normal, viewDir, roughness);\nvec4 t1 = texture2D(ltc_1, uv);\nvec4 t2 = texture2D(ltc_2, uv);\nmat3 mInv = mat3(\nvec3(t1.x, 0, t1.y),\nvec3( 0, 1, 0),\nvec3(t1.z, 0, t1.w)\n);\nvec3 fresnel = (material.specularColor * t2.x + (vec3(1.0) - material.specularColor) * t2.y);\nreflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate(normal, viewDir, position, mInv, rectCoords);\nreflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate(normal, viewDir, position, mat3(1.0), rectCoords);\n}\n#endif\nvoid RE_DirectDiffuse_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\nreflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_DirectSpecular_Node(const in IncidentLight directLight,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nfloat dotNL = saturate(dot(geometry.normal, directLight.direction));\nvec3 irradiance = dotNL * directLight.color;\n#ifdef USE_CLEARCOAT\nfloat dotNLcc = saturate(dot(geometry.clearcoatNormal, directLight.direction));\nvec3 ccIrradiance = dotNLcc * directLight.color;\nclearcoatSpecular += ccIrradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.clearcoatNormal, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness);\n#endif\n#ifdef USE_SHEEN\nsheenSpecular += irradiance * BRDF_Sheen(directLight.direction, geometry.viewDir, geometry.normal, material.sheenColor, material.sheenRoughness);\n#endif\nreflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);\n}\nvoid RE_IndirectDiffuse_Node(const in vec3 irradiance, const in vec3 iblIrradiance,\nconst in GeometricContext geometry, const in NodeMaterial material,\ninout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += (irradiance + iblIrradiance) * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance,\nconst in vec3 clearcoatRadiance, const in GeometricContext geometry,\nconst in NodeMaterial material, inout ReflectedLight reflectedLight) {\n#ifdef USE_CLEARCOAT\nclearcoatSpecular += clearcoatRadiance * EnvironmentBRDF(geometry.clearcoatNormal, geometry.viewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness);\n#endif\n#ifdef USE_SHEEN\nsheenSpecular += irradiance * material.sheenColor * IBLSheenBRDF(geometry.normal, geometry.viewDir, material.sheenRoughness);\n#endif\n#ifdef MT_BLENDER\n#ifdef COMPAT_USE_SPEC_ENV_BLENDER_APPROX\nvec3 specEnv = BRDF_Specular_GGX_Environment_Blender_Approx(geometry,\nmaterial.specularColor, material.fresnelRefl90,\nmaterial.roughness, 0);\n#else\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir,\ngeometry.normal, material.specularColor,\nmaterial.roughness);\n#endif\n#elif defined(MT_MAX)\nfloat alphaEnv = pow2(pow2(material.roughness));\nvec3 specEnv = material.specularColor / (1.0 - alphaEnv + PI * alphaEnv);\n#elif defined(MT_MAYA)\nvec3 specEnv = BRDF_Specular_GGX_Environment(geometry.viewDir, geometry.normal, material.specularColor, material.roughness);\n#else\nvec3 specEnv = vec3(1.0);\n#endif\nreflectedLight.indirectSpecular += radiance * specEnv;\n}\nvoid RE_Refraction_Node(const vec3 refraction, const NodeMaterial material,\ninout vec3 refractedLight) {\nrefractedLight += refraction * material.refractionColor;\n}\n#ifdef MT_BLENDER\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.roughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#elif defined(MT_MAX)\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.roughness * exp(0.35*(1.0-pow2(material.roughness))))\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness * exp(0.35*(1.0-pow2(material.refractionRoughness))))\n#else\n#define Material_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.roughness)\n#define Material_Refraction_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.refractionRoughness)\n#endif\n#define Material_ClearCoat_BlinnShininessExponent(material) GGXRoughnessToBlinnExponent(material.clearcoatRoughness)\nfloat computeSpecularOcclusion(const in float dotNV, const in float ambientOcclusion, const in float roughness) {\nreturn saturate(pow(abs(dotNV + ambientOcclusion), exp2(- 16.0 * roughness - 1.0)) - 1.0 + ambientOcclusion);\n}\n#define RE_Direct_RectArea RE_Direct_RectArea_Node",lights_node_gtao_pars_fragment:"#ifdef USE_GTAO\nuniform sampler2D gtaoMap;\nuniform vec2 currResolution;\nfloat calcGTAOVisibilityFix(vec3 viewDir, vec3 normal) {\nfloat slopeCoeff = saturate(dot(viewDir, normal));\nreturn pow(2.0 / (slopeCoeff + 1.0), log2(PI) - 1.0);\n}\nfloat calcSolidAngle(float radiusAngle) {\nreturn PI2 * (1.0 - cos(radiusAngle));\n}\nfloat calcSolidAnglesIntersectionApprox(float radiusAngle0, float radiusAngle1,\nfloat distanceAngle) {\nfloat rp = radiusAngle0, rl = radiusAngle1, d = distanceAngle;\nfloat rDiff = abs(rp - rl);\nreturn PI2 * (1.0 - cos(min(rp, rl))) * smoothstep(0.0, 1.0, 1.0 -\n(d - rDiff) / (rp + rl - rDiff));\n}\nfloat calcGTSOVisibility(float aoVisibility, vec3 bentNormal, vec3 viewDir, vec3 normal,\nfloat roughness) {\naoVisibility = saturate(aoVisibility * calcGTAOVisibilityFix(viewDir, normal));\nfloat radiusAngleVisCone = acos(clamp(sqrt(1.0 - aoVisibility), -1.0, 1.0));\nfloat radiusAngleSpecCone = acos(clamp(exp2(-3.32193 * pow2(roughness)), -1.0, 1.0));\nradiusAngleSpecCone = max(0.001, radiusAngleSpecCone);\nvec3 specularConeAxis = -reflect(viewDir, normal);\nfloat distanceAngle = acos(clamp(dot(bentNormal, specularConeAxis), -1.0, 1.0));\nfloat solidAngleIntersection = calcSolidAnglesIntersectionApprox(\nradiusAngleVisCone, radiusAngleSpecCone, distanceAngle);\nfloat solidAngleSpecular = calcSolidAngle(radiusAngleSpecCone);\nfloat specVisibility = solidAngleIntersection / solidAngleSpecular;\nreturn mix(specVisibility, 1.0, aoVisibility);\n}\n#endif",lights_fragment_gtso:"#ifdef USE_GTAO\nreflectedLight.indirectSpecular *= calcGTSOVisibility(gtaoVisibility,\ngtaoBentNormal, gtaoViewDir, gtaoNormal, gtaoRoughness);\n#endif",normal_output_fragment:"#if NORMAL_OUTPUT == 1\ngl_FragColor = vec4(packNormalToRGB(normal), gl_FragColor.a);\n#endif",ssr_pars_fragment:"#ifdef USE_SSR\nuniform sampler2D ssrSourceBuffer;\nuniform sampler2D ssrDepthBuffer;\nuniform sampler2D ssrBackfaceDepthBuffer;\nuniform mat4 invProjectionMatrix;\nuniform vec2 ssrResolution;\nuniform float ssrThickness;\nuniform float ssrStride;\nuniform float ssrJitter;\nuniform float ssrMaxDistance;\n#ifdef USE_SSR_REFRACT\n#define STEPS_FADE_AMOUNT 0.1\n#define SCREEN_FADE_THRESHOLD 0.6\n#else\n#define STEPS_FADE_AMOUNT 1.0\n#define SCREEN_FADE_THRESHOLD 0.4\n#endif\nvec3 deproject(vec3 p) {\nvec4 res = invProjectionMatrix * vec4(p, 1);\nreturn res.xyz / res.w;\n}\nbool doesIntersect(float rayzmax, float rayzmin, vec2 uv) {\nfloat sceneZMin = texture2D(ssrDepthBuffer, uv).r;\n#ifdef USE_SSR_REFRACT\nreturn rayzmin >= (sceneZMin-ssrThickness) && rayzmax <= sceneZMin;\n#else\nfloat sceneZMax = texture2D(ssrBackfaceDepthBuffer, uv).r;\nreturn rayzmin >= sceneZMax && rayzmax <= sceneZMin;\n#endif\n}\nfloat distanceSquared(vec2 a, vec2 b) { a -= b; return dot(a, a); }\nvoid swapIfBigger(inout float a, inout float b) {\nif (a > b) {\nfloat t = a;\na = b;\nb = t;\n}\n}\nbool isOutsideUvBounds(float x) { return x < 0.0 || x > 1.0; }\nbool isOutsideUvBounds(vec2 uv) { return isOutsideUvBounds(uv.x) || isOutsideUvBounds(uv.y); }\nvec3 computeSSR(vec3 color, vec3 normal, float ior) {\nvec2 uv = gl_FragCoord.xy / ssrResolution;\nvec2 screenCoord = uv * 2.0 - vec2(1, 1);\nfloat nearClip = deproject(vec3(0, 0, -1)).z;\nvec3 ray = deproject(vec3(screenCoord, -1));\nray /= ray.z;\nfloat depthSample = -vViewPosition.z;\nvec3 vpos = depthSample * ray;\n#ifdef USE_SSR_REFRACT\nvec3 dir = normalize(refract(normalize(vpos), normalize(normal), 1.0/ior));\n#else\nvec3 dir = normalize(reflect(normalize(vpos), normalize(normal)));\n#endif\nfloat maxDist = ssrMaxDistance;\nfloat rayLength = (vpos.z + dir.z * maxDist) > nearClip ? (nearClip - vpos.z) / dir.z : maxDist;\nvec3 csOrig = vpos;\nvec3 csEndPoint = csOrig + dir * rayLength;\nvec4 H0 = projectionMatrix * vec4(csOrig, 1.0);\nvec4 H1 = projectionMatrix * vec4(csEndPoint, 1.0);\nfloat k0 = 1.0 / H0.w, k1 = 1.0 / H1.w;\nvec3 Q0 = csOrig.xyz * k0, Q1 = csEndPoint.xyz * k1;\nvec2 P0 = H0.xy * k0, P1 = H1.xy * k1;\nP0 = P0 * 0.5 + vec2(0.5), P1 = P1 * 0.5 + vec2(0.5);\n#ifndef SSR_SIMPLE_REFRACT\nP0 *= ssrResolution, P1 *= ssrResolution;\nP1 += vec2((distanceSquared(P0, P1) < 0.0001) ? 0.01 : 0.0);\nvec2 delta = P1 - P0;\nbool permute = false;\nif (abs(delta.x) < abs(delta.y)) {\npermute = true; delta = delta.yx; P0 = P0.yx; P1 = P1.yx;\n}\nfloat stepDir = sign(delta.x);\nfloat invdx = stepDir / delta.x;\nvec3 dQ = (Q1 - Q0) * invdx;\nfloat dk = (k1 - k0) * invdx;\nvec2 dP = vec2(stepDir, delta.y * invdx);\nfloat pixelStride = ssrStride;\nfloat jitterMod = (gl_FragCoord.x + gl_FragCoord.y) * 0.25;\nvec4 PQK = vec4(P0, Q0.z, k0);\nvec4 dPQK = vec4(dP, dQ.z, dk);\ndPQK *= pixelStride;\nPQK += dPQK * mod(jitterMod, 1.0) * ssrJitter;\nfloat end = P1.x * stepDir;\nfloat prevZMaxEstimate = PQK.z / PQK.w;\nfloat rayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfloat stepped = 0.0;\nvec2 hitUV;\nbool intersected = false;\nfor (float stepCount = 1.0; stepCount <= float(MAX_STEPS); stepCount ++) {\nPQK += dPQK;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\nstepped = stepCount;\nhitUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nif (isOutsideUvBounds(hitUV)) break;\nintersected = doesIntersect(rayZMax, rayZMin, hitUV);\nif (intersected || (P0.x * stepDir) > end) break;\n}\nif (intersected && pixelStride > 1.0) {\nPQK -= dPQK;\ndPQK /= ssrStride;\nfloat ogStride = pixelStride * 0.5;\nfloat currStride = pixelStride;\nprevZMaxEstimate = PQK.z / PQK.w;\nrayZMin = prevZMaxEstimate, rayZMax = prevZMaxEstimate;\nfor(int j = 0; j < int(BINARY_SEARCH_ITERATIONS); j ++) {\nPQK += dPQK * currStride;\nrayZMin = prevZMaxEstimate;\nrayZMax = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);\nprevZMaxEstimate = rayZMax;\nswapIfBigger(rayZMax, rayZMin);\nvec2 newUV = (permute ? PQK.yx: PQK.xy) / ssrResolution;\nogStride *= 0.5;\nif (doesIntersect(rayZMax, rayZMin, newUV)) {\nhitUV = newUV;\ncurrStride = -ogStride;\n} else {\ncurrStride = ogStride;\n}\n}\n}\nvec3 result = color;\n#ifdef USE_SSR_REFRACT\n#endif\nif (intersected) {\nvec4 col = texture2D(ssrSourceBuffer, hitUV);\nvec2 ndc = abs(hitUV * 2.0 - 1.0);\nfloat maxndc = max(ndc.x, ndc.y);\nfloat fadeVal =\n(1.0 - (max(0.0, maxndc - SCREEN_FADE_THRESHOLD) / (1.0 - SCREEN_FADE_THRESHOLD))) *\n(1.0 - STEPS_FADE_AMOUNT * (stepped / float(MAX_STEPS)));\ncol.a = fadeVal;\nresult = mix(result, col.rgb, col.a);\n}\n#else\nvec3 result = texture2D(ssrSourceBuffer, P1).xyz;\n#endif\nreturn result;\n}\n#endif",plane_reflection_pars_vertex:"#ifdef USE_PLANE_REFLECTION\nuniform mat4 planeReflTextureMatrix;\nvarying vec4 vPlaneReflUv;\n#endif",plane_reflection_pars_fragment:"#ifdef USE_PLANE_REFLECTION\nuniform sampler2D planeReflTexture;\nuniform mat4 planeReflTextureMatrix;\nuniform vec3 planeReflDir;\nuniform vec3 planeReflBoundingBoxMin;\nuniform vec3 planeReflBoundingBoxMax;\nuniform mat4 planeReflInvModelMatrix;\nuniform float planeReflFalloff;\nvarying vec4 vPlaneReflUv;\nvec3 computePlaneReflection(vec3 radiance, float roughness, vec3 position, vec3 normal, mat4 modelMatrix) {\nvec3 posRefl = (planeReflInvModelMatrix * invViewMatrix * vec4(position, 1.0)).xyz;\nif (any(lessThan(posRefl, planeReflBoundingBoxMin)) || any(greaterThan(posRefl, planeReflBoundingBoxMax)))\nreturn radiance;\nvec3 norWorld = transformDirection(normal, invViewMatrix);\nvec3 uvNormalOffsetScale;\nuvNormalOffsetScale.x = length(vec3(modelMatrix[0].xyz));\nuvNormalOffsetScale.y = length(vec3(modelMatrix[1].xyz));\nuvNormalOffsetScale.z = length(vec3(modelMatrix[2].xyz));\nvec4 uvNormalOffset = planeReflTextureMatrix * vec4((norWorld - planeReflDir) * uvNormalOffsetScale, 0.0);\nvec3 result = texture2DProj(planeReflTexture, vPlaneReflUv + uvNormalOffset).rgb;\nfloat falloffFactor;\nif (planeReflFalloff < EPSILON)\nfalloffFactor = 0.0;\nelse if (posRefl.y > 0.0)\nfalloffFactor = 1.0 - clamp((planeReflBoundingBoxMax.y - posRefl.y) / (planeReflBoundingBoxMax.y * (planeReflFalloff)), 0.0, 1.0);\nelse\nfalloffFactor = 1.0 - clamp((planeReflBoundingBoxMin.y - posRefl.y) / (planeReflBoundingBoxMin.y * (planeReflFalloff)), 0.0, 1.0);\nresult = mix(result, radiance, falloffFactor);\nresult = mix(result, radiance, (roughness < 0.0526) ? 0.0 : saturate(10.0*roughness));\nreturn result;\n}\n#endif",plane_reflection_vertex:"#ifdef USE_PLANE_REFLECTION\nvPlaneReflUv = planeReflTextureMatrix * modelMatrix * vec4(position, 1.0);\n#endif",node_common_frag:"\n#define LUM_WEIGHTS vec3(0.2126, 0.7152, 0.0722)\n#define LUM_WEIGHTS_MAYA vec3(0.3, 0.59, 0.11)\n#define LUMENS_PER_WATT 683.0\n#define MAX_ENV_COORDS_DIR 0\n#define MAX_ENV_COORDS_REFLECT 1\n#define MAX_ENV_COORDS_REFRACT 2\n#if defined(NODE_COLOR_CONVERT_AR) || defined(NODE_COLOR_CORRECT_AR) || defined(NODE_COMBINE_COLOR_BL) || defined(NODE_SEPARATE_COLOR_BL) || defined(NODE_COMBHSV_BL) || defined(NODE_SEPHSV_BL) || defined(NODE_HUE_SAT_BL) || defined(NODE_COLOR_CORRECTION_MX) || defined(NODE_COMPOSITE_LAYER_MX) || defined(NODE_COLOR_CORRECT_MY) || defined(USE_OSL)\n#define HSV_NODES\n#endif\nvec4 nodeTexelToLinear(in vec4 color, in int sourceType) {\nif (sourceType == 1) {\nreturn vec4(pow(color.rgb, vec3(2.2)), color.a);\n}else\nreturn color;\n}\n#if defined HSV_NODES\nvoid hsvToRGB(vec4 hsv, out vec4 outCol)\n{\nfloat i, f, p, q, t, h, s, v;\nvec3 rgb;\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\nif (s == 0.0)\nrgb = vec3(v, v, v);\nelse {\nif (h == 1.0)\nh = 0.0;\nh *= 6.0;\ni = floor(h);\nf = h - i;\nrgb = vec3(f, f, f);\np = v * (1.0 - s);\nq = v * (1.0 - (s * f));\nt = v * (1.0 - (s * (1.0 - f)));\nif (i == 0.0)\nrgb = vec3(v, t, p);\nelse if (i == 1.0)\nrgb = vec3(q, v, p);\nelse if (i == 2.0)\nrgb = vec3(p, v, t);\nelse if (i == 3.0)\nrgb = vec3(p, q, v);\nelse if (i == 4.0)\nrgb = vec3(t, p, v);\nelse\nrgb = vec3(v, p, q);\n}\noutCol = vec4(rgb, hsv.w);\n}\nvoid rgbToHSV(vec4 rgb, out vec4 outCol)\n{\nfloat cmax, cmin, h, s, v, cdelta;\nvec3 c;\ncmax = max(rgb[0], max(rgb[1], rgb[2]));\ncmin = min(rgb[0], min(rgb[1], rgb[2]));\ncdelta = cmax - cmin;\nv = cmax;\nif (cmax != 0.0)\ns = cdelta / cmax;\nelse {\ns = 0.0;\nh = 0.0;\n}\nif (s == 0.0)\nh = 0.0;\nelse {\nc = (vec3(cmax, cmax, cmax) - rgb.xyz) / cdelta;\nif (rgb.x == cmax) h = c[2] - c[1];\nelse if (rgb.y == cmax) h = 2.0 + c[0] - c[2];\nelse h = 4.0 + c[1] - c[0];\nh /= 6.0;\nif (h < 0.0)\nh += 1.0;\n}\noutCol = vec4(h, s, v, rgb.w);\n}\n#endif\nbool isPerspective(const mat4 projMatrix)\n{\nreturn (projMatrix[3][3] == 0.0);\n}\n#if defined(NODE_REFLECT_REFRACT_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_SKYDOME_LIGHT_AR) || defined(NODE_ENV_SPHERE_MY)\nvec4 sampleEquirectangular(sampler2D map, vec3 reflectVec, mat3 uvTransform, int encoding)\n{\nreflectVec = normalize(reflectVec);\nvec2 sampleUV;\nsampleUV.y = asin(clamp(reflectVec.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nsampleUV.x = atan(reflectVec.x, reflectVec.z) * RECIPROCAL_PI2 + 0.5;\nsampleUV.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (reflectVec.x) / seamWidth) *\nclamp (1.0 - reflectVec.z / seamWidth, 0.0, 1.0);\nsampleUV = (uvTransform * vec3(sampleUV, 1.0)).xy;\nreturn texture2D(map, sampleUV, seamBiasFactor * seam);\n}\n#endif\n#if defined(NODE_FRESNEL_BL) || defined(NODE_LAYER_WEIGHT_BL) || defined(NODE_FALLOFF_MX) || defined(NODE_BSDF_GLASS_BL) || defined(NODE_BSDF_PRINCIPLED_BL)\nfloat fresnelReflection(const vec3 dir, const vec3 normal, const float ior) {\nfloat cosTheta = clamp(abs(dot(dir, normal)), -1.0, 1.0);\nfloat gSquared = pow2(ior) + pow2(cosTheta) - 1.0;\nif (gSquared < 0.0) return 1.0;\nfloat g = sqrt(gSquared);\nreturn 0.5 * pow2((g - cosTheta) / (g + cosTheta))\n* (1.0 + pow2(\n((g + cosTheta) * cosTheta - 1.0) /\n((g - cosTheta) * cosTheta + 1.0)\n));\n}\n#endif\n#if defined(NODE_BITMAP_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_GRADIENT_RAMP_MX)\n#define MAPPING_EXPLICIT_MAP_CHANNEL 1\n#define MAPPING_VERTEX_COLOR_CHANNEL 2\n#define MAPPING_PLANAR_OBJECT_XYZ 3\n#define MAPPING_PLANAR_WORLD_XYZ 4\n#define AXIS_XY 1\n#define AXIS_YZ 2\n#define AXIS_ZX 3\n#endif\n#if defined(NODE_BITMAP_MX) || defined(NODE_BITMAP_ENV_MX) || defined(NODE_BUMP_MX) || defined(NODE_GRADIENT_RAMP_MX) || defined(NODE_PLACE_2D_TEXTURE_MY)\nmat3 calcUvTransform(float uOffset, float vOffset, float uTiling, float vTiling, float wAngle)\n{\nif (abs(uOffset) < EPSILON && abs(vOffset) < EPSILON &&\n(abs(uTiling - 1.0)) < EPSILON && (abs(vTiling - 1.0)) < EPSILON &&\nabs(wAngle) < EPSILON)\nreturn mat3(1.0);\nfloat sx = uTiling;\nfloat sy = vTiling;\nfloat c = cos(-wAngle);\nfloat s = sin(-wAngle);\n#if defined(NODE_PLACE_2D_TEXTURE_MY)\nfloat tx = uOffset;\nfloat ty = vOffset;\nfloat cx = 0.5;\nfloat cy = 0.5;\nreturn mat3(c*sx, s*sx, 0.0,\n-s*sy, c*sy, 0.0,\ns*(ty+sy-cy)+c*(tx-cx)+cx, -c*(ty+sy-cy)+s*(tx-cx)-cy+1.0, 1.0);\n#else\nfloat tx = -uOffset;\nfloat ty = -vOffset;\nfloat cx = uOffset + 0.5;\nfloat cy = vOffset + 0.5;\nreturn mat3(sx * c, -sy * s, 0.0,\nsx * s, sy * c, 0.0,\n-sx * (c * cx + s * cy) + cx + tx, -sy * (- s * cx + c * cy) + cy + ty, 1.0);\n#endif\n}\n#endif\n#if defined(NODE_NOISE_MX)\nmat4 calcXYZTransform(vec3 offset, vec3 tiling, vec3 angle) {\nmat4 rot = mat4(\ncos(angle.y)*cos(angle.z), cos(angle.x)*sin(angle.z)+sin(angle.x)*sin(angle.y)*cos(angle.z), sin(angle.x)*sin(angle.z)-cos(angle.x)*sin(angle.y)*cos(angle.z), 0.0,\n-cos(angle.y)*sin(angle.z), cos(angle.x)*cos(angle.z)-sin(angle.x)*sin(angle.y)*sin(angle.z), cos(angle.x)*sin(angle.y)*sin(angle.z)+sin(angle.x)*cos(angle.z), 0.0,\nsin(angle.y), -sin(angle.x)*cos(angle.y), cos(angle.x)*cos(angle.y), 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nmat4 til = mat4(\ntiling.x, 0.0, 0.0, 0.0,\n0.0, tiling.y, 0.0, 0.0,\n0.0, 0.0, tiling.z, 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nmat4 off = mat4(\n1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\noffset.x, offset.y, offset.z, 1.0\n);\nreturn (til * rot * off);\n}\n#endif\n#if defined(NODE_TEX_NOISE_BL) || defined(NODE_TEX_WAVE_BL) || defined(NODE_NOISE_MX) || defined(USE_OSL) || defined(NODE_NOISE_MY)\n#define NOISE_AMP_HACK 0.75\n#define NOISE_BLENDER_MEAN 0.78\n#define NOISE_SCALE_HACK 0.5\n#define noiseModulo(x) (x - floor(x * (1.0 / 289.0)) * 289.0)\nvec4 noisePermute(vec4 x) {\nreturn noiseModulo(((x * 34.0) + 1.0) * x);\n}\nvec4 taylorInvSqrt(vec4 r) {\nreturn 1.79284291400159 - 0.85373472095314 * r;\n}\nfloat taylorInvSqrt(float r) {\nreturn 1.79284291400159 - 0.85373472095314 * r;\n}\nfloat noisePerlin(vec3 v) {\nconst vec2 C = vec2(1.0 / 6.0, 1.0 / 3.0);\nconst vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\nvec3 i = floor(v + dot(v, C.yyy));\nvec3 x0 = v - i + dot(i, C.xxx);\nvec3 g = step(x0.yzx, x0.xyz);\nvec3 l = 1.0 - g;\nvec3 i1 = min(g.xyz, l.zxy);\nvec3 i2 = max(g.xyz, l.zxy);\nvec3 x1 = x0 - i1 + C.xxx;\nvec3 x2 = x0 - i2 + C.yyy;\nvec3 x3 = x0 - D.yyy;\ni = noiseModulo(i);\nvec4 p = noisePermute(noisePermute(noisePermute(i.z + vec4(0.0, i1.z, i2.z, 1.0))\n+ i.y + vec4(0.0, i1.y, i2.y, 1.0)) + i.x + vec4(0.0, i1.x, i2.x, 1.0));\nfloat n_ = 0.142857142857;\nvec3 ns = n_ * D.wyz - D.xzx;\nvec4 j = p - 49.0 * floor(p * ns.z * ns.z);\nvec4 x_ = floor(j * ns.z);\nvec4 y_ = floor(j - 7.0 * x_);\nvec4 x = x_ * ns.x + ns.yyyy;\nvec4 y = y_ * ns.x + ns.yyyy;\nvec4 h = 1.0 - abs(x) - abs(y);\nvec4 b0 = vec4(x.xy, y.xy);\nvec4 b1 = vec4(x.zw, y.zw);\nvec4 s0 = floor(b0) * 2.0 + 1.0;\nvec4 s1 = floor(b1) * 2.0 + 1.0;\nvec4 sh = -step(h, vec4(0.0));\nvec4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;\nvec4 a1 = b1.xzyw + s1.xzyw * sh.zzww;\nvec3 p0 = vec3(a0.xy, h.x);\nvec3 p1 = vec3(a0.zw, h.y);\nvec3 p2 = vec3(a1.xy, h.z);\nvec3 p3 = vec3(a1.zw, h.w);\nvec4 norm = taylorInvSqrt(vec4(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));\np0 *= norm.x;\np1 *= norm.y;\np2 *= norm.z;\np3 *= norm.w;\nvec4 m = max(0.6 - vec4(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), 0.0);\nm = m * m;\nreturn 42.0 * dot(m * m, vec4(dot(p0, x0), dot(p1, x1),\ndot(p2, x2), dot(p3, x3)));\n}\nvec4 permute(vec4 x) {\nreturn mod(((x*34.0)+1.0)*x, 289.0);\n}\nfloat permute(float x) {\nreturn floor(mod(((x*34.0)+1.0)*x, 289.0));\n}\nvec4 grad4(float j, vec4 ip) {\nconst vec4 ones = vec4(1.0, 1.0, 1.0, -1.0);\nvec4 p,s;\np.xyz = floor( fract (vec3(j) * ip.xyz) * 7.0) * ip.z - 1.0;\np.w = 1.5 - dot(abs(p.xyz), ones.xyz);\ns = vec4(lessThan(p, vec4(0.0)));\np.xyz = p.xyz + (s.xyz*2.0 - 1.0) * s.www;\nreturn p;\n}\nfloat snoise(vec4 v) {\nconst vec2 C = vec2(0.138196601125010504,\n0.309016994374947451);\nvec4 i = floor(v + dot(v, C.yyyy) );\nvec4 x0 = v - i + dot(i, C.xxxx);\nvec4 i0;\nvec3 isX = step( x0.yzw, x0.xxx );\nvec3 isYZ = step( x0.zww, x0.yyz );\ni0.x = isX.x + isX.y + isX.z;\ni0.yzw = 1.0 - isX;\ni0.y += isYZ.x + isYZ.y;\ni0.zw += 1.0 - isYZ.xy;\ni0.z += isYZ.z;\ni0.w += 1.0 - isYZ.z;\nvec4 i3 = clamp( i0, 0.0, 1.0 );\nvec4 i2 = clamp( i0-1.0, 0.0, 1.0 );\nvec4 i1 = clamp( i0-2.0, 0.0, 1.0 );\nvec4 x1 = x0 - i1 + 1.0 * C.xxxx;\nvec4 x2 = x0 - i2 + 2.0 * C.xxxx;\nvec4 x3 = x0 - i3 + 3.0 * C.xxxx;\nvec4 x4 = x0 - 1.0 + 4.0 * C.xxxx;\ni = mod(i, 289.0);\nfloat j0 = permute( permute( permute( permute(i.w) + i.z) + i.y) + i.x);\nvec4 j1 = permute( permute( permute( permute (\ni.w + vec4(i1.w, i2.w, i3.w, 1.0 ))\n+ i.z + vec4(i1.z, i2.z, i3.z, 1.0 ))\n+ i.y + vec4(i1.y, i2.y, i3.y, 1.0 ))\n+ i.x + vec4(i1.x, i2.x, i3.x, 1.0 ));\nvec4 ip = vec4(1.0/294.0, 1.0/49.0, 1.0/7.0, 0.0) ;\nvec4 p0 = grad4(j0, ip);\nvec4 p1 = grad4(j1.x, ip);\nvec4 p2 = grad4(j1.y, ip);\nvec4 p3 = grad4(j1.z, ip);\nvec4 p4 = grad4(j1.w, ip);\nvec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\np0 *= norm.x;\np1 *= norm.y;\np2 *= norm.z;\np3 *= norm.w;\np4 *= taylorInvSqrt(dot(p4,p4));\nvec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.0);\nvec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.0);\nm0 = m0 * m0;\nm1 = m1 * m1;\nreturn 49.0 * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))\n+ dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;\n}\nfloat noiseBlender(vec3 p) {\nreturn 0.5 * NOISE_AMP_HACK * (noisePerlin(NOISE_SCALE_HACK * vec3(p.x, p.y, p.z))) + 0.5;\n}\nfloat noiseSmooth(vec3 p, float octaveLenPerPixel, float falloffFactor,\nfloat dispersionFactor) {\nfloat mixFac = mix(1.0, smoothstep(0.0, 1.0, octaveLenPerPixel) * falloffFactor,\ndispersionFactor);\nreturn mix(noiseBlender(p), NOISE_BLENDER_MEAN, mixFac);\n}\n#define MAX_OCTAVES_NUM 16\nfloat noiseTurbulence(vec3 p, float octaves, float octaveLenPerPixel,\nfloat falloffFactor, float dispersionFactor) {\nfloat fscale = 1.0;\nfloat amp = 1.0;\nfloat sum = 0.0;\noctaves = clamp(octaves, 0.0, 16.0);\nint octavesInt = int(octaves);\nfor (int i = 0; i <= MAX_OCTAVES_NUM; i++) {\n#if __VERSION__ == 300\nif (i <= octavesInt) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n} else {\ni = MAX_OCTAVES_NUM;\n}\n#else\nif (i > octavesInt) break;\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nsum += t * amp;\namp *= 0.5;\nfscale *= 2.0;\noctaveLenPerPixel *= 2.0;\n#endif\n}\nfloat octavesFrac = fract(octaves);\nfloat octavesCoeff = pow(2.0, float(octavesInt));\nif (octavesFrac != 0.0) {\nfloat t = noiseSmooth(fscale * p, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nfloat sum2 = sum + t * amp;\nsum *= octavesCoeff / (2.0 * octavesCoeff - 1.0);\nsum2 *= 2.0 * octavesCoeff / (4.0 * octavesCoeff - 1.0);\nreturn mix(sum, sum2, octavesFrac);\n} else {\nreturn sum * octavesCoeff / (2.0 * octavesCoeff - 1.0);\n}\n}\n#endif\n#if (defined(USE_OSL) || defined(NODE_WAVELENGTH_BL)) && __VERSION__ == 300\nvec3 cieColorMatch[81] = vec3[](\nvec3(0.0014,0.0000,0.0065), vec3(0.0022,0.0001,0.0105), vec3(0.0042,0.0001,0.0201),\nvec3(0.0076,0.0002,0.0362), vec3(0.0143,0.0004,0.0679), vec3(0.0232,0.0006,0.1102),\nvec3(0.0435,0.0012,0.2074), vec3(0.0776,0.0022,0.3713), vec3(0.1344,0.0040,0.6456),\nvec3(0.2148,0.0073,1.0391), vec3(0.2839,0.0116,1.3856), vec3(0.3285,0.0168,1.6230),\nvec3(0.3483,0.0230,1.7471), vec3(0.3481,0.0298,1.7826), vec3(0.3362,0.0380,1.7721),\nvec3(0.3187,0.0480,1.7441), vec3(0.2908,0.0600,1.6692), vec3(0.2511,0.0739,1.5281),\nvec3(0.1954,0.0910,1.2876), vec3(0.1421,0.1126,1.0419), vec3(0.0956,0.1390,0.8130),\nvec3(0.0580,0.1693,0.6162), vec3(0.0320,0.2080,0.4652), vec3(0.0147,0.2586,0.3533),\nvec3(0.0049,0.3230,0.2720), vec3(0.0024,0.4073,0.2123), vec3(0.0093,0.5030,0.1582),\nvec3(0.0291,0.6082,0.1117), vec3(0.0633,0.7100,0.0782), vec3(0.1096,0.7932,0.0573),\nvec3(0.1655,0.8620,0.0422), vec3(0.2257,0.9149,0.0298), vec3(0.2904,0.9540,0.0203),\nvec3(0.3597,0.9803,0.0134), vec3(0.4334,0.9950,0.0087), vec3(0.5121,1.0000,0.0057),\nvec3(0.5945,0.9950,0.0039), vec3(0.6784,0.9786,0.0027), vec3(0.7621,0.9520,0.0021),\nvec3(0.8425,0.9154,0.0018), vec3(0.9163,0.8700,0.0017), vec3(0.9786,0.8163,0.0014),\nvec3(1.0263,0.7570,0.0011), vec3(1.0567,0.6949,0.0010), vec3(1.0622,0.6310,0.0008),\nvec3(1.0456,0.5668,0.0006), vec3(1.0026,0.5030,0.0003), vec3(0.9384,0.4412,0.0002),\nvec3(0.8544,0.3810,0.0002), vec3(0.7514,0.3210,0.0001), vec3(0.6424,0.2650,0.0000),\nvec3(0.5419,0.2170,0.0000), vec3(0.4479,0.1750,0.0000), vec3(0.3608,0.1382,0.0000),\nvec3(0.2835,0.1070,0.0000), vec3(0.2187,0.0816,0.0000), vec3(0.1649,0.0610,0.0000),\nvec3(0.1212,0.0446,0.0000), vec3(0.0874,0.0320,0.0000), vec3(0.0636,0.0232,0.0000),\nvec3(0.0468,0.0170,0.0000), vec3(0.0329,0.0119,0.0000), vec3(0.0227,0.0082,0.0000),\nvec3(0.0158,0.0057,0.0000), vec3(0.0114,0.0041,0.0000), vec3(0.0081,0.0029,0.0000),\nvec3(0.0058,0.0021,0.0000), vec3(0.0041,0.0015,0.0000), vec3(0.0029,0.0010,0.0000),\nvec3(0.0020,0.0007,0.0000), vec3(0.0014,0.0005,0.0000), vec3(0.0010,0.0004,0.0000),\nvec3(0.0007,0.0002,0.0000), vec3(0.0005,0.0002,0.0000), vec3(0.0003,0.0001,0.0000),\nvec3(0.0002,0.0001,0.0000), vec3(0.0002,0.0001,0.0000), vec3(0.0001,0.0000,0.0000),\nvec3(0.0001,0.0000,0.0000), vec3(0.0001,0.0000,0.0000), vec3(0.0000,0.0000,0.0000)\n);\n#endif\n#if defined(USE_OSL) || defined(NODE_BLACKBODY_BL)\nvec3 colorTempToRGB(float temp)\n{\nvec3 retColor;\ntemp = clamp(temp, 100.0, 40000.0) / 100.0;\nif (temp <= 66.0) {\nretColor.r = 1.0;\nretColor.g = saturate(0.390081578 * log(temp) - 0.631841443);\n} else {\nfloat t = temp - 60.0;\nretColor.r = saturate(1.292936186 * pow(t, -0.133204759));\nretColor.g = saturate(1.129890860 * pow(t, -0.075514849));\n}\nif (temp >= 66.0)\nretColor.b = 1.0;\nelse if (temp <= 19.0)\nretColor.b = 0.0;\nelse\nretColor.b = saturate(0.543206789 * log(temp - 10.0) - 1.196254089);\nretColor.rgb = pow(retColor.rgb, vec3(2.2));\nreturn retColor;\n}\n#endif\n#ifdef USE_OSL\n#define M_PI PI\n#define M_PI_2 PI / 2.0\n#define M_PI_4 PI / 4.0\n#define M_2_PI 2.0 / PI\n#define M_2PI 2.0 * PI\n#define M_4PI 4.0 * PI\n#define M_2_SQRTPI 2.0 / sqrt(PI)\n#define M_E 2.718281828459\n#define M_LN2 0.69314718056\n#define M_LN10 2.30258509299\n#define M_LOG2E 1.4426950409\n#define M_LOG10E 0.43429448190\n#define M_SQRT2 sqrt(2.0)\n#define M_SQRT1_2 sqrt(0.5)\n#define OSL_ALPHA 33633\n#define OSL_ANISOTROPIC 40205\n#define OSL_AVERAGEALPHA 57701\n#define OSL_AVERAGECOLOR 46077\n#define OSL_BANDWIDTH 37485\n#define OSL_BEZIER 27645\n#define OSL_BLACK 62409\n#define OSL_BSPLINE 16959\n#define OSL_CAMERA 8198\n#define OSL_CAMERA_CLIP 34380\n#define OSL_CAMERA_CLIP_FAR 31933\n#define OSL_CAMERA_CLIP_NEAR 21485\n#define OSL_CAMERA_FOV 60706\n#define OSL_CAMERA_PIXELASPECT 4950\n#define OSL_CAMERA_PROJECTION 29369\n#define OSL_CAMERA_RESOLUTION 39679\n#define OSL_CAMERA_SCREEN_WINDOW 47009\n#define OSL_CAMERA_SHUTTER 7107\n#define OSL_CAMERA_SHUTTER_CLOSE 34406\n#define OSL_CAMERA_SHUTTER_OPEN 40085\n#define OSL_CATMULL_ROM 31642\n#define OSL_CELL 20984\n#define OSL_CHANNELS 8726\n#define OSL_CLAMP 20052\n#define OSL_COLOR 53753\n#define OSL_COMMON 49871\n#define OSL_CONSTANT 25144\n#define OSL_DATAWINDOW 54276\n#define OSL_DEFAULT 54870\n#define OSL_DIFFUSE 40389\n#define OSL_DIRECTION 42220\n#define OSL_DISPLAYWINDOW 30728\n#define OSL_DISTANCE 51337\n#define OSL_DO_FILTER 35765\n#define OSL_EMPTY 9314\n#define OSL_ERRORMESSAGE 38305\n#define OSL_EXISTS 41510\n#define OSL_FILL 39132\n#define OSL_FIRSTCHANNEL 48155\n#define OSL_GABOR 57764\n#define OSL_GEOM_NAME 63686\n#define OSL_GLOSSY 47998\n#define OSL_HASH 49390\n#define OSL_HERMITE 63643\n#define OSL_HIT 48491\n#define OSL_HITDIST 22029\n#define OSL_HSL 49898\n#define OSL_HSV 29073\n#define OSL_IMPULSES 56191\n#define OSL_INDEX 1731\n#define OSL_INTERP 10557\n#define OSL_LINEAR 2182\n#define OSL_MIRROR 64591\n#define OSL_MISSINGALPHA 39755\n#define OSL_MISSINGCOLOR 51667\n#define OSL_NDC 48899\n#define OSL_NORMAL 16520\n#define OSL_OBJECT 59084\n#define OSL_OSL_VERSION 47920\n#define OSL_PERIODIC 8749\n#define OSL_PERLIN 730\n#define OSL_POSITION 43041\n#define OSL_RASTER 2618\n#define OSL_REFLECTION 37621\n#define OSL_REFRACTION 37287\n#define OSL_RESOLUTION 48704\n#define OSL_RGB 26673\n#define OSL_RWRAP 47801\n#define OSL_SCREEN 55875\n#define OSL_SHADER 21066\n#define OSL_SHADER_GROUPNAME 62327\n#define OSL_SHADER_LAYERNAME 51796\n#define OSL_SHADER_SHADERNAME 65123\n#define OSL_SHADOW 60708\n#define OSL_SIMPLEX 61636\n#define OSL_SUBIMAGE 33526\n#define OSL_SUBIMAGES 2366\n#define OSL_SWRAP 4328\n#define OSL_TEXTUREFORMAT 17851\n#define OSL_TIME 52235\n#define OSL_TRACE 62908\n#define OSL_TWRAP 30524\n#define OSL_TYPE 64071\n#define OSL_UPERLIN 65308\n#define OSL_USIMPLEX 11314\n#define OSL_WIDTH 48751\n#define OSL_WORLD 9059\n#define OSL_WORLDTOCAMERA 32273\n#define OSL_WORLDTOSCREEN 33876\n#define OSL_WRAP 58300\n#define OSL_XYY 2228\n#define OSL_XYZ 47351\n#define OSL_YIQ 15839\nvec3 oslGetP(vec3 viewPos) {\n#if WORLD_NODES == 1\nreturn swizzleUpZ((invViewMatrix * vec4(-viewPos, 0.0)).xyz);\n#else\nreturn swizzleUpZ((invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n#endif\n}\nvec3 oslGetI(vec3 viewPos) {\n#if WORLD_NODES == 1\nreturn swizzleUpZ((invViewMatrix * vec4(normalize(-viewPos), 0.0)).xyz);\n#else\nreturn swizzleUpZ((invViewMatrix * vec4(normalize(-viewPos), 0.0)).xyz);\n#endif\n}\nvec3 oslGetN(vec3 viewNorm) {\nreturn swizzleUpZ(normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz);\n}\nvec3 oslBlackbody(float temperatureK) {\nreturn vec4(colorTempToRGB(temperatureK), 1.0).rgb;\n}\nfloat oslDistance(vec3 p0, vec3 p1) {\nreturn distance(p0, p1);\n}\nfloat oslDistance(vec3 p0, vec3 p1, vec3 q) {\nvec3 d = p1 - p0;\nfloat dd = dot(d, d);\nif (dd == 0.0)\nreturn distance(q, p0);\nfloat t = dot(q - p0, d) / dd;\nreturn distance(q, p0 + clamp(t, 0.0, 1.0) * d);\n}\nint oslEndsWith(int name1, int name2) {\nreturn int(name1 == name2);\n}\nint oslFormat(int name1, int name2) {\nreturn name2;\n}\nint oslGetAttribute(int name, out int value) {\nvalue = 0;\nreturn 0;\n}\nint oslGetAttribute(int name, out float value) {\nvalue = 0.0;\nreturn 0;\n}\nint oslGetAttribute(int name, out vec3 vec) {\nvec = vec3(0.0, 0.0, 0.0);\nreturn 0;\n}\nvoid oslGetTextureInfo(int filename, int name, out int value) {\nvalue = 4;\n}\nvoid oslGetTextureInfo(int filename, int name, out int value[2]) {\nvalue[0] = 1024;\nvalue[1] = 1024;\n}\nvec3 oslHSV(float h, float s, float v) {\nvec4 outCol;\nhsvToRGB(vec4(h, s, v, 1.0), outCol);\nreturn outCol.rgb;\n}\nfloat oslHypot(float x, float y) {\nreturn sqrt(x*x + y*y);\n}\nfloat oslHypot(float x, float y, float z) {\nreturn sqrt(x*x + y*y + z*z);\n}\nfloat oslLog2(float x, float y) {\nreturn log(x) / log(y);\n}\nfloat oslLuminance(vec3 color) {\nreturn linearToRelativeLuminance(color);\n}\nfloat oslNoise(int type, vec3 vec, float phase) {\nfloat n = snoise(vec4(vec, phase));\nif (type == OSL_UPERLIN)\nn = n * 0.5 + 0.5;\nreturn n;\n}\nfloat oslNoise(int type, float value, float phase) {\nreturn oslNoise(type, vec3(value), phase);\n}\nfloat oslNoise(int type, vec3 vec) {\nreturn oslNoise(type, vec, 0.0);\n}\nfloat oslNoise(int type, float value) {\nreturn oslNoise(type, vec3(value), 0.0);\n}\nvec3 oslNoise3D(int type, vec3 vec, float phase) {\nfloat x = snoise(vec4(vec, phase));\nfloat y = snoise(vec4(vec.y, vec.x, vec.z, phase));\nfloat z = snoise(vec4(vec.y, vec.z, vec.x, phase));\nvec3 n = vec3(x, y, z);\nif (type == OSL_UPERLIN)\nn = n * 0.5 + 0.5;\nreturn n;\n}\nvec3 oslNoise3D(int type, float value, float phase) {\nreturn oslNoise3D(type, vec3(value), phase);\n}\nvec3 oslNoise3D(int type, vec3 vec) {\nreturn oslNoise3D(type, vec, 0.0);\n}\nvec3 oslNoise3D(int type, float value) {\nreturn oslNoise3D(type, vec3(value), 0.0);\n}\nfloat oslPow(float a, float b) {\nreturn pow(a, b);\n}\nvec3 oslPow(vec3 a, float b) {\nreturn pow(a, vec3(b));\n}\nint oslRayType(int name) {\nif (name == OSL_CAMERA)\n#if LIGHT_PATH_IS_CAM_RAY\nreturn 1;\n#else\nreturn 0;\n#endif\nelse\nreturn 0;\n}\nvec3 oslRotate(vec3 vec, float angle, vec3 p0, vec3 p1) {\nvec3 axis = normalize(p1 - p0);\nfloat c = cos(angle);\nfloat s = sin(angle);\nfloat x = axis[0];\nfloat y = axis[1];\nfloat z = axis[2];\nmat4 mat = mat4(\nx * x + (1.0 - x * x) * c, x * y * (1.0 - c) + z * s, x * z * (1.0 - c) - y * s, 0.0,\nx * y * (1.0 - c) - z * s, y * y + (1.0 - y * y) * c, y * z * (1.0 - c) + x * s, 0.0,\nx * z * (1.0 - c) + y * s, y * z * (1.0 - c) - x * s, z * z + (1.0 - z * z) * c, 0.0,\n0.0, 0.0, 0.0, 1.0\n);\nreturn (mat * vec4((vec - p0), 1.0) + vec4(p0, 1.0)).xyz;\n}\nvec3 oslRotate(vec3 vec, float angle, vec3 axis) {\nreturn oslRotate(vec, angle, vec3(0.0), axis);\n}\nint oslStartsWith(int name1, int name2) {\nreturn int(name1 == name2);\n}\nint oslStrLen(int name) {\nif (name == OSL_EMPTY)\nreturn 0;\nelse\nreturn 1;\n}\nint oslSubStr(int s, int start, int len) {\nreturn s;\n}\nint oslSubStr(int s, int start) {\nreturn s;\n}\nvec3 oslTexture(sampler2D image, float u, float v, int wrapModeFlag, int wrapMode, int alphaFlag, out float alpha) {\nif (wrapMode == OSL_DEFAULT || wrapMode == OSL_BLACK) {\nif (u < 0.0 || u > 1.0 || v < 0.0 || v > 1.0)\nreturn vec3(0.0);\n} else if (wrapMode == OSL_CLAMP) {\nu = clamp(u, 0.0, 1.0);\nv = clamp(v, 0.0, 1.0);\n} else if (wrapMode == OSL_PERIODIC) {\nu = mod(u, 1.0);\nv = mod(v, 1.0);\n} else if (wrapMode == OSL_MIRROR) {\nif (mod(floor(u), 2.0) == 0.0)\nu = u - floor(u);\nelse\nu = 1.0 - (u - floor(u));\nif (mod(floor(v), 2.0) == 0.0)\nv = v - floor(v);\nelse\nv = 1.0 - (v - floor(v));\n}\nvec4 colAlpha = texture2D(image, vec2(u, v));\nalpha = colAlpha.a;\nreturn colAlpha.rgb;\n}\nvec3 oslTexture(sampler2D image, float u, float v, int alphaFlag, out float alpha, int wrapModeFlag, int wrapMode) {\nreturn oslTexture(image, u, v, wrapModeFlag, wrapMode, alphaFlag, alpha);\n}\nvec3 oslTexture(sampler2D image, float u, float v, int alphaFlag, out float alpha) {\nreturn oslTexture(image, u, v, OSL_WRAP, OSL_DEFAULT, alphaFlag, alpha);\n}\nvec3 oslTexture(sampler2D image, float u, float v, int wrapModeFlag, int wrapMode) {\nfloat alpha;\nreturn oslTexture(image, u, v, wrapModeFlag, wrapMode, OSL_ALPHA, alpha);\n}\nvec3 oslTexture(sampler2D image, float u, float v) {\nfloat alpha;\nreturn oslTexture(image, u, v, OSL_WRAP, OSL_DEFAULT, OSL_ALPHA, alpha);\n}\nvec3 oslTransform(int fromSpace, int toSpace, vec4 vec) {\nif (toSpace == OSL_WORLD || toSpace == OSL_SHADER || toSpace == OSL_COMMON) {\nreturn vec.xyz;\n} else if (toSpace == OSL_OBJECT) {\nvec = vec4(swizzleUpY(vec.xyz), vec.w);\nvec = invModelMatrix * vec;\nreturn swizzleUpZ(vec.xyz);\n} else if (toSpace == OSL_CAMERA) {\nvec = vec4(swizzleUpY(vec.xyz), vec.w);\nreturn (viewMatrix * vec).xyz;\n} else if (toSpace == OSL_SCREEN) {\nreturn vec.xyz;\n} else if (toSpace == OSL_RASTER) {\nreturn gl_FragCoord.xyz;\n} else if (toSpace == OSL_NDC) {\nreturn vec.xyz;\n} else {\nreturn vec.xyz;\n}\n}\nvec3 oslTransform(int fromSpace, int toSpace, vec3 vec) {\nreturn oslTransform(fromSpace, toSpace, vec4(vec, 1.0));\n}\nvec3 oslTransform(int toSpace, vec3 vec) {\nreturn oslTransform(OSL_COMMON, toSpace, vec4(vec, 1.0));\n}\nvec3 oslTransformDir(int fromSpace, int toSpace, vec3 vec) {\nreturn oslTransform(fromSpace, toSpace, vec4(vec, 0.0));\n}\nvec3 oslTransformDir(int toSpace, vec3 vec) {\nreturn oslTransform(OSL_COMMON, toSpace, vec4(vec, 0.0));\n}\nvec3 oslTransformC(int fromSpace, int toSpace, vec3 vec) {\nvec4 outVec = vec4(vec, 1.0);\nif (fromSpace == OSL_HSV && toSpace == OSL_RGB)\nhsvToRGB(vec4(vec, 1.0), outVec);\nelse if (fromSpace == OSL_RGB && toSpace == OSL_HSV)\nrgbToHSV(vec4(vec, 1.0), outVec);\nreturn outVec.rgb;\n}\nvec3 oslTransformC(int toSpace, vec3 vec) {\nreturn oslTransformC(OSL_RGB, toSpace, vec);\n}\nvoid oslError() {}\nvoid oslFPrintf() {}\nvoid oslPrintf() {}\nvoid oslWarning() {}\nvec3 oslWaveLengthColor(float lambdaNM) {\n#if __VERSION__ == 300\nvec3 xyz = vec3(0.0);\nfloat ii = (lambdaNM - 380.0) / 5.0;\nint i = int(ii);\nif (i < 0 || i >= 80)\nreturn xyz;\nii -= float(i);\nvec3 c1 = cieColorMatch[i];\nvec3 c2 = cieColorMatch[i+1];\nxyz = mix(c1, c2, ii);\nreturn xyz_to_sRGB(xyz);\n#else\nreturn vec3(0.0);\n#endif\n}\n#endif\n#if __VERSION__ == 300 && defined(NODE_TEX_WHITE_NOISE_BL)\n#define rot_uint_32(x, k) (((x) << (k)) | ((x) >> (32 - (k))))\n#define mix_uint_32(a, b, c) { a -= c; a ^= rot_uint_32(c, 4); c += b; b -= a; b ^= rot_uint_32(a, 6); a += c; c -= b; c ^= rot_uint_32(b, 8); b += a; a -= c; a ^= rot_uint_32(c, 16); c += b; b -= a; b ^= rot_uint_32(a, 19); a += c; c -= b; c ^= rot_uint_32(b, 4); b += a; }\n#define final_uint_32(a, b, c) { c ^= b; c -= rot_uint_32(b, 14); a ^= c; a -= rot_uint_32(c, 11); b ^= a; b -= rot_uint_32(a, 25); c ^= b; c -= rot_uint_32(b, 16); a ^= c; a -= rot_uint_32(c, 4); b ^= a; b -= rot_uint_32(a, 14); c ^= b; c -= rot_uint_32(b, 24); }\nuint hash_uint(uint x) {\nuint a = 0xdeadbeefu + 17u + x;\nuint b = 0xdeadbeefu + 17u;\nuint c = 0xdeadbeefu + 17u;\nfinal_uint_32(a, b, c);\nreturn c;\n}\nuint hash_uint2(uvec2 vec) {\nuvec3 abc = uvec3(0xdeadbeefu + 21u) + uvec3(vec, 0u);\nfinal_uint_32(abc.x, abc.y, abc.z);\nreturn abc.z;\n}\nuint hash_uint3(uvec3 vec) {\nuvec3 abc = uvec3(0xdeadbeefu + 25u) + vec;\nfinal_uint_32(abc.x, abc.y, abc.z);\nreturn abc.z;\n}\nuint hash_uint4(uvec4 vec) {\nuvec3 abc = uvec3(0xdeadbeefu + 29u) + vec.xyz;\nmix_uint_32(abc.x, abc.y, abc.z);\nabc.x += vec.w;\nfinal_uint_32(abc.x, abc.y, abc.z);\nreturn abc.z;\n}\n#undef rot_uint_32\n#undef mix_uint_32\n#undef final_uint_32\nfloat uint_to_float(uint value) {\nreturn float(value) / float(0xFFFFFFFFu);\n}\nfloat hash_float_to_float(float value) {\nreturn uint_to_float(hash_uint(floatBitsToUint(value)));\n}\nfloat hash_vec2_to_float(vec2 vec) {\nreturn uint_to_float(hash_uint2(floatBitsToUint(vec)));\n}\nfloat hash_vec3_to_float(vec3 vec) {\nreturn uint_to_float(hash_uint3(floatBitsToUint(vec)));\n}\nfloat hash_vec4_to_float(vec4 vec) {\nreturn uint_to_float(hash_uint4(floatBitsToUint(vec)));\n}\nvec3 hash_float_to_vec3(float val) {\nreturn vec3(hash_float_to_float(val), hash_vec2_to_float(vec2(val, 1.0)),\nhash_vec2_to_float(vec2(val, 2.0)));\n}\nvec3 hash_vec2_to_vec3(vec2 vec) {\nreturn vec3(hash_vec2_to_float(vec), hash_vec3_to_float(vec3(vec, 1.0)),\nhash_vec3_to_float(vec3(vec, 2.0)));\n}\nvec3 hash_vec3_to_vec3(vec3 vec) {\nreturn vec3(hash_vec3_to_float(vec), hash_vec4_to_float(vec4(vec, 1.0)),\nhash_vec4_to_float(vec4(vec, 2.0)));\n}\nvec3 hash_vec4_to_vec3(vec4 vec) {\nreturn vec3(hash_vec4_to_float(vec.xyzw), hash_vec4_to_float(vec.zxwy),\nhash_vec4_to_float(vec.wzyx));\n}\n#endif",node_incident_frag:"void node_incident(vec3 viewPos, out vec3 incident)\n{\n\nvec4 viewDir = vec4(normalize(viewPos), 0.0);\nincident = -swizzleUpZ(viewDir.xyz);\n}",node_normal_frag:"void node_normal(vec3 norParam, out vec3 norOut)\n{\n#ifdef MT_BLENDER\n#if WORLD_NODES == 1\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-vViewPosition), 0.0);\nviewDir = invViewMatrix * viewDir;\nnorOut = -swizzleUpZ(viewDir.xyz);\n#else\nnorOut = normalize(invViewMatrix * vec4(norParam, 0.0)).xyz;\nnorOut = swizzleUpZ(norOut);\n#endif\n#else\nnorOut = norParam;\n#endif\n}",node_position_frag:"void node_position(vec3 posParam, out vec3 posOut)\n{\n#if defined(MT_BLENDER) || defined(MT_MAX)\nposOut = swizzleUpZ(-posParam);\n#else\nposOut = -posParam;\n#endif\n}",node_rgb_alpha_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb_alpha(vec4 color, out vec3 outColor, out float outAlpha)\n{\noutColor = color.rgb;\noutAlpha = color.a;\n}",node_value_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_u_float_frag:"void node_u_float(vec2 inUv, out float u)\n{\nu = inUv.x;\n}",node_abs_ar_frag:"void node_abs(\nvec3 inputVal,\nout vec3 outColor)\n{\noutColor = abs(inputVal);\n}",node_add_ar_frag:"void node_add(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 + input2;\n}",node_atan_ar_frag:"void node_atan(\nint units,\nvec3 x, vec3 y,\nout vec3 outColor)\n{\noutColor = atan(y, x);\nif (units == 1)\noutColor = degrees(outColor);\n}",node_checkerboard_ar_frag:"void node_checkerboard(\nconst vec2 inUv, vec3 color1, vec3 color2, float uFrequency, float vFrequency, float uOffset, float vOffset, float contrast,\nout vec3 outColor) {\nvec2 uv = -1.0 + 2.0 * inUv;\nfloat fmodResult = mod(floor(uOffset * 2.0 + uFrequency * uv.x) + floor(vOffset * 2.0 + vFrequency * uv.y), 2.0);\nfloat final = max(sign(fmodResult), 0.0);\nvec3 col = vec3(final);\nif (final == 0.0)\ncol = color1;\nelse\ncol = color2;\noutColor = col * vec3(contrast) + vec3(1.0 - contrast);\n}",node_clamp_ar_frag:"void node_clamp(\nconst int mode,\nvec3 inputValue, float minValue, float maxValue, vec3 minColor, vec3 maxColor,\nout vec3 outColor, out vec3 outTransparency)\n{\nif (mode == 0)\noutColor = clamp(inputValue, vec3(minValue), vec3(maxValue));\nelse\noutColor = clamp(inputValue, minColor, maxColor);\noutTransparency = outColor;\n}",node_color_convert_ar_frag:"void node_color_convert(\nconst int from, const int to,\nvec3 inputValue,\nout vec3 outColor, out vec3 outTransparency)\n{\nvec4 c;\nif (from == to)\nc = vec4(inputValue, 1.0);\nelse if (from == 0) \nrgbToHSV(vec4(inputValue, 1.0), c);\nelse if (from == 1)\nhsvToRGB(vec4(inputValue, 1.0), c);\noutColor = c.rgb;\noutTransparency = outColor;\n}",node_color_correct_ar_frag:"void node_color_correct(\nvec3 inputValue, float mask, float gamma, float hueShift, float saturation, float contrast, float contrastPivot,\nfloat exposure, vec3 multiply, vec3 add, bool invert, bool alphaIsLuminance, float alphaMultiply, float alphaAdd, bool invertAlpha,\nout vec3 outColor, out float outAlpha)\n{ \noutColor = inputValue;\noutColor = invert ? 1.0 - outColor : outColor;\noutColor = vec3(pow(abs(outColor.r), gamma), pow(abs(outColor.g), gamma), pow(abs(outColor.b), gamma));\nvec4 hsv;\nrgbToHSV(vec4(outColor, 1.0), hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\n\nhsv[1] *= (saturation);\nhsv[1] = saturate(hsv[1]);\nhsv[2] += exposure * 2.0;\nvec4 c = hsv;\nhsvToRGB(hsv, c);\nc = ((c - contrastPivot) * contrast + contrastPivot) * vec4(multiply, 1.0) + vec4(add, 1.0);\noutColor = c.rgb;\noutAlpha = 1.0;\n}",node_color_to_float_ar_frag:"void node_color_to_float(\nconst int mode,\nvec3 inputValue,\nout float outValue)\n{\nif (mode == 0)\noutValue = min(min(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 1)\noutValue = max(max(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b) / 3.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_compare_ar_frag:"void node_compare(\nint test,\nfloat input1, float input2,\nout bool outValue)\n{\nif (test == 0)\noutValue = input1 == input2;\nelse if (test == 1)\noutvalue = input1 != input2;\nelse if (test == 2)\noutValue = input1 < input2;\nelse if (test == 3)\noutValue = input1 > input2;\nelse if (test == 4)\noutValue = input1 <= input2;\nelse if (test == 5)\noutValue = input1 >= input2;\n}",node_complement_ar_frag:"void node_complement(\nvec3 inputValue,\nout vec3 outColor)\n{\noutColor = 1.0 - inputValue;\n}",node_composite_ar_frag:"void node_composite(\nconst int operation, const int alphaOperation,\nvec3 A, vec3 B, float AA, float BA,\nout float outAlpha, out vec3 outColor, out vec3 outTransparency)\n{\nvec4 A1 = vec4(A, AA);\nvec4 B1 = vec4(B, BA);\nvec4 color = vec4(0.0);\nif (operation == 0)\ncolor = A1;\nelse if (operation == 1)\ncolor = B1;\nelse if (operation == 2)\ncolor = A1 * B1.a + B1 * (1.0 - A1.a);\nelse if (operation == 3)\ncolor = (A1 + B1) / 2.0;\nelse if (operation == 4)\ncolor = A1.a > B1.a ? A1 : (A1 + B1 * (1.0 - A1.a) / B1.a);\nelse if (operation == 5)\ncolor = abs(A1 - B1);\nelse if (operation == 6)\ncolor = A1.a + B1.a < 1.0 ? A1 + B1 : A1 + B1 * (1.0 - A1.a) / B1.a;\nelse if (operation == 7)\nfor (int i = 0; i < 4; i++)\ncolor[i] = B1[i] == 0.0 ? 0.0 : (A1[i] / B1[i]);\nelse if (operation == 8)\ncolor = A1 + B1 - 2.0 * A1 * B1;\nelse if (operation == 9)\ncolor = B1 - A1;\nelse if (operation == 10)\ncolor = 2.0 * A1 * B1 / (A1 + B1);\nelse if (operation == 11)\nfor (int i = 0; i < 4; i++)\ncolor[i] = A1[i] < 0.5 ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 12)\ncolor = sqrt(A1 * A1 + B1 * B1);\nelse if (operation == 13)\ncolor = A1 * B1.a;\nelse if (operation == 14)\ncolor = B1 * A1.a;\nelse if (operation == 15)\ncolor = A1 * A1.a + B1 * (1.0 - A1.a);\nelse if (operation == 16)\ncolor = max(A1, B1);\nelse if (operation == 17)\ncolor = min(A1, B1);\nelse if (operation == 18)\ncolor = A1 - B1;\nelse if (operation == 19)\ncolor = A1 * B1;\nelse if (operation == 20)\ncolor = A1 * (1.0 - B1.a);\nelse if (operation == 21)\ncolor = A1 + B1 * (1.0 - A1.a);\nelse if (operation == 22)\nfor (int i = 0; i < 4; i++)\ncolor[i] = B1[i] < 0.5 ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 23)\ncolor = A1 + B1;\nelse if (operation == 24)\nfor (int i = 0; i < 4; i++)\ncolor[i] = (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\n\nelse if (operation == 25)\nfor (int i = 0; i < 4; i++)\ncolor[i] = (A1[i] < .75) ? (A1[i] * B1[i]) : (A1[i] >= 0.0 && A1[i] <= 1.0 && B1[i] >= 0.0 && B1[i] <= 1.0) ? (A1[i] + B1[i] - A1[i] * B1[i]) : max(A1[i], B1[i]);\nelse if (operation == 26)\ncolor = B1 * (1.0 - A1.a);\nelse if (operation == 27)\ncolor = A1 * (1.0 - B1.a) + B1;\nelse if (operation == 28)\ncolor = A1 * (1.0 - B1.a) + B1 * (1.0 - A1.a);\nif (alphaOperation == 1)\ncolor.a = AA;\nelse if (alphaOperation ==2)\ncolor.a = BA;\noutColor = color.rgb;\noutAlpha = color.a;\noutTransparency = outColor;\n}",node_cross_ar_frag:"void node_cross(\nvec3 input1, vec3 input2,\nout vec3 outValue)\n{\noutValue = cross(input1, input2);\n}",node_divide_ar_frag:"void node_divide(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 / input2;\n}",node_dot_ar_frag:"void node_dot(\nvec3 input1, vec3 input2,\nout vec3 outValue)\n{\noutValue = dot(input1, input2);\n}",node_exp_ar_frag:"void node_exp(\nvec3 inputVal,\nout vec3 outColor)\n{\noutColor = exp(inputVal);\n}",node_facing_ratio_ar_frag:"void node_facing_ratio(\nvec3 viewNorm,\nconst float bias, const float gain, const bool invert, const bool linear,\nout float outValue)\n{\noutValue = dot(normalize(viewNorm), normalize(vViewPosition));\n}",node_flat_ar_frag:"void node_flat(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_float_to_int_ar_frag:"void node_float_to_int(\nconst int mode, \nfloat inputValue,\nout int outValue)\n{\nif (mode == 0)\noutValue = round(inputValue);\nelse if (mode == 1)\noutValue = trunc(inputValue);\nelse if (mode == 2)\noutValue = floor(inputValue);\nelse if (mode == 3)\noutValue = ceil(inputValue);\n}",node_float_to_matrix_ar_frag:"void node_float_to_matrix(\nfloat input00, float input01, float input02, float input03, float input10, float input11, float input12, float input13, float input20, float input21, float input22, float input23, float input30, float input31, float input32, float input33,\nout mat4 outValue)\n{\noutValue = mat4(input00, input01, input02, input03,\ninput10, input11, input12, input13,\ninput20, input21, input22, input23,\ninput30, input31, input32, input33);\n}",node_float_to_rgba_ar_frag:"void node_float_to_rgba(\nfloat r, float g, float b, float a,\nout vec4 outColor, out float outAlpha, out vec3 outTransparency)\n{\noutAlpha = a;\noutColor = vec4(r, g, b, a);\noutTransparency = vec3(1.0 - a);\n}",node_float_to_rgb_ar_frag:"void node_float_to_rgb(\nfloat r, float g, float b,\nout vec3 outValue)\n{\noutValue = vec3(r, g, b);\n}",node_fraction_ar_frag:"void node_fraction(\nvec3 inputValue,\nout vec3 outColor)\n{\noutColor = fract(inputValue);\n}",node_is_finite_ar_frag:"void node_is_finite(\nvec3 inputValue,\nout bool outValue)\n{\noutValue = !any(isinf(inputValue));\n}",node_image_ar_frag:"float check(bool value) {\nif (value == true) return -1.0;\nreturn 1.0;\n}\nvoid node_image(sampler2D ima, const int encoding, \nvec3 multiply, vec3 offset, vec2 uvcoords, float soffset, float toffset, float sscale, float tscale, bool sflip, bool tflip, bool swapSt,\nout vec3 outColor, out float outAlpha, out vec3 outTransparency) {\n\nvec2 uv = vec2(uvcoords.x, uvcoords.y);\nif (swapSt == false) {\nif (sflip) uv.x = 1.0 - uv.x;\nif (tflip) uv.y = 1.0 - uv.y;\nuv = vec2(sscale, tscale) * (uv + vec2(soffset * check(sflip), toffset * check(tflip)));\n} else {\nif (sflip) uv.y = 1.0 - uv.y;\nif (tflip) uv.x = 1.0 - uv.x;\nuv = vec2(sscale, tscale) * (uv.yx + vec2(toffset * check(sflip), soffset * check(tflip)));\n}\nuv.y = 1.0 - uv.y;\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb * multiply + offset;\noutAlpha = tex.a;\noutTransparency = outColor.rgb;\n}\nvoid node_image(sampler2D ima, const int encoding, \nvec4 multiply, vec4 offset, vec2 uvcoords, float soffset, float toffset, float sscale, float tscale, bool sflip, bool tflip, bool swapSt,\nout vec4 outColor) {\nvec2 uv = vec2(uvcoords.x, uvcoords.y);\nif (swapSt == false) {\nif (sflip) uv.x = 1.0 - uv.x;\nif (tflip) uv.y = 1.0 - uv.y;\nuv = vec2(sscale, tscale) * (uv + vec2(soffset * check(sflip), toffset * check(tflip)));\n} else {\nif (sflip) uv.y = 1.0 - uv.y;\nif (tflip) uv.x = 1.0 - uv.x;\nuv = vec2(sscale, tscale) * (uv.yx + vec2(toffset * check(sflip), soffset * check(tflip)));\n}\nuv.y = 1.0 - uv.y;\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgba * multiply + offset;\n}",node_lambert_ar_frag:"void node_lambert(\nvec3 geometryNormal,\nfloat Kd, vec3 KdColor, vec3 normalCamera, vec3 opacity,\nout vec4 outColor, out float outAlpha, out vec3 outTransparency)\n{\nNodeMaterial material;\nmaterial.diffuseColor = Kd * KdColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 normal = normalCamera;\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\noutAlpha = average(opacity);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, outAlpha);\noutTransparency = vec3(1.0) - opacity;\n}",node_length_ar_frag:"void node_length(\nint mode,\nvec3 inputVec,\nout float outValue)\n{\nif (mode == 0)\noutValue = length(inputVec);\nelse if (mode == 1)\noutValue = dot(inputVec, inputVec);\nelse\noutValue = abs(inputVec.x) + abs(inputVec.y) + abs(inputVec.z);\n}",node_log_ar_frag:"void node_log(\nvec3 inputVec, vec3 base,\nout vec3 outColor)\n{\noutColor = log(inputVec) / log(base);\n}",node_map_to_mtl_ar_frag:"\nvoid node_map_to_mtl(bool opaqueEnabled, vec4 color, out vec4 outColor)\n{\noutColor = vec4(color.rgb, opaqueEnabled ? color.a : 1.0);\n}",node_max_ar_frag:"void node_max(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = max(input1, input2);\n}",node_min_ar_frag:"void node_min(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = min(input1, input2);\n}",node_mix_shader_ar_frag:"void node_mix_shader(const int mode,\nconst float mixAmt, vec4 shader1, vec4 shader2,\nout vec4 color)\n{\nshader1.rgb *= shader1.a;\nshader2.rgb *= shader2.a;\nif (mode == 0)\ncolor = mix(shader1, shader2, clamp(mixAmt, 0.0, 1.0));\nelse\ncolor = vec4(shader1.rgb + shader2.rgb, min(shader1.a, shader2.a));\ncolor.rgb /= color.a;\n}",node_modulo_ar_frag:"void node_modulo(\nvec3 inputVec, vec3 divisor,\nout vec3 outColor)\n{\noutColor = mod(inputVec, divisor);\n}",node_multiply_ar_frag:"void node_multiply(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 * input2;\n}",node_negate_ar_frag:"void node_negate(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = -inputVec;\n}",node_normalize_ar_frag:"void node_normalize(\nvec3 inputVec,\nout vec3 outValue)\n{\noutValue = normalize(inputVec);\n}",node_normal_map_ar_frag:"void node_normal_map(\nvec4 tangentParam,\nvec3 inputVal, vec3 normal, float strength, vec3 tangent,\nout vec3 outValue) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = inputVal.xyz * 2.0 - 1.0;\nvec3 bitangent = tangentParam.w * cross(normal, tangent);\noutValue = normalize(normalTex.x * tangent + normalTex.y * bitangent + normalTex.z * normal);\n}",node_pow_ar_frag:"void node_pow(\nvec3 base, vec3 exponent,\nout vec3 outColor)\n{\noutColor = pow(base, exponent);\n}",node_random_ar_frag:"void node_abs(\nvec3 inputColor,\nout vec3 outColor)\n{\noutColor = inputColor;\n}",node_range_ar_frag:"void node_range(\nvec3 inputValue, float inputMin, float inputMax, \nfloat outputMin, float outputMax, bool smoothstep1, \nfloat contrast, float contrastPivot, float bias, float gain,\nout vec3 outColor, out vec3 outTransparency)\n{\n\noutColor = min(max(inputValue, vec3(inputMin)), vec3(inputMax));\noutColor = (outColor - contrastPivot) * contrast + contrastPivot;\nif (smoothstep1 == true) {\nfor (int i = 0; i < 3; i++)\noutColor[i] = smoothstep(outputMin, outputMax, outColor[i]);\n} else\noutColor = min(max(outColor, vec3(outputMin)), vec3(outputMax));\noutTransparency = outColor;\n}",node_ray_switch_ar_frag:"void node_ray_switch(vec3 camera, vec3 diffuseReflection, vec3 diffuseTransmission,\nvec3 shadow, vec3 specularReflection, vec3 specularTransmission,\nout vec3 outColor, out float outAlpha)\n{\n#if LIGHT_PATH_IS_CAM_RAY\noutColor = camera;\n#else\noutColor = diffuseReflection;\n#endif\noutAlpha = 1.0;\n}",node_reciprocal_ar_frag:"void node_reciprocal(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = 1.0 / inputVec;\n}",node_rgba_to_float_ar_frag:"void node_rgba_to_float(\nconst int mode,\nvec3 inputValue, float inputA,\nout float outValue, out vec3 outTransparency)\n{\noutTransparency = inputValue + vec3(inputA / 4.0);\nif (mode == 0)\noutValue = min(min(min(inputValue.r, inputValue.g), inputValue.b), inputA);\nelse if (mode == 1)\noutValue = max(max(max(inputValue.r, inputValue.g), inputValue.b), inputA);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b + inputA) / 4.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b + inputA;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_rgb_to_float_ar_frag:"void node_rgb_to_float(\nconst int mode,\nvec3 inputValue,\nout float outValue)\n{\nif (mode == 0)\noutValue = min(min(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 1)\noutValue = max(max(inputValue.r, inputValue.g), inputValue.b);\nelse if (mode == 2)\noutValue = (inputValue.r + inputValue.g + inputValue.b) / 3.0;\nelse if (mode == 3)\noutValue = inputValue.r + inputValue.g + inputValue.b;\nelse if (mode == 4) {\noutValue = dot(inputValue, LUM_WEIGHTS);\n}\nelse if (mode == 5)\noutValue = inputValue.r;\nelse if (mode == 6)\noutValue = inputValue.g;\nelse if (mode == 7)\noutValue = inputValue.b;\n}",node_rgb_to_vector_ar_frag:"void node_rgb_to_vector(\nconst int mode, \nvec3 inputValue,\nout vec3 outValue)\n{\n\noutValue = inputValue;\n}",node_shadow_matte_ar_frag:"#include \nvoid node_shadow_matte(\nvec3 normal,\nvec3 shadowColor, float backlighting, float shadowOpacity,\nout vec4 outColor, out float outAlpha) {\nfloat shadow = getShadowMask();\noutColor = vec4(shadowColor, shadowOpacity * (1.0 - shadow));\noutAlpha = outColor.a;\n}",node_shuffle_ar_frag:"\nvoid node_shuffle(const int channelR, const int channelG, const int channelB, const int channelA,\nvec3 color, float alpha, bool negateR, bool negateG, bool negateB, bool negateA,\nout vec3 outColor, out float outAlpha)\n{\noutColor = vec3(0.0);\nvec4 choose = vec4(color, alpha);\noutAlpha = 1.0;\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutAlpha = choose[channelA];\nif (negateR)\noutColor.r = -outColor.r;\nif (negateG)\noutColor.g = -outColor.g;\nif (negateB)\noutColor.b = -outColor.b;\nif (negateA)\noutAlpha = -outAlpha;\n}\nvoid node_shuffle(const int channelR, const int channelG, const int channelB, const int channelA,\nvec4 color, float alpha, bool negateR, bool negateG, bool negateB, bool negateA,\nout vec4 outColor)\n{\noutColor = vec4(0.0);\nvec4 choose = vec4(color.rgb, alpha);\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutColor.a = choose[channelA];\nif (negateR)\noutColor.r = -outColor.r;\nif (negateG)\noutColor.g = -outColor.g;\nif (negateB)\noutColor.b = -outColor.b;\nif (negateA)\noutColor.a = -outColor.a;\n}",node_sign_ar_frag:"void node_sign(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = sign(inputVec);\n}",node_skydome_light_ar_frag:"void node_skydome_light(vec3 color, float intensity,\nout vec4 outgoingLight)\n{\noutgoingLight = vec4(color * intensity, 1.0);\n}\nvoid node_skydome_light(sampler2D envMap, int encoding, vec3 normal,\nfloat intensity,\nout vec4 outgoingLight)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec = normalize(cameraToVertex);\nmat3 uvTransform = mat3(1.0);\nvec4 color = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\n#if LIGHT_PATH_IS_CAM_RAY\nintensity = 1.0;\n#endif\noutgoingLight = color * intensity;\n}",node_sqrt_ar_frag:"void node_sqrt(\nvec3 inputVec,\nout vec3 outColor)\n{\noutColor = sqrt(inputVec);\n}",node_standard_surface_ar_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal, const vec3 clearcoatNormal, const float specularIOR,\nout vec4 outColor, out vec3 outTransparency)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = base * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - metalness) * (1.0 - trans);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoat = saturate(coat);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\nmaterial.clearcoatF0 = vec3(0.04);\nmaterial.clearcoatF90 = 1.0;\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = saturate(sheen * sheenColor);\nmaterial.sheenRoughness = clamp(sheenRoughness, 0.0, 1.0);\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.roughness = max(specularRoughness, 0.0525);\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min(material.roughness, 1.0);\nvec3 dielRefl = DEFAULT_SPECULAR_COEFFICIENT * specular * specularColor;\nmaterial.specularColor = mix(dielRefl, baseColorWeighted, metalness);\nmaterial.refractionColor = pow(trans * (1.0 - metalness) * transColor.rgb, vec3(2.0));\nmaterial.refractionIOR = specularIOR;\nmaterial.refractionRoughness = material.roughness;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \nvec3 totalEmissiveRadiance = emission * emissionColor;\nvec3 outSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\noutSpecular + totalEmissiveRadiance;\n#ifdef USE_SHEEN\nfloat sheenEnergyComp = 1.0 - 0.157 * max3(material.sheenColor);\noutColor3 = outColor3 * sheenEnergyComp + sheenSpecular;\n#endif\n#ifdef USE_CLEARCOAT\nfloat dotNVcc = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 Fcc = F_Schlick(material.clearcoatF0, material.clearcoatF90, dotNVcc);\noutColor3 = outColor3 * (1.0 - material.clearcoat * Fcc) + clearcoatSpecular * material.clearcoat;\n#endif\nfloat alpha = 1.0;\nif (thinWalled) {\nalpha = average(opacity) * (1.0 - saturate(trans) + maxFromRGB(outSpecular) * saturate(trans));\n} else {\noutColor3 += refractedLight;\n}\noutColor = vec4(outColor3, saturate(alpha));\noutTransparency = outColor3;\n}\nvoid node_standard_surface(\nvec3 geometryNormal, const bool thinWalled,\nconst float base, const vec3 baseColor, const float diffuseRoughness,\nconst float metalness, const float specular, const vec3 specularColor,\nconst float specularRoughness, const float trans, const vec3 transColor,\nconst float transDepth, const vec3 transScatter, const float transExtraRoughness,\nconst float subsurface, const vec3 subsurfaceColor, const vec3 subsurfaceRadius,\nconst float coat, const vec3 coatColor, const float coatRoughness,\nconst float sheen, const vec3 sheenColor, const float sheenRoughness,\nconst float emission, const vec3 emissionColor, const vec3 opacity,\nconst vec3 normal, const vec3 clearcoatNormal,\nout vec4 outColor, out vec3 outTransparency)\n{\nnode_standard_surface(\ngeometryNormal, thinWalled,\nbase, baseColor, diffuseRoughness,\nmetalness, specular, specularColor,\nspecularRoughness, trans, transColor,\ntransDepth, transScatter, transExtraRoughness,\nsubsurface, subsurfaceColor, subsurfaceRadius,\ncoat, coatColor, coatRoughness,\nsheen, sheenColor, sheenRoughness,\nemission, emissionColor, opacity,\nnormal, clearcoatNormal, 1.5,\noutColor, outTransparency);\n}",node_subtract_ar_frag:"void node_subtract(\nvec3 input1, vec3 input2,\nout vec3 outColor)\n{\noutColor = input1 - input2;\n}",node_trigo_ar_frag:"void node_trigo(\nconst int function, const int units,\nvec3 inputVec, float frequency, float phase,\nout vec3 outColor)\n{\nif (units == 1 && function >= 0 && function <=2)\ninputVec = radians(inputVec);\nif (function == 0)\noutColor = cos(inputVec * frequency + phase);\nelse if (function == 1)\noutColor = sin(inputVec * frequency + phase);\nelse if (function == 2)\noutColor = tan(inputVec * frequency + phase);\nelse if (function == 3)\noutColor = acos(inputVec * frequency + phase);\nelse if (function == 4)\noutColor = asin(inputVec * frequency + phase);\nelse if (function == 5)\noutColor = atan(inputVec * frequency + phase);\nelse if (function == 6)\noutColor = cosh(inputVec * frequency + phase);\nelse if (function == 7)\noutColor = sinh(inputVec * frequency + phase);\nelse\noutColor = tanh(inputVec * frequency + phase);\nif (units == 1 && function >= 3 && function <=5)\noutColor = degrees(outColor);\n}",node_two_sided_ar_frag:"void node_two_sided(\nbool frontFacing, \nvec3 front, vec3 back,\nout vec3 outColor)\n{\noutColor = frontFacing ? front : back;\n}",node_user_data_color_ar_frag:"void node_user_data_color(vec4 color, \nout vec3 outColor, out float outAlpha)\n{\noutColor = color.rgb;\noutAlpha = color.a;\n}",node_vector_to_rgb_ar_frag:"void node_vector_to_rgb(\nconst int mode, \nvec3 inputValue,\nout vec3 outColor)\n{\nif (mode == 0)\noutColor = inputValue;\nelse if (mode == 1)\noutColor = normalize(inputValue);\nelse if (mode == 2)\noutColor = inputValue;\n}",node_add_shader_bl_frag:"void node_add_shader(vec4 color1, vec4 color2, out vec4 outColor) {\noutColor.rgb = color1.rgb + color2.rgb;\noutColor.a = clamp(color1.a + color2.a, 0.0, 1.0);\n}",node_ambient_occlusion_bl_frag:"void node_ambient_occlusion(vec4 color, float distance, vec3 normal,\nout vec4 outColor, out float outAO) {\noutColor = color;\noutAO = 1.0;\n}",node_attribute_bl_frag:"void node_attribute(\nvec4 paramAttr,\nout vec4 outColor, out vec3 outVector, out float outFac,\nout float outAlpha) {\noutColor = vec4(paramAttr.xyz, 1.0);\noutVector = paramAttr.xyz;\noutFac = average(paramAttr.xyz);\noutAlpha = paramAttr.w;\n}\nvoid node_attribute(\nvec4 paramAttr,\nout vec4 outColor, out vec3 outVector, out float outFac) {\nfloat outAlpha;\nnode_attribute(paramAttr, outColor, outVector, outFac, outAlpha);\n}",node_background_bl_frag:"void node_background(vec4 color, float strength, out vec4 outColor)\n{\noutColor = strength * color;\n}",node_bevel_bl_frag:"void node_bevel(float radius, vec3 normal, out vec3 outNormal) {\noutNormal = normal;\n}",node_blackbody_bl_frag:"void node_blackbody(float temp, out vec4 outColor)\n{\noutColor = vec4(colorTempToRGB(temp), 1.0);\n}",node_brightcontrast_bl_frag:"\nvoid node_brightcontrast(vec4 color, float bright, float contrast, out vec4 outColor)\n{\nfloat bminc = bright - contrast * 0.5;\noutColor.r = max((1.0 + contrast) * color.r + bminc, 0.0);\noutColor.g = max((1.0 + contrast) * color.g + bminc, 0.0);\noutColor.b = max((1.0 + contrast) * color.b + bminc, 0.0);\noutColor.a = color.a;\n}",node_bsdf_anisotropic_bl_frag:"void node_bsdf_anisotropic(\nvec4 color, float roughness, float anisotropy, float rotation, vec3 normal, vec3 tangent,\nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_diffuse_bl_frag:"\nvoid node_bsdf_diffuse(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_glass_bl_frag:"void node_bsdf_glass(\nvec3 geometryNormal,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = normalize(normal);\nnormal = swizzleUpY(normal);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.roughness = clamp(roughness, 0.0, 1.0);\nmaterial.refractionColor = vec3(1.0);\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.roughness = calcCubeUVAdjustedRoughness(\nmaterial.roughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0),\nvec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\n#ifdef USE_GTAO\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\noutColor = vec4(color.rgb * mix(refractedLight, reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular, fresnel), 1.0);\n}",node_bsdf_glossy_bl_frag:"\nvoid node_bsdf_glossy(\nvec3 geometryNormal,\nvec4 color, float roughness, vec3 normal,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nnormal = normalize((viewMatrix * vec4(normal.xyz, 0.0)).xyz);\nNodeMaterial material;\nmaterial.specularColor = vec3(1.0);\nmaterial.fresnelRefl90 = vec3(1.0);\nmaterial.roughness = clamp(roughness, 0.0, 1.0);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.roughness = calcCubeUVAdjustedRoughness(\nmaterial.roughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectSpecular\n#undef RE_IndirectSpecular\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\n#ifdef USE_GTAO\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \noutColor = vec4(color.rgb * (reflectedLight.directSpecular\n+ reflectedLight.indirectSpecular), 1.0);\n}",node_bsdf_hair_bl_frag:"void node_bsdf_hair(vec4 color, float offset, float roughnessU, float roughnessV, vec3 tangent, out vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_principled_bl_frag:"\nvec3 tintFromColor(vec3 color) {\nfloat lum = dot(color, vec3(0.3, 0.6, 0.1));\nreturn lum > 0.0 ? color / lum : vec3(1.0);\n}\nvec3 fresnelBlend(float ior, float fresnel, vec3 fresnelColor) {\nfloat fresnelFac = fresnelReflection(vec3(1.0, 0.0, 0.0), vec3(1.0, 0.0, 0.0), ior);\nfloat mixFac = saturate((fresnel - fresnelFac) / max(1e-8, 1.0 - fresnelFac));\nreturn mix(fresnelColor, vec3(1.0), mixFac);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat subsurfaceIOR, float subsurfaceAnisotropy,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission,\nfloat emissionStrength, float alpha, vec3 normal, vec3 clearcoatNormal,\nvec3 tangent,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat dielectric = 1.0 - metallic;\ntransmission *= dielectric;\nmaterial.diffuseColor = baseColor.rgb * dielectric;\n#ifndef USE_CLEARCOAT\nfloat dielReflCoeff = BLENDER_SPECULAR_COEFFICIENT;\n#else\nfloat dielReflCoeff = MAXIMUM_SPECULAR_COEFFICIENT;\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 1.0);\nmaterial.clearcoatF0 = vec3(0.04);\nmaterial.clearcoatF90 = 1.0;\n#endif\n#ifdef USE_SHEEN\nmaterial.sheenColor = sheen * mix(vec3(0.05), baseColor.rgb, sheenTint);\nmaterial.sheenRoughness = 0.25;\n#endif\nvec3 dielRefl = dielReflCoeff * specular\n* mix(vec3(1.0), tintFromColor(baseColor.rgb), specularTint);\nmaterial.specularColor = mix(dielRefl, baseColor.rgb, metallic);\nmaterial.roughness = clamp(roughness, 0.0, 1.0);\nvec3 viewWorld;\nif (isPerspective(projectionMatrix))\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nviewWorld = normalize(viewWorld);\nfloat fresnel = fresnelReflection(viewWorld, normalWorld, ior);\nvec3 fresnelColor = mix(vec3(1.0), baseColor.rgb, specularTint);\nmaterial.specularColor = mix(material.specularColor,\nfresnelBlend(ior, fresnel, fresnelColor) * fresnel, transmission);\nfloat isStrictDielectric = step(0.0, -length(vec4(subsurface, clearcoat,\ntransmission, float(metallic == 1.0))));\nmaterial.fresnelRefl90 = mix(vec3(1.0), material.specularColor,\n(1.0 - specular) * metallic * (1.0 - isStrictDielectric));\nmaterial.specularF90 = average(material.fresnelRefl90);\nmaterial.refractionColor = baseColor.rgb;\nmaterial.refractionIOR = ior;\nmaterial.refractionRoughness = pow2(roughness);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.roughness = calcCubeUVAdjustedRoughness(\nmaterial.roughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \nvec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse) * (1.0 - transmission)\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular\n+ refractedLight * transmission * (1.0 - fresnel)\n+ emission.rgb * emissionStrength;\n#ifdef USE_SHEEN\nfloat sheenEnergyComp = 1.0 - 0.157 * max3(material.sheenColor);\noutColor3 = outColor3 * sheenEnergyComp + sheenSpecular;\n#endif\n#ifdef USE_CLEARCOAT\nfloat dotNVcc = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 Fcc = F_Schlick(material.clearcoatF0, material.clearcoatF90, dotNVcc);\noutColor3 = outColor3 * (1.0 - material.clearcoat * Fcc) + clearcoatSpecular * material.clearcoat;\n#endif\noutColor = vec4(outColor3, alpha);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission, float alpha,\nvec3 normal, vec3 clearcoatNormal, vec3 tangent,\nout vec4 outColor) {\nnode_bsdf_principled(geometryNormal, baseColor, subsurface, subsurfaceRadius,\nsubsurfaceColor, 0.0, 0.0, metallic, specular, specularTint, roughness,\nanisotropic, anisotropicRotation, sheen, sheenTint, clearcoat,\nclearcoatRoughness, ior, transmission, transmissionRoughness,\nemission, 1.0, alpha, normal, clearcoatNormal, tangent, outColor);\n}\nvoid node_bsdf_principled(\nvec3 geometryNormal,\nvec4 baseColor, float subsurface, vec3 subsurfaceRadius, vec4 subsurfaceColor,\nfloat metallic, float specular, float specularTint, float roughness,\nfloat anisotropic, float anisotropicRotation, float sheen, float sheenTint,\nfloat clearcoat, float clearcoatRoughness, float ior,\nfloat transmission, float transmissionRoughness, vec4 emission,\nfloat emissionStrength, float alpha, vec3 normal, vec3 clearcoatNormal,\nvec3 tangent,\nout vec4 outColor) {\nnode_bsdf_principled(geometryNormal, baseColor, subsurface, subsurfaceRadius,\nsubsurfaceColor, 0.0, 0.0, metallic, specular, specularTint, roughness,\nanisotropic, anisotropicRotation, sheen, sheenTint, clearcoat,\nclearcoatRoughness, ior, transmission, transmissionRoughness,\nemission, emissionStrength, alpha, normal, clearcoatNormal, tangent, outColor);\n}",node_bsdf_refraction_bl_frag:"#define BSDF_REFRACTION_GGX 0\n#define BSDF_REFRACTION_BECKMANN 1\n#define BSDF_REFRACTION_SHARP 2\nvoid node_bsdf_refraction(\nvec3 geometryNormal, const int distribution,\nvec4 color, float roughness, float ior, vec3 normal,\nout vec4 outColor) {\nnormal = swizzleUpY(normal);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.refractionColor = color.rgb;\nmaterial.refractionIOR = ior;\nif (distribution == BSDF_REFRACTION_SHARP) {\nmaterial.refractionRoughness = 0.0;\n} else {\nmaterial.refractionRoughness = pow2(roughness);\n}\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_Refraction\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\noutColor = vec4(refractedLight, 1.0);\n}",node_bsdf_toon_bl_frag:"void node_bsdf_toon(\nvec4 color, float size, float smoothFac, vec3 normal,\nout vec4 outColor)\n{\noutColor = color;\n}",node_bsdf_translucent_bl_frag:"void node_bsdf_translucent(vec4 color, vec3 normal, out vec4 outColor) {\nnormal = -vec3(normal[0], normal[2], -normal[1]);\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse, 1.0);\n}",node_bsdf_transparent_bl_frag:"\nvoid node_bsdf_transparent(vec4 color, out vec4 outColor)\n{\nfloat alpha = saturate(1.0 - dot(color.rgb, vec3(0.333333)));\noutColor = vec4(0.0, 0.0, 0.0, alpha);\n}",node_bsdf_velvet_bl_frag:"void node_bsdf_velvet(vec4 color, float sigma, vec3 normal, out vec4 outColor)\n{\noutColor = color;\n}",node_bump_bl_frag:"\nvoid node_bump(\nconst bool invert,\nfloat strength, float bumpDist, float height, vec3 normal,\nout vec3 outNormal) {\nvec3 position = swizzleUpZ(vWorldPosition);\nif (invert)\nbumpDist *= -1.0;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(height);\nfloat dHdy = dFdy(height);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * bumpDist * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, strength)));\n}\nvoid node_bump(const bool invert,\nfloat strength, float bumpDist, float height, float height_dx, float height_dy, vec3 normal,\nout vec3 outNormal) {\nnode_bump(invert, strength, bumpDist, height, normal, outNormal);\n}",node_camera_bl_frag:"\nvoid node_camera(\nvec3 viewPos, const bool invCamZ,\nout vec3 outViewVector, out float outViewZDepth, out float outViewDistance)\n{\nviewPos = -viewPos;\nif (invCamZ)\nviewPos.z = -viewPos.z;\noutViewVector = normalize(viewPos);\noutViewZDepth = abs(viewPos.z);\noutViewDistance = length(viewPos);\n}",node_clamp_bl_frag:"void node_clamp(float value, float minVal, float maxVal, out float result) {\nresult = max(min(value, maxVal), minVal);\n}",node_combhsv_bl_frag:"\nvoid node_combhsv(float h, float s, float v, out vec4 col)\n{\nhsvToRGB(vec4(h, s, v, 1.0), col);\n}",node_combine_color_bl_frag:"#define NODE_COMB_COL_RGB 0\n#define NODE_COMB_COL_HSV 1\n#define NODE_COMB_COL_HSL 2\nvoid hslToRGB(vec3 hsl, out vec3 outCol)\n{\nfloat nr, ng, nb, chroma;\nfloat h, s, l;\nh = hsl[0];\ns = hsl[1];\nl = hsl[2];\nnr = abs(h * 6.0 - 3.0) - 1.0;\nng = 2.0 - abs(h * 6.0 - 2.0);\nnb = 2.0 - abs(h * 6.0 - 4.0);\nnr = clamp(nr, 0.0, 1.0);\nnb = clamp(nb, 0.0, 1.0);\nng = clamp(ng, 0.0, 1.0);\nchroma = (1.0 - abs(2.0 * l - 1.0)) * s;\noutCol = vec3((nr - 0.5) * chroma + l, (ng - 0.5) * chroma + l, (nb - 0.5) * chroma + l);\n}\nvoid node_combine_color(int mode, float r, float g, float b, out vec4 col)\n{\nif (mode == NODE_COMB_COL_RGB) {\ncol = vec4(r, g, b, 1.0);\n} else if (mode == NODE_COMB_COL_HSV) {\nhsvToRGB(vec4(r, g, b, 1.0), col);\n} else {\nvec3 col3;\nhslToRGB(vec3(r, g, b), col3);\ncol = vec4(col3, 1.0);\n}\n}",node_combrgb_bl_frag:"\nvoid node_combrgb(float r, float g, float b, out vec4 col)\n{\ncol = vec4(r, g, b, 1.0);\n}",node_combxyz_bl_frag:"void node_combxyz(float x, float y, float z, out vec3 outVector)\n{\noutVector = vec3(x, y, z);\n}",node_curve_float_bl_frag:"void node_curve_float(sampler2D curveData, float fac, float value, out float outValue)\n{\noutValue = texture2D(curveData, vec2((value + 1.0) * 0.5, 0.0)).x;\noutValue = mix(value, outValue * 2.0 - 1.0, fac);\n}",node_curve_rgb_bl_frag:"\nvoid node_curve_rgb(sampler2D curveData, float fac, vec4 col, out vec4 outCol)\n{\noutCol.r = texture2D(curveData, vec2(texture2D(curveData, vec2(col.r, 0.0)).a, 0.0)).r;\noutCol.g = texture2D(curveData, vec2(texture2D(curveData, vec2(col.g, 0.0)).a, 0.0)).g;\noutCol.b = texture2D(curveData, vec2(texture2D(curveData, vec2(col.b, 0.0)).a, 0.0)).b;\noutCol = mix(col, outCol, fac);\noutCol.a = col.a;\n}",node_curve_vec_bl_frag:"\nvoid node_curve_vec(sampler2D curveData, float fac, vec3 vec, out vec3 outVec)\n{\noutVec.x = texture2D(curveData, vec2((vec.x + 1.0) * 0.5, 0.0)).x;\noutVec.y = texture2D(curveData, vec2((vec.y + 1.0) * 0.5, 0.0)).y;\noutVec.z = texture2D(curveData, vec2((vec.z + 1.0) * 0.5, 0.0)).z;\noutVec = mix(vec, outVec * 2.0 - vec3(1.0), fac);\n}",node_displacement_bl_frag:"void node_displacement(float height, float midlevel, float scale, vec3 normal, out vec3 outDisplacement) {\noutDisplacement = vec3(0.0);\n}",node_eevee_specular_bl_frag:"void node_eevee_specular(\nvec3 geometryNormal,\nvec4 baseColor, vec4 specular, float roughness, vec4 emissiveColor,\nfloat transparency, vec3 normal, float clearcoat, float clearcoatRoughness,\nvec3 clearcoatNormal, float ambientOcclusion,\nout vec4 outColor) {\nnormal = vec3(normal[0], normal[2], -normal[1]);\nvec3 normalWorld = normal;\nnormal = (viewMatrix * vec4(normal.xyz, 0.0)).xyz;\nNodeMaterial material;\nmaterial.diffuseColor = baseColor.rgb;\nmaterial.specularColor = specular.rgb;\nmaterial.roughness = clamp(roughness, 0.0, 1.0);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoat = saturate(clearcoat);\nmaterial.clearcoatRoughness = clamp(clearcoatRoughness, 0.0, 1.0);\n#endif\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.roughness = calcCubeUVAdjustedRoughness(\nmaterial.roughness, geomRoughness);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\nclearcoatNormal = normalize(vec3(clearcoatNormal[0], clearcoatNormal[2], -clearcoatNormal[1]));\nclearcoatNormal = (viewMatrix * vec4(clearcoatNormal.xyz, 0.0)).xyz;\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \nvec3 outColor3 = (reflectedLight.directDiffuse + reflectedLight.indirectDiffuse\n+ reflectedLight.directSpecular + reflectedLight.indirectSpecular) * ambientOcclusion\n+ emissiveColor.rgb;\noutColor = vec4(outColor3, 1.0 - transparency);\n}",node_emission_bl_frag:"\nvoid node_emission(vec4 color, float strength, out vec4 outColor)\n{\noutColor = vec4(strength * color.rgb, 1.0);\n}",node_fresnel_bl_frag:"void node_fresnel(vec3 viewPos, float IOR, vec3 normal, out float fac)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\n}",node_gamma_bl_frag:"\nvoid node_gamma(vec4 col, float gamma, out vec4 outCol)\n{\noutCol = col;\nif (col.r > 0.0)\noutCol.r = powCompat(col.r, gamma);\nif (col.g > 0.0)\noutCol.g = powCompat(col.g, gamma);\nif (col.b > 0.0)\noutCol.b = powCompat(col.b, gamma);\n}",node_hair_info_bl_frag:"\nvoid node_hair_info(out float isStrand, out float intercept, out float len, out float thickness,\nout vec3 tangentNormal, out float random) {\nisStrand = 0.0;\nintercept = 0.0;\nlen = 0.0;\nthickness = 0.0;\ntangentNormal = vec3(0.0);\nrandom = 1.0;\n}\nvoid node_hair_info(out float isStrand, out float intercept, out float thickness,\nout vec3 tangentNormal, out float random) {\nfloat len;\nnode_hair_info(isStrand, intercept, len, thickness, tangentNormal, random);\n}",node_holdout_bl_frag:"void node_holdout(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_hue_sat_bl_frag:"\nvoid node_hue_sat(float hue, float sat, float value, float fac, vec4 col, out vec4 outCol)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nhsv[0] += (fract(hue) - 0.5);\nif (hsv[0] > 1.0) hsv[0] -= 1.0; else if (hsv[0] < 0.0) hsv[0] += 1.0;\nhsv[1] *= sat;\nif (hsv[1] > 1.0) hsv[1] = 1.0; else if (hsv[1] < 0.0) hsv[1] = 0.0;\nhsv[2] *= value;\nhsvToRGB(hsv, outCol);\noutCol = mix(col, outCol, fac);\n}",node_invert_bl_frag:"\nvoid node_invert(float fac, vec4 col, out vec4 outCol)\n{\noutCol.xyz = mix(col.xyz, vec3(1.0, 1.0, 1.0) - col.xyz, fac);\noutCol.w = col.w;\n}",node_layer_weight_bl_frag:"\nvoid node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\nvec3 worldDir;\nif (isPerspective(projectionMatrix))\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\n\nworldDir = normalize(swizzleUpZ(worldDir));\nfloat eta = max(1.0 - blend, EPSILON);\nfresnel = fresnelReflection(worldDir, normal, (gl_FrontFacing) ? 1.0 / eta : eta);\nfacing = abs(dot(worldDir, normal));\nif (blend != 0.5) {\nblend = clamp(blend, 0.0, 1.0 - EPSILON);\nblend = (blend < 0.5) ? blend * 2.0 : 0.5 / (1.0 - blend);\nfacing = pow(facing, blend);\n}\nfacing = 1.0 - facing;\n}",node_light_falloff_bl_frag:"void node_light_falloff(\nfloat strength, float inSmooth,\nout float quadratic, out float linear, out float constant)\n{\nquadratic = 1.0;\nlinear = 1.0;\nconstant = 1.0;\n}",node_light_path_bl_frag:"void node_light_path(\nout float isCameraRay, out float isShadowRay, out float isDiffuseRay, \nout float isGlossyRay, out float isSingularRay, out float isReflectionRay,\nout float isTransmissionRay, out float rayLength, out float rayDepth, \nout float diffuseDepth, out float glossyDepth, out float transparentDepth, \nout float transmissionDepth)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\nisShadowRay = 0.0;\nisDiffuseRay = 0.0;\nisGlossyRay = 0.0;\nisSingularRay = 0.0;\nisReflectionRay = 0.0;\nisTransmissionRay = 0.0;\nrayLength = 1.0;\nrayDepth = 1.0;\ndiffuseDepth = 1.0;\nglossyDepth = 1.0;\ntransparentDepth = 1.0; \ntransmissionDepth = 1.0;\n}",node_mapping_bl_frag:"\nvoid node_mapping(mat4 mat, vec3 minVec, vec3 maxVec, bool useMin, bool useMax, vec3 vec, out vec3 outVec)\n{\noutVec = (mat * vec4(vec, 1.0)).xyz;\nif (useMin)\noutVec = max(outVec, minVec);\nif (useMax)\noutVec = min(outVec, maxVec);\n}\nmat3 rotationMatrix(float angleX, float angleY, float angleZ) {\nfloat cx = cos(angleX);\nfloat sx = sin(angleX);\nfloat cy = cos(angleY);\nfloat sy = sin(angleY);\nfloat cz = cos(angleZ);\nfloat sz = sin(angleZ);\nmat3 mat;\nmat[0][0] = cy * cz;\nmat[0][1] = cy * sz;\nmat[0][2] = -sy;\nmat[1][0] = sy * sx * cz - cx * sz;\nmat[1][1] = sy * sx * sz + cx * cz;\nmat[1][2] = cy * sx;\nmat[2][0] = sy * cx * cz + sx * sz;\nmat[2][1] = sy * cx * sz - sx * cz;\nmat[2][2] = cy * cx;\nreturn mat;\n}\n#define NODE_MAPPING_POINT 1\n#define NODE_MAPPING_TEXTURE 2\n#define NODE_MAPPING_VECTOR 3\n#define NODE_MAPPING_NORMAL 4\nvoid node_mapping(int type, vec3 vec, vec3 loc, vec3 rot, vec3 scale, out vec3 outVec)\n{\nif (type == NODE_MAPPING_POINT)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale) + loc;\nelse if (type == NODE_MAPPING_TEXTURE)\noutVec = transposeMat3(rotationMatrix(rot.x, rot.y, rot.z)) * (vec - loc) / scale;\nelse if (type == NODE_MAPPING_VECTOR)\noutVec = rotationMatrix(rot.x, rot.y, rot.z) * (vec * scale);\nelse {\nmat3 rot = rotationMatrix(rot.x, rot.y, rot.z) * mat3(\nscale[0], 0.0, 0.0,\n0.0, scale[1], 0.0,\n0.0, 0.0, scale[2]\n);\noutVec = normalize(mat3GetInverseTransposed(rot) * vec);\n}\n}",node_map_range_bl_frag:"#define NODE_MAP_RANGE_INTERP_LINEAR 0\n#define NODE_MAP_RANGE_INTERP_STEPPED 1\n#define NODE_MAP_RANGE_INTERP_SMOOTHSTEP 2\n#define NODE_MAP_RANGE_INTERP_SMOOTHERSTEP 3\n#define NODE_MAP_RANGE_TYPE_FLOAT 0\n#define NODE_MAP_RANGE_TYPE_FLOAT_VECTOR 1\nvoid node_map_range(const int interpolation, bool inClamp, float value, float fromMin, float fromMax,\nfloat toMin, float toMax, float steps, out float result) {\nif (fromMax == fromMin) {\nresult = 0.0;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_LINEAR) {\nresult = (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_STEPPED) {\nfloat fac = (value - fromMin) / (fromMax - fromMin);\nfac = (steps > 0.0) ? floor(fac * (steps + 1.0)) / steps : 0.0;\nresult = fac * (toMax - toMin) + toMin;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_SMOOTHSTEP) {\nfloat fac = (fromMin > fromMax) ?\n1.0 - smoothstep(fromMax, fromMin, value) :\nsmoothstep(fromMin, fromMax, value);\nresult = fac * (toMax - toMin) + toMin;\n} else {\nfloat fac = (fromMin > fromMax) ?\n1.0 - smootherstep(fromMax, fromMin, value) :\nsmootherstep(fromMin, fromMax, value);\nresult = fac * (toMax - toMin) + toMin;\n}\nif (inClamp && interpolation <= NODE_MAP_RANGE_INTERP_STEPPED) {\nresult = clamp(result, toMin, toMax);\n}\n}\nvoid node_map_range(const int dataType, const int interpolation, bool inClamp, float value,\nfloat fromMin, float fromMax, float toMin, float toMax, float steps, vec3 valueVec,\nvec3 fromMinVec, vec3 fromMaxVec, vec3 toMinVec, vec3 toMaxVec, vec3 stepsVec,\nout float result, out vec3 resultVec) {\nif (dataType == NODE_MAP_RANGE_TYPE_FLOAT) {\nif (fromMax == fromMin) {\nresult = 0.0;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_LINEAR) {\nresult = (value - fromMin) / (fromMax - fromMin) * (toMax - toMin) + toMin;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_STEPPED) {\nfloat fac = (value - fromMin) / (fromMax - fromMin);\nfac = (steps > 0.0) ? floor(fac * (steps + 1.0)) / steps : 0.0;\nresult = fac * (toMax - toMin) + toMin;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_SMOOTHSTEP) {\nfloat fac = (fromMin > fromMax) ?\n1.0 - smoothstep(fromMax, fromMin, value) :\nsmoothstep(fromMin, fromMax, value);\nresult = fac * (toMax - toMin) + toMin;\n} else {\nfloat fac = (fromMin > fromMax) ?\n1.0 - smootherstep(fromMax, fromMin, value) :\nsmootherstep(fromMin, fromMax, value);\nresult = fac * (toMax - toMin) + toMin;\n}\nif (inClamp && interpolation <= NODE_MAP_RANGE_INTERP_STEPPED) {\nresult = clamp(result, toMin, toMax);\n}\n} else if (dataType == NODE_MAP_RANGE_TYPE_FLOAT_VECTOR) {\nvec3 deltaVec = fromMaxVec - fromMinVec;\nvec3 fac = vec3(\ndeltaVec.x == 0.0 ? 0.0 : (valueVec.x - fromMinVec.x) / deltaVec.x,\ndeltaVec.y == 0.0 ? 0.0 : (valueVec.y - fromMinVec.y) / deltaVec.y,\ndeltaVec.z == 0.0 ? 0.0 : (valueVec.z - fromMinVec.z) / deltaVec.z\n);\nif (interpolation == NODE_MAP_RANGE_INTERP_LINEAR) {\nresultVec = fac * (toMaxVec - toMinVec) + toMinVec;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_STEPPED) {\nfac.x = stepsVec.x == 0.0 ? 0.0 : floor(fac.x * (stepsVec.x + 1.0)) / stepsVec.x;\nfac.y = stepsVec.y == 0.0 ? 0.0 : floor(fac.y * (stepsVec.y + 1.0)) / stepsVec.y;\nfac.z = stepsVec.z == 0.0 ? 0.0 : floor(fac.z * (stepsVec.z + 1.0)) / stepsVec.z;\nresultVec = fac * (toMaxVec - toMinVec) + toMinVec;\n} else if (interpolation == NODE_MAP_RANGE_INTERP_SMOOTHSTEP) {\nfac = clamp(fac, 0.0, 1.0);\nfac = fac * fac * (3.0 - 2.0 * fac);\nresultVec = fac * (toMaxVec - toMinVec) + toMinVec;\n} else {\nresultVec = smootherstep(fac) * (toMaxVec - toMinVec) + toMinVec;\n}\nif (inClamp && interpolation <= NODE_MAP_RANGE_INTERP_STEPPED) {\nvec3 sumVec = toMinVec + toMaxVec;\ntoMaxVec = max(toMaxVec, toMinVec);\ntoMinVec = sumVec - toMaxVec;\nresultVec = clamp(resultVec, toMinVec, toMaxVec);\n}\n}\n}",node_math_bl_frag:"\nvoid node_math_add(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 + val2;\n}\nvoid node_math_subtract(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 - val2;\n}\nvoid node_math_multiply(float val1, float val2, float val3, out float outVal)\n{\noutVal = val1 * val2;\n}\nvoid node_math_divide(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = val1 / val2;\n}\nvoid node_math_sine(float val, float val2, float val3, out float outVal)\n{\noutVal = sin(val);\n}\nvoid node_math_cosine(float val, float val2, float val3, out float outVal)\n{\noutVal = cos(val);\n}\nvoid node_math_tangent(float val, float val2, float val3, out float outVal)\n{\noutVal = tan(val);\n}\nvoid node_math_arcsine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = asin(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arccosine(float val, float val2, float val3, out float outVal)\n{\nif (val <= 1.0 && val >= -1.0)\noutVal = acos(val);\nelse\noutVal = 0.0;\n}\nvoid node_math_arctangent(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val);\n}\nvoid node_math_arctan2(float val, float val2, float val3, out float outVal)\n{\noutVal = atan(val, val2);\n}\nvoid node_math_power(float val1, float val2, float val3, out float outVal)\n{\nif (val1 >= 0.0)\noutVal = powCompat(val1, val2);\nelse {\nfloat val2_mod_1 = mod(abs(val2), 1.0);\nif (val2_mod_1 > 0.999 || val2_mod_1 < 0.001)\noutVal = powCompat(val1, floor(val2 + 0.5));\nelse\noutVal = 0.0;\n}\n}\nvoid node_math_logarithm(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > 0.0 && val2 > 0.0)\noutVal = log2(val1) / log2(val2);\nelse\noutVal = 0.0;\n}\nvoid node_math_sqrt(float val1, float val2, float val3, out float outVal)\n{\noutVal = sqrt(val1);\n}\nvoid node_math_maximum(float val1, float val2, float val3, out float outVal)\n{\noutVal = max(val1, val2);\n}\nvoid node_math_minimum(float val1, float val2, float val3, out float outVal)\n{\noutVal = min(val1, val2);\n}\nvoid node_math_round(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1 + 0.5);\n}\nvoid node_math_floor(float val1, float val2, float val3, out float outVal)\n{\noutVal = floor(val1);\n}\nvoid node_math_ceil(float val1, float val2, float val3, out float outVal)\n{\noutVal = ceil(val1);\n}\nvoid node_math_fract(float val1, float val2, float val3, out float outVal)\n{\noutVal = fract(val1);\n}\nvoid node_math_less_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 < val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_greater_than(float val1, float val2, float val3, out float outVal)\n{\nif (val1 > val2)\noutVal = 1.0;\nelse\noutVal = 0.0;\n}\nvoid node_math_modulo(float val1, float val2, float val3, out float outVal)\n{\nif (val2 == 0.0)\noutVal = 0.0;\nelse\noutVal = mod(val1, val2);\noutVal = (val1 > 0.0) ? outVal : outVal - val2;\n}\nvoid node_math_absolute(float val1, float val2, float val3, out float outVal)\n{\noutVal = abs(val1);\n}\nvoid node_math_compare(float val1, float val2, float val3, out float outVal) {\noutVal = step(abs(val1 - val2), val3);\n}\nvoid node_math_cosh(float val1, float val2, float val3, out float outVal) {\noutVal = cosh(val1);\n}\nvoid node_math_degrees(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / PI * 180.0;\n}\nvoid node_math_exponent(float val1, float val2, float val3, out float outVal) {\noutVal = exp(val1);\n}\nvoid node_math_inverse_sqrt(float val1, float val2, float val3, out float outVal) {\nif (val1 >= 0.0) {\noutVal = 1.0 / sqrt(val1);\n} else {\noutVal = 0.0;\n}\n}\nvoid node_math_multiply_add(float val1, float val2, float val3, out float outVal) {\noutVal = val1 * val2 + val3;\n}\nvoid node_math_pingpong(float val1, float val2, float val3, out float outVal) {\nif (val2 == 0.0) {\noutVal = 0.0;\n} else {\nfloat absVal2 = abs(val2);\nfloat rem = mod(val1, absVal2);\noutVal = mix(rem, absVal2 - rem, mod(floor(val1 / absVal2), 2.0));\n}\n}\nvoid node_math_radians(float val1, float val2, float val3, out float outVal) {\noutVal = val1 / 180.0 * PI;\n}\nvoid node_math_sign(float val1, float val2, float val3, out float outVal) {\noutVal = sign(val1);\n}\nvoid node_math_sinh(float val1, float val2, float val3, out float outVal) {\noutVal = sinh(val1);\n}\nvoid node_math_smooth_max(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMax(val1, val2, val3);\n}\nvoid node_math_smooth_min(float val1, float val2, float val3, out float outVal) {\noutVal = smoothMin(val1, val2, val3);\n}\nvoid node_math_snap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5 * sign(val2);\nfloat quot = val1 / val2;\noutVal = floor(quot) * val2;\n}\nvoid node_math_tanh(float val1, float val2, float val3, out float outVal) {\noutVal = tanh(val1);\n}\nvoid node_math_trunc(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = trunc(val1);\n}\nvoid node_math_wrap(float val1, float val2, float val3, out float outVal) {\nval1 += 1e-5;\noutVal = mod(val1 - val3, val2 - val3) + val3;\n}",node_mix_rgb_bl_frag:"\nvoid node_mix_rgb_mix(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_add(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 + col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_multiply(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 * col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_screen(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = vec4(1.0) - (vec4(facm) + fac * (vec4(1.0) - col2)) * (vec4(1.0) - col1);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_overlay(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (outCol.r < 0.5)\noutCol.r *= facm + 2.0 * fac * col2.r;\nelse\noutCol.r = 1.0 - (facm + 2.0 * fac * (1.0 - col2.r)) * (1.0 - outCol.r);\nif (outCol.g < 0.5)\noutCol.g *= facm + 2.0 * fac * col2.g;\nelse\noutCol.g = 1.0 - (facm + 2.0 * fac * (1.0 - col2.g)) * (1.0 - outCol.g);\nif (outCol.b < 0.5)\noutCol.b *= facm + 2.0 * fac * col2.b;\nelse\noutCol.b = 1.0 - (facm + 2.0 * fac * (1.0 - col2.b)) * (1.0 - outCol.b);\n}\nvoid node_mix_rgb_subtract(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, col1 - col2, fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_divide(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nif (col2.r != 0.0) outCol.r = facm * outCol.r + fac * outCol.r / col2.r;\nif (col2.g != 0.0) outCol.g = facm * outCol.g + fac * outCol.g / col2.g;\nif (col2.b != 0.0) outCol.b = facm * outCol.b + fac * outCol.b / col2.b;\n}\nvoid node_mix_rgb_difference(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = mix(col1, abs(col1 - col2), fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_darken(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = min(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_lighten(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol.rgb = max(col1.rgb, col2.rgb * fac);\noutCol.a = col1.a;\n}\nvoid node_mix_rgb_dodge(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1;\nif (outCol.r != 0.0) {\nfloat tmp = 1.0 - fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 1.0;\nelse if ((tmp = outCol.r / tmp) > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\n}\nif (outCol.g != 0.0) {\nfloat tmp = 1.0 - fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 1.0;\nelse if ((tmp = outCol.g / tmp) > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\n}\nif (outCol.b != 0.0) {\nfloat tmp = 1.0 - fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 1.0;\nelse if ((tmp = outCol.b / tmp) > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n}\nvoid node_mix_rgb_burn(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat tmp, facm = 1.0 - fac;\noutCol = col1;\ntmp = facm + fac * col2.r;\nif (tmp <= 0.0)\noutCol.r = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.r) / tmp)) < 0.0)\noutCol.r = 0.0;\nelse if (tmp > 1.0)\noutCol.r = 1.0;\nelse\noutCol.r = tmp;\ntmp = facm + fac * col2.g;\nif (tmp <= 0.0)\noutCol.g = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.g) / tmp)) < 0.0)\noutCol.g = 0.0;\nelse if (tmp > 1.0)\noutCol.g = 1.0;\nelse\noutCol.g = tmp;\ntmp = facm + fac * col2.b;\nif (tmp <= 0.0)\noutCol.b = 0.0;\nelse if ((tmp = (1.0 - (1.0 - outCol.b) / tmp)) < 0.0)\noutCol.b = 0.0;\nelse if (tmp > 1.0)\noutCol.b = 1.0;\nelse\noutCol.b = tmp;\n}\n#ifdef HSV_NODES\nvoid node_mix_rgb_hue(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\nvoid node_mix_rgb_saturation(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2;\nrgbToHSV(outCol, hsv);\nif (hsv.y != 0.0) {\nrgbToHSV(col2, hsv2);\nhsv.y = facm * hsv.y + fac * hsv2.y;\nhsvToRGB(hsv, outCol);\n}\n}\nvoid node_mix_rgb_value(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 hsv, hsv2;\nrgbToHSV(col1, hsv);\nrgbToHSV(col2, hsv2);\nhsv.z = facm * hsv.z + fac * hsv2.z;\nhsvToRGB(hsv, outCol);\n}\nvoid node_mix_rgb_color(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\noutCol = col1;\nvec4 hsv, hsv2, tmp;\nrgbToHSV(col2, hsv2);\nif (hsv2.y != 0.0) {\nrgbToHSV(outCol, hsv);\nhsv.x = hsv2.x;\nhsv.y = hsv2.y;\nhsvToRGB(hsv, tmp);\noutCol = mix(outCol, tmp, fac);\noutCol.a = col1.a;\n}\n}\n#endif\nvoid node_mix_rgb_soft_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\nfloat facm = 1.0 - fac;\nvec4 one = vec4(1.0);\nvec4 scr = one - (one - col2) * (one - col1);\noutCol = facm * col1 + fac * ((one - col1) * col2 * col1 + col1 * scr);\n}\nvoid node_mix_rgb_linear_light(float fac, vec4 col1, vec4 col2, out vec4 outCol)\n{\nfac = clamp(fac, 0.0, 1.0);\noutCol = col1 + fac * (2.0 * (col2 - vec4(0.5)));\n}",node_mix_shader_bl_frag:"\nvoid node_mix_shader(int transpShaderNum,\nfloat fac, vec4 color1, vec4 color2, out vec4 outColor)\n{\nif (transpShaderNum == 0)\ncolor1.rgb = color2.rgb;\nelse if (transpShaderNum == 1)\ncolor2.rgb = color1.rgb;\noutColor = mix(color1, color2, fac);\n}",node_new_geometry_bl_frag:"void node_new_geometry(\nbool frontFacing, vec3 viewPos, vec3 viewNorm,\nout vec3 position, out vec3 normal, out vec3 tangent,\nout vec3 trueNormal, out vec3 incoming, out vec3 parametric,\nout float backfacing, out float pointiness, out float randomPerIsland)\n{\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nposition = swizzleUpZ(posWorld.xyz);\nvec4 viewDir = isOrtho(projectionMatrix) ? vec4(0.0, 0.0, -1.0, 0.0) : vec4(normalize(-viewPos), 0.0);\nviewDir = invViewMatrix * viewDir;\nvec3 incomingVec = -swizzleUpZ(viewDir.xyz);\n#if WORLD_NODES == 1\nnormal = incomingVec;\ntangent = vec3(0.0);\n#else\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nnormal = swizzleUpZ(norWorld);\nvec4 posLocal = invModelMatrix * posWorld;\nvec3 posLocalDelta = posLocal.xyz - boundingBoxMin;\nvec3 bbDelta = boundingBoxMax - boundingBoxMin;\nvec3 posOrco = vec3(\nbbDelta.x < 1e-5 ? -sign(posLocal.y) : posLocalDelta.x / bbDelta.x,\n0.0,\nbbDelta.z < 1e-5 ? sign(posLocal.y) : posLocalDelta.z / bbDelta.z\n);\nposOrco -= 0.5;\nvec3 tangWorld = (modelMatrix * vec4(posOrco.z, 0.0, -posOrco.x, 0.0)).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\ntangent = swizzleUpZ(tangWorld);\n#endif\ntrueNormal = normal;\nincoming = incomingVec;\nparametric = vec3(0.0);\nbackfacing = (frontFacing) ? 0.0 : 1.0;\n#if WORLD_NODES == 1\npointiness = 0.0;\n#else\npointiness = 0.5;\n#endif\nrandomPerIsland = 0.0;\n}",node_normal_bl_frag:"\nvoid node_normal(vec3 norParam, vec3 norIn, out vec3 norOut, out float dotOut)\n{\nnorOut = norParam;\ndotOut = dot(normalize(norIn), norParam);\n}",node_normal_map_bl_frag:"\nvoid node_normal_map(vec4 tangent, vec3 normal, float strength, vec4 normalColor, out vec3 normalOut)\n{\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, strength);\nnormalOut = normalize((invViewMatrix * vec4(normalOut, 0.0)).xyz);\nnormalOut = swizzleUpZ(normalOut);\n}",node_object_info_bl_frag:"uniform int objectIndex;\nuniform vec4 objectColor;\nuniform int materialIndex;\nuniform float objectRandom;\nvoid node_object_info(out vec3 location, out vec4 color, out float alpha, out float objIndex,\nout float matIndex, out float random) {\n#if WORLD_NODES == 1\nlocation = vec3(0.0);\ncolor = vec4(1.0);\nalpha = 1.0;\nobjIndex = 0.0;\nmatIndex = 0.0;\nrandom = 0.0;\n#else\nlocation = swizzleUpZ(modelMatrix[3].xyz);\ncolor = vec4(objectColor.rgb, 1.0);\nalpha = objectColor.a;\nobjIndex = float(objectIndex);\nmatIndex = float(materialIndex);\nrandom = float(objectRandom);\n#endif\n}\nvoid node_object_info(out vec3 location, out vec4 color, out float objIndex,\nout float matIndex, out float random) {\nfloat alpha;\nnode_object_info(location, color, alpha, objIndex, matIndex, random);\n}",node_output_lamp_bl_frag:"void node_output_lamp(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_output_material_bl_frag:"void node_output_material(vec4 surface, vec4 volume, vec3 displacement, float thickness, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}\nvoid node_output_material(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\nnode_output_material(surface, volume, displacement, 0.0, outgoingLight);\n}",node_output_world_bl_frag:"void node_output_world(vec4 surface, vec4 volume, out vec4 outgoingLight)\n{\noutgoingLight = surface;\n}",node_particle_info_bl_frag:"\nvoid node_particle_info(out float index, out float random, out float age,\nout float lifeTime, out vec3 location, out float size, out vec3 velocity,\nout vec3 angularVelocity) {\n#if WORLD_NODES == 1\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#else\nindex = 0.0;\nrandom = 0.0;\nage = 0.0;\nlifeTime = 0.0;\nlocation = vec3(0.0);\nsize = 0.0;\nvelocity = vec3(0.0);\nangularVelocity = vec3(0.0);\n#endif\n}",node_point_info_bl_frag:"void node_point_info(out vec3 position, out float radius, out float random) {\nposition = vec3(0.0);\nradius = 0.0;\nrandom = 0.0;\n}",node_principled_volume_bl_frag:"void node_principled_volume(vec4 color, float colorAttribute, float density,\nfloat densityAttribute, float anisotropy, vec4 absorptionColor,\nfloat emissionStrength, vec4 emissionColor, float blackbodyIntensity,\nvec4 blackbodyTint, float temperature, float temperatureAttribute,\nout vec4 volume) {\nvolume = vec4(0.0);\n}",node_rgb_bl_frag:"\nuniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_rgbtobw_bl_frag:"\nvoid node_rgbtobw(vec4 color, out float outVal) {\noutVal = linearToRelativeLuminance(color.rgb);\n}",node_script_bl_frag:"void node_script(out vec4 outColor)\n{\noutColor = vec4(0.0);\n}",node_sephsv_bl_frag:"\nvoid node_sephsv(vec4 col, out float h, out float s, out float v)\n{\nvec4 hsv;\nrgbToHSV(col, hsv);\nh = hsv[0];\ns = hsv[1];\nv = hsv[2];\n}",node_separate_color_bl_frag:"#define NODE_SEP_COL_RGB 0\n#define NODE_SEP_COL_HSV 1\n#define NODE_SEP_COL_HSL 2\nvoid rgbToHSL(vec3 rgb, out vec3 outCol)\n{\nfloat cMax, cMin;\nfloat h, s, l;\ncMax = max(rgb[0], max(rgb[1], rgb[2]));\ncMin = min(rgb[0], min(rgb[1], rgb[2]));\nl = min(1.0, (cMax + cMin) / 2.0);\nif (cMax == cMin) {\nh = s = 0.0;\n} else {\nfloat cdelta = cMax - cMin;\ns = l > 0.5 ? cdelta / (2.0 - cMax - cMin) : cdelta / (cMax + cMin);\nif (cMax == rgb[0]) {\nh = (rgb[1] - rgb[2]) / cdelta + (rgb[1] < rgb[2] ? 6.0 : 0.0);\n} else if (cMax == rgb[1]) {\nh = (rgb[2] - rgb[0]) / cdelta + 2.0;\n} else {\nh = (rgb[0] - rgb[1]) / cdelta + 4.0;\n}\n}\nh /= 6.0;\noutCol = vec3(h, s, l);\n}\nvoid node_separate_color(int mode, vec4 col, out float r, out float g, out float b)\n{\nif (mode == NODE_SEP_COL_RGB) {\nr = col.r;\ng = col.g;\nb = col.b;\n} else if (mode == NODE_SEP_COL_HSV) {\nvec4 hsv;\nrgbToHSV(col, hsv);\nr = hsv[0];\ng = hsv[1];\nb = hsv[2];\n} else {\nvec3 hsl;\nrgbToHSL(col.rgb, hsl);\nr = hsl[0];\ng = hsl[1];\nb = hsl[2];\n}\n}",node_seprgb_bl_frag:"\nvoid node_seprgb(vec4 col, out float r, out float g, out float b)\n{\nr = col.r;\ng = col.g;\nb = col.b;\n}",node_sepxyz_bl_frag:"void node_sepxyz(vec3 vector, out float x, out float y, out float z)\n{\nx = vector.x;\ny = vector.y;\nz = vector.z;\n}",node_shadertorgb_bl_frag:"void node_shadertorgb(vec4 shader, out vec4 color, out float alpha) {\ncolor = vec4(shader.rgb, 1.0);\nalpha = shader.a;\n}",node_squeeze_bl_frag:"\nvoid node_squeeze(float val, float width, float center, out float outVal)\n{\noutVal = 1.0 / (1.0 + pow(2.71828183, -((val - center) * width)));\n}",node_subsurface_scattering_bl_frag:"void node_subsurface_scattering(\nvec4 color, float scale, vec3 radius, float sharpen, float textureBlur, vec3 normal,\nout vec4 outColor)\n{\noutColor = color;\n}",node_tangent_bl_frag:"#define TANGENT_AXIS_X 0\n#define TANGENT_AXIS_Y 1\n#define TANGENT_AXIS_Z 2\nvoid node_tangent(int axis, vec3 viewPos, vec3 viewNorm, out vec3 outTangent) {\noutTangent = vec3(0.0);\n#if WORLD_NODES == 0\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 norWorld = normalize(invViewMatrix * vec4(viewNorm, 0.0)).xyz;\nvec3 posLocal = (invModelMatrix * posWorld).xyz;\nvec3 posOrco = (posLocal - boundingBoxMin)\n/ (boundingBoxMax - boundingBoxMin) - 0.5;\nvec4 posOrcoPermuted;\nif (axis == TANGENT_AXIS_X) {\nposOrcoPermuted = vec4(0.0, -posOrco.z, posOrco.y, 0.0);\n} else if (axis == TANGENT_AXIS_Y) {\nposOrcoPermuted = vec4(-posOrco.y, posOrco.x, 0.0, 0.0);\n} else if (axis == TANGENT_AXIS_Z) {\nposOrcoPermuted = vec4(posOrco.z, 0.0, -posOrco.x, 0.0);\n}\nvec3 tangWorld = (modelMatrix * posOrcoPermuted).xyz;\ntangWorld = cross(norWorld, normalize(cross(tangWorld, norWorld)));\noutTangent = swizzleUpZ(tangWorld);\n#endif\n}\nvoid node_tangent(vec4 tangent, out vec3 outTangent) {\n#if WORLD_NODES == 0\noutTangent = normalize((modelMatrix * vec4(tangent.xyz, 0.0)).xyz);\noutTangent = swizzleUpZ(outTangent);\n#endif\n}",node_tex_brick_bl_frag:"float integer_noise(int rowCount, int brickCount)\n{\n#if __VERSION__ == 300\nint n = (rowCount << 16) + (brickCount & 0xFFFF);\nn = (n + 1013) & 0x7fffffff;\nn = (n >> 13) ^ n;\nint nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;\nreturn 0.5 * (float(nn) / 1073741824.0);\n#else\nconst int RAND_MAX = 32767;\nint next = ((123456 * rowCount) + brickCount) * 1103515245 + 12345;\nreturn (mod(float(next/65536), float(RAND_MAX + 1))) / float(RAND_MAX);\n#endif\n}\nvoid node_tex_brick(\nfloat offset, int offsetFrequency, float squash, int squashFrequency, \nvec3 vector, vec4 color1, vec4 color2, vec4 mortar, float scale,\nfloat mortarSize, float mortarSmooth, float bias, float brickWidth,\nfloat rowHeight,\nout vec4 outColor, out float outFac)\n{\nfloat x, y;\nvec3 p = vector * scale;\nfloat rowCount = floor(p.y / rowHeight);\nif (offsetFrequency != 0 && squashFrequency != 0) {\nbrickWidth *= mod(rowCount, float(squashFrequency)) > 0.5 ? 1.0 : squash;\noffset = mod(rowCount, float(offsetFrequency)) > 0.5 ? 0.0 : (brickWidth * offset);\n} \nint brickCount = int((p.x + offset) / brickWidth); \nfloat tint = clamp((integer_noise(int(rowCount), brickCount) + bias), 0.0, 1.0);\n\nx = abs((p.x + offset) - brickWidth * float(brickCount));\ny = abs(p.y - rowHeight * rowCount);\nfloat min_dist = min(min(x, y), min(brickWidth - x, rowHeight - y));\n\nfloat f = step(min_dist, mortarSize);\nif (mortarSmooth > 0.0) {\nmin_dist = 1.0 - min_dist / mortarSize;\nf *= smoothstep(0.0, mortarSmooth, min_dist);\n}\noutColor = mix(mix(color1, color2, tint), mortar, f);\noutFac = f;\n}",node_tex_checker_bl_frag:"void node_tex_checker(vec3 vector, vec4 color1, vec4 color2, float scale, \nout vec4 outColor, out float outFac)\n{\nvec3 p = vector * scale;\np = (p + 0.00001) * 0.99999;\nfloat cx = floor(p.x);\nfloat cy = floor(p.y);\nfloat cz = floor(p.z);\nfloat result = sign(mod(cx + cy + cz, 2.0));\noutFac = max(result, 0.0);\noutColor = mix(color2, color1, outFac);\n}",node_tex_coord_bl_frag:"uniform mat4 nodeTexCoordObjectMatrices[NODE_TEX_COORD_NUM];\nvoid node_tex_coord(\nmat4 objectMat, vec3 viewPos, vec3 viewNorm, vec2 uv,\nout vec3 outGenerated, out vec3 outNormal, out vec3 outUV, out vec3 outObject,\nout vec3 outCamera, out vec3 outWindow, out vec3 outReflection)\n{\nvec4 view = vec4(-viewPos, 1.0);\nvec4 posWorld = invViewMatrix * view;\nvec3 loc = swizzleUpZ((invModelMatrix * posWorld).xyz);\n#if WORLD_NODES == 1\nloc = normalize(loc);\n#endif\n#if WORLD_NODES == 1\noutGenerated = loc;\n#else\nvec3 boxMin = vec3(boundingBoxMin.x, -boundingBoxMax.z, boundingBoxMin.y);\nvec3 boxMax = vec3(boundingBoxMax.x, -boundingBoxMin.z, boundingBoxMax.y);\nvec3 boxSize = boxMax - boxMin;\nif (abs(boxSize.x) < 0.001) {\noutGenerated.x = 0.5;\n} else {\noutGenerated.x = (loc.x - boxMin.x) / boxSize.x;\n}\nif (abs(boxSize.y) < 0.001) {\noutGenerated.y = 0.5;\n} else {\noutGenerated.y = (loc.y - boxMin.y) / boxSize.y;\n}\nif (abs(boxSize.z) < 0.001) {\noutGenerated.z = 0.5;\n} else {\noutGenerated.z = (loc.z - boxMin.z) / boxSize.z;\n}\n#endif\n#if WORLD_NODES == 1\noutNormal = -loc;\n#else\noutNormal = normalize(invModelMatrix * invViewMatrix * vec4(viewNorm, 0.0)).rgb;\noutNormal = swizzleUpZ(outNormal);\n#endif\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n#if WORLD_NODES == 1\noutObject = loc;\n#else\noutObject = swizzleUpZ((objectMat * posWorld).xyz);\n#endif\noutCamera = vec3(view.xy, -view.z);\n#if WORLD_NODES == 1\noutWindow = vec3(0.0);\n#else\noutWindow = vec3(gl_FragCoord.xy / viewWidthHeight, 0.0);\n#endif\n#if WORLD_NODES == 1\noutReflection = -loc;\n#else\nvec4 reflection = (invViewMatrix * vec4(reflect(view.xyz, normalize(viewNorm)), 0.0));\noutReflection = normalize(swizzleUpZ(reflection.xyz));\n#endif\n}",node_tex_environment_bl_frag:"#define TEX_PROJ_EQUIRECTANGULAR 0\n#define TEX_PROJ_MIRROR_BALL 1\nvoid node_tex_environment(sampler2D tex, const int encoding, const int projection, vec3 vector, out vec4 outColor) {\nvec2 uv;\nfloat bias;\nif (projection == TEX_PROJ_EQUIRECTANGULAR) {\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.z, direction.x) * RECIPROCAL_PI2 + 0.5;\n#if WORLD_NODES == 1\nbias = -16.0;\n#else\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.z) / seamWidth) *\nclamp (1.0 - direction.x / seamWidth, 0.0, 1.0);\nbias = seamBiasFactor * seam;\n#endif\n} else {\nvec3 normal = normalize(vector);\nnormal.y -= 1.0;\nnormal /= (2.0 * sqrt(max(-0.5 * normal.y, 0.0)));\nuv = clamp(0.5 * normal.xz + 0.5, 0.0, 1.0);\nbias = 0.0;\n}\nuv.y = 1.0 - uv.y;\noutColor = texture2D(tex, uv, bias);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_tex_environment_none_bl_frag:"void node_tex_environment_none(vec3 vector, out vec4 outColor) {\noutColor = vec4(1.0, 0.0, 1.0, 1.0);\n}",node_tex_gradient_bl_frag:"#define TEX_GRAD_LINEAR 0\n#define TEX_GRAD_QUADRATIC 1\n#define TEX_GRAD_EASING 2\n#define TEX_GRAD_DIAGONAL 3\n#define TEX_GRAD_SPHERICAL 4\n#define TEX_GRAD_QUADRATIC_SPHERE 5\n#define TEX_GRAD_RADIAL 6\nvoid node_tex_gradient(const int type, vec3 vector, out vec4 outColor, out float outFac)\n{\nfloat x, y, z, r;\nx = vector.x;\ny = vector.y;\nz = vector.z;\nif (type == TEX_GRAD_LINEAR) {\noutFac = x;\n} else if (type == TEX_GRAD_QUADRATIC) {\nr = max(x, 0.0);\noutFac = pow2(r);\n} else if (type == TEX_GRAD_EASING) {\nr = min(max(x, 0.0), 1.0);\noutFac = (3.0 * pow2(r) - 2.0 * pow3(r));\n} else if (type == TEX_GRAD_DIAGONAL) {\noutFac = (x + y) * 0.5;\n} else if (type == TEX_GRAD_RADIAL) {\noutFac = atan(y, x) / PI2 + 0.5;\n} else {\nr = max(0.99999 - sqrt(x * x + y * y + z * z), 0.0);\nif (type == TEX_GRAD_QUADRATIC_SPHERE) {\noutFac = pow2(r);\n} else if (type == TEX_GRAD_SPHERICAL) {\noutFac = r;\n}\n}\noutFac = clamp(outFac, 0.0, 1.0);\noutColor = vec4(outFac, outFac, outFac, 1.0);\n}",node_tex_ies_bl_frag:"void node_tex_ies(vec3 vector, float strength, out float fac) {\nfac = 0.0;\n}",node_tex_image_bl_frag:"#define TEX_PROJ_FLAT 0\n#define TEX_PROJ_BOX 1\n#define TEX_PROJ_SPHERE 2\n#define TEX_PROJ_TUBE 3\nvoid node_tex_image(sampler2D ima, const int encoding, vec3 viewNorm,\nconst int projection, const float projectionBlend, const bool clampToEdgeNoExtend,\nvec3 vector,\nout vec4 outColor, out float outAlpha) {\nif (projection == TEX_PROJ_FLAT) {\nvec2 uv = vector.xy;\nuv.y = 1.0 - uv.y;\nif (clampToEdgeNoExtend && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {\noutColor = vec4(0.0);\noutAlpha = 0.0;\n} else {\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\n}\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_BOX) {\nvec3 norm = normalize(viewNorm * normalMatrix);\nvector = swizzleUpY(vector);\nvec2 uvX = vec2(-sign(norm.x) * vector.z, -vector.y);\nvec2 uvY = vec2(sign(norm.y) * vector.z, -vector.x);\nvec2 uvZ = vec2(sign(norm.z) * vector.x, -vector.y);\nvec4 colX = nodeTexelToLinear(texture2D(ima, uvX), encoding);\nvec4 colY = nodeTexelToLinear(texture2D(ima, uvY), encoding);\nvec4 colZ = nodeTexelToLinear(texture2D(ima, uvZ), encoding);\nvec3 barycentric = abs(norm);\nbarycentric /= barycentric.x + barycentric.y + barycentric.z;\nvec3 edgeShape = min(min(barycentric.yzx, barycentric.zxy),\n(projectionBlend - 1.0) / (projectionBlend - 3.0));\nvec3 edgeValue = (1.0 - projectionBlend) * (1.0 - edgeShape) / 2.0;\nvec3 weight = max((barycentric - edgeValue) / (1.0 - edgeValue), EPSILON);\nweight /= (weight.x + weight.y + weight.z);\noutColor = weight.x * colX + weight.y * colY + weight.z * colZ;\noutAlpha = outColor.a;\n} else if (projection == TEX_PROJ_SPHERE) {\nvector = normalize(vector * 2.0 - 1.0);\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, acos(vector.y) / PI);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n} else if (projection == TEX_PROJ_TUBE) {\nvector = vector * 2.0 - 1.0;\nvector = swizzleUpY(vector);\nvec2 uv = vec2(atan(vector.x, vector.z) / PI2, (1.0 - vector.y) / 2.0);\nuv.x = mod(uv.x, 1.0);\noutColor = texture2D(ima, uv);\noutAlpha = outColor.a;\noutColor = nodeTexelToLinear(outColor, encoding);\n}\n}",node_tex_image_none_bl_frag:"void node_tex_image_none(vec3 vector, out vec4 color, out float alpha)\n{\ncolor = vec4(1.0, 0.0, 1.0, 1.0);\nalpha = 1.0;\n}",node_tex_magic_bl_frag:"void node_tex_magic(vec3 vector, float scale, float distortion,\nout vec4 outColor, out float outFac)\n{\noutColor = vec4(0.0);\noutFac = 0.0;\n}",node_tex_musgrave_bl_frag:"void node_tex_musgrave(vec3 vector, float w, float scale, float detail,\nfloat dimension, float lacunarity, float offset, float gain,\nout float outFac) {\noutFac = 0.0;\n}",node_tex_noise_bl_frag:"\nvoid node_tex_noise(\nfloat falloffFactor, float dispersionFactor,\nvec3 vector, float w, float scale, float detail, float roughness,\nfloat distortion, out float outFac, out vec4 outColor) {\nvec3 p = vector * scale;\nvec3 dx = dFdx(p);\nvec3 dy = dFdy(p);\nfloat octaveLenPerPixel = (length(dx) + length(dy)) / 4.0;\nif (distortion != 0.0) {\nvec3 r, offset = vec3(13.5, 13.5, 13.5);\nr.x = noiseSmooth(p + offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.y = noiseSmooth(p, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\nr.z = noiseSmooth(p - offset, octaveLenPerPixel, falloffFactor,\ndispersionFactor) * distortion;\np += r;\n}\noutFac = noiseTurbulence(p, detail, octaveLenPerPixel, falloffFactor,\ndispersionFactor);\nvec3 color = vec3(outFac,\nnoiseTurbulence(vec3(p.y, p.x, p.z), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor),\nnoiseTurbulence(vec3(p.y, p.z, p.x), detail, octaveLenPerPixel,\nfalloffFactor, dispersionFactor)\n);\noutColor = vec4(color, 1.0);\n}",node_tex_pointdensity_bl_frag:"void node_tex_pointdensity(\nvec3 vector,\nout vec4 outColor, out float outDensity)\n{\noutColor = vec4(0.0);\noutDensity = 0.0;\n}",node_tex_sky_bl_frag:"\n#define TEX_SKY_PREETHAM 0\n#define TEX_SKY_HOSEK_WILKIE 1\n#define TEX_SKY_NISHITA 2\n#define Km 683.0\nvoid node_tex_sky(const int skyType, vec3 param0, vec3 param1, vec3 param2,\nvec3 param3, vec3 param4, vec3 param5, vec3 param6, vec3 param7,\nvec3 param8, vec3 radiance, vec3 sunDirection, vec3 vectorIn,\nout vec4 outColor) {\nif (length(vectorIn) == 0.0) {\nvectorIn = vec3(0.0, 1.0, 0.0);\n} else {\nvectorIn = normalize(vectorIn);\n}\nvectorIn = swizzleUpY(vectorIn);\nsunDirection = swizzleUpY(sunDirection);\nfloat cosGamma = clamp(dot(vectorIn, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(vectorIn.y, 0.0, 1.0);\nif (skyType == TEX_SKY_PREETHAM) {\nvec3 radInternal = (1.0 + param0 * exp(param1 / cosTheta)) * (\n1.0 + param2 * exp(param3 * acos(cosGamma))\n+ param4 * pow(cosGamma, 2.0)\n);\nvec3 XYZ = xyY_to_XYZ(radInternal.y * radiance.y,\nradInternal.z * radiance.z, radInternal.x * radiance.x);\noutColor = vec4(max(xyz_to_sRGB(XYZ), 0.0), 1.0);\n} else if (skyType == TEX_SKY_HOSEK_WILKIE) {\nfloat cosGammaSq = pow(cosGamma, 2.0);\nvec3 chi = (1.0 + cosGammaSq) / pow(1.0 + pow(param8, vec3(2.0))\n- 2.0 * param8 * cosGamma, vec3(1.5));\nvec3 radInternal = (1.0 + param0 * exp(param1 / (cosTheta + 0.01))) * (\nparam2 + param3 * exp(param4 * acos(cosGamma))\n+ param5 * cosGammaSq + param6 * chi + param7 * sqrt(cosTheta)\n);\noutColor = vec4(max(xyz_to_sRGB(radInternal * radiance), 0.0) * PI2/Km, 1.0);\n} else {\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n}\n}",node_tex_voronoi_bl_frag:"#define DISTANCE_EUCLIDEAN 0\n#define DISTANCE_MANHATTAN 1\n#define DISTANCE_CHEBYCHEV 2\n#define DISTANCE_MINKOWSKI 3\n#define FEATURE_F1 0\n#define FEATURE_F2 1\n#define FEATURE_SMOOTH_F1 2\n#define FEATURE_DISTANCE_TO_EDGE 3\n#define FEATURE_N_SPHERE_RADIUS 4\nstruct VoronoiGridData {\nvec3 point;\nvec3 randVec;\nvec3 toClosest;\nfloat dist;\n};\nfloat worleyLength(vec3 vec, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn length(vec);\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(vec.x) + abs(vec.y) + abs(vec.z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(vec.x), abs(vec.y)), abs(vec.z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nreturn pow(pow(abs(vec.x), exponent)\n+ pow(abs(vec.y), exponent)\n+ pow(abs(vec.z), exponent), 1.0 / exponent);\n}\nreturn 0.0;\n}\nvoid worleyNoise(vec3 pos, int distance, float exponent, int feature,\nfloat smoothness, float randomness, out float outDist, out vec4 outColor,\nout vec3 outPosition, out float outW, out float outRadius) {\nconst highp float RAND_FIX_ZERO = 0.125;\nvec3 posI = floor(pos);\nvec3 posF = fract(pos);\nVoronoiGridData vgd[27];\n#pragma unroll_loop_start\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop_start\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop_start\nfor (int k = 0; k <= 2; k++) {\nvec3 point = vec3((i), (j), (k)) - 1.0;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\nconst int counter = (i) + (j) * 3 + (k) * 9;\nvgd[counter].point = point;\nvgd[counter].randVec = randVec;\nvgd[counter].toClosest = toClosest;\nvgd[counter].dist = worleyLength(toClosest, distance, exponent);\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\nfloat f1 = 1e10;\nfloat f2 = 1e10;\nvec3 edgeToClosest = vec3(0.0);\nfloat distToEdge = 1e10;\nvec3 randColF1 = vec3(0.0);\nvec3 randColF2 = vec3(0.0);\nvec3 toClosestF1 = vec3(0.0);\nvec3 toClosestF2 = vec3(0.0);\nvec3 radPoint = vec3(0.0);\nvec3 radToClosest = vec3(0.0);\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nif (feature == FEATURE_F1) {\nif (vgd[i].dist < f1) {\nf1 = vgd[i].dist;\nrandColF1 = vgd[i].randVec;\ntoClosestF1 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_F2) {\nif (vgd[i].dist < f1) {\nf2 = f1;\nf1 = vgd[i].dist;\nrandColF2 = randColF1;\nrandColF1 = vgd[i].randVec;\ntoClosestF2 = toClosestF1;\ntoClosestF1 = vgd[i].toClosest;\n} else if (vgd[i].dist < f2) {\nf2 = vgd[i].dist;\nrandColF2 = vgd[i].randVec;\ntoClosestF2 = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_SMOOTH_F1) {\nf1 = smoothMin(f1, vgd[i].dist, smoothness);\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nedgeToClosest = vgd[i].toClosest;\n}\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat dist = worleyLength(vgd[i].toClosest, DISTANCE_EUCLIDEAN, exponent);\nif (dist < f1) {\nf1 = dist;\nradPoint = vgd[i].point;\nradToClosest = vgd[i].toClosest;\n}\n}\n}\n#pragma unroll_loop_end\nif (feature == FEATURE_F1) {\noutDist = f1;\noutColor = vec4(randColF1, 1.0);\noutPosition = pos + toClosestF1;\n} else if (feature == FEATURE_F2) {\noutDist = f2;\noutColor = vec4(randColF2, 1.0);\noutPosition = pos + toClosestF2;\n} else if (feature == FEATURE_SMOOTH_F1) {\noutDist = f1;\nvec3 avgCol = vec3(0.0);\nvec3 avgOff = vec3(0.0);\nfloat sumWeightsCol = 0.0;\nfloat sumWeightsOff = 0.0;\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nfloat smoothFac = getSmoothFactor(f1, vgd[i].dist, smoothness);\nfloat weightOff = smoothFac * smoothFac * smoothFac;\nfloat weightCol = weightOff * smoothFac;\navgCol += vgd[i].randVec * weightCol;\navgOff += vgd[i].toClosest * weightOff;\nsumWeightsCol += weightCol;\nsumWeightsOff += weightOff;\n}\n#pragma unroll_loop_end\noutColor = vec4(avgCol / sumWeightsCol, 1.0);\noutPosition = pos + avgOff / sumWeightsOff;\n} else if (feature == FEATURE_DISTANCE_TO_EDGE) {\n#pragma unroll_loop_start\nfor (int i = 0; i < 27; i++) {\nif (vgd[i].toClosest != edgeToClosest) {\nfloat dist = dot(0.5 * (edgeToClosest + vgd[i].toClosest),\nnormalize(vgd[i].toClosest - edgeToClosest));\ndistToEdge = min(distToEdge, dist);\n}\n}\n#pragma unroll_loop_end\noutDist = distToEdge;\n} else if (feature == FEATURE_N_SPHERE_RADIUS) {\nfloat diam = 1e10;\n#pragma unroll_loop_start\nfor (int i = 0; i <= 2; i++) {\n#pragma unroll_loop_start\nfor (int j = 0; j <= 2; j++) {\n#pragma unroll_loop_start\nfor (int k = 0; k <= 2; k++) {\nvec3 localPoint = vec3((i), (j), (k)) - 1.0;\nif (length(localPoint) > 0.0) {\nvec3 point = localPoint + radPoint;\nvec3 randVec = rand3(posI + point + RAND_FIX_ZERO);\nvec3 toClosest = point + randomness * randVec - posF;\ndiam = min(diam, length(toClosest - radToClosest));\n}\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\noutRadius = diam / 2.0;\n}\n}\n#define VORONOI_SMOOTH_COEFF 0.74\nvoid node_tex_voronoi(\nint distance, int feature,\nvec3 vector, float w, float scale, float smoothness, float exponent,\nfloat randomness,\nout float outDistance, out vec4 outColor, out vec3 outPosition,\nout float outW, out float outRadius) {\nvector = scale * (vector - 0.0001);\nsmoothness = clamp(smoothness, 1e-3, 1.0);\nsmoothness *= VORONOI_SMOOTH_COEFF;\nworleyNoise(vector, distance, exponent, feature, smoothness, randomness,\noutDistance, outColor, outPosition, outW, outRadius);\noutPosition /= scale;\n}\n#define FEATURE_F3 5\n#define FEATURE_F4 6\n#define FEATURE_F2F1 7\n#define COLORING_INTENSITY 0\n#define COLORING_CELLS 1\nstruct VoronoiClosest {\nvec4 closestDists;\nvec4 closestInds;\n};\nvoid updateVoronoiClosest(inout VoronoiClosest vf, vec3 newDistances,\nvec3 newIndices) {\n#pragma unroll_loop_start\nfor (int i = 0; i < 3; i++) {\nfloat currDist = newDistances[i];\nfloat currIdx = newIndices[i];\n#pragma unroll_loop_start\nfor (int j = 0; j < 4; j++) {\nif (currDist < vf.closestDists[j]) {\nfloat tmp = vf.closestDists[j];\nvf.closestDists[j] = currDist;\ncurrDist = tmp;\ntmp = vf.closestInds[j];\nvf.closestInds[j] = currIdx;\ncurrIdx = tmp;\n}\n}\n#pragma unroll_loop_end\n}\n#pragma unroll_loop_end\n}\nvec3 worleyPermute(vec3 x) {\nreturn mod((34.0 * x + 1.0) * x, 289.0);\n}\nvec3 worleyDist(vec3 x, vec3 y, vec3 z, int distance, float exponent) {\nif (distance == DISTANCE_EUCLIDEAN) {\nreturn x * x + y * y + z * z;\n} else if (distance == DISTANCE_MANHATTAN) {\nreturn abs(x) + abs(y) + abs(z);\n} else if (distance == DISTANCE_CHEBYCHEV) {\nreturn max(max(abs(x), abs(y)), abs(z));\n} else if (distance == DISTANCE_MINKOWSKI) {\nvec3 expVec = vec3(exponent);\nreturn pow(pow(abs(x), expVec)\n+ pow(abs(y), expVec)\n+ pow(abs(z), expVec), 1.0 / expVec);\n}\nreturn vec3(0.0);\n}\nVoronoiClosest worleyClosest(vec3 P, float jitter, int distance, float exponent) {\nfloat K = 0.142857142857;\nfloat Ko = 0.428571428571;\nfloat K2 = 0.020408163265306;\nfloat Kz = 0.166666666667;\nfloat Kzo = 0.416666666667;\nvec3 Pi = mod(floor(P), 289.0);\nvec3 Pf = fract(P) - 0.5;\nvec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\nvec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\nvec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\nvec3 p = worleyPermute(Pi.x + vec3(-1.0, 0.0, 1.0));\nvec3 p1 = worleyPermute(p + Pi.y - 1.0);\nvec3 p2 = worleyPermute(p + Pi.y);\nvec3 p3 = worleyPermute(p + Pi.y + 1.0);\nvec3 p11 = worleyPermute(p1 + Pi.z - 1.0);\nvec3 p12 = worleyPermute(p1 + Pi.z);\nvec3 p13 = worleyPermute(p1 + Pi.z + 1.0);\nvec3 p21 = worleyPermute(p2 + Pi.z - 1.0);\nvec3 p22 = worleyPermute(p2 + Pi.z);\nvec3 p23 = worleyPermute(p2 + Pi.z + 1.0);\nvec3 p31 = worleyPermute(p3 + Pi.z - 1.0);\nvec3 p32 = worleyPermute(p3 + Pi.z);\nvec3 p33 = worleyPermute(p3 + Pi.z + 1.0);\nvec3 ox11 = fract(p11*K) - Ko;\nvec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\nvec3 oz11 = floor(p11*K2)*Kz - Kzo;\nvec3 ox12 = fract(p12*K) - Ko;\nvec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\nvec3 oz12 = floor(p12*K2)*Kz - Kzo;\nvec3 ox13 = fract(p13*K) - Ko;\nvec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\nvec3 oz13 = floor(p13*K2)*Kz - Kzo;\nvec3 ox21 = fract(p21*K) - Ko;\nvec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\nvec3 oz21 = floor(p21*K2)*Kz - Kzo;\nvec3 ox22 = fract(p22*K) - Ko;\nvec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\nvec3 oz22 = floor(p22*K2)*Kz - Kzo;\nvec3 ox23 = fract(p23*K) - Ko;\nvec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\nvec3 oz23 = floor(p23*K2)*Kz - Kzo;\nvec3 ox31 = fract(p31*K) - Ko;\nvec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\nvec3 oz31 = floor(p31*K2)*Kz - Kzo;\nvec3 ox32 = fract(p32*K) - Ko;\nvec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\nvec3 oz32 = floor(p32*K2)*Kz - Kzo;\nvec3 ox33 = fract(p33*K) - Ko;\nvec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\nvec3 oz33 = floor(p33*K2)*Kz - Kzo;\nvec3 dx11 = Pfx + jitter*ox11;\nvec3 dy11 = Pfy.x + jitter*oy11;\nvec3 dz11 = Pfz.x + jitter*oz11;\nvec3 dx12 = Pfx + jitter*ox12;\nvec3 dy12 = Pfy.x + jitter*oy12;\nvec3 dz12 = Pfz.y + jitter*oz12;\nvec3 dx13 = Pfx + jitter*ox13;\nvec3 dy13 = Pfy.x + jitter*oy13;\nvec3 dz13 = Pfz.z + jitter*oz13;\nvec3 dx21 = Pfx + jitter*ox21;\nvec3 dy21 = Pfy.y + jitter*oy21;\nvec3 dz21 = Pfz.x + jitter*oz21;\nvec3 dx22 = Pfx + jitter*ox22;\nvec3 dy22 = Pfy.y + jitter*oy22;\nvec3 dz22 = Pfz.y + jitter*oz22;\nvec3 dx23 = Pfx + jitter*ox23;\nvec3 dy23 = Pfy.y + jitter*oy23;\nvec3 dz23 = Pfz.z + jitter*oz23;\nvec3 dx31 = Pfx + jitter*ox31;\nvec3 dy31 = Pfy.z + jitter*oy31;\nvec3 dz31 = Pfz.x + jitter*oz31;\nvec3 dx32 = Pfx + jitter*ox32;\nvec3 dy32 = Pfy.z + jitter*oy32;\nvec3 dz32 = Pfz.y + jitter*oz32;\nvec3 dx33 = Pfx + jitter*ox33;\nvec3 dy33 = Pfy.z + jitter*oy33;\nvec3 dz33 = Pfz.z + jitter*oz33;\nvec3 d11 = worleyDist(dx11, dy11, dz11, distance, exponent);\nvec3 d12 = worleyDist(dx12, dy12, dz12, distance, exponent);\nvec3 d13 = worleyDist(dx13, dy13, dz13, distance, exponent);\nvec3 d21 = worleyDist(dx21, dy21, dz21, distance, exponent);\nvec3 d22 = worleyDist(dx22, dy22, dz22, distance, exponent);\nvec3 d23 = worleyDist(dx23, dy23, dz23, distance, exponent);\nvec3 d31 = worleyDist(dx31, dy31, dz31, distance, exponent);\nvec3 d32 = worleyDist(dx32, dy32, dz32, distance, exponent);\nvec3 d33 = worleyDist(dx33, dy33, dz33, distance, exponent);\nVoronoiClosest vf = VoronoiClosest(vec4(1e10), vec4(0.0));\nupdateVoronoiClosest(vf, d11, p11);\nupdateVoronoiClosest(vf, d12, p12);\nupdateVoronoiClosest(vf, d13, p13);\nupdateVoronoiClosest(vf, d21, p21);\nupdateVoronoiClosest(vf, d22, p22);\nupdateVoronoiClosest(vf, d23, p23);\nupdateVoronoiClosest(vf, d31, p31);\nupdateVoronoiClosest(vf, d32, p32);\nupdateVoronoiClosest(vf, d33, p33);\nreturn vf;\n}\nvoid node_tex_voronoi(int coloring, int distance, int feature, vec3 vector,\nfloat scale, float exponent, out vec4 outColor, out float outFac) {\nvector = scale * (vector - 0.0001);\nVoronoiClosest vf = worleyClosest(vector, 1.0, distance, exponent);\nvec4 vorColorData;\nif (coloring == COLORING_INTENSITY) {\nvorColorData = vf.closestDists;\n} else if (coloring == COLORING_CELLS) {\nvorColorData = vf.closestInds;\n}\nfloat vorColorFac;\nif (feature == FEATURE_F1) {\nvorColorFac = vorColorData.x;\n} else if (feature == FEATURE_F2) {\nvorColorFac = vorColorData.y;\n} else if (feature == FEATURE_F3) {\nvorColorFac = vorColorData.z;\n} else if (feature == FEATURE_F4) {\nvorColorFac = vorColorData.w;\n} else if (feature == FEATURE_F2F1) {\nvorColorFac = vorColorData.y - vorColorData.x;\n}\nif (coloring == COLORING_INTENSITY) {\noutFac = vorColorFac;\noutColor = vec4(vec3(outFac), 1.0);\n} else if (coloring == COLORING_CELLS) {\nvorColorFac += 1e-3;\nfloat r = rand(vec2(vorColorFac / 289.0));\nfloat g = rand(vec2(vorColorFac / 23535.0));\nfloat b = rand(vec2(vorColorFac / 4353.0));\noutFac = (r + g + b) / 3.0;\noutColor = vec4(r, g, b, 1.0);\n}\n}",node_tex_wave_bl_frag:"#define TEX_WAVE_TYPE_BANDS 0\n#define TEX_WAVE_TYPE_RINGS 1\n#define TEX_WAVE_PROFILE_SIN 0\n#define TEX_WAVE_PROFILE_SAW 1\n#define TEX_WAVE_PROFILE_TRI 2\n#define TEX_WAVE_BANDS_DIR_X 0\n#define TEX_WAVE_BANDS_DIR_Y 1\n#define TEX_WAVE_BANDS_DIR_Z 2\n#define TEX_WAVE_BANDS_DIR_DIAGONAL 3\n#define TEX_WAVE_RINGS_DIR_X 0\n#define TEX_WAVE_RINGS_DIR_Y 1\n#define TEX_WAVE_RINGS_DIR_Z 2\n#define TEX_WAVE_RINGS_DIR_SPHERICAL 3\nvoid node_tex_wave(\nint waveType, int waveProfile, int bandsDirection, int ringsDirection,\nvec3 vector, float scale, float distortion, float detail, float detailScale,\nfloat detailRoughness, float phaseOffset,\nout vec4 outColor, out float outFac) {\nvec3 coScaled = vector * scale;\nfloat waveFac;\nvec3 waveVec = coScaled;\nif (waveType == TEX_WAVE_TYPE_BANDS) {\nconst float BANDS_AXIS_SCALE = 2.0 / 3.0;\nif (bandsDirection == TEX_WAVE_BANDS_DIR_X) {\nwaveVec = waveVec.xxx * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Y) {\nwaveVec = waveVec.yyy * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_Z) {\nwaveVec = waveVec.zzz * BANDS_AXIS_SCALE;\n} else if (bandsDirection == TEX_WAVE_BANDS_DIR_DIAGONAL) {\n}\nwaveFac = (waveVec.x + waveVec.y + waveVec.z) * 10.0;\n} else {\nif (ringsDirection == TEX_WAVE_RINGS_DIR_X) {\nwaveVec.x = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Y) {\nwaveVec.y = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_Z) {\nwaveVec.z = 0.0;\n} else if (ringsDirection == TEX_WAVE_RINGS_DIR_SPHERICAL) {\n}\nwaveFac = length(waveVec) * 20.0;\n}\nif (distortion != 0.0) {\nwaveFac += distortion * noiseTurbulence(coScaled * detailScale, detail,\n0.0, 0.0, 1.0);\n}\nif (waveProfile == TEX_WAVE_PROFILE_SIN) {\nwaveFac = 0.5 + 0.5 * sin(waveFac - PI_HALF + phaseOffset);\n} else if (waveProfile == TEX_WAVE_PROFILE_SAW) {\nwaveFac = fract((waveFac + phaseOffset + 1e-4) / PI2);\n} else if (waveProfile == TEX_WAVE_PROFILE_TRI) {\nwaveFac = abs(2.0 * fract((waveFac + PI + phaseOffset) / PI2) - 1.0);\n}\noutColor = vec4(waveFac, waveFac, waveFac, 1.0);\noutFac = waveFac;\n}",node_tex_white_noise_bl_frag:"\n#if __VERSION__ == 300\nvoid node_tex_white_noise_1d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = hash_float_to_float(w);\noutColor = vec4(hash_float_to_vec3(w), 1.0);\n}\nvoid node_tex_white_noise_2d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = hash_vec2_to_float(vector.xy);\noutColor = vec4(hash_vec2_to_vec3(vector.xy), 1.0);\n}\nvoid node_tex_white_noise_3d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = hash_vec3_to_float(vector);\noutColor = vec4(hash_vec3_to_vec3(vector), 1.0);\n}\nvoid node_tex_white_noise_4d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = hash_vec4_to_float(vec4(vector, w));\noutColor = vec4(hash_vec4_to_vec3(vec4(vector, w)), 1.0);\n}\n#else\nvoid node_tex_white_noise_1d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise_2d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise_3d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = 0.0;\noutColor = vec4(0.0);\n}\nvoid node_tex_white_noise_4d(vec3 vector, float w, out float outValue,\nout vec4 outColor)\n{\noutValue = 0.0;\noutColor = vec4(0.0);\n}\n#endif",node_uvmap_bl_frag:"void node_uvmap(vec2 uv, out vec3 outUV) {\n#if WORLD_NODES == 1\noutUV = vec3(0.0);\n#else\nuv.y = 1.0 - uv.y;\noutUV = vec3(uv, 0.0);\n#endif\n}",node_valtorgb_bl_frag:"\nvoid node_valtorgb(sampler2D colormap, float fac, out vec4 colOut, out float alphaOut)\n{\ncolOut = texture2D(colormap, vec2(fac, 0.0));\nalphaOut = colOut.a;\n}",node_value_bl_frag:"\nuniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vect_math_bl_frag:"void node_vect_math_add(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 + v2;\n}\nvoid node_vect_math_subtract(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 - v2;\n}\nvoid node_vect_math_multiply(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = v1 * v2;\n}\nvoid node_vect_math_divide(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : v1.x / v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : v1.y / v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : v1.z / v2.z;\n}\nvoid node_vect_math_cross_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = cross(v1, v2);\n}\nvoid node_vect_math_project(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nfloat d = dot(v2, v2);\noutVec = (d != 0.0) ? (dot(v1, v2) / d) * v2 : vec3(0.0);\n}\nvoid node_vect_math_reflect(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nif (v2 != vec3(0.0)) {\nv2 = normalize(v2);\n}\noutVec = reflect(v1, v2);\n}\nvoid node_vect_math_dot_product(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVal = dot(v1, v2);\n}\nvoid node_vect_math_distance(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = distance(v1, v2);\n}\nvoid node_vect_math_length(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVal = length(v1);\n}\nvoid node_vect_math_scale(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = v1 * val;\n}\nvoid node_vect_math_normalize(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\nif (v1 != vec3(0.0)) {\nv1 = normalize(v1);\n}\noutVec = v1;\n}\nvoid node_vect_math_snap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec.x = v2.x == 0.0 ? 0.0 : floor(v1.x / v2.x) * v2.x;\noutVec.y = v2.y == 0.0 ? 0.0 : floor(v1.y / v2.y) * v2.y;\noutVec.z = v2.z == 0.0 ? 0.0 : floor(v1.z / v2.z) * v2.z;\n}\nvoid node_vect_math_floor(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = floor(v1);\n}\nvoid node_vect_math_ceil(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = ceil(v1);\n}\nvoid node_vect_math_modulo(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nvec3 signProduct = sign(v1) * sign(v2);\nv1 += 1e-5 * signProduct;\noutVec.x = signProduct.x > 0.0 ? mod(v1.x, abs(v2.x)) : 0.0;\noutVec.y = signProduct.y > 0.0 ? mod(v1.y, abs(v2.y)) : 0.0;\noutVec.z = signProduct.z > 0.0 ? mod(v1.z, abs(v2.z)) : 0.0;\n}\nvoid node_vect_math_fraction(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = fract(v1);\n}\nvoid node_vect_math_absolute(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = abs(v1);\n}\nvoid node_vect_math_minimum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = min(v1, v2);\n}\nvoid node_vect_math_maximum(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = max(v1, v2);\n}\nvoid node_vect_math_cosine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = cos(v1);\n}\nvoid node_vect_math_sine(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = sin(v1);\n}\nvoid node_vect_math_tangent(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\noutVec = tan(v1);\n}\nvoid node_vect_math_wrap(vec3 v1, vec3 v2, vec3 v3, float val, out vec3 outVec,\nout float outVal) {\nv1 += 1e-5;\noutVec.x = v2.x == v3.x ? v2.x : mod(v1.x - v3.x, v2.x - v3.x) + v3.x;\noutVec.y = v2.y == v3.y ? v2.y : mod(v1.y - v3.y, v2.y - v3.y) + v3.y;\noutVec.z = v2.z == v3.z ? v2.z : mod(v1.z - v3.z, v2.z - v3.z) + v3.z;\n}\nvoid node_vect_math_faceforward(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = dot(v2, v3) < 0.0 ? v1 : -v1;\n}\nvoid node_vect_math_multiply_add(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\noutVec = v1 * v2 + v3;\n}\nvoid node_vect_math_refract(vec3 v1, vec3 v2, vec3 v3, float val,\nout vec3 outVec, out float outVal) {\nif (v2 != vec3(0.0)) {\nv2 = normalize(v2);\n}\noutVec = refract(v1, v2, val);\n}",node_vect_transform_bl_frag:"\n#define VEC_TRANS_NONE 0\n#define VEC_TRANS_W_O 1\n#define VEC_TRANS_W_C 2\n#define VEC_TRANS_O_W 3\n#define VEC_TRANS_O_C 4\n#define VEC_TRANS_C_W 5\n#define VEC_TRANS_C_O 6\n#define VEC_TRANS_W_O_DIR 7\n#define VEC_TRANS_W_C_DIR 8\n#define VEC_TRANS_O_W_DIR 9\n#define VEC_TRANS_O_C_DIR 10\n#define VEC_TRANS_C_W_DIR 11\n#define VEC_TRANS_C_O_DIR 12\nvoid node_vect_transform(const int vecTransType, const bool invCamZ, vec3 vIn, out vec3 vOut)\n{\nif (vecTransType == VEC_TRANS_NONE)\nvOut = vIn;\nelse {\nvec4 vec;\nif (vecTransType < VEC_TRANS_W_O_DIR)\nvec = vec4(vIn.xyz, 1.0);\nelse\nvec = vec4(vIn.xyz, 0.0);\nif (vecTransType == VEC_TRANS_W_O || vecTransType == VEC_TRANS_W_O_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = invModelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_W_C || vecTransType == VEC_TRANS_W_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = viewMatrix * vec;\nif (invCamZ)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_O_W || vecTransType == VEC_TRANS_O_W_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_O_C || vecTransType == VEC_TRANS_O_C_DIR) {\nvec = vec4(vec.x, vec.z, -vec.y, vec.w);\nvec = modelViewMatrix * vec;\nif (invCamZ)\nvec[2] = -vec[2];\n} else if (vecTransType == VEC_TRANS_C_W || vecTransType == VEC_TRANS_C_W_DIR) {\nif (invCamZ)\nvec[2] = -vec[2];\nvec = invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n} else if (vecTransType == VEC_TRANS_C_O || vecTransType == VEC_TRANS_C_O_DIR) {\nif (invCamZ)\nvec[2] = -vec[2];\nvec = invModelMatrix * invViewMatrix * vec;\nvec = vec4(vec.x, -vec.z, vec.y, vec.w);\n}\nvOut = vec.xyz;\n}\n}",node_vector_displacement_bl_frag:"void node_vector_displacement(vec4 vector, float midLevel, float scale,\nout vec3 displacement) {\ndisplacement = vec3(0.0);\n}",node_vector_rotate_bl_frag:"void node_vector_rotate_axis_angle(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nif (length(axis) > 0.0) {\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axis, invert * angle);\noutVector += center;\n} else {\noutVector = vector;\n}\n}\nvoid node_vector_rotate_euler_xyz(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvec4 axisAngle = eulerToAxisAngle(rotation);\nvector -= center;\noutVector = vec3RotateAxisAngle(vector, axisAngle.xyz, invert * axisAngle.w);\noutVector += center;\n}\nvoid node_vector_rotate_x_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateXAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_y_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateYAngle(vector, invert * angle);\noutVector += center;\n}\nvoid node_vector_rotate_z_axis(float invert, vec3 vector, vec3 center,\nvec3 axis, float angle, vec3 rotation, out vec3 outVector) {\nvector -= center;\noutVector = vec3RotateZAngle(vector, invert * angle);\noutVector += center;\n}",node_vertex_color_bl_frag:"void node_vertex_color(vec4 color, out vec4 outColor, out float outAlpha) {\noutColor = color;\noutAlpha = color.a;\n}",node_volume_absorption_bl_frag:"void node_volume_absorption(vec4 color, float density, out vec4 outColor)\n{\noutColor = color;\n}",node_volume_info_bl_frag:"void node_volume_info(out vec4 color, out float density, out float flame,\nout float temperature) {\ncolor = vec4(vec3(0.0), 1.0);\ndensity = 0.0;\nflame = 0.0;\ntemperature = 0.0;\n}",node_volume_scatter_bl_frag:"void node_volume_scatter(vec4 color, float density, float anisotropy, out vec4 outColor)\n{\noutColor = vec4(color);\n}",node_wavelength_bl_frag:"void node_wavelength(float wavelength, out vec4 outColor)\n{\noutColor = vec4(0.0, 0.0, 0.0, 1.0);\n#if __VERSION__ == 300\nvec3 xyz = vec3(0.0);\nfloat ii = (wavelength - 380.0) / 5.0;\nint i = int(ii);\nif (i < 0 || i >= 80) {\nreturn;\n}\nii -= float(i);\nvec3 c1 = cieColorMatch[i];\nvec3 c2 = cieColorMatch[i+1];\nxyz = mix(c1, c2, ii);\noutColor = vec4(xyz_to_sRGB(xyz), 1.0);\n#endif\n}",node_wireframe_bl_frag:"void node_wireframe(float size, out float outFac)\n{\noutFac = 0.0;\n}",node_bitmap_none_mx_frag:"void node_bitmap_none(out vec4 color)\n{\ncolor = vec4(1.0);\n}",node_bitmap_env_mx_frag:"void node_bitmap_env(sampler2D envMap, int reflectMode, float IOR,\nconst int encoding, const bool alphaAsMono, const bool alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle, vec3 normal,\nout vec4 color, out float value)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\n#endif\nmat3 uvTransform = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle);\ncolor = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\nif (alphaAsMono)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB)\ncolor = vec4(color.a);\n}",node_bitmap_mx_frag:"void node_bitmap(sampler2D map, const vec2 uvIn, const int mapping, const int axis,\nconst ivec2 clampToEdgeNoExtend,\nconst int encoding, const bool alphaAsMono, const bool alphaAsRGB,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 color, out float value)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\ncolor = vec4(0.0, 0.0, 0.0, 1.0);\n} else {\ncolor = texture2D(map, uv);\ncolor = nodeTexelToLinear(color, encoding);\n}\nif (alphaAsMono)\nvalue = color.a;\nelse\nvalue = average(color.rgb);\nif (alphaAsRGB)\ncolor = vec4(color.a);\n}",node_bump_mx_frag:"void node_bump(sampler2D bumpMap, const vec3 eyePos, const vec3 normal, const vec2 uvIn,\nfloat uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec3 normalOut)\n{\nvec3 coordsIn;\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nvec2 uv = vec2(coordsOut.x, 1.0 - coordsOut.y);\nvec2 dSTdx = dFdx(uv);\nvec2 dSTdy = dFdy(uv);\nif (any(equal(dSTdx, vec2(0.0))) || any(equal(dSTdy, vec2(0.0)))) {\nnormalOut = normal;\n} else {\nconst float bumpScale = 1.0;\nvec3 vSigmaX = vec3(dFdx(eyePos.x), dFdx(eyePos.y), dFdx(eyePos.z));\nvec3 vSigmaY = vec3(dFdy(eyePos.x), dFdy(eyePos.y), dFdy(eyePos.z));\nvec3 vN = normal;\nvec3 R1 = cross(vSigmaY, vN);\nvec3 R2 = cross(vN, vSigmaX);\nfloat fDet = dot(vSigmaX, R1);\nfloat Hll = bumpScale * texture2D(bumpMap, uv).x;\nfloat dBx = bumpScale * texture2D(bumpMap, uv + dSTdx).x - Hll;\nfloat dBy = bumpScale * texture2D(bumpMap, uv + dSTdy).x - Hll;\nvec2 dHdxy = vec2(dBx, dBy);\nvec3 vGrad = sign(fDet) * (dHdxy.x * R1 + dHdxy.y * R2);\nnormalOut = normalize(abs(fDet) * normal - vGrad);\n}\n}",node_blend_mx_frag:"void node_blend(\nconst bool useCurve, const float curveLower, const float curveUpper,\nconst vec4 color1, const vec4 color2, float mask,\nout vec4 color)\n{\nif (useCurve)\nmask = smoothstep(curveLower, curveUpper, mask);\nelse\nmask = clamp(mask, 0.0, 1.0);\ncolor = mix(color1, color2, mask);\n}",node_color_correction_mx_frag:"#define REWIRE_RED 0\n#define REWIRE_GREEN 1\n#define REWIRE_BLUE 2\n#define REWIRE_ALPHA 3\n#define REWIRE_RED_INV 4\n#define REWIRE_GREEN_INV 5\n#define REWIRE_BLUE_INV 6\n#define REWIRE_ALPHA_INV 7\n#define REWIRE_MONOCHROME 8\n#define REWIRE_ONE 9\n#define REWIRE_ZERO 10\nfloat rewireChannel(int type, vec4 color)\n{\nif (type == REWIRE_RED)\nreturn color.r;\nelse if (type == REWIRE_GREEN)\nreturn color.g;\nelse if (type == REWIRE_BLUE)\nreturn color.b;\nelse if (type == REWIRE_ALPHA)\nreturn color.a;\nelse if (type == REWIRE_RED_INV)\nreturn 1.0-color.r;\nelse if (type == REWIRE_GREEN_INV)\nreturn 1.0-color.g;\nelse if (type == REWIRE_BLUE_INV)\nreturn 1.0-color.b;\nelse if (type == REWIRE_ALPHA_INV)\nreturn 1.0-color.a;\nelse if (type == REWIRE_MONOCHROME)\nreturn average(color.rgb);\nelse if (type == REWIRE_ONE)\nreturn 1.0;\nelse\nreturn 0.0;\n}\nvoid node_color_correction(const ivec4 rewire,\nconst vec4 color, const float hueShift, const float saturation,\nconst vec4 tint, const float tintStrength,\nconst float brightness, const float contrast,\nout vec4 outColor)\n{\nif (all(equal(rewire, ivec4(REWIRE_RED, REWIRE_GREEN, REWIRE_BLUE, REWIRE_ALPHA)))) {\noutColor = color;\n} else {\noutColor.r = rewireChannel(rewire.x, color);\noutColor.g = rewireChannel(rewire.y, color);\noutColor.b = rewireChannel(rewire.z, color);\noutColor.a = rewireChannel(rewire.w, color);\n}\nvec4 hsv;\nrgbToHSV(outColor, hsv);\nhsv[0] += hueShift / 360.0;\nif (hsv[0] > 1.0)\nhsv[0] -= 1.0;\nelse if (hsv[0] < 0.0)\nhsv[0] += 1.0;\nhsv[1] *= (saturation / 100.0 + 1.0);\nhsv[1] = saturate(hsv[1]);\nif (tintStrength > 0.0) {\nvec4 hsvTint;\nrgbToHSV(tint, hsvTint);\nhsv[0] = hsv[0] + (hsvTint[0] - hsv[0]) * tintStrength / 100.0;\n}\nhsvToRGB(hsv, outColor);\noutColor = (outColor - 0.5) * (contrast / 100.0 + 1.0) + 0.5 + brightness / 100.0;\noutColor = max(outColor, 0.0);\n}",node_color_map_mx_frag:"void node_color_map(const bool reverseGamma,\nconst vec4 color, const float gamma, const float gain,\nout vec4 outColor)\n{\nfloat p = reverseGamma ? gamma : 1.0 / gamma;\nfloat g = reverseGamma ? (gain > EPSILON ? 1.0 / gain : 1.0) : gain;\noutColor = vec4(g * pow(abs(color.rgb), vec3(p)), color.a);\n}",node_composite_layer_mx_frag:"#define COMP_BLEND_NORMAL 0\n#define COMP_BLEND_AVERAGE 1\n#define COMP_BLEND_ADD 2\n#define COMP_BLEND_SUBTRACT 3\n#define COMP_BLEND_DARKEN 4\n#define COMP_BLEND_MULTIPLY 5\n#define COMP_BLEND_COLORBURN 6\n#define COMP_BLEND_LINEARBURN 7\n#define COMP_BLEND_LIGHTEN 8\n#define COMP_BLEND_SCREEN 9\n#define COMP_BLEND_COLORDODGE 10\n#define COMP_BLEND_LINEARDODGE 11\n#define COMP_BLEND_SPOT 12\n#define COMP_BLEND_SPOTBLEND 13\n#define COMP_BLEND_OVERLAY 14\n#define COMP_BLEND_SOFTLIGHT 15\n#define COMP_BLEND_HARDLIGHT 16\n#define COMP_BLEND_PINLIGHT 17\n#define COMP_BLEND_HARDMIX 18\n#define COMP_BLEND_DIFFERENCE 19\n#define COMP_BLEND_EXCLUSION 20\n#define COMP_BLEND_HUE 21\n#define COMP_BLEND_SATURATION 22\n#define COMP_BLEND_COLOR 23\n#define COMP_BLEND_VALUE 24\nvec4 calcBlending(const vec4 colorBG, const vec4 colorFG, const int blendMode) {\nif (blendMode == COMP_BLEND_NORMAL)\nreturn colorFG;\nelse if (blendMode == COMP_BLEND_AVERAGE)\nreturn (colorFG + colorBG) / 2.0;\nelse if (blendMode == COMP_BLEND_ADD)\nreturn colorBG + colorFG;\nelse if (blendMode == COMP_BLEND_SUBTRACT)\nreturn colorBG - colorFG;\nelse if (blendMode == COMP_BLEND_DARKEN)\nreturn min(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_MULTIPLY)\nreturn colorBG * colorFG;\nelse if (blendMode == COMP_BLEND_COLORBURN) {\nif (colorFG.r == 0.0 && colorFG.g == 0.0 && colorFG.b == 0.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn max(1.0 - (1.0 - colorBG) / colorFG, 0.0);\n} else if (blendMode == COMP_BLEND_LINEARBURN)\nreturn max(colorFG + colorBG - 1.0, 0.0);\nelse if (blendMode == COMP_BLEND_LIGHTEN)\nreturn max(colorFG, colorBG);\nelse if (blendMode == COMP_BLEND_SCREEN)\nreturn colorFG + colorBG - colorFG * colorBG;\nelse if (blendMode == COMP_BLEND_COLORDODGE) {\nif (colorFG.r == 1.0 && colorFG.g == 1.0 && colorFG.b == 1.0)\nreturn vec4(1.0);\nelse\nreturn min(colorBG / (1.0 - colorFG), 1.0);\n} else if (blendMode == COMP_BLEND_LINEARDODGE)\nreturn min(colorFG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOT)\nreturn min(2.0 * colorFG * colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_SPOTBLEND)\nreturn min(colorFG * colorBG + colorBG, 1.0);\nelse if (blendMode == COMP_BLEND_OVERLAY) {\nif (colorBG.r <= 0.5 && colorBG.g <= 0.5 && colorBG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0 * (1.0-colorFG) * (1.0-colorBG));\n} else if (blendMode == COMP_BLEND_SOFTLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(colorBG * (colorBG + 2.0 * colorFG * (1.0 - colorBG)));\nelse\nreturn saturate(colorBG + (2.0 * colorFG - 1.0) * (sqrt(colorBG) - colorBG));\n} else if (blendMode == COMP_BLEND_HARDLIGHT) {\nif (colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5)\nreturn saturate(2.0 * colorFG * colorBG);\nelse\nreturn saturate(1.0 - 2.0*(1.0 - colorFG)*(1.0 - colorBG));\n} else if (blendMode == COMP_BLEND_PINLIGHT) {\nif (((colorFG.r > 0.5 && colorFG.g > 0.5 && colorFG.b > 0.5) && all(greaterThan(colorFG, colorBG))) ||\n((colorFG.r <= 0.5 && colorFG.g <= 0.5 && colorFG.b <= 0.5) && all(lessThan(colorFG, colorBG))))\nreturn colorFG;\nelse\nreturn colorBG;\n} else if (blendMode == COMP_BLEND_HARDMIX) {\nif (colorFG.r + colorBG.r <= 1.0 && colorFG.g + colorBG.g <= 1.0 && colorFG.b + colorBG.b <= 1.0)\nreturn vec4(0.0, 0.0, 0.0, 1.0);\nelse\nreturn vec4(1.0);\n} else if (blendMode == COMP_BLEND_DIFFERENCE)\nreturn abs(colorFG - colorBG);\nelse if (blendMode == COMP_BLEND_EXCLUSION)\nreturn colorFG + colorBG - 2.0 * colorFG * colorBG;\n}\nvec4 calcBlendingHSV(const vec4 colorBG, const vec4 colorFG, const int blendMode)\n{\nvec4 hsvBG, hsvFG;\nvec4 outColor;\nif (blendMode == COMP_BLEND_HUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvBG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_SATURATION) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_COLOR) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvFG[0], hsvFG[1], hsvBG[2], 1.0), outColor);\n} else if (blendMode == COMP_BLEND_VALUE) {\nrgbToHSV(colorBG, hsvBG);\nrgbToHSV(colorFG, hsvFG);\nhsvToRGB(vec4(hsvBG[0], hsvBG[1], hsvFG[2], 1.0), outColor);\n}\nreturn outColor;\n}\nvoid node_composite_layer(const int blendMode, const float opacity, \nconst vec4 colorBG, const vec4 colorFG, const vec4 mask,\nout vec4 outColor)\n{\nfloat fac = saturate(opacity * average(mask.rgb));\nif (blendMode < COMP_BLEND_HUE)\noutColor = calcBlending(colorBG, colorFG, blendMode);\nelse\noutColor = calcBlendingHSV(colorBG, colorFG, blendMode);\noutColor = mix(colorBG, outColor, fac);\n}",node_falloff_mx_frag:"void node_falloff(vec3 viewPos, float IOR,\nconst vec4 color1, const vec4 color2, vec3 normal, out vec4 color)\n{\nfloat fac;\n\nvec3 dir = normalize(viewPos);\nfloat eta = max(IOR, 0.00001);\nfac = fresnelReflection(dir, normal, (gl_FrontFacing) ? eta : 1.0 / eta);\ncolor = mix(color1, color2, fac);\n}",node_gradient_ramp_mx_frag:"#define GRAD_TYPE_4_CORNER 0\n#define GRAD_TYPE_BOX 1\n#define GRAD_TYPE_DIAGONAL 2\n#define GRAD_TYPE_LIGHTING 3\n#define GRAD_TYPE_LINEAR 4\n#define GRAD_TYPE_MAPPED 5\n#define GRAD_TYPE_NORMAL 6\n#define GRAD_TYPE_PONG 7\n#define GRAD_TYPE_RADIAL 8\n#define GRAD_TYPE_SPIRAL 9\n#define GRAD_TYPE_SWEEP 10\n#define GRAD_TYPE_TARTAN 11\nvoid node_gradient_ramp(\nsampler2D gradientData, int gradientType, vec2 uvIn, vec3 geometryNormal,\nvec3 viewPos, int mapping, int axis, ivec2 clampToEdgeNoExtend,\nvec4 sourceMap, float uOffset, float vOffset, float uTiling, float vTiling, float wAngle,\nout vec4 outCol)\n{\nvec3 coordsIn;\nif (mapping == MAPPING_EXPLICIT_MAP_CHANNEL) {\ncoordsIn = vec3(uvIn.x, 1.0 - uvIn.y, 0.0);\n} else if (mapping == MAPPING_VERTEX_COLOR_CHANNEL) {\ncoordsIn = vec3(0.0);\n} else if (mapping == MAPPING_PLANAR_OBJECT_XYZ) {\ncoordsIn = swizzleUpZ((invModelMatrix * invViewMatrix * vec4(-viewPos, 1.0)).xyz);\n} else {\ncoordsIn = swizzleUpZ((invViewMatrix * vec4(-vViewPosition, 1.0)).xyz);\n}\nif (axis == AXIS_XY)\ncoordsIn = vec3(coordsIn.x, coordsIn.y, 1.0);\nelse if (axis == AXIS_YZ)\ncoordsIn = vec3(coordsIn.y, coordsIn.z, 1.0);\nelse if (axis == AXIS_ZX)\ncoordsIn = vec3(coordsIn.z, coordsIn.x, 1.0);\nvec3 coordsOut = calcUvTransform(uOffset, vOffset, uTiling, vTiling, wAngle) * coordsIn;\nfloat coord = uvIn.x;\nuvIn = coordsOut.xy;\nif ((clampToEdgeNoExtend[0] == 1 && (uvIn.x < 0.0 || uvIn.x > 1.0)) ||\n(clampToEdgeNoExtend[1] == 1 && (uvIn.y < 0.0 || uvIn.y > 1.0))) {\noutCol = vec4(0.0, 0.0, 0.0, 1.0);\nreturn;\n}\nuvIn = fract(uvIn);\nif (gradientType == GRAD_TYPE_4_CORNER) {\ncoord = pow(uvIn.x, 2.0);\n} else if (gradientType == GRAD_TYPE_BOX) {\nvec2 boxUv = abs(uvIn - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (gradientType == GRAD_TYPE_DIAGONAL) {\ncoord = abs(uvIn.x - uvIn.y) * sqrt(2.0);\n} else if (gradientType == GRAD_TYPE_LIGHTING) {\nIncidentLight directLight;\nGeometricContext geometry;\ngeometry.position = -viewPos;\nvec3 irr = vec3(0.0);\n#if (NUM_POINT_LIGHTS > 0)\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_POINT_LIGHTS; i++) {\ngetPointLightInfo(pointLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_SPOT_LIGHTS > 0)\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHTS; i++) {\ngetSpotLightInfo(spotLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_DIR_LIGHTS > 0)\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_DIR_LIGHTS; i++) {\ngetDirectionalLightInfo(directionalLights[i], geometry, directLight);\nfloat dotNL = saturate(dot(geometryNormal, directLight.direction));\nirr += dotNL * directLight.color;\n}\n#pragma unroll_loop_end\n#endif\n#if defined(PHYSICALLY_CORRECT_LIGHTS)\nirr /= PI;\n#endif\nvec3 ambIrr = getAmbientLightIrradiance(ambientLightColor);\n#if !defined(PHYSICALLY_CORRECT_LIGHTS)\nambIrr /= PI;\n#endif\nirr += ambIrr;\ncoord = (irr.x + irr.y + irr.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_LINEAR) {\ncoord = uvIn.x;\n} else if (gradientType == GRAD_TYPE_MAPPED) {\ncoord = (sourceMap.x + sourceMap.y + sourceMap.z) / 3.0;\n} else if (gradientType == GRAD_TYPE_NORMAL) {\nfloat angle = acos(clamp(dot(geometryNormal, normalize(viewPos)), -1.0, 1.0));\nfloat k = 100.0;\ncoord = 1.0 - sin(pow2(k) - k * sqrt(pow2(k) - pow2(angle)));\n} else if (gradientType == GRAD_TYPE_PONG) {\nfloat y = min(uvIn.y, uvIn.x);\nfloat x = max(uvIn.y, uvIn.x);\ncoord = y / x;\n} else if (gradientType == GRAD_TYPE_RADIAL) {\ncoord = length(uvIn - vec2(0.5)) * 2.0;\n} else if (gradientType == GRAD_TYPE_SPIRAL) {\nvec2 uvSpiral = mat2(0.0, 1.0, -1.0, 0.0) * (uvIn - vec2(0.5));\ncoord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n} else if (gradientType == GRAD_TYPE_SWEEP) {\ncoord = atan(uvIn.x, uvIn.y) / PI_HALF;\n} else if (gradientType == GRAD_TYPE_TARTAN) {\nvec2 uvTartan = abs(uvIn - vec2(0.5));\ncoord = 1.0 - min(uvTartan.x, uvTartan.y) * 2.0;\n}\noutCol = texture2D(gradientData, vec2(coord, 0.0));\n}",node_map_mx_frag:"\nvoid node_map(const vec4 colorIn, out vec4 color)\n{\ncolor = colorIn;\n}",node_mask_mx_frag:"void node_mask(const bool maskInverted,\nconst vec4 color, vec4 mask,\nout vec4 outColor)\n{\nmask = maskInverted ? vec4(vec3(1.0) - mask.rgb, mask.a) : mask;\noutColor = color * mask;\n}",node_material_mx_frag:"void node_material(\nfloat reflectionRatio, const float refractionRatio,\nconst bool selfIllumColorOn,\nconst vec4 ambientColor, const vec4 diffuseColor, const vec4 specularColor,\nconst float glossiness, const float specularLevel, const vec4 selfIllum,\nconst float opacity, const vec4 filterColor, const vec3 normal,\nconst vec4 reflection, const vec4 refraction, const float displacement,\nout vec4 outColor)\n{\nvec3 diffuse, specular;\nNodeMaterial material;\nfloat ior = 1.5;\nfloat facing = pow2((1.0 - ior) / (1.0 + ior));\nfloat edge = 1.0;\nfloat slope = 5.0;\nfloat cosTheta = saturate(dot(normal, normalize(vViewPosition)));\nfloat fresnelRefl = (facing + (edge - facing) * pow(1.0 - cosTheta, slope)) * saturate(specularLevel);\nfloat kd = 1.0 - fresnelRefl;\nmaterial.diffuseColor = diffuseColor.rgb * kd;\nmaterial.specularColor = mix(vec3(0.0), specularColor.rgb, fresnelRefl);\nmaterial.roughness = 1.0 - glossiness;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\ndiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nif (selfIllumColorOn) {\ndiffuse += selfIllum.rgb;\n} else {\ndiffuse = mix(diffuse, material.diffuseColor, selfIllum[0]);\n}\nspecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\noutColor = vec4(saturate(diffuse + specular), 1.0);\nfloat alpha = opacity - saturate(maxFromRGB(specular)) * (opacity - 1.0);\noutColor += reflection * specularColor * reflectionRatio;\noutColor += refraction * refractionRatio;\nalpha += saturate(maxFromRGB(reflection.rgb) * maxFromRGB(specularColor.rgb)) * reflectionRatio;\nalpha += saturate(maxFromRGB(refraction.rgb)) * refractionRatio;\noutColor.a = alpha;\n}",node_matte_shadow_mx_frag:"#include \nvoid node_matte_shadow(\nvec3 normal, bool receiveShadow, float shadowBrightness, vec3 color,\nout vec4 outColor) {\nfloat shadow = getShadowMask();\noutColor = vec4(color, 1.0 - (shadowBrightness + (1.0 - shadowBrightness) * shadow));\n}",node_mix_mx_frag:"void node_mix(const vec4 color1, const vec4 color2, const float amount, out vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_noise_mx_frag:"#define NOISE_REGULAR 0\n#define NOISE_FRACTAL 1\n#define NOISE_TURBULENCE 2\nfloat noise(vec3 vec, const int noiseType, const float size, const float thresholdLow, const float thresholdHigh, const float levels, float phase) {\nvec /= size;\nfloat n = 0.0;\nif (noiseType == NOISE_REGULAR) {\nn = (1.0 + snoise(vec4(vec, phase))) * 0.5;\n} else if (noiseType == NOISE_FRACTAL) {\nfloat l, f = 1.0;\nfor (l = levels; l >= 1.0; l-=1.0) { \nn += snoise(vec4(vec * f, phase)) / f;\nf *= 2.0;\n}\nif (l > 0.0) \nn += l * snoise(vec4(vec * f, phase)) / f; \nn = 0.5 * (n + 1.0);\n} else {\nfloat l, f = 1.0;\nfloat ml = levels;\nfor (l = levels; l >= 1.0; l-=1.0, ml-=1.0) {\nn += abs(snoise(vec4(vec * f, phase))) / f;\nf *= 2.0f;\n}\nif (l > 0.0)\nn += l * abs(snoise(vec4(vec * f, phase))) / f;\n}\nreturn clamp(smoothstep(thresholdLow, thresholdHigh, n), 0.0, 1.0);\n}\nvoid node_noise(const vec2 uv, const int noiseType, const int coordType, \nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec3 vec = (calcXYZTransform(offset, tiling, angle) * vec4(uv.x, 1.0 - uv.y, 1.0, 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 1.0);\n}\nvoid node_noise(const vec3 viewPos, const int noiseType, const int coordType,\nconst vec3 color1, const vec3 color2, const float size,\nconst float thresholdLow, const float thresholdHigh, const float levels,\nconst float phase, const vec3 offset, const vec3 tiling, const vec3 angle,\nout vec4 color) {\nvec4 posWorld = invViewMatrix * vec4(-viewPos, 1.0);\nvec3 vec;\nif (coordType == 0)\nvec = (invModelMatrix * posWorld).xyz;\nelse\nvec = posWorld.xyz;\nvec = (calcXYZTransform(offset, tiling, angle) * vec4(swizzleUpZ(vec), 1.0)).xyz;\ncolor = vec4(mix(color1, color2, noise(vec, noiseType, size, thresholdLow, thresholdHigh, levels, phase)), 1.0);\n}",node_normal_bump_mx_frag:"void node_normal_bump(const vec4 tangent, const vec3 normal, ivec2 flip,\nvec4 normalColor, vec3 additionalBump, float normalMult, float addBumpMult,\nout vec3 normalOut)\n{\nif (flip[0] == 1)\nnormalColor.x = 1.0 - normalColor.x;\nif (flip[1] == 0)\nnormalColor.y = 1.0 - normalColor.y;\nvec3 normalTex = (normalColor.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize(modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz, tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\nnormalOut = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\nnormalOut = mix(normal, normalOut, normalMult);\nadditionalBump = mix(normal, additionalBump, addBumpMult);\nnormalOut = normalize(normalOut + additionalBump);\n}",node_output_map_mx_frag:"vec4 processOutputColor(vec4 color, const bool invert, const bool clampColor, const bool alphaFromRGB,\nconst float rgbLevel, const float rgbOffset, const float outputAmount)\n{\nvec3 color3 = color.rgb;\ncolor3 = clampColor ? saturate(color3) : color3;\ncolor3 = color3 * rgbLevel + vec3(rgbOffset);\ncolor3 = invert ? (vec3(1.0) - color3) : color3;\ncolor = outputAmount * vec4(color3, color.a);\ncolor.a = alphaFromRGB ? average(color.rgb) : color.a;\nreturn color;\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB,\nconst vec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\noutColor = processOutputColor(color, invert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}\nvoid node_output_map(\nconst bool invert, const bool clampColor, const bool alphaFromRGB, sampler2D colormap,\nvec4 color, const float rgbLevel, const float rgbOffset,\nconst float outputAmount, const float bumpAmount,\nout vec4 outColor)\n{\nfloat r = texture2D(colormap, vec2(color.r, 0.0)).r;\nfloat g = texture2D(colormap, vec2(color.g, 0.0)).g;\nfloat b = texture2D(colormap, vec2(color.b, 0.0)).b;\noutColor = processOutputColor(vec4(r, g, b, color.a),\ninvert, clampColor, alphaFromRGB, rgbLevel, rgbOffset, outputAmount);\n}",node_output_mx_frag:"void node_output(vec4 color, out vec4 outgoingLight)\n{\noutgoingLight = color;\n}",node_physical_mx_frag:"#define DEFAULT_REFLECTION_EDGE 1.0\n#define DEFAULT_REFLECTION_SLOPE 5.0\nvoid node_physical(\nvec3 geometryNormal, const float emitLuminance, const bool useCustomReflCurve,\nconst float reflFacing, const float reflEdge, const float reflSlope,\nconst bool roughnessInv, const bool transRoughnessLock, const bool transRoughnessInv,\nconst bool thinWalled,\nconst float baseWeight, const vec4 baseColor, const float reflectivity,\nconst vec4 reflColor, const float roughness, const float metalness,\nconst float diffRoughness, const float anisotropy, const float anisoangle,\nconst float transparency, const vec4 transColor, const float transRoughness,\nconst float ior, const float scattering, const vec4 sssColor,\nconst float sssScale, const float emission, const vec4 emitColor,\nconst float coating, const vec4 coatColor, const float coatRoughness,\nconst vec3 normal, const vec3 clearcoatNormal, const float displacement,\nconst float opacity,\nout vec4 outColor)\n{\nNodeMaterial material;\nvec3 baseColorWeighted = baseWeight * baseColor.rgb;\nmaterial.diffuseColor = baseColorWeighted * (1.0 - transparency);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoat = saturate(coating);\nmaterial.clearcoatRoughness = clamp(coatRoughness, 0.0, 1.0);\nmaterial.clearcoatF0 = vec3(0.04);\nmaterial.clearcoatF90 = 1.0;\n#endif\nfloat facing, edge, slope;\nif (useCustomReflCurve) {\nfacing = reflFacing;\nedge = reflEdge;\nslope = reflSlope;\n} else {\nfacing = pow2((1.0 - ior) / (1.0 + ior));\nedge = DEFAULT_REFLECTION_EDGE;\nslope = DEFAULT_REFLECTION_SLOPE;\n}\nfloat cosTheta = saturate(dot(normal, normalize(vViewPosition)));\nfloat fresnelRefl = (facing + (edge - facing) * pow(1.0 - cosTheta, slope))\n* saturate(reflectivity + metalness);\nfloat kd = 1.0 - (metalness * (1.0 - fresnelRefl) + fresnelRefl);\nmaterial.specularColor = mix(metalness * baseColorWeighted, reflColor.rgb, fresnelRefl);\nmaterial.diffuseColor *= kd;\nmaterial.specularF90 = 1.0;\nmaterial.roughness = clamp(roughnessInv ? (1.0 - roughness) : roughness, 0.0, 1.0);\nmaterial.refractionColor = pow(transparency * (1.0 - metalness) * transColor.rgb, vec3(2.0));\nmaterial.refractionIOR = ior;\nfloat tRough;\nif (transRoughnessLock) {\ntRough = roughnessInv ? 1.0 - roughness : roughness;\n} else {\ntRough = transRoughnessInv ? 1.0 - transRoughness : transRoughness;\n}\nmaterial.refractionRoughness = pow2(tRough);\n#if defined(ENVMAP_TYPE_CUBE) || defined(ENVMAP_TYPE_CUBE_UV)\nfloat geomRoughness = calcGeometryRoughness(geometryNormal);\nmaterial.roughness = calcCubeUVAdjustedRoughness(\nmaterial.roughness, geomRoughness);\nmaterial.refractionRoughness = calcCubeUVAdjustedRoughness(\nmaterial.refractionRoughness, geomRoughness);\n#ifdef USE_CLEARCOAT\nmaterial.clearcoatRoughness = calcCubeUVAdjustedRoughness(\nmaterial.clearcoatRoughness, geomRoughness);\n#endif\n#endif\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\nvec3 refractedLight = vec3(0.0);\n#ifdef USE_GTAO\nvec4 gtaoVisibilityBentNormal = texture2D(gtaoMap,\ngl_FragCoord.xy / currResolution);\nvec3 bentNormal = normalize(unpackRGBToNormal(gtaoVisibilityBentNormal.gba));\n#define PROBE_NORMAL bentNormal\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#undef RE_Refraction\n#ifdef PROBE_NORMAL\n#undef PROBE_NORMAL\n#endif\n#ifdef USE_GTAO\nreflectedLight.indirectDiffuse *= gtaoVisibilityBentNormal.r;\nfloat gtaoVisibility = gtaoVisibilityBentNormal.r;\nvec3 gtaoBentNormal = bentNormal;\nvec3 gtaoViewDir = geometry.viewDir;\nvec3 gtaoNormal = normal;\nfloat gtaoRoughness = material.roughness;\n#endif\n#include \nvec3 totalEmissiveRadiance = emitLuminance / LUMENS_PER_WATT * emission * emitColor.rgb;\nvec3 specular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\nvec3 outColor3 = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nspecular + totalEmissiveRadiance;\n#ifdef USE_CLEARCOAT\nfloat dotNVcc = saturate(dot(geometry.normal, geometry.viewDir));\nvec3 Fcc = F_Schlick(material.clearcoatF0, material.clearcoatF90, dotNVcc);\noutColor3 = outColor3 * (1.0 - material.clearcoat * Fcc) + clearcoatSpecular * material.clearcoat;\n#endif\nfloat alpha = 1.0;\nif (thinWalled) {\nalpha = 1.0 - saturate(transparency) + maxFromRGB(specular) * saturate(transparency);\n} else {\noutColor3 += refractedLight;\n}\noutColor = vec4(outColor3, saturate(alpha) * opacity);\n}",node_phy_sun_sky_env_mx_frag:"vec3 perezSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 direction)\n{\nfloat cosGamma = clamp(dot(direction, sunDirection), -1.0, 1.0);\nfloat cosTheta = clamp(direction.y, 0.0, 1.0);\nvec3 radInternal = (1.0 + paramA * exp(paramB / cosTheta)) * (\n1.0 + paramC * exp(paramD * acos(cosGamma))\n+ paramE * pow(cosGamma, 2.0)\n);\nfloat ciex = radInternal.y * radiance.y;\nfloat ciey = radInternal.z * radiance.z;\nfloat cieY = clamp(radInternal.x * radiance.x, 0.0, 1000000.0);\nvec3 XYZ = xyY_to_XYZ(ciex, ciey, cieY);\nreturn max(xyz_to_sRGB(XYZ), 0.0);\n}\n#define GROUND_SKY_SAMPLES 16\nvec3 groundSky(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE, vec3 radiance, vec3 sunDirection, vec3 sunIlluminance)\n{\nconst int horizSamples = GROUND_SKY_SAMPLES;\nconst int vertSamples = GROUND_SKY_SAMPLES / 2;\nvec3 result = vec3(0.0);\nfor (int horizSampleIdx = 0; horizSampleIdx < horizSamples; horizSampleIdx++) {\nfloat horizSample = float(horizSampleIdx) / float(horizSamples);\nfloat horizAngle = PI2 * horizSample;\nfor (int vertSampleIdx = 0; vertSampleIdx < vertSamples; vertSampleIdx++) {\nfloat vertSample = float(vertSampleIdx) / float(vertSamples);\nfloat y = 1.0 - vertSample;\nfloat x = sqrt(1.0 - y*y) * cos(horizAngle);\nfloat z = -sqrt(1.0 - y*y) * sin(horizAngle);\nvec3 direction = vec3(x, y, z);\nvec3 sampleColor = perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, direction);\n\nresult += direction.y * sampleColor;\n}\n}\nresult /= float(horizSamples * vertSamples);\nresult += (sunIlluminance * sunDirection.y) / PI;\nreturn result;\n}\nvoid node_phy_sun_sky_env(vec3 paramA, vec3 paramB, vec3 paramC, vec3 paramD, vec3 paramE,\nvec3 radiance, vec3 sunDirection, vec3 sunIlluminance, vec3 sunLuminance, \nfloat globalIntensity, vec4 groundColor,\nout vec4 outColor) \n{\nvec3 dir = vWorldPosition;\nif (length(dir) == 0.0) {\ndir = vec3(0.0, 0.0, -1.0);\n} else {\ndir = normalize(dir);\n}\nif (dir.y < 0.0) {\noutColor = groundColor * vec4(groundSky(paramA, paramB, paramC, paramD, paramE, radiance, sunDirection, sunIlluminance), 1.0);\n} else {\noutColor = vec4(perezSky(paramA, paramB, paramC, paramD, paramE,\nradiance, sunDirection, dir), 1.0);\n}\noutColor = globalIntensity * outColor;\n}",node_reflect_refract_mx_frag:"void node_reflect_refract(sampler2D envMap,\nint reflectMode, const float IOR, const int encoding,\nvec3 normal, out vec4 color)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec3 reflectVec;\nif (reflectMode == MAX_ENV_COORDS_REFLECT)\nreflectVec = reflect(cameraToVertex, worldNormal);\nelse {\nfloat refrRatio = 1.0 / IOR;\nreflectVec = refract(cameraToVertex, worldNormal, refrRatio);\n}\nreflectVec = normalize(reflectVec);\ncolor = sampleEquirectangular(envMap, reflectVec, mat3(1.0), encoding);\n}",node_reflect_refract_color_mx_frag:"void node_reflect_refract_color(const vec4 colorIn, out vec4 color)\n{\ncolor = vec4(colorIn);\n}",node_rgb_multiply_mx_frag:"void node_rgb_multiply(const vec4 color1, const vec4 color2, out vec4 color)\n{\ncolor = color1 * color2;\n}",node_rgb_tint_mx_frag:"void node_rgb_tint(const vec4 color, const vec4 red, const vec4 green, const vec4 blue,\nout vec4 outColor)\n{\nmat3 tintMatrix = mat3(red.rgb, green.rgb, blue.rgb);\noutColor = vec4(tintMatrix * color.rgb, color.a);\n}",node_rgb_mx_frag:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_shellac_mx_frag:"void node_shellac(const vec4 color1, const vec4 color2, const float amount,\nout vec4 color)\n{\ncolor = mix(color1, color2, clamp(amount, 0.0, 1.0));\n}",node_tex_environment_mx_frag:"\nvoid node_tex_environment(sampler2D tex, const int encoding, vec3 vector, out vec4 outColor) {\n\nvec3 direction = swizzleUpY(vector);\nif (length(direction) == 0.0) {\ndirection = vec3(0.0, 1.0, 0.0);\n} else {\ndirection = normalize(direction);\n}\nvec2 uv;\nuv.y = asin(clamp(direction.y, - 1.0, 1.0)) * RECIPROCAL_PI + 0.5;\nuv.x = atan(direction.x, direction.z) * RECIPROCAL_PI2 + 0.5;\nuv.y *= -1.0;\nconst float seamWidth = 0.15;\nconst float seamBiasFactor = -10.0;\nfloat seam = max(0.0, 1.0 - abs (direction.x) / seamWidth) *\nclamp (1.0 - direction.z / seamWidth, 0.0, 1.0);\noutColor = texture2D(tex, uv, seamBiasFactor * seam);\noutColor = nodeTexelToLinear(outColor, encoding);\n}",node_value_mx_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_value(float val, out float outVal)\n{\noutVal = val;\n}",node_vertex_color_mx_frag:"void node_vertex_color(vec3 color, out vec4 outColor)\n{\noutColor = vec4(color, 1.0);\n}",node_add_double_linear_my_frag:"void node_add_double_linear(\nfloat input1, float input2,\nout float outValue) {\noutValue = input1 + input2;\n}",node_add_matrix_my_frag:"void node_add_matrix(\nmat4 matrixIn1,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1;\n}\nvoid node_add_matrix(\nmat4 matrixIn1, mat4 matrixIn2,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1 + matrixIn2;\n}\nvoid node_add_matrix(\nmat4 matrixIn1, mat4 matrixIn2, mat4 matrixIn3,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1 + matrixIn2 + matrixIn3;\n}",node_anim_curve_ta_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_ta(float val, out float outVal)\n{\noutVal = val;\n}",node_anim_curve_tu_my_frag:"uniform float nodeValue[NODE_VALUE_NUM];\nvoid node_anim_curve_tu(float val, out float outVal)\n{\noutVal = val;\n}",node_blend_colors_my_frag:"void node_blend_colors(float blender, vec3 color1, vec3 color2, out vec3 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}\nvoid node_blend_colors(float blender, vec4 color1, vec4 color2, out vec4 outColor)\n{\nblender = clamp(blender, 0.0, 1.0);\noutColor = mix(color1, color2, 1.0 - blender);\n}",node_bulge_my_frag:"void node_bulge(\nfloat uWidth, float vWidth, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = 2.0 * fract(uvCoord); \nfloat bulge = 0.0;\nif (uvCoord.x > uWidth && uvCoord.x < 2.0 - uWidth &&\nuvCoord.y > vWidth && uvCoord.y < 2.0 - vWidth) {\nuvCoord.x = (uvCoord.x - uWidth) / (1.0 - uWidth);\nuvCoord.y = (uvCoord.y - vWidth) / (1.0 - vWidth);\nbulge = uvCoord.x * (2.0 - uvCoord.x) * uvCoord.y * (2.0 - uvCoord.y);\n}\noutAlpha = bulge; \noutColor = vec3(bulge, bulge, bulge); \n}",node_blinn_my_frag:"void node_blinn(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat eccentricity, vec3 specularColor, float specularRollOff, float translucence,\nvec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.roughness = max(eccentricity, 0.0525);\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min(material.roughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_bump_2d_my_frag:"void node_bump_2d(\nvec3 normal,\nfloat bumpDepth, float bumpValue,\nout vec3 outNormal) {\nvec3 position = vViewPosition;\nvec3 dPdx = dFdx(position);\nvec3 dPdy = dFdy(position);\nfloat dHdx = dFdx(bumpValue);\nfloat dHdy = dFdy(bumpValue);\nvec3 tanX = cross(dPdy, normal);\nvec3 tanY = cross(normal, dPdx);\nvec3 surfaceGrad = dHdx * tanX + dHdy * tanY;\nfloat dotPosTanX = dot(dPdx, tanX);\noutNormal = normalize(normal * abs(dotPosTanX) - surfaceGrad * sign(dotPosTanX));\noutNormal = normalize(mix(normal, outNormal, max(0.0, bumpDepth)));\n}\nvoid node_bump_2d(\nvec3 normal, vec4 tangent,\nfloat bumpDepth, vec3 bumpValue,\nout vec3 outNormal) {\n#ifdef DOUBLE_SIDED\nnormal = normal * (float(gl_FrontFacing) * 2.0 - 1.0);\n#endif\nvec3 normalTex = (bumpValue.xyz * 2.0 - 1.0);\nvec4 viewTangent = vec4(normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz), tangent.w);\nvec3 bitangent = viewTangent.w * cross(normal, viewTangent.xyz);\noutNormal = normalize(normalTex.x * viewTangent.xyz + normalTex.y * bitangent \n+ normalTex.z * normal);\noutNormal = mix(normal, outNormal, bumpDepth);\n}",node_channels_my_frag:"void node_channels(\nint channelR, int channelG, int channelB, int channelA,\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutAlpha = 1.0;\noutColor = vec3(1.0);\nif (channelR == 0)\noutColor.r = inColor.r;\nelse if (channelR == 1)\noutColor.r = inColor.g;\nelse if (channelR == 2)\noutColor.r = inColor.b;\nelse\noutColor.r = inAlpha;\nif (channelG == 0)\noutColor.g = inColor.r;\nelse if (channelG == 1)\noutColor.g = inColor.g;\nelse if (channelG == 2)\noutColor.g = inColor.b;\nelse\noutColor.g = inAlpha;\nif (channelB == 0)\noutColor.b = inColor.r;\nelse if (channelB == 1)\noutColor.b = inColor.g;\nelse if (channelB == 2)\noutColor.b = inColor.b;\nelse\noutColor.b = inAlpha;\nif (channelA == 0)\noutAlpha = inColor.r;\nelse if (channelA == 1)\noutAlpha = inColor.g;\nelse if (channelA == 2)\noutAlpha = inColor.b;\nelse\noutAlpha = inAlpha;\n}",node_checker_my_frag:"void node_checker(\nvec3 color1, vec3 color2, float contrast, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord -= floor(uvCoord); \nvec3 deltaColor = color2 - color1;\ncolor1 += (1.0 - contrast) * 0.5 * deltaColor;\ncolor2 -= (1.0 - contrast) * 0.5 * deltaColor;\nif ((uvCoord.x < 0.5 && uvCoord.y >= 0.5) || (uvCoord.x >= 0.5 && uvCoord.y < 0.5)) { \noutColor = color2; \noutAlpha = 1.0; \n} else {\noutColor = color1; \noutAlpha = 0.0; \n}\n}",node_clamp_my_frag:"void node_clamp(\nvec3 inputValue, vec3 maxValue, vec3 minValue,\nout vec3 outputValue) {\noutputValue = clamp(inputValue, minValue, maxValue);\n}",node_cloth_my_frag:"void node_cloth(\nfloat brightSpread, vec3 gapColor, float randomness, vec3 uColor, float uWave, float uWidth,\nvec3 vColor, float vWave, float vWidth, float widthSpread, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nif (abs(uWave) > -EPSILON || abs(vWave) > -EPSILON) {\nuvCoord.x += - uWave * sin(PI2 * uvCoord.y);\nuvCoord.y += vWave * sin(PI2 * uvCoord.x);\n}\nuvCoord = fract(uvCoord);\nint thread = 0;\nif ((uvCoord.x >= 0.5 && uvCoord.y < 0.5) || (uvCoord.x < 0.5 && uvCoord.y >= 0.5)) {\nfloat flippedCoord;\nflippedCoord = uvCoord.x;\nuvCoord.x = uvCoord.y;\nuvCoord.y = flippedCoord;\nflippedCoord = uWidth;\nuWidth = vWidth;\nvWidth = flippedCoord;\nthread = 1;\n}\nuvCoord = fract(2.0 * uvCoord);\nfloat cloth = 1.0;\nif (uvCoord.y <= vWidth) {\nfloat clothU = uvCoord.x - 0.5 * uWidth;\nfloat clothV = 2.0 * uvCoord.y / vWidth - 1.0;\ncloth = 0.75 * (clothU * clothU + clothV * clothV);\n} else if (uvCoord.x <= uWidth) {\nfloat clothU = 2.0 * uvCoord.x / uWidth - 1.0;\nfloat clothV = uvCoord.y - 0.5 * vWidth - 1.0;\ncloth = 0.75 * (clothU * clothU + clothV * clothV);\nthread = 1 - thread;\n}\noutColor = gapColor;\nif (cloth < 1.0) {\ncloth = 1.0 - cloth;\ncloth = min(cloth, 1.0);\noutColor *= (1.0 - cloth);\nvec3 threadColor = uColor;\nif (thread == 0)\nthreadColor = vColor;\noutColor += threadColor * cloth;\n}\noutAlpha = dot(outColor, LUM_WEIGHTS_MAYA);\n}",node_color_condition_my_frag:"void node_color_condition(\nfloat alphaA, float alphaB, vec3 colorA, vec3 colorB, bool condition,\nout float outAlpha, out vec3 outColor) {\noutAlpha = condition ? alphaA : alphaB;\noutColor = condition ? colorA : colorB;\n}",node_color_composite_my_frag:"void node_color_composite(int operation,\nvec3 colorA, float alphaA, vec3 colorB, float alphaB, float factor,\nout vec3 outColor, out float outAlpha)\n{\nif (factor <= 0.0) {\noutColor = colorA;\noutAlpha = alphaA;\nreturn;\n}\nif (operation == 0) {\noutColor[0] = colorA[0] + (colorB[0] * factor);\noutColor[1] = colorA[1] + (colorB[1] * factor);\noutColor[2] = colorA[2] + (colorB[2] * factor);\noutAlpha = alphaA + (alphaB * factor);\n} else if (operation == 1) {\noutColor[0] = colorA[0] + ((colorB[0] - 1.0) * factor);\noutColor[1] = colorA[1] + ((colorB[1] - 1.0) * factor);\noutColor[2] = colorA[2] + ((colorB[2] - 1.0) * factor);\noutAlpha = alphaA + ((alphaB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutColor = colorB;\noutAlpha = alphaB;\nreturn;\n}\noutColor[0] = mix(colorA[0], colorB[0], factor);\noutColor[1] = mix(colorA[1], colorB[1], factor);\noutColor[2] = mix(colorA[2], colorB[2], factor);\noutAlpha = mix(alphaA, alphaB, factor);\n} else if (operation == 3) {\noutColor[0] = colorA[0] * (colorB[0] * factor + (1.0 - factor));\noutColor[1] = colorA[1] * (colorB[1] * factor + (1.0 - factor));\noutColor[2] = colorA[2] * (colorB[2] * factor + (1.0 - factor));\noutAlpha = alphaA * (alphaB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutColor[0] = 1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor));\noutColor[1] = 1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor));\noutColor[2] = 1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor));\noutAlpha = 1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor));\n} else if (operation == 5) {\noutColor[0] = colorB[0] > 0.5 ? (2.0 * colorA[0] * colorB[0] * factor) + colorA[0] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[0]) * (1.0 - colorB[0] * factor)) * (2.0 - (1.0 - factor));\noutColor[1] = colorB[1] > 0.5 ? (2.0 * colorA[1] * colorB[1] * factor) + colorA[1] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[1]) * (1.0 - colorB[1] * factor)) * (2.0 - (1.0 - factor));\noutColor[2] = colorB[2] > 0.5 ? (2.0 * colorA[2] * colorB[2] * factor) + colorA[2] * (1.0 - factor) :\n1.0 - ((1.0 - colorA[2]) * (1.0 - colorB[2] * factor)) * (2.0 - (1.0 - factor));\noutAlpha = alphaB > 0.5 ? (2.0 * alphaA * alphaB * factor) + alphaA * (1.0 - factor) :\n1.0 - ((1.0 - alphaA) * (1.0 - alphaB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutColor[0] = abs(colorA[0] - (colorB[0] * factor));\noutColor[1] = abs(colorA[1] - (colorB[1] * factor));\noutColor[2] = abs(colorA[2] - (colorB[2] * factor));\noutAlpha = abs(alphaA - (alphaB * factor));\n} else if (operation == 7) {\noutColor[0] = clamp(mix(colorA[0], colorA[0] / max(1.0 - colorB[0], 0.00001), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], colorA[1] / max(1.0 - colorB[1], 0.00001), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], colorA[2] / max(1.0 - colorB[2], 0.00001), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, alphaA / max(1.0 - alphaB, 0.00001), factor), alphaA, alphaB);\n} else if (operation == 8) {\noutColor[0] = clamp(mix(colorA[0], 1.0 - (colorA[0] / max(1.0 - colorB[0], 0.00001)), factor), colorA[0], colorB[0]);\noutColor[1] = clamp(mix(colorA[1], 1.0 - (colorA[1] / max(1.0 - colorB[1], 0.00001)), factor), colorA[1], colorB[1]);\noutColor[2] = clamp(mix(colorA[2], 1.0 - (colorA[2] / max(1.0 - colorB[2], 0.00001)), factor), colorA[2], colorB[2]);\noutAlpha = clamp(mix(alphaA, 1.0 - (alphaA / max(1.0 - alphaB, 0.00001)), factor), alphaA, alphaB);\n}\n}",node_color_constant_my_frag:"void node_color_constant(vec3 inColor, float inAlpha, out vec3 outColor, out float outAlpha)\n{\noutColor = inColor;\noutAlpha = inAlpha;\n}",node_color_correct_my_frag:"void node_color_correct(\nbool colClamp, vec3 colClampMin, vec3 colClampMax,\nbool alphaClamp, float alphaClampMin, float alphaClampMax,\nbool unpremultInput, bool premultResult,\nfloat alphaGain, float alphaGamma, float alphaOffset,\nvec3 colGain, vec3 colGamma, vec3 colOffset, float hueShift,\nfloat inAlpha, vec3 inColor, float satGain, float valGain,\nout float outAlpha, out vec3 outColor)\n{\noutColor = unpremultInput ? inColor/inAlpha : inColor;\nif (hueShift != 0.0 || satGain != 1.0 || valGain != 1.0) {\nvec4 color = vec4(outColor, 1.0);\nrgbToHSV(vec4(inColor, 1.0), color);\ncolor.r += hueShift / 360.0;\nif (color.r > 1.0)\ncolor.r -= 1.0;\nelse if (color.r < 0.0)\ncolor.r += 1.0;\ncolor.g *= satGain;\ncolor.b *= valGain;\nhsvToRGB(color, color);\noutColor = color.rgb;\n}\noutColor *= colGain;\noutColor += colOffset;\nif (any(notEqual(colGamma, vec3(1.0))))\noutColor = pow(outColor, 1.0 / colGamma);\nif (colClamp)\noutColor = clamp(outColor, colClampMin, colClampMax);\noutAlpha = inAlpha * alphaGain;\noutAlpha += alphaOffset;\nif (alphaGamma != 1.0)\noutAlpha = pow(outAlpha, 1.0 / alphaGamma);\nif (alphaClamp)\noutAlpha = clamp(outAlpha, alphaClampMin, alphaClampMax);\nif (premultResult)\noutColor *= outAlpha;\n}",node_color_logic_my_frag:"void node_color_logic(\nint operation,\nvec3 colorA, vec3 colorB,\nout bool outBool) {\nif (operation == 0) {\noutBool = all(equal(colorA, colorB));\n} else if (operation == 1) {\noutBool = any(notEqual(colorA, colorB));\n} else if (operation == 2) {\noutBool = ((colorA.x + colorA.y + colorA.z) < (colorB.x + colorB.y + colorB.z));\n} else if (operation == 3) {\noutBool = ((colorA.x + colorA.y + colorA.z) > (colorB.x + colorB.y + colorB.z));\n} else if (operation == 4) {\noutBool = ((colorA.x + colorA.y + colorA.z) <= (colorB.x + colorB.y + colorB.z));\n} else {\noutBool = ((colorA.x + colorA.y + colorA.z) >= (colorB.x + colorB.y + colorB.z));\n}\n}",node_color_mask_my_frag:"void node_color_mask(\nbool maskAlphaIsLuminance,\nfloat inAlpha, vec3 inColor, vec3 mask, float maskAlpha,\nout float outAlpha, out vec3 outColor) {\nif (maskAlphaIsLuminance)\nmaskAlpha = 1.0 - dot(mask, LUM_WEIGHTS_MAYA);\noutColor = inColor * (1.0 - maskAlpha);\n}",node_color_math_my_frag:"void node_color_math(\nint operation,\nfloat alphaA, float alphaB, vec3 colorA, vec3 colorB,\nout float outAlpha, out vec3 outColor) {\nif (operation == 0) {\noutColor = colorA + colorB;\noutAlpha = alphaA + alphaB;\n} else if (operation == 1) {\noutColor = colorA - colorB;\noutAlpha = alphaA - alphaB;\n} else if (operation == 2) {\noutColor = colorA * colorB;\noutAlpha = alphaA * alphaB;\n} else if (operation == 3) {\noutColor = colorA / colorB;\noutAlpha = alphaA / alphaB;\n} else if (operation == 4) {\noutColor = min(colorA, colorB);\noutAlpha = min(alphaA, alphaB);\n} else {\noutColor = max(colorA, colorB);\noutAlpha = max(alphaA, alphaB);\n}\n}",node_compose_matrix_my_frag:"mat3 quatToMat3(vec4 quat) {\nfloat x = quat.x,\ny = quat.y,\nz = quat.z,\nw = quat.w;\nfloat x2 = x + x;\nfloat y2 = y + y;\nfloat z2 = z + z;\n\nfloat xx = x * x2;\nfloat yx = y * x2;\nfloat yy = y * y2;\nfloat zx = z * x2;\nfloat zy = z * y2;\nfloat zz = z * z2;\nfloat wx = w * x2;\nfloat wy = w * y2;\nfloat wz = w * z2;\n\nmat3 mat;\n\nmat[0][0] = 1.0 - yy - zz;\nmat[1][0] = yx - wz;\nmat[2][0] = zx + wy;\n\nmat[0][1] = yx + wz;\nmat[1][1] = 1.0 - xx - zz;\nmat[2][1] = zy - wx;\n\nmat[0][2] = zx - wy;\nmat[1][2] = zy + wx;\nmat[2][2] = 1.0 - xx - yy;\nreturn mat;\n}\nvoid node_compose_matrix(\nbool useEulerRotation, int inputRotateOrder,\nvec4 inputQuat, vec3 inputRotate, vec3 inputScale, vec3 inputShear, vec3 inputTranslate,\nout mat4 outputMatrix)\n{\nmat4 rotateMatrix;\ninputRotate = radians(inputRotate);\nif (useEulerRotation)\nrotateMatrix = toMat4(mat3RotateX(inputRotate.x) * mat3RotateY(inputRotate.y) * mat3RotateZ(inputRotate.z));\nelse\nrotateMatrix = toMat4(quatToMat3(normalize(inputQuat)));\nmat4 scaleMatrix = mat4(inputScale.x, 0.0, 0.0, 0.0,\n0.0, inputScale.y, 0.0, 0.0,\n0.0, 0.0, inputScale.z, 0.0,\n0.0, 0.0, 0.0, 1.0);\nmat4 shearMatrix = mat4(1.0, 0.0, 0.0, 0.0,\ninputShear.x, 1.0, 0.0, 0.0,\ninputShear.y, inputShear.z, 1.0, 0.0,\n0.0, 0.0, 0.0, 1.0);\nmat4 transMatrix = mat4(1.0, 0.0, 0.0, 0.0,\n0.0, 1.0, 0.0, 0.0,\n0.0, 0.0, 1.0, 0.0,\ninputTranslate.x, inputTranslate.y, inputTranslate.z, 1.0);\noutputMatrix = scaleMatrix * shearMatrix * rotateMatrix * transMatrix;\n}",node_condition_my_frag:"void node_condition(\nint operation,\nvec3 colorIfFalse, vec3 colorIfTrue, float firstTerm, float secondTerm,\nout vec3 outColor) {\nif (operation == 0) {\nif (firstTerm == secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 1) {\nif (firstTerm != secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 2) {\nif (firstTerm > secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 3) {\nif (firstTerm >= secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 4) {\nif (firstTerm < secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n} else if (operation == 5) {\nif (firstTerm <= secondTerm)\noutColor = colorIfTrue;\nelse\noutColor = colorIfFalse;\n}\n}",node_decompose_matrix_my_frag:"vec4 mat3ToQuat(mat3 m) {\nfloat trace = m[0][0] + m[1][1] + m[2][2];\nvec4 q = vec4(0.0, 0.0, 0.0, 0.0);\nif (trace > 0.0) {\nfloat s = sqrt(trace + 1.0) * 2.0;\nq.w = 0.25 * s;\nq.x = (m[2][1] - m[1][2]) / s;\nq.y = (m[0][2] - m[2][0]) / s;\nq.z = (m[1][0] - m[0][1]) / s;\n} else if ((m[0][0] > m[1][1]) && (m[0][0] > m[2][2])) {\nfloat s = sqrt(1.0 + m[0][0] - m[1][1] - m[2][2]) * 2.0;\nq.w = (m[2][1] - m[1][2]) / s;\nq.x = 0.25 * s;\nq.y = (m[0][1] + m[1][0]) / s;\nq.z = (m[0][2] + m[2][0]) / s;\n} else if (m[1][1] > m[2][2]) {\nfloat s = sqrt(1.0 + m[1][1] - m[0][0] - m[2][2]) * 2.0;\nq.w = (m[0][2] - m[2][0]) / s;\nq.x = (m[0][1] + m[1][0]) / s;\nq.y = 0.25 * s;\nq.z = (m[1][2] + m[2][1]) / s;\n} else {\nfloat s = sqrt(1.0 + m[2][2] - m[0][0] - m[1][1]) * 2.0;\nq.w = (m[1][0] - m[0][1]) / s;\nq.x = (m[0][2] + m[2][0]) / s;\nq.y = (m[1][2] + m[2][1]) / s;\nq.z = 0.25 * s;\n}\nreturn q;\n}\nvec3 mat3ToEuler(mat3 m) {\nfloat m11 = m[0][0], m12 = m[1][0], m13 = m[2][0];\nfloat m21 = m[0][1], m22 = m[1][1], m23 = m[2][1];\nfloat m31 = m[0][2], m32 = m[1][2], m33 = m[2][2];\nvec3 euler;\neuler.y = asin(clamp(m13, -1.0, 1.0));\nif (abs(m13) < 0.9999999) {\neuler.x = atan(-m23, m33);\neuler.z = atan(-m12, m11);\n} else {\neuler.x = atan(m32, m22);\neuler.z = 0.0;\n}\nreturn euler;\n}\nvoid decomposeMat4(mat4 m, out vec3 position, out vec4 quat, out vec3 euler, out vec3 scale) {\nfloat sx = length(vec3(m[0][0], m[0][1], m[0][2]));\nfloat sy = length(vec3(m[1][0], m[1][1], m[1][2]));\nfloat sz = length(vec3(m[2][0], m[2][1], m[2][2]));\nfloat det = mat3GetDeterminant(toMat3(m));\nif (det < 0.0)\nsx = -sx;\nposition.x = m[3][0];\nposition.y = m[3][1];\nposition.z = m[3][2];\nfloat invSX = 1.0 / sx;\nfloat invSY = 1.0 / sy;\nfloat invSZ = 1.0 / sz;\nm[0][0] *= invSX;\nm[0][1] *= invSX;\nm[0][2] *= invSX;\nm[1][0] *= invSY;\nm[1][1] *= invSY;\nm[1][2] *= invSY;\nm[2][0] *= invSZ;\nm[2][1] *= invSZ;\nm[2][2] *= invSZ;\nquat = mat3ToQuat(toMat3(m));\neuler = mat3ToEuler(toMat3(m));\nscale.x = sx;\nscale.y = sy;\nscale.z = sz;\n}\nvoid node_decompose_matrix(\nmat4 inputMatrix,\nout vec4 outputQuat, out vec3 outputRotate, out vec3 outputScale, out vec3 outputShear, out vec3 outputTranslate)\n{\ndecomposeMat4(inputMatrix, outputTranslate, outputQuat, outputRotate, outputScale);\noutputShear = vec3(0.0, 0.0, 0.0);\n}",node_env_sphere_my_frag:"void node_env_sphere(sampler2D envMap, int encoding, vec3 normal,\nmat4 placementMatrix,\nout float outAlpha, out vec3 outColor)\n{\nvec3 cameraToVertex = normalize(vWorldPosition - cameraPosition);\nvec3 reflectVec;\n#if WORLD_NODES\nreflectVec = normalize(cameraToVertex);\n#else\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nreflectVec = reflect(cameraToVertex, worldNormal);\n#endif\nmat3 uvTransform = mat3(1.0);\nreflectVec = toMat3(placementMatrix) * reflectVec;\nvec4 tex = sampleEquirectangular(envMap, reflectVec, uvTransform, encoding);\noutAlpha = tex.a;\noutColor = tex.rgb;\n}",node_file_my_frag:"void node_file(sampler2D ima, const int encoding, const bool rgbToAlpha,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor, out vec2 outSize, out vec3 outTransparency) {\nvec2 uv = vec2(uvCoord.x, 1.0 - uvCoord.y);\nvec4 tex = texture2D(ima, uv);\noutColor = nodeTexelToLinear(tex, encoding).rgb;\nif (rgbToAlpha)\noutAlpha = dot(tex.rgb, LUM_WEIGHTS_MAYA);\nelse\noutAlpha = tex.a;\noutSize = vec2(0.0);\noutTransparency = vec3(1.0 - outAlpha, 1.0 - outAlpha, 1.0 - outAlpha);\n}",node_float_condition_my_frag:"void node_float_condition(\nbool condition, float floatA, float floatB, \nout float outFloat) {\noutFloat = condition ? floatA : floatB;\n}",node_float_composite_my_frag:"void node_float_composite(int operation,\nfloat floatA, float floatB, float factor,\nout float outFloat)\n{\nif (factor <= 0.0) {\noutFloat = floatA;\nreturn;\n}\nif (operation == 0) {\noutFloat = floatA + (floatB * factor);\n} else if (operation == 1) {\noutFloat = floatA + ((floatB - 1.0) * factor);\n} else if (operation == 2) {\nif (factor >= 1.0) {\noutFloat = floatB;\nreturn;\n}\noutFloat = mix(floatA, floatB, factor);\n} else if (operation == 3) {\noutFloat = floatA * (floatB * factor + (1.0 - factor));\n} else if (operation == 4) {\noutFloat = 1.0 - ((1.0 - floatA) * (1.0 - floatB * factor));\n} else if (operation == 5) {\noutFloat = floatB > 0.5 ? (2.0 * floatA * floatB * factor) + floatA * (1.0 - factor) :\n1.0 - ((1.0 - floatA) * (1.0 - floatB * factor)) * (2.0 - (1.0 - factor));\n} else if (operation == 6) {\noutFloat = abs(floatA - (floatB * factor));\n} else if (operation == 7) {\noutFloat = clamp(mix(floatA, floatA / max(1.0 - floatB, 0.00001), factor), floatA, floatB);\n} else if (operation == 8) {\noutFloat = clamp(mix(floatA, 1.0 - (floatA / max(1.0 - floatB, 0.00001)), factor), floatA, floatB);\n}\n}",node_float_constant_my_frag:"void node_float_constant(float inFloat, out float outFloat)\n{\noutFloat = inFloat;\n}",node_float_logic_my_frag:"void node_float_logic(\nint operation,\nfloat floatA, float floatB,\nout bool outBool) {\nif (operation == 0) {\noutBool = (floatA == floatB);\n} else if (operation == 1) {\noutBool = (floatA != floatB);\n} else if (operation == 2) {\noutBool = (floatA < floatB);\n} else if (operation == 3) {\noutBool = (floatA > floatB);\n} else if (operation == 4) {\noutBool = (floatA <= floatB);\n} else {\noutBool = (floatA >= floatB);\n}\n}",node_float_mask_my_frag:"void node_float_mask(\nfloat inFloat, float mask,\nout float outFloat) {\noutFloat = inFloat - mask;\n}",node_float_math_my_frag:"void node_float_math(\nint operation,\nfloat floatA, float floatB,\nout float outFloat) {\nif (operation == 0) {\noutFloat = floatA + floatB;\n} else if (operation == 1) {\noutFloat = floatA - floatB;\n} else if (operation == 2) {\noutFloat = floatA * floatB;\n} else if (operation == 3) {\noutFloat = floatA / floatB;\n} else if (operation == 4) {\noutFloat = min(floatA, floatB);\n} else if (operation == 5) {\noutFloat = max(floatA, floatB);\n} else {\noutFloat = pow(floatA, floatB);\n}\n}",node_four_by_four_matrix_my_frag:"void node_four_by_four_matrix(\nfloat in00, float in01, float in02, float in03,\nfloat in10, float in11, float in12, float in13,\nfloat in20, float in21, float in22, float in23,\nfloat in30, float in31, float in32, float in33,\nout mat4 outMatrix)\n{\noutMatrix = mat4(in00, in01, in02, in03,\nin10, in11, in12, in13,\nin20, in21, in22, in23,\nin30, in31, in32, in33);\n}",node_gamma_correct_my_frag:"void node_gamma_correct(\nvec3 gamma, vec3 value,\nout vec3 outValue) {\noutValue = pow(value, 1.0 / gamma);\n}",node_grid_my_frag:"void node_grid(\nfloat contrast, vec3 fillerColor, vec3 lineColor, float uWidth, float vWidth, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = fract(uvCoord); \nfloat v0 = max(uvCoord.y, 0.5 * vWidth);\nfloat v1 = min(uvCoord.y, 1.0 - 0.5 * vWidth);\nfloat u0 = max(uvCoord.x, 0.5 * uWidth);\nfloat u1 = min(uvCoord.x, 1.0 - 0.5 * uWidth);\nfloat gridFactor = (v0 <= v1 && u0 <= u1) ? 1.0 : 0.0;\ngridFactor = 0.5 - contrast * (gridFactor - 0.5);\ngridFactor = max(gridFactor, 0.0);\nvec3 gridColor = mix(fillerColor, lineColor, gridFactor); \ngridColor.r = max(gridColor.r, 0.0);\ngridColor.g = max(gridColor.g, 0.0);\ngridColor.b = max(gridColor.b, 0.0);\noutAlpha = saturate(gridFactor); \noutColor = gridColor; \n}",node_inverse_matrix_my_frag:"\nmat4 inverseMat4(mat4 m) {\nfloat a00 = m[0][0], a01 = m[0][1], a02 = m[0][2], a03 = m[0][3],\na10 = m[1][0], a11 = m[1][1], a12 = m[1][2], a13 = m[1][3],\na20 = m[2][0], a21 = m[2][1], a22 = m[2][2], a23 = m[2][3],\na30 = m[3][0], a31 = m[3][1], a32 = m[3][2], a33 = m[3][3];\nfloat b00 = a00 * a11 - a01 * a10,\nb01 = a00 * a12 - a02 * a10,\nb02 = a00 * a13 - a03 * a10,\nb03 = a01 * a12 - a02 * a11,\nb04 = a01 * a13 - a03 * a11,\nb05 = a02 * a13 - a03 * a12,\nb06 = a20 * a31 - a21 * a30,\nb07 = a20 * a32 - a22 * a30,\nb08 = a20 * a33 - a23 * a30,\nb09 = a21 * a32 - a22 * a31,\nb10 = a21 * a33 - a23 * a31,\nb11 = a22 * a33 - a23 * a32;\nfloat det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\nreturn mat4(a11 * b11 - a12 * b10 + a13 * b09,\na02 * b10 - a01 * b11 - a03 * b09,\na31 * b05 - a32 * b04 + a33 * b03,\na22 * b04 - a21 * b05 - a23 * b03,\na12 * b08 - a10 * b11 - a13 * b07,\na00 * b11 - a02 * b08 + a03 * b07,\na32 * b02 - a30 * b05 - a33 * b01,\na20 * b05 - a22 * b02 + a23 * b01,\na10 * b10 - a11 * b08 + a13 * b06,\na01 * b08 - a00 * b10 - a03 * b06,\na30 * b04 - a31 * b02 + a33 * b00,\na21 * b02 - a20 * b04 - a23 * b00,\na11 * b07 - a10 * b09 - a12 * b06,\na00 * b09 - a01 * b07 + a02 * b06,\na31 * b01 - a30 * b03 - a32 * b00,\na20 * b03 - a21 * b01 + a22 * b00) / det;\n}\nvoid node_inverse_matrix(\nmat4 inputMatrix,\nout mat4 outputMatrix)\n{\noutputMatrix = inverseMat4(inputMatrix);\n}",node_lambert_my_frag:"\nvoid node_lambert(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color.rgb;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_IndirectDiffuse\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + incandescence, alpha);\n}",node_layered_texture_layer_my_frag:"#define LAYER_BLEND_MODE_NONE 0.0\n#define LAYER_BLEND_MODE_OVER 1.0\n#define LAYER_BLEND_MODE_IN 2.0\n#define LAYER_BLEND_MODE_OUT 3.0\n#define LAYER_BLEND_MODE_ADD 4.0\n#define LAYER_BLEND_MODE_SUBTRACT 5.0\n#define LAYER_BLEND_MODE_MULTIPLY 6.0\n#define LAYER_BLEND_MODE_DIFFERENCE 7.0\n#define LAYER_BLEND_MODE_LIGHTEN 8.0\n#define LAYER_BLEND_MODE_DARKEN 9.0\n#define LAYER_BLEND_MODE_SATURATE 10.0\n#define LAYER_BLEND_MODE_DESATURATE 11.0\n#define LAYER_BLEND_MODE_ILLUMINATE 12.0\nvoid node_layered_texture_layer(\nconst float alphaBG, const vec3 colorBG, \nconst vec3 color, const float alpha, const float blendMode, const bool isVisible,\nout float outAlpha, out vec3 outColor)\n{\noutAlpha = alphaBG;\noutColor = colorBG;\nif (!isVisible)\nreturn;\nif (blendMode == LAYER_BLEND_MODE_NONE) {\noutColor = color;\n} else if (blendMode == LAYER_BLEND_MODE_OVER) {\noutColor = mix(colorBG, color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_IN) {\noutColor = alpha * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_OUT) {\noutColor = (1.0 - alpha) * colorBG;\n} else if (blendMode == LAYER_BLEND_MODE_ADD) {\noutColor = mix(colorBG, colorBG + color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_SUBTRACT) {\noutColor = mix(colorBG, colorBG - color, alpha);\n} else if (blendMode == LAYER_BLEND_MODE_MULTIPLY) {\noutColor = mix(colorBG, colorBG * color, alpha);\n} else {\noutColor = mix(colorBG, color, alpha);\n}\n}",node_light_path_my_frag:"void node_light_path(out float isCameraRay)\n{\n#if LIGHT_PATH_IS_CAM_RAY\nisCameraRay = 1.0;\n#else\nisCameraRay = 0.0;\n#endif\n}",node_luminance_my_frag:"void node_luminance(\nvec3 value,\nout float outValue) {\noutValue = dot(value, LUM_WEIGHTS_MAYA);\n}",node_multiply_divide_my_frag:"void node_multiply_divide(\nint operation,\nvec3 input1, vec3 input2,\nout vec3 outValue) {\nif (operation == 0) {\noutValue = input1;\n} else if (operation == 1) {\noutValue = input1 * input2;\n} else if (operation == 2) {\n\noutValue = input1 / input2;\n} else {\noutValue = pow(input1, input2);\n}\n}",node_mult_double_linear_my_frag:"void node_mult_double_linear(\nfloat input1, float input2,\nout float outValue) {\noutValue = input1 * input2;\n}",node_mult_matrix_my_frag:"\nvoid node_mult_matrix(\nmat4 matrixIn1,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn1;\n}\nvoid node_mult_matrix(\nmat4 matrixIn1, mat4 matrixIn2,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn2 * matrixIn1;\n}\nvoid node_mult_matrix(\nmat4 matrixIn1, mat4 matrixIn2, mat4 matrixIn3,\nout mat4 matrixSum)\n{\nmatrixSum = matrixIn3 * matrixIn2 * matrixIn1;\n}",node_noise_my_frag:"vec2 calcNoiseImplode(float implode, vec2 implodeCenter, vec2 uv) {\nif (abs(implode) >= EPSILON) {\nuv -= implodeCenter;\nfloat len = length(uv);\nif (len > EPSILON) {\nfloat factor = pow(len, 1.0-implode) / len;\nuv *= factor;\n}\nuv += implodeCenter;\n}\nreturn uv;\n}\nvoid node_noise(\nfloat amplitude, int depthMax, float frequency, float frequencyRatio, float implode,\nvec2 implodeCenter, bool inflection, float ratio, float threshold, float time, vec2 uvCoord,\nout float outAlpha, out vec3 outColor) {\nuvCoord = calcNoiseImplode(implode, implodeCenter, uvCoord);\nfrequency *= 0.6;\namplitude *= 0.9;\nuvCoord *= frequency;\nfloat noiseAccum = 0.0;\nvec2 freqOffset = vec2(0.02, 0.3);\nint depthId = 0;\nwhile (depthId < depthMax) {\nint stepVal = depthId;\nfloat noise = noisePerlin(vec3(uvCoord + freqOffset, time + 0.5 * float(stepVal)));\nif (inflection)\nnoise = abs(noise);\nnoiseAccum += amplitude * noise;\nuvCoord *= frequencyRatio;\ntime *= sqrt(frequencyRatio);\namplitude *= ratio;\nfreqOffset += vec2(0.02, 0.3);\ndepthId++;\n}\nif (!inflection)\nnoiseAccum = 0.5 * noiseAccum + 0.5;\nnoiseAccum += threshold;\noutAlpha = min(1.0, noiseAccum);\noutColor = vec3(outAlpha, outAlpha, outAlpha);\n}",node_output_my_frag:"void node_output(vec4 rgb, out vec4 outgoingLight)\n{\noutgoingLight = rgb;\n}",node_place_2d_texture_my_frag:"void node_place_2d_texture(const vec2 inUv,\nvec2 offset, vec2 repeatUv, float rotateUv,\nout vec2 outUv)\n{\noutUv = (calcUvTransform(offset.x, offset.y, repeatUv.x, repeatUv.y, rotateUv) * vec3(inUv, 1.0)).xy;\noutUv.y = 1.0 - outUv.y;\n}",node_phong_my_frag:"void node_phong(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat cosinePower, vec3 specularColor, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nfloat roughness = sqrt(1.0 / (0.454 * cosinePower + 3.357));\nmaterial.roughness = max(roughness, 0.0525);\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min(material.roughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_phong_e_my_frag:"void node_phong_e(\nvec3 geometryNormal,\nvec3 color, vec3 ambientColor, vec3 incandescence, float matteOpacity,\nfloat diffuse, vec3 normal, float reflectivity, vec3 reflectedColor,\nfloat highlightSize, float roughness, vec3 specularColor, float translucence, vec3 transparency,\nout vec4 outColor) {\nNodeMaterial material;\nmaterial.diffuseColor = diffuse * color;\n#ifdef USE_CLEARCOAT\n#undef USE_CLEARCOAT\n#define _CLEARCOAT_RESTORE\n#endif\nvec3 dxy = max(abs(dFdx(geometryNormal)), abs(dFdy(geometryNormal)));\nfloat geometryRoughness = max(max(dxy.x, dxy.y), dxy.z);\nmaterial.roughness = max(roughness, 0.0525);\nmaterial.roughness += geometryRoughness;\nmaterial.roughness = min(material.roughness, 1.0);\nmaterial.specularColor = specularColor;\nReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));\n#define RE_DirectDiffuse RE_DirectDiffuse_Node\n#define RE_DirectSpecular RE_DirectSpecular_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include \n#include \n#include \n#undef RE_DirectDiffuse\n#undef RE_DirectSpecular\n#undef RE_IndirectDiffuse\n#undef RE_IndirectSpecular\n#ifdef _CLEARCOAT_RESTORE\n#undef _CLEARCOAT_RESTORE\n#define USE_CLEARCOAT\n#endif\nfloat alpha = 1.0 - average(transparency);\noutColor = vec4(reflectedLight.directDiffuse + reflectedLight.indirectDiffuse +\nreflectedLight.directSpecular + reflectedLight.indirectSpecular + incandescence, alpha);\n}",node_premultiply_my_frag:"void node_premultiply(\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutColor = inColor * inAlpha;\noutAlpha = inAlpha;\n}",node_ramp_my_frag:"void node_ramp(\nsampler2D rampData, int rampType,\nvec2 uvCoord,\nout float outAlpha, out vec3 outColor)\n{\nfloat coord;\nif (rampType == 0) {\ncoord = uvCoord.y;\n} else if (rampType == 1) {\ncoord = uvCoord.x;\n} else if (rampType == 2) {\ncoord = abs(uvCoord.x + uvCoord.y) / 2.0;\n} else if (rampType == 3) {\nvec2 uvSpiral = mat2(0.0, 1.0, 1.0, 0.0) * (uvCoord - vec2(0.5));\ncoord = atan(uvSpiral.y, uvSpiral.x) / PI2 + 0.5;\n} else if (rampType == 4) {\ncoord = length(uvCoord - vec2(0.5)) * sqrt(2.0);\n} else if (rampType == 5) {\nvec2 boxUv = abs(uvCoord - vec2(0.5)) * 2.0;\ncoord = max(boxUv.x, boxUv.y);\n} else if (rampType == 6) {\nuvCoord = abs((uvCoord - vec2(0.5)) * 2.0);\ncoord = uvCoord.y;\n} else if (rampType == 7) {\ncoord = uvCoord.y;\n} else {\ncoord = uvCoord.y;\n}\nvec4 tex = texture2D(rampData, vec2(coord, 0.0));\noutAlpha = average(tex.xyz);\noutColor = tex.xyz;\n}",node_remap_hsv_my_frag:"void node_remap_hsv(vec3 color, out vec3 outColor)\n{\noutColor = color;\n}",node_reverse_my_frag:"void node_reverse(\nvec3 inValue,\nout vec3 outValue) {\noutValue = 1.0 - inValue;\n}",node_sampler_info_my_frag:"void node_sampler_info(\nbool frontFacing, vec4 tangent, vec2 uv,\nvec3 viewNorm,\nout float facingRatio, out bool flippedNormal, out mat4 matrixEyeToWorld,\nout vec3 normalCamera, out vec2 pixelCenter, out vec3 pointCamera,\nout vec3 pointObj, out vec3 pointWorld,\nout vec3 tangentUCamera, out vec3 tangentVCamera, out vec2 uvCoord)\n{\nvec4 worldPos = invViewMatrix * vec4(-vViewPosition, 1.0);\nfacingRatio = dot(normalize(viewNorm), normalize(vViewPosition));\nflippedNormal = frontFacing;\nmatrixEyeToWorld = invViewMatrix;\nnormalCamera = viewNorm;\npixelCenter = vec2(1.0);\npointCamera = -vViewPosition;\npointObj = (invModelMatrix * worldPos).xyz;\npointWorld = worldPos.xyz;\ntangentUCamera = normalize((modelViewMatrix * vec4(tangent.xyz, 0.0)).xyz);\ntangentVCamera = tangent.w * cross(viewNorm, tangentUCamera);\nuvCoord = vec2(uv.x, 1.0-uv.y);\n}",node_set_range_my_frag:"void node_set_range(\nvec3 maxValue, vec3 minValue, vec3 oldMax, vec3 oldMin, vec3 value,\nout vec3 outValue) {\noutValue = minValue + (((value - oldMin) / (oldMax - oldMin)) * (maxValue - minValue));\n}",node_shading_engine_my_frag:"void node_shading_engine(vec4 surface, vec4 volume, vec3 displacement, out vec4 outgoingLight) {\noutgoingLight = surface + volume;\n}",node_surface_shader_my_frag:"void node_surface_shader(\nvec3 color, vec3 glowColor, vec3 matteOpacity, vec3 transparency,\nout vec3 outColor, out vec3 outGlowColor, out vec3 outMatteOpacity, out vec3 outTransparency)\n{\noutColor = color;\noutGlowColor = glowColor;\noutMatteOpacity = matteOpacity;\noutTransparency = transparency;\n}",node_transform_my_frag:"void node_transform(\nout vec3 center, out mat4 inverseMatrix, out mat4 matrix,\nout mat4 parentInverseMatrix, out mat4 parentMatrix, out mat4 worldInverseMatrix,\nout mat4 worldMatrix, out mat4 xformMatrix)\n{\ncenter = modelMatrix[3].xyz;\ninverseMatrix = invModelMatrix;\nmatrix = modelMatrix;\nparentInverseMatrix = mat4(1.0);\nparentMatrix = mat4(1.0);\nworldInverseMatrix = invModelMatrix;\nworldMatrix = modelMatrix;\nxformMatrix = matrix;\n}",node_transpose_matrix_my_frag:"mat4 transposeMat4(mat4 m) {\nreturn mat4(vec4(m[0].x, m[1].x, m[2].x, m[3].x),\nvec4(m[0].y, m[1].y, m[2].y, m[3].y),\nvec4(m[0].z, m[1].z, m[2].z, m[3].z),\nvec4(m[0].w, m[1].w, m[2].w, m[3].w));\n}\nvoid node_transpose_matrix(\nmat4 inputMatrix,\nout mat4 outputMatrix)\n{\noutputMatrix = transposeMat4(inputMatrix);\n}",node_unit_conversion_my_frag:"void node_unit_conversion(float conversionFactor, float inInput, out float outOutput)\n{\noutOutput = conversionFactor * inInput;\n}\nvoid node_unit_conversion(float conversionFactor, vec3 inInput, out vec3 outOutput)\n{\noutOutput = conversionFactor * inInput;\n}",node_unpremultiply_my_frag:"void node_unpremultiply(\nfloat inAlpha, vec3 inColor,\nout float outAlpha, out vec3 outColor) {\noutColor = inColor / inAlpha;\noutAlpha = inAlpha;\n}",node_vector_product_my_frag:"void node_vector_product(\nconst int operation, const bool normalizeOutput,\nvec3 input1, vec3 input2, mat4 matrix,\nout vec3 outVector) {\nif (operation == 0) {\noutVector = input1;\n} else if (operation == 1) {\nif (normalizeOutput) {\ninput1 = normalize(input1);\ninput2 = normalize(input2);\n}\noutVector = vec3(dot(input1, input2));\n} else if (operation == 2) {\noutVector = cross(input1, input2);\n} else if (operation == 3) {\noutVector = (matrix * vec4(input1, 0.0)).xyz;\n} else {\noutVector = (matrix * vec4(input1, 1.0)).xyz;\n}\n\nif (operation > 1 && normalizeOutput)\noutVector = normalize(outVector);\n}",node_wt_add_matrix_my_frag:"void node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1;\n}\nvoid node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1, mat4 matrixIn2, float weightIn2,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1 + weightIn2 * matrixIn2;\n}\nvoid node_wt_add_matrix(\nmat4 matrixIn1, float weightIn1, mat4 matrixIn2, float weightIn2, mat4 matrixIn3, float weightIn3,\nout mat4 matrixSum)\n{\nmatrixSum = weightIn1 * matrixIn1 + weightIn2 * matrixIn2 + weightIn3 * matrixIn3;\n}",pp_plane_vert:"varying vec2 vUv;\nvoid main() {\nvUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",pp_afterimage_frag:"uniform float damp;\nuniform sampler2D tOld;\nuniform sampler2D tNew;\nvarying vec2 vUv;\nvec4 when_gt(vec4 x, float y) {\nreturn max(sign(x - y), 0.0);\n}\nvoid main() {\nvec4 texelOld = texture2D(tOld, vUv);\nvec4 texelNew = texture2D(tNew, vUv);\n\ntexelOld *= damp * when_gt(texelOld, 0.1);\ngl_FragColor = max(texelNew, texelOld);\n}",pp_bloom_composite_frag:"varying vec2 vUv;\nuniform sampler2D blurTexture1;\nuniform sampler2D blurTexture2;\nuniform sampler2D blurTexture3;\nuniform sampler2D blurTexture4;\nuniform sampler2D blurTexture5;\nuniform sampler2D dirtTexture;\nuniform float bloomStrength;\nuniform float bloomRadius;\nuniform float bloomFactors[NUM_MIPS];\nuniform vec3 bloomTintColors[NUM_MIPS];\nfloat lerpBloomFactor(const in float factor) {\nfloat mirrorFactor = 1.2 - factor;\nreturn mix(factor, mirrorFactor, bloomRadius);\n}\nvoid main() {\ngl_FragColor = bloomStrength * (\nlerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +\nlerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +\nlerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +\nlerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +\nlerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv)\n);\n}",pp_bloom_lum_high_pass_frag:"uniform sampler2D tDiffuse;\nuniform vec3 defaultColor;\nuniform float defaultOpacity;\nuniform float luminosityThreshold;\nuniform float smoothWidth;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nvec3 luma = vec3(0.299, 0.587, 0.114);\nfloat v = dot(texel.xyz, luma);\nvec4 outputColor = vec4(defaultColor.rgb, defaultOpacity);\nfloat alpha = smoothstep(luminosityThreshold, luminosityThreshold + smoothWidth, v);\ngl_FragColor = mix(outputColor, texel, alpha);\ngl_FragColor = clamp(gl_FragColor, 0.0, 10.0);\n}",pp_bloom_separable_blur_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma)) / sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat fSigma = float(SIGMA);\nfloat weightSum = gaussianPdf(0.0, fSigma);\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\nfor (int i = 1; i < KERNEL_RADIUS; i++) {\nfloat x = float(i);\nfloat w = gaussianPdf(x, fSigma);\nvec2 uvOffset = direction * invSize * x;\nvec3 sample1 = texture2D(colorTexture, vUv + uvOffset).rgb;\nvec3 sample2 = texture2D(colorTexture, vUv - uvOffset).rgb;\ndiffuseSum += (sample1 + sample2) * w;\nweightSum += 2.0 * w;\n}\ngl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n}",pp_blur_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nuniform float kernelRadius;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\n#if LOG_SPACE == 1\nvec3 origDiffuse = texture2D(colorTexture, vUv).rgb;\nvec3 diffuseSum = vec3(weightSum);\n#else\nvec3 diffuseSum = texture2D(colorTexture, vUv).rgb * weightSum;\n#endif\nvec2 delta = direction * invSize * kernelRadius/float(MAX_SAMPLE_RADIUS);\nvec2 uvOffset = delta;\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeDir = normalize(octUVToCubeVec(vUv, invSize));\nvec3 dirX = normalize(abs(cubeDir.y) < 0.99999 ? vec3(cubeDir.z, 0.0, -cubeDir.x)\n: vec3(0.0, -cubeDir.z, cubeDir.y));\nvec3 dirY = cross(cubeDir, dirX);\n#endif\n#pragma unroll_loop_start\nfor (int i = 1; i <= MAX_SAMPLE_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\n#if OCTAHEDRAL_MAP == 1\nvec3 cubeOffset = uvOffset.x * dirX + uvOffset.y * dirY;\nvec2 uv1 = cubeVecToOctUV(cubeDir + cubeOffset, invSize);\nvec2 uv2 = cubeVecToOctUV(cubeDir - cubeOffset, invSize);\n#else\nvec2 uv1 = vUv + uvOffset;\nvec2 uv2 = vUv - uvOffset;\n#endif\nvec3 sample1 = texture2D(colorTexture, uv1).rgb;\nvec3 sample2 = texture2D(colorTexture, uv2).rgb;\n#if LOG_SPACE == 1\ndiffuseSum += (\nclamp(exp(sample1 - origDiffuse), 0.0, 1e38) +\nclamp(exp(sample2 - origDiffuse), 0.0, 1e38)\n) * w;\n#else\ndiffuseSum += ((sample1 + sample2) * w);\n#endif\nweightSum += 2.0 * w;\nuvOffset += delta;\n}\n#pragma unroll_loop_end\n#if LOG_SPACE == 1\ngl_FragColor = vec4(origDiffuse + log(diffuseSum/weightSum), 1.0);\n#else\ngl_FragColor = vec4(diffuseSum/weightSum, 1.0);\n#endif\n}",pp_brightness_contrast_frag:"\nuniform sampler2D tDiffuse;\nuniform float brightness;\nuniform float contrast;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\ntexel.rgb += brightness;\nif (contrast > 0.0)\ntexel.rgb = (texel.rgb - 0.5) / (1.0 - contrast) + 0.5;\nelse\ntexel.rgb = (texel.rgb - 0.5) * (1.0 + contrast) + 0.5;\ngl_FragColor = texel;\n}",pp_bokeh_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D tColor;\nuniform sampler2D tDepth;\nuniform float maxblur;\nuniform float aperture;\nuniform float nearClip;\nuniform float farClip;\nuniform float focus;\nuniform float aspect;\nuniform float depthLeakThreshold;\n#include \nfloat getDepth(const in vec2 screenPosition) {\n#if DEPTH_PACKING == 1\nreturn unpackRGBAToDepth(texture2D(tDepth, screenPosition));\n#else\nreturn texture2D(tDepth, screenPosition).x;\n#endif\n}\nfloat getViewZ(const in float depth) {\n#if PERSPECTIVE_CAMERA == 1\nreturn perspectiveDepthToViewZ(depth, nearClip, farClip);\n#else\nreturn orthoDepthToViewZ(depth, nearClip, farClip);\n#endif\n}\nvec4 blurSample(vec2 uvOffset, vec4 centerCol, float viewZCenter) {\nfloat viewZ = -getViewZ(getDepth(vUv + uvOffset));\nfloat blurFactor = (viewZ >= viewZCenter) ? 1.0 : \nmin(depthLeakThreshold * abs((focus - viewZ) / aperture), 1.0);\nreturn mix(centerCol, texture2D(tColor, vUv + uvOffset), blurFactor);\n}\nvoid main() {\nvec2 aspectcorrect = vec2(1.0, aspect);\nfloat viewZ = -getViewZ(getDepth(vUv));\nfloat factor = abs(focus - viewZ);\n\nfloat dofblur = maxblur * min(factor / aperture, 1.0);\nfloat dofblur9 = dofblur * 0.9;\nfloat dofblur7 = dofblur * 0.7;\nfloat dofblur4 = dofblur * 0.4;\nvec4 centerCol = texture2D(tColor, vUv);\nvec4 col = centerCol;\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.15, 0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.37, 0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2(-0.37, -0.15) * aspectcorrect) * dofblur9, centerCol, viewZ);\ncol += blurSample((vec2( 0.15, -0.37) * aspectcorrect) * dofblur9, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.40, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur7, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur7, centerCol, viewZ);\n\ncol += blurSample((vec2( 0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, -0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, 0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.4, 0.0 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2(-0.29, -0.29) * aspectcorrect) * dofblur4, centerCol, viewZ);\ncol += blurSample((vec2( 0.0, 0.4 ) * aspectcorrect) * dofblur4, centerCol, viewZ);\ngl_FragColor = col / 41.0;\ngl_FragColor.a = centerCol.a;\n}",pp_copy_frag:"uniform sampler2D tDiffuse;\nuniform float opacity;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = (texture2D(tDiffuse, vUv));\ngl_FragColor = opacity * texel;\n}",pp_cube_octahedral_proj_frag:"#include \nuniform samplerCube tCube;\nuniform vec2 texelSize;\nvarying vec2 vUv;\nvoid main() {\ngl_FragColor = textureCube(tCube, octUVToCubeVec(gl_FragCoord.xy * texelSize,\ntexelSize));\n}",pp_fxaa_frag:"precision highp float;\nuniform sampler2D tDiffuse;\nuniform vec2 resolution;\nvarying vec2 vUv;\n#ifndef FXAA_GLSL_120\n#define FXAA_GLSL_120 0\n#endif\n#ifndef FXAA_GLSL_130\n#define FXAA_GLSL_130 0\n#endif\n#ifndef FXAA_GREEN_AS_LUMA\n#define FXAA_GREEN_AS_LUMA 0\n#endif\n#ifndef FXAA_EARLY_EXIT\n#define FXAA_EARLY_EXIT 1\n#endif\n#ifndef FXAA_DISCARD\n#define FXAA_DISCARD 1\n#endif\n#ifndef FXAA_FAST_PIXEL_OFFSET\n#ifdef GL_EXT_gpu_shader4\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifdef GL_NV_gpu_shader5\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifdef GL_ARB_gpu_shader5\n#define FXAA_FAST_PIXEL_OFFSET 1\n#endif\n#ifndef FXAA_FAST_PIXEL_OFFSET\n#define FXAA_FAST_PIXEL_OFFSET 0\n#endif\n#endif\n#ifndef FXAA_QUALITY_PRESET\n#define FXAA_QUALITY_PRESET 12\n#endif\n#if (FXAA_QUALITY_PRESET == 10)\n#define FXAA_QUALITY_PS 3\n#define FXAA_QUALITY_P0 1.5\n#define FXAA_QUALITY_P1 3.0\n#define FXAA_QUALITY_P2 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 11)\n#define FXAA_QUALITY_PS 4\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 3.0\n#define FXAA_QUALITY_P3 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 12)\n#define FXAA_QUALITY_PS 5\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 4.0\n#define FXAA_QUALITY_P4 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 13)\n#define FXAA_QUALITY_PS 6\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 4.0\n#define FXAA_QUALITY_P5 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 14)\n#define FXAA_QUALITY_PS 7\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 4.0\n#define FXAA_QUALITY_P6 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 15)\n#define FXAA_QUALITY_PS 8\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 4.0\n#define FXAA_QUALITY_P7 12.0\n#endif\n#if (FXAA_QUALITY_PRESET == 20)\n#define FXAA_QUALITY_PS 3\n#define FXAA_QUALITY_P0 1.5\n#define FXAA_QUALITY_P1 2.0\n#define FXAA_QUALITY_P2 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 21)\n#define FXAA_QUALITY_PS 4\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 22)\n#define FXAA_QUALITY_PS 5\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 23)\n#define FXAA_QUALITY_PS 6\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 24)\n#define FXAA_QUALITY_PS 7\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 3.0\n#define FXAA_QUALITY_P6 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 25)\n#define FXAA_QUALITY_PS 8\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 4.0\n#define FXAA_QUALITY_P7 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 26)\n#define FXAA_QUALITY_PS 9\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 4.0\n#define FXAA_QUALITY_P8 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 27)\n#define FXAA_QUALITY_PS 10\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 4.0\n#define FXAA_QUALITY_P9 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 28)\n#define FXAA_QUALITY_PS 11\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 4.0\n#define FXAA_QUALITY_P10 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 29)\n#define FXAA_QUALITY_PS 12\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.5\n#define FXAA_QUALITY_P2 2.0\n#define FXAA_QUALITY_P3 2.0\n#define FXAA_QUALITY_P4 2.0\n#define FXAA_QUALITY_P5 2.0\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 2.0\n#define FXAA_QUALITY_P10 4.0\n#define FXAA_QUALITY_P11 8.0\n#endif\n#if (FXAA_QUALITY_PRESET == 39)\n#define FXAA_QUALITY_PS 12\n#define FXAA_QUALITY_P0 1.0\n#define FXAA_QUALITY_P1 1.0\n#define FXAA_QUALITY_P2 1.0\n#define FXAA_QUALITY_P3 1.0\n#define FXAA_QUALITY_P4 1.0\n#define FXAA_QUALITY_P5 1.5\n#define FXAA_QUALITY_P6 2.0\n#define FXAA_QUALITY_P7 2.0\n#define FXAA_QUALITY_P8 2.0\n#define FXAA_QUALITY_P9 2.0\n#define FXAA_QUALITY_P10 4.0\n#define FXAA_QUALITY_P11 8.0\n#endif\n#if 1\n#define FxaaBool bool\n#define FxaaDiscard discard\n#define FxaaFloat float\n#define FxaaFloat2 vec2\n#define FxaaFloat3 vec3\n#define FxaaFloat4 vec4\n#define FxaaHalf float\n#define FxaaHalf2 vec2\n#define FxaaHalf3 vec3\n#define FxaaHalf4 vec4\n#define FxaaInt2 ivec2\n#define FxaaSat(x) clamp(x, 0.0, 1.0)\n#define FxaaTex sampler2D\n#endif\n#if (FXAA_GLSL_100 == 1)\n#define FxaaTexTop(t, p) texture2D(t, p, 0.0)\n#define FxaaTexOff(t, p, o, r) texture2D(t, p + (o * r), 0.0)\n#endif\n#if (FXAA_GLSL_120 == 1)\n#define FxaaTexTop(t, p) texture2DLod(t, p, 0.0)\n#if (FXAA_FAST_PIXEL_OFFSET == 1)\n#define FxaaTexOff(t, p, o, r) texture2DLodOffset(t, p, 0.0, o)\n#else\n#define FxaaTexOff(t, p, o, r) texture2DLod(t, p + (o * r), 0.0)\n#endif\n#endif\n#if (FXAA_GLSL_130 == 1)\n#define FxaaTexTop(t, p) textureLod(t, p, 0.0)\n#define FxaaTexOff(t, p, o, r) textureLodOffset(t, p, 0.0, o)\n#endif\n#if (FXAA_GREEN_AS_LUMA == 0)\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.w; }\n#else\nFxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }\n#endif\nFxaaFloat4 FxaaPixelShader(\nFxaaFloat2 pos,\nFxaaFloat4 fxaaConsolePosPos,\nFxaaTex tex,\nFxaaTex fxaaConsole360TexExpBiasNegOne,\nFxaaTex fxaaConsole360TexExpBiasNegTwo,\nFxaaFloat2 fxaaQualityRcpFrame,\nFxaaFloat4 fxaaConsoleRcpFrameOpt,\nFxaaFloat4 fxaaConsoleRcpFrameOpt2,\nFxaaFloat4 fxaaConsole360RcpFrameOpt2,\nFxaaFloat fxaaQualitySubpix,\nFxaaFloat fxaaQualityEdgeThreshold,\nFxaaFloat fxaaQualityEdgeThresholdMin\n) {\nFxaaFloat2 posM;\nposM.x = pos.x;\nposM.y = pos.y;\n#if 1\nFxaaFloat4 rgbyM = FxaaTexTop(tex, posM);\n#if (FXAA_GREEN_AS_LUMA == 0)\n#define lumaM rgbyM.w\n#else\n#define lumaM rgbyM.y\n#endif\n#if (FXAA_GLSL_100 == 1)\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 0.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(0.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 0.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaS = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaN = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(0,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 0), fxaaQualityRcpFrame.xy));\n#endif\n#endif\nFxaaFloat maxSM = max(lumaS, lumaM);\nFxaaFloat minSM = min(lumaS, lumaM);\nFxaaFloat maxESM = max(lumaE, maxSM);\nFxaaFloat minESM = min(lumaE, minSM);\nFxaaFloat maxWN = max(lumaN, lumaW);\nFxaaFloat minWN = min(lumaN, lumaW);\nFxaaFloat rangeMax = max(maxWN, maxESM);\nFxaaFloat rangeMin = min(minWN, minESM);\nFxaaFloat rangeMaxScaled = rangeMax * fxaaQualityEdgeThreshold;\nFxaaFloat range = rangeMax - rangeMin;\nFxaaFloat rangeMaxClamped = max(fxaaQualityEdgeThresholdMin, rangeMaxScaled);\nFxaaBool earlyExit = range < rangeMaxClamped;\nif(earlyExit)\n#if (FXAA_DISCARD == 1)\nreturn rgbyM;\n#else\nreturn rgbyM;\n#endif\n#if 1\n#if (FXAA_GLSL_100 == 1)\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0, 1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(1.0,-1.0), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaFloat2(-1.0, 1.0), fxaaQualityRcpFrame.xy));\n#else\nFxaaFloat lumaNW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, 1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1,-1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\n#else\nFxaaFloat lumaNE = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(1, -1), fxaaQualityRcpFrame.xy));\nFxaaFloat lumaSW = FxaaLuma(FxaaTexOff(tex, posM, FxaaInt2(-1, 1), fxaaQualityRcpFrame.xy));\n#endif\nFxaaFloat lumaNS = lumaN + lumaS;\nFxaaFloat lumaWE = lumaW + lumaE;\nFxaaFloat subpixRcpRange = 1.0/range;\nFxaaFloat subpixNSWE = lumaNS + lumaWE;\nFxaaFloat edgeHorz1 = (-2.0 * lumaM) + lumaNS;\nFxaaFloat edgeVert1 = (-2.0 * lumaM) + lumaWE;\nFxaaFloat lumaNESE = lumaNE + lumaSE;\nFxaaFloat lumaNWNE = lumaNW + lumaNE;\nFxaaFloat edgeHorz2 = (-2.0 * lumaE) + lumaNESE;\nFxaaFloat edgeVert2 = (-2.0 * lumaN) + lumaNWNE;\nFxaaFloat lumaNWSW = lumaNW + lumaSW;\nFxaaFloat lumaSWSE = lumaSW + lumaSE;\nFxaaFloat edgeHorz4 = (abs(edgeHorz1) * 2.0) + abs(edgeHorz2);\nFxaaFloat edgeVert4 = (abs(edgeVert1) * 2.0) + abs(edgeVert2);\nFxaaFloat edgeHorz3 = (-2.0 * lumaW) + lumaNWSW;\nFxaaFloat edgeVert3 = (-2.0 * lumaS) + lumaSWSE;\nFxaaFloat edgeHorz = abs(edgeHorz3) + edgeHorz4;\nFxaaFloat edgeVert = abs(edgeVert3) + edgeVert4;\nFxaaFloat subpixNWSWNESE = lumaNWSW + lumaNESE;\nFxaaFloat lengthSign = fxaaQualityRcpFrame.x;\nFxaaBool horzSpan = edgeHorz >= edgeVert;\nFxaaFloat subpixA = subpixNSWE * 2.0 + subpixNWSWNESE;\nif(!horzSpan) lumaN = lumaW;\nif(!horzSpan) lumaS = lumaE;\nif(horzSpan) lengthSign = fxaaQualityRcpFrame.y;\nFxaaFloat subpixB = (subpixA * (1.0/12.0)) - lumaM;\nFxaaFloat gradientN = lumaN - lumaM;\nFxaaFloat gradientS = lumaS - lumaM;\nFxaaFloat lumaNN = lumaN + lumaM;\nFxaaFloat lumaSS = lumaS + lumaM;\nFxaaBool pairN = abs(gradientN) >= abs(gradientS);\nFxaaFloat gradient = max(abs(gradientN), abs(gradientS));\nif(pairN) lengthSign = -lengthSign;\nFxaaFloat subpixC = FxaaSat(abs(subpixB) * subpixRcpRange);\nFxaaFloat2 posB;\nposB.x = posM.x;\nposB.y = posM.y;\nFxaaFloat2 offNP;\noffNP.x = (!horzSpan) ? 0.0 : fxaaQualityRcpFrame.x;\noffNP.y = (horzSpan) ? 0.0 : fxaaQualityRcpFrame.y;\nif(!horzSpan) posB.x += lengthSign * 0.5;\nif(horzSpan) posB.y += lengthSign * 0.5;\nFxaaFloat2 posN;\nposN.x = posB.x - offNP.x * FXAA_QUALITY_P0;\nposN.y = posB.y - offNP.y * FXAA_QUALITY_P0;\nFxaaFloat2 posP;\nposP.x = posB.x + offNP.x * FXAA_QUALITY_P0;\nposP.y = posB.y + offNP.y * FXAA_QUALITY_P0;\nFxaaFloat subpixD = ((-2.0)*subpixC) + 3.0;\nFxaaFloat lumaEndN = FxaaLuma(FxaaTexTop(tex, posN));\nFxaaFloat subpixE = subpixC * subpixC;\nFxaaFloat lumaEndP = FxaaLuma(FxaaTexTop(tex, posP));\nif(!pairN) lumaNN = lumaSS;\nFxaaFloat gradientScaled = gradient * 1.0/4.0;\nFxaaFloat lumaMM = lumaM - lumaNN * 0.5;\nFxaaFloat subpixF = subpixD * subpixE;\nFxaaBool lumaMLTZero = lumaMM < 0.0;\nlumaEndN -= lumaNN * 0.5;\nlumaEndP -= lumaNN * 0.5;\nFxaaBool doneN = abs(lumaEndN) >= gradientScaled;\nFxaaBool doneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P1;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P1;\nFxaaBool doneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P1;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P1;\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P2;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P2;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P2;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P2;\n#if (FXAA_QUALITY_PS > 3)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P3;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P3;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P3;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P3;\n#if (FXAA_QUALITY_PS > 4)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P4;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P4;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P4;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P4;\n#if (FXAA_QUALITY_PS > 5)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P5;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P5;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P5;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P5;\n#if (FXAA_QUALITY_PS > 6)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P6;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P6;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P6;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P6;\n#if (FXAA_QUALITY_PS > 7)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P7;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P7;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P7;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P7;\n#if (FXAA_QUALITY_PS > 8)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P8;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P8;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P8;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P8;\n#if (FXAA_QUALITY_PS > 9)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P9;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P9;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P9;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P9;\n#if (FXAA_QUALITY_PS > 10)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P10;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P10;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P10;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P10;\n#if (FXAA_QUALITY_PS > 11)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P11;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P11;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P11;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P11;\n#if (FXAA_QUALITY_PS > 12)\nif(doneNP) {\nif(!doneN) lumaEndN = FxaaLuma(FxaaTexTop(tex, posN.xy));\nif(!doneP) lumaEndP = FxaaLuma(FxaaTexTop(tex, posP.xy));\nif(!doneN) lumaEndN = lumaEndN - lumaNN * 0.5;\nif(!doneP) lumaEndP = lumaEndP - lumaNN * 0.5;\ndoneN = abs(lumaEndN) >= gradientScaled;\ndoneP = abs(lumaEndP) >= gradientScaled;\nif(!doneN) posN.x -= offNP.x * FXAA_QUALITY_P12;\nif(!doneN) posN.y -= offNP.y * FXAA_QUALITY_P12;\ndoneNP = (!doneN) || (!doneP);\nif(!doneP) posP.x += offNP.x * FXAA_QUALITY_P12;\nif(!doneP) posP.y += offNP.y * FXAA_QUALITY_P12;\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\n#endif\n}\nFxaaFloat dstN = posM.x - posN.x;\nFxaaFloat dstP = posP.x - posM.x;\nif(!horzSpan) dstN = posM.y - posN.y;\nif(!horzSpan) dstP = posP.y - posM.y;\nFxaaBool goodSpanN = (lumaEndN < 0.0) != lumaMLTZero;\nFxaaFloat spanLength = (dstP + dstN);\nFxaaBool goodSpanP = (lumaEndP < 0.0) != lumaMLTZero;\nFxaaFloat spanLengthRcp = 1.0/spanLength;\nFxaaBool directionN = dstN < dstP;\nFxaaFloat dst = min(dstN, dstP);\nFxaaBool goodSpan = directionN ? goodSpanN : goodSpanP;\nFxaaFloat subpixG = subpixF * subpixF;\nFxaaFloat pixelOffset = (dst * (-spanLengthRcp)) + 0.5;\nFxaaFloat subpixH = subpixG * fxaaQualitySubpix;\nFxaaFloat pixelOffsetGood = goodSpan ? pixelOffset : 0.0;\nFxaaFloat pixelOffsetSubpix = max(pixelOffsetGood, subpixH);\nif(!horzSpan) posM.x += pixelOffsetSubpix * lengthSign;\nif(horzSpan) posM.y += pixelOffsetSubpix * lengthSign;\n#if (FXAA_DISCARD == 1)\nreturn FxaaTexTop(tex, posM);\n#else\nreturn FxaaFloat4(FxaaTexTop(tex, posM).xyz, lumaM);\n#endif\n}\nvoid main() {\ngl_FragColor = FxaaPixelShader(\nvUv,\nvec4(0.0),\ntDiffuse,\ntDiffuse,\ntDiffuse,\nresolution,\nvec4(0.0),\nvec4(0.0),\nvec4(0.0),\n0.75,\n0.166,\n0.0833\n);\n}",pp_grayscale_frag:"uniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat bw = texel.r * 0.35 + texel.g * 0.45 + texel.b * 0.2;\ntexel = vec4(bw, bw, bw, texel.a);\ngl_FragColor = texel;\n}",pp_gtao_blur_frag:"uniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform vec2 direction;\nuniform vec2 resolution;\nvarying vec2 vUv;\n#include \nconst float SIGMA_SPATIAL = 1.5;\nconst float SIGMA_INTENSITY = 0.01;\nfloat gaussianPdf(float x, float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nfloat weightSum = gaussianPdf(0.0, SIGMA_SPATIAL)\n* gaussianPdf(0.0, SIGMA_INTENSITY);\nvec4 diffSample = texture2D(tDiffuse, vUv);\nvec4 gtaoDataSum = vec4(diffSample.r, unpackRGBToNormal(diffSample.gba)) * weightSum;\nvec3 normCenter = unpackRGBToNormal(texture2D(tNormal, vUv).xyz);\nvec2 delta = direction / resolution;\nvec2 offset = delta;\n#pragma unroll_loop_start\nfor (int i = 1; i <= BLUR_RADIUS_PX; i++) {\nvec2 uvCoords0 = vUv + offset;\nvec2 uvCoords1 = vUv - offset;\nvec4 diffSample0 = texture2D(tDiffuse, uvCoords0);\nvec4 diffSample1 = texture2D(tDiffuse, uvCoords1);\nvec4 gtaoData0 = vec4(diffSample0.r, unpackRGBToNormal(diffSample0.gba));\nvec4 gtaoData1 = vec4(diffSample1.r, unpackRGBToNormal(diffSample1.gba));\nvec3 normSample0 = unpackRGBToNormal(texture2D(tNormal, uvCoords0).xyz);\nvec3 normSample1 = unpackRGBToNormal(texture2D(tNormal, uvCoords1).xyz);\nfloat weightSpatial = gaussianPdf(float(i), SIGMA_SPATIAL);\nfloat weight0 = weightSpatial * gaussianPdf(1.0 - max(0.0,\ndot(normCenter, normSample0)), SIGMA_INTENSITY);\nfloat weight1 = weightSpatial * gaussianPdf(1.0 - max(0.0,\ndot(normCenter, normSample1)), SIGMA_INTENSITY);\nweightSum += weight0 + weight1;\ngtaoDataSum += weight0 * gtaoData0 + weight1 * gtaoData1;\noffset += delta;\n}\n#pragma unroll_loop_end\nfloat visibility = gtaoDataSum.r / weightSum;\nvec3 bentNormal = normalize(gtaoDataSum.gba);\ngl_FragColor = vec4(visibility, packNormalToRGB(bentNormal));\n}",pp_gtao_frag:"uniform sampler2D tNormal;\nuniform sampler2D tDepth;\nuniform sampler2D tNoise;\nuniform float occlDistance;\nuniform float factor;\nuniform float occlPrecision;\nuniform bool bounceApprox;\nuniform mat4 mainCameraProjMat;\nuniform vec2 resolution;\nvarying vec2 vUv;\n#include \n#include \nconst vec3 AXIS_Z = vec3(0.0, 0.0, 1.0);\nconst float NUM_SAMPLES_HALF_MIN = 4.0;\nconst float NUM_SAMPLES_HALF_MAX = 8.0;\nconst float NOISE_TEX_SIZE = 32.0;\nconst float NEAR_FIELD_COEFF = 0.5;\nconst float SELF_OCCL_BIAS = -1e-5;\nconst float NORMAL_RENDER_GEOM_MAX_DIFF_ANGLE = 0.85 * PI_HALF;\nfloat integrateArc(vec2 horizonAngles, float normalAngle) {\nvec2 visCoeffs = (-cos(2.0 * horizonAngles - normalAngle) + cos(normalAngle)\n+ 2.0 * horizonAngles * sin(normalAngle)) / 4.0;\nreturn visCoeffs.x + visCoeffs.y;\n}\nvec3 calcViewFromUVDepth(vec2 uv, float depth, float zBias) {\nvec3 ndcCo = 2.0 * vec3(uv, depth) - 1.0;\n#if ORTHO_CAMERA == 1\nfloat viewZ = (ndcCo.z - mainCameraProjMat[3][2]) / mainCameraProjMat[2][2] + zBias;\nvec2 _00_11 = vec2(mainCameraProjMat[0][0], mainCameraProjMat[1][1]);\nvec2 _30_31 = vec2(mainCameraProjMat[3][0], mainCameraProjMat[3][1]);\nreturn vec3((ndcCo.xy - _30_31) / _00_11, viewZ);\n#else\nfloat viewZ = -mainCameraProjMat[3][2] / (mainCameraProjMat[2][2] + ndcCo.z) + zBias;\nvec2 _00_11 = vec2(mainCameraProjMat[0][0], mainCameraProjMat[1][1]);\nvec2 _20_21 = vec2(mainCameraProjMat[2][0], mainCameraProjMat[2][1]);\nreturn vec3(-viewZ * (ndcCo.xy + _20_21) / _00_11, viewZ);\n#endif\n}\nvec2 calcSliceRadiusUV(float viewZ) {\nvec4 distView = vec4(occlDistance, occlDistance, viewZ, 1.0);\nvec4 distClip = mainCameraProjMat * distView;\nvec2 xyNDC = distClip.xy / distClip.w;\nreturn clamp(0.5 * xyNDC, 0.0, 0.5);\n}\nvec2 calcHorizonAngles(vec3 viewPos, vec3 viewVec, vec2 sliceDir,\nfloat offsetNoise) {\nvec2 maxHorizonCos = vec2(-1.0);\nvec2 sliceRadius = calcSliceRadiusUV(viewPos.z);\nvec2 pxSize = 1.0 / resolution;\nint NUM_SAMPLES_HALF = int(occlPrecision\n* (NUM_SAMPLES_HALF_MAX - NUM_SAMPLES_HALF_MIN) + NUM_SAMPLES_HALF_MIN);\n#if __VERSION__ == 300\nfor (int i = 0; i < NUM_SAMPLES_HALF; i++) {\n#else\nfor (int i = 0; i < int(NUM_SAMPLES_HALF_MAX); i++) {\nif (i >= NUM_SAMPLES_HALF) continue;\n#endif\nvec2 offset = sliceDir * (pxSize * (1.0 + float(i))\n+ sliceRadius * pow((float(i) + offsetNoise) / float(NUM_SAMPLES_HALF), 2.0));\nvec2 uvs = vUv - offset;\nvec3 ps = calcViewFromUVDepth(uvs, texture2D(tDepth, uvs).x, SELF_OCCL_BIAS);\nvec3 ds = normalize(ps - viewPos);\nvec2 uvt = vUv + offset;\nvec3 pt = calcViewFromUVDepth(uvt, texture2D(tDepth, uvt).x, SELF_OCCL_BIAS);\nvec3 dt = normalize(pt - viewPos);\nvec2 sampleLen = vec2(length(ps - viewPos), length(pt - viewPos));\nvec2 blendWeight = (sampleLen / occlDistance - 1.0) / (NEAR_FIELD_COEFF - 1.0);\nblendWeight = clamp(blendWeight, 0.0, 1.0);\nvec2 maxHorizonCosNoBlending = max(maxHorizonCos, vec2(dot(ds, viewVec),\ndot(dt, viewVec)));\nmaxHorizonCos = mix(maxHorizonCos, maxHorizonCosNoBlending, blendWeight);\n}\nvec2 horizons = acos(maxHorizonCos);\nreturn vec2(-horizons.x, horizons.y);\n}\nvec2 calcNormalAngleAndProjLen(vec3 viewVec, vec3 normal, vec2 sliceDir) {\nvec3 sliceVec = vec3(sliceDir, 0.0);\nsliceVec = sliceVec - dot(sliceVec, viewVec) * viewVec;\nvec3 sliceOrthoVec = cross(sliceVec, viewVec);\nvec3 normalProj = normal - dot(normal, sliceOrthoVec) * sliceOrthoVec;\nfloat normalProjLen = length(normalProj);\nfloat normalAngle = acos(clamp(dot(normalProj / normalProjLen, viewVec), 0.0, 1.0));\nnormalAngle *= sign(dot(normalProj, sliceVec));\nreturn vec2(normalAngle, normalProjLen);\n}\n#if CALC_BENT_NORMALS == 1\nvec3 calcSliceBentNormal(vec2 sliceDir, vec2 h, float n) {\nvec2 t = vec2(\n6.0 * sin(h[0] - n) - sin(3.0 * h[0] - n) + 6.0 * sin(h[1] - n)\n- sin(3.0 * h[1] - n) + 16.0 * sin(n) - 3.0 * (sin(h[0] + n) + sin(h[1] + n)),\n-cos(3.0 * h[0] - n) - cos(3.0 * h[1] - n) + 8.0 * cos(n)\n- 3.0 * (cos(h[0] + n) + cos(h[1] + n))\n) / 12.0;\nreturn vec3(sliceDir * t[0], t[1]);\n}\n#endif\nvec2 clampHorizonAnglesAroundNormal(vec2 horizonAngles, float normalAngle,\nfloat geomNormalAngle) {\nhorizonAngles = normalAngle + clamp(horizonAngles - normalAngle, -PI_HALF, PI_HALF);\nif (abs(normalAngle - geomNormalAngle) < NORMAL_RENDER_GEOM_MAX_DIFF_ANGLE) {\nhorizonAngles = geomNormalAngle + clamp(horizonAngles - geomNormalAngle, -PI_HALF, PI_HALF);\n}\nreturn horizonAngles;\n}\nvoid main() {\nfloat depth = texture2D(tDepth, vUv).x;\n#ifndef GTAO_DISABLE_BKG_FIX\nif (depth == 1.0) {\ngl_FragColor = vec4(vec3(1.0), 1.0);\n} else {\n#endif\nvec3 viewPos = calcViewFromUVDepth(vUv, depth, 0.0);\n#if ORTHO_CAMERA == 1\nvec3 viewVec = vec3(0.0, 0.0, 1.0);\n#else\nvec3 viewVec = normalize(-viewPos);\n#endif\nvec3 viewNormal = unpackRGBToNormal(texture2D(tNormal, vUv).xyz);\nvec3 geomViewNormal = normalize(cross(dFdx(viewPos), dFdy(viewPos)));\nvec2 noiseScale = resolution / NOISE_TEX_SIZE;\nvec4 noiseData = texture2D(tNoise, vUv * noiseScale);\nfloat randAngle = noiseData.r * PI_HALF;\nfloat visibility = 0.0;\nvec3 bentNormalAvg = viewNormal;\nfloat normalAngle, normalProjLen, geomNormalAngle;\nvec2 horizonAngles, _vec2Tmp;\nvec3 sliceBentNormal;\n#if CALC_BENT_NORMALS == 1\nbentNormalAvg = vec3(0.0);\n#if ORTHO_CAMERA == 0\nvec3 bentRotAxis = cross(AXIS_Z, viewVec);\nfloat bentRotAngle = acos(clamp(dot(AXIS_Z, viewVec), -1.0, 1.0));\n#endif\n#endif\nvec2 sliceDir = vec2(cos(randAngle), sin(randAngle));\n#pragma unroll_loop_start\nfor (int i = 0; i < 2; i++) {\n_vec2Tmp = calcNormalAngleAndProjLen(viewVec, viewNormal, sliceDir);\nnormalAngle = _vec2Tmp[0], normalProjLen = _vec2Tmp[1];\n_vec2Tmp = calcNormalAngleAndProjLen(viewVec, geomViewNormal, sliceDir);\ngeomNormalAngle = _vec2Tmp[0];\nhorizonAngles = calcHorizonAngles(viewPos, viewVec, sliceDir, noiseData.g);\nhorizonAngles = clampHorizonAnglesAroundNormal(horizonAngles,\nnormalAngle, geomNormalAngle);\nvisibility += normalProjLen * integrateArc(horizonAngles, normalAngle);\n#if CALC_BENT_NORMALS == 1\nsliceBentNormal = calcSliceBentNormal(sliceDir, horizonAngles, normalAngle);\n#if ORTHO_CAMERA == 0\nsliceBentNormal = vec3RotateAxisAngle(sliceBentNormal,\nbentRotAxis, bentRotAngle);\n#endif\nbentNormalAvg += sliceBentNormal * normalProjLen;\n#endif\nsliceDir = vec2(-sliceDir.y, sliceDir.x);\n}\n#pragma unroll_loop_end\nvisibility /= 2.0;\n#if CALC_BENT_NORMALS == 1\nfloat mixFactor = clamp((1.0 - 2.0 * visibility) / (3.0 * visibility - 4.0), 0.0, 1.0);\nbentNormalAvg = normalize(mix(bentNormalAvg, viewNormal, mixFactor));\n#endif\ngl_FragColor = vec4(pow(visibility, factor), packNormalToRGB(bentNormalAvg));\n#ifndef GTAO_DISABLE_BKG_FIX\n}\n#endif\n}",pp_outline_edge_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform vec2 texSize;\nuniform vec4 visibleEdgeColor;\nuniform vec4 hiddenEdgeColor;\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\nvec4 c1 = texture2D(maskTexture, vUv + uvOffset.xy);\nvec4 c2 = texture2D(maskTexture, vUv - uvOffset.xy);\nvec4 c3 = texture2D(maskTexture, vUv + uvOffset.yw);\nvec4 c4 = texture2D(maskTexture, vUv - uvOffset.yw);\nfloat diff1 = (c1.r - c2.r) * 0.5;\nfloat diff2 = (c3.r - c4.r) * 0.5;\nfloat d = length(vec2(diff1, diff2));\nfloat a1 = min(c1.g, c2.g);\nfloat a2 = min(c3.g, c4.g);\nfloat visibilityFactor = min(a1, a2);\nvec4 edgeColor = (1.0 - visibilityFactor > 0.001) ? visibleEdgeColor : hiddenEdgeColor;\ngl_FragColor = edgeColor * vec4(d);\n}",pp_outline_blur_frag:"#include \nvarying vec2 vUv;\nuniform sampler2D colorTexture;\nuniform vec2 texSize;\nuniform vec2 direction;\nuniform float kernelRadius;\nfloat gaussianPdf(in float x, in float sigma) {\nreturn 0.39894 * exp(-0.5 * x * x/(sigma * sigma))/sigma;\n}\nvoid main() {\nvec2 invSize = 1.0 / texSize;\nfloat weightSum = gaussianPdf(0.0, kernelRadius);\nvec4 diffuseSum = texture2D(colorTexture, vUv);\n#if defined(LOG_SPACE)\ndiffuseSum = exp(diffuseSum);\n#endif\ndiffuseSum *= weightSum;\nvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\nvec2 uvOffset = delta;\nfor (int i = 1; i <= MAX_RADIUS; i++) {\nfloat w = gaussianPdf(uvOffset.x, kernelRadius);\nvec4 sample1 = texture2D(colorTexture, vUv + uvOffset);\nvec4 sample2 = texture2D(colorTexture, vUv - uvOffset);\n#if defined(LOG_SPACE)\nsample1 = exp(sample1);\nsample2 = exp(sample2);\n#endif\ndiffuseSum += ((sample1 + sample2) * w);\nweightSum += (2.0 * w);\nuvOffset += delta;\n}\nvec4 finalCol = diffuseSum / weightSum;\n#if defined(LOG_SPACE)\nfinalCol = log(finalCol);\n#endif\ngl_FragColor = finalCol;\n}",pp_outline_overlay_frag:"varying vec2 vUv;\nuniform sampler2D maskTexture;\nuniform sampler2D edgeTexture1;\nuniform sampler2D edgeTexture2;\nuniform sampler2D patternTexture;\nuniform float edgeStrength;\nuniform float edgeGlow;\nuniform bool usePatternTexture;\nvoid main() {\nvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\nvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\nvec4 maskColor = texture2D(maskTexture, vUv);\nvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\nfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\nvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\nvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\nif (usePatternTexture)\nfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\nfloat maxChannel = max(finalColor.r, max(finalColor.g, finalColor.b));\nif (maxChannel != 0.0) {\nfinalColor.rgb /= maxChannel;\n}\ngl_FragColor = finalColor;\n}",pp_tonemap_frag:"#include \nuniform sampler2D tDiffuse;\nvarying vec2 vUv;\nvoid main() {\nvec4 texel = texture2D(tDiffuse, vUv);\nfloat alpha = clamp(texel.a, 0.0, 1.0);\ngl_FragColor = texel;\ngl_FragColor.rgb /= alpha;\n#include \ngl_FragColor = LinearTosRGB(gl_FragColor);\ngl_FragColor.rgb *= alpha;\n#if ALPHA_AS_LUMA == 1\ngl_FragColor.a = linearToRelativeLuminance(gl_FragColor.rgb);\n#endif\n}",raw_meshline_vert:"precision highp float;\nattribute vec3 position;\nattribute vec3 previous;\nattribute vec3 next;\nattribute float side;\nattribute float width;\nattribute vec2 uv;\nattribute float counters;\nuniform mat4 projectionMatrix;\nuniform mat4 modelViewMatrix;\nuniform vec2 resolution;\nuniform float lineWidth;\nuniform float sizeAttenuation;\nvarying float vCounters;\nvarying vec2 vUV;\nconst float EQ_EPS = 0.000001;\nvec2 fix(vec4 i, float aspect) {\nvec2 res = i.xy / i.w;\nres.x *= aspect;\nreturn res;\n}\nbool posEqual(vec2 pos0, vec2 pos1) {\nreturn length(pos0 - pos1) < EQ_EPS;\n}\nvoid main() {\nfloat aspect = resolution.x / resolution.y;\nvCounters = counters;\nvUV = uv;\nmat4 m = projectionMatrix * modelViewMatrix;\nvec4 finalPosition = m * vec4(position, 1.0);\nvec4 prevPos = m * vec4(previous, 1.0);\nvec4 nextPos = m * vec4(next, 1.0);\nvec2 currentP = fix(finalPosition, aspect);\nvec2 prevP = fix(prevPos, aspect);\nvec2 nextP = fix(nextPos, aspect);\nfloat w = lineWidth * width;\nif (sizeAttenuation == 0.0) {\nw *= finalPosition.w / resolution.x;\n}\nvec2 dir;\nif (posEqual(nextP, currentP)) {\ndir = normalize(currentP - prevP);\n} else if (posEqual(prevP, currentP)) {\ndir = normalize(nextP - currentP);\n} else {\nvec2 dir1 = normalize(currentP - prevP);\nvec2 dir2 = normalize(nextP - currentP);\ndir = normalize(dir1 + dir2);\n}\nvec2 offset = vec2(-dir.y, dir.x);\noffset.y *= aspect;\noffset *= w;\nfinalPosition.xy += offset * side;\ngl_Position = finalPosition;\n}",raw_meshline_frag:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D alphaMap;\nuniform float useMap;\nuniform float useAlphaMap;\nuniform float visibility;\nuniform float alphaTest;\nuniform vec2 repeat;\nuniform vec3 color;\nuniform float opacity;\nvarying vec2 vUV;\nvarying float vCounters;\n#include \nvoid main() {\nvec4 c = vec4(color, opacity);\nif (useMap == 1.0) {\nc *= texture2D(map, vUV * repeat);\n}\nif (useAlphaMap == 1.0) {\nc.a *= texture2D(alphaMap, vUV * repeat).a;\n}\nif (c.a < alphaTest) {\ndiscard;\n}\ngl_FragColor = c;\ngl_FragColor.a *= step(vCounters, visibility);\ngl_FragColor = LinearTosRGB(gl_FragColor);\n}"},oo={common:{diffuse:{value:new yt(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new tt},uv2Transform:{value:new tt},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},maxMipLevel:{value:0}},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 et(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 yt(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},maxDistance:{},shadowCameraNear:{},expBias:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadow:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},rectAreaLightShadows:{value:[],properties:{shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{},expBias:{}}},rectAreaShadowMap:{value:[]},rectAreaShadowMatrix:{value:[]},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new yt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new tt}},sprite:{diffuse:{value:new yt(16777215)},opacity:{value:1},center:{value:new et(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new tt}},mask:{depthTexture:{value:null},cameraNearFar:{value:new et(.5,.5)},textureMatrix:{value:new un}},node:{nodeRGB:{value:[]},nodeValue:{value:[]},flipCubeMap:{value:-1},materialIndex:{value:0}},nodeGTAO:{gtaoMap:{value:null}},ssr:{invProjectionMatrix:{value:new un},ssrSourceBuffer:{value:null},ssrDepthBuffer:{value:null},ssrBackfaceDepthBuffer:{value:null},ssrStride:{value:20},ssrResolution:{value:new et},ssrThickness:{value:.01},ssrJitter:{value:1},ssrMaxDistance:{value:100}},planeReflectionProbe:{planeReflTexture:{value:null},planeReflTextureMatrix:{value:new un},planeReflDir:{value:new Bt},planeReflBoundingBoxMin:{value:new Bt},planeReflBoundingBoxMax:{value:new Bt},planeReflInvModelMatrix:{value:new un},planeReflFalloff:{value:0}}},ro={basic:{uniforms:Ui([oo.common,oo.specularmap,oo.envmap,oo.aomap,oo.lightmap,oo.fog]),vertexShader:io.meshbasic_vert,fragmentShader:io.meshbasic_frag},lambert:{uniforms:Ui([oo.common,oo.specularmap,oo.envmap,oo.aomap,oo.lightmap,oo.emissivemap,oo.fog,oo.lights,{emissive:{value:new yt(0)}}]),vertexShader:io.meshlambert_vert,fragmentShader:io.meshlambert_frag},phong:{uniforms:Ui([oo.common,oo.specularmap,oo.envmap,oo.aomap,oo.lightmap,oo.emissivemap,oo.bumpmap,oo.normalmap,oo.displacementmap,oo.fog,oo.lights,{emissive:{value:new yt(0)},specular:{value:new yt(1118481)},shininess:{value:30}}]),vertexShader:io.meshphong_vert,fragmentShader:io.meshphong_frag},standard:{uniforms:Ui([oo.common,oo.envmap,oo.aomap,oo.lightmap,oo.emissivemap,oo.bumpmap,oo.normalmap,oo.displacementmap,oo.roughnessmap,oo.metalnessmap,oo.fog,oo.lights,oo.planeReflectionProbe,{emissive:{value:new yt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new un},envMapParallaxMatrixInv:{value:new un}}]),vertexShader:io.meshphysical_vert,fragmentShader:io.meshphysical_frag},toon:{uniforms:Ui([oo.common,oo.aomap,oo.lightmap,oo.emissivemap,oo.bumpmap,oo.normalmap,oo.displacementmap,oo.gradientmap,oo.fog,oo.lights,{emissive:{value:new yt(0)}}]),vertexShader:io.meshtoon_vert,fragmentShader:io.meshtoon_frag},matcap:{uniforms:Ui([oo.common,oo.bumpmap,oo.normalmap,oo.displacementmap,oo.fog,{matcap:{value:null}}]),vertexShader:io.meshmatcap_vert,fragmentShader:io.meshmatcap_frag},points:{uniforms:Ui([oo.points,oo.fog]),vertexShader:io.points_vert,fragmentShader:io.points_frag},dashed:{uniforms:Ui([oo.common,oo.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:io.linedashed_vert,fragmentShader:io.linedashed_frag},depth:{uniforms:Ui([oo.common,oo.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:io.depth_vert,fragmentShader:io.depth_frag},normal:{uniforms:Ui([oo.common,oo.bumpmap,oo.normalmap,oo.displacementmap,{opacity:{value:1}}]),vertexShader:io.meshnormal_vert,fragmentShader:io.meshnormal_frag},sprite:{uniforms:Ui([oo.sprite,oo.fog]),vertexShader:io.sprite_vert,fragmentShader:io.sprite_frag},background:{uniforms:{uvTransform:{value:new tt},t2D:{value:null}},vertexShader:io.background_vert,fragmentShader:io.background_frag},cube:{uniforms:Ui([oo.envmap,{opacity:{value:1}}]),vertexShader:io.cube_vert,fragmentShader:io.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:io.equirect_vert,fragmentShader:io.equirect_frag},distanceRGBA:{uniforms:Ui([oo.common,oo.displacementmap,{referencePosition:{value:new Bt},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:io.distanceRGBA_vert,fragmentShader:io.distanceRGBA_frag},shadow:{uniforms:Ui([oo.lights,oo.fog,{color:{value:new yt(0)},opacity:{value:1}}]),vertexShader:io.shadow_vert,fragmentShader:io.shadow_frag},mask:{uniforms:Ui([oo.common,oo.displacementmap,oo.mask]),vertexShader:io.mask_vert,fragmentShader:io.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:io.equicube_vert,fragmentShader:io.equicube_frag},node:{uniforms:Ui([oo.common,oo.displacementmap,oo.envmap,oo.fog,oo.lights,oo.ssr,oo.planeReflectionProbe,oo.node,oo.nodeGTAO,{envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new un},envMapParallaxMatrixInv:{value:new un}}]),vertexShader:io.meshnode_vert,fragmentShader:io.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new et(.5,.5)}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_cube_octahedral_proj_frag}};function ao(e,t,n,i,o,r){const a=new yt(0);let s,l,c=!0===o?0:1,u=null,d=0,h=null;function f(e,t){n.buffers.color.setClear(e.r,e.g,e.b,t,r)}return{getClearColor:function(){return a},setClearColor:function(e,t=1){a.set(e),c=t,f(a,c)},getClearAlpha:function(){return c},setClearAlpha:function(e){c=e,f(a,c)},dispose:function(){s&&(s.geometry.dispose(),s.material.dispose()),s=void 0,l&&(l.geometry.dispose(),l.material.dispose()),l=void 0},render:function(n,o){let r=!1;const m=o.background&&o.background.isSceneBackground;let g=m?o.background.data:o.background;g&&g.isTexture&&(g=t.get(g));const v=e.xr,A=v.getSession&&v.getSession();A&&"additive"===A.environmentBlendMode&&(g=null),null===g?f(a,c):g&&g.isColor&&(f(g,1),r=!0),(e.autoClear||r)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil);const _=!!m&&o.background.useHDR;g&&(g.isCubeTexture||g.isWebGLCubeRenderTarget||g.mapping===p)?(void 0===l&&(l=new Di(new Oi(1,1,1),new Vi({name:"BackgroundCubeMaterial",uniforms:Fi(ro.cube.uniforms),vertexShader:ro.cube.vertexShader,fragmentShader:ro.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1,useHDR:_})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(e,t,n){const i=n.far;this.matrixWorld.makeScale(i,i,i),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),g.isWebGLCubeRenderTarget&&(g=g.texture),l.material.uniforms.envMap.value=g,l.material.uniforms.flipEnvMap.value=g.isCubeTexture&&!1===g.isRenderTargetTexture?-1:1,u===g&&d===g.version&&h===e.toneMapping||(l.material.needsUpdate=!0,u=g,d=g.version,h=e.toneMapping),n.unshift(l,l.geometry,l.material,0,0,null)):g&&g.isTexture&&(void 0===s&&(s=new Di(new no(2,2),new Vi({name:"BackgroundMaterial",uniforms:Fi(ro.background.uniforms),vertexShader:ro.background.vertexShader,fragmentShader:ro.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),s.geometry.deleteAttribute("normal"),Object.defineProperty(s.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(s)),s.material.uniforms.t2D.value=g,!0===g.matrixAutoUpdate&&g.updateMatrix(),s.material.uniforms.uvTransform.value.copy(g.matrix),u===g&&d===g.version&&h===e.toneMapping||(s.material.needsUpdate=!0,u=g,d=g.version,h=e.toneMapping),n.unshift(s,s.geometry,s.material,0,0,null))}}}function so(e,t,n,i){const o=e.getParameter(34921),r=i.isWebGL2?null:t.get("OES_vertex_array_object"),a=i.isWebGL2||null!==r,s={},l=h(null);let c=l;function u(t){return i.isWebGL2?e.bindVertexArray(t):r.bindVertexArrayOES(t)}function d(t){return i.isWebGL2?e.deleteVertexArray(t):r.deleteVertexArrayOES(t)}function h(e){const t=[],n=[],i=[];for(let e=0;e=0){let r=l[t];if(void 0===r&&("instanceMatrix"===t&&o.instanceMatrix&&(r=o.instanceMatrix),"instanceColor"===t&&o.instanceColor&&(r=o.instanceColor)),void 0!==r){const t=r.normalized,a=r.itemSize,l=n.get(r);if(void 0===l)continue;const c=l.buffer,u=l.type,d=l.bytesPerElement;if(r.isInterleavedBufferAttribute){const n=r.data,l=n.stride,h=r.offset;if(n&&n.isInstancedInterleavedBuffer){for(let e=0;e0&&e.getShaderPrecisionFormat(35632,36338).precision>0)return"highp";t="mediump"}return"mediump"===t&&e.getShaderPrecisionFormat(35633,36337).precision>0&&e.getShaderPrecisionFormat(35632,36337).precision>0?"mediump":"lowp"}const r="undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext||"undefined"!=typeof WebGL2ComputeRenderingContext&&e instanceof WebGL2ComputeRenderingContext;let a=void 0!==n.precision?n.precision:"highp";const s=o(a);s!==a&&(console.warn("v3d.WebGLRenderer:",a,"not supported, using",s,"instead."),a=s);const l=r||t.has("WEBGL_draw_buffers"),c=!0===n.logarithmicDepthBuffer,u=e.getParameter(34930),d=e.getParameter(35660),h=e.getParameter(3379),p=e.getParameter(34076),f=e.getParameter(34921),m=e.getParameter(36347),g=e.getParameter(36348),v=e.getParameter(36349),A=d>0,_=r||t.has("OES_texture_float");return{isWebGL2:r,drawBuffers:l,getMaxAnisotropy:function(){if(void 0!==i)return i;if(!0===t.has("EXT_texture_filter_anisotropic")){const n=t.get("EXT_texture_filter_anisotropic");i=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i},getMaxPrecision:o,precision:a,logarithmicDepthBuffer:c,maxTextures:u,maxVertexTextures:d,maxTextureSize:h,maxCubemapSize:p,maxAttributes:f,maxVertexUniforms:m,maxVaryings:g,maxFragmentUniforms:v,vertexTextures:A,floatFragmentTextures:_,floatVertexTextures:A&&_,maxSamples:r?e.getParameter(36183):0}}function uo(e){const t=this;let n=null,i=0,o=!1,r=!1;const a=new qi,s=new tt,l={value:null,needsUpdate:!1};function c(){l.value!==n&&(l.value=n,l.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function u(e,n,i,o){const r=null!==e?e.length:0;let c=null;if(0!==r){if(c=l.value,!0!==o||null===c){const t=i+4*r,o=n.matrixWorldInverse;s.getNormalMatrix(o),(null===c||c.length0){const a=new ji(r.height/2);return a.fromEquirectangularTexture(e,o),t.set(o,a),o.addEventListener("dispose",i),n(a.texture,o.mapping)}return null}}}return o},dispose:function(){t=new WeakMap}}}ro.physical={uniforms:Ui([ro.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new et(1,1)},clearcoatNormalMap:{value:null},sheen:{value:0},sheenColor:{value:new yt(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new et},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new yt(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new yt(1,1,1)},specularColorMap:{value:null}}]),vertexShader:io.meshphysical_vert,fragmentShader:io.meshphysical_frag},ro.copy={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_copy_frag},ro.bokeh={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:1},nearClip:{value:1},farClip:{value:1e3},depthLeakThreshold:{value:.2}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_bokeh_frag},ro.fxaa={defines:{FXAA_GLSL_100:1,FXAA_GLSL_130:0,FXAA_QUALITY_PRESET:12,FXAA_GREEN_AS_LUMA:1},uniforms:{tDiffuse:{value:null},resolution:{value:new et(1/1024,1/512)}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_fxaa_frag},ro.grayscale={uniforms:{tDiffuse:{value:null}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_grayscale_frag},ro.brightness_contrast={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_brightness_contrast_frag},ro.bloomLumHighPass={uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new yt(0)},defaultOpacity:{type:"f",value:0}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_bloom_lum_high_pass_frag},ro.blur={defines:{LOG_SPACE:0,OCTAHEDRAL_MAP:0},uniforms:{colorTexture:{value:null},texSize:{value:new et(.5,.5)},direction:{value:new et(.5,.5)},kernelRadius:{value:1}},customPrepTokens:{MAX_SAMPLE_RADIUS:4},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_blur_frag},ro.tonemap={defines:{ALPHA_AS_LUMA:0},uniforms:{tDiffuse:{value:null}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_tonemap_frag},ro.afterimage={uniforms:{damp:{value:.96},tOld:{value:null},tNew:{value:null}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_afterimage_frag};class po extends Gi{constructor(e=-1,t=1,n=1,i=-1,o=.1,r=2e3){super(),this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=i,this.near=o,this.far=r,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=null===e.view?null:Object.assign({},e.view),this}setViewOffset(e,t,n,i,o,r){null===this.view&&(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=i,this.view.width=o,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let o=n-e,r=n+e,a=i+t,s=i-t;if(null!==this.view&&this.view.enabled){const e=(this.right-this.left)/this.view.fullWidth/this.zoom,t=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=e*this.view.offsetX,r=o+e*this.view.width,a-=t*this.view.offsetY,s=a-t*this.view.height}this.projectionMatrix.makeOrthographic(o,r,a,s,this.near,this.far),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,null!==this.view&&(t.object.view=Object.assign({},this.view)),t}}po.prototype.isOrthographicCamera=!0;class fo extends Vi{constructor(e){super(e),this.type="RawShaderMaterial"}}fo.prototype.isRawShaderMaterial=!0;class mo extends Nn{constructor(){super(),this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.overrideMaterial=null,this.autoUpdate=!0,this.postprocessing=[],this.worldMaterial=null,this.worldEnvMapProbe=null,"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.autoUpdate=e.autoUpdate,this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),t}dispose(){this.dispatchEvent({type:"dispose"})}}mo.prototype.isScene=!0;let go=256;const vo=[{relSize:1,sigma:0,origin:[0,0]},{relSize:.5,sigma:.025,origin:[0,2/3]},{relSize:1/4,sigma:.07,origin:[.5,2/3]},{relSize:1/8,sigma:.18,origin:[.75,2/3]},{relSize:1/16,sigma:.24,origin:[.875,2/3]},{relSize:1/16,sigma:.3,origin:[.875,17/24]},{relSize:1/16,sigma:.36,origin:[.875,.75]},{relSize:1/16,sigma:.42,origin:[.875,19/24]},{relSize:1/16,sigma:.48,origin:[.875,20/24]},{relSize:1/16,sigma:.54,origin:[.875,.875]},{relSize:1/16,sigma:.6,origin:[.875,22/24]}];function Ao(e){return vo[e].relSize*go}const _o=20,xo=new po;let yo=null,bo=null,Mo=null;const Co=vo.map((function(e,t){const n=1/(Ao(t)-1),i=-n/2,o=1+n/2,r=[i,i,o,i,o,o,i,i,o,o,i,o],a=new Float32Array(108),s=new Float32Array(72),l=new Float32Array(36);for(let e=0;e<6;e++){const t=e%3*2/3-1,n=e>2?0:-1,i=[t,n,0,t+2/3,n,0,t+2/3,n+1,0,t,n,0,t+2/3,n+1,0,t,n+1,0];a.set(i,18*e),s.set(r,12*e);const o=[e,e,e,e,e,e];l.set(o,6*e)}const c=new gi;return c.setAttribute("position",new Jn(a,3)),c.setAttribute("uv",new Jn(s,2)),c.setAttribute("faceIndex",new Jn(l,1)),c}));let So=null,wo=null,Eo=null;const To=(1+Math.sqrt(5))/2,Io=1/To,Ro=[new Bt(1,1,1),new Bt(-1,1,1),new Bt(1,1,-1),new Bt(-1,1,-1),new Bt(0,To,Io),new Bt(0,To,-Io),new Bt(Io,0,To),new Bt(-Io,0,To),new Bt(To,Io,0),new Bt(-To,Io,0)];class Lo{constructor(e,t){this.flipCubemapX=!0,wo=e,Object.defineProperties(this,{maxTileSize:{get:function(){return go},set:function(e){go=e}}}),void 0!==t&&(this.maxTileSize=t),yo=function(e,t){const n=new Float32Array(e),i=new Bt(0,1,0),o=new fo({defines:{n:e,cubeUV_maxTileSize:ct(t)},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},lodIdx:{value:0},poleAxis:{value:i}},vertexShader:ko(),fragmentShader:"\n\n precision highp float;\n precision highp int;\n\n varying vec3 vOutputDirection;\n\n uniform sampler2D envMap;\n uniform int samples;\n uniform float weights[n];\n uniform bool latitudinal;\n uniform float dTheta;\n uniform float lodIdx;\n uniform vec3 poleAxis;\n\n #define ENVMAP_TYPE_CUBE_UV\n #include \n\n vec3 getSample(float theta, vec3 axis) {\n\n float cosTheta = cos(theta);\n // Rodrigues' axis-angle rotation\n vec3 sampleDirection = vOutputDirection * cosTheta\n + cross(axis, vOutputDirection) * sin(theta)\n + axis * dot(axis, vOutputDirection) * (1.0 - cosTheta);\n\n return bilinearCubeUV(envMap, sampleDirection, lodIdx);\n\n }\n\n void main() {\n\n vec3 axis = latitudinal ? poleAxis : cross(poleAxis, vOutputDirection);\n\n if (all(equal(axis, vec3(0.0)))) {\n\n axis = vec3(vOutputDirection.z, 0.0, - vOutputDirection.x);\n\n }\n\n axis = normalize(axis);\n\n gl_FragColor = vec4(0.0);\n gl_FragColor.rgb += weights[0] * getSample(0.0, axis);\n\n for (int i = 1; i < n; i++) {\n\n if (i >= samples) {\n\n break;\n\n }\n\n float theta = dTheta * float(i);\n gl_FragColor.rgb += weights[i] * getSample(-1.0 * theta, axis);\n gl_FragColor.rgb += weights[i] * getSample(theta, axis);\n\n }\n\n }\n ",blending:0,depthTest:!1,depthWrite:!1});return o.type="SphericalGaussianBlur",o}(_o,this.maxTileSize),Do(yo)}fromScene(e,t=0,n=.1,i=100){Eo=wo.getRenderTarget();const o=Bo();return function(e,t,n,i){const o=new ki(90,1,t,n),r=[1,1,1,1,-1,1],a=[1,1,-1,-1,-1,1],s=wo.outputEncoding,l=wo.toneMapping,c=wo.toneMappingExposure,u=wo.getClearColor(new yt),d=wo.getClearAlpha();wo.toneMapping=1,wo.toneMappingExposure=1,wo.outputEncoding=ve,e.scale.z*=-1;let h=e.background;if(h&&h.isColor){h.convertSRGBToLinear();const t=Math.max(h.r,h.g,h.b),n=Math.min(Math.max(Math.ceil(Math.log2(t)),-128),127);h=h.multiplyScalar(Math.pow(2,-n));const i=(n+128)/255;wo.setClearColor(h,i),e.background=null}for(let t=0;t<6;t++){const n=t%3;0==n?(o.up.set(0,r[t],0),o.lookAt(a[t],0,0)):1==n?(o.up.set(0,0,r[t]),o.lookAt(0,a[t],0)):(o.up.set(0,r[t],0),o.lookAt(0,0,a[t]));const s=Ao(0);Oo(i,n*s,t>2?s:0,s,s),wo.setRenderTarget(i),wo.render(e,o)}wo.toneMapping=l,wo.toneMappingExposure=c,wo.outputEncoding=s,wo.setClearColor(u,d),e.scale.z*=-1}(e,n,i,o),t>0&&Uo(o,0,0,t),Fo(o),Po(o),o}fromEquirectangular(e){return e.magFilter=y,e.minFilter=y,e.generateMipmaps=!1,this.fromCubemap(e)}fromCubemap(e){Eo=wo.getRenderTarget();const t=Bo(e);return function(e,t,n){const i=new mo;e.isCubeTexture?null==Mo&&(Mo=Go()):null==bo&&(bo=Vo());const o=e.isCubeTexture?Mo:bo;i.add(new Di(Co[0],o));const r=o.uniforms;r.envMap.value=e,e.isCubeTexture?r.flipCubemapX.value=n||!1:r.texelSize.value.set(1/e.image.width,1/e.image.height);const a=Ao(0);Oo(t,0,0,3*a,2*a),wo.setRenderTarget(t),wo.render(i,xo)}(e,t,this.flipCubemapX),Fo(t),Po(t),t}fromCubeRenderTarget(e,t){const n=Bo(e.texture,t);return function(e,t,n){const i=new mo;null==Mo&&(Mo=Go());const o=Mo;i.add(new Di(Co[0],o));const r=o.uniforms;r.envMap.value=e.texture,r.flipCubemapX.value=n||!1;const a=Ao(0);Oo(t,0,0,3*a,2*a),wo.setRenderTarget(t),wo.render(i,xo)}(e,n,this.flipCubemapX),Fo(n),Po(n),n}compileCubemapShader(){null==Mo&&(Mo=Go(),Do(Mo))}compileEquirectangularShader(){null==bo&&(bo=Vo(),Do(bo))}dispose(){yo.dispose(),null!=Mo&&Mo.dispose(),null!=bo&&bo.dispose();for(let e=0;e_o&&(h=_o,d=19/3,u=o/d);const p=[];let f=0;for(let e=0;e<_o;++e){const t=e/d,n=Math.exp(-t*t/2);p.push(n),0==e?f+=n:e0||s&&r&&function(e){let t=0;const n=6;for(let i=0;it.maxTextureSize&&(d=Math.ceil(u/t.maxTextureSize),u=t.maxTextureSize);const h=new Float32Array(u*d*4*i),p=new Xo(h,u,d,i);p.format=R,p.type=E,p.needsUpdate=!0;const f=4*l;for(let t=0;t0)return e;const o=t*n;let r=rr[o];if(void 0===r&&(r=new Float32Array(o),rr[o]=r),0!==t){i.toArray(r,0);for(let i=1,o=0;i!==t;++i)o+=n,e[i].toArray(r,o)}return r}function dr(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n",t[n]);return e}const ga=/^[ \t]*#include +<([\w\d./]+)>/gm;function va(e){return e.replace(ga,Aa)}function Aa(e,t){const n=io[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return va(n)}function _a(e){const t=new RegExp("#pragma unroll_loop_start[\\s]+?for \\(int (\\w+) \\= (\\d+)\\; (\\w+) <(=?) (\\w+)\\; (\\w+)\\+\\+\\) \\{"),n=new RegExp("\\{|\\}","g");let i;for(;i=t.exec(e);){let t,o;t=o=n.lastIndex=i.index+i[0].length;let r,a=1;do{(r=n.exec(e))&&("{"==r[0]?a++:"}"==r[0]&&a--,o=r.index)}while(r&&a>0);if(0==a){const r=e.substring(i.index,n.lastIndex),a=e.substring(t,o),s=new RegExp(`\\[${i[1]}\\]`,"g"),l=new RegExp(`\\(${i[1]}\\)`,"g");let c="";const u=parseInt(i[2]),d=parseInt(i[5])+("="===i[4]?1:0);for(let e=u;e0&&(y+="\n"),b=[v,A].filter(ua).join("\n"),b.length>0&&(b+="\n")):(y=[xa(n),"#define SHADER_NAME "+n.shaderName,e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",A,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define MAX_BONES "+n.maxBones,n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+h:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.displacementMap&&n.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.flatShading?"#define FLAT_SHADED":"",n.skinning?"#define USE_SKINNING":"",n.useVertexTexture?"#define BONE_TEXTURE":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE":"",n.morphTargetsCount>0&&n.isWebGL2?"#define MORPHTARGETS_TEXTURE_STRIDE "+n.morphTextureStride:"",n.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+n.morphTargetsCount:"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",n.planeReflProbe?"#define USE_PLANE_REFLECTION":"","\n uniform mat4 modelMatrix;\n uniform mat4 modelViewMatrix;\n uniform mat4 projectionMatrix;\n uniform mat4 viewMatrix;\n uniform mat3 normalMatrix;\n uniform vec3 cameraPosition;\n uniform bool isOrthographic;\n\n #ifdef USE_INSTANCING\n attribute mat4 instanceMatrix;\n #endif\n\n #ifdef USE_INSTANCING_COLOR\n attribute vec3 instanceColor;\n #endif\n\n attribute vec3 position;\n attribute vec3 normal;\n attribute vec2 uv;\n\n #ifdef USE_TANGENT\n attribute vec4 tangent;\n #endif\n\n #if defined(USE_COLOR_ALPHA)\n attribute vec4 color;\n #elif defined(USE_COLOR)\n attribute vec3 color;\n #endif\n\n #if (defined(USE_MORPHTARGETS) && !defined(MORPHTARGETS_TEXTURE))\n #if MORPHTARGETS_COUNT > 0\n attribute vec3 morphTarget0;\n #endif\n #if MORPHTARGETS_COUNT > 1\n attribute vec3 morphTarget1;\n #endif\n #if MORPHTARGETS_COUNT > 2\n attribute vec3 morphTarget2;\n #endif\n #if MORPHTARGETS_COUNT > 3\n attribute vec3 morphTarget3;\n #endif\n #if MORPHTARGETS_COUNT > 4\n attribute vec3 morphTarget4;\n #endif\n #if MORPHTARGETS_COUNT > 5\n attribute vec3 morphTarget5;\n #endif\n\n #ifdef USE_MORPHNORMALS\n #if MORPHTARGETS_COUNT > 0\n attribute vec3 morphNormal0;\n #endif\n #if MORPHTARGETS_COUNT > 1\n attribute vec3 morphNormal1;\n #endif\n #if MORPHTARGETS_COUNT > 2\n attribute vec3 morphNormal2;\n #endif\n #if MORPHTARGETS_COUNT > 3\n attribute vec3 morphNormal3;\n #endif\n #if MORPHTARGETS_COUNT > 4\n attribute vec3 morphNormal4;\n #endif\n #if MORPHTARGETS_COUNT > 5\n attribute vec3 morphNormal5;\n #endif\n #else\n #if MORPHTARGETS_COUNT > 6\n attribute vec3 morphTarget6;\n #endif\n #if MORPHTARGETS_COUNT > 7\n attribute vec3 morphTarget7;\n #endif\n #if MORPHTARGETS_COUNT > 8\n attribute vec3 morphTarget8;\n #endif\n #if MORPHTARGETS_COUNT > 9\n attribute vec3 morphTarget9;\n #endif\n #if MORPHTARGETS_COUNT > 10\n attribute vec3 morphTarget10;\n #endif\n #if MORPHTARGETS_COUNT > 11\n attribute vec3 morphTarget11;\n #endif\n #endif\n #endif\n\n #ifdef USE_SKINNING\n attribute vec4 skinIndex;\n attribute vec4 skinWeight;\n #endif\n "].filter(ua).join("\n"),b=[v,xa(n),"#define SHADER_NAME "+n.shaderName,A,fa(n.materialProfile),e.compatSettings.saturateSpecEnvBlenderApprox?"#define COMPAT_SATURATE_SPEC_ENV_BLENDER_APPROX":"",e.compatSettings.useSpecEnvBlenderApprox?"#define COMPAT_USE_SPEC_ENV_BLENDER_APPROX":"",n.useFog&&n.fog?"#define USE_FOG":"",n.useFog&&n.fogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.matcap?"#define USE_MATCAP":"",n.envMap?"#define USE_ENVMAP":"",n.envMap?"#define "+d:"",n.envMap?"#define "+h:"",n.envMap?"#define "+m:"",0!==n.envMapCubeUVTileSize?`#define cubeUV_maxTileSize ${ct(n.envMapCubeUVTileSize)}`:"",n.lightMap?"#define USE_LIGHTMAP":"",n.aoMap?"#define USE_AOMAP":"",n.emissiveMap?"#define USE_EMISSIVEMAP":"",n.bumpMap?"#define USE_BUMPMAP":"",n.normalMap?"#define USE_NORMALMAP":"",n.normalMap&&n.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",n.normalMap&&n.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",n.clearcoat?"#define USE_CLEARCOAT":"",n.clearcoatMap?"#define USE_CLEARCOATMAP":"",n.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",n.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",n.specularMap?"#define USE_SPECULARMAP":"",n.specularIntensityMap?"#define USE_SPECULARINTENSITYMAP":"",n.specularColorMap?"#define USE_SPECULARCOLORMAP":"",n.roughnessMap?"#define USE_ROUGHNESSMAP":"",n.metalnessMap?"#define USE_METALNESSMAP":"",n.alphaMap?"#define USE_ALPHAMAP":"",n.alphaTest?"#define USE_ALPHATEST":"",n.sheen?"#define USE_SHEEN":"",n.sheenColorMap?"#define USE_SHEENCOLORMAP":"",n.sheenRoughnessMap?"#define USE_SHEENROUGHNESSMAP":"",n.transmission?"#define USE_TRANSMISSION":"",n.transmissionMap?"#define USE_TRANSMISSIONMAP":"",n.thicknessMap?"#define USE_THICKNESSMAP":"",n.vertexTangents?"#define USE_TANGENT":"",n.vertexColors||n.instancingColor?"#define USE_COLOR":"",n.vertexAlphas?"#define USE_COLOR_ALPHA":"",n.vertexUvs?"#define USE_UV":"",n.uvsVertexOnly?"#define UVS_VERTEX_ONLY":"",n.gradientMap?"#define USE_GRADIENTMAP":"",n.flatShading?"#define FLAT_SHADED":"",n.doubleSided?"#define DOUBLE_SIDED":"",n.flipSided?"#define FLIP_SIDED":"",n.shadowMapEnabled?"#define USE_SHADOWMAP":"",n.shadowMapEnabled?"#define "+l:"",n.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",n.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",n.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",n.logarithmicDepthBuffer&&n.rendererExtensionFragDepth?"#define USE_LOGDEPTHBUF_EXT":"",(n.extensionShaderTextureLOD||n.envMap)&&n.rendererExtensionShaderTextureLod?"#define TEXTURE_LOD_EXT":"",n.physicallyCorrectLights?"#define UNITS_SCALE_FACTOR "+g:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",0===n.toneMapping||n.useHDR?"":"#define TONE_MAPPING",0===n.toneMapping||n.useHDR?"":io.tonemapping_pars_fragment,0===n.toneMapping||n.useHDR?"":ca("toneMapping",n.toneMapping),n.dithering?"#define DITHERING":"",n.transparent||n.alphaToCoverage?"":"#define OPAQUE",io.encodings_pars_fragment,la("linearToOutputTexel",n.outputEncoding),n.depthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"",`#define ESM_DISTANCE_SCALE ${ct(n.esmDistanceScale)}`,n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",n.useGTAO?"#define USE_GTAO":"",e.compatSettings.gtaoDisableBkgFix?"#define GTAO_DISABLE_BKG_FIX":"","\n"].filter(ua).join("\n")),n.isMeshNodeMaterial&&(a=ma(a,n.nodeChunks),s=ma(s,n.nodeChunks)),a=va(a),a=da(a,n),a=ha(a,n),n.customPrepTokens&&(a=pa(a,n.customPrepTokens)),s=va(s),s=da(s,n),s=ha(s,n),n.customPrepTokens&&(s=pa(s,n.customPrepTokens)),a=_a(a),s=_a(s),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(M="#version 300 es\n",y=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+y,b=["#define varying in",n.glslVersion===Te?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Te?"":"#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("\n")+"\n"+b);let C=M+y+a,S=M+b+s;e.debug.disableCompiledShaderCache&&(C+="\nconst float ANTI_CACHE = "+Math.random()+";",S+="\nconst float ANTI_CACHE = "+Math.random()+";");const w=ra(o,35633,C),E=ra(o,35632,S);o.attachShader(_,w),o.attachShader(_,E),void 0!==n.index0AttributeName?o.bindAttribLocation(_,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(_,0,"position"),o.linkProgram(_);let T,I,R=!0;function L(){if(R=!1,e.debug.checkShaderErrors){const e=o.getProgramInfoLog(_).trim(),t=o.getShaderInfoLog(w).trim(),n=o.getShaderInfoLog(E).trim();let i=!0,r=!0;if(!1===o.getProgramParameter(_,35714)){i=!1;const t=sa(o,w,"vertex"),n=sa(o,E,"fragment");console.error("v3d.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(_,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(r=!1);r&&(x.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:y},fragmentShader:{log:n,prefix:b}})}o.deleteShader(w),o.deleteShader(E)}return this.getUniforms=function(){return void 0===T&&(R&&L(),T=new oa(o,_)),T},this.getAttributes=function(){return void 0===I&&(R&&L(),I=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let o=0;o=0;o--){const r=i[o],a=t?e.getQueryParameter(r,34919):n.getQueryObjectEXT(r,n.QUERY_RESULT_AVAILABLE_EXT),s=e.getParameter(n.GPU_DISJOINT_EXT);if(a&&!s){const a=t?e.getQueryParameter(r,34918):n.getQueryObjectEXT(r,n.QUERY_RESULT_EXT);this.profile.renderTime+=a/1e6,i.splice(o,1)}}},this}let ba=0;class Ma{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,i=this._getShaderStage(t),o=this._getShaderStage(n),r=this._getShaderCacheForMaterial(e);return!1===r.has(i)&&(r.add(i),i.usedTimes++),!1===r.has(o)&&(r.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const e of t)e.usedTimes--,0===e.usedTimes&&this.shaderCache.delete(e);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!1===t.has(e)&&t.set(e,new Set),t.get(e)}_getShaderStage(e){const t=this.shaderCache;if(!1===t.has(e)){const n=new Ca;t.set(e,n)}return t.get(e)}}class Ca{constructor(){this.id=ba++,this.usedTimes=0}}function Sa(e,t,n,i,o,r,a){const s=new yn,l=new Ma,c=[],u=o.isWebGL2,d=o.logarithmicDepthBuffer,h=o.floatVertexTextures,m=o.maxVertexUniforms,g=o.vertexTextures;let v=o.precision;const A={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",MeshMaskMaterial:"mask",MeshNodeMaterial:"node"};return this.programs=c,{getParameters:function(r,s,c,_,x,y){const b=_.fog,M=x.geometry,C=r.isMeshStandardMaterial?_.environment:null,S=((r.isMeshStandardMaterial||r.isMeshNodeMaterial)&&r.envMap&&!r.envMap.isCubeTexture?n:t).get(r.envMap||C),w=A[r.type],E=x.isSkinnedMesh?function(e){const t=e.skeleton.bones;if(h)return 1024;{const e=m,n=Math.floor((e-20)/4),i=Math.min(n,t.length);return i0,F=r.clearcoat>0,U=!!S&&(S.mapping===p||S.mapping===f);return{isWebGL2:u,shaderID:w,shaderName:r.type,vertexShader:R,fragmentShader:L,defines:r.defines,customVertexShaderID:B,customFragmentShaderID:P,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:v,instancing:!0===x.isInstancedMesh,instancingColor:!0===x.isInstancedMesh&&null!==x.instanceColor,supportsVertexTextures:g,outputEncoding:null===N?e.outputEncoding:!0===N.isXRRenderTarget?N.texture.encoding:ve,map:!!r.map,matcap:!!r.matcap,envMap:!!S,envMapMode:S&&S.mapping,envMapCubeUV:U,lightMap:!!r.lightMap,aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:1===r.normalMapType,tangentSpaceNormalMap:0===r.normalMapType,decodeVideoTexture:!!r.map&&!0===r.map.isVideoTexture&&r.map.encoding===Ae,clearcoat:F,clearcoatMap:F&&!!r.clearcoatMap,clearcoatRoughnessMap:F&&!!r.clearcoatRoughnessMap,clearcoatNormalMap:F&&!!r.clearcoatNormalMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,specularIntensityMap:!!r.specularIntensityMap,specularColorMap:!!r.specularColorMap,transparent:r.transparent,alphaMap:!!r.alphaMap,alphaTest:O,gradientMap:!!r.gradientMap,sheen:r.sheen>0,sheenColorMap:!!r.sheenColorMap,sheenRoughnessMap:!!r.sheenRoughnessMap,transmission:r.transmission>0,transmissionMap:!!r.transmissionMap,thicknessMap:!!r.thicknessMap,combine:r.combine,vertexTangents:!!r.normalMap&&!!M.attributes.tangent,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!M.attributes.color&&4===M.attributes.color.itemSize,vertexUvs:!!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatMap||r.clearcoatRoughnessMap||r.clearcoatNormalMap||r.displacementMap||r.transmissionMap||r.thicknessMap||r.specularIntensityMap||r.specularColorMap||r.sheenColorMap||r.sheenRoughnessMap),uvsVertexOnly:!(r.map||r.bumpMap||r.normalMap||r.specularMap||r.alphaMap||r.emissiveMap||r.roughnessMap||r.metalnessMap||r.clearcoatNormalMap||r.transmission>0||r.transmissionMap||r.thicknessMap||r.specularIntensityMap||r.specularColorMap||r.sheen>0||r.sheenColorMap||r.sheenRoughnessMap||!r.displacementMap),fog:!!b,useFog:r.fog,fogExp2:b&&b.isFogExp2,flatShading:!!r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===x.isSkinnedMesh&&E>0,maxBones:E,useVertexTexture:h,morphTargets:void 0!==M.morphAttributes.position,morphNormals:void 0!==M.morphAttributes.normal,morphColors:void 0!==M.morphAttributes.color,morphTargetsCount:I,morphTextureStride:D,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:r.dithering,shadowMapEnabled:e.shadowMap.enabled&&c.length>0,shadowMapType:e.shadowMap.type,toneMapping:r.toneMapped?e.toneMapping:0,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,doubleSided:2===r.side,flipSided:1===r.side,depthPacking:void 0!==r.depthPacking&&r.depthPacking,envMapCubeUVTileSize:U&&void 0!==S.image?S.image.width/3:0,distancePacking:void 0!==r.distancePacking&&r.distancePacking,useSlopeScaledBias:void 0!==r.useSlopeScaledBias&&r.useSlopeScaledBias,esmDistanceScale:e.shadowMap.esmDistanceScale,numRectAreaLightShadows:s.rectAreaShadowMap.length,planeReflProbe:!!y,materialName:r.name,materialProfile:r.profile,unitsScaleFactor:e.unitsScaleFactor,useHDR:!!r.useHDR,alphaToCoverage:!!r.alphaToCoverage,customPrepTokens:r.customPrepTokens,isMeshNodeMaterial:r.isMeshNodeMaterial,nodeChunks:r.nodeChunks,nodeChunksHash:r.nodeChunksHash,useGTAO:r.isMeshNodeMaterial&&r.canUseGTAO()&&e.canUseGTAO(),index0AttributeName:r.index0AttributeName,extensionDerivatives:r.extensions&&r.extensions.derivatives,extensionFragDepth:r.extensions&&r.extensions.fragDepth,extensionDrawBuffers:r.extensions&&r.extensions.drawBuffers,extensionShaderTextureLOD:r.extensions&&r.extensions.shaderTextureLOD,rendererExtensionFragDepth:u||i.has("EXT_frag_depth"),rendererExtensionDrawBuffers:u||i.has("WEBGL_draw_buffers"),rendererExtensionShaderTextureLod:u||i.has("EXT_shader_texture_lod"),customProgramCacheKey:r.customProgramCacheKey()}},getProgramCacheKey:function(t){const n=[];if(t.shaderID?n.push(t.shaderID):(n.push(t.customVertexShaderID),n.push(t.customFragmentShaderID)),void 0!==t.defines)for(const e in t.defines)n.push(e),n.push(t.defines[e]);if(void 0!==t.customPrepTokens)for(const e in t.customPrepTokens)n.push(e),n.push(t.customPrepTokens[e]);return!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.maxBones),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.unitsScaleFactor),e.push(t.esmDistanceScale),e.push(t.numRectAreaLightShadows)}(n,t),function(e,t){s.disableAll(),t.isWebGL2&&s.enable(0);t.supportsVertexTextures&&s.enable(1);t.instancing&&s.enable(2);t.instancingColor&&s.enable(3);t.map&&s.enable(4);t.matcap&&s.enable(5);t.envMap&&s.enable(6);t.envMapCubeUV&&s.enable(7);t.lightMap&&s.enable(8);t.aoMap&&s.enable(9);t.emissiveMap&&s.enable(10);t.bumpMap&&s.enable(11);t.normalMap&&s.enable(12);t.objectSpaceNormalMap&&s.enable(13);t.tangentSpaceNormalMap&&s.enable(14);t.clearcoat&&s.enable(15);t.clearcoatMap&&s.enable(16);t.clearcoatRoughnessMap&&s.enable(17);t.clearcoatNormalMap&&s.enable(18);t.displacementMap&&s.enable(19);t.specularMap&&s.enable(20);t.roughnessMap&&s.enable(21);t.metalnessMap&&s.enable(22);t.gradientMap&&s.enable(23);t.alphaMap&&s.enable(24);t.alphaTest&&s.enable(25);t.vertexColors&&s.enable(26);t.vertexAlphas&&s.enable(27);t.vertexUvs&&s.enable(28);t.vertexTangents&&s.enable(29);t.uvsVertexOnly&&s.enable(30);t.fog&&s.enable(31);e.push(s.mask),s.disableAll(),t.useFog&&s.enable(0);t.flatShading&&s.enable(1);t.logarithmicDepthBuffer&&s.enable(2);t.skinning&&s.enable(3);t.useVertexTexture&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.premultipliedAlpha&&s.enable(7);t.shadowMapEnabled&&s.enable(8);t.physicallyCorrectLights&&s.enable(9);t.doubleSided&&s.enable(10);t.flipSided&&s.enable(11);t.depthPacking&&s.enable(12);t.dithering&&s.enable(13);t.specularIntensityMap&&s.enable(14);t.specularColorMap&&s.enable(15);t.transmission&&s.enable(16);t.transmissionMap&&s.enable(17);t.thicknessMap&&s.enable(18);t.sheen&&s.enable(19);t.sheenColorMap&&s.enable(20);t.sheenRoughnessMap&&s.enable(21);t.decodeVideoTexture&&s.enable(22);t.transparent&&s.enable(23);e.push(s.mask),s.disableAll(),t.distancePacking&&s.enable(0);t.useSlopeScaledBias&&s.enable(1);t.useGTAO&&s.enable(2);t.useHDR&&s.enable(3);t.planeReflProbe&&s.enable(4);t.alphaToCoverage&&s.enable(5);e.push(s.mask)}(n,t),n.push(e.outputEncoding)),n.push(t.customProgramCacheKey),void 0!==t.nodeChunksHash&&n.push(t.nodeChunksHash),n.join()},getUniforms:function(e){const t=A[e.type];let n;if(t){const e=ro[t];n=zi.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e0?i.push(u):!0===a.transparent?o.push(u):n.push(u)},unshift:function(e,t,a,s,l,c){const u=r(e,t,a,s,l,c);a.transmission>0?i.unshift(u):!0===a.transparent?o.unshift(u):n.unshift(u)},finish:function(){for(let n=t,i=e.length;n1&&n.sort(e||Ea),i.length>1&&i.sort(t||Ta),o.length>1&&o.sort(t||Ta)}}}function Ra(){let e=new WeakMap;return{get:function(t,n){let i;return!1===e.has(t)?(i=new Ia,e.set(t,[i])):n>=e.get(t).length?(i=new Ia,e.get(t).push(i)):i=e.get(t)[n],i},dispose:function(){e=new WeakMap}}}function La(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={direction:new Bt,color:new yt};break;case"SpotLight":n={position:new Bt,direction:new Bt,color:new yt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new Bt,color:new yt,distance:0,decay:0};break;case"HemisphereLight":n={direction:new Bt,skyColor:new yt,groundColor:new yt};break;case"RectAreaLight":n={color:new yt,position:new Bt,halfWidth:new Bt,halfHeight:new Bt}}return e[t.id]=n,n}}}let Ba=0;function Pa(e,t){return(t.castShadow?1:0)-(e.castShadow?1:0)}function Da(e,t){const n=new La,i=function(){const e={};return{get:function(t){if(void 0!==e[t.id])return e[t.id];let n;switch(t.type){case"DirectionalLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new et,position:new Bt,shadowCameraNear:1,maxDistance:0,expBias:1};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new et,shadow:0,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"PointLight":case"RectAreaLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new et,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1}}return e[t.id]=n,n}}}(),o={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numRectAreaShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadow:[],spotShadowMap:[],spotShadowMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],rectAreaShadow:[],rectAreaShadowMap:[],rectAreaShadowMatrix:[]};for(let e=0;e<9;e++)o.probe.push(new Bt);const r=new Bt,a=new un,s=new un;return{setup:function(r,a){let s=0,l=0,c=0;for(let e=0;e<9;e++)o.probe[e].set(0,0,0);let u=0,d=0,h=0,p=0,f=0,m=0,g=0,v=0,A=0;r.sort(Pa);const _=!0!==a?Math.PI:1;for(let e=0,t=r.length;e0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(o.rectAreaLTC1=oo.LTC_FLOAT_1,o.rectAreaLTC2=oo.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(o.rectAreaLTC1=oo.LTC_HALF_1,o.rectAreaLTC2=oo.LTC_HALF_2):console.error("v3d.WebGLRenderer: Unable to use RectAreaLight. Missing WebGL extensions.")),o.ambient[0]=s,o.ambient[1]=l,o.ambient[2]=c;const x=o.hash;x.directionalLength===u&&x.pointLength===d&&x.spotLength===h&&x.rectAreaLength===p&&x.hemiLength===f&&x.numDirectionalShadows===m&&x.numPointShadows===g&&x.numSpotShadows===v&&x.numRectAreaShadows===A||(o.directional.length=u,o.spot.length=h,o.rectArea.length=p,o.point.length=d,o.hemi.length=f,o.directionalShadow.length=m,o.directionalShadowMap.length=m,o.pointShadow.length=g,o.pointShadowMap.length=g,o.spotShadow.length=v,o.spotShadowMap.length=v,o.directionalShadowMatrix.length=m,o.pointShadowMatrix.length=g,o.spotShadowMatrix.length=v,x.directionalLength=u,x.pointLength=d,x.spotLength=h,x.rectAreaLength=p,x.hemiLength=f,x.numDirectionalShadows=m,x.numPointShadows=g,x.numSpotShadows=v,o.rectAreaShadow.length=A,o.rectAreaShadowMap.length=A,o.rectAreaShadowMatrix.length=A,x.numRectAreaShadows=A,o.version=Ba++)},setupView:function(e,t){let n=0,l=0,c=0,u=0,d=0;const h=t.matrixWorldInverse;for(let p=0,f=e.length;pe.influenceDistance-t.influenceDistance))},pushPlaneReflProbe:function(e){a.push(e)}}}function Oa(e,t){let n=new WeakMap;return{get:function(i,o=0){let r;return!1===n.has(i)?(r=new Na(e,t),n.set(i,[r])):o>=n.get(i).length?(r=new Na(e,t),n.get(i).push(r)):r=n.get(i)[o],r},dispose:function(){n=new WeakMap}}}class Fa extends Xn{constructor(e){super(),this.type="MeshDepthMaterial",this.depthPacking=3200,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}Fa.prototype.isMeshDepthMaterial=!0;class Ua extends Xn{constructor(e){super(),this.type="MeshDistanceMaterial",this.referencePosition=new Bt,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.fog=!1,this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=ye,this.useSlopeScaledBias=!1,this.slopeScaledBias=0,this.setValues(e)}copy(e){return super.copy(e),this.referencePosition.copy(e.referencePosition),this.nearDistance=e.nearDistance,this.farDistance=e.farDistance,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.distancePacking=e.distancePacking,this.useSlopeScaledBias=e.useSlopeScaledBias,this.slopeScaledBias=e.slopeScaledBias,this}}Ua.prototype.isMeshDistanceMaterial=!0;const za=new un,Va=new Bt,Ga=new Bt;class ka{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new et(512,512),this.map=null,this.mapPass=null,this.matrix=new un,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $i,this._frameExtents=new et(1,1),this._viewportCount=1,this._viewports=[new Et(0,0,1,1)],this.expBias=1,this.slopeScaledBias=0,this._additionalMap2D=null,this._additionalMapCube=null}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Va.setFromMatrixPosition(e.matrixWorld),t.position.copy(Va),Ga.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(Ga),t.updateMatrixWorld(),za.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(za),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(t.projectionMatrix),n.multiply(t.matrixWorldInverse)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose(),null!==this._additionalMap2D&&this._additionalMap2D.dispose(),null!==this._additionalMapCube&&this._additionalMapCube.dispose()}copy(e){return this.camera=e.camera.clone(),this.bias=e.bias,this.radius=e.radius,this.mapSize.copy(e.mapSize),this.expBias=e.expBias,this.slopeScaledBias=e.slopeScaledBias,this}clone(){return(new this.constructor).copy(this)}toJSON(){const e={};return 0!==this.bias&&(e.bias=this.bias),0!==this.normalBias&&(e.normalBias=this.normalBias),1!==this.radius&&(e.radius=this.radius),512===this.mapSize.x&&512===this.mapSize.y||(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}ka.prototype.isLightShadow=!0;const Qa=Math.PI/4,Wa=new un,Ha=new Bt,ja=new Bt;class Ya extends ka{constructor(){super(new ki(50,1,.5,500)),this.focus=1,this.useOmniMaps=!1,this.useMinFov90=!1,this._frameExtentsOmni=new et(4,2),this._viewportCountOmni=6,this._viewportsOmni=[new Et(2,1,1,1),new Et(0,1,1,1),new Et(3,1,1,1),new Et(1,1,1,1),new Et(3,0,1,1),new Et(1,0,1,1)],this._cubeDirections=[new Bt(1,0,0),new Bt(-1,0,0),new Bt(0,0,1),new Bt(0,0,-1),new Bt(0,1,0),new Bt(0,-1,0)],this._cubeUps=[new Bt(0,1,0),new Bt(0,1,0),new Bt(0,1,0),new Bt(0,1,0),new Bt(0,0,1),new Bt(0,0,-1)]}updateMatrices(e,t=0){if(this.useOmniMaps){const n=this.camera,i=this.matrix;Ha.setFromMatrixPosition(e.matrixWorld),n.position.copy(Ha),ja.copy(n.position),ja.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(ja),n.updateMatrixWorld(),i.makeTranslation(-Ha.x,-Ha.y,-Ha.z),Wa.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Wa)}else{const t=this.camera,n=2*Oe*e.angle*this.focus,i=this.mapSize.width/this.mapSize.height,o=e.distance||t.far;n===t.fov&&i===t.aspect&&o===t.far||(t.fov=n,t.aspect=i,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}}getViewportCount(){return this.useOmniMaps?this._viewportCountOmni:super.getViewportCount()}getViewport(e){return this.useOmniMaps?this._viewportsOmni[e]:super.getViewport(e)}getFrameExtents(){return this.useOmniMaps?this._frameExtentsOmni:super.getFrameExtents()}calcUseOmniMaps(e){return this.useOmniMaps=e>Qa,this.useOmniMaps}copy(e){return super.copy(e),this.focus=e.focus,this.useOmniMaps=e.useOmniMaps,this.useMinFov90=e.useMinFov90,this}}Ya.prototype.isSpotLightShadow=!0;function Xa(e,t,n){let i=new $i;const o=new et,r=new et,a=new Et,s=new Fa({depthPacking:_e}),l=new Ua,c={},u=n.maxTextureSize,d=n.isWebGL2,h={0:1,1:0,2:2},p=new Vi({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8},uniforms:{shadow_pass:{value:null},resolution:{value:new et},radius:{value:4}},vertexShader:"void main() {\ngl_Position = vec4(position, 1.0);\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include \nvoid main() {\nconst float samples = float(VSM_SAMPLES);\nfloat mean = 0.0;\nfloat squared_mean = 0.0;\nfloat uvStride = samples <= 1.0 ? 0.0 : 2.0 / (samples - 1.0);\nfloat uvStart = samples <= 1.0 ? 0.0 : - 1.0;\nfor (float i = 0.0; i < samples; i++) {\nfloat uvOffset = uvStart + i * uvStride;\n#ifdef HORIZONTAL_PASS\nvec2 distribution = unpackRGBATo2Half(texture2D(shadow_pass, (gl_FragCoord.xy + vec2(uvOffset, 0.0) * radius) / resolution));\nmean += distribution.x;\nsquared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n#else\nfloat depth = unpackRGBAToDepth(texture2D(shadow_pass, (gl_FragCoord.xy + vec2(0.0, uvOffset) * radius) / resolution));\nmean += depth;\nsquared_mean += depth * depth;\n#endif\n}\nmean = mean / samples;\nsquared_mean = squared_mean / samples;\nfloat std_dev = sqrt(squared_mean - mean * mean);\ngl_FragColor = pack2HalfToRGBA(vec2(mean, std_dev));\n}"}),f=p.clone();f.defines.HORIZONTAL_PASS=1;const m=new gi;m.setAttribute("position",new Jn(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Di(m,p),v=new un,_=new un,x=new et(u,u),b=new Bt,M=new Bt,C=new Bt,S=[new Bt(1,0,0),new Bt(-1,0,0),new Bt(0,1,0),new Bt(0,-1,0),new Bt(0,0,1),new Bt(0,0,-1)],w=[new Bt(0,1,0),new Bt(0,1,0),new Bt(0,0,1),new Bt(0,0,-1),new Bt(0,1,0),new Bt(0,1,0)],E=new en,I=[new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt,new Bt],L=new Di(new no(1,1,1,1));L.name="esmFarPlane",L.castShadow=!0,L.material.shadowSide=0;const B=new po(-1,1,1,-1,0,10),D=new Di(new no(2,2)),N=new Vi({type:"ShadowCubeOctahedral",defines:Object.assign({},ro.cubeOctahedral.defines),uniforms:zi.clone(ro.cubeOctahedral.uniforms),vertexShader:ro.cubeOctahedral.vertexShader,fragmentShader:ro.cubeOctahedral.fragmentShader}),O={},F={},U=this;function z(t,n,i,o,r,a,u,d,p){let f=null;const m=d||4===u?t.customDistanceMaterial:t.customDepthMaterial;if(f=void 0!==m?m:d||4===u?l:s,e.localClippingEnabled&&!0===i.clipShadows&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0){const e=f.uuid,t=i.uuid;let n=c[e];void 0===n&&(n={},c[e]=n);let o=n[t];void 0===o&&(o=f.clone(),n[t]=o),f=o}switch(f.visible=i.visible,f.wireframe=i.wireframe,f.side=3===u?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:h[i.side],f.alphaMap=i.alphaMap,f.alphaTest=i.alphaTest,f.clipShadows=i.clipShadows,f.clippingPlanes=i.clippingPlanes,f.clipIntersection=i.clipIntersection,f.displacementMap=i.displacementMap,f.displacementScale=i.displacementScale,f.displacementBias=i.displacementBias,f.wireframeLinewidth=i.wireframeLinewidth,f.linewidth=i.linewidth,!d&&4!==u||!0!==f.isMeshDistanceMaterial||(f.referencePosition.copy(p),f.nearDistance=r,f.farDistance=a,f.distancePacking=4===u?3302:ye),4===u&&(f.defines.DISTANCE_SCALE=ct(U.esmDistanceScale)),u){case 0:case 6:case 1:case 2:case 5:f.useSlopeScaledBias=!0,f.slopeScaledBias=o.shadow.slopeScaledBias;break;case 4:f.useSlopeScaledBias=!0,f.slopeScaledBias=.5}return f}function V(n,o,r,a,s,l){if(!1===n.visible)return;if((o.ignoreShadowLayers||n.layers.test(o.layers))&&(n.isMesh||n.isLine||n.isPoints)&&(n.castShadow||n.receiveShadow&&3===s)&&(!n.frustumCulled||i.intersectsObject(n))){n.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,n.matrixWorld);const i=t.update(n),o=n.material;if(Array.isArray(o)){const t=i.groups;for(let c=0,u=t.length;cu||o.y>u)&&(o.x>u&&(r.x=Math.floor(u/m.x),o.x=r.x*m.x,d.mapSize.x=r.x),o.y>u&&(r.y=Math.floor(u/m.y),o.y=r.y*m.y,d.mapSize.y=r.y)),l.isSpotLight&&d.map&&d.map.width/d.map.height!=2){const e=d.map;d.map=d._additionalMap2D,d._additionalMap2D=e}const v=l.isPointLight||l.isRectAreaLight||l.isSpotLight&&d.useOmniMaps;if(v)l.isSpotLight&&(h.fov=90,h.updateProjectionMatrix());else if(l.isDirectionalLight){if(l.shadow.isDirectionalLightShadowCSM){const e=H(s,d,o,E);h.left=e.center.x-e.radius,h.right=e.center.x+e.radius,h.top=e.center.y+e.radius,h.bottom=e.center.y-e.radius,h.near=-e.center.z-e.radius,h.far=-e.center.z+e.radius,h.updateProjectionMatrix()}const e=l.getWorldDirection(C);M.addScaledVector(e,h.near)}else l.isSpotLight&&d.useMinFov90&&(h.fov=90,h.updateProjectionMatrix());if(null===d.map&&!v&&3===c){const e={minFilter:y,magFilter:y,format:R};d.map=new Tt(o.x,o.y,e),d.map.texture.name=l.name+".shadowMap",d.mapPass=new Tt(o.x,o.y,e),h.updateProjectionMatrix()}if(null===d.map){const e={minFilter:A,magFilter:A,format:R};d.map=new Tt(o.x,o.y,e),d.map.texture.name=l.name+".shadowMap",h.updateProjectionMatrix()}e.state.buffers.color.setClear(1,1,1,1),e.setRenderTarget(d.map),e.clear();const _=d.getViewportCount();for(let t=0;t<_;t++){const o=d.getViewport(t);a.set(r.x*o.x,r.y*o.y,r.x*o.z,r.y*o.w),e.state.viewport(a),d.updateMatrices(l,t),i=d.getFrustum(),V(n,s,d.camera,l,c,v)}v||3!==c||function(n,i){const o=t.update(g);p.uniforms.shadow_pass.value=n.map.texture,p.uniforms.resolution.value=n.mapSize,p.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,o,p,g,null),f.uniforms.shadow_pass.value=n.mapPass.texture,f.uniforms.resolution.value=n.mapSize,f.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,o,f,g,null)}(d,s)}function k(t,n,r,a){const s=r.shadow,l=s.camera,c=s.matrix,u=r.isPointLight||r.isRectAreaLight?2:1,h=o.copy(s.mapSize).multiplyScalar(u).min(x).multiplyScalar(1/u);null===s._additionalMapCube&&(s._additionalMapCube=new ji(h.x,{minFilter:y,magFilter:y,format:d?P:R,type:T}),s._additionalMapCube.texture.name=r.name+".shadowMap.tmpCube"),null===s._additionalMap2D&&(s._additionalMap2D=new Tt(h.x*u,h.y*u,{minFilter:y,magFilter:y,format:d?P:R,type:T}),s._additionalMap2D.texture.name=r.name+".shadowMap.tmp2D"),null===s.map&&(s.map=new Tt(h.x*u,h.y*u,{minFilter:y,magFilter:y,format:d?P:R,type:T}),s.map.texture.name=r.name+".shadowMap"),M.setFromMatrixPosition(r.matrixWorld),l.position.copy(M),r.isSpotLight&&(l.fov=90,l.updateProjectionMatrix()),c.makeTranslation(-M.x,-M.y,-M.z);for(let o=0;o<6;o++)b.copy(l.position),b.add(S[o]),l.up.copy(w[o]),2!==o&&3!==o&&l.up.multiplyScalar(-1),l.lookAt(b),l.updateMatrixWorld(),v.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),i.setFromProjectionMatrix(v),e.setRenderTarget(s._additionalMapCube,o),e.clearDepth(),j(n,l,r,a),V(t,n,l,r,a,!0);const p=Math.max(s.radius*u,.001),f=function(e){return Math.ceil(.2*e)}(p);!function(e,t,n){const i=D.material=N;i.uniforms.tCube.value=t.texture,i.uniforms.texelSize.value.set(1/n.width,1/n.height),i.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(D),e.renderBufferDirect(B,!1,D.geometry,i,D,null)}(e,s._additionalMapCube,s.map),Q(e,s.map,s._additionalMap2D,f,p,1,0),Q(e,s._additionalMap2D,s.map,f,p,0,0)}function Q(e,t,n,i,o,r,a){const s=D.material=0===a?function(e){if(!(e in O)){(O[e]=new Vi({type:"ShadowBlur",defines:Object.assign({},ro.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:zi.clone(ro.blur.uniforms),customPrepTokens:Object.assign({},ro.blur.customPrepTokens),vertexShader:ro.blur.vertexShader,fragmentShader:ro.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=e}return O[e]}(i):function(e){if(!(e in F)){(F[e]=new Vi({type:"ShadowBlur",defines:Object.assign({},ro.blur.defines,{LOG_SPACE:1}),uniforms:zi.clone(ro.blur.uniforms),customPrepTokens:Object.assign({},ro.blur.customPrepTokens),vertexShader:ro.blur.vertexShader,fragmentShader:ro.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=e}return F[e]}(i);s.uniforms.direction.value.set(+(0===r),+(1===r)),s.uniforms.colorTexture.value=t.texture,s.uniforms.texSize.value.set(t.width,t.height),s.uniforms.kernelRadius.value=o,s.uniformsNeedUpdate=!0,e.setRenderTarget(n),e.clear(),e.updateGeometry(D),e.renderBufferDirect(B,!1,D.geometry,s,D,null)}function W(t,n,r,a){const s=r.shadow,l=s.camera,c=s.matrix,u=o.copy(s.mapSize).min(x);if(null===s._additionalMap2D&&(s._additionalMap2D=new Tt(u.x,u.y,{minFilter:y,magFilter:y,format:d?P:R,type:T}),s._additionalMap2D.texture.name=r.name+".shadowMap.tmp2D"),null===s.map&&(s.map=new Tt(u.x,u.y,{minFilter:y,magFilter:y,format:d?P:R,type:T}),s.map.texture.name=r.name+".shadowMap"),M.setFromMatrixPosition(r.matrixWorld),l.position.copy(M),b.setFromMatrixPosition(r.target.matrixWorld),l.lookAt(b),l.updateMatrixWorld(),r.isDirectionalLight){if(r.shadow.isDirectionalLightShadowCSM){const e=H(n,s,u,E);l.left=e.center.x-e.radius,l.right=e.center.x+e.radius,l.top=e.center.y+e.radius,l.bottom=e.center.y-e.radius,l.near=-e.center.z-e.radius,l.far=-e.center.z+e.radius,l.updateProjectionMatrix()}const e=r.getWorldDirection(C);M.addScaledVector(e,l.near)}else r.isSpotLight&&s.useMinFov90&&(l.fov=90,l.updateProjectionMatrix());let h;var p,f;c.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),c.multiply(l.projectionMatrix),c.multiply(l.matrixWorldInverse),v.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),i.setFromProjectionMatrix(v),e.setRenderTarget(s.map),e.clearDepth(),j(n,l,r,a),V(t,n,l,r,a,!1),r.isDirectionalLight&&r.shadow.isDirectionalLightShadowCSM?(p=s.radius,f=(l.right-l.left)/2,h=50*p/f):h=r.isSpotLight?.8*s.radius:s.radius,h=Math.max(h,.001);const m=function(e){return Math.ceil(.8*e)}(h);Q(e,s.map,s._additionalMap2D,m,h,0,1),Q(e,s._additionalMap2D,s.map,m,h,1,1)}function H(e,t,n,i){const o=Ue(t.maxDistance,e.near,e.far)/e.far;for(let t=0;t>2&1,t>>1&1,i).multiplyScalar(2).subScalar(1).applyMatrix4(e.projectionMatrixInverse),1===i&&n.multiplyScalar(o)}i.setFromPoints(I),_.multiplyMatrices(t.camera.matrixWorldInverse,e.matrixWorld);const r=i.center.applyMatrix4(_),a=i.radius*=_.getMaxScaleOnAxis(),s=n.x/2/a,l=n.y/2/a;return r.x=Math.round(r.x*s)/s,r.y=Math.round(r.y*l)/l,i}function j(e,t,n,i){let o,r,a,s,l,c;t.isPerspectiveCamera?(o=r=0,a=-.999*t.far,s=l=2*-a*Math.tan(ke(t.fov)/2),c=1):t.isOrthographicCamera&&(o=(t.right+t.left)/2,r=(t.top+t.bottom)/2,a=-.999*t.far,s=t.right-t.left,l=t.top-t.bottom,c=1),t.add(L),L.scale.set(s,l,c),L.position.set(o,r,a),L.updateMatrixWorld(),V(L,e,t,n,i,!0)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=1,this.esmDistanceScale=1,this.render=function(t,n,i){if(!1===U.enabled)return;if(!1===U.autoUpdate&&!1===U.needsUpdate)return;if(0===t.length)return;const o=e.getRenderTarget(),r=e.getActiveCubeFace(),a=e.getActiveMipmapLevel(),s=e.state;s.setBlending(0),s.buffers.color.setClear(1,1,1,1),s.buffers.depth.setTest(!0),s.setScissorTest(!1);for(let e=0,o=t.length;e=1):-1!==D.indexOf("OpenGL ES")&&(P=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),B=P>=2);let N=null,O={};const F=e.getParameter(3088),U=e.getParameter(2978),z=(new Et).fromArray(F),V=(new Et).fromArray(U);function G(t,n,i){const o=new Uint8Array(4),r=e.createTexture();e.bindTexture(t,r),e.texParameteri(t,10241,9728),e.texParameteri(t,10240,9728);for(let t=0;ti||e.height>i)&&(o=i/Math.max(e.width,e.height)),o<1||!0===t){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const i=t?je:Math.floor,r=i(o*e.width),a=i(o*e.height);void 0===f&&(f=D(r,a));const s=n?D(r,a):f;s.width=r,s.height=a;return s.getContext("2d").drawImage(e,0,0,r,a),console.warn("v3d.WebGLRenderer: Texture has been resized from ("+e.width+"x"+e.height+") to ("+r+"x"+a+")."),s}return"data"in e&&console.warn("v3d.WebGLRenderer: Image in DataTexture is too big ("+e.width+"x"+e.height+")."),e}return e}function O(e){return We(e.width)&&We(e.height)}function F(e,t){return e.generateMipmaps&&t&&e.minFilter!==A&&e.minFilter!==y}function U(t,n,o,r){e.generateMipmap(t);i.get(n).__maxMipLevel=Math.log2(Math.max(o,r))}function z(n,i,o,r,a=!1){if(!1===s)return i;if(null!==n){if(void 0!==e[n])return e[n];console.warn("v3d.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+n+"'")}let l=i;return 6403===i&&(5126===o&&(l=33326),5131===o&&(l=33325),5121===o&&(l=33321)),33319===i&&(5126===o&&(l=33328),5131===o&&(l=33327),5121===o&&(l=33323)),6408===i&&(5126===o&&(l=34836),5131===o&&(l=34842),5121===o&&(l=r===Ae&&!1===a?35907:32856),32819===o&&(l=32854),32820===o&&(l=32855)),33325!==l&&33326!==l&&33327!==l&&33328!==l&&34842!==l&&34836!==l||t.get("EXT_color_buffer_float"),l}function V(e,t,n){return!0===F(e,n)||e.isFramebufferTexture&&e.minFilter!==A&&e.minFilter!==y?Math.log2(Math.max(t.width,t.height))+1:void 0!==e.mipmaps&&e.mipmaps.length>0?e.mipmaps.length:e.isCompressedTexture&&Array.isArray(e.image)?t.mipmaps.length:1}function G(e){return e===A||e===_||e===x?9728:9729}function k(t){const n=t.target;n.removeEventListener("dispose",k),function(t){const n=i.get(t);if(void 0===n.__webglInit)return;e.deleteTexture(n.__webglTexture),i.remove(t)}(n),n.isVideoTexture&&p.delete(n),a.memory.textures--,a.removeTextureSpec(n)}function Q(t){const n=t.target;n.removeEventListener("dispose",Q),function(t){const n=t.texture,o=i.get(t),r=i.get(n);if(!t)return;void 0!==r.__webglTexture&&(e.deleteTexture(r.__webglTexture),a.memory.textures--);t.depthTexture&&t.depthTexture.dispose();if(t.isWebGLCubeRenderTarget)for(let t=0;t<6;t++)e.deleteFramebuffer(o.__webglFramebuffer[t]),o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer[t]);else e.deleteFramebuffer(o.__webglFramebuffer),o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&e.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer&&e.deleteRenderbuffer(o.__webglColorRenderbuffer),o.__webglDepthRenderbuffer&&e.deleteRenderbuffer(o.__webglDepthRenderbuffer);if(t.isWebGLMultipleRenderTargets)for(let t=0,o=n.length;t0&&o.__version!==e.version){const n=e.image;if(void 0===n)console.warn("v3d.WebGLRenderer: Texture marked for update but image is undefined");else{if(!1!==n.complete)return void Z(o,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}n.activeTexture(33984+t),n.bindTexture(3553,o.__webglTexture)}function j(t,o){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,i,o){if(6!==i.image.length)return;q(t,i),n.activeTexture(33984+o),n.bindTexture(34067,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const a=i&&(i.isCompressedTexture||i.image[0].isCompressedTexture),l=i.image[0]&&i.image[0].isDataTexture,u=[];for(let e=0;e<6;e++)u[e]=a||l?l?i.image[e].image:i.image[e]:N(i.image[e],!1,!0,c),u[e]=ne(i,u[e]);const d=u[0],h=O(d)||s,p=r.convert(i.format,i.encoding),f=r.convert(i.type),m=z(i.internalFormat,p,f,i.encoding),g=s&&!0!==i.isVideoTexture,v=void 0===t.__version;let A,_=V(i,d,h);if(K(34067,i,h),a){g&&v&&n.texStorage2D(34067,_,m,d.width,d.height);for(let e=0;e<6;e++){A=u[e].mipmaps;for(let t=0;t0&&_++,n.texStorage2D(34067,_,m,u[0].width,u[0].height));for(let e=0;e<6;e++)if(l){g?n.texSubImage2D(34069+e,0,0,0,u[e].width,u[e].height,p,f,u[e].data):n.texImage2D(34069+e,0,m,u[e].width,u[e].height,0,p,f,u[e].data);for(let t=0;t1||i.get(r).__currentAnisotropy)&&(e.texParameterf(n,a.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(r.anisotropy,o.getMaxAnisotropy())),i.get(r).__currentAnisotropy=r.anisotropy)}}function q(t,n){void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",k),t.__webglTexture=e.createTexture(),a.memory.textures++,a.addTextureSpec(n))}function Z(t,i,o){let a=3553;i.isDataTexture2DArray&&(a=35866),i.isDataTexture3D&&(a=32879),q(t,i),n.activeTexture(33984+o),n.bindTexture(a,t.__webglTexture),e.pixelStorei(37440,i.flipY),e.pixelStorei(37441,i.premultiplyAlpha),e.pixelStorei(3317,i.unpackAlignment),e.pixelStorei(37443,0);const l=function(e){return!s&&(e.wrapS!==g||e.wrapT!==g||e.minFilter!==A&&e.minFilter!==y)}(i)&&!1===O(i.image);let c=N(i.image,l,!1,u);c=ne(i,c);const d=O(c)||s,h=r.convert(i.format,i.encoding);let p,f=r.convert(i.type),m=z(i.internalFormat,h,f,i.encoding,i.isVideoTexture);K(a,i,d);const v=i.mipmaps,_=s&&!0!==i.isVideoTexture,x=void 0===t.__version,b=V(i,c,d);if(i.isDepthTexture)m=6402,s?m=i.type===E?36012:i.type===w?33190:i.type===I?35056:33189:i.type===E&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),i.format===L&&6402===m&&i.type!==S&&i.type!==w&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),i.type=S,f=r.convert(i.type)),i.format===B&&6402===m&&(m=34041,i.type!==I&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),i.type=I,f=r.convert(i.type))),_&&x?n.texStorage2D(3553,1,m,c.width,c.height):n.texImage2D(3553,0,m,c.width,c.height,0,h,f,null);else if(i.isDataTexture)if(v.length>0&&d){_&&x&&n.texStorage2D(3553,b,m,v[0].width,v[0].height);for(let e=0,t=v.length;e0&&d){_&&x&&n.texStorage2D(3553,b,m,v[0].width,v[0].height);for(let e=0,t=v.length;e=l&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),W+=1,e},this.resetTextureUnits=function(){W=0},this.setTexture2D=H,this.setTexture2DArray=function(e,t){const o=i.get(e);e.version>0&&o.__version!==e.version?Z(o,e,t):(n.activeTexture(33984+t),n.bindTexture(35866,o.__webglTexture))},this.setTexture3D=function(e,t){const o=i.get(e);e.version>0&&o.__version!==e.version?Z(o,e,t):(n.activeTexture(33984+t),n.bindTexture(32879,o.__webglTexture))},this.setTextureCube=j,this.rebindTextures=function(e,t,n){const o=i.get(e);void 0!==t&&J(o.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&ee(e)},this.setupRenderTarget=function(t){const l=t.texture,c=i.get(t),u=i.get(l);t.addEventListener("dispose",Q),!0!==t.isWebGLMultipleRenderTargets&&(void 0===u.__webglTexture&&(u.__webglTexture=e.createTexture()),u.__version=l.version,a.memory.textures++),a.addTextureSpec(t);const d=!0===t.isWebGLCubeRenderTarget,h=!0===t.isWebGLMultipleRenderTargets,p=l.isDataTexture3D||l.isDataTexture2DArray,f=O(t)||s;if(d){c.__webglFramebuffer=[];for(let t=0;t<6;t++)c.__webglFramebuffer[t]=e.createFramebuffer()}else if(c.__webglFramebuffer=e.createFramebuffer(),h)if(o.drawBuffers){const n=t.texture;for(let t=0,o=n.length;ts+c?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!l.inputState.pinching&&a<=s-c&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else null!==s&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),null!==o&&(s.matrix.fromArray(o.transform.matrix),s.matrix.decompose(s.position,s.rotation,s.scale),o.linearVelocity?(s.hasLinearVelocity=!0,s.linearVelocity.copy(o.linearVelocity)):s.hasLinearVelocity=!1,o.angularVelocity?(s.hasAngularVelocity=!0,s.angularVelocity.copy(o.angularVelocity)):s.hasAngularVelocity=!1));return null!==a&&(a.visible=null!==i),null!==s&&(s.visible=null!==o),null!==l&&(l.visible=null!==r),this}}class ns extends St{constructor(e,t,n,i,o,r,a,s,l,c){if((c=void 0!==c?c:L)!==L&&c!==B)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===L&&(n=S),void 0===n&&c===B&&(n=I),super(null,i,o,r,a,s,c,n,l),this.image={width:e,height:t},this.magFilter=void 0!==a?a:A,this.minFilter=void 0!==s?s:A,this.flipY=!1,this.generateMipmaps=!1}}ns.prototype.isDepthTexture=!0;class is{constructor(e,t,n=0,i=1/0){this.ray=new cn(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new yn,this.params={Mesh:{omitGeometry:!1},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{},checkVisibility:!0},this.layers.enable(3),this.layers.enable(4),this.layers.enable(5),this.layers.enable(6),this.layers.enable(7)}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t&&t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t&&t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):console.error("v3d.Raycaster: Unsupported camera type: "+t.type)}intersectObject(e,t=!0,n=[]){return rs(e,this,n,t,this.params.checkVisibility),n.sort(os),n}intersectObjects(e,t=!0,n=[]){for(let i=0,o=e.length;i0&&(t.alphaTest.value=n.alphaTest);const i=e.get(n).envMap;if(i){t.envMap.value=i,t.flipEnvMap.value=i.isCubeTexture&&!1===i.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.ior.value=n.ior,t.refractionRatio.value=n.refractionRatio;const o=e.get(i).__maxMipLevel;void 0!==o&&(t.maxMipLevel.value=o)}let o,r;n.lightMap&&(t.lightMap.value=n.lightMap,t.lightMapIntensity.value=n.lightMapIntensity),n.aoMap&&(t.aoMap.value=n.aoMap,t.aoMapIntensity.value=n.aoMapIntensity),n.map?o=n.map:n.specularMap?o=n.specularMap:n.displacementMap?o=n.displacementMap:n.normalMap?o=n.normalMap:n.bumpMap?o=n.bumpMap:n.roughnessMap?o=n.roughnessMap:n.metalnessMap?o=n.metalnessMap:n.alphaMap?o=n.alphaMap:n.emissiveMap?o=n.emissiveMap:n.clearcoatMap?o=n.clearcoatMap:n.clearcoatNormalMap?o=n.clearcoatNormalMap:n.clearcoatRoughnessMap?o=n.clearcoatRoughnessMap:n.specularIntensityMap?o=n.specularIntensityMap:n.specularColorMap?o=n.specularColorMap:n.transmissionMap?o=n.transmissionMap:n.thicknessMap?o=n.thicknessMap:n.sheenColorMap?o=n.sheenColorMap:n.sheenRoughnessMap&&(o=n.sheenRoughnessMap),void 0!==o&&(o.isWebGLRenderTarget&&(o=o.texture),!0===o.matrixAutoUpdate&&o.updateMatrix(),t.uvTransform.value.copy(o.matrix)),n.aoMap?r=n.aoMap:n.lightMap&&(r=n.lightMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),t.uv2Transform.value.copy(r.matrix))}function n(t,n){t.roughness.value=n.roughness,t.metalness.value=n.metalness,n.roughnessMap&&(t.roughnessMap.value=n.roughnessMap),n.metalnessMap&&(t.metalnessMap.value=n.metalnessMap),n.emissiveMap&&(t.emissiveMap.value=n.emissiveMap),n.bumpMap&&(t.bumpMap.value=n.bumpMap,t.bumpScale.value=n.bumpScale,1===n.side&&(t.bumpScale.value*=-1)),n.normalMap&&(t.normalMap.value=n.normalMap,t.normalScale.value.copy(n.normalScale),1===n.side&&t.normalScale.value.negate()),n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias);e.get(n).envMap&&(t.envMapIntensity.value=n.envMapIntensity,t.envMapParallaxType.value=n.envMapParallaxType,t.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),t.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv))}return{refreshFogUniforms:function(e,t){e.fogColor.value.copy(t.color),t.isFog?(e.fogNear.value=t.near,e.fogFar.value=t.far):t.isFogExp2&&(e.fogDensity.value=t.density)},refreshMaterialUniforms:function(i,o,r,a,s){o.ssrParams&&function(e,t){e.invProjectionMatrix.value=t.ssrParams.invProjectionMatrix,e.ssrSourceBuffer.value=t.ssrParams.sourceBuffer.texture,e.ssrDepthBuffer.value=t.ssrParams.depthBuffer.texture,e.ssrBackfaceDepthBuffer.value=t.ssrParams.backfaceDepthBuffer.texture,e.ssrResolution.value.set(t.ssrParams.sourceBuffer.width,t.ssrParams.sourceBuffer.height),e.ssrStride.value=t.ssrParams.stride,e.ssrThickness.value=t.ssrParams.thickness,e.ssrMaxDistance.value=t.ssrParams.maxDistance,e.ssrJitter.value=t.ssrParams.jitter}(i,o),o.isMeshBasicMaterial?t(i,o):o.isMeshLambertMaterial?(t(i,o),function(e,t){t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap)}(i,o)):o.isMeshToonMaterial?(t(i,o),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap);t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(i,o)):o.isMeshPhongMaterial?(t(i,o),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4),t.emissiveMap&&(e.emissiveMap.value=t.emissiveMap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(i,o)):o.isMeshStandardMaterial?(t(i,o),o.isMeshPhysicalMaterial?function(e,t,i){n(e,t),e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap));t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap),t.clearcoatNormalMap&&(e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),e.clearcoatNormalMap.value=t.clearcoatNormalMap,1===t.side&&e.clearcoatNormalScale.value.negate()));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=i.texture,e.transmissionSamplerSize.value.set(i.width,i.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor));e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap);t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap)}(i,o,s):n(i,o)):o.isMeshMatcapMaterial?(t(i,o),function(e,t){t.matcap&&(e.matcap.value=t.matcap);t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(i,o)):o.isMeshDepthMaterial?(t(i,o),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.slopeScaledBias.value=t.slopeScaledBias}(i,o)):o.isMeshDistanceMaterial?(t(i,o),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance,e.slopeScaledBias.value=t.slopeScaledBias}(i,o)):o.isMeshNormalMaterial?(t(i,o),function(e,t){t.bumpMap&&(e.bumpMap.value=t.bumpMap,e.bumpScale.value=t.bumpScale,1===t.side&&(e.bumpScale.value*=-1));t.normalMap&&(e.normalMap.value=t.normalMap,e.normalScale.value.copy(t.normalScale),1===t.side&&e.normalScale.value.negate());t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias)}(i,o)):o.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(i,o),o.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(i,o)):o.isPointsMaterial?function(e,t,n,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*n,e.scale.value=.5*i,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let o;t.map?o=t.map:t.alphaMap&&(o=t.alphaMap);void 0!==o&&(!0===o.matrixAutoUpdate&&o.updateMatrix(),e.uvTransform.value.copy(o.matrix))}(i,o,r,a):o.isSpriteMaterial?function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map);t.alphaMap&&(e.alphaMap.value=t.alphaMap);t.alphaTest>0&&(e.alphaTest.value=t.alphaTest);let n;t.map?n=t.map:t.alphaMap&&(n=t.alphaMap);void 0!==n&&(!0===n.matrixAutoUpdate&&n.updateMatrix(),e.uvTransform.value.copy(n.matrix))}(i,o):o.isShadowMaterial?(i.color.value.copy(o.color),i.opacity.value=o.opacity):o.isMeshMaskMaterial?(t(i,o),function(e,t){t.displacementMap&&(e.displacementMap.value=t.displacementMap,e.displacementScale.value=t.displacementScale,e.displacementBias.value=t.displacementBias);t.cameraNearFar&&(e.cameraNearFar.value=t.cameraNearFar);e.depthTexture.value=t.depthTexture,t.textureMatrix&&(e.textureMatrix.value=t.textureMatrix)}(i,o)):o.isMeshNodeMaterial?function(t,n){n.alphaTest>0&&(t.alphaTest.value=n.alphaTest);const i=e.get(n).envMap;if(i){t.envMap.value=i,t.flipEnvMap.value=i.isCubeTexture&&i.isRenderTargetTexture?-1:1,t.reflectivity.value=n.reflectivity,t.refractionRatio.value=n.refractionRatio;const o=e.get(i).__maxMipLevel;void 0!==o&&(t.maxMipLevel.value=o),t.envMapIntensity.value=n.envMapIntensity,t.envMapParallaxType.value=n.envMapParallaxType,t.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),t.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv)}n.displacementMap&&(t.displacementMap.value=n.displacementMap,t.displacementScale.value=n.displacementScale,t.displacementBias.value=n.displacementBias);t.materialIndex.value=n.materialIndex}(i,o):o.isMeshLineMaterial?function(e,t){e.lineWidth.value=t.lineWidth,e.sizeAttenuation.value=t.sizeAttenuation,e.color.value=t.color,e.opacity.value=t.opacity,e.useMap.value=t.useMap,t.map&&(e.map.value=t.map);e.useAlphaMap.value=t.useAlphaMap,t.alphaMap&&(e.alphaMap.value=t.alphaMap);e.visibility.value=t.visibility,e.alphaTest.value=t.alphaTest,e.repeat.value=t.repeat}(i,o):o.isShaderMaterial&&(o.uniformsNeedUpdate=!1)},refreshGTAOUniforms:function(e,t){e.gtaoMap.value=t},refreshPlaneReflProbeUniforms:function(e,t){e.planeReflTexture.value=t.renderTarget.texture,e.planeReflTextureMatrix.value.copy(t.textureMatrix),e.planeReflDir.value.copy(t.normal),e.planeReflBoundingBoxMin.value.copy(t.boundingBox.min),e.planeReflBoundingBoxMax.value.copy(t.boundingBox.max),e.planeReflInvModelMatrix.value.copy(t.matrixWorldInverse),e.planeReflFalloff.value=t.falloff}}}const ls={checkWebGL:function(){try{const e=document.createElement("canvas");return!(!window.WebGLRenderingContext||!e.getContext("webgl")&&!e.getContext("experimental-webgl"))}catch(e){return!1}},checkWebGL2:function(){try{const e=document.createElement("canvas");return!(!window.WebGL2RenderingContext||!e.getContext("webgl2"))}catch(e){return!1}},checkWorkers:function(){return!!window.Worker},checkFileAPI:function(){return window.File&&window.FileReader&&window.FileList&&window.Blob},genWebGLErrorMessage:function(){const e=document.createElement("div");return e.setAttribute("class","v3d-webgl-error"),e.innerHTML=window.WebGLRenderingContext?["Ouch! Your graphics card does not support WebGL.
",'Find out how to fix it here.'].join("\n"):["Ouch! Your browser does not support WebGL.
",'Find out how to fix it here.'].join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild(ls.genWebGLErrorMessage());const t=document.getElementById("v3d_preloader_container");t&&(t.style.visibility="hidden")},checkIOS:function(){return(/iPad|iPhone|iPod/.test(navigator.platform)||"MacIntel"===navigator.platform&&navigator.maxTouchPoints>1)&&!window.MSStream},checkAndroid:function(){return!!navigator.userAgent.match(/Android/i)},checkSafari:function(){return/Safari/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)},checkFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float")||t&&!n.getExtension("OES_texture_float_linear"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_float")||t&&!n.getExtension("OES_texture_float_linear"))},checkHalfFloatTex:function(e,t){const n=e.getContext();return!(!e.capabilities.isWebGL2||!n.getExtension("EXT_color_buffer_float"))||!(e.capabilities.isWebGL2||!n.getExtension("OES_texture_half_float")||t&&!n.getExtension("OES_texture_half_float_linear"))},checkHalfFloatReadPixels:function(e){const t=e.getContext(),n=e.capabilities;return!/Firefox/.test(navigator.userAgent)&&!!(t.getExtension("EXT_color_buffer_half_float")||n.isWebGL2&&t.getExtension("EXT_color_buffer_float"))},checkFloatReadPixels:function(e){const t=e.getContext();return!!(e.capabilities.isWebGL2||t.getExtension("OES_texture_float")||t.getExtension("WEBGL_color_buffer_float"))},checkDepthTex:function(e){const t=e.getContext();return!(!e.capabilities.isWebGL2&&!t.getExtension("WEBGL_depth_texture"))},getGPUVendor:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");if(/Firefox/.test(navigator.userAgent))return t.getParameter(7936);{const e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_VENDOR_WEBGL):""}},getGPUModel:function(e){const t=e?e.getContext():document.createElement("canvas").getContext("webgl")||document.createElement("canvas").getContext("experimental-webgl");if(/Firefox/.test(navigator.userAgent))return t.getParameter(7937);{const e=t.getExtension("WEBGL_debug_renderer_info");return null!=e?t.getParameter(e.UNMASKED_RENDERER_WEBGL):""}},checkWebXR:function(e,t,n){"xr"in navigator&&navigator.xr.isSessionSupported?navigator.xr.isSessionSupported(e).then((function(e){e?t():n()})).catch(n):n()},checkNativeWebXR:function(){return!1},checkCardboard:function(){return!1},checkSwiftShader:function(e){return"Google SwiftShader"==this.getGPUModel(e)},checkWebAudio:function(){return void 0!==(window.AudioContext||window.webkitAudioContext)},isSafariWithMultisamplingBug:function(){const e=navigator.userAgent;return!(!this.checkSafari()&&!e.match("MicroMessenger"))&&(e.match("Version/15.4")||e.match(/CPU (OS|iPhone OS) (15_4|15_4_1|15_4_2|15_4_3) like Mac OS X/))}};function cs(e={}){const t=void 0!==e.canvas?e.canvas:function(){const e=at("canvas");return e.style.display="block",e}(),n=void 0!==e.context?e.context:null,i=void 0!==e.alpha&&e.alpha,o=void 0===e.depth||e.depth,r=void 0===e.stencil||e.stencil,a=void 0!==e.antialias&&e.antialias,s=void 0===e.premultipliedAlpha||e.premultipliedAlpha,l=void 0!==e.preserveDrawingBuffer&&e.preserveDrawingBuffer,c=void 0!==e.powerPreference?e.powerPreference:"default",u=void 0!==e.failIfMajorPerformanceCaveat&&e.failIfMajorPerformanceCaveat;let d=null,h=null;const p=[],f=[];this.domElement=t,this.debug={checkShaderErrors:!0,disableCompiledShaderCache:!1},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.outputEncoding=ve,this.physicallyCorrectLights=!1,this.unitsScaleFactor=1,this.toneMapping=1,this.toneMappingExposure=1,this.gtaoMap=null,this.gtaoMapEnabled=!1,this.compatSettings={useSpecEnvBlenderApprox:!0,saturateSpecEnvBlenderApprox:!1,gtaoDisableBkgFix:!1};const m=this;let v=!1,_=0,x=0,y=null,b=-1,S=null;const w=new Et,I=new Et;let L=null,B=t.width,P=t.height,D=1,N=null,O=null;const F=new Et(0,0,B,P),U=new Et(0,0,B,P);let z=!1;const V=new $i;let G=!1,k=!1,Q=null;const W=new un,H=new Bt,j={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},Y=new un,X=new un,K=new et,q=new Et,Z=new un;function J(){return null===y?D:1}let $,ee,te,ne,ie,oe,re,ae,se,le,ce,ue,de,he,pe,fe,me,ge,Ae,_e,xe,ye,be,Me=n;function Ce(e,n){for(let i=0;i{if(null===e.influenceGroup)return e.intersectsMesh(o);return o.groupNames.includes(e.influenceGroup)^e.influenceGroupInv}))||t.worldEnvMapProbe;if(e){var l;i.envMap=(null==(l=e.renderTarget)?void 0:l.texture)||null;const t=e.parallaxDistance;i.envMapParallaxMatrix.copy(e.matrixWorldInverse).premultiply(Z.makeScale(1/t,1/t,1/t)),i.envMapParallaxMatrixInv.copy(e.matrixWorld).multiply(Z.makeScale(t,t,t)),i.envMapParallaxType=e.parallaxType}}const c=((i.isMeshStandardMaterial||i.isMeshNodeMaterial)&&i.envMap&&!i.envMap.isCubeTexture?ae:re).get(i.envMap||a),u=!0===i.vertexColors&&o.geometry&&o.geometry.attributes.color&&4===o.geometry.attributes.color.itemSize,d=!!i.normalMap&&!!n.attributes.tangent,p=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,g=n.morphAttributes.position?n.morphAttributes.position.length:0,v=i.toneMapped?m.toneMapping:0,A=1===i.side,_=ie.get(i),x=h.state.lights;if(!0===G&&(!0===k||e!==S)){const t=e===S&&i.id===b;fe.setState(i,e,t)}const M=ke(o,i,h),C=i.isMeshNodeMaterial&&i.canUseGTAO()&&m.canUseGTAO();let E=!1,T=!1;if(i.version===_.__version)_.needsLights&&_.lightsStateVersion!==x.state.version||_.outputEncoding!==s||o.isInstancedMesh&&!1===_.instancing?E=!0:o.isInstancedMesh||!0!==_.instancing?o.isSkinnedMesh&&!1===_.skinning?E=!0:o.isSkinnedMesh||!0!==_.skinning?_.envMap!==c?(E=!0,T=!0):i.fog&&_.fog!==r?E=!0:void 0===_.numClippingPlanes||_.numClippingPlanes===fe.numPlanes&&_.numIntersection===fe.numIntersection?(_.vertexAlphas!==u||_.vertexTangents!==d||_.morphTargets!==p||_.morphNormals!==f||_.toneMapping!==v||!0===ee.isWebGL2&&_.morphTargetsCount!==g||_.planeReflProbe!==M||i.isMeshNormalMaterial&&_.flipSided!==A||_.useGTAO!==C)&&(E=!0):E=!0:E=!0:E=!0;else if(E=!0,_.__version=i.version,i.nodeRGBArr)for(let e=0;e{e.isLight?(n.pushLight(e),e.castShadow&&n.pushShadow(e)):e.isCubeReflectionProbe?n.pushEnvMapProbe(e):e.isPlaneReflectionProbe&&n.pushPlaneReflProbe(e)})),n.setupLights(m.physicallyCorrectLights),n.sortEnvMapProbes();let i=null;return null!==e.worldEnvMapProbe&&null!==e.worldEnvMapProbe.renderTarget&&(i=e.worldEnvMapProbe.renderTarget.texture),e.traverse((e=>{if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((t=>{(t.isMeshStandardMaterial||t.isMeshPhysicalMaterial||t.isMeshNodeMaterial)&&(e.material.envMap=i,e.material.needsUpdate=!0)}))}})),n},this.compile=function(e,t){this.gtaoMapEnabled=!0;const n=pe.get(e,f.length);this._compilePrepareRenderState(e,t,n);const i={};e.traverse((function(t){const o=t.material;if(o)if(Array.isArray(o))for(let r=0;r0&&function(e,t,n){if(null===Q){const e=!0===a&&!0===ee.isWebGL2;Q=new(e?Rt:Tt)(1024,1024,{generateMipmaps:!0,type:null!==ye.convert(T)?T:C,minFilter:M,magFilter:A,wrapS:g,wrapT:g,useRenderToTexture:$.has("WEBGL_multisampled_render_to_texture")})}const i=m.getRenderTarget();m.setRenderTarget(Q),m.clear();const o=m.toneMapping;m.toneMapping=0,Fe(e,t,n),m.toneMapping=o,oe.updateMultisampleRenderTarget(Q),oe.updateRenderTargetMipmap(Q),m.setRenderTarget(i)}(o,t,n),i&&te.viewport(w.copy(i)),o.length>0&&Fe(o,t,n),r.length>0&&Fe(r,t,n),s.length>0&&Fe(s,t,n)}function Fe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let o=0,r=e.length;ot.intersectsMesh(e)))||null}De.setAnimationLoop((function(e){Re&&Re(e)})),"undefined"!=typeof window&&De.setContext(window),this.setAnimationLoop=function(e){Re=e,we.setAnimationLoop(e),null===e?De.stop():De.start()},we.addEventListener("sessionstart",Be),we.addEventListener("sessionend",Pe),this.render=function(e,t){if(void 0!==t&&!0!==t.isCamera)return void console.error("v3d.WebGLRenderer.render: camera is not an instance of v3d.Camera.");if(!0===v)return;!0===e.autoUpdate&&e.updateMatrixWorld(),null===t.parent&&t.updateMatrixWorld(),!0===we.enabled&&!0===we.isPresenting&&(!0===we.cameraAutoUpdate&&we.updateCamera(t),t=we.getCamera()),!0===e.isScene&&e.onBeforeRender(m,e,t,y),h=pe.get(e,f.length),h.init(),f.push(h),W.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),V.setFromProjectionMatrix(W),k=this.localClippingEnabled,G=fe.init(this.clippingPlanes,k,t),d=he.get(e,p.length),d.init(),p.push(d),Ne(e,t,0,m.sortObjects),d.finish(),!0===m.sortObjects&&d.sort(N,O),!0===G&&fe.beginShadows();const n=h.state.shadowsArray;if(me.render(n,e,t),!0===G&&fe.endShadows(),!0===this.info.autoReset&&this.info.reset(),ge.render(d,e),h.setupLights(m.physicallyCorrectLights),h.sortEnvMapProbes(),t.isArrayCamera){const n=t.cameras;for(let t=0,i=n.length;t0?f[f.length-1]:null,p.pop(),d=p.length>0?p[p.length-1]:null},this.getActiveCubeFace=function(){return _},this.getActiveMipmapLevel=function(){return x},this.getRenderTarget=function(){return y},this.setRenderTargetTextures=function(e,t,n){ie.get(e.texture).__webglTexture=t,ie.get(e.depthTexture).__webglTexture=n;const i=ie.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||e.useRenderToTexture&&(console.warn("render-to-texture extension was disabled because an external texture was provided"),e.useRenderToTexture=!1,e.useRenderbuffer=!0))},this.setRenderTargetFramebuffer=function(e,t){const n=ie.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){y=e,_=t,x=n;let i=!0;if(e){const t=ie.get(e);void 0!==t.__useDefaultFramebuffer?(te.bindFramebuffer(36160,null),i=!1):void 0===t.__webglFramebuffer?oe.setupRenderTarget(e):t.__hasExternalTextures&&oe.rebindTextures(e,ie.get(e.texture).__webglTexture,ie.get(e.depthTexture).__webglTexture)}let o=null,r=!1,a=!1;if(e){const n=e.texture;(n.isDataTexture3D||n.isDataTexture2DArray)&&(a=!0);const i=ie.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(o=i[t],r=!0):o=e.useRenderbuffer?ie.get(e).__webglMultisampledFramebuffer:i,w.copy(e.viewport),I.copy(e.scissor),L=e.scissorTest}else w.copy(F).multiplyScalar(D).floor(),I.copy(U).multiplyScalar(D).floor(),L=z;if(te.bindFramebuffer(36160,o)&&ee.drawBuffers&&i&&te.drawBuffers(e,o),te.viewport(w),te.scissor(I),te.setScissorTest(L),r){const i=ie.get(e.texture);Me.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(a){const i=ie.get(e.texture),o=t||0;Me.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,o)}b=-1},this.readRenderTargetPixels=function(e,t,n,i,o,r,a){if(!e||!e.isWebGLRenderTarget)return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not v3d.WebGLRenderTarget.");let s=ie.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){te.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==R&&ye.convert(s)!==Me.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===T&&($.has("EXT_color_buffer_half_float")||ee.isWebGL2&&$.has("EXT_color_buffer_float"));if(!(l===C||ye.convert(l)===Me.getParameter(35738)||l===E&&(ee.isWebGL2||$.has("OES_texture_float")||$.has("WEBGL_color_buffer_float"))||c))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");36053===Me.checkFramebufferStatus(36160)?t>=0&&t<=e.width-i&&n>=0&&n<=e.height-o&&Me.readPixels(t,n,i,o,ye.convert(s),ye.convert(l),r):console.error("v3d.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.")}finally{const e=null!==y?ie.get(y).__webglFramebuffer:null;te.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){if(!0!==t.isFramebufferTexture)return void console.error("v3d.WebGLRenderer: copyFramebufferToTexture() can only be used with FramebufferTexture.");const i=Math.pow(2,-n),o=Math.floor(t.image.width*i),r=Math.floor(t.image.height*i);oe.setTexture2D(t,0),Me.copyTexSubImage2D(3553,n,0,0,e.x,e.y,o,r),te.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const o=t.image.width,r=t.image.height,a=ye.convert(n.format),s=ye.convert(n.type);oe.setTexture2D(n,0),Me.pixelStorei(37440,n.flipY),Me.pixelStorei(37441,n.premultiplyAlpha),Me.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?Me.texSubImage2D(3553,i,e.x,e.y,o,r,a,s,t.image.data):t.isCompressedTexture?Me.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Me.texSubImage2D(3553,i,e.x,e.y,a,s,t.image),0===i&&n.generateMipmaps&&Me.generateMipmap(3553),te.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,o=0){if(m.isWebGL1Renderer)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: can only be used with WebGL2.");const r=e.max.x-e.min.x+1,a=e.max.y-e.min.y+1,s=e.max.z-e.min.z+1,l=ye.convert(i.format),c=ye.convert(i.type);let u;if(i.isDataTexture3D)oe.setTexture3D(i,0),u=32879;else{if(!i.isDataTexture2DArray)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: only supports v3d.DataTexture3D and v3d.DataTexture2DArray.");oe.setTexture2DArray(i,0),u=35866}Me.pixelStorei(37440,i.flipY),Me.pixelStorei(37441,i.premultiplyAlpha),Me.pixelStorei(3317,i.unpackAlignment);const d=Me.getParameter(3314),h=Me.getParameter(32878),p=Me.getParameter(3316),f=Me.getParameter(3315),g=Me.getParameter(32877),v=n.isCompressedTexture?n.mipmaps[0]:n.image;Me.pixelStorei(3314,v.width),Me.pixelStorei(32878,v.height),Me.pixelStorei(3316,e.min.x),Me.pixelStorei(3315,e.min.y),Me.pixelStorei(32877,e.min.z),n.isDataTexture||n.isDataTexture3D?Me.texSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,c,v.data):n.isCompressedTexture?(console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Me.compressedTexSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,v.data)):Me.texSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,c,v),Me.pixelStorei(3314,d),Me.pixelStorei(32878,h),Me.pixelStorei(3316,p),Me.pixelStorei(3315,f),Me.pixelStorei(32877,g),0===o&&i.generateMipmaps&&Me.generateMipmap(u),te.unbindTexture()},this.initTexture=function(e){oe.setTexture2D(e,0),te.unbindTexture()},this.resetState=function(){_=0,x=0,y=null,te.reset(),be.reset()},"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.updateGeometry=function(e){return ce.update(e)}}cs.prototype.isWebGLRenderer=!0;class us extends cs{}us.prototype.isWebGL1Renderer=!0;class ds{constructor(e,t=25e-5){this.name="",this.color=new yt(e),this.density=t}clone(){return new ds(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}ds.prototype.isFogExp2=!0;class hs{constructor(e,t=1,n=1e3){this.name="",this.color=new yt(e),this.near=t,this.far=n}clone(){return new hs(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}hs.prototype.isFog=!0;class ps{constructor(e,t){this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=we,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=Fe()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}setUsage(e){return this.usage=e,this}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let i=0,o=this.stride;ie.far||t.push({distance:s,point:As.clone(),uv:jn.getUV(As,Cs,Ss,ws,Es,Ts,Is,new et),face:null,object:this})}copy(e){return super.copy(e),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Ls(e,t,n,i,o,r){ys.subVectors(e,n).addScalar(.5).multiply(i),void 0!==o?(bs.x=r*ys.x-o*ys.y,bs.y=o*ys.x+r*ys.y):bs.copy(ys),e.copy(t),e.x+=bs.x,e.y+=bs.y,e.applyMatrix4(Ms)}Rs.prototype.isSprite=!0;const Bs=new Bt,Ps=new Bt;class Ds extends Nn{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,n=t.length;e0){let n,i;for(n=1,i=t.length;n0){Bs.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(Bs);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Bs.setFromMatrixPosition(e.matrixWorld),Ps.setFromMatrixPosition(this.matrixWorld);const n=Bs.distanceTo(Ps)/e.zoom;let i,o;for(t[0].object.visible=!0,i=1,o=t.length;i=t[i].distance;i++)t[i-1].object.visible=!1,t[i].object.visible=!0;for(this._currentLevel=i-1;is)continue;d.applyMatrix4(this.matrixWorld);const h=e.ray.origin.distanceTo(d);he.far||t.push({distance:h,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}else{for(let n=Math.max(0,r.start),i=Math.min(o.count,r.start+r.count)-1;ns)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);ie.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}else n.isGeometry&&console.error("v3d.Line.raycast() no longer supports v3d.Geometry. Use v3d.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,n=Object.keys(t);if(n.length>0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("v3d.Line.updateMorphTargets() does not support v3d.Geometry. Use v3d.BufferGeometry instead.")}}}ol.prototype.isLine=!0;const rl=new Bt,al=new Bt;class sl extends ol{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e0){const e=t[n[0]];if(void 0!==e){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t0&&console.error("v3d.Points.updateMorphTargets() does not support v3d.Geometry. Use v3d.BufferGeometry instead.")}}}function ml(e,t,n,i,o,r,a){const s=dl.distanceSqToPoint(e);if(so.far)return;r.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}fl.prototype.isPoints=!0;class gl extends St{constructor(e,t,n,i,o,r,a,s,l){super(e,t,n,i,o,r,a,s,l),this.minFilter=void 0!==r?r:y,this.magFilter=void 0!==o?o:y,this.generateMipmaps=!1;const c=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){c.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}gl.prototype.isVideoTexture=!0;class vl extends St{constructor(e,t,n){super({width:e,height:t}),this.format=n,this.magFilter=A,this.minFilter=A,this.generateMipmaps=!1,this.needsUpdate=!0}}vl.prototype.isFramebufferTexture=!0;class Al extends St{constructor(e,t,n,i,o,r,a,s,l,c,u,d){super(null,r,a,s,l,c,i,o,u,d),this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}Al.prototype.isCompressedTexture=!0;class _l extends St{constructor(e,t,n,i,o,r,a,s,l){super(e,t,n,i,o,r,a,s,l),this.needsUpdate=!0}}_l.prototype.isCanvasTexture=!0;class xl extends gi{constructor(e=1,t=8,n=0,i=2*Math.PI){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:i},t=Math.max(3,t);const o=[],r=[],a=[],s=[],l=new Bt,c=new et;r.push(0,0,0),a.push(0,0,1),s.push(.5,.5);for(let o=0,u=3;o<=t;o++,u+=3){const d=n+o/t*i;l.x=e*Math.cos(d),l.y=e*Math.sin(d),r.push(l.x,l.y,l.z),a.push(0,0,1),c.x=(r[u]/e+1)/2,c.y=(r[u+1]/e+1)/2,s.push(c.x,c.y)}for(let e=1;e<=t;e++)o.push(e,e+1,0);this.setIndex(o),this.setAttribute("position",new si(r,3)),this.setAttribute("normal",new si(a,3)),this.setAttribute("uv",new si(s,2))}static fromJSON(e){return new xl(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class yl extends gi{constructor(e=1,t=1,n=1,i=8,o=1,r=!1,a=0,s=2*Math.PI){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:i,heightSegments:o,openEnded:r,thetaStart:a,thetaLength:s};const l=this;i=Math.floor(i),o=Math.floor(o);const c=[],u=[],d=[],h=[];let p=0;const f=[],m=n/2;let g=0;function v(n){const o=p,r=new et,f=new Bt;let v=0;const A=!0===n?e:t,_=!0===n?1:-1;for(let e=1;e<=i;e++)u.push(0,m*_,0),d.push(0,_,0),h.push(.5,.5),p++;const x=p;for(let e=0;e<=i;e++){const t=e/i*s+a,n=Math.cos(t),o=Math.sin(t);f.x=A*o,f.y=m*_,f.z=A*n,u.push(f.x,f.y,f.z),d.push(0,_,0),r.x=.5*n+.5,r.y=.5*o*_+.5,h.push(r.x,r.y),p++}for(let e=0;e0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new si(u,3)),this.setAttribute("normal",new si(d,3)),this.setAttribute("uv",new si(h,2))}static fromJSON(e){return new yl(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class bl extends yl{constructor(e=1,t=1,n=8,i=1,o=!1,r=0,a=2*Math.PI){super(0,e,t,n,i,o,r,a),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:i,openEnded:o,thetaStart:r,thetaLength:a}}static fromJSON(e){return new bl(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ml extends gi{constructor(e=[],t=[],n=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:i};const o=[],r=[];function a(e,t,n,i){const o=i+1,r=[];for(let i=0;i<=o;i++){r[i]=[];const a=e.clone().lerp(n,i/o),s=t.clone().lerp(n,i/o),l=o-i;for(let e=0;e<=l;e++)r[i][e]=0===e&&i===o?a:a.clone().lerp(s,e/l)}for(let e=0;e.9&&a<.1&&(t<.2&&(r[e+0]+=1),n<.2&&(r[e+2]+=1),i<.2&&(r[e+4]+=1))}}()}(),this.setAttribute("position",new si(o,3)),this.setAttribute("normal",new si(o.slice(),3)),this.setAttribute("uv",new si(r,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new Ml(e.vertices,e.indices,e.radius,e.details)}}class Cl extends Ml{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,i=1/n;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-n,0,-i,n,0,i,-n,0,i,n,-i,-n,0,-i,n,0,i,-n,0,i,n,0,-n,0,-i,n,0,-i,-n,0,i,n,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Cl(e.radius,e.detail)}}const Sl=new Bt,wl=new Bt,El=new Bt,Tl=new jn;class Il extends gi{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const n=4,i=Math.pow(10,n),o=Math.cos(Ne*t),r=e.getIndex(),a=e.getAttribute("position"),s=r?r.count:a.count,l=[0,0,0],c=["a","b","c"],u=new Array(3),d={},h=[];for(let e=0;e0)){l=i;break}l=i-1}if(i=l,n[i]===r)return i/(o-1);const c=n[i];return(i+(r-c)/(n[i+1]-c))/(o-1)}getTangent(e,t){const n=1e-4;let i=e-n,o=e+n;i<0&&(i=0),o>1&&(o=1);const r=this.getPoint(i),a=this.getPoint(o),s=t||(r.isVector2?new et:new Bt);return s.copy(a).sub(r).normalize(),s}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t){const n=new Bt,i=[],o=[],r=[],a=new Bt,s=new un;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new Bt)}o[0]=new Bt,r[0]=new Bt;let l=Number.MAX_VALUE;const c=Math.abs(i[0].x),u=Math.abs(i[0].y),d=Math.abs(i[0].z);c<=l&&(l=c,n.set(1,0,0)),u<=l&&(l=u,n.set(0,1,0)),d<=l&&n.set(0,0,1),a.crossVectors(i[0],n).normalize(),o[0].crossVectors(i[0],a),r[0].crossVectors(i[0],o[0]);for(let t=1;t<=e;t++){if(o[t]=o[t-1].clone(),r[t]=r[t-1].clone(),a.crossVectors(i[t-1],i[t]),a.length()>Number.EPSILON){a.normalize();const e=Math.acos(Ue(i[t-1].dot(i[t]),-1,1));o[t].applyMatrix4(s.makeRotationAxis(a,e))}r[t].crossVectors(i[t],o[t])}if(!0===t){let t=Math.acos(Ue(o[0].dot(o[e]),-1,1));t/=e,i[0].dot(a.crossVectors(o[0],o[e]))>0&&(t=-t);for(let n=1;n<=e;n++)o[n].applyMatrix4(s.makeRotationAxis(i[n],t*n)),r[n].crossVectors(i[n],o[n])}return{tangents:i,normals:o,binormals:r}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Ll extends Rl{constructor(e=0,t=0,n=1,i=1,o=0,r=2*Math.PI,a=!1,s=0){super(),this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=i,this.aStartAngle=o,this.aEndAngle=r,this.aClockwise=a,this.aRotation=s}getPoint(e,t){const n=t||new et,i=2*Math.PI;let o=this.aEndAngle-this.aStartAngle;const r=Math.abs(o)i;)o-=i;o0?0:(Math.floor(Math.abs(l)/o)+1)*o:0===c&&l===o-1&&(l=o-2,c=1),this.closed||l>0?a=i[(l-1)%o]:(Dl.subVectors(i[0],i[1]).add(i[0]),a=Dl);const u=i[l%o],d=i[(l+1)%o];if(this.closed||l+2i.length-2?i.length-1:r+1],u=i[r>i.length-3?i.length-1:r+2];return n.set(zl(a,s.x,l.x,c.x,u.x),zl(a,s.y,l.y,c.y,u.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t=n){const e=i[o]-n,r=this.curves[o],a=r.getLength(),s=0===a?0:1-e/a;return r.getPointAt(s,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,i=this.curves.length;n1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t0){const e=l.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(l);const c=l.getPoint(1);return this.currentPoint.copy(c),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class Jl extends Zl{constructor(e){super(e),this.uuid=Fe(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n80*n){s=c=e[0],l=u=e[1];for(let t=n;tc&&(c=d),h>u&&(u=h);p=Math.max(c-s,u-l),p=0!==p?1/p:0}return nc(r,a,n,s,l,p),a};function ec(e,t,n,i,o){let r,a;if(o===function(e,t,n,i){let o=0;for(let r=t,a=n-i;r0)for(r=t;r=t;r-=i)a=yc(r,e[r],e[r+1],a);return a&&mc(a,a.next)&&(bc(a),a=a.next),a}function tc(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!mc(i,i.next)&&0!==fc(i.prev,i,i.next))i=i.next;else{if(bc(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function nc(e,t,n,i,o,r,a){if(!e)return;!a&&r&&function(e,t,n,i){let o=e;do{null===o.z&&(o.z=uc(o.x,o.y,t,n,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,function(e){let t,n,i,o,r,a,s,l,c=1;do{for(n=e,e=null,r=null,a=0;n;){for(a++,i=n,s=0,t=0;t0||l>0&&i;)0!==s&&(0===l||!i||n.z<=i.z)?(o=n,n=n.nextZ,s--):(o=i,i=i.nextZ,l--),r?r.nextZ=o:e=o,o.prevZ=r,r=o;n=i}r.nextZ=null,c*=2}while(a>1)}(o)}(e,i,o,r);let s,l,c=e;for(;e.prev!==e.next;)if(s=e.prev,l=e.next,r?oc(e,i,o,r):ic(e))t.push(s.i/n),t.push(e.i/n),t.push(l.i/n),bc(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?nc(e=rc(tc(e),t,n),t,n,i,o,r,2):2===a&&ac(e,t,n,i,o,r):nc(tc(e),t,n,i,o,r,1);break}}function ic(e){const t=e.prev,n=e,i=e.next;if(fc(t,n,i)>=0)return!1;let o=e.next.next;for(;o!==e.prev;){if(hc(t.x,t.y,n.x,n.y,i.x,i.y,o.x,o.y)&&fc(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function oc(e,t,n,i){const o=e.prev,r=e,a=e.next;if(fc(o,r,a)>=0)return!1;const s=o.xr.x?o.x>a.x?o.x:a.x:r.x>a.x?r.x:a.x,u=o.y>r.y?o.y>a.y?o.y:a.y:r.y>a.y?r.y:a.y,d=uc(s,l,t,n,i),h=uc(c,u,t,n,i);let p=e.prevZ,f=e.nextZ;for(;p&&p.z>=d&&f&&f.z<=h;){if(p!==e.prev&&p!==e.next&&hc(o.x,o.y,r.x,r.y,a.x,a.y,p.x,p.y)&&fc(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,f!==e.prev&&f!==e.next&&hc(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&fc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(;p&&p.z>=d;){if(p!==e.prev&&p!==e.next&&hc(o.x,o.y,r.x,r.y,a.x,a.y,p.x,p.y)&&fc(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;f&&f.z<=h;){if(f!==e.prev&&f!==e.next&&hc(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&fc(f.prev,f,f.next)>=0)return!1;f=f.nextZ}return!0}function rc(e,t,n){let i=e;do{const o=i.prev,r=i.next.next;!mc(o,r)&&gc(o,i,i.next,r)&&_c(o,r)&&_c(r,o)&&(t.push(o.i/n),t.push(i.i/n),t.push(r.i/n),bc(i),bc(i.next),i=e=r),i=i.next}while(i!==e);return tc(i)}function ac(e,t,n,i,o,r){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&pc(a,e)){let s=xc(a,e);return a=tc(a,a.next),s=tc(s,s.next),nc(a,t,n,i,o,r),void nc(s,t,n,i,o,r)}e=e.next}a=a.next}while(a!==e)}function sc(e,t){return e.x-t.x}function lc(e,t){if(t=function(e,t){let n=t;const i=e.x,o=e.y;let r,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){const e=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=i&&e>a){if(a=e,e===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x=n.x&&n.x>=l&&i!==n.x&&hc(or.x||n.x===r.x&&cc(r,n)))&&(r=n,d=u)),n=n.next}while(n!==s);return r}(e,t),t){const n=xc(t,e);tc(t,t.next),tc(n,n.next)}}function cc(e,t){return fc(e.prev,e,t.prev)<0&&fc(t.next,e,e.next)<0}function uc(e,t,n,i,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*o)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-i)*o)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function dc(e){let t=e,n=e;do{(t.x=0&&(e-a)*(i-s)-(n-a)*(t-s)>=0&&(n-a)*(r-s)-(o-a)*(i-s)>=0}function pc(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&gc(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(_c(e,t)&&_c(t,e)&&function(e,t){let n=e,i=!1;const o=(e.x+t.x)/2,r=(e.y+t.y)/2;do{n.y>r!=n.next.y>r&&n.next.y!==n.y&&o<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==e);return i}(e,t)&&(fc(e.prev,e,t.prev)||fc(e,t.prev,t))||mc(e,t)&&fc(e.prev,e,e.next)>0&&fc(t.prev,t,t.next)>0)}function fc(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function mc(e,t){return e.x===t.x&&e.y===t.y}function gc(e,t,n,i){const o=Ac(fc(e,t,n)),r=Ac(fc(e,t,i)),a=Ac(fc(n,i,e)),s=Ac(fc(n,i,t));return o!==r&&a!==s||(!(0!==o||!vc(e,n,t))||(!(0!==r||!vc(e,i,t))||(!(0!==a||!vc(n,e,i))||!(0!==s||!vc(n,t,i)))))}function vc(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Ac(e){return e>0?1:e<0?-1:0}function _c(e,t){return fc(e.prev,e,e.next)<0?fc(e,t,e.next)>=0&&fc(e,e.prev,t)>=0:fc(e,t,e.prev)<0||fc(e,e.next,t)<0}function xc(e,t){const n=new Mc(e.i,e.x,e.y),i=new Mc(t.i,t.x,t.y),o=e.next,r=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,i.next=n,n.prev=i,r.next=i,i.prev=r,i}function yc(e,t,n,i){const o=new Mc(e,t,n);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function bc(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Mc(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}class Cc{static area(e){const t=e.length;let n=0;for(let i=t-1,o=0;o2&&e[t-1].equals(e[0])&&e.pop()}function wc(e,t){for(let n=0;nNumber.EPSILON){const d=Math.sqrt(u),h=Math.sqrt(l*l+c*c),p=t.x-s/d,f=t.y+a/d,m=((n.x-c/h-p)*c-(n.y+l/h-f)*l)/(a*c-s*l);i=p+a*m-e.x,o=f+s*m-e.y;const g=i*i+o*o;if(g<=2)return new et(i,o);r=Math.sqrt(g/2)}else{let e=!1;a>Number.EPSILON?l>Number.EPSILON&&(e=!0):a<-Number.EPSILON?l<-Number.EPSILON&&(e=!0):Math.sign(s)===Math.sign(c)&&(e=!0),e?(i=-s,o=a,r=Math.sqrt(u)):(i=a,o=s,r=Math.sqrt(u/2))}return new et(i/r,o/r)}const L=[];for(let e=0,t=w.length,n=t-1,i=e+1;e=0;e--){const t=e/p,n=u*Math.cos(t*Math.PI/2),i=d*Math.sin(t*Math.PI/2)+h;for(let e=0,t=w.length;e=0;){const i=n;let o=n-1;o<0&&(o=e.length-1);for(let e=0,n=s+2*p;e0)&&h.push(t,o,l),(e!==n-1||s1?.5*s-u:-.5*u+.5*d;break;case"bottom":c=s-u+d;break;case"bottomBaseline":c=r>1?s-u-d:0}(Math.abs(l)>0||Math.abs(c)>0)&&e.translate(l,c,0)}(this,t.alignX||"left",t.alignY||"bottom",e,t.font),this.type="BlenderTextGeometry"}cloneWithText(e){var t=this.parameters.parameters;return new kc(e,{font:t.font,size:t.size,height:t.height,curveSegments:t.curveSegments,bevelEnabled:t.bevelEnabled,bevelThickness:t.bevelThickness,bevelSize:t.bevelSize,alignX:t.alignX,alignY:t.alignY})}}class Qc extends gi{constructor(e=50,t=10,n=!0,i=!0,o=!0,r=!0,a=!0){const s=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,3,16,17,18,7,19,20,21,11,22,23,24,15,25,26,27,18,28,29,30,21,31,32,33,24,34,35,36,27,37,38,39,30,40,41,0,33,42,43,4,36,44,45,8,39,46,47,12,12,13,14,15,48,49,50,51,52,53,54,55,56,57,58,59,15,25,26,27,51,60,61,62,55,63,64,65,59,66,67,68,27,37,38,39,62,69,70,71,65,72,73,74,68,75,76,77,39,46,47,12,71,78,79,48,74,80,81,52,77,82,83,56,56,57,58,59,84,85,86,87,88,89,90,91,92,93,94,95,59,66,67,68,87,96,97,98,91,99,100,101,95,102,103,104,68,75,76,77,98,105,106,107,101,108,109,110,104,111,112,113,77,82,83,56,107,114,115,84,110,116,117,88,113,118,119,92,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,123,136,137,120,127,138,139,124,131,140,141,128,135,142,143,132,132,133,134,135,144,145,146,147,148,149,150,151,68,152,153,154,135,142,143,132,147,155,156,144,151,157,158,148,154,159,160,68,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,164,177,178,161,168,179,180,165,172,181,182,169,176,183,184,173,173,174,175,176,185,186,187,188,189,190,191,192,193,194,195,196,176,183,184,173,188,197,198,185,192,199,200,189,196,201,202,193,203,203,203,203,204,205,206,207,208,208,208,208,209,210,211,212,203,203,203,203,207,213,214,215,208,208,208,208,212,216,217,218,203,203,203,203,215,219,220,221,208,208,208,208,218,222,223,224,203,203,203,203,221,225,226,204,208,208,208,208,224,227,228,209,209,210,211,212,229,230,231,232,233,234,235,236,237,238,239,240,212,216,217,218,232,241,242,243,236,244,245,246,240,247,248,249,218,222,223,224,243,250,251,252,246,253,254,255,249,256,257,258,224,227,228,209,252,259,260,229,255,261,262,233,258,263,264,237,265,265,265,265,266,267,268,269,270,271,272,273,92,119,118,113,265,265,265,265,269,274,275,276,273,277,278,279,113,112,111,104,265,265,265,265,276,280,281,282,279,283,284,285,104,103,102,95,265,265,265,265,282,286,287,266,285,288,289,270,95,94,93,92],l=[1.4,0,2.4,1.4,-.784,2.4,.784,-1.4,2.4,0,-1.4,2.4,1.3375,0,2.53125,1.3375,-.749,2.53125,.749,-1.3375,2.53125,0,-1.3375,2.53125,1.4375,0,2.53125,1.4375,-.805,2.53125,.805,-1.4375,2.53125,0,-1.4375,2.53125,1.5,0,2.4,1.5,-.84,2.4,.84,-1.5,2.4,0,-1.5,2.4,-.784,-1.4,2.4,-1.4,-.784,2.4,-1.4,0,2.4,-.749,-1.3375,2.53125,-1.3375,-.749,2.53125,-1.3375,0,2.53125,-.805,-1.4375,2.53125,-1.4375,-.805,2.53125,-1.4375,0,2.53125,-.84,-1.5,2.4,-1.5,-.84,2.4,-1.5,0,2.4,-1.4,.784,2.4,-.784,1.4,2.4,0,1.4,2.4,-1.3375,.749,2.53125,-.749,1.3375,2.53125,0,1.3375,2.53125,-1.4375,.805,2.53125,-.805,1.4375,2.53125,0,1.4375,2.53125,-1.5,.84,2.4,-.84,1.5,2.4,0,1.5,2.4,.784,1.4,2.4,1.4,.784,2.4,.749,1.3375,2.53125,1.3375,.749,2.53125,.805,1.4375,2.53125,1.4375,.805,2.53125,.84,1.5,2.4,1.5,.84,2.4,1.75,0,1.875,1.75,-.98,1.875,.98,-1.75,1.875,0,-1.75,1.875,2,0,1.35,2,-1.12,1.35,1.12,-2,1.35,0,-2,1.35,2,0,.9,2,-1.12,.9,1.12,-2,.9,0,-2,.9,-.98,-1.75,1.875,-1.75,-.98,1.875,-1.75,0,1.875,-1.12,-2,1.35,-2,-1.12,1.35,-2,0,1.35,-1.12,-2,.9,-2,-1.12,.9,-2,0,.9,-1.75,.98,1.875,-.98,1.75,1.875,0,1.75,1.875,-2,1.12,1.35,-1.12,2,1.35,0,2,1.35,-2,1.12,.9,-1.12,2,.9,0,2,.9,.98,1.75,1.875,1.75,.98,1.875,1.12,2,1.35,2,1.12,1.35,1.12,2,.9,2,1.12,.9,2,0,.45,2,-1.12,.45,1.12,-2,.45,0,-2,.45,1.5,0,.225,1.5,-.84,.225,.84,-1.5,.225,0,-1.5,.225,1.5,0,.15,1.5,-.84,.15,.84,-1.5,.15,0,-1.5,.15,-1.12,-2,.45,-2,-1.12,.45,-2,0,.45,-.84,-1.5,.225,-1.5,-.84,.225,-1.5,0,.225,-.84,-1.5,.15,-1.5,-.84,.15,-1.5,0,.15,-2,1.12,.45,-1.12,2,.45,0,2,.45,-1.5,.84,.225,-.84,1.5,.225,0,1.5,.225,-1.5,.84,.15,-.84,1.5,.15,0,1.5,.15,1.12,2,.45,2,1.12,.45,.84,1.5,.225,1.5,.84,.225,.84,1.5,.15,1.5,.84,.15,-1.6,0,2.025,-1.6,-.3,2.025,-1.5,-.3,2.25,-1.5,0,2.25,-2.3,0,2.025,-2.3,-.3,2.025,-2.5,-.3,2.25,-2.5,0,2.25,-2.7,0,2.025,-2.7,-.3,2.025,-3,-.3,2.25,-3,0,2.25,-2.7,0,1.8,-2.7,-.3,1.8,-3,-.3,1.8,-3,0,1.8,-1.5,.3,2.25,-1.6,.3,2.025,-2.5,.3,2.25,-2.3,.3,2.025,-3,.3,2.25,-2.7,.3,2.025,-3,.3,1.8,-2.7,.3,1.8,-2.7,0,1.575,-2.7,-.3,1.575,-3,-.3,1.35,-3,0,1.35,-2.5,0,1.125,-2.5,-.3,1.125,-2.65,-.3,.9375,-2.65,0,.9375,-2,-.3,.9,-1.9,-.3,.6,-1.9,0,.6,-3,.3,1.35,-2.7,.3,1.575,-2.65,.3,.9375,-2.5,.3,1.125,-1.9,.3,.6,-2,.3,.9,1.7,0,1.425,1.7,-.66,1.425,1.7,-.66,.6,1.7,0,.6,2.6,0,1.425,2.6,-.66,1.425,3.1,-.66,.825,3.1,0,.825,2.3,0,2.1,2.3,-.25,2.1,2.4,-.25,2.025,2.4,0,2.025,2.7,0,2.4,2.7,-.25,2.4,3.3,-.25,2.4,3.3,0,2.4,1.7,.66,.6,1.7,.66,1.425,3.1,.66,.825,2.6,.66,1.425,2.4,.25,2.025,2.3,.25,2.1,3.3,.25,2.4,2.7,.25,2.4,2.8,0,2.475,2.8,-.25,2.475,3.525,-.25,2.49375,3.525,0,2.49375,2.9,0,2.475,2.9,-.15,2.475,3.45,-.15,2.5125,3.45,0,2.5125,2.8,0,2.4,2.8,-.15,2.4,3.2,-.15,2.4,3.2,0,2.4,3.525,.25,2.49375,2.8,.25,2.475,3.45,.15,2.5125,2.9,.15,2.475,3.2,.15,2.4,2.8,.15,2.4,0,0,3.15,.8,0,3.15,.8,-.45,3.15,.45,-.8,3.15,0,-.8,3.15,0,0,2.85,.2,0,2.7,.2,-.112,2.7,.112,-.2,2.7,0,-.2,2.7,-.45,-.8,3.15,-.8,-.45,3.15,-.8,0,3.15,-.112,-.2,2.7,-.2,-.112,2.7,-.2,0,2.7,-.8,.45,3.15,-.45,.8,3.15,0,.8,3.15,-.2,.112,2.7,-.112,.2,2.7,0,.2,2.7,.45,.8,3.15,.8,.45,3.15,.112,.2,2.7,.2,.112,2.7,.4,0,2.55,.4,-.224,2.55,.224,-.4,2.55,0,-.4,2.55,1.3,0,2.55,1.3,-.728,2.55,.728,-1.3,2.55,0,-1.3,2.55,1.3,0,2.4,1.3,-.728,2.4,.728,-1.3,2.4,0,-1.3,2.4,-.224,-.4,2.55,-.4,-.224,2.55,-.4,0,2.55,-.728,-1.3,2.55,-1.3,-.728,2.55,-1.3,0,2.55,-.728,-1.3,2.4,-1.3,-.728,2.4,-1.3,0,2.4,-.4,.224,2.55,-.224,.4,2.55,0,.4,2.55,-1.3,.728,2.55,-.728,1.3,2.55,0,1.3,2.55,-1.3,.728,2.4,-.728,1.3,2.4,0,1.3,2.4,.224,.4,2.55,.4,.224,2.55,.728,1.3,2.55,1.3,.728,2.55,.728,1.3,2.4,1.3,.728,2.4,0,0,0,1.425,0,0,1.425,.798,0,.798,1.425,0,0,1.425,0,1.5,0,.075,1.5,.84,.075,.84,1.5,.075,0,1.5,.075,-.798,1.425,0,-1.425,.798,0,-1.425,0,0,-.84,1.5,.075,-1.5,.84,.075,-1.5,0,.075,-1.425,-.798,0,-.798,-1.425,0,0,-1.425,0,-1.5,-.84,.075,-.84,-1.5,.075,0,-1.5,.075,.798,-1.425,0,1.425,-.798,0,.84,-1.5,.075,1.5,-.84,.075];super(),t=Math.max(2,Math.floor(t));const c=3.15*(a?1:1.3)/2,u=e/c;let d=n?(8*t-4)*t:0;d+=i?(16*t-4)*t:0,d+=o?40*t*t:0;const h=new Uint32Array(3*d);let p=n?4:0;p+=i?8:0,p+=o?20:0,p*=(t+1)*(t+1);const f=new Float32Array(3*p),m=new Float32Array(3*p),g=new Float32Array(2*p),v=new un;v.set(-1,3,-3,1,3,-6,3,0,-3,3,0,0,1,0,0,0);const A=[],_=[],x=[],y=[],b=[],M=[],C=[],S=[],w=[],E=new Bt;let T,I,R,L,B=0,P=0;const D=new Bt,N=new un,O=new un,F=new Et,U=new Et,z=new Et,V=new Et,G=new Bt,k=new Bt,Q=v.clone();Q.transpose();const W=(e,t,n)=>!(f[3*e]===f[3*t]&&f[3*e+1]===f[3*t+1]&&f[3*e+2]===f[3*t+2]||f[3*e]===f[3*n]&&f[3*e+1]===f[3*n+1]&&f[3*e+2]===f[3*n+2]||f[3*t]===f[3*n]&&f[3*t+1]===f[3*n+1]&&f[3*t+2]===f[3*n+2]);for(let e=0;e<3;e++)M[e]=new un;const H=n?32:28,j=t+1;let Y=0,X=0,K=0,q=0,Z=0;for(let e=o?0:20;e=28){for(let t=0;t<3;t++){for(let n=0;n<4;n++)for(let i=0;i<4;i++)A[4*i+n]=l[3*s[16*e+4*n+i]+t],r&&e>=20&&e<28&&2!==t&&(A[4*i+n]*=1.077),a||2!==t||(A[4*i+n]*=1.3);N.set(A[0],A[1],A[2],A[3],A[4],A[5],A[6],A[7],A[8],A[9],A[10],A[11],A[12],A[13],A[14],A[15]),O.multiplyMatrices(N,v),M[t].multiplyMatrices(Q,O)}for(let e=0;e<=t;e++){const n=e/t;for(let e=0;e<=t;e++){const i=e/t;for(L=4,I=R=1;L--;)_[L]=I,x[L]=R,I*=n,R*=i,3===L?(y[L]=b[L]=0,B=P=1):(y[L]=B*(3-L),b[L]=P*(3-L),B*=n,P*=i);F.fromArray(_),U.fromArray(x),z.fromArray(y),V.fromArray(b);for(let e=0;e<3;e++)T=F.clone(),T.applyMatrix4(M[e]),C[e]=T.dot(U),T=z.clone(),T.applyMatrix4(M[e]),S[e]=T.dot(U),T=F.clone(),T.applyMatrix4(M[e]),w[e]=T.dot(V);G.fromArray(S),k.fromArray(w),E.crossVectors(k,G),E.normalize(),0===C[0]&&0===C[1]?D.set(0,C[2]>c?1:-1,0):D.set(E.x,E.z,-E.y),f[X++]=u*C[0],f[X++]=u*(C[2]-c),f[X++]=-u*C[1],m[K++]=D.x,m[K++]=D.y,m[K++]=D.z,g[q++]=1-i,g[q++]=1-n}}for(let e=0;e0!=e>0&&this.version++,this._sheen=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.ior=e.ior,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}Yc.prototype.isMeshPhysicalMaterial=!0;class Xc extends Xn{constructor(e){super(),this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this}}Xc.prototype.isMeshPhongMaterial=!0;class Kc extends Xn{constructor(e){super(),this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new yt(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Kc.prototype.isMeshToonMaterial=!0;class qc extends Xn{constructor(e){super(),this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}qc.prototype.isMeshNormalMaterial=!0;class Zc extends Xn{constructor(e){super(),this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this}}Zc.prototype.isMeshLambertMaterial=!0;class Jc extends Xn{constructor(e){super(),this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new yt(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new et(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this}}Jc.prototype.isMeshMatcapMaterial=!0;class $c extends Js{constructor(e){super(),this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}$c.prototype.isLineDashedMaterial=!0;class eu extends Xn{constructor(e){super(),this.type="MeshMaskMaterial",this.side=2,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.cameraNearFar=null,this.depthTexture=null,this.textureMatrix=null,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,e.cameraNearFar&&(this.cameraNearFar=e.cameraNearFar.clone()),e.textureMatrix&&(this.textureMatrix=e.textureMatrix.clone()),e.depthTexture&&(this.depthTexture=e.depthTexture),this}}eu.prototype.isMeshMaskMaterial=!0;class tu{constructor(e,t,n,i){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=void 0!==i?i:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,i=t[n],o=t[n-1];e:{t:{let r;n:{i:if(!(e=o)break e;{const a=t[1];e=o)break t}r=n,n=0}}for(;n>>1;en&&(i=n+"_"+t),this.edges[i]=new e.Edge(t,n,0)},r.prototype.adj=function(e){return this.adjList[e]},r.prototype.node=function(e){return this.nodeInfo[e]},r.prototype.len=function(){return this.V},r.prototype.edge=function(e,t){var n=e+"_"+t;return e>t&&(n=t+"_"+e),n in this.edges?this.edges[n]:null},e.Graph=r;var a=function(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;te?n-1:n,u=l>e?l-1:l,d=this.edge(n,l).copy();d.v=c,d.w=u,s.addEdge(d)}this.V--,this.adjList=s.adjList,this.nodeInfo.splice(e,1),this.edges=s.edges}},a.prototype.insert=function(e,n,i){for(var o=this.V,r=e.V,a=0;a "+i[o]+";"}}t+="}",console.log(t)},e.DiGraph=a;var s=function(e,t,n){this.v=e,this.w=t,this.weight=n};s.prototype.either=function(){return this.v},s.prototype.other=function(e){return e==this.v?this.w:this.v},s.prototype.from=function(){return this.v},s.prototype.to=function(){return this.w},s.prototype.copy=function(){var e=new s(0,0,0);for(var t in this)this.hasOwnProperty(t)&&(e[t]=this[t]);return e},e.Edge=s;var l=function(e,t){this.s=t;var n=e.V;this.marked=[],this.edgeTo=[];for(var i=0;i-1){i.removedNodes.push(o+e.len());const r=e.findInEdges(n),a=t.findOutEdges(o);for(let e=0;e0&&Eu(e,e.len()-2,0,e.len()-1,0)}for(let t=0;t0&&(Eu(e,e.len()-1,0,e.len()-2,0),Eu(e,e.len()-1,1,e.len()-2,1))}for(let t=0;t-1}function v(e){return e.type.indexOf("varying")>-1}function _(e,n){return n=st(n)?n:"color",t.nodeVCAliases[e]||n}function x(e,t,n,i){const o=new ks(e,t,1,n,i,St.DEFAULT_MAPPING,g,g,y,y);return o.needsUpdate=!0,o}function b(e){return!0===e.isVideoTexture&&e.encoding===Ae?"1":"0"}function M(e,t,n,i,o){let r;return t==n?r=e:"float"==t&&"vec3"==n?r="vec3("+[e,e,e].join(",")+")":"float"==t&&"vec4"==n?r="vec4("+[e,e,e,e].join(",")+")":"vec3"==t&&"float"==n||"vec4"==t&&"float"==n?r="("+[e+"[0]",e+"[1]",e+"[2]"].join("+")+")/3.0":"vec3"==t&&"vec4"==n?r="vec4("+e+", 1.0)":"vec4"==t&&"vec3"==n?r="vec3("+[e+"[0]",e+"[1]",e+"[2]"].join(",")+")":"float"==t&&"int"==n?r="int("+e+")":"int"==t&&"float"==n||"bool"==t&&"float"==n?r="float("+e+")":console.error("MeshNodeMaterial: Missing type conversion: "+t+" -> "+n),(o<1||1!=o&&"normal"==i)&&(r="mix("+i+","+r+","+Q(o)+")","normal"==i&&(r="normalize("+r+")")),r}function S(e,t,n,i,o){let r;const a=[],s=G(n),l=G(i);for(let n=0;n0||w(e,l,15))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[18]>0||w(e,l,18))&&(t.defines.USE_SHEEN=""),c.inputFactors.length=0;break;case"TRIGO_AR":c.params.push(O(u.function)),c.params.push(O(u.units));break;case"TWO_SIDED_AR":c.params.push(O("FRONT_FACING_VALUE"));break;case"USER_DATA_COLOR_AR":h=_(u.colorLayer,""),h?(p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(O(k("vec4",u.defaultColor)));break;case"ATTRIBUTE_BL":case"VERTEX_COLOR_BL":h=_(u.colorLayer,""),h?(p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(O("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BSDF_PRINCIPLED_BL":c.params.push(O("geometryNormal")),u.inputs.length<=23?((u.inputs[12]>0||w(e,l,yu))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[10]>0||w(e,l,10))&&(t.defines.USE_SHEEN="")):((u.inputs[14]>0||w(e,l,14))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[12]>0||w(e,l,12))&&(t.defines.USE_SHEEN=""));break;case"BSDF_REFRACTION_BL":c.params.push(O("geometryNormal")),c.params.push(O("BSDF_REFRACTION_"+u.distribution));break;case"BUMP_BL":c.params.push(B(u.invert));break;case"CAMERA_BL":c.params.push(O("vViewPosition")),a(e,"OUTPUT_MATERIAL_BL")>0||a(e,"OUTPUT_WORLD_BL")>0?c.params.push(N(!0)):c.params.push(N(!1));break;case"COMBINE_COLOR_BL":c.params.push(O("NODE_COMB_COL_"+u.mode));break;case"CURVE_FLOAT_BL":t.useFloatTex?(m=new Float32Array(1024),g=1):(m=new Uint8Array(1024),g=255);for(let e=0;e3?(t=g*u.curveData[L*e],n=g*u.curveData[L*e+1],i=g*u.curveData[L*e+2],o=g*u.curveData[L*e+3]):(t=g*(u.curveData[L*e]/2+.5),n=g*(u.curveData[L*e+1]/2+.5),i=g*(u.curveData[L*e+2]/2+.5),o=g),m[4*e]=Ue(t,0,g),m[4*e+1]=Ue(n,0,g),m[4*e+2]=Ue(i,0,g),m[4*e+3]=Ue(o,0,g)}y=x(m,bu,R,t.useFloatTex?E:C),M=wu.nodeTexUniName(d,n),t.nodeTextures[M]=y,c.params.push(P(d,n)),n++;break;case"EEVEE_SPECULAR_BL":c.params.push(O("geometryNormal")),(u.inputs[6]>0||w(e,l,6))&&(t.defines.USE_CLEARCOAT="");break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":case"INCIDENT":case"POSITION":c.params.push(O("vViewPosition"));break;case"GRADIENT_RAMP_MX":t.useFloatTex?(m=new Float32Array(2048),g=1):(m=new Uint8Array(2048),g=255);for(let e=0;e-1?c.params.push(O("MAPPING_EXPLICIT_MAP_CHANNEL")):c.params.push(O("MAPPING_"+u.mapping)),c.params.push(O("AXIS_"+u.axis)),c.params.push(O(k("ivec2",[U(u.clampToEdgeNoExtend[0]),U(u.clampToEdgeNoExtend[1])])));break;case"MAPPING_BL":c.params.push(O("NODE_MAPPING_"+u.vectorType));break;case"MAP_RANGE_BL":st(u.dataType)&&c.params.push(O("NODE_MAP_RANGE_TYPE_"+u.dataType)),c.params.push(O("NODE_MAP_RANGE_INTERP_"+u.interpolationType)),c.params.push(N(u.clamp));break;case"NEW_GEOMETRY_BL":c.params.push(O("FRONT_FACING_VALUE")),c.params.push(O("vViewPosition")),c.params.push(O("normal")),T(e,l,2)&&(t.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":h="tangent",p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(O("vNormal"));break;case"SEPARATE_COLOR_BL":c.params.push(O("NODE_SEP_COL_"+u.mode));break;case"TANGENT_BL":"RADIAL"===u.directionType?(c.params.push(O("TANGENT_AXIS_"+u.axis)),c.params.push(O("vViewPosition")),c.params.push(O("normal")),t.needsBoundingBox=!0):"UV_MAP"===u.directionType&&(h="tangent",p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"TEX_BRICK_BL":c.params.push(O(k("float",u.offset))),c.params.push(O(k("int",u.offsetFrequency))),c.params.push(O(k("float",u.squash))),c.params.push(O(k("int",u.squashFrequency)));break;case"TEX_COORD_BL":c.params.push(O(`nodeTexCoordObjectMatrices[${o}]`)),c.params.push(O("vViewPosition")),c.params.push(O("normal")),h="uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),T(e,l,0)&&(t.needsBoundingBox=!0),t.nodeTexCoordObject.push(null),t.nodeTexCoordObjectMap[u.name]=o,o++;break;case"TEX_ENVIRONMENT_BL":case"TEX_ENVIRONMENT_MX":case"TEX_IMAGE_BL":if(S=P(d,u.texture),c.params.push(S),c.params.push(O(b(t.nodeTextures[S.name]))),"TEX_ENVIRONMENT_BL"==d){const e=u.projection;c.params.push(O("TEX_PROJ_"+e))}else if("TEX_IMAGE_BL"==d){c.params.push(O("normal"));const e=u.projection;c.params.push(O("TEX_PROJ_"+e)),c.params.push(B(u.projectionBlend)),c.params.push(N(u.clampToEdgeNoExtend))}break;case"TEX_GRADIENT_BL":c.params.push(O("TEX_GRAD_"+u.gradientType));break;case"TEX_NOISE_BL":c.params.push(O(k("float",st(u.falloffFactor)?u.falloffFactor:0))),c.params.push(O(k("float",st(u.dispersionFactor)?u.dispersionFactor:1)));break;case"TEX_SKY_BL":if(G=(new Bt).fromArray(u.sunDirection).angleTo(new Bt(0,0,1)),"PREETHAM"==u.skyType)Q=_u.getDistParams(u.turbidity,0).concat([0,0,0,0]),W=_u.getDistParams(u.turbidity,1).concat([0,0,0,0]),H=_u.getDistParams(u.turbidity,2).concat([0,0,0,0]),j=_u.getZenithParams(u.turbidity,G,0),Y=_u.getZenithParams(u.turbidity,G,1),X=_u.getZenithParams(u.turbidity,G,2);else if("HOSEK_WILKIE"==u.skyType){const e=Math.max(Math.PI/2-G,0);Q=du(u.turbidity,u.groundAlbedo,e,0),W=du(u.turbidity,u.groundAlbedo,e,1),H=du(u.turbidity,u.groundAlbedo,e,2),j=hu(u.turbidity,u.groundAlbedo,e,0),Y=hu(u.turbidity,u.groundAlbedo,e,1),X=hu(u.turbidity,u.groundAlbedo,e,2)}else Q=W=H=new Array(9).fill(0),j=Y=X=0;c.params.push(O("TEX_SKY_"+u.skyType)),c.params.push(B([Q[0],W[0],H[0]])),c.params.push(B([Q[1],W[1],H[1]])),c.params.push(B([Q[2],W[2],H[2]])),c.params.push(B([Q[3],W[3],H[3]])),c.params.push(B([Q[4],W[4],H[4]])),c.params.push(B([Q[5],W[5],H[5]])),c.params.push(B([Q[6],W[6],H[6]])),c.params.push(B([Q[7],W[7],H[7]])),c.params.push(B([Q[8],W[8],H[8]])),c.params.push(B([j,Y,X])),c.params.push(B(u.sunDirection));break;case"TEX_VORONOI_BL":c.params.push(O("DISTANCE_"+u.distance)),c.params.push(O("FEATURE_"+u.feature));break;case"TEX_WAVE_BL":c.params.push(O("TEX_WAVE_TYPE_"+u.waveType)),c.params.push(O("TEX_WAVE_PROFILE_"+u.waveProfile)),c.params.push(O(`TEX_WAVE_BANDS_DIR_${u.bandsDirection}`)),c.params.push(O(`TEX_WAVE_RINGS_DIR_${u.ringsDirection}`));break;case"MATH_BL":c.outputs[0].clamp=u.useClamp;break;case"MIX_RGB_BL":switch(c.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":t.defines.HSV_NODES=""}c.outputs[0].clamp=u.useClamp;break;case"MIX_SHADER_BL":let z=-1;for(let t=1;t<3;t++){const n=I(e,l,t);n&&"BSDF_TRANSPARENT_BL"==n.originData.type&&(z=t-1)}c.params.push(O(String(z)));break;case"NORMAL_BL":c.params.push(B(u.outputs[0]));break;case"RGB_BL":case"RGB_MX":S=(new Et).fromArray(u.outputs[0]),t.nodeRGB.push(S),t.nodeRGBMap[u.name]=i,c.params.push(O("nodeRGB["+i+"]")),i++;break;case"UVMAP_BL":s=u.uvLayer,h=t.nodeUVAliases[s]||"uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"VALUE_BL":case"VALUE_MX":case"ANIM_CURVE_TA_MY":case"ANIM_CURVE_TU_MY":case"VALUE":S=u.outputs[0],t.nodeValue[r]=S,t.nodeValueMap[u.name]=r,c.params.push(O("nodeValue["+r+"]")),r++;break;case"VALTORGB_BL":V=u.curve;const K=new("STEP"==V.interpolation?nu:pu)(new Float32Array(V.input),new Float32Array(V.output),4);t.useFloatTex?(m=new Float32Array(1024),g=1):(m=new Uint8Array(1024),g=255);for(let e=0;e0||a(e,"OUTPUT_WORLD_BL")>0?c.params.push(N(!0)):c.params.push(N(!1));break;case"BITMAP_MX":case"BITMAP_ENV_MX":case"REFLECT_REFRACT_MX":if(f=P(d,u.texture),c.params.push(f),"BITMAP_MX"==d){h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(O("MAPPING_"+u.mapping)),c.params.push(O("AXIS_"+u.axis));const e=k("ivec2",[U(u.clampToEdgeNoExtend[0]),U(u.clampToEdgeNoExtend[1])]);c.params.push(O(e))}else c.params.push(O(u.reflectMode)),c.params.push(B(u.IOR));c.params.push(O(b(t.nodeTextures[f.name]))),"BITMAP_MX"!=d&&"BITMAP_ENV_MX"!=d||(c.params.push(N(u.alphaAsMono)),c.params.push(N(u.alphaAsRGB)),c.outputs.push({name:d.toLowerCase()+"_out1_n"+l,type:"float",clamp:!1,normalize:!1}));break;case"BLEND_MX":c.params.push(N(u.useCurve)),c.params.push(B(u.curveLower)),c.params.push(B(u.curveUpper));break;case"BUMP_MX":f=P("BITMAP_MX",u.texture),c.params.push(f),c.params.push(O("-vViewPosition")),c.params.push(O("normal")),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"COLOR_CORRECTION_MX":const ee=k("ivec4",[u.rewireR,u.rewireG,u.rewireB,u.rewireA]);c.params.push(O(ee));break;case"COMPOSITE_LAYER_MX":c.params.push(O(k("int",u.blendMode)));const te=w(e,l,1)?u.opacity:0;c.params.push(B(te));break;case"COLOR_MAP_MX":c.params.push(N(u.reverseGamma));break;case"FALLOFF_MX":c.params.push(O("-vViewPosition")),c.params.push(B(u.IOR));break;case"MASK_MX":c.params.push(N(u.maskInverted));break;case"MATERIAL_MX":c.params.push(B(u.inputFactors[9])),c.params.push(B(u.inputFactors[10])),u.inputFactors[9]=1,u.inputFactors[10]=1,c.params.push(N(u.selfIllumColorOn));break;case"MATTE_SHADOW_MX":c.params.push(O("normal")),c.params.push(N(u.receiveShadows)),c.params.push(B(u.shadowBrightness)),c.params.push(B(u.color));break;case"NOISE_MX":2==u.coordType?(h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)):c.params.push(O("vViewPosition")),c.params.push(D(u.noiseType)),c.params.push(D(u.coordType));break;case"NORMAL_BUMP_MX":h="tangent",p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(O("normal"));const ne="ivec2("+U(u.flip[0])+","+U(u.flip[1])+")";c.params.push(O(ne));break;case"OUTPUT_MAP_MX":if(c.params.push(N(u.invert)),c.params.push(N(u.clamp)),c.params.push(N(u.alphaFromRGB)),u.colorMap){t.useFloatTex?(v=u.colorMap,m=new Float32Array(1024),g=1):(v=lt(u.colorMap.slice(),0,1),m=new Uint8Array(1024),g=255),L=v.length/bu;for(let e=0;e0||w(e,l,18))&&(t.defines.USE_CLEARCOAT="");break;case"PHY_SUN_SKY_ENV_MX":const se=15*u.haze+2,le=new xu;G=Math.PI/2-u.sunPolarAngle;const ce=Math.PI-u.sunAzimuthAngle;le.phi=G,le.theta=ce;const ue=(new Bt).setFromSpherical(le).toArray();Q=_u.getDistParams(se,0),W=_u.getDistParams(se,1),H=_u.getDistParams(se,2),j=_u.getZenithParams(se,G,0),Y=_u.getZenithParams(se,G,1),X=_u.getZenithParams(se,G,2),j/=.06,j*=1e3,c.params.push(B([Q[0],W[0],H[0]])),c.params.push(B([Q[1],W[1],H[1]])),c.params.push(B([Q[2],W[2],H[2]])),c.params.push(B([Q[3],W[3],H[3]])),c.params.push(B([Q[4],W[4],H[4]])),c.params.push(B([j,Y,X]));const de=_u.getSunIlluminance(ue,se),he=[0,0,0];c.params.push(B(ue)),c.params.push(B(de)),c.params.push(B(he)),c.params.push(B(u.globalIntensity/Cu)),c.params.push(B(u.groundColor));break;case"REFLECT_REFRACT_COLOR_MX":S=u.outputs[0],c.params.push(B(S));break;case"VERTEX_COLOR_MX":h="color",p=F(h,3),c.attributes.push({name:h,type:"attribute vec3"}),c.params.push(p);break;case"BUMP_2D_MY":c.params.push(O("vNormal")),u.bumpInterp>0&&(h="tangent",p=F(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"COLOR_COMPOSITE_MY":case"COLOR_LOGIC_MY":case"COLOR_MATH_MY":case"CONDITION_MY":case"FLOAT_COMPOSITE_MY":case"FLOAT_LOGIC_MY":case"FLOAT_MATH_MY":case"MULTIPLY_DIVIDE_MY":c.params.push(O(u.operation));break;case"COLOR_CORRECT_MY":c.params.push(N(u.colClamp)),c.params.push(B(u.colClampMin)),c.params.push(B(u.colClampMax)),c.params.push(N(u.alphaClamp)),c.params.push(B(u.alphaClampMin)),c.params.push(B(u.alphaClampMax)),c.params.push(N(u.unpremultiplyInput)),c.params.push(N(u.premultiplyResult));break;case"COLOR_MASK_MY":c.params.push(N(u.maskAlphaIsLuminance));break;case"COMPOSE_MATRIX_MY":c.params.push(N(u.useEulerRotation)),c.params.push(O(u.inputRotateOrder));break;case"FILE_MY":case"ENV_SPHERE_MY":if(S=P("FILE_MY",u.texture),c.params.push(S),c.params.push(O(b(t.nodeTextures[S.name]))),"ENV_SPHERE_MY"==d)c.params.push(O("normal"));else{const t=!1===u.fileHasAlpha;c.params.push(N(t&&T(e,l,0)))}break;case"RAMP_MY":t.useFloatTex?(m=new Float32Array(2048),g=1):(m=new Uint8Array(2048),g=255);for(let e=0;e-1&&c.params.push(O("oslGetP(vViewPosition)")),pe.indexOf("I")>-1&&c.params.push(O("oslGetI(vViewPosition)")),pe.indexOf("N")>-1&&c.params.push(O("oslGetN(normal)")),(pe.indexOf("u")>-1||pe.indexOf("v")>-1)&&(h="uv",c.attributes.push({name:h,type:"attribute vec2"}),pe.indexOf("u")>-1&&c.params.push(F(h+"_u",1,h+".x")),pe.indexOf("v")>-1&&c.params.push(F(h+"_v",1,"1.0 - "+h+".y")));break;case"RGB_ALPHA":S=(new Et).fromArray(u.outputs[0].concat([u.outputs[1]])),t.nodeRGB.push(S),t.nodeRGBMap[u.name]=i,c.params.push(O("nodeRGB["+i+"]")),i++;break;case"U_FLOAT":h="uv",p=F(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)}}var s;for(let t=0;t0||w(e,t,yu))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Eu(e,e.len()-1,0,t,20)}if("BSDF_PRINCIPLED_<3.0_BL"==o&&!w(e,t,21)&&(n.inputs[12]>0||w(e,t,yu))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Eu(e,e.len()-1,0,t,21)}if("BSDF_PRINCIPLED_BL"==o&&!w(e,t,23)&&(n.inputs[14]>0||w(e,t,14))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Eu(e,e.len()-1,0,t,23)}if("EEVEE_SPECULAR_BL"==o&&!w(e,t,8)&&(n.inputs[6]>0||w(e,t,6))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Eu(e,e.len()-1,0,t,8)}if("OSL_NODE"==o){const i=n.initializers;for(let r=0;r0||w(e,t,15))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Eu(e,e.len()-1,0,t,25)}if("BUMP_2D_MY"==i&&n.bumpInterp>0){n.inputs[1]=[0,0,0];const i=e.findInEdges(t);for(let t=0;t=i)){l.push(t.times[e]);for(let n=0;nr.tracks[e].times[0]&&(s=r.tracks[e].times[0]);for(let e=0;e=i.times[d]){const e=d*l+s,t=e+l-s;h=Ru.arraySlice(i.values,e,t)}else{const e=i.createInterpolant(),t=s,n=l-s;e.evaluate(r),h=Ru.arraySlice(e.resultBuffer,t,n)}if("quaternion"===o){(new Lt).fromArray(h).normalize().conjugate().toArray(h)}const p=a.times.length;for(let e=0;et;)--r;if(++r,0!==o||r!==i){o>=r&&(r=Math.max(r,1),o=r-1);const e=this.getValueSize();this.times=Ru.arraySlice(n,o,r),this.values=Ru.arraySlice(this.values,o*e,r*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("v3d.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,i=this.values,o=n.length;0===o&&(console.error("v3d.KeyframeTrack: Track is empty.",this),e=!1);let r=null;for(let t=0;t!==o;t++){const i=n[t];if("number"==typeof i&&isNaN(i)){console.error("v3d.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==r&&r>i){console.error("v3d.KeyframeTrack: Out of order keys.",this,t,i,r),e=!1;break}r=i}if(void 0!==i&&Ru.isTypedArray(i))for(let t=0,n=i.length;t!==n;++t){const n=i[t];if(isNaN(n)){console.error("v3d.KeyframeTrack: Value is not a valid number.",this,t,n),e=!1;break}}return e}optimize(){const e=Ru.arraySlice(this.times),t=Ru.arraySlice(this.values),n=this.getValueSize(),i=this.getInterpolation()===de,o=e.length-1;let r=1;for(let a=1;a0){e[r]=e[o];for(let e=o*n,i=r*n,a=0;a!==n;++a)t[i+a]=t[e+a];++r}return r!==e.length?(this.times=Ru.arraySlice(e,0,r),this.values=Ru.arraySlice(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Ru.arraySlice(this.times,0),t=Ru.arraySlice(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Bu.prototype.TimeBufferType=Float32Array,Bu.prototype.ValueBufferType=Float32Array,Bu.prototype.DefaultInterpolation=ue;class Pu extends Bu{}Pu.prototype.ValueTypeName="bool",Pu.prototype.ValueBufferType=Array,Pu.prototype.DefaultInterpolation=ce,Pu.prototype.InterpolantFactoryMethodLinear=void 0,Pu.prototype.InterpolantFactoryMethodSmooth=void 0;class Du extends Bu{}Du.prototype.ValueTypeName="color";class Nu extends Bu{}Nu.prototype.ValueTypeName="number";class Ou extends tu{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e,t,n,i){const o=this.resultBuffer,r=this.sampleValues,a=this.valueSize,s=(n-t)/(i-t);let l=e*a;for(let e=l+a;l!==e;l+=4)Lt.slerpFlat(o,0,r,l-a,r,l,s);return o}}class Fu extends Bu{InterpolantFactoryMethodLinear(e){return new Ou(this.times,this.values,this.getValueSize(),e)}}Fu.prototype.ValueTypeName="quaternion",Fu.prototype.DefaultInterpolation=ue,Fu.prototype.InterpolantFactoryMethodSmooth=void 0;class Uu extends Bu{}Uu.prototype.ValueTypeName="string",Uu.prototype.ValueBufferType=Array,Uu.prototype.DefaultInterpolation=ce,Uu.prototype.InterpolantFactoryMethodLinear=void 0,Uu.prototype.InterpolantFactoryMethodSmooth=void 0;class zu extends Bu{}zu.prototype.ValueTypeName="vector";class Vu{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=Fe(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,i=1/(e.fps||1);for(let e=0,o=n.length;e!==o;++e)t.push(Gu(n[e]).scale(i));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o}static toJSON(e){const t=[],n=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=n.length;e!==i;++e)t.push(Bu.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const o=t.length,r=[];for(let e=0;e1){const e=r[1];let t=i[e];t||(i[e]=t=[]),t.push(n)}}const r=[];for(const e in i)r.push(this.CreateFromMorphTargetSequence(e,i[e],t,n));return r}static parseAnimation(e,t){if(!e)return console.error("v3d.AnimationClip: No animation in JSONLoader data."),null;const n=function(e,t,n,i,o){if(0!==n.length){const r=[],a=[];Ru.flattenJSON(n,r,a,i),0!==r.length&&o.push(new e(t,r,a))}},i=[],o=e.name||"default",r=e.fps||30,a=e.blendMode;let s=e.length||-1;const l=e.hierarchy||[];for(let e=0;e{t&&t(o),this.manager.itemEnd(e)}),0),o;if(void 0!==ju[e])return void ju[e].push({onLoad:t,onProgress:n,onError:i});ju[e]=[],ju[e].push({onLoad:t,onProgress:n,onError:i});const r=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,s=this.responseType;fetch(r).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("v3d.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body.getReader)return t;const n=ju[e],i=t.body.getReader(),o=t.headers.get("Content-Length"),r=o?parseInt(o):0,a=0!==r;let s=0;const l=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:o})=>{if(i)e.close();else{s+=o.byteLength;const i=new ProgressEvent("progress",{lengthComputable:a,loaded:s,total:r});for(let e=0,t=n.length;e{switch(s){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,a)));case"json":return e.json();default:if(void 0===a)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(a),n=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(n);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{ku.add(e,t);const n=ju[e];delete ju[e];for(let e=0,i=n.length;e{const n=ju[e];if(void 0===n)throw this.manager.itemError(e),t;delete ju[e];for(let e=0,i=n.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class Xu extends Hu{constructor(e){super(e)}load(e,t,n,i){void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,r=ku.get(e);if(void 0!==r)return o.manager.itemStart(e),setTimeout((function(){t&&t(r),o.manager.itemEnd(e)}),0),r;const a=at("img");function s(){c(),ku.add(e,this),t&&t(this),o.manager.itemEnd(e)}function l(t){c(),i&&i(t),o.manager.itemError(e),o.manager.itemEnd(e)}function c(){a.removeEventListener("load",s,!1),a.removeEventListener("error",l,!1)}return a.addEventListener("load",s,!1),a.addEventListener("error",l,!1),"data:"!==e.substr(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),o.manager.itemStart(e),a.src=e,a}}class Ku extends Hu{constructor(e){super(e)}load(e,t,n,i){const o=new Hi,r=new Xu(this.manager);r.setCrossOrigin(this.crossOrigin),r.setPath(this.path);let a=0;function s(n){r.load(e[n],(function(e){o.images[n]=e,a++,6===a&&(o.needsUpdate=!0,t&&t(o))}),void 0,i)}for(let t=0;t0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const o=e.uniforms[t];switch(i.uniforms[t]={},o.type){case"t":i.uniforms[t].value=n(o.value);break;case"c":i.uniforms[t].value=(new yt).setHex(o.value);break;case"v2":i.uniforms[t].value=(new et).fromArray(o.value);break;case"v3":i.uniforms[t].value=(new Bt).fromArray(o.value);break;case"v4":i.uniforms[t].value=(new Et).fromArray(o.value);break;case"m3":i.uniforms[t].value=(new tt).fromArray(o.value);break;case"m4":i.uniforms[t].value=(new un).fromArray(o.value);break;default:i.uniforms[t].value=o.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.shading&&(i.flatShading=1===e.shading),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=n(e.map)),void 0!==e.matcap&&(i.matcap=n(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=n(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=n(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=n(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new et).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=n(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=n(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=n(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=n(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=n(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=n(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=n(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=n(e.envMap)),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=n(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=n(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=n(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=n(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=n(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new et).fromArray(e.clearcoatNormalScale)),void 0!==e.transmissionMap&&(i.transmissionMap=n(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=n(e.thicknessMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=n(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=n(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}}class vd{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(n,i,this._addIndex*t,1,t);for(let e=t,o=t+t;e!==o;++e)if(n[e]!==n[e+t]){a.setValue(n,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,i=n*this._origIndex;e.getValue(t,i);for(let e=n,o=i;e!==o;++e)t[e]=t[i+e%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n=.5)for(let i=0;i!==o;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){Lt.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,o){const r=this._workIndex*o;Lt.multiplyQuaternionsFlat(e,r,e,t,e,n),Lt.slerpFlat(e,t,e,t,e,r,i)}_lerp(e,t,n,i,o){const r=1-i;for(let a=0;a!==o;++a){const o=t+a;e[o]=e[o]*r+e[n+a]*i}}_lerpAdditive(e,t,n,i,o){for(let r=0;r!==o;++r){const o=t+r;e[o]=e[o]+e[n+r]*i}}}const Hd="\\[\\]\\.",jd=new RegExp("[\\[\\]\\.]","g"),Yd="[^\\[\\]\\.]",Xd="[^"+Hd.replace("\\.","")+"]",Kd=(/((?:WC+[\/:])*)/.source.replace("WC",Yd),/(WCOD+)?/.source.replace("WCOD",Xd)),qd=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Yd),Zd=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Yd),Jd=new RegExp("^"+Kd+qd+Zd+"$"),$d=["material","materials","bones"];class eh{constructor(e,t,n){this.path=t,this.parsedPath=n||eh.parseTrackName(t),this.node=eh.findNode(e,this.parsedPath.nodeName)||e,this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new eh.Composite(e,t,n):new eh(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(jd,"")}static parseTrackName(e){const t=Jd.exec(e);if(!t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[1],objectName:t[2],objectIndex:t[3],propertyName:t[4],propertyIndex:t[5]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=n.nodeName.substring(i+1);-1!==$d.indexOf(e)&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=e)}if(null===n.propertyName||0===n.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(!t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(void 0!==n)return n}if(e.children){const n=function(e){for(let i=0;i=o){const r=o++,c=e[r];t[c.uuid]=l,e[l]=c,t[s]=r,e[r]=a;for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[r],o=t[l];t[l]=i,t[r]=o}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let o=this.nCachedObjects_,r=e.length;for(let a=0,s=arguments.length;a!==s;++a){const s=arguments[a].uuid,l=t[s];if(void 0!==l)if(delete t[s],l0&&(t[a.uuid]=l),e[l]=a,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e];t[l]=t[o],t.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let i=n[e];const o=this._bindings;if(void 0!==i)return o[i];const r=this._paths,a=this._parsedPaths,s=this._objects,l=s.length,c=this.nCachedObjects_,u=new Array(l);i=o.length,n[e]=i,r.push(e),a.push(t),o.push(u);for(let n=c,i=s.length;n!==i;++n){const i=s[n];u[n]=new eh(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(void 0!==n){const i=this._paths,o=this._parsedPaths,r=this._bindings,a=r.length-1,s=r[a];t[e[a]]=n,r[n]=s,r.pop(),o[n]=o[a],o.pop(),i[n]=i[a],i.pop()}}}th.prototype.isAnimationObjectGroup=!0;class nh{constructor(e,t,n=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=i;const o=t.tracks,r=o.length,a=new Array(r),s={endingStart:he,endingEnd:he};for(let e=0;e!==r;++e){const t=o[e].createInterpolant(null);a[e]=t,t.settings=s}this._interpolantSettings=s,this._interpolants=a,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=se,this._loopCount=-1,this._pingIsEven=!0,this._startTime=null,this.time=0,this.timeStart=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this._pingIsEven=!0,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n){if(e.fadeOut(t),this.fadeIn(t),n){const n=this._clip.duration,i=e._clip.duration,o=i/n,r=n/i;e.warp(1,o,t),this.warp(r,1,t)}return this}crossFadeTo(e,t,n){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const i=this._mixer,o=i.time,r=this.timeScale;let a=this._timeScaleInterpolant;null===a&&(a=i._lendControlInterpolant(),this._timeScaleInterpolant=a);const s=a.parameterPositions,l=a.sampleValues;return s[0]=o,s[1]=o+n,l[0]=e/r,l[1]=t/r,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,i){if(!this.enabled)return void this._updateWeight(e);const o=this._startTime;if(null!==o){const i=(e-o)*n;if(i<0||0===n)return;this._startTime=null,t=n*i}t*=this._updateTimeScale(e);const r=this._updateTime(t),a=this._updateWeight(e);if(a>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===ge)for(let n=0,i=e.length;n!==i;++n)e[n].evaluate(r),t[n].accumulateAdditive(a);else for(let n=0,o=e.length;n!==o;++n)e[n].evaluate(r),t[n].accumulate(i,a)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(null!==n){const i=n.evaluate(e)[0];t*=i,e>n.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(null!==n){t*=n.evaluate(e)[0],e>n.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_loopIsPing(e){if(this.loop!==le)return!0;if(-1==e)return!0;return 0==(1&e)===this._pingIsEven}_updateTime(e){if(0===e)return this.time;if(this.loop!==ae&&this.repetitions<=0)return this.clampWhenFinished?this.paused=!0:this.enabled=!1,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1}),this.time;var t=this.timeStart,n=Math.max(t,this._clip.duration),i=n-t;if(this.loop===ae)return this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.timen)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Ue(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var o=this.loop===le,r=this._loopIsPing(this._loopCount)?1:-1;this.time+=r*e;var a=this.timen,s=!1;if(-1===this._loopCount&&(s=a,this._loopCount=s?-1:0,this._pingIsEven=!s,e>=0?this._setEndings(!0,0===this.repetitions,o):this._setEndings(0===this.repetitions,!0,o)),a){var l=Math.floor((this.time-t)/i);this._loopCount+=Math.abs(l);var c=this.repetitions-this._loopCount;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=Ue(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1});else{if(1==c){var u=e<0;this._setEndings(u,!u,o)}else this._setEndings(!1,!1,o);var d=(this.time-t)%i;d<0&&(d+=i),this.time=o?n-d:d+t,s||this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:l})}}return this.time}_setEndings(e,t,n){const i=this._interpolantSettings;n?(i.endingStart=pe,i.endingEnd=pe):(i.endingStart=e?this.zeroSlopeAtStart?pe:he:fe,i.endingEnd=t?this.zeroSlopeAtEnd?pe:he:fe)}_scheduleFading(e,t,n){const i=this._mixer,o=i.time;let r=this._weightInterpolant;null===r&&(r=i._lendControlInterpolant(),this._weightInterpolant=r);const a=r.parameterPositions,s=r.sampleValues;return a[0]=o,s[0]=t,a[1]=o+e,s[1]=n,this}}class ih extends Be{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,i=e._clip.tracks,o=i.length,r=e._propertyBindings,a=e._interpolants,s=n.uuid,l=this._bindingsByRootAndName;let c=l[s];void 0===c&&(c={},l[s]=c);for(let e=0;e!==o;++e){const o=i[e],l=o.name;let u=c[l];if(void 0!==u)++u.referenceCount,r[e]=u;else{if(u=r[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,s,l));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new Wd(eh.create(n,l,i),o.ValueTypeName,o.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,s,l),r[e]=u}a[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,n=e._clip.uuid,i=this._actionsByClip[n];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,n,t)}const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==n.useCount++&&(this._lendBinding(n),n.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.useCount&&(n.restoreOriginalState(),this._takeBackBinding(n))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,i=this.time+=e,o=Math.sign(e),r=this._accuIndex^=1;for(let a=0;a!==n;++a){t[a]._update(i,e,o,r)}const a=this._bindings,s=this._nActiveBindings;for(let e=0;e!==s;++e)a[e].apply(r);return this}setTime(e){this.time=0;for(let e=0;ethis.max.x||e.ythis.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.xthis.max.x||e.max.ythis.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return sh.copy(e).clamp(this.min,this.max).sub(e).length()}intersect(e){return this.min.max(e.min),this.max.min(e.max),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}lh.prototype.isBox2=!0;const ch=new Bt,uh=new Bt;class dh{constructor(e=new Bt,t=new Bt){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){ch.subVectors(e,this.start),uh.subVectors(this.end,this.start);const n=uh.dot(uh);let i=uh.dot(ch)/n;return t&&(i=Ue(i,0,1)),i}closestPointToPoint(e,t,n){const i=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const hh=new Bt;const ph=new Bt,fh=new un,mh=new un;class gh extends sl{constructor(e){const t=vh(e),n=new gi,i=[],o=[],r=new yt(0,0,1),a=new yt(0,1,0);for(let e=0;eNumber.EPSILON){if(l<0&&(n=t[r],s=-s,a=t[o],l=-l),e.ya.y)continue;if(e.y===n.y){if(e.x===n.x)return!0}else{const t=l*(e.x-n.x)-s*(e.y-n.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==n.y)continue;if(a.x<=e.x&&e.x<=n.x||n.x<=e.x&&e.x<=a.x)return!0}}return i}const o=Cc.isClockWise,r=this.subPaths;if(0===r.length)return[];if(!0===t)return n(r);let a,s,l;const c=[];if(1===r.length)return s=r[0],l=new Jl,l.curves=s.curves,c.push(l),c;let u=!o(r[0].getPoints());u=e?!u:u;const d=[],h=[];let p,f,m=[],g=0;h[g]=void 0,m[g]=[];for(let t=0,n=r.length;t1){let e=!1;const t=[];for(let e=0,t=h.length;e0&&(e||(m=d))}for(let e=0,t=h.length;e65504&&(console.warn("v3d.DataUtils.toHalfFloat(): value exceeds 65504."),e=65504),Oh[0]=e;const t=Fh[0];let n=t>>16&32768,i=t>>12&2047;const o=t>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&t,n):o<113?(i|=2048,n|=(i>>114-o)+(i>>113-o&1),n):(n|=o-112<<10|i>>1,n+=1&i,n)}static fromHalfFloat(e){const t=(31744&e)>>10,n=1023&e;return(e>>15?-1:1)*(t?31===t?n?NaN:1/0:Math.pow(2,t-15)*(1+n/1024):n/1024*6103515625e-14)}}class zh extends Be{constructor(){super(),this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("v3d.Pass: .render() must be implemented in derived pass.")}setCamera(e){}dispose(){}}const Vh=new po(-1,1,1,-1,0,1),Gh=new gi;Gh.setAttribute("position",new si([-1,3,0,-1,-1,0,3,-1,0],3)),Gh.setAttribute("uv",new si([0,2,0,0,2,0],2));class kh{constructor(e){this._mesh=new Di(Gh,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Vh)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}static dispose(){Gh.dispose()}}class Qh extends zh{constructor(e,t,n){super(),this.damp=t,this.shader=ro.afterimage,this.uniforms=zi.clone(this.shader.uniforms),this.uniforms.damp.value=this.damp,this.textureComp=new Tt(e.x,e.y,n),this.textureOld=new Tt(e.x,e.y,n),this.shaderMaterial=new Vi({uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.compFsQuad=new kh(this.shaderMaterial);const i=new Kn;this.copyFsQuad=new kh(i)}dispose(){this.textureComp.dispose(),this.textureOld.dispose()}render(e,t,n){this.uniforms.tOld.value=this.textureOld.texture,this.uniforms.tNew.value=n.texture,this.uniforms.damp.value=this.damp,e.setRenderTarget(this.textureComp),this.compFsQuad.render(e),this.copyFsQuad.material.map=this.textureComp.texture,this.renderToScreen?(e.setRenderTarget(null),this.copyFsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(),this.copyFsQuad.render(e));const i=this.textureOld;this.textureOld=this.textureComp,this.textureComp=i}setSize(e,t){this.textureComp.setSize(e,t),this.textureOld.setSize(e,t)}}class Wh extends zh{constructor(e,t,n,s,l){super(),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=s,this.resolution=void 0!==e?new et(e.x,e.y):new et(256,256),l=l||{minFilter:y,magFilter:y,format:R},this.clearColor=new yt(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let c=Math.round(this.resolution.x/2),u=Math.round(this.resolution.y/2);this.renderTargetBright=new Tt(c,u,l),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e65535?Uint32Array:Uint16Array;this.geometry.setIndex(new Jn(new m(p),1))}}}()});class ip extends fo{constructor(e){super(),this.type="MeshLineMaterial",this.lineWidth=1,this.sizeAttenuation=1,this.color=new yt(16777215),this.opacity=1,this.useMap=0,this.map=null,this.useAlphaMap=0,this.alphaMap=null,this.visibility=1,this.alphaTest=0,this.repeat=new et(1,1),this.uniforms={lineWidth:{value:1},sizeAttenuation:{value:1},color:{value:new yt(16777215)},opacity:{value:1},useMap:{value:0},map:{value:null},alphaMap:{value:null},useAlphaMap:{value:0},visibility:{value:1},alphaTest:{value:0},repeat:{value:new et(1,1)}},this.vertexShader=io.raw_meshline_vert,this.fragmentShader=io.raw_meshline_frag,this.setValues(e)}copy(e){return super.copy(e),this.lineWidth=e.lineWidth,this.sizeAttenuation=e.sizeAttenuation,this.color.copy(e.color),this.opacity=e.opacity,this.useMap=e.useMap,this.map=e.map,this.useAlphaMap=e.useAlphaMap,this.alphaMap=e.alphaMap,this.visibility=e.visibility,this.alphaTest=e.alphaTest,this.repeat.copy(e.repeat),this}}ip.prototype.isMeshLineMaterial=!0;class op extends zh{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new Et(1,1,1,1),this.hiddenEdgeColor=new Et(.1,.04,.02,1),this.edgeGlow=0,this.usePatternTexture=!1,this.edgeThickness=1,this.edgeStrength=3,this.downSampleRatio=2,this.pulsePeriod=0,this.renderToScreen=!1,this.resolution=void 0!==e?new et(e.x,e.y):new et(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),r=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new Tt(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.renderTargetDepthBuffer=new Tt(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new Tt(o,r),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new Tt(o,r),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new Tt(Math.round(o/2),Math.round(r/2)),this.renderTargetBlurBuffer2.texture.name="OutlinePass.blur2",this.renderTargetBlurBuffer2.texture.generateMipmaps=!1,this.edgeDetectionMaterial=this.getEdgeDetectionMaterial(),this.renderTargetEdgeBuffer1=new Tt(o,r),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new Tt(Math.round(o/2),Math.round(r/2)),this.renderTargetEdgeBuffer2.texture.name="OutlinePass.edge2",this.renderTargetEdgeBuffer2.texture.generateMipmaps=!1;this.separableBlurMaterial1=this.getSeparableBlurMaterial(4),this.separableBlurMaterial1.uniforms.texSize.value=new et(o,r),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new et(Math.round(o/2),Math.round(r/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial();const a=ro.copy;this.copyUniforms=zi.clone(a.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new Vi({defines:Object.assign({},a.defines),uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,blending:0,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new yt,this.oldClearAlpha=1,this.basic=new Kn({toneMapped:!1}),this.fsQuad=new kh(null),this.camera=new po(-1,1,1,-1,0,1),this.tempPulseColor1=new Et,this.tempPulseColor2=new Et,this.textureMatrix=new un,this.visibilityState=new WeakMap,this._depthMaterial=new Fa({blending:0,depthPacking:_e,side:2}),this._maskMaterial=new eu({side:2})}dispose(){this.renderTargetMaskBuffer.dispose(),this.renderTargetDepthBuffer.dispose(),this.renderTargetMaskDownSampleBuffer.dispose(),this.renderTargetBlurBuffer1.dispose(),this.renderTargetBlurBuffer2.dispose(),this.renderTargetEdgeBuffer1.dispose(),this.renderTargetEdgeBuffer2.dispose()}setSize(e,t){this.renderTargetMaskBuffer.setSize(e,t);let n=Math.round(e/this.downSampleRatio),i=Math.round(t/this.downSampleRatio);this.renderTargetMaskDownSampleBuffer.setSize(n,i),this.renderTargetBlurBuffer1.setSize(n,i),this.renderTargetEdgeBuffer1.setSize(n,i),this.separableBlurMaterial1.uniforms.texSize.value=new et(n,i),n=Math.round(n/2),i=Math.round(i/2),this.renderTargetBlurBuffer2.setSize(n,i),this.renderTargetEdgeBuffer2.setSize(n,i),this.separableBlurMaterial2.uniforms.texSize.value=new et(n,i)}saveVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof Di&&e.visibilityState.set(t,t.visible)}))}restoreVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof Di&&(t.visible=e.visibilityState.get(t))}))}changeVisibilityOfSelectedObjects(e){const t=this;function n(n){n instanceof Di&&t.visibilityState.get(n)&&(n.visible=e)}for(let e=0;e0){const e=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(e),this.tempPulseColor2.multiplyScalar(e)}this.fsQuad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new et(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=op.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.setRenderTarget(this.renderTargetBlurBuffer1),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=op.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer1),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=op.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=op.BlurDirectionY,e.setRenderTarget(this.renderTargetEdgeBuffer2),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,o&&e.context.enable(e.context.STENCIL_TEST),this.renderToScreen?e.setRenderTarget(null):e.setRenderTarget(n),this.fsQuad.render(e),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=r,this.renderScene.traverse((function(e){e.isAnnotationControl&&(e.doUpdate=e._doUpdateSave)}))}getEdgeDetectionMaterial(){return new Vi({type:"OutlineEdgeDetection",defines:{HIDDEN_EDGE_ALPHA:1},uniforms:{maskTexture:{value:null},texSize:{value:new et(.5,.5)},visibleEdgeColor:{value:new Et(1,1,1,1)},hiddenEdgeColor:{value:new Et(1,1,1,1)}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_outline_edge_frag})}getSeparableBlurMaterial(e){return new Vi({type:"OutlineSeparableBlur",defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new et(.5,.5)},direction:{value:new et(.5,.5)},kernelRadius:{value:1}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_outline_blur_frag})}getOverlayMaterial(){return new Vi({type:"OutlineOverlay",uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_outline_overlay_frag,blending:5,blendEquation:i,blendEquationAlpha:i,blendSrc:a,blendDst:s,blendSrcAlpha:r,blendDstAlpha:r,depthTest:!1,depthWrite:!1,transparent:!0})}setCamera(e){this.renderCamera=e}}op.BlurDirectionX=new et(1,0),op.BlurDirectionY=new et(0,1);class rp extends zh{constructor(e,t,n,i,o){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==o?o:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new yt}render(e,t,n){const i=e.autoClear;let o,r;e.autoClear=!1,void 0!==this.overrideMaterial&&(r=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor&&(e.getClearColor(this._oldClearColor),o=e.getClearAlpha(),e.setClearColor(this.clearColor,this.clearAlpha)),this.clearDepth&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor&&e.setClearColor(this._oldClearColor,o),void 0!==this.overrideMaterial&&(this.scene.overrideMaterial=r),e.autoClear=i}setCamera(e){this.camera=e}}class ap extends zh{constructor(e,t,n,i){super(),this.scene=e,this.camera=t,this.sampleLevel=4,this.unbiased=!0,this.clearColor=void 0!==n?n:0,this.clearAlpha=void 0!==i?i:0,this._oldClearColor=new yt;const o=ro.copy;this.copyUniformsAccum=zi.clone(o.uniforms),this.copyMaterialAccum=new Vi({type:"SSAACopyAccum",defines:Object.assign({},o.defines),uniforms:this.copyUniformsAccum,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:2,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new kh(this.copyMaterialAccum),this.copyUniformsFinal=zi.clone(o.uniforms),this.copyMaterialFinal=new Vi({type:"SSAACopyFinal",defines:Object.assign({},o.defines),uniforms:this.copyUniformsFinal,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:0,depthTest:!1,depthWrite:!1}),this.fsQuadFinal=new kh(this.copyMaterialFinal),this.iterative=!1,this.iterativeFrame=0}_getJitterOffsets(){return sp[Math.max(0,Math.min(this.sampleLevel,5))]}_isLastIterativeFrame(){const e=this._getJitterOffsets();return this.iterativeFrame==e.length-1}dispose(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null,this.accumRenderTarget.dispose(),this.accumRenderTarget=null)}setSize(e,t){this.sampleRenderTarget&&(this.sampleRenderTarget.setSize(e,t),this.accumRenderTarget.setSize(e,t))}render(e,t,n){this.sampleRenderTarget||(this.sampleRenderTarget=n.clone(),this.sampleRenderTarget.texture.name="SSAARenderPass.sample",this.accumRenderTarget=n.clone(),this.accumRenderTarget.texture.name="SSAARenderPass.accum");const i=this._getJitterOffsets(),o=e.autoClear;e.autoClear=!1,e.getClearColor(this._oldClearColor);const r=e.getClearAlpha(),a=1/i.length;this.copyUniformsAccum.tDiffuse.value=this.sampleRenderTarget.texture;const s=n.width,l=n.height,c=this.camera.view?this.camera.view.offsetX:0,u=this.camera.view?this.camera.view.offsetY:0;let d,h;this.iterative?(d=this.iterativeFrame,h=performance.now()):d=0;const p=i.length;for(let n=d;n4)break}this.iterative&&(this._isLastIterativeFrame()?(this.copyUniformsFinal.tDiffuse.value=this.accumRenderTarget.texture,e.setRenderTarget(this.renderToScreen?null:t),this.fsQuadFinal.render(e),this.iterativeFrame=0):this.iterativeFrame++),this.camera.setViewOffset&&this.camera.setViewOffset(s,l,c,u,s,l),e.autoClear=o,e.setClearColor(this._oldClearColor,r)}isLastIterativeFrame(){console.error("isLastIterativeFrame() deprectated, use pass event listener instead")}setCamera(e){this.camera=e}}const sp=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]];class lp extends zh{constructor(e,t,n){super(),this.enabled=!0,this.needsSwap=!1,n=n||{},this.objects=n.objects||[],this.steps=st(n.steps)||10,this.stride=st(n.stride)||30,this.binarySearchSteps=st(n.binarySearchSteps)||4,this.renderTargetScale=st(n.renderTargetScale)||.5,this.thickness=st(n.thickness)||.01,this.maxDistance=st(n.maxDistance)||100,this.jitter=st(n.jitter)||1,this.useRefract=st(n.useRefract)||!1,this.renderAfter=st(n.renderAfter)||[],this.simpleRefraction=st(n.simpleRefraction)||!1,this.scene=e,this.camera=t,this._prevClearColor=new yt,this._depthBuffer=new Tt(256,256,{minFilter:A,magFilter:A,format:R,type:T}),this._depthBuffer.texture.name="SSRPass.Depth",this._depthBuffer.texture.generateMipmaps=!1,this._depthMaterial=new Fa,this._depthMaterial.depthPacking=xe,this._backfaceDepthBuffer=this._depthBuffer.clone(),this._backfaceDepthBuffer.texture.name="SSRPass.Depth",this._backfaceDepthMaterial=new Fa,this._backfaceDepthMaterial.depthPacking=xe,this._backfaceDepthMaterial.side=1,this.basic=new Kn,this.fsQuad=new kh(null)}_setLayer(e,t){e.layers.set(t),e.isMesh&&e.isMaterialGeneratedMesh&&e.parent.layers.enable(t)}dispose(){this._depthBuffer.dispose(),this._backfaceDepthBuffer.dispose();for(let e=0;eMADE WITH VERGE3D TRIAL`,t.appendChild(i),setTimeout((function(){t.contains(i)&&890310108==Ye(i.textContent)||e.dispose()}),1e3)},isXML:function(e){return null!==e.match(/.*\.xml$/)},isJS:function(e){return null!==e.match(/.*\.js$/)},addToAppList:function(e){const t=ut();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))},removeFromAppList:function(e){const t=ut();if(t.v3d&&t.v3d.apps){const n=t.v3d.apps.indexOf(e);n>-1&&t.v3d.apps.splice(n,1)}},printPerformanceInfo:function(e,t){t=t||1;const n=e.renderer.info,i=n.autoReset;n.autoReset=!1,n.reset();const o=e.frame;for(let e=0;e1e4);const l=-1!=e._loadSceneURL.indexOf(".xz",e._loadSceneURL.length-3);r("Asset Compression: "+(l?"yes":"no"),0==l);const c=a/t;r("FPS: "+c,c<30);const u=n.render.calls/a;r("Render Calls: "+u,u>1e3);const d=n.render.triangles/a;r("Triangles Rendered: "+d,d>1e6),r("Geometry Buffers: "+n.memory.geometries,n.memory.geometries>200),r("HDR Rendering: "+(e.useHDR?"yes":"no"));const h=e.renderer.getDrawingBufferSize(new et);r("Viewport Resolution: "+h.x+"x"+h.y),r(`Pixel Ratio: ${e.renderer.getPixelRatio()} (current) / ${window.devicePixelRatio} (device)`);let p="N/A";switch(e._envIBLMode){case 0:p="PMREM";break;case 1:p="Light Probe + Cubemap";break;case 2:p="Light Probe"}r(`Image-Based Lighting: ${p} ${e._pmremMaxTileSize}px`);let f=0,m=0,g=0,v=0,A=0,_=0;e.scene.traverse((function(e){e.isLight&&(f++,e.castShadow&&e.shadow&&(v++,A=e.shadow.mapSize.width,_=e.shadow.mapSize.height)),e.isCubeReflectionProbe&&m++,e.isPlaneReflectionProbe&&g++})),r("Lights: "+f,f>10),r(`Reflection Probes: ${m} (cube) / ${g} (plane) `,m>3||g>1);const x=[];if(e.postprocessing){e.postprocessing.composer.passes.forEach((function(e){for(let t in up)if(e instanceof up[t])return void x.push(t);x.push("Undefined")}))}r(`Post-Processing: ${x.length?x.join(","):"N/A"}`);let y="N/A";if(v&&e.renderer.shadowMap&&e.renderer.shadowMap.enabled){switch(e.renderer.shadowMap.type){case 0:y="Basic";break;case 6:y="Bilinear";break;case 1:y="PCF";break;case 2:y="PCF (Bilinear)";break;case 5:y="PCF (Poisson Disk)";break;case 4:y="ESM";break;case 3:y="VSM";break;default:y="Unknown"}y+=` ${v}x${A}x${_}`}r("Shadow Map: "+y,v>4||A>2048||_>2048);const b=n.programs.slice(0);r("Materials and Shaders: "+b.length,b>100),b.sort((function(e,t){return t.profile.renderTime-e.profile.renderTime}));let M=0;for(let e=0;e16),M+=i,t.profile.renderTime=0}r("Total Render Time: "+String(Math.round(10*M)/10)+"ms",M>16),r("Textures & Render Buffers: "+n.memory.textures,n.memory.textures>100);const C=Array.from(n.memory.textureSpecs.values());C.sort((function(e,t){return e.typet.type?-1:e.width!=t.width?t.width-e.width:t.height-e.height}));for(let e=0;e=4096||t.height>=4096)}n.autoReset=i}),1e3*t)}},pp={prepareRenderer:function(e){const t=ls.getGPUVendor(e),n=ls.getGPUModel(e),i=ls.checkAndroid();i&&"ARM"===t&&"Mali-T760"===n&&(e.compatSettings.saturateSpecEnvBlenderApprox=!0),e.compatSettings.gtaoDisableBkgFix=i}};function fp(e){this.sourceTexture=e,this.camera=new po(-1,1,1,-1,0,1),this.shader=new Vi({type:"CubeCopy",uniforms:{faceIdx:{value:0},cubemap:{value:null}},vertexShader:"\n uniform int faceIdx;\n\n varying vec3 vCubeDirection;\n\n vec3 uvToCubeDirection(vec2 uv, int face) {\n vec3 dir;\n uv = 2.0 * uv - 1.0;\n\n if (face == 0) {\n dir = vec3(1.0, -uv.y, -uv.x);\n } else if (face == 1) {\n dir = vec3(-1.0, -uv.y, uv.x);\n } else if (face == 2) {\n dir = vec3(uv.x, 1.0, uv.y);\n } else if (face == 3) {\n dir = vec3(uv.x, -1.0, -uv.y);\n } else if (face == 4) {\n dir = vec3(uv.x, -uv.y, 1.0);\n } else if (face == 5) {\n dir = vec3(-uv.x, -uv.y, -1.0);\n }\n return dir;\n }\n\n void main() {\n vCubeDirection = uvToCubeDirection(uv, faceIdx);\n gl_Position = vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform samplerCube cubemap;\n\n varying vec3 vCubeDirection;\n\n void main() {\n gl_FragColor = textureCube(cubemap, vCubeDirection);\n\n #include \n\n gl_FragColor = linearToOutputTexel(gl_FragColor);\n }\n "}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new Di(new no(2,2),this.shader),this.scene=new mo,this.scene.add(this.camera),this.scene.add(this.planeMesh)}fp.prototype={constructor:fp,render:function(e,t,n=1){var i=e.toneMapping,o=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=1,e.toneMappingExposure=n;for(var a=0;a<6;a++)e.setRenderTarget(t,a),this.shader.uniforms.faceIdx.value=a,e.render(this.scene,this.camera);e.toneMapping=i,e.toneMappingExposure=o,e.setRenderTarget(r)},dispose:function(){this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};var mp=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],gp={disposeTextures:function(e){if(mp.forEach((function(t){e[t]&&e[t].isTexture&&e[t].dispose()})),"MeshNodeMaterial"==e.type)for(var t in e.nodeTextures)e.nodeTextures[t]&&e.nodeTextures[t].dispose()}};const vp={_useHalfFloatCubemaps:e=>!!ls.checkHalfFloatTex(e,!0)&&(!/Firefox/.test(navigator.userAgent)||!/Android/.test(navigator.userAgent)),renderSceneToCubemap(e,t,n,{camPos:i=new Bt,clipStart:o=.1,clipEnd:r=100}={}){this._useHalfFloatCubemaps(t)||(console.warn("v3d.RenderUtils: disabling half float cubemaps"),n.texture.type=C);const a=new Wi(o,r,n);a.position.copy(i);let s=e.worldMaterial;if(null!==s&&s.isMeshNodeMaterial){const i=new Di(new Oi(1,1,1),s);i.material.side=1,i.material.defines.WORLD_NODES=1,new Wi(.1,10,n).update(t,i),i.geometry.disposeBoundsTree&&i.geometry.disposeBoundsTree(),i.geometry.dispose();const o=e.background;e.background=null;const r=t.autoClearColor;t.autoClearColor=!1,a.update(t,e),t.autoClearColor=r,e.background=o}else a.update(t,e);return a.renderTarget},renderWorldNodeMatToCubemap(e,t,n,i){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");const o=new mo;return o.worldMaterial=t,this.renderSceneToCubemap(o,e,new ji(n,i))},assignAllLayersMask:function(e){const t=e.layers.mask;return e.layers.set(0),e.isArrayCamera&&(e.layers.enable(1),e.layers.enable(2)),e.layers.enable(3),e.layers.enable(4),e.layers.enable(5),e.layers.enable(6),e.layers.enable(7),t}},Ap=new Nt,_p=new en,xp=new un,yp=new Bt,bp=new Bt;class Mp extends Nn{constructor(e=256){super(),this.type="CubeReflectionProbe",this.influenceType=1,this.influenceDistance=1,this.parallaxType=1,this.parallaxDistance=1,this.probeClipStart=.1,this.probeClipEnd=100,this.probeIntensity=1,this.visibilityGroup=null,this.visibilityGroupInv=!1,this.influenceGroup=null,this.influenceGroupInv=!1,this._renderTargetCube=new ji(e,{encoding:Ae,format:R,generateMipmaps:!0,minFilter:M,type:T}),this._exposureRenderTargetCube=this._renderTargetCube.clone(),this.renderTarget=null,this.matrixWorldInverse=new un}setSize(e){this._renderTargetCube.setSize(e,e),this._exposureRenderTargetCube.setSize(e,e)}setEncoding(e){this._renderTargetCube.texture.encoding=e,this._exposureRenderTargetCube.texture.encoding=e}intersectsMesh(e){let t=!1;const n=e.geometry,i=n.boundsTree,o=xp;try{o.copy(e.matrixWorld).invert()}catch(e){return!1}switch(o.multiply(this.matrixWorld),this.influenceType){case 0:t=!0;break;case 1:_p.center.setScalar(0),_p.radius=this.influenceDistance,_p.applyMatrix4(o),i?t=i.intersectsSphere(e,_p):(null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsSphere(_p));break;case 2:const r=yp.setScalar(0),a=bp.setScalar(2*this.influenceDistance);Ap.setFromCenterAndSize(r,a),i?t=i.intersectsBox(e,Ap,o):(Ap.applyMatrix4(o),null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsBox(Ap))}return t}update(e,t){const n={};e.traverse((e=>{!e.isCubeReflectionProbe&&this._isVisible(e)||(n[e.id]=e.layers.mask,e.layers.disableAll())}));const i=e.worldMaterial,o=null!==i&&i.isMeshNodeMaterial&&i.needsLightPathDir();let r;o&&(r=i.defines.LIGHT_PATH_IS_CAM_RAY,i.defines.LIGHT_PATH_IS_CAM_RAY=0),vp.renderSceneToCubemap(e,t,this._renderTargetCube,{camPos:this.position,clipStart:this.probeClipStart,clipEnd:this.probeClipEnd}),this._exposureRenderTargetCube.texture.type=this._renderTargetCube.texture.type;const a=new fp(this._renderTargetCube.texture);a.render(t,this._exposureRenderTargetCube,this.probeIntensity),a.dispose(),this.renderTarget=this.onUpdate(this._exposureRenderTargetCube),o&&(i.defines.LIGHT_PATH_IS_CAM_RAY=r),e.traverse((e=>{!e.isCubeReflectionProbe&&this._isVisible(e)||(e.layers.mask=n[e.id])}))}onUpdate(e){return e}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)}copy(e){return super.copy(e),this.influenceType=e.influenceType,this.influenceDistance=e.influenceDistance,this.parallaxType=e.parallaxType,this.parallaxDistance=e.parallaxDistance,this.probeClipStart=e.probeClipStart,this.probeClipEnd=e.probeClipEnd,this.probeIntensity=e.probeIntensity,this.visibilityGroup=e.visibilityGroup,this.visibilityGroupInv=e.visibilityGroupInv,this.influenceGroup=e.influenceGroup,this.influenceGroupInv=e.influenceGroupInv,this.setSize(e._renderTargetCube.width),this.matrixWorldInverse.copy(e.matrixWorldInverse),this}dispose(){null!==this._renderTargetCube&&this._renderTargetCube.dispose(),null!==this._exposureRenderTargetCube&&this._exposureRenderTargetCube.dispose(),null!==this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=null),this.dispatchEvent({type:"dispose"})}_isVisible(e){if(null===this.visibilityGroup)return!0;if(!e.isMesh)return!0;return-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv}}Mp.prototype.isCubeReflectionProbe=!0;class Cp{constructor(e,t){if(this.renderer=e,void 0===t){const n=e.getSize(new et);this._pixelRatio=e.getPixelRatio(),this._width=n.width,this._height=n.height,(t=new Tt(this._width*this._pixelRatio,this._height*this._pixelRatio)).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=[],this.copyPass=new jh(ro.copy),this.clock=new Bd}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);-1!==t&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t-1&&(n=e+1);this.insertPass(e,n)}enableAllPasses(){for(let e=0;eMath.PI&&(s=a+Math.sign(a-s)*(2*Math.PI-l)),this.sphericalFrom.theta=a,this.sphericalTo.theta=s}return this}),start(e){this.active=!0,this.duration=e,this.clock.start()},update:(Sp=new Bt,wp=new Bt,function(e=function(e,t,n){}){var t=this.clock.getElapsedTime()/this.duration;if(t=Ge(t,0,1),wp.lerpVectors(this.targetFrom,this.targetTo,t),0===this.movementType)Sp.lerpVectors(this.posFrom,this.posTo,t);else if(1===this.movementType){var n=Ve(this.sphericalFrom.radius,this.sphericalTo.radius,t),i=Ve(this.sphericalFrom.phi,this.sphericalTo.phi,t),o=Ve(this.sphericalFrom.theta,this.sphericalTo.theta,t);Sp.setFromSphericalCoords(n,i,o),Sp.add(wp)}e(t,Sp,wp),t>=1&&(this.active=!1,this.finishCb())})}),Object.assign(Lp.prototype,{setup:function({posFrom:e=new Bt,targetFrom:t=new Bt,posTo:n=new Bt,targetTo:i=new Bt,zoomFrom:o=0,zoomTo:r=0,finishCb:a=function(){}}){return this.posFrom.copy(e),this.targetFrom.copy(t),this.posTo.copy(n),this.targetTo.copy(i),this.zoomFrom=o,this.zoomTo=r,this.finishCb=a,this},start(e){this.active=!0,this.duration=e,this.clock.start()},update:function(){const e=new Bt;return function(t=function(e,t,n){}){let n=this.clock.getElapsedTime()/this.duration;n=Ge(n,0,1),e.lerpVectors(this.targetFrom,this.targetTo,n);let i=Ve(this.zoomFrom,this.zoomTo,n);t(n,e,i),n>=1&&(this.active=!1,this.finishCb())}}()});const Bp={gazeLevel:1.8,enablePan:!0,panInertia:.05,panSpeedKey:.15,enableRotate:!0,rotateInertia:.05,rotateInertiaTouch:.05,rotateSpeed:.9,rotateSpeedTouch:.75,storyHeight:3,enableZoom:!0,zoomInertia:.05,zoomSpeed:30,zoomSpeedKey:.2,enableDamping:!0,enableKeys:!0};var Pp=.001;class Dp extends Be{constructor(e,t){super();var n=this;this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.screen={left:0,top:0,width:0,height:0},this.enableDamping=Bp.enableDamping,this.enableRotate=Bp.enableRotate,this.rotateSpeed=Bp.rotateSpeed,this.rotateSpeedTouch=Bp.rotateSpeedTouch,this.rotateInertia=Bp.rotateInertia,this.rotateInertiaTouch=Bp.rotateInertiaTouch,this.enableZoom=Bp.enableZoom,this.zoomSpeed=Bp.zoomSpeed,this.zoomSpeedKey=Bp.zoomSpeedKey,this.zoomInertia=Bp.zoomInertia,this.enablePan=Bp.enablePan,this.panSpeedKey=Bp.panSpeedKey,this.panInertia=Bp.panInertia,this.enableKeys=Bp.enableKeys,this.gazeLevel=Bp.gazeLevel,this.storyHeight=Bp.storyHeight,this.collisionMeshes=[];let i=!1;Object.defineProperty(this,"enablePointerLock",{get:()=>i,set(e){i!==e&&(i=e,q())}}),Object.defineProperty(this,"inTween",{get:()=>R.active||L.active});var o,r=new Bd,a=1e-6,s=new Bt,l=new Bt,c=new Bt,u=new Bt,d=new Lt,h=new Bt,p={};p[Tp.W]=p[Tp.S]=p[Tp.A]=p[Tp.D]=p[Tp.UP_ARROW]=p[Tp.DOWN_ARROW]=p[Tp.LEFT_ARROW]=p[Tp.RIGHT_ARROW]=0;var f=!1,m=new xu,g=new xu,v=new et,A=1,_=1,x=new et,y=new et,b=0,M=0,C=1,S=1,w=new et,E=new et,T=new is(new Bt,new Bt(0,-1,0));T.params.checkVisibility=!1;var I=!1,R=new Rp;const L=new Lp;var B={type:"change"},P={type:"start"},D={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var N,O=(N=new et,function(e,t){return N.set((e-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-t))/n.screen.width),N});const F=function(){const e=new et;return function(t,i){return e.set(t,-i).multiplyScalar(2/n.screen.width)}}();function U(e){!1!==n.enabled&&(e.preventDefault(),!1!==n.enableRotate&&(y.copy(O(e.pageX,e.pageY).negate()),x.copy(y),f=!0,document.addEventListener("mousemove",z),document.addEventListener("mouseup",V),document.addEventListener("mouseleave",V),n.dispatchEvent(P)))}function z(e){if(!1!==n.enabled&&(e.preventDefault(),f)){if(!1===n.enableRotate)return;y.copy(O(e.pageX,e.pageY).negate()),v.add(y).sub(x),x.copy(y),A=n.rotateSpeed,_=n.rotateInertia}}function V(e){!1!==n.enabled&&(e.preventDefault(),f=!1,document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V),n.dispatchEvent(D))}function G(e){if(!1!==n.enabled&&!1!==n.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:M-=.025*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia;break;case 1:M-=.01*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia;break;default:M-=25e-5*e.deltaY,C=n.zoomSpeed,S=n.zoomInertia}n.dispatchEvent(P),n.dispatchEvent(D)}}function k(e){if(!1!==n.enabled){var t=e.touches[0];f=!0,y.copy(O(t.pageX,t.pageY).negate()),x.copy(y),n.dispatchEvent(P)}}function Q(e){if(!1!==n.enabled){e.preventDefault();var t=e.touches[0];!1!==n.enableRotate&&(y.copy(O(t.pageX,t.pageY).negate()),v.add(y).sub(x),x.copy(y),A=n.rotateSpeedTouch,_=n.rotateInertiaTouch)}}function W(e){if(!1!==n.enabled){if(0===e.touches.length)f=!1;else{if(!1===n.enableRotate)return;f=!0,y.copy(O(e.touches[0].pageX,e.touches[0].pageY).negate()),x.copy(y)}n.dispatchEvent(D)}}function H(e){!1!==n.enabled&&e.preventDefault()}function j(e){n.domElement.requestPointerLock()}function Y(e){document.pointerLockElement===n.domElement?(n.dispatchEvent(P),document.addEventListener("mousemove",K)):(n.dispatchEvent(D),document.removeEventListener("mousemove",K))}function X(e){console.error("Pointer lock failed")}function K(e){e.preventDefault(),n.enabled&&n.enableRotate&&(v.add(F(e.movementX,e.movementY).negate()),A=n.rotateSpeed,_=n.rotateInertia)}function q(){Z(),n.domElement.addEventListener("contextmenu",H),n.enablePointerLock?(n.domElement.addEventListener("click",j),document.addEventListener("pointerlockchange",Y),document.addEventListener("pointerlockerror",X)):n.domElement.addEventListener("mousedown",U),n.domElement.addEventListener("wheel",G,{passive:!1}),n.domElement.addEventListener("touchstart",k,{passive:!0}),n.domElement.addEventListener("touchend",W),n.domElement.addEventListener("touchmove",Q,{passive:!1}),(o=new Ip(window)).onKeyDown=function(e){e.keyCode in p&&(p[e.keyCode]=1)}}function Z(){n.domElement.removeEventListener("contextmenu",H),n.domElement.removeEventListener("click",j),document.removeEventListener("pointerlockchange",Y),document.removeEventListener("pointerlockerror",X),document.removeEventListener("mousemove",K),n.domElement.removeEventListener("mousedown",U),n.domElement.removeEventListener("wheel",G),n.domElement.removeEventListener("touchstart",k),n.domElement.removeEventListener("touchend",W),n.domElement.removeEventListener("touchmove",Q),document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",V),document.removeEventListener("mouseleave",V),o&&o.dispose()}this.update=function(){if(R.active?R.update((function(e,t,i){if(n.object.position.copy(t),n.object.lookAt(i),e>=1){for(var o in g.set(0,0,0),v.set(0,0),b=0,M=0,w.set(0,0),E.set(0,0),p)p[o]=0;r.getDelta()}})):L.active?L.update((function(e,t,i){if(n.object.lookAt(t),n.object.zoom=i,n.object.updateProjectionMatrix(),e>=1){g.set(0,0,0),v.set(0,0),b=0,M=0,w.set(0,0),E.set(0,0);for(let e in p)p[e]=0;r.getDelta()}})):(n.object.getLocalDirection(h),m.setFromVector3(h),m.theta+=g.theta*A,m.phi+=g.phi*A,m.makeSafe(),h.setFromSpherical(m),s.copy(h).add(n.object.position),n.object.lookAtLocal(s),n.object.isPerspectiveCamera?n.object.position.addScaledVector(h,b):n.object.isOrthographicCamera&&(n.object.zoom*=1+.15*b,n.object.updateProjectionMatrix()),l.copy(h).cross(n.object.up).setLength(-w.x),l.add(c.copy(n.object.up).setLength(w.y)),n.object.position.add(l),function(){var e=r.getDelta();for(var t in g.set(g.radius,v.y,v.x),v.x=n.enableDamping?Ke(v.x,0,e,_,.001):0,v.y=n.enableDamping?Ke(v.y,0,e,_,.001):0,g.set(g.radius,g.phi-v.y,g.theta-v.x),w.copy(E),E.x=n.enableDamping?Ke(E.x,0,e,1,Pp):0,E.y=n.enableDamping?Ke(E.y,0,e,1,Pp):0,w.sub(E),w.multiplyScalar(1),b=M,M=n.enableDamping?Ke(M,0,e,S,.001):0,b-=M,b*=C,p){var i=t==Tp.A||t==Tp.LEFT_ARROW||t==Tp.D||t==Tp.RIGHT_ARROW,a=t==Tp.W||t==Tp.UP_ARROW||t==Tp.S||t==Tp.DOWN_ARROW,s=i?n.panInertia:n.zoomInertia,l=i?n.panSpeedKey:n.zoomSpeedKey,c=i?Pp:.001;if(o.isKeyDown[t])var u=p[t]=1;else{var d=p[t];p[t]=Ke(p[t],0,e,s,c),u=d-p[t]}n.enabled&&n.enableKeys&&(i&&!n.enablePan||a&&!n.enableZoom||(u*=60*e*l,t==Tp.A||t==Tp.LEFT_ARROW?w.x+=u:t==Tp.D||t==Tp.RIGHT_ARROW?w.x-=u:t==Tp.W||t==Tp.UP_ARROW?b+=u:t!=Tp.S&&t!=Tp.DOWN_ARROW||(b-=u)))}}()),n.collisionMeshes.length){T.ray.origin.copy(n.object.position),T.far=n.storyHeight;var e=T.intersectObjects(n.collisionMeshes,!1);if(e.length>0){var t=e[0];n.object.position.y=t.point.y+n.gazeLevel,I=!0}else I&&n.object.position.copy(u)}var i=!1;u.distanceToSquared(n.object.position)>a&&(u.copy(n.object.position),i=!0),d.dot(n.object.quaternion)<1-a&&(d.copy(n.object.quaternion),i=!0),i&&n.dispatchEvent(B)},this.forceMouseUp=function(){V({preventDefault:function(){}})},this.dispose=Z,this.releaseFromCollision=function(){I=!1},this.tween=function(){var e=new Bt,t=new Bt,i=new Bt;return function(o,r,a,s,l){n.object.parent&&(o=e.copy(o),n.object.parent.worldToLocal(o));var c=n.object.getWorldPosition(t),u=i.subVectors(r,c).length(),d=n.object.getWorldDirection(i).multiplyScalar(u).add(c),h=1e-5;o.manhattanDistanceTo(n.object.position)G.active||k.active});var u=new Bd,d=1e-6,h=new Bt,p=new Bt,f=new Bt,m=new et,g=new Bt,v=new Lt,A=o,_=new Bt,x={};x[Tp.W]=x[Tp.S]=x[Tp.A]=x[Tp.D]=x[Tp.UP_ARROW]=x[Tp.DOWN_ARROW]=x[Tp.LEFT_ARROW]=x[Tp.RIGHT_ARROW]=0;var y=new Ip(window);y.onKeyDown=function(e){e.keyCode in x&&(x[e.keyCode]=1)};var b=new xu,M=new xu,C=new et,S=1,w=1,E=new et,T=new et,I=0,R=0,L=1,B=1,P=0,D=0,N=new et,O=new et,F=1,U=1,z=new et,V=new et,G=new Rp;const k=new Lp;var Q={type:"change"},W={type:"start"},H={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}},this.handleEvent=function(e){"function"==typeof this[e.type]&&this[e.type](e)};var j,Y=(j=new et,function(e,t){return j.set((e-i.screen.left)/i.screen.width,(t-i.screen.top)/i.screen.height),j}),X=function(){var e=new et;return function(t,n){return e.set((t-.5*i.screen.width-i.screen.left)/(.5*i.screen.width),(i.screen.height+2*(i.screen.top-n))/i.screen.width),e}}();function K(e){if(!1!==i.enabled){switch(e.preventDefault(),e.button){case i.mouseButtons.ROTATE:if(!1===i.enableRotate)return;T.copy(X(e.pageX,e.pageY).negate()),E.copy(T),A=r;break;case i.mouseButtons.ZOOM:case i.mouseButtons.PAN:if(!1===i.enablePan)return;z.copy(Y(e.pageX,e.pageY)),V.copy(z),A=e.button==i.mouseButtons.PAN?s:a}document.addEventListener("mousemove",q),document.addEventListener("mouseup",Z),document.addEventListener("mouseleave",Z),i.dispatchEvent(W)}}function q(e){if(!1!==i.enabled)if(e.preventDefault(),A===r){if(!1===i.enableRotate)return;T.copy(X(e.pageX,e.pageY).negate()),C.add(T).sub(E),E.copy(T),S=i.rotateSpeed,w=i.rotateInertia}else if(A===s||A===a){if(!1===i.enablePan)return;V.copy(Y(e.pageX,e.pageY)),O.add(V).sub(z),z.copy(V),F=i.panSpeed,U=i.panInertia}}function Z(e){!1!==i.enabled&&(e.preventDefault(),A=o,document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z),document.removeEventListener("mouseleave",Z),i.dispatchEvent(H))}function J(e){if(!1!==i.enabled&&!1!==i.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:R-=.025*e.deltaY,L=i.zoomSpeed,B=i.zoomInertia;break;case 1:R-=.01*e.deltaY,L=i.zoomSpeed,B=i.zoomInertia;break;default:R-=25e-5*e.deltaY,L=i.zoomSpeed,B=i.zoomInertia}i.dispatchEvent(W),i.dispatchEvent(H)}}function $(e){if(!1!==i.enabled){var t=e.touches[0],n=e.touches[1];if(1===e.touches.length){if(!1===i.enableRotate)return;A=l,T.copy(X(t.pageX,t.pageY).negate()),E.copy(T)}else{if(!1===i.enableZoom&&!1===i.enablePan)return;if(A=c,i.enableZoom){var o=Y(t.pageX-n.pageX,t.pageY-n.pageY);P=D=o.length()}if(i.enablePan){var r=Y((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2);z.copy(r),V.copy(z)}}i.dispatchEvent(W)}}function ee(e){if(!1!==i.enabled){e.preventDefault();var t=e.touches[0],n=e.touches[1];if(1===e.touches.length){if(!1===i.enableRotate)return;T.copy(X(t.pageX,t.pageY).negate()),C.add(T).sub(E),E.copy(T),S=i.rotateSpeedTouch,w=i.rotateInertiaTouch}else{if(!1===i.enableZoom&&!1===i.enablePan)return;var o=Y(t.pageX-n.pageX,t.pageY-n.pageY),r=(D=o.length())-P;P=D;var a=Y((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2);V.copy(a);var s=m.subVectors(V,z),l=s.length();z.copy(V),i.enableZoom&&Math.abs(r)>Math.abs(l)&&(R+=r,L=i.zoomSpeedTouch,B=i.zoomInertiaTouch),i.enablePan&&Math.abs(r)<=Math.abs(l)&&(O.add(s),F=i.panSpeedTouch,U=i.panInertiaTouch)}}}function te(e){if(!1!==i.enabled){switch(e.touches.length){case 0:A=o;break;case 1:if(!1===i.enableRotate)return;A=l,T.copy(X(e.touches[0].pageX,e.touches[0].pageY).negate()),E.copy(T)}i.dispatchEvent(H)}}function ne(e){!1!==i.enabled&&e.preventDefault()}this.update=function(){G.active?G.update((function(e,t,n){if(i.object.position.copy(t),i.object.lookAt(n),e>=1){for(var o in M.set(0,0,0),C.set(0,0),I=0,R=0,N.set(0,0),O.set(0,0),x)x[o]=0;u.getDelta()}})):k.active?k.update((function(e,t,n){if(i.object.lookAt(t),i.object.zoom=n,i.object.updateProjectionMatrix(),e>=1){M.set(0,0,0),C.set(0,0),I=0,R=0,N.set(0,0),O.set(0,0);for(let e in x)x[e]=0;u.getDelta()}})):(i.object.getLocalDirection(_),b.setFromVector3(_),b.theta+=M.theta*S,b.phi+=M.phi*S,b.theta=Math.max(i.minAzimuthAngle,Math.min(i.maxAzimuthAngle,b.theta)),b.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,b.phi)),b.makeSafe(),_.setFromSpherical(b),h.copy(_).add(i.object.position),i.object.lookAtLocal(h),i.object.isPerspectiveCamera?i.object.position.addScaledVector(_,I):i.object.isOrthographicCamera&&(i.object.zoom*=1+.15*I,i.object.updateProjectionMatrix()),p.copy(_).cross(i.object.up).setLength(-N.x),p.add(f.copy(i.object.up).setLength(N.y)),i.object.position.add(p),function(){var e=u.getDelta();for(var t in M.set(M.radius,C.y,C.x),C.x=i.enableDamping?Ke(C.x,0,e,w,.001):0,C.y=i.enableDamping?Ke(C.y,0,e,w,.001):0,M.set(M.radius,M.phi-C.y,M.theta-C.x),N.copy(O),O.x=i.enableDamping?Ke(O.x,0,e,U,Op):0,O.y=i.enableDamping?Ke(O.y,0,e,U,Op):0,N.sub(O),N.multiplyScalar(F),I=R,R=i.enableDamping?Ke(R,0,e,B,.001):0,I-=R,I*=L,x){var n=t==Tp.A||t==Tp.LEFT_ARROW||t==Tp.D||t==Tp.RIGHT_ARROW,o=t==Tp.W||t==Tp.UP_ARROW||t==Tp.S||t==Tp.DOWN_ARROW,r=n?i.panInertia:i.zoomInertia,a=n?i.panSpeedKey:i.zoomSpeedKey,s=n?Op:.001;if(y.isKeyDown[t])var l=x[t]=1;else{var c=x[t];x[t]=Ke(x[t],0,e,r,s),l=c-x[t]}i.enabled&&i.enableKeys&&(n&&!i.enablePan||o&&!i.enableZoom||(l*=60*e*a,t==Tp.A||t==Tp.LEFT_ARROW?N.x+=l:t==Tp.D||t==Tp.RIGHT_ARROW?N.x-=l:t==Tp.W||t==Tp.UP_ARROW?I+=l:t!=Tp.S&&t!=Tp.DOWN_ARROW||(I-=l)))}}());var e=!1;g.distanceToSquared(i.object.position)>d&&(g.copy(i.object.position),e=!0),v.dot(i.object.quaternion)<1-d&&(v.copy(i.object.quaternion),e=!0),e&&i.dispatchEvent(Q)},this.forceMouseUp=function(){Z({preventDefault:function(){}})},this.dispose=function(){this.domElement.removeEventListener("contextmenu",ne),this.domElement.removeEventListener("mousedown",K),this.domElement.removeEventListener("wheel",J),this.domElement.removeEventListener("touchstart",$),this.domElement.removeEventListener("touchend",te),this.domElement.removeEventListener("touchmove",ee),document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",Z),document.removeEventListener("mouseleave",Z),y.dispose()},this.tween=function(){var e=new Bt,t=new Bt,n=new Bt;return function(o,r,a,s,l){i.object.parent&&(o=e.copy(o),i.object.parent.worldToLocal(o));var c=i.object.getWorldPosition(t),u=n.subVectors(r,c).length(),d=i.object.getWorldDirection(n).multiplyScalar(u).add(c),h=1e-5;o.manhattanDistanceTo(i.object.position){l||(s=require("fs"),l=require("path"))},o=function(e,t){var n=W(e);return n?t?n:n.toString():(c(),e=l.normalize(e),s.readFileSync(e,t?null:"utf8"))},a=e=>{var t=o(e,!0);return t.buffer||(t=new Uint8Array(t)),t},r=(e,t,n)=>{var i=W(e);i&&t(i),c(),e=l.normalize(e),s.readFile(e,(function(e,i){e?n(e):t(i.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",(function(e){if(!(e instanceof q))throw e})),process.on("unhandledRejection",(function(e){throw e})),e.inspect=function(){return"[Emscripten Module object]"}):(d||h)&&(h?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),Up&&(f=Up),f=0!==f.indexOf("blob:")?f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):"",o=e=>{try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText}catch(t){var n=W(e);if(n)return function(e){for(var t=[],n=0;n255&&(i&=255),t.push(String.fromCharCode(i))}return t.join("")}(n);throw t}},h&&(a=e=>{try{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}catch(t){var n=W(e);if(n)return n;throw t}}),r=(e,t,n)=>{var i=new XMLHttpRequest;i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=()=>{if(200==i.status||0==i.status&&i.response)t(i.response);else{var o=W(e);o?t(o.buffer):n()}},i.onerror=n,i.send(null)}),e.print||console.log.bind(console);var m,g=e.printErr||console.warn.bind(console);i(e,u),u=null,e.arguments&&e.arguments,e.thisProgram&&e.thisProgram,e.quit&&e.quit,e.wasmBinary&&(m=e.wasmBinary);var v;e.noExitRuntime;"object"!=typeof WebAssembly&&B("no native wasm support detected");var A=!1;function _(t){return e["_"+t]}function x(e,t,n,i,o){var r={string:function(e){var t=0;if(null!=e&&0!==e){var n=1+(e.length<<2);!function(e,t,n){!function(e,t,n,i){if(!(i>0))return 0;for(var o=n+i-1,r=0;r=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++r)),a<=127){if(n>=o)break;t[n++]=a}else if(a<=2047){if(n+1>=o)break;t[n++]=192|a>>6,t[n++]=128|63&a}else if(a<=65535){if(n+2>=o)break;t[n++]=224|a>>12,t[n++]=128|a>>6&63,t[n++]=128|63&a}else{if(n+3>=o)break;t[n++]=240|a>>18,t[n++]=128|a>>12&63,t[n++]=128|a>>6&63,t[n++]=128|63&a}}t[n]=0}(e,M,t,n)}(e,t=K(n),n)}return t},array:function(e){var t=K(e.length);return function(e,t){b.set(e,t)}(e,t),t}};function a(e){return"string"===t?(n=e)?function(e,t,n){for(var i=t+n,o=t;e[o]&&!(o>=i);)++o;if(o-t>16&&e.subarray&&C)return C.decode(e.subarray(t,o));for(var r="";t>10,56320|1023&c)}}else r+=String.fromCharCode((31&a)<<6|s)}else r+=String.fromCharCode(a)}return r}(M,n,i):"":"boolean"===t?Boolean(e):e;var n,i}var s=_(e),l=[],c=0;if(i)for(var u=0;u0;){var n=t.shift();if("function"!=typeof n){var i=n.func;"number"==typeof i?void 0===n.arg?G(i)():G(i)(n.arg):i(void 0===n.arg?null:n.arg)}else n(e)}}O(P="data:application/octet-stream;base64,AGFzbQEAAAABIwdgAX8AYAABf2ABfwF/YAN/f38Bf2ADf39/AGACf38AYAAAAg0CAWEBYQACAWEBYgADAxoZBAMCAAIFBgQCAAQDAQEBAQIAAQEBAAAAAAQFAXABAQEFBwEBgAKAgAIGCQF/AUHQpIADCwdBEAFjAgABZAAIAWUAEQFmABABZwAPAWgADgFpABoBagAZAWsAGAFsABcBbQAWAW4AFQFvAQABcAAUAXEAEwFyABIKl6QBGf0DAQJ/IAJBgARPBEAgACABIAIQARoPCyAAIAJqIQMCQCAAIAFzQQNxRQRAAkAgAEEDcUUEQCAAIQIMAQsgAkUEQCAAIQIMAQsgACECA0AgAiABLQAAOgAAIAFBAWohASACQQFqIgJBA3FFDQEgAiADSQ0ACwsCQCADQXxxIgBBwABJDQAgAiAAQUBqIgRLDQADQCACIAEoAgA2AgAgAiABKAIENgIEIAIgASgCCDYCCCACIAEoAgw2AgwgAiABKAIQNgIQIAIgASgCFDYCFCACIAEoAhg2AhggAiABKAIcNgIcIAIgASgCIDYCICACIAEoAiQ2AiQgAiABKAIoNgIoIAIgASgCLDYCLCACIAEoAjA2AjAgAiABKAI0NgI0IAIgASgCODYCOCACIAEoAjw2AjwgAUFAayEBIAJBQGsiAiAETQ0ACwsgACACTQ0BA0AgAiABKAIANgIAIAFBBGohASACQQRqIgIgAEkNAAsMAQsgA0EESQRAIAAhAgwBCyAAIANBBGsiBEsEQCAAIQIMAQsgACECA0AgAiABLQAAOgAAIAIgAS0AAToAASACIAEtAAI6AAIgAiABLQADOgADIAFBBGohASACQQRqIgIgBE0NAAsLIAIgA0kEQANAIAIgAS0AADoAACABQQFqIQEgAkEBaiICIANHDQALCwujAQEBfyACQX9zIQICQCABRQ0AIAFBAXEEfyAALQAAIAJB/wFxc0ECdEGwCGooAgAgAkEIdnMhAiAAQQFqIQAgAUEBawUgAQshAyABQQFGDQADQCAALQABIAAtAAAgAkH/AXFzQQJ0QbAIaigCACACQQh2cyIBQf8BcXNBAnRBsAhqKAIAIAFBCHZzIQIgAEECaiEAIANBAmsiAw0ACwsgAkF/cwtRAQJ/QaAIKAIAIgEgAEEDakF8cSICaiEAAkAgAkEAIAAgAU0bDQAgAD8AQRB0SwRAIAAQAEUNAQtBoAggADYCACABDwtB1KDAAEEwNgIAQX8L8QwBB38CQCAARQ0AIABBCGsiAyAAQQRrKAIAIgFBeHEiAGohBQJAIAFBAXENACABQQNxRQ0BIAMgAygCACIBayIDQeigwAAoAgBJDQEgACABaiEAIANB7KDAACgCAEcEQCABQf8BTQRAIAMoAggiAiABQQN2IgRBA3RBgKHAAGpGGiACIAMoAgwiAUYEQEHYoMAAQdigwAAoAgBBfiAEd3E2AgAMAwsgAiABNgIMIAEgAjYCCAwCCyADKAIYIQYCQCADIAMoAgwiAUcEQCADKAIIIgIgATYCDCABIAI2AggMAQsCQCADQRRqIgIoAgAiBA0AIANBEGoiAigCACIEDQBBACEBDAELA0AgAiEHIAQiAUEUaiICKAIAIgQNACABQRBqIQIgASgCECIEDQALIAdBADYCAAsgBkUNAQJAIAMgAygCHCICQQJ0QYijwABqIgQoAgBGBEAgBCABNgIAIAENAUHcoMAAQdygwAAoAgBBfiACd3E2AgAMAwsgBkEQQRQgBigCECADRhtqIAE2AgAgAUUNAgsgASAGNgIYIAMoAhAiAgRAIAEgAjYCECACIAE2AhgLIAMoAhQiAkUNASABIAI2AhQgAiABNgIYDAELIAUoAgQiAUEDcUEDRw0AQeCgwAAgADYCACAFIAFBfnE2AgQgAyAAQQFyNgIEIAAgA2ogADYCAA8LIAMgBU8NACAFKAIEIgFBAXFFDQACQCABQQJxRQRAIAVB8KDAACgCAEYEQEHwoMAAIAM2AgBB5KDAAEHkoMAAKAIAIABqIgA2AgAgAyAAQQFyNgIEIANB7KDAACgCAEcNA0HgoMAAQQA2AgBB7KDAAEEANgIADwsgBUHsoMAAKAIARgRAQeygwAAgAzYCAEHgoMAAQeCgwAAoAgAgAGoiADYCACADIABBAXI2AgQgACADaiAANgIADwsgAUF4cSAAaiEAAkAgAUH/AU0EQCAFKAIIIgIgAUEDdiIEQQN0QYChwABqRhogAiAFKAIMIgFGBEBB2KDAAEHYoMAAKAIAQX4gBHdxNgIADAILIAIgATYCDCABIAI2AggMAQsgBSgCGCEGAkAgBSAFKAIMIgFHBEAgBSgCCCICQeigwAAoAgBJGiACIAE2AgwgASACNgIIDAELAkAgBUEUaiICKAIAIgQNACAFQRBqIgIoAgAiBA0AQQAhAQwBCwNAIAIhByAEIgFBFGoiAigCACIEDQAgAUEQaiECIAEoAhAiBA0ACyAHQQA2AgALIAZFDQACQCAFIAUoAhwiAkECdEGIo8AAaiIEKAIARgRAIAQgATYCACABDQFB3KDAAEHcoMAAKAIAQX4gAndxNgIADAILIAZBEEEUIAYoAhAgBUYbaiABNgIAIAFFDQELIAEgBjYCGCAFKAIQIgIEQCABIAI2AhAgAiABNgIYCyAFKAIUIgJFDQAgASACNgIUIAIgATYCGAsgAyAAQQFyNgIEIAAgA2ogADYCACADQeygwAAoAgBHDQFB4KDAACAANgIADwsgBSABQX5xNgIEIAMgAEEBcjYCBCAAIANqIAA2AgALIABB/wFNBEAgAEEDdiIBQQN0QYChwABqIQACf0HYoMAAKAIAIgJBASABdCIBcUUEQEHYoMAAIAEgAnI2AgAgAAwBCyAAKAIICyECIAAgAzYCCCACIAM2AgwgAyAANgIMIAMgAjYCCA8LQR8hAiADQgA3AhAgAEH///8HTQRAIABBCHYiASABQYD+P2pBEHZBCHEiAXQiAiACQYDgH2pBEHZBBHEiAnQiBCAEQYCAD2pBEHZBAnEiBHRBD3YgASACciAEcmsiAUEBdCAAIAFBFWp2QQFxckEcaiECCyADIAI2AhwgAkECdEGIo8AAaiEBAkACQAJAQdygwAAoAgAiBEEBIAJ0IgdxRQRAQdygwAAgBCAHcjYCACABIAM2AgAgAyABNgIYDAELIABBAEEZIAJBAXZrIAJBH0YbdCECIAEoAgAhAQNAIAEiBCgCBEF4cSAARg0CIAJBHXYhASACQQF0IQIgBCABQQRxaiIHQRBqKAIAIgENAAsgByADNgIQIAMgBDYCGAsgAyADNgIMIAMgAzYCCAwBCyAEKAIIIgAgAzYCDCAEIAM2AgggA0EANgIYIAMgBDYCDCADIAA2AggLQfigwABB+KDAACgCAEEBayIAQX8gABs2AgALC5IvAQt/IwBBEGsiCyQAAkACQAJAAkACQAJAAkACQAJAAkACQCAAQfQBTQRAQdigwAAoAgAiBkEQIABBC2pBeHEgAEELSRsiB0EDdiICdiIBQQNxBEAgAUF/c0EBcSACaiIDQQN0IgFBiKHAAGooAgAiBEEIaiEAAkAgBCgCCCICIAFBgKHAAGoiAUYEQEHYoMAAIAZBfiADd3E2AgAMAQsgAiABNgIMIAEgAjYCCAsgBCADQQN0IgFBA3I2AgQgASAEaiIBIAEoAgRBAXI2AgQMDAsgB0HgoMAAKAIAIgpNDQEgAQRAAkBBAiACdCIAQQAgAGtyIAEgAnRxIgBBACAAa3FBAWsiACAAQQx2QRBxIgJ2IgFBBXZBCHEiACACciABIAB2IgFBAnZBBHEiAHIgASAAdiIBQQF2QQJxIgByIAEgAHYiAUEBdkEBcSIAciABIAB2aiIDQQN0IgBBiKHAAGooAgAiBCgCCCIBIABBgKHAAGoiAEYEQEHYoMAAIAZBfiADd3EiBjYCAAwBCyABIAA2AgwgACABNgIICyAEQQhqIQAgBCAHQQNyNgIEIAQgB2oiAiADQQN0IgEgB2siA0EBcjYCBCABIARqIAM2AgAgCgRAIApBA3YiAUEDdEGAocAAaiEFQeygwAAoAgAhBAJ/IAZBASABdCIBcUUEQEHYoMAAIAEgBnI2AgAgBQwBCyAFKAIICyEBIAUgBDYCCCABIAQ2AgwgBCAFNgIMIAQgATYCCAtB7KDAACACNgIAQeCgwAAgAzYCAAwMC0HcoMAAKAIAIglFDQEgCUEAIAlrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QYijwABqKAIAIgEoAgRBeHEgB2shAyABIQIDQAJAIAIoAhAiAEUEQCACKAIUIgBFDQELIAAoAgRBeHEgB2siAiADIAIgA0kiAhshAyAAIAEgAhshASAAIQIMAQsLIAEoAhghCCABIAEoAgwiBEcEQCABKAIIIgBB6KDAACgCAEkaIAAgBDYCDCAEIAA2AggMCwsgAUEUaiICKAIAIgBFBEAgASgCECIARQ0DIAFBEGohAgsDQCACIQUgACIEQRRqIgIoAgAiAA0AIARBEGohAiAEKAIQIgANAAsgBUEANgIADAoLQX8hByAAQb9/Sw0AIABBC2oiAEF4cSEHQdygwAAoAgAiCUUNAEEAIAdrIQMCQAJAAkACf0EAIAdBgAJJDQAaQR8gB0H///8HSw0AGiAAQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgByAAQRVqdkEBcXJBHGoLIgZBAnRBiKPAAGooAgAiAkUEQEEAIQAMAQtBACEAIAdBAEEZIAZBAXZrIAZBH0YbdCEBA0ACQCACKAIEQXhxIAdrIgUgA08NACACIQQgBSIDDQBBACEDIAIhAAwDCyAAIAIoAhQiBSAFIAIgAUEddkEEcWooAhAiAkYbIAAgBRshACABQQF0IQEgAg0ACwsgACAEckUEQEEAIQRBAiAGdCIAQQAgAGtyIAlxIgBFDQMgAEEAIABrcUEBayIAIABBDHZBEHEiAnYiAUEFdkEIcSIAIAJyIAEgAHYiAUECdkEEcSIAciABIAB2IgFBAXZBAnEiAHIgASAAdiIBQQF2QQFxIgByIAEgAHZqQQJ0QYijwABqKAIAIQALIABFDQELA0AgACgCBEF4cSAHayIBIANJIQIgASADIAIbIQMgACAEIAIbIQQgACgCECIBBH8gAQUgACgCFAsiAA0ACwsgBEUNACADQeCgwAAoAgAgB2tPDQAgBCgCGCEGIAQgBCgCDCIBRwRAIAQoAggiAEHooMAAKAIASRogACABNgIMIAEgADYCCAwJCyAEQRRqIgIoAgAiAEUEQCAEKAIQIgBFDQMgBEEQaiECCwNAIAIhBSAAIgFBFGoiAigCACIADQAgAUEQaiECIAEoAhAiAA0ACyAFQQA2AgAMCAsgB0HgoMAAKAIAIgJNBEBB7KDAACgCACEDAkAgAiAHayIBQRBPBEBB4KDAACABNgIAQeygwAAgAyAHaiIANgIAIAAgAUEBcjYCBCACIANqIAE2AgAgAyAHQQNyNgIEDAELQeygwABBADYCAEHgoMAAQQA2AgAgAyACQQNyNgIEIAIgA2oiACAAKAIEQQFyNgIECyADQQhqIQAMCgsgB0HkoMAAKAIAIghJBEBB5KDAACAIIAdrIgE2AgBB8KDAAEHwoMAAKAIAIgIgB2oiADYCACAAIAFBAXI2AgQgAiAHQQNyNgIEIAJBCGohAAwKC0EAIQAgB0EvaiIJAn9BsKTAACgCAARAQbikwAAoAgAMAQtBvKTAAEJ/NwIAQbSkwABCgKCAgICABDcCAEGwpMAAIAtBDGpBcHFB2KrVqgVzNgIAQcSkwABBADYCAEGUpMAAQQA2AgBBgCALIgFqIgZBACABayIFcSICIAdNDQlBkKTAACgCACIEBEBBiKTAACgCACIDIAJqIgEgA00NCiABIARLDQoLQZSkwAAtAABBBHENBAJAAkBB8KDAACgCACIDBEBBmKTAACEAA0AgAyAAKAIAIgFPBEAgASAAKAIEaiADSw0DCyAAKAIIIgANAAsLQQAQBCIBQX9GDQUgAiEGQbSkwAAoAgAiA0EBayIAIAFxBEAgAiABayAAIAFqQQAgA2txaiEGCyAGIAdNDQUgBkH+////B0sNBUGQpMAAKAIAIgQEQEGIpMAAKAIAIgMgBmoiACADTQ0GIAAgBEsNBgsgBhAEIgAgAUcNAQwHCyAGIAhrIAVxIgZB/v///wdLDQQgBhAEIgEgACgCACAAKAIEakYNAyABIQALAkAgAEF/Rg0AIAdBMGogBk0NAEG4pMAAKAIAIgEgCSAGa2pBACABa3EiAUH+////B0sEQCAAIQEMBwsgARAEQX9HBEAgASAGaiEGIAAhAQwHC0EAIAZrEAQaDAQLIAAiAUF/Rw0FDAMLQQAhBAwHC0EAIQEMBQsgAUF/Rw0CC0GUpMAAQZSkwAAoAgBBBHI2AgALIAJB/v///wdLDQEgAhAEIQFBABAEIQAgAUF/Rg0BIABBf0YNASAAIAFNDQEgACABayIGIAdBKGpNDQELQYikwABBiKTAACgCACAGaiIANgIAQYykwAAoAgAgAEkEQEGMpMAAIAA2AgALAkACQAJAQfCgwAAoAgAiBQRAQZikwAAhAANAIAEgACgCACIDIAAoAgQiAmpGDQIgACgCCCIADQALDAILQeigwAAoAgAiAEEAIAAgAU0bRQRAQeigwAAgATYCAAtBACEAQZykwAAgBjYCAEGYpMAAIAE2AgBB+KDAAEF/NgIAQfygwABBsKTAACgCADYCAEGkpMAAQQA2AgADQCAAQQN0IgNBiKHAAGogA0GAocAAaiICNgIAIANBjKHAAGogAjYCACAAQQFqIgBBIEcNAAtB5KDAACAGQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBB8KDAACAAIAFqIgA2AgAgACACQQFyNgIEIAEgA2pBKDYCBEH0oMAAQcCkwAAoAgA2AgAMAgsgAC0ADEEIcQ0AIAMgBUsNACABIAVNDQAgACACIAZqNgIEQfCgwAAgBUF4IAVrQQdxQQAgBUEIakEHcRsiAGoiAjYCAEHkoMAAQeSgwAAoAgAgBmoiASAAayIANgIAIAIgAEEBcjYCBCABIAVqQSg2AgRB9KDAAEHApMAAKAIANgIADAELQeigwAAoAgAgAUsEQEHooMAAIAE2AgALIAEgBmohAkGYpMAAIQACQAJAAkACQAJAAkADQCACIAAoAgBHBEAgACgCCCIADQEMAgsLIAAtAAxBCHFFDQELQZikwAAhAANAIAUgACgCACICTwRAIAIgACgCBGoiBCAFSw0DCyAAKAIIIQAMAAsACyAAIAE2AgAgACAAKAIEIAZqNgIEIAFBeCABa0EHcUEAIAFBCGpBB3EbaiIJIAdBA3I2AgQgAkF4IAJrQQdxQQAgAkEIakEHcRtqIgYgByAJaiIIayECIAUgBkYEQEHwoMAAIAg2AgBB5KDAAEHkoMAAKAIAIAJqIgA2AgAgCCAAQQFyNgIEDAMLIAZB7KDAACgCAEYEQEHsoMAAIAg2AgBB4KDAAEHgoMAAKAIAIAJqIgA2AgAgCCAAQQFyNgIEIAAgCGogADYCAAwDCyAGKAIEIgBBA3FBAUYEQCAAQXhxIQUCQCAAQf8BTQRAIAYoAggiAyAAQQN2IgBBA3RBgKHAAGpGGiADIAYoAgwiAUYEQEHYoMAAQdigwAAoAgBBfiAAd3E2AgAMAgsgAyABNgIMIAEgAzYCCAwBCyAGKAIYIQcCQCAGIAYoAgwiAUcEQCAGKAIIIgAgATYCDCABIAA2AggMAQsCQCAGQRRqIgAoAgAiAw0AIAZBEGoiACgCACIDDQBBACEBDAELA0AgACEEIAMiAUEUaiIAKAIAIgMNACABQRBqIQAgASgCECIDDQALIARBADYCAAsgB0UNAAJAIAYgBigCHCIDQQJ0QYijwABqIgAoAgBGBEAgACABNgIAIAENAUHcoMAAQdygwAAoAgBBfiADd3E2AgAMAgsgB0EQQRQgBygCECAGRhtqIAE2AgAgAUUNAQsgASAHNgIYIAYoAhAiAARAIAEgADYCECAAIAE2AhgLIAYoAhQiAEUNACABIAA2AhQgACABNgIYCyAFIAZqIQYgAiAFaiECCyAGIAYoAgRBfnE2AgQgCCACQQFyNgIEIAIgCGogAjYCACACQf8BTQRAIAJBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAg2AgggACAINgIMIAggAjYCDCAIIAA2AggMAwtBHyEAIAJB////B00EQCACQQh2IgAgAEGA/j9qQRB2QQhxIgN0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgA3IgAHJrIgBBAXQgAiAAQRVqdkEBcXJBHGohAAsgCCAANgIcIAhCADcCECAAQQJ0QYijwABqIQQCQEHcoMAAKAIAIgNBASAAdCIBcUUEQEHcoMAAIAEgA3I2AgAgBCAINgIAIAggBDYCGAwBCyACQQBBGSAAQQF2ayAAQR9GG3QhACAEKAIAIQEDQCABIgMoAgRBeHEgAkYNAyAAQR12IQEgAEEBdCEAIAMgAUEEcWoiBCgCECIBDQALIAQgCDYCECAIIAM2AhgLIAggCDYCDCAIIAg2AggMAgtB5KDAACAGQShrIgNBeCABa0EHcUEAIAFBCGpBB3EbIgBrIgI2AgBB8KDAACAAIAFqIgA2AgAgACACQQFyNgIEIAEgA2pBKDYCBEH0oMAAQcCkwAAoAgA2AgAgBSAEQScgBGtBB3FBACAEQSdrQQdxG2pBL2siACAAIAVBEGpJGyICQRs2AgQgAkGgpMAAKQIANwIQIAJBmKTAACkCADcCCEGgpMAAIAJBCGo2AgBBnKTAACAGNgIAQZikwAAgATYCAEGkpMAAQQA2AgAgAkEYaiEAA0AgAEEHNgIEIABBCGohASAAQQRqIQAgASAESQ0ACyACIAVGDQMgAiACKAIEQX5xNgIEIAUgAiAFayIEQQFyNgIEIAIgBDYCACAEQf8BTQRAIARBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAU2AgggACAFNgIMIAUgAjYCDCAFIAA2AggMBAtBHyEAIAVCADcCECAEQf///wdNBEAgBEEIdiIAIABBgP4/akEQdkEIcSICdCIAIABBgOAfakEQdkEEcSIBdCIAIABBgIAPakEQdkECcSIAdEEPdiABIAJyIAByayIAQQF0IAQgAEEVanZBAXFyQRxqIQALIAUgADYCHCAAQQJ0QYijwABqIQMCQEHcoMAAKAIAIgJBASAAdCIBcUUEQEHcoMAAIAEgAnI2AgAgAyAFNgIAIAUgAzYCGAwBCyAEQQBBGSAAQQF2ayAAQR9GG3QhACADKAIAIQEDQCABIgIoAgRBeHEgBEYNBCAAQR12IQEgAEEBdCEAIAIgAUEEcWoiAygCECIBDQALIAMgBTYCECAFIAI2AhgLIAUgBTYCDCAFIAU2AggMAwsgAygCCCIAIAg2AgwgAyAINgIIIAhBADYCGCAIIAM2AgwgCCAANgIICyAJQQhqIQAMBQsgAigCCCIAIAU2AgwgAiAFNgIIIAVBADYCGCAFIAI2AgwgBSAANgIIC0HkoMAAKAIAIgAgB00NAEHkoMAAIAAgB2siATYCAEHwoMAAQfCgwAAoAgAiAiAHaiIANgIAIAAgAUEBcjYCBCACIAdBA3I2AgQgAkEIaiEADAMLQdSgwABBMDYCAEEAIQAMAgsCQCAGRQ0AAkAgBCgCHCICQQJ0QYijwABqIgAoAgAgBEYEQCAAIAE2AgAgAQ0BQdygwAAgCUF+IAJ3cSIJNgIADAILIAZBEEEUIAYoAhAgBEYbaiABNgIAIAFFDQELIAEgBjYCGCAEKAIQIgAEQCABIAA2AhAgACABNgIYCyAEKAIUIgBFDQAgASAANgIUIAAgATYCGAsCQCADQQ9NBEAgBCADIAdqIgBBA3I2AgQgACAEaiIAIAAoAgRBAXI2AgQMAQsgBCAHQQNyNgIEIAQgB2oiBSADQQFyNgIEIAMgBWogAzYCACADQf8BTQRAIANBA3YiAEEDdEGAocAAaiECAn9B2KDAACgCACIBQQEgAHQiAHFFBEBB2KDAACAAIAFyNgIAIAIMAQsgAigCCAshACACIAU2AgggACAFNgIMIAUgAjYCDCAFIAA2AggMAQtBHyEAIANB////B00EQCADQQh2IgAgAEGA/j9qQRB2QQhxIgJ0IgAgAEGA4B9qQRB2QQRxIgF0IgAgAEGAgA9qQRB2QQJxIgB0QQ92IAEgAnIgAHJrIgBBAXQgAyAAQRVqdkEBcXJBHGohAAsgBSAANgIcIAVCADcCECAAQQJ0QYijwABqIQECQAJAIAlBASAAdCICcUUEQEHcoMAAIAIgCXI2AgAgASAFNgIADAELIANBAEEZIABBAXZrIABBH0YbdCEAIAEoAgAhBwNAIAciASgCBEF4cSADRg0CIABBHXYhAiAAQQF0IQAgASACQQRxaiICKAIQIgcNAAsgAiAFNgIQCyAFIAE2AhggBSAFNgIMIAUgBTYCCAwBCyABKAIIIgAgBTYCDCABIAU2AgggBUEANgIYIAUgATYCDCAFIAA2AggLIARBCGohAAwBCwJAIAhFDQACQCABKAIcIgJBAnRBiKPAAGoiACgCACABRgRAIAAgBDYCACAEDQFB3KDAACAJQX4gAndxNgIADAILIAhBEEEUIAgoAhAgAUYbaiAENgIAIARFDQELIAQgCDYCGCABKAIQIgAEQCAEIAA2AhAgACAENgIYCyABKAIUIgBFDQAgBCAANgIUIAAgBDYCGAsCQCADQQ9NBEAgASADIAdqIgBBA3I2AgQgACABaiIAIAAoAgRBAXI2AgQMAQsgASAHQQNyNgIEIAEgB2oiAiADQQFyNgIEIAIgA2ogAzYCACAKBEAgCkEDdiIAQQN0QYChwABqIQVB7KDAACgCACEEAn9BASAAdCIAIAZxRQRAQdigwAAgACAGcjYCACAFDAELIAUoAggLIQAgBSAENgIIIAAgBDYCDCAEIAU2AgwgBCAANgIIC0HsoMAAIAI2AgBB4KDAACADNgIACyABQQhqIQALIAtBEGokACAAC9YCAQF/AkAgAUUNACAAQQA6AAAgACABaiICQQFrQQA6AAAgAUEDSQ0AIABBADoAAiAAQQA6AAEgAkEDa0EAOgAAIAJBAmtBADoAACABQQdJDQAgAEEAOgADIAJBBGtBADoAACABQQlJDQAgAEEAIABrQQNxIgJqIgBBADYCACAAIAEgAmtBfHEiAmoiAUEEa0EANgIAIAJBCUkNACAAQQA2AgggAEEANgIEIAFBCGtBADYCACABQQxrQQA2AgAgAkEZSQ0AIABBADYCGCAAQQA2AhQgAEEANgIQIABBADYCDCABQRBrQQA2AgAgAUEUa0EANgIAIAFBGGtBADYCACABQRxrQQA2AgAgAiAAQQRxQRhyIgJrIgFBIEkNACAAIAJqIQADQCAAQgA3AxggAEIANwMQIABCADcDCCAAQgA3AwAgAEEgaiEAIAFBIGsiAUEfSw0ACwsLAwABC7AEAQd/AkAgACgCACIGQYCAgAhPBEAgACgCBCEEDAELIAAgBkEIdCIGNgIAIAAgACgCECIDQQFqNgIQIAAgAyAAKAIMai0AACAAKAIEQQh0ciIENgIECwJ/IAEvAQAiBSAGQQt2bCIDIARLBEAgASAFQYAQIAVrQQV2ajsBACABIAJBBHRqQQRqIQhBAiEFQQgMAQsgACAEIANrIgQ2AgQgASAFIAVBBXZrOwEAIAYgA2siBkH///8HTQRAIAAgBkEIdCIGNgIAIAAgACgCECIDQQFqNgIQIAAgAyAAKAIMai0AACAEQQh0ciIENgIECyABLwECIgUgBkELdmwiAyAESwRAIAEgBUGAECAFa0EFdmo7AQIgASACQQR0akGEAmohCEEKIQVBCAwBCyAAIAQgA2siBDYCBCABIAUgBUEFdms7AQIgAUGEBGohCCAGIANrIQNBEiEFQYACCyEGIAAgBTYCaEEBIQEDQCAIIAFBAXQiAWohCQJAIANB////B0sEQCADIQIMAQsgACADQQh0IgI2AgAgACAAKAIQIgNBAWo2AhAgACADIAAoAgxqLQAAIARBCHRyIgQ2AgQLAkAgCS8BACIHIAJBC3ZsIgMgBE0EQCAAIAQgA2siBDYCBCAAIAIgA2siAzYCACAJIAcgB0EFdms7AQAgAUEBciEBDAELIAAgAzYCACAJIAdBgBAgB2tBBXZqOwEACyABIAZJDQALIAAgASAGayAFajYCaAvIHwEQfwJAIAAoAigiASAAKAIgIglNDQAgACgCaCICRQ0AIAAoAlQiAyAAKAIkTw0AIAAoAjAgA00NACAAIAIgASAJayIBIAIgASACSRsiBms2AmggCSADQX9zaiEEIAMgCU8EQCAAKAIsIARqIQQLIAAoAhgiAyAEai0AACEBIAAgCUEBajYCICADIAlqIAE6AAACQCAGQQFrIgdFDQAgB0EBcQRAIAAoAhgiAkEAIARBAWoiASABIAAoAixGGyIEai0AACEDIAAgACgCICIBQQFqNgIgIAEgAmogAzoAACAGQQJrIQcLIAZBAkYNAANAIAAoAhgiAkEAIARBAWoiASABIAAoAixGGyIGai0AACEDIAAgACgCICIBQQFqNgIgIAEgAmogAzoAACAAKAIYIgJBACAGQQFqIgEgASAAKAIsRhsiBGotAAAhAyAAIAAoAiAiAUEBajYCICABIAJqIAM6AAAgB0ECayIHDQALCyAAKAIgIgkgACgCJE0NACAAIAk2AiQLAkACQCAJIAAoAihPDQAgAEHcDWohDiAAQeAVaiEPIABB1ABqIRADQCAAKAIQIgMgACgCFEsNASAAIAAoAmQiCkEFdGogACgCdCAJcSIIQQF0aiIMIQYCQCAAKAIAIgVBgICACE8EQCAAKAIEIQQMAQsgACAFQQh0IgU2AgAgACADQQFqIgE2AhAgACAAKAIMIANqLQAAIAAoAgRBCHRyIgQ2AgQgASEDCwJAIAYvAXgiASAFQQt2bCICIARLBEAgACACNgIAIAYgAUGAECABa0EFdmo7AXggCUEBayEFIAlFBEAgACgCLCAFaiEFCyAAKAJwIAlxIAAoAmwiAXQgACgCJCIGBH8gACgCGCAFai0AAAVBAAtBCCABa3ZqIQ1BASEFAkAgCkEGTQRAA0AgBUEBdCIFIAAgDUGADGxqakHkHWohBgJAIAJB////B0sEQCACIQEMAQsgACACQQh0IgE2AgAgACADQQFqIgI2AhAgACAAKAIMIANqLQAAIARBCHRyIgQ2AgQgAiEDCwJAIAYvAQAiCCABQQt2bCICIARNBEAgACAEIAJrIgQ2AgQgACABIAJrIgI2AgAgBiAIIAhBBXZrOwEAIAVBAXIhBQwBCyAAIAI2AgAgBiAIQYAQIAhrQQV2ajsBAAsgBUGAAkkNAAwCCwALIAkgACgCVCIBQX9zaiEFIAEgCU8EQCAAKAIsIAVqIQULIAYEfyAAKAIYIAVqLQAABUEACyEGQQEhBUGAAiEHA0AgACANQYAMbGogBkEBdCIGIAdxIgwgB2ogBWpBAXRqQeQdaiELAkAgAkH///8HSwRAIAIhCAwBCyAAIAJBCHQiCDYCACAAIANBAWoiATYCECAAIAAoAgwgA2otAAAgBEEIdHIiBDYCBCABIQMLIAsCfyAEIAsvAQAiASAIQQt2bCICTyIKRQRAIAAgAjYCACABQYAQIAFrQQV2agwBCyAAIAQgAmsiBDYCBCAAIAggAmsiAjYCAEEAIQcgASABQQV2aws7AQAgByAMcyEHIAVBAXQgCnIiBUGAAkkNAAsLIAAgCUEBajYCICAAKAIYIAlqIAU6AAAgACgCICIJIAAoAiRLBEAgACAJNgIkC0EAIQIgACAAKAJkIgFBBE8EfyABQQlNBEAgACABQQNrNgJkDAMLIAFBBmsFQQALNgJkDAELIAAgBCACayIENgIEIAAgBSACayICNgIAIAYgASABQQV2azsBeCAAIApBAXRqIgshBgJAIAJB////B0sEQCADIQEMAQsgACACQQh0IgI2AgAgACADQQFqIgE2AhAgACAAKAIMIANqLQAAIARBCHRyIgQ2AgQLAkAgBi8B+AMiCiACQQt2bCIDIARNBEAgACAEIANrIgQ2AgQgACACIANrIgI2AgAgBiAKIApBBXZrOwH4AwJAIAJB////B0sEQCABIQYMAQsgACACQQh0IgI2AgAgACABQQFqIgY2AhAgACAAKAIMIAFqLQAAIARBCHRyIgQ2AgQLAkAgCy8BkAQiASACQQt2bCIFIARLBEAgCyABQYAQIAFrQQV2ajsBkAQgBUH///8HTQRAIAAgBUEIdCIFNgIAIAAgBkEBajYCECAAIAAoAgwgBmotAAAgBEEIdHIiBDYCBAsgDC8B2AQiAyAFQQt2bCIBIARNBEAgACAEIAFrNgIEIAAgBSABazYCACAMIAMgA0EFdms7AdgEDAILIAAgATYCACAMIANBgBAgA2tBBXZqOwHYBCAAQQE2AmggAEEJQQsgACgCZEEHSRs2AmQMAwsgACAEIAVrIgQ2AgQgCyABIAFBBXZrOwGQBAJAIAIgBWsiAkH///8HSwRAIAYhAQwBCyAAIAJBCHQiAjYCACAAIAZBAWoiATYCECAAIAAoAgwgBmotAAAgBEEIdHIiBDYCBAsCQCALLwGoBCIGIAJBC3ZsIgMgBEsEQCAAIAM2AgAgCyAGQYAQIAZrQQV2ajsBqAQgACgCWCECDAELIAAgBCADayIENgIEIAsgBiAGQQV2azsBqAQgAiADayICQf///wdNBEAgACACQQh0IgI2AgAgACABQQFqNgIQIAAgACgCDCABai0AACAEQQh0ciIENgIECwJAIAsvAcAEIgMgAkELdmwiASAESwRAIAAgATYCACALIANBgBAgA2tBBXZqOwHABCAAKAJcIQIMAQsgACAEIAFrNgIEIAAgAiABazYCACALIAMgA0EFdms7AcAEIAAoAmAhAiAAIAAoAlw2AmALIAAgACgCWDYCXAsgACAAKAJUNgJYIAAgAjYCVAsgAEEIQQsgACgCZEEHSRs2AmQgACAPIAgQCQwBCyAAIAM2AgAgBiAKQYAQIAprQQV2ajsB+AMgACAAKAJcNgJgIAAgACkCVDcCWCAAQQdBCiAAKAJkQQdJGzYCZCAAIA4gCBAJIAAoAmgiAUECa0EDIAFBBkkbIQMgACgCACECQQEhBANAIARBAXQiBCAAIANBB3RqaiEGAkAgAkGAgIAITwRAIAAoAgQhBQwBCyAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgACgCBEEIdHIiBTYCBAsCQCAGLwHYByIIIAJBC3ZsIgEgBU0EQCAAIAUgAWsiBTYCBCAAIAIgAWsiAjYCACAGIAggCEEFdms7AdgHIARBAXIhBAwBCyAAIAE2AgAgBiAIQYAQIAhrQQV2ajsB2AcgASECCyAEQcAASQ0ACyAEQUBqIgNBA00EQCAAIAM2AlQMAQsgACAEQQFxQQJyIgc2AlQgA0EBdiEBIANBDU0EQCAAIAcgAUEBayIKdCIINgJUQQEhByAQIAhBAXRqQQAgBGtBAXRqQYIMaiEGQQAhCwNAIAYgB0EBdCIHaiEMAkAgAkH///8HSwRAIAIhAQwBCyAAIAJBCHQiATYCACAAIAAoAhAiA0EBajYCECAAIAMgACgCDGotAAAgBUEIdHIiBTYCBAsCQCAMLwEAIgMgAUELdmwiAiAFTQRAIAAgBSACayIFNgIEIAAgASACayICNgIAIAwgAyADQQV2azsBACAAQQEgC3QgCGoiCDYCVCAHQQFyIQcMAQsgACACNgIAIAwgA0GAECADa0EFdmo7AQALIAtBAWoiCyAKRw0ACwwBCyABQQVrIQQDQAJAIAJB////B0sEQCACIQMMAQsgACACQQh0IgM2AgAgACAAKAIQIgFBAWo2AhAgASAAKAIMai0AACAFQQh0ciEFCyAAIANBAXYiAjYCACAAIAUgAmsiBkEfdSIBIAdBAXRqQQFqIgc2AlQgACABIAJxIAZqIgU2AgQgBEEBayIEDQALIAAgB0EEdCIHNgJUIANB////D00EQCAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsgAAJ/IAAvAb4NIgEgAkELdmwiBCAFTQRAIAAgBSAEayIFNgIEIAAgB0EBciIHNgJUIAAgASABQQV2azsBvg0gAiAEayEEQQMMAQsgACABQYAQIAFrQQV2ajsBvg1BAgtBAXQiA2pBvA1qIQYgBEH///8HTQRAIAAgBEEIdCIENgIAIAAgACgCECIBQQFqNgIQIAAgASAAKAIMai0AACAFQQh0ciIFNgIECwJAIAYvAQAiASAEQQt2bCICIAVNBEAgACAFIAJrIgU2AgQgBiABIAFBBXZrOwEAIAAgB0ECaiIHNgJUIAQgAmshAiADQQFyIQMMAQsgBiABQYAQIAFrQQV2ajsBAAsgACADQQF0IgNqQbwNaiEGIAJB////B00EQCAAIAJBCHQiAjYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsCQCAGLwEAIgEgAkELdmwiBCAFTQRAIAAgBSAEayIFNgIEIAYgASABQQV2azsBACAAIAdBBGoiBzYCVCACIARrIQQgA0EBciEDDAELIAYgAUGAECABa0EFdmo7AQALIARB////B00EQCAAIARBCHQiBDYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgBUEIdHIiBTYCBAsgACADQQF0akG8DWoiAS8BACICIARBC3ZsIgMgBU0EQCAAIAUgA2s2AgQgACAEIANrNgIAIAEgAiACQQV2azsBACAAIAdBCGo2AlQMAQsgACADNgIAIAEgAkGAECACa0EFdmo7AQALQQAhAiAAKAJUIgYgACgCJE8NAyAAKAIwIAZNDQMgACAAKAJoIgMgACgCKCAAKAIgIgprIgEgAyABIANJGyIIazYCaCAKIAZBf3NqIQIgBiAKTwRAIAAoAiwgAmohAgsgACgCGCIDIAJqLQAAIQEgACAKQQFqNgIgIAMgCmogAToAAAJAIAhBAWsiBUUNACAFQQFxBEAgACgCGCIGQQAgAkEBaiIBIAEgACgCLEYbIgJqLQAAIQMgACAAKAIgIgFBAWo2AiAgASAGaiADOgAAIAhBAmshBQsgCEECRg0AA0AgACgCGCIGQQAgAkEBaiIBIAEgACgCLEYbIgJqLQAAIQMgACAAKAIgIgFBAWo2AiAgASAGaiADOgAAIAAoAhgiBkEAIAJBAWoiASABIAAoAixGGyICai0AACEDIAAgACgCICIBQQFqNgIgIAEgBmogAzoAACAFQQJrIgUNAAsLIAAoAiAiCSAAKAIkTQ0AIAAgCTYCJAsgCSAAKAIoSQ0ACwtBASECIAAoAgAiAUH///8HSw0AIAAgAUEIdDYCACAAIAAoAhAiAUEBajYCECAAIAEgACgCDGotAAAgACgCBEEIdHI2AgQLIAILJgEBfyAABEAgACgCsAkiASgCPARAIAEoAhgQBQsgARAFIAAQBQsLMgEBfyAAIAApA4ABIAIgACgCECICayIDrXw3A4ABIAAgASACaiADIAAoAhgQA603AxgLgQEBAn8CQAJAIAJBBE8EQCAAIAFyQQNxDQEDQCAAKAIAIAEoAgBHDQIgAUEEaiEBIABBBGohACACQQRrIgJBA0sNAAsLIAJFDQELA0AgAC0AACIDIAEtAAAiBEYEQCABQQFqIQEgAEEBaiEAIAJBAWsiAg0BDAILCyADIARrDwtBAAsJAEG8oCAoAgALCQBBsKAgKAIAC9QzAhR/An4CQAJAAkACQAJAAkACQAJAAn8Cf0HQoMAAKAIAIgEoAiQEQCABKAIADAELIAFBADoAKCABQgA3AwAgAUIANwMYIAFByABqQeQAEAcgAUEMNgKsAUEACyEAQcCgICgCACENIAFBtKAgKAIAIg42AhAgAUHgAGohDyABQbYBaiEQIAFBsAFqIREgAUGoAWohCANAAkACQAJAAkACQAJAAkACQAJAAkAgCAJ/AkACQAJAIAAOCgECAAoLDAQFBgcOC0GwoCAoAgAhAyABKAKsASECQbSgICgCACEAQbigICgCACEGIAEoAqgBDAILIAggASgCqAEiAGpBCGpBtKAgKAIAIgJBsKAgKAIAakG4oCAoAgAgAmsiAiABKAKsASAAayIAIAAgAksbIgAQAkG0oCBBtKAgKAIAIABqNgIAQQAhAyABQQAgASgCqAEgAGoiACAAIAEoAqwBIgJGGzYCqAEgACACRw0LIAFBATYCACARQYAIQQYQDQRAQQUhAwwMCyAQQQJBABADIAEoALgBRwRAQQchAwwMC0EGIQMgEC0AAA0LIAEgAS0AtwEiADYCICAAQQ9LDQtBAiEDIABBBEsNC0EBIAB0QRNxRQ0LC0G0oCAoAgAiAEG4oCAoAgAiBkYEQEEAIQMMCwtBsKAgKAIAIgMgAGotAAAiAkUEQEG0oCAgAEEBajYCACABIAA2AhBBBiEAIAFBBjYCAAwMCyABQQA2AqgBIAFBAjYCACABIAJBAnRBBGoiAjYCrAEgASACNgJAQQALIgVqQQhqIAAgA2ogBiAAayIAIAIgBWsiAiAAIAJJGyIAEAJBtKAgIABBtKAgKAIAajYCAEEAIQMgAUEAIAEoAqgBIABqIgAgACABKAKsASICRhs2AqgBIAAgAkcNCSABIABBBGsiADYCrAEgESAAQQAQAyABIAEoAqwBIgVqKACwAUcEQEEHIQMMCgsgAUECNgKoASABLACxASIEQT9xBEBBBiEDDAoLQQIhAEJ/IRVCfyEUIARBwABxRQ0FIAEoAgQiAkUEQCABQgA3AwgLIAVBAiAFQQJLGyEGA0AgACAGRgRAQQchAwwLCyAAIAhqLQAIIQMgASAAQQFqIgA2AqgBIAEgASkDCCADQf8Aca0gAq2GhCIUNwMIIANBgAFxRQRAAkAgAw0AIAJFDQBBByEDDAwLIAFBADYCBAwHC0EHIQMgASACQQdqIgI2AgQgAkE/Rw0ACwwJCwJ/IAFBkAFqIQYDQEG4oCAoAgAhAkGwoCAoAgAhBCABKAIEIgVFBEAgAUIANwMIC0G0oCAoAgAiACACIAAgAksbIQICQANAAkAgACACRgRAQQAhAyACIQAMAQsgACAEai0AACEDQbSgICAAQQFqIgA2AgAgASABKQMIIANB/wBxrSAFrYaEIhQ3AwggA0GAAXFFBEAgAw0DIAVFDQNBByEDDAELQQchAyABIAVBB2oiBTYCBCAFQT9HDQELCyABIAEpA4ABIAAgASgCECIAayICrXw3A4ABIAEgACAEaiACIAEoAhgQA603AxggAwwCCyABQQA2AgQCQAJAAkACQAJAIAEoAngOAwACAQMLIAEgFDcDiAFBByABKQNYIBRSDQUaIAFBATYCeAwDCyABIAEpA5gBIBR8NwOYASABIAZBGCABKAKgARADNgKgASABQQE2AnggASABKQOIAUIBfSIUNwOIAQwCCyABQQI2AnggASABKQOQASAUfDcDkAELIAEpA4gBIRQLIBRCAFINAAtBAQsiA0EBRw0IIAFBBzYCAAsCQCABKQOAASIUQbSgICgCACIAIAEoAhAiBGutfEIDg1ANAEGwoCAoAgAhBkG4oCAoAgAgAEYEQCAAIQIMBAtBtKAgIABBAWoiAjYCAEEHIQMgACAGai0AAA0IAkAgFCACIARrrXxCA4NQDQBBsKAgKAIAIQYgAkG4oCAoAgBGDQRBtKAgIABBAmoiBTYCACACIAZqLQAADQkgFCAFIARrrXxCA4NQBEAgBSEADAILQbCgICgCACEGQbigICgCACAFRgRAIAUhAgwFC0G0oCAgAEEDaiICNgIAIAUgBmotAAANCSAUIAIgBGutfEIDg1ANAEG4oCAoAgAgAkYEQEGwoCAoAgAhBgwFC0G0oCAgAEEEajYCAAwJCyACIQALIAFBsKAgKAIAIAAQDEEHIQMgDyABQZABakEYEA0NByABQQg2AgALAn9BtKAgKAIAIQBBuKAgKAIAIQUDQEEAIAAgBUYNARogASkDGCEUIAEoAgQhA0G0oCAgAEEBaiICNgIAQQdBsKAgKAIAIABqLQAAIBQgA62Ip0H/AXFHDQEaIAEgA0EIaiIDNgIEIAIhACADQSBJDQALIAFBADYCBCABQgA3AxhBAQsiA0EBRw0GIAFBCTYCACABQQw2AqwBC0EAIQMgASABKAKoASIAakGwAWpBtKAgKAIAIgJBsKAgKAIAakG4oCAoAgAgAmsiAiABKAKsASAAayIAIAAgAksbIgAQAkG0oCBBtKAgKAIAIABqNgIAIAFBACABKAKoASAAaiIAIAAgASgCrAFGIgAbNgKoASAARQ0FQQchAAJAIAEvALoBQdm0AUcNACABQbQBakEGQQAQAyABKACwAUcNACABNQC0ASABKQOAAUICiFINACABLQC4AQ0AQQFBByABKAIgIAEtALkBRhshAAsgACEDDAULIAEgBiACEAxBACEDDAQLIAEgFDcDMCAEQQBIBEAgASgCBCICRQRAIAFCADcDCAsgACAFIAAgBUsbIQQDQCAAIARGBEBBByEDDAYLIAAgCGotAAghAyABIABBAWoiADYCqAEgASABKQMIIANB/wBxrSACrYaEIhU3AwgCQCADQYABcUUEQCADDQEgAkUNAUEHIQMMBwtBByEDIAEgAkEHaiICNgIEIAJBP0cNAQwGCwsgAUEANgIECyABIBU3AzggBSAAa0ECSQRAQQchAwwECyABIABBAWoiAjYCqAEgACAIai0ACEEhRwRAQQYhAwwECyABIABBAmoiBDYCqAEgAiAIai0ACEEBRwRAQQYhAwwEC0EHIQMgBCAFRg0DIAEgAEEDajYCqAEgASgCsAkhAEEGIQICQCAEIAhqLQAIIgNBJ0sNACAAIANBAXFBAnIgA0EBdkELanQiBTYCMAJ/AkAgACgCPCIDRQ0AQQQhAiAFIAAoAjRLDQIgACAFNgIsIANBAkcNACAFIABBOGoiAygCAE0NACAAKAIYEAUgACAAKAIwEAYiAjYCGCACDQBBAwwBCyAAQQA2AkAgAEEBOgBQIABBADYCaCAAQeTdAWohA0EACyECIANBADYCAAsgAiIDDQMgASgCqAEiACABKAKsASICIAAgAksbIQMCQANAIAAgA0YNASABIABBAWoiAjYCqAEgACAIaiEFIAIhACAFLQAIRQ0AC0EGIQMMBAsgAUEANgKoASABQgA3A1AgAUIANwNIIAFBAzYCAAsgAUG0oCAoAgA2AhAgAUHAoCAoAgA2AhQCfyABKAKwCSIEQejdAWohBSAEQfgAaiEKIARB5N0BaiELA38gBCgCQCEDAkACQAJAAkACQAJAAkACQAJAAkACQAJAAkACQAJAQbSgICgCACIAQbigICgCACICTwRAIANBB0YNAUEADBELIAMOCQECAwQFBgcACQ8LIAQoAkwhAwwHC0EBIQZBtKAgIABBAWo2AgBBsKAgKAIAIABqLQAAIgBFDQggAEEBRyAAQd8BTXFFBEAgBEGAAjsBUCAEKAI8RQRAIARBwKAgKAIAIgJBvKAgKAIAajYCGCAEQcSgICgCACACazYCLAsgBEIANwIcIARCADcCJAwLCyAELQBQRQ0KQQcMDgtBtKAgIABBAWo2AgBBsKAgKAIAIABqLQAAIQAgBEECNgJAIAQgBCgCSCAAQQh0ajYCSAwMC0G0oCAgAEEBajYCAEGwoCAoAgAgAGotAAAhACAEQQM2AkAgBCAAIAQoAkhqQQFqNgJIDAsLQbSgICAAQQFqNgIAQbCgICgCACAAai0AACEAIARBBDYCQCAEIABBCHQ2AkwMCgtBtKAgIABBAWo2AgBBsKAgKAIAIABqLQAAIQAgBCAEKAJENgJAIAQgACAEKAJMakEBajYCTAwJC0G0oCAgAEEBajYCAEEHIQZBsKAgKAIAIABqLQAAIgBB4AFLDQNBACEDIARBfyAAQS1JBH9BAAUgAEEtayIAIABB/wFxQS1uIgJBLWxrIQAgAkEBagt0QX9zNgJ0IABB/wFxQQlPBEAgAEEJayIAIABB/wFxQQluIgJBCWxrIQAgAkEBaiEDCyAEIAM2AnAgBCAAQf8BcSIANgJsIAAgA2pBBEsNAyAEQX8gA3RBf3M2AnBBACEAIARBADYCZCAEQgA3AlwgBEIANwJUA0AgCiAAQQF0IgJqQYAIOwEAIAogAkECcmpBgAg7AQAgAEECaiIAQbbuAEcNAAsgBEEGNgJAIARBBTYCCCAEQv////8PNwIAC0EHIAQoAkwiBkEFSQ0IGiAEKAIIIgMEQEG0oCAoAgAhAEG4oCAoAgAhBwNAQQAgACAHRg0KGiAEKAIEIQxBtKAgIABBAWoiAjYCAEGwoCAoAgAgAGotAAAhACAEIANBAWsiAzYCCCAEIAAgDEEIdHI2AgQgAiEAIAMNAAsLIARBBzYCQCAEIAZBBWsiAzYCTAsgBCAEKAIgIgBBxKAgKAIAQcCgICgCAGsiAiAEKAJIIgYgAiAGSRsiAmogBCgCLCIGIAYgAGsgAksbNgIoQbigICgCACIGQbSgICgCACICayEAAkACQCAEKALk3QEiB0UEQCADDQFBACEDCyAHIAtqQQRqQbCgICgCACACaiAAIAMgB2siAkEqIAdrIgMgAiADSRsiAiAAIAJJGyIAEAICfyAAIAQoAuTdASIDaiICIAQoAkxGBEAgAyALaiAAakEEakE/IAJrEAcgBCgC5N0BIABqDAELIAJBFE0EQCAEIAI2AuTdAUG0oCBBtKAgKAIAIABqNgIADAMLIAJBFWsLIQIgBEEANgIQIAQgBTYCDCAEIAI2AhRBByEGIAQQCkUNAyAEKAIQIgcgACAEKALk3QEiAmpLDQMgBCAEKAJMIAdrIgM2AkwgAiAHSwRAIAQgAiAHayIANgLk3QECQCAFIgIgByALakEEaiIDRg0AIAMgACACaiIHa0EAIABBAXRrTQRAIAIgAyAAEAIMAQsgAiADc0EDcSEGAkACQCACIANJBEAgBg0CIAJBA3FFDQEDQCAARQ0EIAIgAy0AADoAACADQQFqIQMgAEEBayEAIAJBAWoiAkEDcQ0ACwwBCwJAIAYNACAHQQNxBEADQCAARQ0FIAIgAEEBayIAaiIGIAAgA2otAAA6AAAgBkEDcQ0ACwsgAEEDTQ0AA0AgAiAAQQRrIgBqIAAgA2ooAgA2AgAgAEEDSw0ACwsgAEUNAgNAIAIgAEEBayIAaiAAIANqLQAAOgAAIAANAAsMAgsgAEEDTQ0AA0AgAiADKAIANgIAIANBBGohAyACQQRqIQIgAEEEayIAQQNLDQALCyAARQ0AA0AgAiADLQAAOgAAIAJBAWohAiADQQFqIQMgAEEBayIADQALCwwCC0G0oCBBtKAgKAIAIAcgAmtqIgI2AgAgBEEANgLk3QFBuKAgKAIAIgYgAmshAAsgAEEVTwRAQbCgICgCACEHIAQgAjYCECAEIAc2AgwgBCAGQRVrIAIgA2ogACADQRVqSRs2AhRBByEGIAQQCkUNAyAEKAJMIgAgBCgCECICQbSgICgCAGsiA0kNAyAEIAAgA2siAzYCTEG0oCAgAjYCAEG4oCAoAgAgAmsiAEEUSw0BCyAFQbCgICgCACACaiADIAAgACADSxsiABACIAQgADYC5N0BQbSgIEG0oCAoAgAgAGo2AgALIAQoAiAiAiAEKAIcIgNrIQAgBCAEKAI8BH8gBCgCLCACRgRAIARBADYCIAtBvKAgKAIAQcCgICgCAGogBCgCGCADaiAAEAIgBCgCIAUgAgs2AhxBwKAgQcCgICgCACAAaiICNgIAIAQgBCgCSCAAayIANgJIIABFBEBBByEGIAQoAkwNAiAEKAJoDQIgBCgCBA0CIARBADYCQAwFC0EAIQYgAkHEoCAoAgBGDQFBtKAgKAIAQbigICgCAEcNBiAEKALk3QEgBCgCTE8NBgwBCyAEKAJMIgNFDQFBACEGIAAgAk8NAANAQcSgICgCACIHQcCgICgCACIMTQ0BIAQgAyADIAQoAiwgBCgCICISayITIAIgAGsiAiAHIAxrIgcgAiAHSRsiAiACIBNLGyICIAIgA0sbIgJrNgJMIBIgBCgCGGpBsKAgKAIAIABqIAIQAiAEIAQoAiAgAmoiADYCICAAIAQoAiRLBEAgBCAANgIkCyAEIAQoAjwEfyAEKAIsIABGBEAgBEEANgIgC0G8oCAoAgBBwKAgKAIAakGwoCAoAgBBtKAgKAIAaiACEAIgBCgCIAUgAAs2AhxBwKAgQcCgICgCACACajYCAEG0oCBBtKAgKAIAIAJqIgA2AgAgBCgCTCIDRQ0CQbigICgCACICIABLDQALCyAGDAULIARBADYCQAwDCyAAQRh0QRh1QQBODQEgBEEBNgJAIAQgAEEQdEGAgPwAcTYCSCAAQcABTwRAIARBBTYCRCAEQQA6AFEMAwtBByAELQBRDQMaIARBBjYCRCAAQaABSQ0CIARCADcCVEEAIQAgBEEANgJkIARCADcCXANAIAogAEEBdCICakGACDsBACAKIAJBAnJqQYAIOwEAIABBAmoiAEG27gBHDQALCyAEQQU2AgggBEL/////DzcCAAwBCyAAQQJLBH9BBwUgBEKDgICAgAE3AkAMAQsLCyEDIAEgASkDSEG0oCAoAgAgASgCEGutfCIUNwNIIAEgASkDUEHAoCAoAgAgASgCFCICayIArXwiFTcDUCABKQMwIBRUBEBBByEDDAMLIAEpAzggFVQEQEEHIQMMAwsCQCABAn4CQAJAIAEoAiBBAWsOBAADAwEDC0G8oCAoAgAgAmogACABKAIYEAOtDAELQbygICgCACACaiEFIAEpAxhCf4UhFAJAIABFDQAgAEEBcQR/IAUxAAAgFEL/AYOFp0EDdEGwEGopAwAgFEIIiIUhFCAFQQFqIQUgAEEBawUgAAshAiAAQQFGDQADQCAFMQABIAUxAAAgFEL/AYOFp0EDdEGwEGopAwAgFEIIiIUiFEL/AYOFp0EDdEGwEGopAwAgFEIIiIUhFCAFQQJqIQUgAkECayICDQALCyAUQn+FCzcDGAsgA0EBRw0CAkAgASkDMCIUQn9RDQAgFCABKQNIUQ0AQQchAwwDCyABKQNQIRUCQCABKQM4IhRCf1EEQCAVIRQMAQtBByEDIBQgFVINAwsgASABKQNoIBR8NwNoIAEgASgCIEGQCGoxAAAgASkDYCABKQNIIAE1AkB8fHw3A2AgASAPQRggASgCcBADNgJwIAFBBDYCACABIAEpA1hCAXw3A1gLAkAgASkDSCIUQgODUA0AQQAhA0G0oCAoAgAiAEG4oCAoAgAiAkYNAkG0oCAgAEEBaiIFNgIAQbCgICgCACAAai0AAARAQQchAwwDCyABIBRCAXwiFTcDSCAVQgODUA0AIAIgBUYNAkG0oCAgAEECaiIENgIAQbCgICgCACAFai0AAARAQQchAwwDCyABIBRCAnwiFTcDSCAVQgODUA0AIAIgBEYNAkG0oCAgAEEDaiIFNgIAQbCgICgCACAEai0AAARAQQchAwwDCyABIBRCA3wiFTcDSCAVQgODUA0AIAIgBUYNAkG0oCAgAEEEajYCAEEHIQNBsKAgKAIAIAVqLQAADQIgASAUQgR8NwNICyABQQU2AgALAkACQAJAAkACQCABKAIgIgBBAWsOBAACAgECC0G0oCAoAgAhAEG4oCAoAgAhBQNAIAAgBUYEQEEAIQMMBgsgASkDGCEUIAEoAgQhA0G0oCAgAEEBaiICNgIAQbCgICgCACAAai0AACAUIAOtiKdB/wFxRwRAQQchAwwGCyABIANBCGoiAzYCBCACIQAgA0EgSQ0ACyABQgA3AxgMAgtBtKAgKAIAIQBBuKAgKAIAIQUDQCAAIAVGBEBBACEDDAULIAEpAxghFCABKAIEIQNBtKAgIABBAWoiAjYCAEGwoCAoAgAgAGotAAAgFCADrYinQf8BcUcEQEEHIQMMBQsgASADQQhqIgM2AgQgAiEAIANBwABJDQALIAFCADcDGAwBCyABKAIEIgIgAEGQCGotAAAiBU8NAEEAIQNBtKAgKAIAIgBBuKAgKAIAIgRGDQIDQAJAIABBAWohACACQQFqIgIgBUYNACAAIARHDQEMAwsLQbSgICAANgIACyABQQA2AgRBASEAIAFBATYCAAwCC0G0oCAgBDYCACABIAI2AgRBASEAIAIgBUkNACABQQE2AgAMAQsLAkAgASgCJEUEQAJAAkAgAw4CAAMBC0EHQQhBtKAgKAIAQbigICgCAEYbIQMLQcCgICANNgIAQbSgICAONgIAIAMMAgsCQCADDQAgDkG0oCAoAgBHDQAgDUHAoCAoAgBHDQAgAS0AKCEAIAFBAToAKCAAQQN0DAILIAFBADoAKAsgAwsOCQcGBwABAgMEBAULQQEhCQwFC0ECIQkMBAtBBCEJDAMLQQUhCQwCC0EGIQkMAQtBByEJC0HQoMAAKAIAEAsLIAkL9wQCA38DfkHAoCBCgICAgICAgAQ3AgBBvKAgQdCgIDYCAEG0oCBCADcCAEGwoCBBsCA2AgADQCAAQQJ0QbAIakEAQQBBAEEAIABBAXYiAUEBcWtBoIbi7X5xQQAgAEEBcWtBoIbi7X5xIAFzQQF2IgFzQQF2IgJBAXFrQaCG4u1+cUEAIAFBAXFrQaCG4u1+cSACc0EBdiIBc0EBdiICQQFxa0GghuLtfnFBACABQQFxa0GghuLtfnEgAnNBAXYiAXNBAXYiAkEBcWtBoIbi7X5xQQAgAUEBcWtBoIbi7X5xIAJzQQF2czYCACAAQQFqIgBBgAJHDQALA0AgBadBA3RBsBBqQgBCAEIAQgAgBUIBiCIDQgGDfULCnpy83fKVtkmDQgAgBUIBg31Cwp6cvN3ylbZJgyADhUIBiCIDhUIBiCIEQgGDfULCnpy83fKVtkmDQgAgA0IBg31Cwp6cvN3ylbZJgyAEhUIBiCIDhUIBiCIEQgGDfULCnpy83fKVtkmDQgAgA0IBg31Cwp6cvN3ylbZJgyAEhUIBiCIDhUIBiCIEQgGDfULCnpy83fKVtkmDQgAgA0IBg31Cwp6cvN3ylbZJgyAEhUIBiIU3AwAgBUIBfCIFQoACUg0AC0HQoMAAAn9BuAkQBiIABEAgAEECNgIkIABBqN4BEAYiAQR/IAFBgICABDYCNCABQQI2AjwgAUEANgIYIAFBADYCOCABBUEACyIBNgKwCSABBEAgAEEAOgAoIABCADcDACAAQgA3AxggAEHIAGpB5AAQByAAQQw2AqwBIAAMAgsgABAFC0EACyIANgIAIAAEf0EABUEAEAtBAQsLEAAjACAAa0FwcSIAJAAgAAsGACAAJAALBAAjAAsRAEG0oCAoAgBBuKAgKAIARgsJAEHAoCAoAgALFwBBxKAgIABBgIAgIABBgIAgSRs2AgALCwBBwKAgIAA2AgALFwBBuKAgIABBgIAgIABBgIAgSRs2AgALCwBBtKAgIAA2AgALCyoDAEGACAsF/Td6WFoAQZEICw8EBAQICAgQEBAgICBAQEAAQaAICwNQEmA=")||(D=P,P=e.locateFile?e.locateFile(D,f):f+D);var V=[];function G(e){var t=V[e];return t||(e>=V.length&&(V.length=e+1),V[e]=t=w.get(e)),t}function k(e){try{return v.grow(e-y.byteLength+65535>>>16),S(v.buffer),1}catch(e){}}var Q="function"==typeof atob?atob:function(e){var t,n,i,o,r,a,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",c=0;e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{t=s.indexOf(e.charAt(c++))<<2|(o=s.indexOf(e.charAt(c++)))>>4,n=(15&o)<<4|(r=s.indexOf(e.charAt(c++)))>>2,i=(3&r)<<6|(a=s.indexOf(e.charAt(c++))),l+=String.fromCharCode(t),64!==r&&(l+=String.fromCharCode(n)),64!==a&&(l+=String.fromCharCode(i))}while(c>>=0)>o)return!1;for(var r=1;r<=4;r*=2){var a=i*(1+.2/r);if(a=Math.min(a,e+100663296),k(Math.min(o,((t=Math.max(e,a))%(n=65536)>0&&(t+=n-t%n),t))))return!0}return!1}},Y=(function(){var t={a:j};function i(t,n){var i,o=t.exports;e.asm=o,S((v=e.asm.c).buffer),w=e.asm.o,i=e.asm.d,T.unshift(i),function(t){if(R--,e.monitorRunDependencies&&e.monitorRunDependencies(R),0==R&&L){var n=L;L=null,n()}}()}function o(e){i(e.instance)}function a(e){return function(){if(!m&&(d||h)){if("function"==typeof fetch&&!F(P))return fetch(P,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+P+"'";return e.arrayBuffer()})).catch((function(){return U(P)}));if(r)return new Promise((function(e,t){r(P,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return U(P)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(e,(function(e){g("failed to asynchronously prepare wasm: "+e),B(e)}))}if(R++,e.monitorRunDependencies&&e.monitorRunDependencies(R),e.instantiateWasm)try{return e.instantiateWasm(t,i)}catch(e){return g("Module.instantiateWasm callback failed with error: "+e),!1}(m||"function"!=typeof WebAssembly.instantiateStreaming||O(P)||F(P)||"function"!=typeof fetch?a(o):fetch(P,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(o,(function(e){return g("wasm streaming compile failed: "+e),g("falling back to ArrayBuffer instantiation"),a(o)}))}))).catch(n)}(),e.___wasm_call_ctors=function(){return(e.___wasm_call_ctors=e.asm.d).apply(null,arguments)},e._init_decompressor=function(){return(e._init_decompressor=e.asm.e).apply(null,arguments)},e._decompress=function(){return(e._decompress=e.asm.f).apply(null,arguments)},e._get_in_buffer_ptr=function(){return(e._get_in_buffer_ptr=e.asm.g).apply(null,arguments)},e._get_out_buffer_ptr=function(){return(e._get_out_buffer_ptr=e.asm.h).apply(null,arguments)},e._in_buffer_set_pos=function(){return(e._in_buffer_set_pos=e.asm.i).apply(null,arguments)},e._in_buffer_set_size=function(){return(e._in_buffer_set_size=e.asm.j).apply(null,arguments)},e._out_buffer_set_pos=function(){return(e._out_buffer_set_pos=e.asm.k).apply(null,arguments)},e._out_buffer_set_size=function(){return(e._out_buffer_set_size=e.asm.l).apply(null,arguments)},e._get_curr_output_length=function(){return(e._get_curr_output_length=e.asm.m).apply(null,arguments)},e._is_input_end_reached=function(){return(e._is_input_end_reached=e.asm.n).apply(null,arguments)},e.stackSave=function(){return(Y=e.stackSave=e.asm.p).apply(null,arguments)}),X=e.stackRestore=function(){return(X=e.stackRestore=e.asm.q).apply(null,arguments)},K=e.stackAlloc=function(){return(K=e.stackAlloc=e.asm.r).apply(null,arguments)};function q(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function Z(n){function i(){H||(H=!0,e.calledRun=!0,A||(z(T),t(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),function(){if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)t=e.postRun.shift(),I.unshift(t);var t;z(I)}()))}R>0||(function(){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)t=e.preRun.shift(),E.unshift(t);var t;z(E)}(),R>0||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),i()}),1)):i()))}if(e.cwrap=function(e,t,n,i){var o=(n=n||[]).every((function(e){return"number"===e}));return"string"!==t&&o&&!i?_(e):function(){return x(e,t,n,arguments)}},L=function e(){H||Z(),H||(L=e)},e.run=Z,e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return Z(),e.ready});const Vp=524288,Gp=["","Memory allocation failed","Memory usage limit reached","Unsupported check; not verifying file integrity","Not an .xz file","Unsupported options in the .xz headers","File is corrupt","Unknown decompression bug"];class kp{constructor(e){this.manager=void 0!==e?e:Wu,this.crossOrigin="Anonymous",this.xz=null}init(){return this.xz?Promise.resolve():zp().then((e=>{this._emInitDecompressor=e.cwrap("init_decompressor","number"),this._emDecompress=e.cwrap("decompress","number"),this._emGetInBufferPtr=e.cwrap("get_in_buffer_ptr","number"),this._emGetOutBufferPtr=e.cwrap("get_out_buffer_ptr","number"),this._emInBufferSetPos=e.cwrap("in_buffer_set_pos",null,["number"]),this._emInBufferSetSize=e.cwrap("in_buffer_set_size",null,["number"]),this._emOutBufferSetPos=e.cwrap("out_buffer_set_pos",null,["number"]),this._emOutBufferSetSize=e.cwrap("out_buffer_set_size",null,["number"]),this._emGetCurrOutputLength=e.cwrap("get_curr_output_length","number"),this._emIsInputEndReached=e.cwrap("is_input_end_reached","number"),this.xz=e}))}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e);const o=this,r=ku.get(e);if(void 0!==r)return o.manager.itemStart(e),setTimeout((function(){t&&t(r),o.manager.itemEnd(e)}),0),r;const a=this.init(),s=new XMLHttpRequest;return s.open("GET",e,!0),s.addEventListener("load",(function(r){const s=r.target.response;200===this.status||0===this.status?(0===this.status&&console.warn("v3d.XZLoader: HTTP Status 0 received."),a.then((()=>{o.decompressArrayBuffer(s,(function(n){setTimeout((function(){t&&t(n),o.manager.itemEnd(e),ku.add(e,n)}),1)}),(function(e){if(n){n((2+1*e)/3)}}),(function(t){i&&i(t),o.manager.itemEnd(e),o.manager.itemError(e)}))}))):(i&&i(r),o.manager.itemEnd(e),o.manager.itemError(e))}),!1),n&&s.addEventListener("progress",(function(e){let t;t=e.lengthComputable?e.loaded/e.total:1;n(2*t/3)}),!1),s.addEventListener("error",(function(t){i&&i(t),o.manager.itemEnd(e),o.manager.itemError(e)}),!1),s.responseType="arraybuffer",s.send(null),o.manager.itemStart(e),s}setCrossOrigin(e){return this.crossOrigin=e,this}setPath(e){return this.path=e,this}decompressArrayBuffer(e,t,n,i){const o=this;function r(e){const t=o._emGetInBufferPtr();o.xz.HEAPU8.set(e,t),o._emInBufferSetPos(0),o._emInBufferSetSize(e.length),a()}function a(){o._emOutBufferSetPos(0)}const s=o._emInitDecompressor();if(0!=s)return console.error("XZLoader._emInitDecompressor: error code "+s+" ("+Gp[s]+")"),void(i&&i(s));const l=new Uint8Array(e),c=l.length,u=[];let d=0,h=Math.min(Vp,c),p=0;r(l.subarray(d,h)),function e(){const s=o._emDecompress();if(s)console.error("XZLoader._emDecompress: error code "+s+" ("+Gp[s]+")"),i&&i(s);else{const i=o._emGetCurrOutputLength();if(u.push(function(e){const t=o._emGetOutBufferPtr();return new Uint8Array(o.xz.HEAPU8.subarray(t,t+e))}(i)),a(),o._emIsInputEndReached()&&(d=h,h=Math.min(h+Vp,c),r(l.subarray(d,h))),n&&n(d/c),d==h){const e=u.reduce((function(e,t,n,i){return e+t.length}),0),n=new Uint8Array(e);let i=0;u.forEach((function(e){n.set(e,i),i+=e.length})),t&&t(n.buffer)}else p++,p%2==0?setTimeout(e,1):e()}}()}}class Qp extends Hu{constructor(e){super(e),this.reversed=!1}load(e,t,n,i){var o=this,r=new Yu(this.manager);r.setPath(this.path),r.setResponseType("arraybuffer"),r.load(e,(function(e){t(o.parse(e))}),n,i)}parse(e){function t(e){var t,n=[];e.forEach((function(e){"m"===e.type.toLowerCase()?(t=[e],n.push(t)):"z"!==e.type.toLowerCase()&&t.push(e)}));var i=[];return n.forEach((function(e){var t={type:"m",x:e[e.length-1].x,y:e[e.length-1].y};i.push(t);for(var n=e.length-1;n>0;n--){var o=e[n];t={type:o.type};void 0!==o.x2&&void 0!==o.y2?(t.x1=o.x2,t.y1=o.y2,t.x2=o.x1,t.y2=o.y1):void 0!==o.x1&&void 0!==o.y1&&(t.x1=o.x1,t.y1=o.y1),t.x=e[n-1].x,t.y=e[n-1].y,i.push(t)}})),i}return"undefined"==typeof opentype?(console.warn("v3d.TTFLoader: The loader requires opentype.js. Make sure it's included before using the loader."),null):function(e,n){for(var i=Math.round,o={},r=1e3/(e.unitsPerEm||2048),a=e.encoding.cmap.glyphIndexMap,s=Object.keys(a),l=0;l(o=s.indexOf("\n"))&&r=e.byteLength||!(l=n(e)))return t(1,"no header found");if(!(c=l.match(/^#\?(\S+)/)))return t(3,"bad initial token");for(s.valid|=1,s.programtype=c[1],s.string+=l+"\n";l=n(e),!1!==l;)if(s.string+=l+"\n","#"!==l.charAt(0)){if((c=l.match(i))&&(s.gamma=parseFloat(c[1],10)),(c=l.match(o))&&(s.exposure=parseFloat(c[1],10)),(c=l.match(r))&&(s.valid|=2,s.format=c[1]),(c=l.match(a))&&(s.valid|=4,s.height=parseInt(c[1],10),s.width=parseInt(c[2],10)),2&s.valid&&4&s.valid)break}else s.comments+=l+"\n";return 2&s.valid?4&s.valid?s:t(3,"missing image size specifier"):t(3,"missing format specifier")}(r);if(-1!==a){const e=a.width,n=a.height,s=function(e,n,i){const o=n;if(o<8||o>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(o!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");const r=new Uint8Array(4*n*i);if(!r.length)return t(4,"unable to allocate buffer space");let a=0,s=0;const l=4*o,c=new Uint8Array(4),u=new Uint8Array(l);let d=i;for(;d>0&&se.byteLength)return t(1);if(c[0]=e[s++],c[1]=e[s++],c[2]=e[s++],c[3]=e[s++],2!=c[0]||2!=c[1]||(c[2]<<8|c[3])!=o)return t(3,"bad rgbe scanline format");let n,i=0;for(;i128;if(o&&(n-=128),0===n||i+n>l)return t(3,"bad scanline data");if(o){const t=e[s++];for(let e=0;e{!e.isPlaneReflectionProbe&&this._isVisible(e)||(i[e.id]=e.layers.mask,e.layers.disableAll())}));const o=this.reflectorWorldPosition;o.setFromMatrixPosition(this.matrixWorld);const r=this.cameraWorldPosition;r.setFromMatrixPosition(t.matrixWorld);const a=this.rotationMatrix;a.extractRotation(this.matrixWorld);const s=this.normal;s.set(0,1,0),s.applyMatrix4(a);const l=this.view;if(l.subVectors(o,r),l.dot(s)>0)return void e.traverse((e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=i[e.id])}));l.reflect(s).negate(),l.add(o),a.extractRotation(t.matrixWorld);const c=this.lookAtPosition;c.set(0,0,-1),c.applyMatrix4(a),c.add(r);const u=this.target;u.subVectors(o,c),u.reflect(s).negate(),u.add(o);const d=this.virtualCamera;d.position.copy(l),d.up.set(0,1,0),d.up.applyMatrix4(a),d.up.reflect(s),d.lookAt(u),d.far=t.far,d.updateMatrixWorld();const h=d.projectionMatrix;h.copy(t.projectionMatrix);const p=this.textureMatrix;p.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),p.multiply(h),p.multiply(d.matrixWorldInverse);const f=this.reflectorPlane;f.setFromNormalAndCoplanarPoint(s,o),f.applyMatrix4(d.matrixWorldInverse);const m=this.clipPlane;m.set(f.normal.x,f.normal.y,f.normal.z,f.constant),Kp.x=(Math.sign(m.x)+h.elements[8])/h.elements[0],Kp.y=(Math.sign(m.y)+h.elements[9])/h.elements[5],Kp.z=-1,Kp.w=(1+h.elements[10])/h.elements[14],m.multiplyScalar(2/m.dot(Kp)),h.elements[2]=m.x,h.elements[6]=m.y,h.elements[10]=m.z+1-this.probeClipStart,h.elements[14]=m.w;const g=n.getRenderTarget(),v=n.xr.enabled,A=n.shadowMap.autoUpdate;n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,n.setRenderTarget(this.renderTarget),n.state.buffers.depth.setMask(!0),!1===n.autoClear&&n.clear(),n.render(e,d),n.xr.enabled=v,n.shadowMap.autoUpdate=A,n.setRenderTarget(g);const _=t.viewport;void 0!==_&&n.state.viewport(_),e.traverse((e=>{!e.isPlaneReflectionProbe&&this._isVisible(e)||(e.layers.mask=i[e.id])})),this._calcLocalBounding()}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)}copy(e){return super.copy(e),this.influenceDistance=e.influenceDistance,this.probeClipStart=e.probeClipStart,this.visibilityGroup=e.visibilityGroup,this.visibilityGroupInv=e.visibilityGroupInv,this}dispose(){null!==this.renderTarget&&(this.renderTarget.dispose(),this.renderTarget=null),this.dispatchEvent({type:"dispose"})}_isVisible(e){if(null===this.visibilityGroup)return!0;if(!e.isMesh)return!0;return-1!==e.groupNames.indexOf(this.visibilityGroup)^this.visibilityGroupInv}}qp.prototype.isPlaneReflectionProbe=!0;class Zp{static init(e,t){void 0!==e&&void 0!==t||console.error("RectAreaLightUniformsLib: Missing LTC data (required in Verge3D)");const n=new Float32Array(e),i=new Float32Array(t);oo.LTC_FLOAT_1=new ks(n,64,64,R,E,l,g,g,y,A,1),oo.LTC_FLOAT_2=new ks(i,64,64,R,E,l,g,g,y,A,1),oo.LTC_FLOAT_1.needsUpdate=!0,oo.LTC_FLOAT_2.needsUpdate=!0;const o=new Uint16Array(e.length);e.forEach((function(e,t){o[t]=Uh.toHalfFloat(e)}));const r=new Uint16Array(t.length);t.forEach((function(e,t){r[t]=Uh.toHalfFloat(e)})),oo.LTC_HALF_1=new ks(o,64,64,R,T,l,g,g,y,A,1),oo.LTC_HALF_2=new ks(r,64,64,R,T,l,g,g,y,A,1),oo.LTC_HALF_1.needsUpdate=!0,oo.LTC_HALF_2.needsUpdate=!0}}class Jp{constructor(e){this.type="Font",this.data=e}generateShapes(e,t=100,n="left",i="topBaseline",o=-1,r=!1){const a=[],s=function(e,t,n,i,o,r,a){const s=String(e).split("\n"),l=[];for(let e=0;e1?.5*f-g:-n.ascender/2*c;break;case"bottom":h=f-r-n.descender*c;break;case"bottomBaseline":h=f-r}for(let e=0;e=0||null===this.clippingGroup)&&!e.isAuxClippingMesh}assignToObject(e,t=0){const n=this.plane,i=e.material,o=e.geometry;if(i.clippingPlanes=i.clippingPlanes||[],-1==i.clippingPlanes.indexOf(n)&&i.clippingPlanes.push(n),i.clipShadows=this.clipShadows,i.clipIntersection=this.clipIntersection,this.crossSection){this.cleanupAuxMeshes(e);const r=new Kn;r.depthWrite=!1,r.depthTest=!1,r.colorWrite=!1,r.stencilWrite=!0,r.stencilFunc=519,r.clipShadows=this.clipShadows,r.clipIntersection=this.clipIntersection;const a=!!e.isSkinnedMesh,s=e.morphTargetInfluences,l=st(s)&&s.length>0,c=r.clone();let u;c.name="ClipCrossSectionStencilBack",c.side=1,c.clippingPlanes=[n],c.stencilFail=Ce,c.stencilZFail=Ce,c.stencilZPass=Ce,a?(u=new Vs(o,c),u.skeleton=e.skeleton):u=new Di(o,c),u.renderOrder=t,u.name="ClipCrossSectionStencilBack",u.isAuxClippingMesh=!0,l&&(u.morphTargetInfluences=s.slice(),u.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.add(u);const d=r.clone();let h;d.name="ClipCrossSectionStencilFront",d.side=0,d.clippingPlanes=[n],d.stencilFail=Se,d.stencilZFail=Se,d.stencilZPass=Se,a?(h=new Vs(o,d),h.skeleton=e.skeleton):h=new Di(o,d),h.renderOrder=t+.1,h.name="ClipCrossSectionStencilFront",h.isAuxClippingMesh=!0,l&&(h.morphTargetInfluences=s.slice(),h.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),e.add(h),i.isMeshNodeMaterial&&(this._crossMatProfile=i.profile)}}createCrossSectionPlane(e,t){this.cleanupAuxMeshes();const n=new wu({name:"ClipCrossSectionColor",nodeGraph:wu.nodeGraphDiffuse(this.crossSectionColor,this.crossSectionOpacity,this._crossMatProfile),profile:this._crossMatProfile,clippingPlanes:e.filter((e=>e!==this.plane)),clipShadows:this.clipShadows,clipIntersection:this.clipIntersection,stencilWrite:!0,stencilRef:0,stencilFunc:517,stencilFail:Me,stencilZFail:Me,stencilZPass:Me,side:this.crossSectionRenderSide});this.crossSectionOpacity<1&&(n.transparent=!0,n.premultipliedAlpha=!0,n.blending=5,n.blendEquation=i,n.blendSrc=r,n.blendDst=s);const o=new no(this.crossSectionSize,this.crossSectionSize);this.negated?o.rotateX(-Math.PI/2):o.rotateX(Math.PI/2);const a=new Di(o,n);a.name="ClipCrossSectionColor",a.isAuxClippingMesh=!0,a.renderOrder=t,a.onAfterRender=function(e){e.clearStencil()},this.add(a)}cleanupAuxMeshes(e=null){if(e)for(let t=e.children.length-1;t>=0;t--){const n=e.children[t];n.isAuxClippingMesh&&n.material.clippingPlanes[0]==this.plane&&(n.geometry.dispose(),n.material.dispose(),e.remove(n))}else for(let e=this.children.length-1;e>=0;e--){const t=this.children[e];t.isAuxClippingMesh&&(t.geometry.dispose(),t.material.dispose(),this.remove(t))}}copy(e){return super.copy(e),this.plane=e.plane,this.clippingGroup=e.clippingGroup,this.clipShadows=e.clipShadows,this.negated=e.negated,this.clipIntersection=e.clipIntersection,this.crossSection=e.crossSection,this.crossSectionColor.copy(e.crossSectionColor),this.crossSectionOpacity=e.crossSectionOpacity,this.crossSectionRenderSide=e.crossSectionRenderSide,this.crossSectionSize=e.crossSectionSize,this._crossMatProfile=e._crossMatProfile,this}}of.prototype.isClippingPlaneObject=!0;const rf={minDistance:0,maxDistance:1/0,minZoom:0,maxZoom:1/0,minPolarAngle:0,maxPolarAngle:Math.PI,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,autoRotate:!1,autoRotateSpeed:2,enablePan:!0,panInertia:.05,panSpeed:1.3,panSpeedKey:15,screenSpacePanning:!0,enableRotate:!0,rotateInertia:.05,rotateInertiaTouch:.05,rotateSpeed:1.2,rotateSpeedTouch:.7,enableZoom:!0,zoomInertia:.05,zoomInertiaTouch:.05,zoomSpeed:5,zoomSpeedTouch:1,enableDamping:!0,enableTurnover:!1,enableKeys:!0},af=.1,sf=new Bt(0,1,0),lf=(new Lt).setFromAxisAngle(new Bt(0,0,1),Math.PI),cf=-1,uf=0,df=1,hf=2,pf=3,ff=4,mf=1e-6,gf=new Bt,vf=new Bt,Af=new Lt,_f=new Lt,xf={type:"change"},yf={type:"start"},bf={type:"end"};class Mf extends Be{constructor(e,t){super(),void 0===t&&console.warn('v3d.OrbitControls: The second parameter "domElement" is now mandatory.'),t===document&&console.error('v3d.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=t,this.domElement.style.touchAction="none",this.enabled=!0,this.targetObj=new Nn,this.minDistance=rf.minDistance,this.maxDistance=rf.maxDistance,this.minZoom=rf.minZoom,this.maxZoom=rf.maxZoom,this.minPolarAngle=rf.minPolarAngle,this.maxPolarAngle=rf.maxPolarAngle,this.minAzimuthAngle=rf.minAzimuthAngle,this.maxAzimuthAngle=rf.maxAzimuthAngle,this.enableDamping=rf.enableDamping,this.enableZoom=rf.enableZoom,this.zoomSpeed=rf.zoomSpeed,this.zoomSpeedTouch=rf.zoomSpeedTouch,this.zoomInertia=rf.zoomInertia,this.zoomInertiaTouch=rf.zoomInertiaTouch,this.enableRotate=rf.enableRotate,this.rotateSpeed=rf.rotateSpeed,this.rotateSpeedTouch=rf.rotateSpeedTouch,this.rotateInertia=rf.rotateInertia,this.rotateInertiaTouch=rf.rotateInertiaTouch,this.enablePan=rf.enablePan,this.panSpeed=rf.panSpeed,this.screenSpacePanning=rf.screenSpacePanning,this.panSpeedKey=rf.panSpeedKey,this.panInertia=rf.panInertia,this.autoRotate=rf.autoRotate,this.autoRotateSpeed=rf.autoRotateSpeed,this.enableTurnover=rf.enableTurnover,this.enableKeys=rf.enableKeys,this.mouseButtons={ROTATE:n.LEFT,ZOOM:n.MIDDLE,PAN:n.RIGHT},this.target0=this.targetObj.position.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,Object.defineProperty(this,"inTween",{get:()=>I.active||R.active,set(e){I.active=e}}),this.getPolarAngle=function(){return r.phi},this.getAzimuthalAngle=function(){return r.theta},this.getDistance=function(){return this.object.position.distanceTo(this.targetObj.position)},this.saveState=function(){i.targetObj.updateWorldMatrix(!0,!1),i.target0.setFromMatrixPosition(i.targetObj.matrixWorld),i.position0.copy(i.object.position),i.zoom0=i.object.zoom},this.forceMouseUp=function(){G()},this.reset=function(){i.targetObj.updateWorldMatrix(!0,!1);const e=gf.copy(i.target0);i.targetObj.worldToLocal(e),i.targetObj.position.add(e),i.object.position.copy(i.position0),i.object.zoom=i.zoom0,i.object.updateProjectionMatrix(),i.dispatchEvent(xf),i.update(),o=cf},this.update=function(){const e=new Bt,t=new Bt,n=new Bt,h=new Lt;let p=!1,A=!1;return function(){const _=i.object.position;if(i.targetObj.updateWorldMatrix(!0,!1),I.active)I.update((function(t,n,o){if(_.copy(n),e.copy(o),i.object.lookAt(e),t>=1){a.set(0,0,0),l.set(0,0,0),s=1,y.set(0,0);for(let e in u)u[e]=0;m.set(0,0),T.getDelta()}}));else if(R.active)R.update((function(t,n,o){if(e.copy(n),i.object.lookAt(e),i.object.zoom=o,i.object.updateProjectionMatrix(),t>=1){a.set(0,0,0),l.set(0,0,0),s=1,y.set(0,0);for(let e in u)u[e]=0;m.set(0,0),T.getDelta()}}));else{e.setFromMatrixPosition(i.targetObj.matrixWorld),t.copy(_).sub(e);const n=Af.setFromUnitVectors(i.object.up,sf),c=_f.copy(n).invert();if(t.applyQuaternion(n),r.setFromVector3(t),i.autoRotate&&o===cf&&B(2*Math.PI/60/60*i.autoRotateSpeed),r.theta+=a.theta,r.phi+=a.phi,i.enableTurnover){p&&(r.phi-=2*a.phi),A!=p&&o==cf&&(A=p),A&&(r.theta-=2*a.theta);const e=r.phi;(e<=0||e>=Math.PI)&&(p=!p,r.theta+=Math.PI,r.phi=e>0?2*Math.PI-e:Math.abs(e))}else isFinite(i.minAzimuthAngle)&&isFinite(i.maxAzimuthAngle)&&(r.theta=Je(r.theta,i.minAzimuthAngle,i.maxAzimuthAngle)),r.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,r.phi));r.makeSafe(),i.object.isPerspectiveCamera?(r.radius*=s,r.radius=Math.max(i.minDistance,Math.min(i.maxDistance,r.radius))):i.object.isOrthographicCamera&&(i.object.zoom/=s,i.object.zoom=Math.max(i.minZoom,Math.min(i.maxZoom,i.object.zoom)),i.object.updateProjectionMatrix()),e.add(l),t.setFromSpherical(r),t.applyQuaternion(c),_.copy(e).add(t),i.object.lookAt(e),p&&(i.enableTurnover?i.object.quaternion.multiply(lf):p=!1),a.set(0,0,0),l.set(0,0,0),function(){const e=T.getDelta();let t,n;f.copy(m),m.x=i.enableDamping?Ke(m.x,0,e,v,1):0,m.y=i.enableDamping?Ke(m.y,0,e,v,1):0,f.sub(m),function(){const e=i.domElement===document?i.domElement.body:i.domElement,t=e.clientWidth,n=e.clientHeight;if(!t||!n)return;B(2*Math.PI*f.x/t*g),o=2*Math.PI*f.y/n*g,a.phi-=o;var o}(),x.copy(y),y.x=i.enableDamping?Ke(y.x,0,e,i.panInertia,af):0,y.y=i.enableDamping?Ke(y.y,0,e,i.panInertia,af):0,x.sub(y),x.multiplyScalar(i.panSpeed);for(let o in u)d.isKeyDown[o]?t=u[o]=1:(n=u[o],u[o]=Ke(u[o],0,e,i.panInertia,af),t=n-u[o]),i.enabled&&i.enableKeys&&i.enablePan&&(t*=60*e*i.panSpeedKey,o==Tp.A||o==Tp.LEFT_ARROW?x.x+=t:o==Tp.D||o==Tp.RIGHT_ARROW?x.x-=t:o==Tp.W||o==Tp.UP_ARROW?x.y+=t:o!=Tp.S&&o!=Tp.DOWN_ARROW||(x.y-=t));(function(e,t){const n=i.domElement===document?i.domElement.body:i.domElement,o=n.clientWidth,r=n.clientHeight;if(!o||!r)return;if(i.object.isPerspectiveCamera){i.targetObj.updateWorldMatrix(!0,!1);const n=gf.setFromMatrixPosition(i.targetObj.matrixWorld),o=i.object.position;let a=vf.copy(o).sub(n).length();a*=Math.tan(i.object.fov/2*Ne),D(2*e*a/r,i.object.matrix),N(2*t*a/r,i.object.matrix)}else i.object.isOrthographicCamera?(D(e*(i.object.right-i.object.left)/i.object.zoom/o,i.object.matrix),N(t*(i.object.top-i.object.bottom)/i.object.zoom/r,i.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),i.enablePan=!1)})(x.x,x.y),s=S,S=i.enableDamping?Ke(S,1,e,E,.01):1,s/=S}()}return i.targetObj.position.copy(e),!!(c||n.distanceToSquared(i.object.position)>mf||8*(1-h.dot(i.object.quaternion))>mf)&&(i.dispatchEvent(xf),n.copy(i.object.position),h.copy(i.object.quaternion),c=!1,!0)}}(),this.dispose=function(){i.domElement.removeEventListener("contextmenu",j),i.domElement.removeEventListener("mousedown",z),i.domElement.removeEventListener("wheel",k),i.domElement.removeEventListener("touchstart",Q),i.domElement.removeEventListener("touchend",H),i.domElement.removeEventListener("touchmove",W),document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),d.dispose()},this.tween=function(){const e=1e-5;return function(t,n,o,r,a){i.targetObj.updateWorldMatrix(!0,!1);const s=gf.setFromMatrixPosition(i.targetObj.matrixWorld);i.object.parent&&(t=vf.copy(t),i.object.parent.worldToLocal(t)),t.manhattanDistanceTo(i.object.position)0?O(L()):C.y<0&&F(L()),b.copy(M),i.update()}(e);break;case hf:if(!1===i.enablePan)return;U(e)}}function G(e){!1!==i.enabled&&(document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",G),document.removeEventListener("mouseleave",G),i.dispatchEvent(bf),o=cf)}function k(e){!1===i.enabled||!1===i.enableZoom||o!==cf&&o!==uf||(e.preventDefault(),e.stopPropagation(),i.dispatchEvent(yf),function(e){w=i.zoomSpeed,E=i.zoomInertia,e.deltaY<0?F(L(Math.abs(e.deltaY)/100)):e.deltaY>0&&O(L(Math.abs(e.deltaY)/100)),i.update()}(e),i.dispatchEvent(bf))}function Q(e){if(!1!==i.enabled){switch(e.touches.length){case 1:if(!1===i.enableRotate)return;!function(e){h.set(e.touches[0].pageX,e.touches[0].pageY)}(e),o=pf;break;case 2:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(e){if(i.enableZoom){w=i.zoomSpeedTouch,E=i.zoomInertiaTouch;let t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+n*n);b.set(0,o)}if(i.enablePan){let t=.5*(e.touches[0].pageX+e.touches[1].pageX),n=.5*(e.touches[0].pageY+e.touches[1].pageY);A.set(t,n)}i.update()}(e),o=ff;break;default:o=cf}o!==cf&&i.dispatchEvent(yf)}}function W(e){if(!1!==i.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===i.enableRotate)return;if(o!==pf)return;!function(e){P(e.touches[0].pageX,e.touches[0].pageY),g=i.rotateSpeedTouch,v=i.rotateInertiaTouch}(e);break;case 2:if(!1===i.enableZoom&&!1===i.enablePan)return;if(o!==ff)return;!function(e){let t=e.touches[0].pageX-e.touches[1].pageX,n=e.touches[0].pageY-e.touches[1].pageY,o=Math.sqrt(t*t+n*n);M.set(0,o),C.subVectors(M,b),b.copy(M);let r=.5*(e.touches[0].pageX+e.touches[1].pageX),a=.5*(e.touches[0].pageY+e.touches[1].pageY);_.set(r,a),x.subVectors(_,A),A.copy(_),i.enableZoom&&Math.abs(C.length())>Math.abs(x.length())&&(C.y>0?F(L()):C.y<0&&O(L())),i.enablePan&&Math.abs(C.length())t.x?t.copy(cm):t.x=Math.max(t.x,dm.x);break;case"Y":dm.y+=i*n.y,um.subVectors(t,dm),e=lm.dot(um),lm.multiplyScalar(e),cm.subVectors(um,lm).add(dm),cm.y>t.y?t.copy(cm):t.y=Math.max(t.y,dm.y);break;case"Z":dm.z+=i*n.z,um.subVectors(t,dm),e=lm.dot(um),lm.multiplyScalar(e),cm.subVectors(um,lm).add(dm),cm.z>t.z?t.copy(cm):t.z=Math.max(t.z,dm.z);break;case"-X":dm.x+=i*n.x,um.subVectors(t,dm),e=lm.dot(um),lm.multiplyScalar(e),cm.subVectors(um,lm).add(dm),cm.x=this.distance&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)):"LIMITDIST_OUTSIDE"==this.limitMode?this._distInit<=this.distance&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)):"LIMITDIST_ONSURFACE"==this.limitMode&&this._distInit-this.distance!=0&&(this._clampSurf=1,0!=this._distInit&&(this._sfac=this.distance/this._distInit)),this._clampSurf&&(e.position.lerpVectors(this._objPosInit,pm,(1-this._sfac)*this.influence),e.parent&&e.parent.worldToLocal(e.position)))}}vm.prototype.isLimitDistanceConstraint=!0;class Am extends wf{constructor(){super(),this.type="LimitLocationConstraint",this.min=(new Bt).setScalar(-1/0),this.max=(new Bt).setScalar(1/0)}copy(e){return super.copy(e),this.min.copy(e.min),this.max.copy(e.max),this}update(e){super.update(e),this.mute||e.position.clamp(this.min,this.max)}}Am.prototype.isLimitLocationConstraint=!0;const _m=new xn;class xm extends wf{constructor(){super(),this.type="LimitRotationConstraint",this.axis="Y",this.min=0,this.max=2*Math.PI}copy(e){return super.copy(e),this.axis=e.axis,this.min=e.min,this.max=e.max,this}update(e){super.update(e),this.mute||("X"==this.axis?(_m.setFromQuaternion(e.quaternion,"XYZ"),_m.x=this._clampAngle(_m.x,this.min,this.max)):"Y"==this.axis?(_m.setFromQuaternion(e.quaternion,"YZX"),_m.y=this._clampAngle(_m.y,this.min,this.max)):"Z"==this.axis&&(_m.setFromQuaternion(e.quaternion,"ZXY"),_m.z=this._clampAngle(_m.z,this.min,this.max)),e.quaternion.setFromEuler(_m))}_clampAngle(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=Je(e,t,n)),e}}xm.prototype.isLimitRotationConstraint=!0;class ym extends wf{constructor(){super(),this.type="LimitScaleConstraint",this.min=(new Bt).setScalar(-1/0),this.max=(new Bt).setScalar(1/0)}copy(e){return super.copy(e),this.min.copy(e.min),this.max.copy(e.max),this}update(e){super.update(e),this.mute||e.scale.clamp(this.min,this.max)}}ym.prototype.isLimitScaleConstraint=!0;const bm=(new Lt).setFromAxisAngle(new Bt(1,0,0),-Math.PI/2),Mm=new Bt,Cm=new Bt,Sm=new Bt,wm=new Bt,Em=new Bt,Tm=new qi,Im=new Bt,Rm=new Bt,Lm=new Lt;class Bm extends Ef{constructor(e){super(e),this.type="LockedTrackConstraint",this.trackAxis="X",this.lockAxis="Y",this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.lockAxis=e.lockAxis,this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){if(super.update(e),this.mute)return;if(Sm.set("X"==this.trackAxis?1:"-X"==this.trackAxis?-1:0,"Y"==this.trackAxis?1:"-Y"==this.trackAxis?-1:0,"Z"==this.trackAxis?1:"-Z"==this.trackAxis?-1:0),wm.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1==Math.abs(Sm.dot(wm)))return;Mm.setFromMatrixPosition(e.matrixWorld),Cm.setFromMatrixPosition(this.target.matrixWorld),Tm.setFromNormalAndCoplanarPoint(wm,Mm),Tm.projectPoint(Cm,Em).sub(Mm);const t=Im.crossVectors(Sm,Em).dot(wm)>0?1:-1;e.setRotationFromAxisAngle(Tm.normal,t*Sm.angleTo(Em)),e.parent&&(e.parent.matrixWorld.decompose(Rm,Lm,Rm),e.quaternion.premultiply(Lm.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(bm)}}Bm.prototype.isLockedTrackConstraint=!0;const Pm=new Bt(0,1,0),Dm=(new Lt).setFromAxisAngle(new Bt(1,0,0),-Math.PI/2),Nm=new qi,Om=new Bt,Fm=new Bt,Um=new Bt,zm=new Bt,Vm=new Bt,Gm=new un,km=new Bt,Qm=new Lt;class Wm extends Ef{constructor(e){super(e),this.type="TrackToConstraint",this.trackAxis="X",this.upAxis="Y",this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.upAxis=e.upAxis,this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){if(super.update(e),this.mute)return;const t=this.trackAxis[this.trackAxis.length-1],n=this.upAxis[this.upAxis.length-1],i="-"==this.trackAxis[0],o="-"==this.upAxis[0];if(t==n)return;Om.setFromMatrixPosition(e.matrixWorld),Fm.setFromMatrixPosition(this.target.matrixWorld),Um.subVectors(Fm,Om),Um.lengthSq()?Um.normalize():Um.set(0,-1,0),Nm.set(Um,0),1!=Math.abs(Um.dot(Pm))?Nm.projectPoint(Pm,zm).normalize():zm.set(0,0,-1),i&&Um.negate(),o&&zm.negate();let r="X"==t?Um:"X"==n?zm:null,a="Y"==t?Um:"Y"==n?zm:null,s="Z"==t?Um:"Z"==n?zm:null;r?a?s||(s=Vm.crossVectors(r,a)):a=Vm.crossVectors(s,r):r=Vm.crossVectors(a,s),Gm.makeBasis(r,a,s),e.setRotationFromMatrix(Gm),e.parent&&(e.parent.matrixWorld.decompose(km,Qm,km),e.quaternion.premultiply(Qm.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Dm)}}Wm.prototype.isTrackToConstraint=!0;class Hm extends Ef{constructor(e){super(e),this._orthoZoom=1}copy(e){super.copy(e),this._orthoZoom=e._orthoZoom}update(e){if(super.update(e),this.mute)return;const t=this.target;if(e.parent!==t||!t.isOrthographicCamera)return void console.error("FixOrthoZoom: object should be a direct child of the orthographic camera");const n=this._orthoZoom/t.zoom;e.position.multiplyScalar(n),e.scale.multiplyScalar(n),this._orthoZoom=t.zoom}}Hm.prototype.isFixOrthoZoomConstraint=!0;var jm=new Bt,Ym=new Bt,Xm=new Lt,Km=new Nt,qm=new en;class Zm extends Ef{constructor(e){super(e),this.type="CanvasFitConstraint",this.edgeH=0,this.edgeV=0,this.offset=0,this.useBoundingBox=!0}copy(e){return super.copy(e),this.edgeH=e.edgeH,this.edgeV=e.edgeV,this.offset=e.offset,this.useBoundingBox=e.useBoundingBox,this}update(e){if(super.update(e),this.mute)return;const t=this.target;if(e.parent!==t)return void console.error("CanvasFitConstraint: object should be a direct child of the camera");let n,i,o;const r="LEFT"==this.edgeH?-1:"RIGHT"==this.edgeH?1:0,a="BOTTOM"==this.edgeV?-1:"TOP"==this.edgeV?1:0;t.isPerspectiveCamera&&(i=ke(t.fov/2),n=Math.atan(t.aspect*Math.tan(i)),"LEFT"==this.edgeH&&(n*=r),"BOTTOM"==this.edgeV&&(i*=a),o=Math.abs(e.position.z));const s=e.geometry;let l=0,c=0,u=0,d=0;if(s)if(e.matrix.compose(e.position,e.quaternion,e.scale),this.useBoundingBox){null===s.boundingBox&&s.computeBoundingBox(),Km.copy(e.geometry.boundingBox).applyMatrix4(e.matrix);const t=Km.getCenter(jm).sub(e.position),n=Km.getSize(Ym).addScalar(2*this.offset);l=-(.5*n.x*r+t.x),c=-(.5*n.y*a+t.y),u=n.x,d=n.y}else{null===s.boundingSphere&&s.computeBoundingSphere(),qm.copy(e.geometry.boundingSphere).applyMatrix4(e.matrix),qm.radius+=this.offset;const o=jm.copy(qm.center).sub(e.position);l=-(qm.radius*r+o.x),c=-(qm.radius*a+o.y),t.isPerspectiveCamera&&(l/=Math.cos(n),c/=Math.cos(i)),u=2*qm.radius,d=2*qm.radius}"STRETCH"==this.edgeH?(e.position.x=l,0!==u&&(e.scale.applyQuaternion(Xm.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.x*=2*o*Math.tan(n)/u:e.scale.x*=(t.right-t.left)/t.zoom/u,e.scale.applyQuaternion(Xm.copy(e.quaternion).invert()))):"NONE"!==this.edgeH&&(t.isPerspectiveCamera?e.position.x=o*Math.tan(n)+l:e.position.x=(r<0?t.left:t.right)/t.zoom+l),"STRETCH"==this.edgeV?(e.position.y=c,0!==d&&(e.scale.applyQuaternion(Xm.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.y*=2*o*Math.tan(i)/d:e.scale.y*=(t.top-t.bottom)/t.zoom/d,e.scale.applyQuaternion(Xm.copy(e.quaternion).invert()))):"NONE"!==this.edgeV&&(t.isPerspectiveCamera?e.position.y=o*Math.tan(i)+c:e.position.y=(a<0?t.bottom:t.top)/t.zoom+c)}}Zm.prototype.isCanvasFitConstraint=!0;class Jm extends wf{constructor(){super(),this.type="CanvasBreakpointsConstraint",this.minWidth=0,this.maxWidth=1/0,this.minHeight=0,this.maxHeight=1/0,this.orientation="ALL",this.appInstance=null}copy(e){return super.copy(e),this.minWidth=e.minWidth,this.maxWidth=e.maxWidth,this.minHeight=e.minHeight,this.maxHeight=e.maxHeight,this.orientation=e.orientation,this.appInstance=null,this}update(e){if(super.update(e),this.mute)return;if(!this.appInstance)return;const t=this.appInstance.getWidth(),n=this.appInstance.getHeight();let i;switch(this.orientation){case"ALL":i=!0;break;case"LANDSCAPE":i=t/n>=1;break;case"PORTRAIT":i=t/n<1}if(this.appInstance.getCamera()!==e||t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&i)t>=this.minWidth&&t<=this.maxWidth&&n>=this.minHeight&&n<=this.maxHeight&&i?e.traverse((e=>{e.internVisible=!0})):e.traverse((e=>{e.internVisible=!1}));else{let i=this.findAlternativeCamera(e,this.appInstance.scene,t,n);i&&this.appInstance.setCamera(i)}}findAlternativeCamera(e,t,n,i){let o,r,a=!1;return e&&t.traverse((function(t){if(!a&&t.isCamera&&t!=e)for(let e=0;e=1;break;case"PORTRAIT":o=n/i<1}n>=s.minWidth&&n<=s.maxWidth&&i>=s.minHeight&&i<=s.maxHeight&&o&&(r?(console.error("CanvasBreakpointsConstraint: two or more alternative cameras"),a=!0):r=t)}}})),r}}Jm.prototype.isCanvasBreakpointsConstraint=!0;const $m=function(e){return!!e&&(!!e.dtype&&new RegExp("function View[0-9]+d(:?"+e.dtype+")+").test(String(e.constructor)))},eg=function(e){return!!e&&(void 0!==e.data&&Array.isArray(e.shape)&&void 0!==e.offset&&void 0!==e.stride)};function tg(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function ng(e){if(e){if($m(e)||eg(e))return"generic"===e.dtype?ng.GENERIC_NDARRAY:ng.NDARRAY;if(tg(e))return ng.ARRAY_OF_ARRAYS;throw new Error("Unhandled data type. Got type: "+typeof e)}}ng.ARRAY_OF_ARRAYS="Arr",ng.NDARRAY="Nd",ng.GENERIC_NDARRAY="GenNd",ng.PACKED="PackArr";const ig=function(e,t){return function(t,n){void 0===t||Array.isArray(t)||(t=[t]);for(var i=[],o=0;o=0;i--){if(o[i]!==(Array.isArray(e[i])?e[i][1]:e[i])-1){o[i]++;break}o[i]=Array.isArray(e[i])?e[i][0]:0}},ug=function(e,t,n,i){var o,r=[];switch(ng(i)){case ng.NDARRAY:for(r.push(" const "+t+" = "+n+".data;"),r.push(" const "+t+"Offset = "+n+".offset;"),o=0;o1)throw new Error("Analytical derivative not implemented for rational b-splines with order n = "+y+".")}r&&(e="Basis"+e),a&&(e="Der"+a.join("_")+"_"+e);var b=hg[e];if(i)var M="function"==typeof i?i:console.log;if(b)return i&&M(pg[e]),b.bind(t);var C=[],S="evaluate"+e,w=n.point;r&&(w=function(e,t){for(var n=[],i=0;i "+D+"[i][1] || a === undefined || isNaN(a)) {"),U(" throw new Error('Invalid Spline parameter in dimension '+i+'. Valid domain is ['+"+D+"[i][0]+', '+"+D+"[i][1]+']. but got t'+i+' = '+arguments[i + 1]+'.');"),U(" }"),U("}")),d=0;d "+O(d)+" + 1) {"),U(" m = 0.5 * (h + "+O(d)+") | 0;"),U(" if ("+T([d,"m"])+" > "+P(d)+") h = m;"),U(" else "+O(d)+" = m;"),U("}"),z("\n // Fetch knots for dimension "+d+"\n"),s=1-m[d];s<=m[d];s++)"closed"===x[d]?U(s<0?"let "+I([d,s+m[d]-1])+" = "+k(O(d)+" < "+-s,T([d,0])+" + "+T([d,[N(d),O(d),s]])+" - "+T([d,[N(d)]]),T([d,[O(d),s]]))+";":s>0?"let "+I([d,s+m[d]-1])+" = "+k(O(d)+" + "+s+" > "+N(d),T([d,N(d)])+" + "+T([d,s+" + "+O(d)+" - "+N(d)])+" - "+T([d,0]),T([d,[O(d),s]]))+";":"let "+I([d,s+m[d]-1])+" = "+T([d,[O(d),s]])+";"):U("let "+I([d,s+m[d]-1])+" = "+T([d,[O(d),s]])+";");else{for(z("\n // Directly compute knot interval for dimension "+d+"\n"),"closed"===x[d]?U(O(d)+" = ("+P(d)+" | 0) % "+N(d)+";"):(U(O(d)+" = ("+P(d)+" | 0);"),U("if ("+O(d)+" < "+m[d]+") "+O(d)+" = "+m[d]+";"),U("if ("+O(d)+" > "+N(d)+" - 1) "+O(d)+" = "+N(d)+" - 1;")),z("\n // Compute and clamp knots for dimension "+d+"\n"),s=1-m[d];s<=m[d];s++)U("let "+(h=I([d,s+m[d]-1]))+" = "+O(d)+" + "+s+";");if("clamped"===x[d])for(s=1-m[d];s<=m[d];s++)h=I([d,s+m[d]-1]),s<0&&U("if ("+h+" < "+m[d]+") "+h+" = "+m[d]+";"),s>0&&U("if ("+h+" > "+N(d)+") "+h+" = "+N(d)+";");"closed"===x[d]&&(z("\n // Wrap the B-Spline parameter for closed boundary"),U(P(d)+" %= "+N(d)+";"))}for(d=0,c=[];d=0;d--)for(c[d]=[m[d],m[d]+1],s=0;ss;l--){var W=a&&m[d]-s-a[d]<=0;W?(U("m = 1 / ("+I([d,l-s+m[d]-1])+" - "+I([d,l-1])+");"),v&&(U("a = ("+P(d)+" - "+I([d,l-1])+") * m;"),U("b = 1 - a;"))):(U("a = ("+P(d)+" - "+I([d,l-1])+") / ("+I([d,l-s+m[d]-1])+" - "+I([d,l-1])+");"),U("b = 1 - a;")),v&&cg(c,(function(e){var t=e.slice(),n=e.slice();t[d]=l,n[d]=l-1,W&&v&&U("h = "+L(t)+";"),U(L(t)+" = b * "+L(n)+" + a * "+L(t)+";")})),cg(c,(function(e){var t,n,i,o=e.slice(),a=e.slice();if(o[d]=l,a[d]=l-1,W){var c=s+1;if(r)t=v?"h * "+L(a)+" / "+L(o)+" * ":"",n=R(o)+(v?" / h":""),i=R(a)+(v?" / "+L(a):""),U(R(o)+" = "+c+" * "+t+"("+n+" - "+i+") * m;");else{var h=o.slice(),f=a.slice();for(u=0;u<_;u++)h[p]=f[p]=u,t=v?"h * "+L(a)+" / "+L(o)+" * ":"",n=R(h)+(v?" / h":""),i=R(f)+(v?" / "+L(a):""),U(R(h)+" = "+c+" * "+t+"("+n+" - "+i+") * m;")}}else if(r)U(R(o)+" = b * "+R(a)+" + a * "+R(o)+";");else for(u=0;u<_;u++)o[p]=a[p]=u,U(R(o)+" = b * "+R(a)+" + a * "+R(o)+";")})),z("\n")}if(i&&U(v?"\n // Project back from homogeneous coordinates and return final output\n":"\n // Return final output\n"),r)U(v?"return "+R(m)+" / "+L(m)+";":"return "+R(m)+";");else for(d=0;d<_;d++)U(v?"out["+d+"] = "+R(m.concat([d]))+" / "+L(m)+";":"out["+d+"] = "+R(m.concat([d]))+";");if(r||U("return out;"),C.push("}"),i){var H=C.join("\n");M(H),pg[e]=H}const j=new Function([C.join("\n"),"; return ",S].join(""))();return hg[e]=j,j.bind(t)};var mg={};var gg={};var vg={open:"open",closed:"closed",clamped:"clamped"};function Ag(e){return null==e}function _g(e,t,n,i,o,r){var a,s;!e||tg(e)||$m(e)?(r=r||{},this.weights=i,this.knots=n,this.degree=t,this.points=e,this.boundary=o,this.debug=r.debug,this.checkBounds=!!r.checkBounds,Object.defineProperty(this,"size",{value:r.size,writable:!0,configurable:!0})):(r=e,this.debug=e.debug,this.checkBounds=!!e.checkBounds,this.weights=e.weights,this.knots=e.knots,this.degree=e.degree,this.boundary=e.boundary,this.points=e.points,Object.defineProperty(this,"size",{value:r.size,writable:!0,configurable:!0}));var l=ng(this.points),c=ng(this.weights),u=ng(this.knots);if(this.points)switch(l){case ng.GENERIC_NDARRAY:case ng.NDARRAY:Object.defineProperties(this,{splineDimension:{value:this.points.shape.length-1,writable:!1,configurable:!0},dimension:{value:this.points.shape[this.points.shape.length-1],writable:!1,configurable:!0},size:{get:function(){return this.points.shape.slice(0,this.points.shape.length-1)},set:function(){throw new Error("Cannot assign to read only property 'size'")},configurable:!0}});break;case ng.ARRAY_OF_ARRAYS:var d=0,h=this.size||[];h.length=0;for(var p=this.points;tg(p[0]);p=p[0])d++,h.push(p.length);if(0===d)throw new Error("Expected an array of points");Object.defineProperties(this,{splineDimension:{value:d,writable:!1,configurable:!0},dimension:{value:p.length,writable:!1,configurable:!0},size:{get:function(){var e=[];e.length=0;for(var t=0,n=this.points;t0&&!tg(this.knots[0])&&(this.knots=[this.knots]),a=0;a= 0; "+a+"--) {");for(o=0;o=0;o--)p.push("}");p.push("return this;"),p.push("}");const g=new Function([p.join("\n"),"; return ",f].join(""))();return i&&console.log(p.join("\n")),mg[e]=g,g.bind(t)}(this.__cacheKey,this,v,this.debug),this.support=function(e,t,n,i,o){var r=gg[e];if(r)return r.bind(t);var a,s,l,c=t.degree,u=t.knots,d=t.splineDimension,h=t.boundary,p=[],f="support"+e,m=n.knot,g=ig("t"),v=i?"domain":"d",A=ig(i?"size":"s"),_=ig(i?"knotIndex":"i"),x=!0;for(l=0;l "+v+"[i][1] || a === undefined || isNaN(a)) {"),y(" throw new Error('Invalid Spline parameter in dimension '+i+'. Valid domain is ['+"+v+"[i][0]+', '+"+v+"[i][1]+']. but got t'+i+' = '+arguments[i + 1]+'.');"),y(" }"),y("}")),l=0;l "+_(l)+" + 1) {"),y(" m = 0.5 * (h + "+_(l)+") | 0;"),y(" if ("+m([l,"m"])+" > "+g(l)+") h = m;"),y(" else "+_(l)+" = m;"),y("}")):"closed"===h[l]?y(_(l)+" = ("+g(l)+" | 0) % "+A(l)+";"):(y(_(l)+" = ("+g(l)+" | 0);"),y("if ("+_(l)+" < "+c[l]+") "+_(l)+" = "+c[l]+";"),y("if ("+_(l)+" > "+A(l)+" - 1) "+_(l)+" = "+A(l)+" - 1;"));for(l=0,s=[];l0?1:-1;Vg.setFromAxisAngle(t,o.angleTo(i)*n),e.multiply(Vg)}else r<0&&(Vg.setFromAxisAngle(t,Math.PI),e.multiply(Vg));return e}_calcBankAngle(e,t,n,i){const o=Og.copy(t).add(n).normalize();return e*(Fg.crossVectors(o,t).normalize().dot(i)>0?1:-1)}_calcCurvature(e,t){return Og.crossVectors(e,t).length()/Math.pow(e.length(),3)}_calcSecondDerivative(e,t,n,i){this.secondDerivativeEvaluatorForNonUniformBSplines(Gg,t);const o=Og.fromArray(Gg);this.derivativeEvaluatorForWeights1(Gg,t);const r=Gg[0];this.derivativeEvaluatorForWeights2(Gg,t);const a=Gg[0];this.derivativeEvaluatorForWeights0(Gg,t);const s=Gg[0];return e.copy(o).sub(Fg.copy(i).multiplyScalar(2*r)),e.sub(Fg.copy(n).multiplyScalar(a)),e.divideScalar(s),e}_limitAngle(e,t){return e>0?Math.min(e,t):Math.max(e,-t)}_calcChordLengths(e,t){let n=1/Math.max(1,t-1),i=0,o=0;const r=this.curve.domain;let a=r[0][0],s=r[0][1]-r[0][0];const l=Og,c=Fg;this._calcPosition(l,a);for(let r=0;r=1)return 1;let n=e*t[t.length-1],i=0,o=0,r=t.length-1;for(;it[o]?i=o+1:r=o-1;return n>t[r]?r+=(n-t[r])/(t[r+1]-t[r]):r-=1-(n-t[r-1])/(t[r]-t[r-1]),r/(t.length-1)}}kg.prototype.isMotionPathConstraint=!0;const Qg=["IMAGE_AR","SKYDOME_LIGHT_AR","TEXTURE_BL","TEX_IMAGE_BL","TEX_ENVIRONMENT_BL","BITMAP_MX","BITMAP_ENV_MX","TEX_ENVIRONMENT_MX","REFLECT_REFRACT_MX","FILE_MY","TEXTURE","TEX_IMAGE","TEX_ENVIRONMENT","TEX_ENVIRONMENT_MAX","BITMAP_MAX","BITMAP_ENV_MAX","REFLECT_REFRACT_MAX","AI_SKYDOME_LIGHT_MY","OSL_NODE"];class Wg extends Hu{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Kg(e)})),this.register((function(e){return new tv(e)})),this.register((function(e){return new nv(e)})),this.register((function(e){return new qg(e)})),this.register((function(e){return new Zg(e)})),this.register((function(e){return new Jg(e)})),this.register((function(e){return new $g(e)})),this.register((function(e){return new ev(e)})),this.register((function(e){return new Yg(e)})),this.register((function(e){return new iv(e)})),this.register((function(e){return new pv(e)})),this.register((function(e){return new fv(e)})),this.register((function(e){return new mv(e)})),this.register((function(e){return new gv(e)})),this.register((function(e){return new vv(e)})),this.register((function(e){return new Av(e)})),this.register((function(e){return new _v(e)})),this.register((function(e){return new xv(e)})),this.register((function(e){return new yv(e)})),this.onProgress=null}load(e,t,n,i){const o=this;let r;o.onProgress=n||function(){},r=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:vd.extractUrlBase(e);const a=-1!=e.indexOf(".xz",e.length-3);let s;a?s=new kp(o.manager):(s=new Yu(o.manager),s.setResponseType("arraybuffer"));const l=function(e){o.onProgress&&o.onProgress(.3*e*100)};let c=l;s instanceof Yu&&(c=function(e){const t=e.lengthComputable?e.loaded/e.total:1;l(t)}),s.load(e,(function(e){try{o.parse(e,r,t,i,a)}catch(e){void 0!==i&&i(e.constructor===Error?e:new Error("v3d.GLTFLoader: Unable to parse model."))}}),c,i)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('v3d.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i,o){let r;const a={},s={};if("string"==typeof e)r=e;else{if(vd.decodeText(new Uint8Array(e,0,4))===ov){try{a[jg.KHR_BINARY_GLTF]=new sv(e)}catch(e){return void(i&&i(e))}r=a[jg.KHR_BINARY_GLTF].content}else r=vd.decodeText(new Uint8Array(e))}const l=JSON.parse(r);if(void 0===l.asset||l.asset.version[0]<2)return void(i&&i(new Error("v3d.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=this;!function(e){const t=["S8S_v3d_lights","S8S_v3d_light_probes","S8S_v3d_curves","S8S_v3d_clipping_planes"],n=e.extensionsUsed||[];n.includes("S8S_v3d_animation_data")&&(eA("S8S_v3d_animation_data","S8S_v3d_animation",n),(e.animations||[]).forEach((e=>{tA("S8S_v3d_animation_data","S8S_v3d_animation",e)})),nA("S8S_v3d_animation_data"));n.includes("S8S_v3d_node_data")&&(eA("S8S_v3d_node_data","S8S_v3d_node",n),(e.nodes||[]).forEach((e=>{tA("S8S_v3d_node_data",[].concat(["S8S_v3d_node"],t),e)})),nA("S8S_v3d_node_data"));n.includes("S8S_v3d_material_data")&&(eA("S8S_v3d_material_data","S8S_v3d_materials",n),(e.materials||[]).forEach((e=>{e.extensions&&e.extensions.S8S_v3d_material_data&&e.pbrMetallicRoughness?delete e.extensions.S8S_v3d_material_data:tA("S8S_v3d_material_data","S8S_v3d_materials",e)})),nA("S8S_v3d_material_data"));n.includes("S8S_v3d_mesh_data")&&(eA("S8S_v3d_mesh_data","S8S_v3d_mesh",n),(e.meshes||[]).forEach((e=>{tA("S8S_v3d_mesh_data","S8S_v3d_mesh",e)})),nA("S8S_v3d_mesh_data"));n.includes("S8S_v3d_camera_data")&&(eA("S8S_v3d_camera_data","S8S_v3d_camera",n),(e.cameras||[]).forEach((e=>{tA("S8S_v3d_camera_data","S8S_v3d_camera",e)})),nA("S8S_v3d_camera_data"));n.includes("S8S_v3d_scene_data")&&(eA("S8S_v3d_scene_data","S8S_v3d_scene",n),(e.scenes||[]).forEach((e=>{tA("S8S_v3d_scene_data","S8S_v3d_scene",e)})),nA("S8S_v3d_scene_data"));n.includes("S8S_v3d_texture_data")&&(eA("S8S_v3d_texture_data","S8S_v3d_texture",n),(e.textures||[]).forEach((e=>{tA("S8S_v3d_texture_data","S8S_v3d_texture",e)})),nA("S8S_v3d_texture_data"));n.includes("S8S_v3d_data")&&(eA("S8S_v3d_data",t,n),tA("S8S_v3d_data",[].concat(t,["S8S_v3d_materials"]),e),nA("S8S_v3d_data"));(e.textures||[]).forEach((t=>{if(st(t.source)){const n=e.images[t.source],i=n.uri||"",o=n.mimeType;if("hdr"==i.split(".").pop()||"image/vnd.radiance"==o||"xz"==i.split(".").pop()||"application/x-xz"==o){t.extensions=t.extensions||{};const e=t.extensions.S8S_v3d_texture||{};e.source=t.source,delete t.source,t.extensions.S8S_v3d_texture=e,console.warn("Placing HDR map to S8S_v3d_texture extension, please reexport your scene file")}}}))}(l);const u=new qv(l,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder,loadBinXZ:o,onProgress:function(e){c.onProgress&&c.onProgress(e)}});for(let e=0;e=0&&void 0===s[t]&&console.warn('v3d.GLTFLoader: Unknown extension "'+t+'".')}}u.setExtensions(a),u.setPlugins(s),u.parse((function(e){c.onProgress&&c.onProgress(100),n(e)}),i)}parseAsync(e,t){const n=this;return new Promise((function(i,o){n.parse(e,t,i,o)}))}}function Hg(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const jg={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",S8S_V3D_ANIMATION:"S8S_v3d_animation",S8S_V3D_CAMERA:"S8S_v3d_camera",S8S_V3D_MATERIALS:"S8S_v3d_materials",S8S_V3D_MESH:"S8S_v3d_mesh",S8S_V3D_NODE:"S8S_v3d_node",S8S_V3D_SCENE:"S8S_v3d_scene",S8S_V3D_TEXTURE:"S8S_v3d_texture",S8S_V3D_LIGHTS:"S8S_v3d_lights",S8S_V3D_LIGHT_PROBES:"S8S_v3d_light_probes",S8S_V3D_CURVES:"S8S_v3d_curves",S8S_V3D_CLIPPING_PLANES:"S8S_v3d_clipping_planes"};class Yg{constructor(e){this.parser=e,this.name=jg.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n=0)throw new Error("v3d.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,r,a)}}class nv{constructor(e){this.parser=e,this.name=jg.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t],a=i.images[r.source];let s=n.textureLoader;if(a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return this.detectSupport().then((function(o){if(o)return n.loadTextureImage(e,a,s);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("v3d.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class iv{constructor(e){this.name=jg.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("v3d.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,o.ready]).then((function(t){const n=e.byteOffset||0,i=e.byteLength||0,r=e.count,a=e.byteStride,s=new ArrayBuffer(r*a),l=new Uint8Array(t[0],n,i);return o.decodeGltfBuffer(new Uint8Array(s),r,a,l,e.mode,e.filter),s}))}return null}}const ov="glTF",rv=1313821514,av=5130562;class sv{constructor(e){this.name=jg.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:vd.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==ov)throw new Error("v3d.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("v3d.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,i=new DataView(e,12);let o=0;for(;o",t).replace("#include ",n).replace("#include ",i).replace("#include ",o).replace("#include ",r)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class dv{constructor(){this.name=jg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return uv}extendParams(e,t,n){const i=t.extensions[this.name];e.color=new yt(1,1,1),e.opacity=1;const o=[];if(Array.isArray(i.diffuseFactor)){const t=i.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==i.diffuseTexture&&o.push(n.assignTexture(e,"map",i.diffuseTexture)),e.emissive=new yt(0,0,0),e.glossiness=void 0!==i.glossinessFactor?i.glossinessFactor:1,e.specular=new yt(1,1,1),Array.isArray(i.specularFactor)&&e.specular.fromArray(i.specularFactor),void 0!==i.specularGlossinessTexture){const t=i.specularGlossinessTexture;o.push(n.assignTexture(e,"glossinessMap",t)),o.push(n.assignTexture(e,"specularMap",t))}return Promise.all(o)}createMaterial(e){const t=new uv(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=TangentSpaceNormalMap,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t.refractionRatio=.98,t}}class hv{constructor(){this.name=jg.KHR_MESH_QUANTIZATION}}class pv{constructor(e){this.parser=e,this.name=jg.S8S_V3D_LIGHTS,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n(e&&(a.target=e),i=Promise.resolve(a),t.cache.add(n,i),i)))}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],o=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===o?null:this._loadLight(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class fv{constructor(e){this.parser=e,this.name=jg.S8S_V3D_LIGHT_PROBES,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n0||r.bevelThickness>0,t=new Gc(r.text,{font:l,size:r.size,height:r.height,curveSegments:r.curveSegments,bevelEnabled:e,bevelThickness:r.bevelThickness,bevelSize:r.bevelSize,bevelSegments:r.bevelSegments,alignX:r.alignX,alignY:r.alignY,lineHeight:r.lineHeight,scaledEmSize:r.scaledEmSize});a=new Di(t,c)}else a=new Nn;return a.name=t.createUniqueName(r.name||"curve_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}))}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],o=(i.extensions&&i.extensions[this.name]||{}).curve;return void 0===o?null:this._loadCurve(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class gv{constructor(e){this.parser=e,this.name=jg.S8S_V3D_CLIPPING_PLANES,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n-1){[["Blender","BLENDER"],["3ds Max","MAX"],["Maya","MAYA"]].forEach((function(t){const n=t[0],i=t[1];e.indexOf(n)>-1&&Re!=i&&console.warn("The glTF asset was exported from "+n+". It may not be fully compatible with Verge3D for Blender.")}))}}afterRoot(e){const t=this.parser,n=t.json,i=n.scenes[n.scene||0],o=e.scene,r=st(i.extensions)?i.extensions[jg.S8S_V3D_SCENE]:void 0,a=[],s=[],l=[];let c;return c=i&&r&&st(r.worldMaterial)?t.getDependency("material",r.worldMaterial):Promise.resolve(),c.then((t=>{const n={};t&&(n.material=t),e.world=n})).then((()=>(t.assignedMaterials.forEach((function(e){e.isMeshNodeMaterial&&e.traverseNodes((function(n){"TEX_COORD_BL"===n.originData.type&&st(n.originData.object)&&n.originData.object>-1&&(a.push(t.getDependency("node",n.originData.object)),s.push(n),l.push(e))}))})),Promise.all(a)))).then((t=>{for(let e=0;e(t[0]&&(e.controls.orbitTarget=t[0]),t[1]&&(e.controls.collisionMaterial=t[1]),e)))}}class xv{constructor(e){this.name=jg.S8S_V3D_MATERIALS,this.parser=e}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?wu:null}extendMaterialParams(e,t){const n=this.parser.json,i=n.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name],r=[];if(st(o.nodeGraph)){const e=o.nodeGraph;t.nodeGraph=wu.nodeGraphFromExtGraph(e);for(let n=0;n-1&&st(i.texture)){const e=wu.nodeTexUniName(i.type,i.texture);r.push(this.assignTextureNode(t,e,i.texture))}else"RAMP_MY"==i.type&&(i.wrapS=Dv[i.wrapS]||m,i.wrapT=Dv[i.wrapT]||m)}const i=n.extensions&&n.extensions[this.name]||{};if(i&&i.nodeGraphs){t.additionalNodeGraphs={};for(let e in i.nodeGraphs){const n=i.nodeGraphs[e];t.additionalNodeGraphs[e]=wu.nodeGraphFromExtGraph(n);for(let e=0;e-1){const e=wu.nodeTexUniName(i.type,i.texture);r.push(this.assignTextureNode(t,e,i.texture))}}}}}return st(o.profile)&&(t.profile=o.profile),st(o.renderSide)&&(t.side=kv[o.renderSide]),st(o.useShadows)&&(t.receiveShadow=o.useShadows),st(o.useCastShadows)&&(t.castShadow=o.useCastShadows),st(o.depthWrite)&&(t.depthWrite=o.depthWrite),st(o.depthTest)&&(t.depthTest=o.depthTest),st(o.dithering)&&(t.dithering=o.dithering),st(o.materialIndex)&&(t.materialIndex=o.materialIndex),!0===o.alphaToCoverage&&(t.alphaToCoverage=!0),st(o.gtaoVisible)&&(t.gtaoVisible=o.gtaoVisible),delete t.metalness,delete t.roughness,Promise.all(r)}assignTextureNode(e,t,n){return this.parser.getDependency("texture",n).then((function(n){e.nodeTextures=e.nodeTextures||{},e.nodeTextures[t]=n}))}assignTransparency(e,t){const n=e.extensions[this.name]||{};if(e.premultipliedAlpha=t==Gv.BLEND,t==Gv.BLEND)if(st(n.blendMode)){const t=n.blendMode;e.blending=5,st(t.blendEquation)&&(e.blendEquation=Nv[t.blendEquation]),st(t.blendEquationAlpha)&&(e.blendEquationAlpha=Nv[t.blendEquationAlpha]),st(t.srcRGB)&&(e.blendSrc=Ov[t.srcRGB]),st(t.dstRGB)&&(e.blendDst=Ov[t.dstRGB]),st(t.srcAlpha)&&(e.blendSrcAlpha=Ov[t.srcAlpha]),st(t.dstAlpha)&&(e.blendDstAlpha=Ov[t.dstAlpha])}else aA(e)}}class yv{constructor(e){this.parser=e,this.name=jg.S8S_V3D_TEXTURE,this.textureLoaderRGBE=new Wp,this.textureLoaderRGBE.setCrossOrigin(this.parser.options.crossOrigin),this.textureLoaderRGBE.setRequestHeader(this.parser.options.requestHeader)}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const r=o.extensions[t];if(!st(r.source))return null;const a=i.images[r.source];let s=n.textureLoader;if("hdr"==(a.uri||"").split(".").pop()||"image/vnd.radiance"==a.mimeType?s=this.textureLoaderRGBE:"xz"!=(a.uri||"").split(".").pop()&&"application/x-xz"!=a.mimeType||(s=new kp),a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return n.loadTextureImage(e,a,s)}extendTextureParams(e,t,n){const i=this.name;if(!t.extensions||!t.extensions[i])return null;const o=t.extensions[i],r="linear"==o.colorSpace||"non-color"==o.colorSpace?ve:Ae;e.encoding=r,(n instanceof Wp||n instanceof kp)&&(e.minFilter=y),st(o.anisotropy)&&(e.anisotropy=o.anisotropy),st(o.uvTransform)&&(e.matrix=(new tt).fromArray(o.uvTransform),e.matrixAutoUpdate=!1)}}class bv extends tu{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i*3+i;for(let e=0;e!==i;e++)t[e]=n[o+e];return t}}bv.prototype.beforeStart_=bv.prototype.copySampleValue_,bv.prototype.afterEnd_=bv.prototype.copySampleValue_,bv.prototype.interpolate_=function(e,t,n,i){const o=this.resultBuffer,r=this.sampleValues,a=this.valueSize,s=2*a,l=3*a,c=i-t,u=(n-t)/c,d=u*u,h=d*u,p=e*l,f=p-l,m=-2*h+3*d,g=h-d,v=1-m,A=g-d+u;for(let e=0;e!==a;e++){const t=r[f+e+a],n=r[f+e+s]*c,i=r[p+e+a],l=r[p+e]*c;o[e]=v*t+A*n+m*i+g*l}return o};const Mv=new Lt;class Cv extends bv{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return Mv.fromArray(o).normalize().toArray(o),o}}const Sv=0,wv=1,Ev=2,Tv=3,Iv=4,Rv=5,Lv=6,Bv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Pv={9728:A,9729:y,9984:_,9985:b,9986:x,9987:M},Dv={33071:g,33648:v,10497:m},Nv={32774:i,32778:101,32779:102},Ov={0:o,1:r,768:202,769:203,770:a,771:s,772:206,773:207,774:208,775:209,776:210},Fv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Uv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},zv={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences",intensity:"intensity"},Vv={CUBICSPLINE:void 0,LINEAR:ue,STEP:ce},Gv={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},kv={FRONT:0,BACK:1,DOUBLE:2};function Qv(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new jc({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0,receiveShadow:!0,castShadow:!0})),e.DefaultMaterial}function Wv(e,t,n){for(const i in n.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=n.extensions[i])}function Hv(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("v3d.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function jv(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,i]of e.children.entries())o(i,t.children[n])};return o(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n=2&&p.setY(t,u[e*r+1]),r>=3&&p.setZ(t,u[e*r+2]),r>=4&&p.setW(t,u[e*r+3]),r>=5)throw new Error("v3d.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e],o=t.images[i.source];let r=this.textureLoader;if(o.uri){const e=n.manager.getHandler(o.uri);null!==e&&(r=e)}return this.loadTextureImage(e,o,r)}loadTextureImage(e,t,n){const i=this,o=this.json,r=this.options,a=o.textures[e],s=(t.uri||t.bufferView)+":"+a.sampler;if(this.textureCache[s])return this.textureCache[s];const l=self.URL||self.webkitURL;let c=t.uri||"",u=!1;if(void 0!==t.bufferView)c=i.getDependency("bufferView",t.bufferView).then((function(e){u=!0;const n=new Blob([e],{type:t.mimeType});return c=l.createObjectURL(n),c}));else if(void 0===t.uri)throw new Error("v3d.GLTFLoader: Image "+e+" is missing URI and bufferView");const d=Promise.resolve(c).then((function(e){return new Promise((function(t,i){let o=t;!0===n.isImageBitmapLoader&&(o=function(e){const n=new St(e);n.needsUpdate=!0,t(n)}),n.load(vd.resolveURL(e,r.path),o,void 0,i)}))})).then((function(e){if(e instanceof ArrayBuffer){return i.plugins[jg.S8S_V3D_TEXTURE].textureLoaderRGBE.loadAsync(l.createObjectURL(new Blob([e],{type:"image/vnd.radiance"})))}return Promise.resolve(e)})).then((function(t){!0===u&&l.revokeObjectURL(c),t.flipY=!1,a.name&&(t.name=a.name);const r=(o.samplers||{})[a.sampler]||{};return t.magFilter=Pv[r.magFilter]||y,t.minFilter=Pv[r.minFilter]||M,t.wrapS=Dv[r.wrapS]||m,t.wrapT=Dv[r.wrapT]||m,i._invokeAll((function(e){return e.extendTextureParams&&e.extendTextureParams(t,a,n)})),i.associations.set(t,{textures:e}),t})).catch((function(){return console.error("v3d.GLTFLoader: Couldn't load texture",c),new St}));return this.textureCache[s]=d,d}assignTexture(e,t,n){const i=this;return this.getDependency("texture",n.index).then((function(o){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("v3d.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[jg.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[jg.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(o);o=i.extensions[jg.KHR_TEXTURE_TRANSFORM].extendTexture(o,e),i.associations.set(o,t)}}return e[t]=o,o}))}assignFinalMaterial(e,t,n){const i=e.geometry;let o=e.material;const r=void 0===i.attributes.tangent,a=void 0!==i.attributes.color&&!o.isMeshNodeMaterial,s=void 0===i.attributes.normal,l=o.isMeshNodeMaterial&&(o.nodeValue.length||o.nodeRGB.length),c=o.isMeshNodeMaterial&&o.hasNode("TEX_COORD_BL"),u=o.isMeshNodeMaterial&&Object.getOwnPropertyNames(t).length>0&&o.hasNode("UVMAP_BL"),d=o.isMeshNodeMaterial&&Object.getOwnPropertyNames(n).length>0&&(o.hasNode("ATTRIBUTE_BL")||o.hasNode("VERTEX_COLOR_BL"));if(e.isPoints){const e="PointsMaterial:"+o.uuid;let t=this.cache.get(e);t||(t=new PointsMaterial,Xn.prototype.copy.call(t,o),t.color.copy(o.color),t.map=o.map,t.sizeAttenuation=!1,this.cache.add(e,t)),o=t}else if(e.isLine){const e="LineBasicMaterial:"+o.uuid;let t=this.cache.get(e);t||(t=new LineBasicMaterial,Xn.prototype.copy.call(t,o),t.color.copy(o.color),this.cache.add(e,t)),o=t}if(r||a||s||l||c||u||d){let e="ClonedMaterial:"+o.uuid+":";o.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="derivative-tangents:"),a&&(e+="vertex-colors:"),s&&(e+="flat-shading:");const i=Fe();l&&(e=i),c&&(e=i),u&&(e=i),d&&(e=i);let h=this.cache.get(e);h||(h=o.clone(),a&&(h.vertexColors=!0),s&&(h.flatShading=!0),r&&(h.normalScale&&(h.normalScale.y*=-1),h.clearcoatNormalScale&&(h.clearcoatNormalScale.y*=-1)),h.isMeshNodeMaterial&&(Object.assign(h.nodeUVAliases,t),Object.assign(h.nodeVCAliases,n),h.updateNodeGraph()),this.cache.add(e,h),this.associations.set(h,this.associations.get(o))),o=h}o.aoMap&&void 0===i.attributes.uv2&&void 0!==i.attributes.uv&&i.setAttribute("uv2",i.attributes.uv),e.material=o,this.assignedMaterials.includes(o)||this.assignedMaterials.push(o)}getMaterialType(){return jc}loadMaterial(e){const t=this,n=this.json,i=this.extensions,o=n.materials[e];let r;const a={},s=o.extensions||{},l=[];if(s[jg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=i[jg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];r=e.getMaterialType(),l.push(e.extendParams(a,o,t))}else if(s[jg.KHR_MATERIALS_UNLIT]){const e=i[jg.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),l.push(e.extendParams(a,o,t))}else{const n=o.pbrMetallicRoughness||{};if(a.color=new yt(1,1,1),a.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(a,"map",n.baseColorTexture)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===o.doubleSided&&(a.side=2);const c=o.alphaMode||Gv.OPAQUE;if(c===Gv.BLEND?(a.transparent=!0,r!==wu&&(a.depthWrite=!1)):(a.transparent=!1,c===Gv.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&r!==Kn&&(l.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new et(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==o.occlusionTexture&&r!==Kn&&(l.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&r!==Kn&&(a.emissive=(new yt).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&r!==Kn&&l.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture)),Promise.all(l).then((function(){let n;n=r===uv?i[jg.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new r(a),o.name&&(n.name=o.name),n.map&&(n.map.encoding=Ae),n.emissiveMap&&(n.emissiveMap.encoding=Ae);const s=t.plugins[jg.S8S_V3D_MATERIALS];return n.isMeshNodeMaterial&&s.assignTransparency(n,c),n.isMeshStandardMaterial&&n.normalScale&&s&&st(s.profile)&&"max"==s.profile&&(n.normalScale.y=-n.normalScale.y),Hv(n,o),t.associations.set(n,{materials:e}),o.extensions&&Wv(i,n,o),n}))}createUniqueName(e){const t=e;let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function o(e){return n[jg.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return Jv(n,e,t)}))}const r=[];for(let n=0,a=e.length;n0&&jv(h,o),h.name=t.createUniqueName(o.name||"mesh_"+e),Hv(h,o),d.extensions&&Wv(i,h,d);const f={},m={};if(h.material.isMeshNodeMaterial&&s){if(s.uvLayers)for(let e in s.uvLayers)f[e]=oA(s.uvLayers[e]);if(s.colorLayers)for(let e in s.colorLayers)m[e]=rA(s.colorLayers[e])}t.assignFinalMaterial(h,f,m),c.push(h)}for(let n=0,i=c.length;n-1){p=Nu,f="constraints["+h.path.match(/".*"/g)[0]+"]."+h.path.match(/[^\\.]*$/g)[0]}else{let e;p=zu,h.path.indexOf("nodeValue")>-1?(e=h.path.match(/".*"/g)[0],f="material.nodeValue["+e+"]"):h.path.indexOf("nodeRGB")>-1&&(e=h.path.match(/".*"/g)[0],f="material.nodeRGB["+e+"]")}}const m=t.name?t.name:t.uuid,g=void 0!==d.interpolation?Vv[d.interpolation]:ue,v=[];if(zv[h.path]===zv.weights)t.traverse((function(e){e.morphTargetInfluences&&v.push(e.name?e.name:e.uuid)}));else if(h.path.indexOf("material")>-1){const e=n[5];t.traverse((function(t){if(!t.isMesh)return;if(!t.material.isMeshNodeMaterial)return;let n=!1;if(h.extras){n=e[h.extras.material].name===t.material.name;const i=h.path.match(/\["(.*)"\]/);n=n&&null!==i&&null!==t.material.findNodeByName(i[1])}else n=!0;n&&v.push(t.name?t.name:t.uuid)}))}else v.push(m);let A=u.array;if(u.normalized){const e=Kv(A.constructor),t=new Float32Array(A.length);for(let n=0,i=A.length;n1?new $a:1===t.length?t[0]:new Nn,a!==t[0])for(let e=0,n=t.length;e{i._invokeOne((function(n){if(t!==e)return n.extendNodeParams&&n.extendNodeParams(t,o)}))})),i._invokeOne((function(t){return t.extendNodeParams&&t.extendNodeParams(e,o)}))}))}loadScene(e){const t=this.json,n=this.extensions,i=this.json.scenes[e],o=this,r=new mo;i.name&&(r.name=o.createUniqueName(i.name)),Hv(r,i),i.extensions&&Wv(n,r,i);const a=i.nodes||[],s=[];for(let e=0,n=a.length;e{const t=new Map;for(const[e,n]of o.associations)(e instanceof Xn||e instanceof St)&&t.set(e,n);return e.traverse((e=>{const n=o.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function Zv(e,t,n,i){const o=n.nodes[e];return i.getDependency("node",e).then((function(e){if(void 0===o.skin)return e;let t;return i.getDependency("skin",o.skin).then((function(e){t=e;const n=[];for(let e=0,o=t.joints.length;e-1&&n.splice(i,1),Array.isArray(t)?t.forEach((e=>{n.push(e)})):n.push(t)}function tA(e,t,n){const i=n.extensions||{};Array.isArray(t)?t.forEach((t=>{i[t]=i[e]})):i[t]=i[e],delete i[e]}function nA(e){console.warn(`Deprecated '${e}' extension found, please reexport your scene file`)}function iA(e){return e.indexOf("TEXCOORD_")>-1?oA(e):e.indexOf("COLOR_")>-1?rA(e):""}function oA(e){return"TEXCOORD_0"==e?"uv":"uv"+String(Number(e.split("TEXCOORD_")[1])+1)}function rA(e){return"COLOR_0"==e?"color":"color"+String(Number(e.split("COLOR_")[1])+1)}function aA(e){e.blending=5,e.blendEquation=i,e.blendSrc=r,e.blendDst=s}const sA=new yt;class lA extends Be{constructor(e,t,n=512,i=512){super(),this.scene=e,this.camera=t,this.width=n,this.height=i,this.distance=.1,this.factor=1,this.precision=1,this.bentNormals=!1,this.bounceApprox=!1,this.noiseTexture=this.createNoiseTexture(),this.fsQuad=new kh(null);const o=new ns;o.type=w,this.renderTargetNormalDepth=new Tt(this.width,this.height,{format:R,depthTexture:o,depthBuffer:!0}),this.renderTargetGTAO=new Tt(this.width,this.height),this.renderTargetBlurX=new Tt(this.width,this.height),this.renderTarget=new Tt(this.width,this.height),this.materialNormal=new qc({}),this.materialGTAO=new Vi({type:"GTAO",defines:{ORTHO_CAMERA:0,CALC_BENT_NORMALS:0},extensions:{derivatives:!0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},occlDistance:{value:.1},factor:{value:1},occlPrecision:{value:1},bounceApprox:{value:0},mainCameraProjMat:{value:new un},resolution:{value:new et}},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_gtao_frag}),this.materialBlur=new Vi({type:"GTAOBlur",defines:{},uniforms:{tDiffuse:{value:null},tNormal:{value:null},direction:{value:new et},resolution:{value:new et}},customPrepTokens:{BLUR_RADIUS_PX:2},vertexShader:io.pp_plane_vert,fragmentShader:io.pp_gtao_blur_frag}),this._layerMasks={}}setCamera(e){this.camera=e}setSize(e,t){this.width=e,this.height=t,this.renderTargetNormalDepth.setSize(e,t),this.renderTargetGTAO.setSize(e,t),this.renderTargetBlurX.setSize(e,t),this.renderTarget.setSize(e,t),this.materialGTAO.uniforms.mainCameraProjMat.value.copy(this.camera.projectionMatrix),this.materialGTAO.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this.materialBlur.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height)}dispose(){this.dispatchEvent({type:"dispose"}),this.renderTargetNormalDepth.dispose(),this.renderTargetGTAO.dispose(),this.renderTargetBlurX.dispose(),this.renderTarget.dispose(),this.materialNormal.dispose(),this.materialGTAO.dispose(),this.materialBlur.dispose(),this.noiseTexture.dispose()}_saveLayers(){this.scene.traverse((e=>this._layerMasks[e.id]=e.layers.mask))}_setupLayers(){this.scene.traverse((e=>{e.layers.disableAll();const t=e instanceof Di&&e.material&&!e.material.gtaoVisible,n=e instanceof Di&&e.material&&e.material.isMeshNodeMaterial&&(e.material.alphaTest>0||e.material.alphaToCoverage);t?e.layers.enable(0):n?e.layers.enable(1):e.layers.enable(2)}))}_restoreLayers(){this.scene.traverse((e=>e.layers.mask=this._layerMasks[e.id]))}_setupNodeAlphaClipHashMaterials(){this.scene.traverse((e=>{e instanceof Di&&e.material&&e.material.isMeshNodeMaterial&&(e.material.defines.NORMAL_OUTPUT=Number(e.material.alphaTest>0||e.material.alphaToCoverage),e.material.needsUpdate=!0)}))}_restoreNodeAlphaClipHashMaterials(){this.scene.traverse((e=>{e instanceof Di&&e.material&&e.material.isMeshNodeMaterial&&(e.material.defines.NORMAL_OUTPUT=0,e.material.needsUpdate=!0)}))}render(e){this._saveLayers(),this._setupLayers(),this.camera.layers.disableAll(),this.camera.layers.enable(1),this._setupNodeAlphaClipHashMaterials(),this._renderOverride(e,null,this.renderTargetNormalDepth,8355839,1,!0),this._restoreNodeAlphaClipHashMaterials(),this.camera.layers.disableAll(),this.camera.layers.enable(2),this._renderOverride(e,this.materialNormal,this.renderTargetNormalDepth,null,null,!0),this._restoreLayers(),this.materialGTAO.defines.ORTHO_CAMERA=this.camera.isOrthographicCamera?1:0,this.materialGTAO.defines.CALC_BENT_NORMALS=this.bentNormals?1:0,this.materialGTAO.needsUpdate=!0,this.materialGTAO.uniforms.tNormal.value=this.renderTargetNormalDepth.texture,this.materialGTAO.uniforms.tDepth.value=this.renderTargetNormalDepth.depthTexture,this.materialGTAO.uniforms.tNoise.value=this.noiseTexture,this.materialGTAO.uniforms.occlDistance.value=this.distance,this.materialGTAO.uniforms.factor.value=this.factor,this.materialGTAO.uniforms.occlPrecision.value=this.precision,this.materialGTAO.uniforms.bounceApprox.value=this.bounceApprox,this.materialGTAO.uniforms.mainCameraProjMat.value.copy(this.camera.projectionMatrix),this.materialGTAO.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this._renderPass(e,this.materialGTAO,this.renderTargetGTAO),this.materialBlur.uniforms.tDiffuse.value=this.renderTargetGTAO.texture,this.materialBlur.map=this.renderTargetGTAO.texture,this.materialBlur.uniforms.tNormal.value=this.renderTargetNormalDepth.texture,this.materialBlur.uniforms.direction.value.set(1,0),this.materialBlur.uniforms.resolution.value.set(this.renderTargetGTAO.width,this.renderTargetGTAO.height),this._renderPass(e,this.materialBlur,this.renderTargetBlurX),this.materialBlur.uniforms.tDiffuse.value=this.renderTargetBlurX.texture,this.materialBlur.map=this.renderTargetBlurX.texture,this.materialBlur.uniforms.direction.value.set(0,1),this.materialBlur.uniforms.resolution.value.set(this.renderTargetBlurX.width,this.renderTargetBlurX.height),this._renderPass(e,this.materialBlur,this.renderTarget)}_renderOverride(e,t,n,i,o,r){const a=e.getRenderTarget(),s=e.getClearColor(sA),l=e.getClearAlpha(),c=e.autoClear,u=this.scene.background;e.setRenderTarget(n),null!=i&&(e.setClearColor(i),e.setClearAlpha(null!=o?o:0),e.clear()),e.autoClear=!1,r&&(this.scene.background=null),t&&(this.scene.overrideMaterial=t),e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.setRenderTarget(a),e.setClearColor(s),e.setClearAlpha(l),e.autoClear=c,this.scene.background=u}_renderPass(e,t,n,i,o){const r=e.getRenderTarget(),a=e.getClearColor(sA),s=e.getClearAlpha(),l=e.autoClear;e.setRenderTarget(n),null!=i&&(e.setClearColor(i),e.setClearAlpha(null!=o?o:0),e.clear()),e.autoClear=!1,this.fsQuad.material=t,this.fsQuad.render(e),e.setRenderTarget(r),e.setClearColor(a),e.setClearAlpha(s),e.autoClear=l}createNoiseTexture(){const e=new Uint8Array([101,192,145,80,53,136,86,207,229,131,240,6,58,41,171,13,199,63,175,128,113,55,246,66,115,213,157,59,243,114,68,169,255,60,216,5,200,37,250,65,170,48,153,108,125,211,137,29,120,82,38,213,25,198,15,150,33,131,173,16,140,180,9,206,134,20,117,176,99,222,124,190,95,33,198,221,86,68,241,157,227,142,253,96,72,135,169,102,204,253,89,195,50,233,94,38,185,86,235,72,149,163,25,2,146,75,254,14,164,189,0,100,49,187,162,8,181,222,240,52,7,73,41,109,210,123,76,150,226,161,44,11,242,51,107,232,212,116,177,54,141,37,207,77,115,19,59,235,110,42,83,122,160,184,224,148,2,164,248,24,203,109,129,192,208,138,83,182,61,132,28,229,96,121,224,173,248,197,88,127,147,29,193,210,139,96,237,30,63,191,102,54,69,178,32,93,63,170,36,247,17,201,80,155,245,18,60,133,151,32,219,206,165,67,230,20,57,12,171,128,84,221,139,13,236,146,220,252,20,120,222,150,99,166,43,108,196,183,89,45,9,107,74,49,4,100,175,117,246,71,198,113,241,39,174,119,46,82,1,157,105,195,72,9,127,239,217,6,69,145,211,166,230,181,240,136,190,251,87,155,35,219,143,50,22,159,213,92,191,127,212,41,135,237,50,206,88,58,176,118,36,234,27,114,64,93,157,119,21,214,45,129,187,105,92,208,182,66,6,249,27,167,62,185,78,172,29,160,188,25,139,249,161,84,130,254,203,14,37,226,59,143,77,238,0,166,18,254,79,133,103,153,205,113,94,246,12,216,100,116,227,76,209,48,97,186,1,53,144,192,82,169,108,179,28,198,65,228,42,151,122,197,233,53,74,222,24,146,123,56,141,255,3,151,106,20,200,220,73,174,104,216,131,248,7,209,156,86,112,136,177,58,223,11,36,140,241,8,195,178,232,85,200,43,65,180,240,133,61,149,120,231,22,46,71,30,92,230,121,52,242,215,97,26,110,186,89,172,158,102,50,70,34,156,15,189,126,91,34,168,10,245,39,91,163,243,152,202,140,42,188,17,163,8,203,77,156,237,63,118,32,130,251,165,112,208,98,235,161,213,228,81,110,194,178,14,125,185,111,61,173,103,253,71,144,39,125,250,45,207,15,217,177,202,88,1,226,132,75,26,56,12,119,203,46,137,66,209,77,220,3,238,19,80,129,218,179,90,193,168,132,98,146,81,19,235,142,59,183,44,250,174,104,144,69,155,251,97,230,145,33,99,49,159,212,196,31,56,110,225,22,62,2,183,245,55,123,40,106,215,17,150,116,218,194,238,31,186,0,23,55,162,241,194,135,87,118,147,236,4,158,244,75,117,228,35,109,194,67,155,78,168,199,91,64,8,135,47,88,169,212,129,181,111,11,65,170,227,40,68,176,95,201,46,142,209,154,90,165,218,255,188,232,27,121,244,35,163,79,206,124,242,103,72,223,83,204,123,25,247,10,191,111,136,26,85,187,18,236,51,134,7,144,13,99,48,138,227,190,101,223,24,153,60,41,149,30,255,45,152,184,103,78,162,51,252,217,128,171,104,70,197,30,84,114,57,176,205,70,4,148,54,253,181,113,6,231,191,134,172,95,220,56,211,141,233,205,16,66,40,224,5,122,243,179,211,226,127,247,158,85,111,174,126,15,73,202,167,87,215,17,116,3,71,130,19,35,90,124,154,182,98,248,148,57,156,96,43,73,196,34,16,218,237,42,208,94,143,38,247,122,67,52,201,234,164,249,177,199,61,1,108,76,167,31,204,80,231,22,170,0,147,93,120,183,64,28,161,239,57,185,105,28,159,139,184,106,40,81,114,145,242,219,190,239,53,138,112,11,187,133,107,204,239,168,54,141,102,193,81,221,134,9,216,78,229,244,90,23,153,225,10,95,160,43,132,23,214,195,89,47,215,252,62,38,82,228,21,214,251,2,151,109,21,175,197,149,44,5,173,64,210,52,196,69,29,172,83,118,13,154,236,175,119,26,159,137,112,189,44,131,75,171,121,49,232,92,126,62,101,205,130,117,250,138,180,125,207,254,58,225,97,67,37,142,74,98,182,210,7,68,152,202,94,34,243,200,70,39,252,166,16,224,188,32,84,21,100,231,12,106,148,199,178,249,164,5,229,55,245,87,165,234,105,14,225,60,184,140,158,214,27,115,143,74,51,162,147,238,47,76,167,36,137,3,48,126,104,201,189,128,18,47,124,31,244,180,160,115,23,10,101,79,179,193,233,93,246,107,217,4,192,154,221,91,186,234,79,24,219,85,33,152,223]),t=new Uint8Array([7,87,145,233,57,15,124,219,7,163,132,35,222,160,41,99,10,23,228,253,53,207,65,214,94,146,248,134,214,15,97,230,201,181,41,105,189,206,171,100,146,78,188,106,177,87,141,232,198,122,70,178,149,26,124,174,16,55,115,35,70,179,158,111,74,241,122,159,29,90,47,242,23,229,213,16,245,72,26,183,58,136,205,43,86,239,139,226,77,188,203,86,224,144,50,30,135,62,11,218,255,68,156,185,59,121,91,49,199,152,219,109,243,162,14,221,113,192,3,100,42,152,233,168,22,123,251,210,153,191,99,173,139,114,2,133,201,32,169,135,64,118,1,47,89,31,102,76,154,35,63,164,255,127,9,62,106,187,4,91,44,222,17,80,39,209,237,82,107,251,148,11,231,174,208,130,194,171,234,184,248,121,216,199,110,28,212,137,240,77,164,232,25,128,247,150,57,193,20,160,44,211,75,191,96,37,81,254,147,66,8,140,54,21,177,89,74,51,175,93,39,199,55,115,84,202,104,179,230,124,97,222,64,177,27,111,239,158,17,57,105,219,42,209,95,132,231,13,144,244,194,157,226,18,143,180,66,166,48,5,74,32,169,142,7,241,128,52,216,137,185,228,26,124,84,166,189,71,38,158,221,115,1,65,123,102,250,216,34,242,140,113,212,188,249,85,118,197,156,89,5,70,116,167,202,153,240,114,4,246,203,100,46,185,84,31,209,173,6,130,196,22,225,91,155,61,16,49,103,229,36,206,173,249,46,92,12,73,33,223,142,60,172,126,22,234,135,246,151,75,52,97,161,79,182,12,235,132,207,150,184,20,78,143,101,28,196,235,134,178,53,195,24,108,82,215,150,55,168,110,43,189,233,144,207,59,125,44,168,108,34,220,69,166,244,58,225,125,149,63,213,104,253,93,155,184,11,250,73,96,201,8,218,88,14,117,223,105,247,193,71,88,254,122,3,132,191,113,10,181,40,83,0,162,127,41,210,235,122,36,195,18,228,65,131,176,253,38,19,165,0,146,27,203,178,54,96,234,43,159,90,218,245,112,191,229,18,79,66,137,51,160,180,141,118,164,30,101,154,71,137,94,217,56,238,134,17,153,200,80,29,204,67,23,155,52,172,33,145,198,175,7,223,103,87,244,41,79,236,204,51,186,81,199,176,112,77,224,40,110,170,223,144,251,174,131,98,205,73,121,247,97,238,116,29,204,62,2,213,183,145,24,125,241,228,45,31,129,160,92,188,246,62,6,102,50,116,15,240,140,10,218,59,45,151,83,167,255,130,157,107,55,92,219,110,5,61,147,252,8,212,51,12,140,75,126,183,215,83,194,43,226,88,165,109,187,21,215,68,39,192,20,239,198,12,68,174,159,99,121,192,70,231,177,119,209,237,19,154,33,232,163,65,180,29,200,129,4,231,135,182,98,147,76,118,165,136,248,40,211,14,85,169,107,25,151,100,36,164,197,92,58,136,2,123,106,148,252,75,210,162,53,120,9,233,217,46,28,226,83,128,195,245,224,38,141,205,61,249,86,48,227,114,255,186,207,77,236,16,56,39,102,85,30,247,203,60,87,179,103,186,56,152,22,180,131,53,236,81,15,190,134,175,8,72,147,24,99,48,215,192,172,139,240,196,149,108,168,17,127,157,252,1,206,114,74,161,98,3,186,156,120,221,27,108,211,129,40,170,242,158,131,91,115,225,20,178,71,45,222,142,197,36,66,145,93,234,34,198,67,217,109,243,45,67,161,237,54,195,224,85,112,6,32,69,155,9,64,123,212,3,94,242,76,113,214,25,170,49,220,119,148,28,170,90,10,200,143,80,95,153,18,64,202,175,220,250,42,208,96,163,254,133,185,21,52,230,190,126,244,138,13,86,254,58,138,211,125,179,251,34,2,183,248,126,143,54,187,78,136,235,193,50,32,82,117,173,161,98,9,82,63,105,187,19,205,37,230,76,21,104,60,167,119,214,106,37,227,13,101,120,167,25,109,146,227,201,60,238,38,148,206,181,42,163,236,176,128,107,154,184,50,225,208,133,232,49,73,165,90,239,152,204,0,89,182,72,11,156,101,217,14,130,252,111,227,5,72,95,47,196,0,245,94,149,13,84,27,150,193,19,181,68,30,48,243,61,221,127,246,24,138,190,69,88,57,26,141,210,151,220,249,67,117,166,35,194,112,176,202,95,237,139,208,111,129,216,190,142,37,171,197,81,47,119,229,159,200,171,79,120,33,133,169,23,213,80,138,238,69,44,253,63,117,4,56,250,172,78,157,93,116,6,104,162,241,31,182,1,103,46,243,189,59]),n=new Uint8Array(4096);for(let i=0;i<1024;i++)n[4*i]=e[i],n[4*i+1]=t[i],n[4*i+2]=0,n[4*i+3]=0;const i=new ks(n,32,32,R,C);return i.name="GTAONoiseTexture",i.wrapS=m,i.wrapT=m,i.needsUpdate=!0,i}}class cA{constructor(e=4){this.pool=e,this.queue=[],this.workers=[],this.workersResolve=[],this.workerStatus=0}_initWorker(e){if(!this.workers[e]){const t=this.workerCreator();t.addEventListener("message",this._onMessage.bind(this,e)),this.workers[e]=t}}_getIdleWorker(){for(let e=0;e{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const uA=new WeakMap;let dA=0;class hA extends Hu{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new cA,this.workerSourceURL="",this.workerConfig=null,"undefined"!=typeof MSC_TRANSCODER&&console.warn('v3d.KTX2Loader: Please update to latest "basis_transcoder". "msc_basis_transcoder" is no longer supported in three.js r125+.')}setTranscoderPath(e){return this.transcoderPath=e,this}setWorkerLimit(e){return this.workerPool.setWorkerLimit(e),this}detectSupport(e){return this.workerConfig={astcSupported:e.extensions.has("WEBGL_compressed_texture_astc"),etc1Supported:e.extensions.has("WEBGL_compressed_texture_etc1"),etc2Supported:e.extensions.has("WEBGL_compressed_texture_etc"),dxtSupported:e.extensions.has("WEBGL_compressed_texture_s3tc")&&e.extensions.has("WEBGL_compressed_texture_s3tc_srgb"),bptcSupported:e.extensions.has("EXT_texture_compression_bptc"),pvrtcSupported:e.extensions.has("WEBGL_compressed_texture_pvrtc")||e.extensions.has("WEBKIT_WEBGL_compressed_texture_pvrtc")},e.capabilities.isWebGL2&&(this.workerConfig.etc1Supported=!1),this}dispose(){return this.workerPool.dispose(),this.workerSourceURL&&URL.revokeObjectURL(this.workerSourceURL),this}init(){if(!this.transcoderPending){const e=new Yu(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new Yu(this.manager);n.setPath(this.transcoderPath),n.setResponseType("arraybuffer"),n.setWithCredentials(this.withCredentials);const i=n.loadAsync("basis_transcoder.wasm");this.transcoderPending=Promise.all([t,i]).then((([e,t])=>{const n=hA.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(hA.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(hA.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(hA.BasisFormat),"/* basis_transcoder.js */",e,"/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i])),this.transcoderBinary=t,this.workerPool.setWorkerCreator((()=>{const e=new Worker(this.workerSourceURL),t=this.transcoderBinary.slice(0);return e.postMessage({type:"init",config:this.workerConfig,transcoderBinary:t},[t]),e}))})),dA>0&&console.warn("v3d.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),dA++}return this.transcoderPending}load(e,t,n,i){if(null===this.workerConfig)throw new Error("v3d.KTX2Loader: Missing initialization with `.detectSupport(renderer)`.");const o=new Yu(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const r=new Al;return o.load(e,(e=>{if(uA.has(e)){return uA.get(e).promise.then(t).catch(i)}this._createTexture([e]).then((function(e){r.copy(e),r.needsUpdate=!0,t&&t(r)})).catch(i)}),n,i),r}_createTextureFrom(e){const{mipmaps:t,width:n,height:i,format:o,type:r,error:a,dfdTransferFn:s,dfdFlags:l}=e;if("error"===r)return Promise.reject(a);const c=new Al(t,n,i,o,C);return c.minFilter=1===t.length?y:M,c.magFilter=y,c.generateMipmaps=!1,c.needsUpdate=!0,c.encoding=2===s?Ae:ve,c.premultiplyAlpha=!!(1&l),c}_createTexture(e,t={}){const n=t,i=this.init().then((()=>this.workerPool.postMessage({type:"transcode",buffers:e,taskConfig:n},e))).then((e=>this._createTextureFrom(e.data)));return uA.set(e[0],{promise:i}),i}dispose(){return URL.revokeObjectURL(this.workerSourceURL),this.workerPool.dispose(),dA--,this}}hA.BasisFormat={ETC1S:0,UASTC_4x4:1},hA.TranscoderFormat={ETC1:0,ETC2:1,BC1:2,BC3:3,BC4:4,BC5:5,BC7_M6_OPAQUE_ONLY:6,BC7_M5:7,PVRTC1_4_RGB:8,PVRTC1_4_RGBA:9,ASTC_4x4:10,ATC_RGB:11,ATC_RGBA_INTERPOLATED_ALPHA:12,RGBA32:13,RGB565:14,BGR565:15,RGBA4444:16},hA.EngineFormat={RGBAFormat:R,RGBA_ASTC_4x4_Format:H,RGBA_BPTC_Format:re,RGBA_ETC2_EAC_Format:W,RGBA_PVRTC_4BPPV1_Format:V,RGBA_S3TC_DXT5_Format:F,RGB_ETC1_Format:k,RGB_ETC2_Format:Q,RGB_PVRTC_4BPPV1_Format:U,RGB_S3TC_DXT1_Format:D},hA.BasisWorker=function(){let e,t,n;const i=_EngineFormat,o=_TranscoderFormat,r=_BasisFormat;self.addEventListener("message",(function(a){const u=a.data;switch(u.type){case"init":e=u.config,d=u.transcoderBinary,t=new Promise((e=>{n={wasmBinary:d,onRuntimeInitialized:e},BASIS(n)})).then((()=>{n.initializeBasis(),void 0===n.KTX2File&&console.warn("v3d.KTX2Loader: Please update Basis Universal transcoder.")}));break;case"transcode":t.then((()=>{try{const{width:t,height:a,hasAlpha:d,mipmaps:h,format:p,dfdTransferFn:f,dfdFlags:m}=function(t){const a=new n.KTX2File(new Uint8Array(t));function u(){a.close(),a.delete()}if(!a.isValid())throw u(),new Error("v3d.KTX2Loader: Invalid or unsupported .ktx2 file");const d=a.isUASTC()?r.UASTC_4x4:r.ETC1S,h=a.getWidth(),p=a.getHeight(),f=a.getLevels(),m=a.getHasAlpha(),g=a.getDFDTransferFunc(),v=a.getDFDFlags(),{transcoderFormat:A,engineFormat:_}=function(t,n,a,u){let d,h;const p=t===r.ETC1S?s:l;for(let i=0;i=i&&(this._timer&&(window.clearTimeout(this._timer),this._timer=null),this._counter=0,this._callback()))}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1)}function gA(e){this.data=void 0!==e?e:null,this.useHDR=!1}Object.assign(mA.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._timer&&window.clearTimeout(this._timer)}}),Object.assign(gA.prototype,{isSceneBackground:!0,clone:function(){return(new this.constructor).copy(this)},copy:function(e){null===e.data?this.data=null:e.data.isColor?this.data=e.data.clone():e.data.isCubeTexture||e.data.isTexture?(this.data=e.data.clone(),this.data.needsUpdate=!0):e.data.isWebGLCubeRenderTarget?(this.data=e.data.clone(),this.data.texture.needsUpdate=!0):this.data=e.data,this.useHDR=e.useHDR},toJSON:function(e){const t={metadata:{version:4.5,type:"SceneBackground",generator:"SceneBackground.toJSON"}};return null!==this.data&&(t.data=this.data.toJSON(e)),t}});const vA={createMultiMaterialObject:function(e,t){const n=new $a;for(let i=0,o=t.length;i=r+1e3&&(s.update(1e3*a/(e-r),100),r=e,a=0,c)){var t=performance.memory;c.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){o=this.end()},domElement:t,setMode:i}};AA.Panel=function(e,t,n){var i=1/0,o=0,r=Math.round,a=r(window.devicePixelRatio||1),s=80*a,l=48*a,c=3*a,u=2*a,d=3*a,h=15*a,p=74*a,f=30*a,m=document.createElement("canvas");m.width=s,m.height=l,m.style.cssText="width:80px;height:48px";var g=m.getContext("2d");return g.font="bold "+9*a+"px Helvetica,Arial,sans-serif",g.textBaseline="top",g.fillStyle=n,g.fillRect(0,0,s,l),g.fillStyle=t,g.fillText(e,c,u),g.fillRect(d,h,p,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d,h,p,f),{dom:m,update:function(l,v){i=Math.min(i,l),o=Math.max(o,l),g.fillStyle=n,g.globalAlpha=1,g.fillRect(0,0,s,h),g.fillStyle=t,g.fillText(r(l)+" "+e+" ("+r(i)+"-"+r(o)+")",c,u),g.drawImage(m,d+a,h,p-a,f,d,h,p-a,f),g.fillRect(d+p-a,h,a,f),g.fillStyle=n,g.globalAlpha=.9,g.fillRect(d+p-a,h,a,r((1-l/v)*f))}}};class _A{constructor(e,t,n,i,o,r=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new Bt,this.vertexNormals=Array.isArray(i)?i:[],this.color=o&&o.isColor?o:new yt,this.vertexColors=Array.isArray(o)?o:[],this.materialIndex=r}clone(){return(new this.constructor).copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;tn.far?null:{distance:l,point:TA.clone(),object:e}}(e,e.material,t,n,yA,bA,MA,EA);if(l){o&&(CA.fromBufferAttribute(o,r),SA.fromBufferAttribute(o,a),wA.fromBufferAttribute(o,s),l.uv=jn.getUV(EA,yA,bA,MA,CA,SA,wA,new et));var c=new Bt;l.face=new _A(r,a,s,jn.getNormal(yA,bA,MA,c)),l.faceIndex=r}return l}function RA(e,t,n,i,o,r){var a=3*o,s=t.index.getX(a),l=t.index.getX(a+1),c=t.index.getX(a+2),u=IA(e,n,i,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=o,r&&r.push(u),u):null}function LA(e,t){return t.min.x=e[0],t.min.y=e[1],t.min.z=e[2],t.max.x=e[3],t.max.y=e[4],t.max.z=e[5],t}function BA(e){for(var t=-1,n=-1/0,i=0;i<3;i++){var o=e[i+3]-e[i];o>n&&(n=o,t=i)}return t}class PA{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){for(var n=1/0,i=-1/0,o=0,r=e.length;oe.max||e.min>this.max}}PA.prototype.setFromBox=(xA=new Bt,function(e,t){for(var n=t.min,i=t.max,o=1/0,r=-1/0,a=0;a<=1;a++)for(var s=0;s<=1;s++)for(var l=0;l<=1;l++){xA.x=n.x*a+i.x*(1-a),xA.y=n.y*s+i.y*(1-s),xA.z=n.z*l+i.z*(1-l);var c=e.dot(xA);o=Math.min(c,o),r=Math.max(c,r)}this.min=o,this.max=r});var DA,NA,OA,FA,UA,zA,VA,GA,kA,QA,WA,HA,jA,YA,XA,KA,qA,ZA,JA,$A,e_,t_,n_,i_,o_=(DA=new Bt,NA=new Bt,OA=new Bt,function(e,t,n){var i=e.start,o=DA,r=t.start,a=NA;OA.subVectors(i,r),DA.subVectors(e.end,t.start),NA.subVectors(t.end,t.start);var s,l,c=OA.dot(a),u=a.dot(o),d=a.dot(a),h=OA.dot(o),p=o.dot(o)*d-u*u;l=(c+(s=0!==p?(c*u-h*d)/p:0)*u)/d,n.x=s,n.y=l}),r_=(FA=new et,UA=new Bt,zA=new Bt,function(e,t,n,i){o_(e,t,FA);var o,r,a=FA.x,s=FA.y;if(a>=0&&a<=1&&s>=0&&s<=1)return e.at(a,n),void t.at(s,i);if(a>=0&&a<=1)return s<0?t.at(0,i):t.at(1,i),void e.closestPointToPoint(i,!0,n);if(s>=0&&s<=1)return a<0?e.at(0,n):e.at(1,n),void t.closestPointToPoint(n,!0,i);o=a<0?e.start:e.end,r=s<0?t.start:t.end;var l=UA,c=zA;return e.closestPointToPoint(r,!0,UA),t.closestPointToPoint(o,!0,zA),l.distanceToSquared(r)<=c.distanceToSquared(o)?(n.copy(l),void i.copy(r)):(n.copy(o),void i.copy(c))}),a_=(VA=new Bt,GA=new Bt,kA=new qi,QA=new dh,function(e,t){var n=e.radius,i=e.center,o=t.a,r=t.b,a=t.c;if(QA.start=o,QA.end=r,QA.closestPointToPoint(i,!0,VA).distanceTo(i)<=n)return!0;if(QA.start=o,QA.end=a,QA.closestPointToPoint(i,!0,VA).distanceTo(i)<=n)return!0;if(QA.start=r,QA.end=a,QA.closestPointToPoint(i,!0,VA).distanceTo(i)<=n)return!0;var s=t.getPlane(kA);if(Math.abs(s.distanceToPoint(i))<=n){var l=s.projectPoint(i,GA);if(t.containsPoint(l))return!0}return!1});class s_ extends jn{constructor(...e){super(...e),this.isSeparatingAxisTriangle=!0,this.satAxes=new Array(4).fill().map((function(){return new Bt})),this.satBounds=new Array(4).fill().map((function(){return new PA})),this.points=[this.a,this.b,this.c],this.sphere=new en}}s_.prototype.update=(WA=new Array(3),function(){var e=this.a,t=this.b,n=this.c;WA[0]=this.a,WA[1]=this.b,WA[2]=this.c;var i=this.satAxes,o=this.satBounds,r=i[0],a=o[0];this.getNormal(r),a.setFromPoints(r,WA);var s=i[1],l=o[1];s.subVectors(e,t),l.setFromPoints(s,WA);var c=i[2],u=o[2];c.subVectors(t,n),u.setFromPoints(c,WA);var d=i[3],h=o[3];d.subVectors(n,e),h.setFromPoints(d,WA),this.sphere.setFromPoints(this.points)}),s_.prototype.intersectsTriangle=(HA=new s_,jA=new Array(3),YA=new Array(3),XA=new PA,KA=new PA,qA=new Bt,function(e){e.isSeparatingAxisTriangle||(HA.copy(e),HA.update(),e=HA);var t=this.satBounds,n=this.satAxes;YA[0]=e.a,YA[1]=e.b,YA[2]=e.c;for(var i=0;i<4;i++){var o=t[i],r=n[i];if(XA.setFromPoints(r,YA),o.isSeparated(XA))return!1}var a=e.satBounds,s=e.satAxes;jA[0]=this.a,jA[1]=this.b,jA[2]=this.c;for(var l=0;l<4;l++){var c=a[l],u=s[l];if(XA.setFromPoints(u,jA),c.isSeparated(XA))return!1}for(var d=0;d<4;d++)for(var h=n[d],p=0;p<4;p++){var f=s[p];if(qA.crossVectors(h,f),XA.setFromPoints(qA,jA),KA.setFromPoints(qA,YA),XA.isSeparated(KA))return!1}return!0}),s_.prototype.distanceToPoint=(ZA=new Bt,function(e){return this.closestPointToPoint(e,ZA),e.distanceTo(ZA)}),s_.prototype.distanceToTriangle=(JA=new Bt,$A=new Bt,e_=["a","b","c"],t_=new dh,n_=new dh,function(e,t=null,n=null){if(this.intersectsTriangle(e))return(t||n)&&(this.getMidpoint(JA),e.closestPointToPoint(JA,$A),this.closestPointToPoint($A,JA),t&&t.copy(JA),n&&n.copy($A)),0;for(var i=1/0,o=0;o<3;o++){var r=void 0,a=e_[o],s=e[a];this.closestPointToPoint(s,JA),(r=s.distanceToSquared(JA))=0?(i=this.left,o=this.right):(i=this.right,o=this.left);var s=i.intersectRay(n,m_)?i.raycastFirst(e,t,n):null;if(s){var l=n.origin[a],c=l-s.point[a],u=l-o.boundingData[r],d=l-o.boundingData[r+3],h=c*c;if(h<=u*u&&h<=d*d)return s}var p=o.intersectRay(n,m_)?o.raycastFirst(e,t,n):null;return s&&p?s.distance<=p.distance?s:p:s||p||null}}A_.prototype.shapecast=(c_=new s_,u_=new Nt,d_=new Nt,function(e,t,n=null,i=null){if(this.count&&n){for(var o=e.geometry,r=o.index,a=o.attributes.position,s=this.offset,l=3*s,c=3*(this.count+s);lm)){e.update();var u=t.distanceToTriangle(e,d,h);if(u=r;)o--;if(!(i65535?Uint32Array:Uint16Array)(t);e.setIndex(new Jn(n,1));for(var i=0;i=t.maxDepth&&(i=!0),a<=t.maxLeafTris||s>=t.maxDepth)return e.offset=r,e.count=a,e;var l=n.getOptimalSplit(e.boundingData,r,a,t.strategy);if(-1===l.axis)return e.offset=r,e.count=a,e;var c=n.partition(r,a,l);if(c===r||c===r+a)e.offset=r,e.count=a;else{e.splitAxis=l.axis;var u=e.left=new A_,d=r,h=c-r;u.boundingData=n.getBounds(d,h,new Float32Array(6)),o(u,d,h,s+1);var p=e.right=new A_,f=c,m=a-h;p.boundingData=n.getBounds(f,m,new Float32Array(6)),o(p,f,m,s+1)}return e},r=[],a=this._getRootIndexRanges(e);if(1===a.length){var s=new A_,l=a[0];null!=e.boundingBox?s.boundingData=function(e){var t=new Float32Array(6);return t[0]=e.min.x,t[1]=e.min.y,t[2]=e.min.z,t[3]=e.max.x,t[4]=e.max.y,t[5]=e.max.z,t}(e.boundingBox):s.boundingData=n.getBounds(l.offset,l.count,new Float32Array(6)),o(s,l.offset,l.count),r.push(s)}else for(var c=0;ct;)this.remove(this.children.pop())}}}var E_=new cn,T_=new un,I_=Di.prototype.raycast;function R_(e,t){if(this.geometry.boundsTree){if(this.isAuxClippingMesh)return;if(void 0===this.material)return;try{T_.copy(this.matrixWorld).invert()}catch(e){return}if(E_.copy(e.ray).applyMatrix4(T_),!0===e.firstHitOnly){var n=this.geometry.boundsTree.raycastFirst(this,e,E_);n&&t.push(n)}else this.geometry.boundsTree.raycast(this,e,E_,t)}else I_.call(this,e,t)}function L_(e){return this.boundsTree=new b_(this,e),this.boundsTree}function B_(){this.boundsTree=null}const P_=["toneMapping","toneMappingMidTones","toneMappingPhysicalScale","toneMappingBrightness","toneMappingContrast","toneMappingChromaticAdaptation","toneMappingWhiteColor","toneMappingColorDifferentiation","toneMappingExteriorDaylight","toneMappingWhiteBalance","toneMappingHighlights","toneMappingShadows","toneMappingSaturation","toneMappingAperture","toneMappingShutter","toneMappingISO","toneMappingVignetting"],D_=.6,N_=.4;function O_(e,t,n){return 2*Oe*Math.atan(Math.tan(Ne*e/2)*t/n)}class F_ extends Be{constructor(e,t,n){if(super(),this.container=e instanceof HTMLElement?e:document.getElementById(e),this.scene=null,this.camera=null,this.clock=new Bd,this.mixer=null,this.renderCallbacks=[],this.compileCallbacks=[],this.elapsed=0,this.frame=0,this.preloader=n,this.worldCubemapRes=1024,this._pmremMaxTileSize=256,this._lightProbeCubemapRes=64,this.xrSession=null,this.xrControllers=[],!ls.checkWebGL())return void ls.showWebGLErrorMessage(this.container);void 0===(t=t||{}).alpha&&(t.alpha=!1),void 0===t.depth&&(t.depth=!0),void 0===t.stencil&&(t.stencil=!0),void 0===t.antialias&&(t.antialias=!0),void 0===t.premultipliedAlpha&&(t.premultipliedAlpha=!0),void 0===t.preserveDrawingBuffer&&(t.preserveDrawingBuffer=!1),ls.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy context AA on Safari 15.4"),t.antialias=!1),this.renderer=new cs(t),pp.prepareRenderer(this.renderer),this.clearBkgOnLoad=!1,this.frameRateDivider=1,this.enableRender=!0,this.disableRenderTrigger=0,this.ssaaOnPause=!1,this.renderer.setSize(this.container.offsetWidth,this.container.offsetHeight),this.renderer.outputEncoding=Ae,this.container.appendChild(this.renderer.domElement),this.container.classList.add("v3d-container"),this.renderer.domElement.classList.add("v3d-canvas"),this.container.setAttribute("translate","no"),this.loader=new Wg;const i=(new hA).setTranscoderPath(ht()).detectSupport(this.renderer);this.loader.setKTX2Loader(i),gi.prototype.computeBoundsTree=L_,gi.prototype.disposeBoundsTree=B_,Di.prototype.raycast=R_,this.actions=[],this.materials={push:function(){}},this.updateMaterials=function(){},this._envIBLMode=0,this._envLightProbe=null,this._resizeCb=null,this._loadSceneURL="",this._loadingTime=0,this._backgroundSave=null,this._postprocessingSave=null,this.stats=null,hp.drawWatermark(this),hp.addToAppList(this),this.worldMaterial=null}_updateRendererFromGLTF(e){var t;const n=this,i=ls.checkHalfFloatTex(this.renderer,!0);if(e.renderer.shadowMap?(this.renderer.shadowMap.enabled=e.renderer.shadowMap.enabled,this.renderer.shadowMap.type=e.renderer.shadowMap.type,i||4!==this.renderer.shadowMap.type||(this.renderer.shadowMap.type=2,e.scene.traverse((function(e){e.isLight&&e.castShadow&&e.shadow&&(e.shadow.bias/=100,e.shadow.isDirectionalLightShadowCSM&&(e.shadow.radius*=100/e.shadow.mapSize.x/2,e.shadow=(new sd).copy(e.shadow),e.shadow.camera.updateProjectionMatrix()))})))):(this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=2),e.renderer.physicallyCorrectLights&&(this.renderer.physicallyCorrectLights=!0),this.aaMethod=e.renderer.aaMethod||"AUTO",this.useHDR=Boolean(e.renderer.useHDR&&i),this.renderer.unitsScaleFactor=null!=(t=e.renderer.unitsScaleFactor)?t:1,e.renderer.toneMapping)for(let t=0;t{e.isMesh&&t.layers.set(7)})),n.useHiDPIRenderPass=!0,n.renderer.setPixelRatio(window.devicePixelRatio))})),n.useHiDPIRenderPass&&e.scene.traverse((function(e){e.isLight&&e.layers.enable(7)}))}_updateMeshesRaycastFromGLTF(e){e.scene&&e.scene.traverse((function(e){const t=e.geometry;e.isMesh&&(!t.computeBoundsTree||0!==Object.keys(t.morphAttributes).length||t.attributes.position.isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute||t.computeBoundsTree({verbose:!1}))}))}_prepareReflProbesFromGLTF(e){e.scene&&e.scene.traverse((e=>{if(e.isCubeReflectionProbe)this._prepareEnvMapProbe(e);else if(e.isPlaneReflectionProbe){let t=this._checkMSAA(this.renderer,4);t>0&&e.makeMultisampleRenderTarget(t)}}))}_prepareEnvMapProbe(e){switch(e.setSize(this._pmremMaxTileSize),this._envIBLMode){case 0:e.onUpdate=e=>this.generateRTargetPMREM(e);break;case 1:break;case 2:e.onUpdate=()=>null}}_prepareReflProbesEncoding(e,t){e.traverse((e=>{(e.isCubeReflectionProbe||e.isPlaneReflectionProbe)&&e.setEncoding(t)}))}_prepareEnvMapProbeWorld(){const e=new mo;e.worldMaterial=this.scene.worldMaterial,null===this.scene.worldEnvMapProbe&&(this.scene.worldEnvMapProbe=new Mp(this._pmremMaxTileSize),this.scene.worldEnvMapProbe.influenceType=0,this.scene.worldEnvMapProbe.parallaxType=0);const t=this.scene.worldEnvMapProbe;switch(this._envIBLMode){case 0:t.onUpdate=e=>this.generateRTargetPMREM(e);break;case 1:case 2:t.onUpdate=e=>{const t=e.clone();t.setSize(this._lightProbeCubemapRes,this._lightProbeCubemapRes),ls.checkHalfFloatReadPixels(this.renderer)?t.texture.type=T:ls.checkFloatReadPixels(this.renderer)?t.texture.type=E:(console.warn("v3d.App: Target platform does not support reading pixels in float format, expect quality loss."),t.texture.type=C),t.texture.format=R,t.texture.encoding=ve;const n=new fp(e.texture);return n.render(this.renderer,t),n.dispose(),this._disposeEnvLightProbe(),this._envLightProbe=pA.fromCubeRenderTarget(this.renderer,t),this.scene.add(this._envLightProbe),t.dispose(),1===this._envIBLMode?e:null}}t.update(e,this.renderer),this.renderer.compatSettings.useSpecEnvBlenderApprox=0===this._envIBLMode}_updateMaterialsFromGLTF(e){const t=this;e.scene&&e.scene.traverse((function(e){const n=e.material;n&&t.useHDR&&(n.useHDR=!0,n.useFloatTex=ls.checkFloatTex(t.renderer,!0),n.isMeshNodeMaterial&&n.updateNodeGraph())}))}_updateAnimationsFromGLTF(e,t){const n=this;!n.mixer&&e.animations&&e.animations.length&&(n.mixer=new ih(n.scene)),(e.animations||[]).forEach((function(e){const i=t.getObjectById(e.nodeId);if(i){let o;o=i.id==t.id||""!==i.name&&"root"!==i.name&&"."!==i.name&&i.name!==t.name&&i.name!==t.uuid?n.mixer.clipAction(e.clip,t):n.mixer.clipAction(e.clip,i),o.setLoop(e.loop,e.repetitions),o.startAt(e.startAt+n.mixer.time),o.clampWhenFinished=!0,e.auto?o.play():(o.stop(),o.paused=!0),n.actions.push(o)}}))}_traverseSceneForTexUniforms(e,t){e.traverse((function(e){if(e.material){(Array.isArray(e.material)?e.material:[e.material]).forEach((function(n){void 0!==n.program&&t(e,n,n.program.getTexUniformCount())}))}}))}_checkMSAA(e,t){return Math.min(t,e.capabilities.maxSamples)}_precompileSceneAsync(e,t,n,i){const o=this,r=o.compileCallbacks;for(let e=0;e=1&&o.renderer.setRenderTarget(a),i&&i(100*e)}))}_handleAlphaToCoverage(e){this.scene.traverse((function(t){const n=t.material;n&&n.alphaToCoverage&&(e>0?(n.transparent=!1,n.premultipliedAlpha=!1,n.blending=0):n.alphaToCoverage=!1)}))}assignClippingPlanes(e){const t=this;let n=[],i=[],o=[],r=-1e3;e.traverse((function(t){t.isClippingPlaneObject&&(n.push(t),i.push(t.plane),e.traverse((function(e){t.needsClippingPlane(e)&&t.assignToObject(e,r++)})),o.push(r++))}));for(let e=0;e8&&console.warn(`v3d.App: Material "${t.name}" on object "${e.name}" exceeds iOS limit of 8 textures (has ${n}).`)})),o.removeEventListener("firstFrameRendered",a)},s=o.postprocessing?o.postprocessing.composer.renderTarget1:null;o._precompileSceneAsync(o.scene,o.camera,s,(function(i){const r=(60+N_*i)/1;n&&n(r),o.preloader&&o.preloader.onUpdate(r),r>=100&&(o._updateMeshesRaycastFromGLTF(e),o.addEventListener("firstFrameRendered",a),t&&setTimeout((function(){o.scene.visible=!0,o.scene.disableChildRendering=!1,o.updateReflectionProbes(o.scene),o._loadingTime=performance.now()-o._loadingTime,o.dispatchEvent({type:"loadSceneEnd"}),t(o.scene)}),16))})),o.clearBkgOnLoad&&(o.scene.background=null),o._tripleP=new mA(window,Tp.P,(function(){hp.printPerformanceInfo(o,1)}),3,1),o._tripleF=new mA(window,Tp.F,(function(){o.stats?o.hideFPS():o.showFPS()}),3,1),o._tripleH=new mA(window,Tp.H,(function(){o.enableRender?o.disableRendering():o.enableRendering()}),3,1)}),(function(e){const t=D_*e/1;n&&n(t),o.preloader&&o.preloader.onUpdate(t)}),(function(e){console.error(e),i&&i(e)})),window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=function(){o.onResize&&o.onResize()},window.addEventListener("resize",this._resizeCb,!1)):i&&i("WebGL not found")}appendScene(e,t,n,i,o,r){const a=this;a.renderer?(void 0===o&&(o=!0),void 0===r&&(r=!0),a.preloader&&a.preloader.onUpdate(0),this.loader.load(e,(function(e){const i=e.scene||new mo,s=[];i.traverse((function(e){(e.isCamera&&!o||e.isLight&&!r)&&s.push(e)})),s.forEach((function(e){a.unload(e)})),a.scene&&(a.scene.add(i),a._prepareReflProbesFromGLTF(e),a._updateMaterialsFromGLTF(e),a._updateAnimationsFromGLTF(e,i),a.scene.updateMatrixWorld());const l=a.postprocessing?a.postprocessing.composer.renderTarget1:null,c=a.scene||i;a.assignClippingPlanes(c),a.updateConstraints(c),i.visible=!1,i.disableChildRendering=!0,a._precompileSceneAsync(c,a.camera||new Gi,l,(function(o){const r=(60+N_*o)/1;n&&n(r),a.preloader&&a.preloader.onUpdate(r),r>=100&&(a._updateMeshesRaycastFromGLTF(e),a._traverseSceneForTexUniforms(i,(function(e,t,n){n>8&&console.warn(`v3d.App: Material "${t.name}" on object "${e.name}" exceeds iOS limit of 8 textures (has ${n}).`)})),t&&setTimeout((function(){i.visible=!0,i.disableChildRendering=!1,a.updateReflectionProbes(a.scene),t(i)}),16))}))}),(function(e){const t=D_*e/1;n&&n(t),a.preloader&&a.preloader.onUpdate(t)}),(function(e){console.error(e),i&&i(e)}))):i&&i("WebGL not found")}unload(e){const t=this;function n(e){if(e.isAnnotation)e.dispose();else if(e.isLight&&e.shadow&&e.shadow.isLightShadow)e.shadow.dispose();else if(e.isCamera&&e.controls&&e.controls.orbitTarget)n(e.controls.orbitTarget);else if(e.isScene){const t=e.worldMaterial;null!==t&&(gp.disposeTextures(t),t.dispose()),null!==e.worldEnvMapProbe&&(e.worldEnvMapProbe.dispose(),e.worldEnvMapProbe=null)}else if(e.isMesh){e.geometry.dispose(),e.geometry.disposeBoundsTree&&e.geometry.disposeBoundsTree();const t=e.material;gp.disposeTextures(t),t.dispose()}}if(e||(e=t.scene),e===t.scene){if(t.scene&&(t.scene.traverse(n),t.disposeEnvironment()),t.scene=null,t.controls&&t.controls.dispose&&t.controls.dispose(),t.controls=null,t.camera=null,t.mixer&&(t.mixer.stopAllAction(),t.actions.forEach((function(e){t.mixer.uncacheAction(e.getClip(),e.getRoot())}))),t.mixer=null,t.actions=[],t.postprocessing){if(t.postprocessing.composer)for(let e in t.postprocessing){const n=t.postprocessing[e];(n instanceof zh||n instanceof Cp)&&n.dispose()}t.disablePostprocessing()}t.postprocessing=null,kh.dispose(),t.renderer&&t.renderer.disposeInternalCaches(),t._tripleP&&t._tripleP.dispose(),t._tripleF&&t._tripleF.dispose(),t._tripleH&&t._tripleH.dispose(),t.useHiDPIRenderPass=!1,t.renderer.setPixelRatio(1)}else if(t.scene&&(e.traverse(n),e.parent&&e.parent.remove(e)),t.mixer)for(let e=t.actions.length-1;e>=0;e--){const n=t.actions[e];vA.checkActionIsUsed(t.scene,n)||(n.stop(),t.mixer.uncacheAction(n.getClip(),n.getRoot()),t.actions.splice(e,1))}}dispose(){this.scene&&this.unload(),this.renderer&&(this.renderer.forceContextLoss(),this.renderer.dispose(),this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement)),this.renderer=null,window.removeEventListener("resize",this._resizeCb,!1),hp.removeFromAppList(this),ku.clear(),this.dispatchEvent({type:"dispose"})}getWidth(){return this.container.offsetWidth}getHeight(){return this.container.offsetHeight}onResize(){if(!this.renderer)return;this.enableRender&&!this.ssaaOnPause||(this.enableRendering(),this.disableRendering(1));const e=this.getWidth(),t=this.getHeight();if(this.renderer.setSize(e,t),this.postprocessing&&(this.postprocessing.gtaoGenerator&&this.postprocessing.gtaoGenerator.setSize(e,t),this.postprocessing.composer.setSize(e,t)),this.scene){this.scene.traverse((n=>{n.isPlaneReflectionProbe&&n.setSize(e,t)}));const n=e/t,i=this.camera;if(i.isPerspectiveCamera){const e=i.aspect{e.isPlaneReflectionProbe&&e.update(this.scene,this.camera,this.renderer)})),this.renderer.gtaoMapEnabled=!0,this.postprocessing){const e=this.postprocessing.gtaoGenerator;e&&e.render(this.renderer);this.postprocessing.composer.render(this.elapsed)}else e&&this.renderer.render(this.scene,this.camera);if(e&&this.useHiDPIRenderPass){const e=this.camera.layers.mask,t=this.scene.background,n=this.renderer.autoClear;this.scene.background=null,this.camera.layers.set(7),this.renderer.autoClear=!1,this.renderer.clearDepth(),this.renderer.render(this.scene,this.camera),this.camera.layers.mask=e,this.scene.background=t,this.renderer.autoClear=n}this.renderer.gtaoMapEnabled=!1,this.dispatchEvent({type:"onAfterRender"})}enableControls(e){const t=this.camera;if(t.controls){if(this.controls&&t===this.controls.object&&(this.controls instanceof Mf&&"ORBIT"===t.controls.type||this.controls instanceof Fp&&"FLYING"===t.controls.type||this.controls instanceof Dp&&"FIRST_PERSON"===t.controls.type));else switch(this.controls&&this.controls.dispose(),t.controls.type){case"ORBIT":this.controls=new Mf(t,e||this.renderer.domElement);break;case"FLYING":this.controls=new Fp(t,this.renderer.domElement);break;case"FIRST_PERSON":this.controls=new Dp(t,this.renderer.domElement);break;default:this.controls=null}this.controls&&(t.controls.assignToControls(this.controls,this.scene),this.controls.update())}}setCamera(e){if(this.camera=e,this.postprocessing){const t=this.postprocessing.composer.passes;for(let n=0;n{p.removeEventListener("dispose",e),this.renderer.disposeGTAO()};p.addEventListener("dispose",e),this.renderer.gtaoMap=p.renderTarget.texture}p.distance=r.distance,p.factor=r.factor,p.precision=r.precision,p.bentNormals=null!=(t=r.bentNormals)&&t,p.bounceApprox=r.bounceApprox;break;case"outline":let f;if(this.postprocessing.outlinePass?f=this.postprocessing.outlinePass:(f=new op(new et(this.getWidth(),this.getHeight()),this.scene,this.camera),i.insertPass(f,a),this.postprocessing.outlinePass=f),f.edgeStrength=r.edgeStrength,f.edgeGlow=r.edgeGlow,f.edgeThickness=r.edgeThickness,f.pulsePeriod=r.pulsePeriod,f.visibleEdgeColor.fromArray(r.visibleEdgeColor),f.hiddenEdgeColor.fromArray(r.hiddenEdgeColor),void 0===r.renderHiddenEdge){const e=0===r.hiddenEdgeColor[0]&&0===r.hiddenEdgeColor[1]&&0===r.hiddenEdgeColor[2];f.hiddenEdgeColor.setW(Number(!e))}else f.hiddenEdgeColor.setW(Number(r.renderHiddenEdge));break;case"ssr":if(!ls.checkHalfFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSR since your hardware does not support half float textures");break}let m,g=!1;st(r.useRefract)&&(g=r.useRefract),(g?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect)?m=g?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect:(m=new lp(this.scene,this.camera),i.insertPassAfter(m,[this.postprocessing.renderPass,this.postprocessing.ssrPassRefract,this.postprocessing.ssrPassReflect]),g?this.postprocessing.ssrPassRefract=m:this.postprocessing.ssrPassReflect=m),m.useRefract=g,st(r.objects)&&(m.objects=r.objects),st(r.intensity)&&(m.intensity=r.intensity),st(r.steps)&&(m.steps=r.steps),st(r.stride)&&(m.stride=r.stride),st(r.binarySearchSteps)&&(m.binarySearchSteps=r.binarySearchSteps),st(r.renderTargetScale)&&(m.renderTargetScale=r.renderTargetScale),st(r.thickness)&&(m.thickness=r.thickness),st(r.maxDistance)&&(m.maxDistance=r.maxDistance),st(r.jitter)&&(m.jitter=r.jitter),st(r.renderAfter)&&(m.renderAfter=r.renderAfter),st(r.simpleRefraction)&&(m.simpleRefraction=r.simpleRefraction),this.onResize&&this.onResize();break;default:console.error(`v3d.App: wrong postprocessing effect "${r.type}"`)}}if(1==i.passes.length){const e=new jh(ro.copy);i.passes.push(e),this.postprocessing.copyPass=e}}disablePostprocessing(e,t){if(!this.postprocessing)return;const n=this.postprocessing.gtaoGenerator;!t&&n&&(n.dispose(),this.postprocessing.gtaoGenerator=null);const i=["afterimagePass","bloomPass","brightnessContrastPass","bokehPass","grayscalePass","ssrPassReflect","ssrPassRefract"];e||i.push("outlinePass");const o=this.postprocessing.composer;for(let e=0;e0&&(this.postprocessing.ssrPassRefract||this.postprocessing.ssrPassReflect))return;const n=this;this.scene.traverse((function(t){t.isAnnotationControl&&(t.update(n.camera),t.doUpdate=!Boolean(e))}));const i=this.postprocessing.composer;if(e>0&&i.passes[0]instanceof rp){let o;this.postprocessing.ssaaRenderPass?o=this.postprocessing.ssaaRenderPass:(o=new ap(this.scene,this.camera),this.postprocessing.ssaaRenderPass=o,t&&o.addEventListener("iteration",(function(t){t.frame==e*e-1&&(i.enableAllPasses(),i.renderToScreen=!0,i.passes[i.passes.length-1].renderToScreen=!0,n.disableRenderTrigger=1)}))),o.sampleLevel=e||4,i.passes[0]=o,this.postprocessing.fxaaPass&&i.passes.splice(i.passes.length-1,1),t&&(o.iterative=!0,o.iterativeFrame=0,i.disableAllPasses(),i.renderToScreen=!1,o.enabled=!0)}else e>0?(i.passes[0].sampleLevel=e||4,t&&(ssaaRenderPass.iterative=!0,ssaaRenderPass.iterativeFrame=0,i.disableAllPasses(),i.renderToScreen=!1,ssaaRenderPass.enabled=!0)):0==e&&i.passes[0]instanceof ap&&(i.passes[0]=this.postprocessing.renderPass,this.postprocessing.fxaaPass&&i.passes.push(this.postprocessing.fxaaPass),i.enableAllPasses(),i.renderToScreen=!0)}updateEnvironment(e){const t=this.renderer.xr.enabled;this.renderer.xr.enabled=!1,this.disposeEnvironment(),e.useHDR=!0,null!==this.scene.background&&this.scene.background.isSceneBackground&&(this.scene.background.data=vp.renderWorldNodeMatToCubemap(this.renderer,e,this.worldCubemapRes,{encoding:Ae,format:R,generateMipmaps:!0,minFilter:M,type:T}),this.scene.background.useHDR=this.useHDR),0===this._envIBLMode&&new Lo(this.renderer,this._pmremMaxTileSize,!0).compileCubemapShader(),this._prepareEnvMapProbeWorld(),this.renderer.xr.enabled=t}disposeEnvironment(){this._disposeEnvLightProbe();let e=this.scene.background;e&&(e.isSceneBackground&&(e=e.data),e&&(e.isTexture||e.isWebGLRenderTarget)&&e.dispose())}_disposeEnvLightProbe(){null!==this._envLightProbe&&(this.scene.remove(this._envLightProbe),this._envLightProbe=null)}updateReflectionProbes(e){e.traverse((e=>{e.isCubeReflectionProbe&&e.update(this.scene,this.renderer)}))}generateRTargetPMREM(e){if(!e.isWebGLCubeRenderTarget)return null;const t=new Lo(this.renderer,this._pmremMaxTileSize,!0);t.flipCubemapX=!1;const n=t.fromCubeRenderTarget(e,{encoding:ve});return t.dispose(),n}initWebXR(e,t,n,i,o,r){n=n||function(){},i=i||function(){},o=o||function(){},r=r||{};const a=this;function s(e){a.xrSession.removeEventListener("end",s),a.renderer.xr.setSession(null),o();for(let e=0;e=0;e--){const n=t.children[e];n.name.indexOf(t.name)>-1&&(n.geometry.dispose(),n.material.dispose(),t.remove(n))}}const u={optionalFeatures:[t]};"immersive-ar"==e&&(u.optionalFeatures.push("hit-test"),r.domOverlay&&(u.optionalFeatures.push("dom-overlay"),u.domOverlay={root:a.container})),navigator.xr.requestSession(e,u).then((function(i){a._postprocessingSave=a.postprocessing,a.postprocessing=null,a.renderer.xr.setReferenceSpaceType(t),a.xrSession=i,i.addEventListener("end",s);const o="immersive-vr"==e?2:1;for(let e=0;em?(v=p>u?Math.min(l.bottom+this.offset,p):Math.max(l.top-this.offset,p),g=(v-p)/f+h):(g=h[])))}const h=Math.log10(1/t),p=Math.pow(10,h);for(let t=0;t=0&&o<=n&&r>=0&&r<=i;this.visible=a,this.updatedCallback&&this.updatedCallback(t.x,t.y,a)}}}ex.prototype.isAnnotationControl=!0;var tx=new is,nx=new Bt,ix=new Bt,ox=new Bt;class rx extends ex{constructor(e,t,n){super(e),this.type="Annotation",this.character=t,this.dialogContents=n,this.annotation=document.createElement("div"),this.annotation.innerHTML=t,this.annotation.className="v3d-annotation",this.container.appendChild(this.annotation),this.annotationDialogVisible=!1,this.annotationDialog=document.createElement("div"),this.annotationDialog.innerHTML=n,this.annotationDialog.className="v3d-annotation-dialog",this.annotation.appendChild(this.annotationDialog),this.fadeObscured=!0,this.obscured=!1,this.text=this.dialogContents,this.annotationText=this.annotationDialog;var i=!1,o=this;function r(e){e.target==o.annotation?0==o.annotationDialog.innerHTML.length||o.obscured||(o.annotationDialogVisible=!o.annotationDialogVisible,o.annotationDialog.style.visibility=o.annotationDialogVisible?"visible":"hidden",o.annotationDialogVisible?o.annotation.style.zIndex="2":o.annotation.style.zIndex="1"):e.target.className.indexOf("v3d-annotation")>-1&&(o.annotationDialogVisible=!1,o.annotationDialog.style.visibility="hidden",o.annotation.style.zIndex=o.obscured?"auto":"1")}this._touchstartCb=function(e){r(e),i=!0},document.body.addEventListener("touchstart",this._touchstartCb,!1),this._mousedownCb=function(e){i||r(e),i=!1},document.body.addEventListener("mousedown",this._mousedownCb,!1)}raycast(){}clone(){return new this.constructor(this.container,this.character,this.dialogContents).copy(this)}update(e){if(super.update(e),this.doUpdate){var t=this.projected,n=this.annotation;if(n.style.transform="translate("+t.x+"px, "+t.y+"px)",n.style.visibility=this.visible?"visible":"hidden",this.annotationDialog.style.visibility=this.visible&&this.annotationDialogVisible?"visible":"hidden",this.fadeObscured){e.getWorldPositionNU(nx),this.getWorldPositionNU(ix),ox.copy(ix).sub(nx).normalize(),tx.set(nx,ox),tx.far=nx.distanceTo(ix);var i=tx.intersectObject(this.findRoot(),!0);i.length>1||1==i.length&&i[0].object!=this.parent?(n.classList.add("v3d-annotation-transparent"),this.obscured=!0,n.style.zIndex="auto",this.annotationDialog.style.visibility="hidden"):(n.classList.remove("v3d-annotation-transparent"),n.style.zIndex="visible"==this.annotationDialog.style.visibility?"2":"1",this.obscured=!1)}}}setDialogVisibility(e){e?(this.annotationDialogVisible=!0,this.annotationDialog.style.visibility="visible",this.annotation.style.zIndex="2"):(this.annotationDialogVisible=!1,this.annotationDialog.style.visibility="hidden",this.annotation.style.zIndex="1")}dispose(){var e=this.annotation.parentElement;e&&e.removeChild(this.annotation),document.body.removeEventListener("touchstart",this._touchstartCb,!1),document.body.removeEventListener("mousedown",this._mousedownCb,!1)}}rx.prototype.isAnnotation=!0;var ax,sx,lx={translateVRCamera:function(){var e=new Bt;new un;return function(t,n,i){var o=t.parent;o&&!o.isScene&&(e.copy(n).applyQuaternion(t.quaternion).applyQuaternion(o.quaternion),o.position.add(e.multiplyScalar(i)))}}(),rotateVRCamera:(ax=new Lt,sx=new Lt,function(e,t,n){var i=e.parent;i&&!i.isScene&&(ax.setFromAxisAngle(t,n),ax.premultiply(e.quaternion),ax.premultiply(i.quaternion),i.quaternion.multiplyQuaternions(ax,sx.copy(e.quaternion).invert()))})};class cx{constructor(){this.pluginCallbacks=[],this.register((function(e){return new Fx(e)})),this.register((function(e){return new Ux(e)})),this.register((function(e){return new zx(e)})),this.register((function(e){return new Gx(e)})),this.register((function(e){return new kx(e)})),this.register((function(e){return new Vx(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){"object"==typeof n&&(console.warn("v3d.GLTFExporter: parse() expects options as the fourth argument now."),i=n);const o=new Ox,r=[];for(let e=0,t=this.pluginCallbacks.length;e0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);const i=this,o=i.buffers,r=i.json;n=i.options;const a=i.extensionsUsed,s=new Blob(o,{type:"application/octet-stream"}),l=Object.keys(a);if(l.length>0&&(r.extensionsUsed=l),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=s.size),!0===n.binary){const e=new window.FileReader;e.readAsArrayBuffer(s),e.onloadend=function(){const n=Dx(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const o=Dx(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;const t=new Uint8Array(new ArrayBuffer(e.length));for(let n=0,i=e.length;n255?32:i}return t.buffer}(JSON.stringify(r)),32),a=new DataView(new ArrayBuffer(8));a.setUint32(0,o.byteLength,!0),a.setUint32(4,1313821514,!0);const s=new ArrayBuffer(12),l=new DataView(s);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0);const c=12+a.byteLength+o.byteLength+i.byteLength+n.byteLength;l.setUint32(8,c,!0);const u=new Blob([s,a,o,i,n],{type:"application/octet-stream"}),d=new window.FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(r.buffers&&r.buffers.length>0){const e=new window.FileReader;e.readAsDataURL(s),e.onloadend=function(){const n=e.result;r.buffers[0].uri=n,t(r)}}else t(r)}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const n=this.options,i=this.extensionsUsed;try{const o=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&o.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in o.gltfExtensions)t.extensions[e]=o.gltfExtensions[e],i[e]=!0;delete o.gltfExtensions}Object.keys(o).length>0&&(t.extras=o)}catch(t){console.warn("v3d.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new Bt;for(let n=0,i=e.count;n5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const n=e.clone(),i=new Bt;for(let e=0,t=n.count;e4?i=e.array[o*e.itemSize+n]:0===n?i=e.getX(o):1===n?i=e.getY(o):2===n?i=e.getZ(o):3===n&&(i=e.getW(o)),t===vx?l.setFloat32(c,i,!0):t===Ax?l.setUint32(c,i,!0):t===gx?l.setUint16(c,i,!0):t===mx&&l.setUint8(c,i),c+=a}const u={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:s};void 0!==o&&(u.target=o),o===_x&&(u.byteStride=e.itemSize*a),this.byteOffset+=s,r.bufferViews.push(u);return{id:r.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,n=t.json;return n.bufferViews||(n.bufferViews=[]),new Promise((function(i){const o=new window.FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const e=Dx(o.result),r={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(n.bufferViews.push(r)-1)}}))}processAccessor(e,t,n,i){const o=this.options,r=this.json;let a;if(e.array.constructor===Float32Array)a=vx;else if(e.array.constructor===Uint32Array)a=Ax;else if(e.array.constructor===Uint16Array)a=gx;else{if(e.array.constructor!==Uint8Array)throw new Error("v3d.GLTFExporter: Unsupported bufferAttribute component type.");a=mx}if(void 0===n&&(n=0),void 0===i&&(i=e.count),o.truncateDrawRange&&void 0!==t&&null===t.index){const o=n+i,r=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;n=Math.max(n,t.drawRange.start),(i=Math.min(o,r)-n)<0&&(i=0)}if(0===i)return null;const s=function(e,t,n){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let o=t;o4?n=e.array[o*e.itemSize+t]:0===t?n=e.getX(o):1===t?n=e.getY(o):2===t?n=e.getZ(o):3===t&&(n=e.getW(o)),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let l;void 0!==t&&(l=e===t.index?xx:_x);const c=this.processBufferView(e,a,n,i,l),u={bufferView:c.id,byteOffset:c.byteOffset,componentType:a,count:i,max:s.max,min:s.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(u.normalized=!0),r.accessors||(r.accessors=[]),r.accessors.push(u)-1}processImage(e,t,n){const i=this,o=i.cache,r=i.json,a=i.options,s=i.pending;o.images.has(e)||o.images.set(e,{});const l=o.images.get(e),c=t===R?"image/png":"image/jpeg",u=c+":flipY/"+n.toString();if(void 0!==l[u])return l[u];r.images||(r.images=[]);const d={mimeType:c};if(a.embedImages){const o=Nx=Nx||document.createElement("canvas");o.width=Math.min(e.width,a.maxTextureSize),o.height=Math.min(e.height,a.maxTextureSize);const r=o.getContext("2d");if(!0===n&&(r.translate(0,o.height),r.scale(1,-1)),"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)r.drawImage(e,0,0,o.width,o.height);else{t!==R&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t1&&(t.multiplyScalar(1/n),console.warn("v3d.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),n>0&&(i.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),i.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&1!==e.normalScale.x&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),i.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(r),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),i.occlusionTexture=t}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),2===e.side&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const a=n.materials.push(i)-1;return t.materials.set(e,a),a}processMesh(e){const t=this.cache,n=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t0){const n=[],i=[],o={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)o[e.morphTargetDictionary[t]]=t;for(let a=0;a0&&(s.extras={},s.extras.targetNames=i)}const f=Array.isArray(e.material);if(f&&0===r.groups.length)return null;const m=f?e.material:[e.material],g=f?r.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,n=g.length;e0&&(n.targets=u),null!==r.index){let i=this.getUID(r.index);void 0===g[e].start&&void 0===g[e].count||(i+=":"+g[e].start+":"+g[e].count),t.attributes.has(i)?n.indices=t.attributes.get(i):(n.indices=this.processAccessor(r.index,r,g[e].start,g[e].count),t.attributes.set(i,n.indices)),null===n.indices&&delete n.indices}const i=this.processMaterial(m[g[e].materialIndex]);null!==i&&(n.material=i),c.push(n)}s.primitives=c,n.meshes||(n.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,s)}));const v=n.meshes.push(s)-1;return t.meshes.set(o,v),v}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const n=e.isOrthographicCamera,i={type:n?"orthographic":"perspective"};return n?i.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:ke(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const n=this.json,i=this.nodeMap;n.animations||(n.animations=[]);const o=(e=cx.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,r=[],a=[];for(let e=0;e0){const t=[];for(let n=0,i=e.children.length;n0&&(r.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,r)}));const a=t.nodes.push(r)-1;return i.set(e,a),a}processScene(e){const t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const o=[];for(let t=0,i=e.children.length;t0&&(i.nodes=o),this.serializeUserData(e,i)}processObjects(e){const t=new mo;t.name="AuxScene";for(let n=0;n0&&this.processObjects(n);for(let e=0;e0&&(r.range=e.distance)):e.isSpotLight&&(r.type="spot",e.distance>0&&(r.range=e.distance),r.spot={},r.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,r.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("v3d.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("v3d.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),o[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},o[this.name]=!0);const a=i.extensions[this.name].lights;a.push(r),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Ux{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class zx{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;const n=this.writer,i=n.extensionsUsed,o={};t.pbrMetallicRoughness.baseColorFactor&&(o.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const r=[1,1,1];if(e.specular.toArray(r,0),o.specularFactor=r,o.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(o.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const t={index:n.processTexture(e.specularMap)};n.applyTextureTransform(t,e.specularMap),o.specularGlossinessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,i[this.name]=!0}}class Vx{constructor(e){this.writer=e,this.name="KHR_materials_clearcoat"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const n=this.writer,i=n.extensionsUsed,o={};if(o.clearcoatFactor=e.clearcoat,e.clearcoatMap){const t={index:n.processTexture(e.clearcoatMap)};n.applyTextureTransform(t,e.clearcoatMap),o.clearcoatTexture=t}if(o.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){const t={index:n.processTexture(e.clearcoatRoughnessMap)};n.applyTextureTransform(t,e.clearcoatRoughnessMap),o.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){const t={index:n.processTexture(e.clearcoatNormalMap)};n.applyTextureTransform(t,e.clearcoatNormalMap),o.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,i[this.name]=!0}}class Gx{constructor(e){this.writer=e,this.name="KHR_materials_transmission"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,o={};if(o.transmissionFactor=e.transmission,e.transmissionMap){const t={index:n.processTexture(e.transmissionMap)};n.applyTextureTransform(t,e.transmissionMap),o.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,i[this.name]=!0}}class kx{constructor(e){this.writer=e,this.name="KHR_materials_volume"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||0===e.transmission)return;const n=this.writer,i=n.extensionsUsed,o={};if(o.thicknessFactor=e.thickness,e.thicknessMap){const t={index:n.processTexture(e.thicknessMap)};n.applyTextureTransform(t,e.thicknessMap),o.thicknessTexture=t}o.attenuationDistance=e.attenuationDistance,o.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=o,i[this.name]=!0}}cx.Utils={insertKeyframe:function(e,t){const n=.001,i=e.getValueSize(),o=new e.TimeBufferType(e.times.length+1),r=new e.ValueBufferType(e.values.length+i),a=e.createInterpolant(new e.ValueBufferType(i));let s;if(0===e.times.length){o[0]=t;for(let e=0;ee.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)t){o.set(e.times.slice(0,l+1),0),o[l+1]=t,o.set(e.times.slice(l+1),l+2),r.set(e.values.slice(0,(l+1)*i),0),r.set(a.evaluate(t),(l+1)*i),r.set(e.values.slice((l+1)*i),(l+2)*i),s=l+1;break}}return e.times=o,e.values=r,s},mergeMorphTargetTracks:function(e,t){const n=[],i={},o=e.tracks;for(let e=0;e.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{Lh.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(Lh,t)}}setLength(e,t=.2*e,n=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}},e.Audio=Ud,e.AudioAnalyser=Qd,e.AudioContext=Sd,e.AudioListener=class extends Nn{constructor(){super(),this.type="AudioListener",this.context=Sd.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Bd}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,n=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Dd,Nd,Od),Fd.set(0,0,-1).applyQuaternion(Nd),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Dd.x,e),t.positionY.linearRampToValueAtTime(Dd.y,e),t.positionZ.linearRampToValueAtTime(Dd.z,e),t.forwardX.linearRampToValueAtTime(Fd.x,e),t.forwardY.linearRampToValueAtTime(Fd.y,e),t.forwardZ.linearRampToValueAtTime(Fd.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Dd.x,Dd.y,Dd.z),t.setOrientation(Fd.x,Fd.y,Fd.z,n.x,n.y,n.z)}},e.AudioLoader=wd,e.AxesHelper=Dh,e.AxisHelper=function(e){return console.warn("v3d.AxisHelper has been renamed to v3d.AxesHelper."),new Dh(e)},e.BackSide=1,e.BasicDepthPacking=3200,e.BasicShadowMap=0,e.BilinearShadowMap=6,e.BinaryTextureLoader=function(e){return console.warn("v3d.BinaryTextureLoader has been renamed to v3d.DataTextureLoader."),new qu(e)},e.BlenderTextBufferGeometry=kc,e.BlenderTextGeometry=kc,e.BloomPass=Wh,e.BokehPass=Hh,e.Bone=Gs,e.BooleanKeyframeTrack=Pu,e.BoundingBoxHelper=function(e,t){return console.warn("v3d.BoundingBoxHelper has been deprecated. Creating a v3d.BoxHelper instead."),new Ih(e,t)},e.Box2=lh,e.Box3=Nt,e.Box3Helper=Rh,e.BoxBufferGeometry=Oi,e.BoxGeometry=Oi,e.BoxHelper=Ih,e.BrightnessContrastPass=Yh,e.BufferAttribute=Jn,e.BufferGeometry=gi,e.BufferGeometryLoader=_d,e.BufferGeometryUtils=J_,e.ByteType=1010,e.CENTER=0,e.CSVParser=k_,e.Cache=ku,e.Camera=Gi,e.CameraHelper=class extends sl{constructor(e){const t=new gi,n=new Js({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],o=[],r={},a=new yt(16755200),s=new yt(16711680),l=new yt(43775),c=new yt(16777215),u=new yt(3355443);function d(e,t,n){h(e,n),h(t,n)}function h(e,t){i.push(0,0,0),o.push(t.r,t.g,t.b),void 0===r[e]&&(r[e]=[]),r[e].push(i.length/3-1)}d("n1","n2",a),d("n2","n4",a),d("n4","n3",a),d("n3","n1",a),d("f1","f2",a),d("f2","f4",a),d("f4","f3",a),d("f3","f1",a),d("n1","f1",a),d("n2","f2",a),d("n3","f3",a),d("n4","f4",a),d("p","n1",s),d("p","n2",s),d("p","n3",s),d("p","n4",s),d("u1","u2",l),d("u2","u3",l),d("u3","u1",l),d("c","t",c),d("p","c",u),d("cn1","cn2",u),d("cn3","cn4",u),d("cf1","cf2",u),d("cf3","cf4",u),t.setAttribute("position",new si(i,3)),t.setAttribute("color",new si(o,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=r,this.update()}update(){const e=this.geometry,t=this.pointMap;wh.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Eh("c",t,e,wh,0,0,-1),Eh("t",t,e,wh,0,0,1),Eh("n1",t,e,wh,-1,-1,-1),Eh("n2",t,e,wh,1,-1,-1),Eh("n3",t,e,wh,-1,1,-1),Eh("n4",t,e,wh,1,1,-1),Eh("f1",t,e,wh,-1,-1,1),Eh("f2",t,e,wh,1,-1,1),Eh("f3",t,e,wh,-1,1,1),Eh("f4",t,e,wh,1,1,1),Eh("u1",t,e,wh,.7,1.1,-1),Eh("u2",t,e,wh,-.7,1.1,-1),Eh("u3",t,e,wh,0,2,-1),Eh("cf1",t,e,wh,-1,0,1),Eh("cf2",t,e,wh,1,0,1),Eh("cf3",t,e,wh,0,-1,1),Eh("cf4",t,e,wh,0,1,1),Eh("cn1",t,e,wh,-1,0,-1),Eh("cn2",t,e,wh,1,0,-1),Eh("cn3",t,e,wh,0,-1,-1),Eh("cn4",t,e,wh,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CameraUtils=G_,e.CanvasBreakpointsConstraint=Jm,e.CanvasFitConstraint=Zm,e.CanvasRenderer=function(){console.error("v3d.CanvasRenderer has been removed")},e.CanvasTexture=_l,e.CatmullRomCurve3=Ul,e.ChildOfConstraint=Rf,e.CineonToneMapping=3,e.CircleBufferGeometry=xl,e.CircleGeometry=xl,e.ClampToEdgeWrapping=g,e.ClearMaskPass=Zh,e.Clock=Bd,e.Color=yt,e.ColorKeyframeTrack=Du,e.Compat=pp,e.CompressedTexture=Al,e.CompressedTextureLoader=class extends Hu{constructor(e){super(e)}load(e,t,n,i){const o=this,r=[],a=new Al,s=new Yu(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(o.withCredentials);let l=0;function c(c){s.load(e[c],(function(e){const n=o.parse(e,!0);r[c]={width:n.width,height:n.height,format:n.format,mipmaps:n.mipmaps},l+=1,6===l&&(1===n.mipmapCount&&(a.minFilter=y),a.image=r,a.format=n.format,a.needsUpdate=!0,t&&t(a))}),n,i)}if(Array.isArray(e))for(let t=0,n=e.length;t0){const n=new Qu(t);o=new Xu(n),o.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t0){i=new Xu(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;tt;)this._roots.pop();for(var n=0;n=this._roots.length){var i=new w_(this._mesh,this.depth,n);this.add(i),this._roots.push(i)}else{var o=this._roots[n];o.depth=this.depth,o.update()}this.position.copy(this._mesh.position),this.rotation.copy(this._mesh.rotation),this.scale.copy(this._mesh.scale)}},e.WebGL1Renderer=us,e.WebGLCubeRenderTarget=ji,e.WebGLMultipleRenderTargets=It,e.WebGLMultisampleRenderTarget=Rt,e.WebGLRenderTarget=Tt,e.WebGLRenderTargetCube=function(e,t,n){return console.warn("v3d.WebGLRenderTargetCube(width, height, options) is now WebGLCubeRenderTarget(size, options)."),new ji(e,n)},e.WebGLRenderer=cs,e.WebGLUtils=Za,e.WebXRUtils=lx,e.WireframeGeometry=zc,e.WireframeHelper=function(e,t){return console.warn("v3d.WireframeHelper has been removed. Use v3d.WireframeGeometry instead."),new sl(new zc(e.geometry),new Js({color:void 0!==t?t:16777215}))},e.WrapAroundEnding=fe,e.XHRLoader=function(e){return console.warn("v3d.XHRLoader has been renamed to v3d.FileLoader."),new Yu(e)},e.XZ=zp,e.XZLoader=kp,e.ZeroCurvatureEnding=he,e.ZeroFactor=o,e.ZeroSlopeEnding=pe,e.ZeroStencilOp=0,e._SRGBAFormat=Ie,e.acceleratedRaycast=R_,e.arrayMax=nt,e.arrayMin=function(e){if(0===e.length)return 1/0;let t=e[0];for(let n=1,i=e.length;n