function _extends(){return _extends=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},_extends.apply(this,arguments)}!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).v3d={})}(this,(function(e){"use strict";const t="4.3.0",n={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},i=0,o=1,r=2,a=0,s=1,l=2,c=3,u=4,d=5,h=6,p=0,f=1,m=2,g=3,v=0,A=1,_=2,x=3,y=4,b=5,C=100,M=101,S=102,E=103,w=104,T=200,I=201,R=202,L=203,P=204,B=205,D=206,N=207,O=208,F=209,U=210,z=0,V=1,G=2,k=3,Q=4,W=5,H=6,j=7,Y=0,X=1,K=2,q=0,Z=1,J=2,$=3,ee=4,te=5,ne=6,ie=7,oe=8,re=300,ae=301,se=302,le=303,ce=304,ue=306,de=1e3,he=1001,pe=1002,fe=1003,me=1004,ge=1005,ve=1006,Ae=1007,_e=1008,xe=1009,ye=1010,be=1011,Ce=1012,Me=1013,Se=1014,Ee=1015,we=1016,Te=1017,Ie=1018,Re=1020,Le=1021,Pe=1022,Be=1023,De=1024,Ne=1025,Oe=1026,Fe=1027,Ue=1028,ze=1029,Ve=1030,Ge=1031,ke=1033,Qe=33776,We=33777,He=33778,je=33779,Ye=35840,Xe=35841,Ke=35842,qe=35843,Ze=36196,Je=37492,$e=37496,et=37808,tt=37809,nt=37810,it=37811,ot=37812,rt=37813,at=37814,st=37815,lt=37816,ct=37817,ut=37818,dt=37819,ht=37820,pt=37821,ft=36492,mt=2200,gt=2201,vt=2202,At=2300,_t=2301,xt=2302,yt=2400,bt=2401,Ct=2402,Mt=2500,St=2501,Et=0,wt=1,Tt=2,It=3e3,Rt=3001,Lt=3201,Pt=3202,Bt=3301,Dt=3302,Nt=0,Ot=1,Ft="srgb",Ut="srgb-linear",zt=7680,Vt=7681,Gt=34055,kt=34056,Qt=35044,Wt="300 es",Ht=1035,jt="MAX",Yt="__V3DL__1a7a468eb6",Xt=0,Kt=0;class qt{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const n=this._listeners;void 0===n[e]&&(n[e]=[]),-1===n[e].indexOf(t)&&n[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const n=this._listeners;return void 0!==n[e]&&-1!==n[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const n=this._listeners[e];if(void 0!==n){const e=n.indexOf(t);-1!==e&&n.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const n=t.slice(0);for(let t=0,i=n.length;t<i;t++)n[t].call(this,e);e.target=null}}}const Zt=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Jt=1234567;const $t=Math.PI/180,en=180/Math.PI;function tn(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(Zt[255&e]+Zt[e>>8&255]+Zt[e>>16&255]+Zt[e>>24&255]+"-"+Zt[255&t]+Zt[t>>8&255]+"-"+Zt[t>>16&15|64]+Zt[t>>24&255]+"-"+Zt[63&n|128]+Zt[n>>8&255]+"-"+Zt[n>>16&255]+Zt[n>>24&255]+Zt[255&i]+Zt[i>>8&255]+Zt[i>>16&255]+Zt[i>>24&255]).toLowerCase()}function nn(e,t,n){return Math.max(t,Math.min(n,e))}function on(e,t){return(e%t+t)%t}function rn(e,t,n){return(1-n)*e+n*t}function an(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*e*(e*(6*e-15)+10)}function sn(e){return e*$t}function ln(e){return e*en}function cn(e){return 0==(e&e-1)&&0!==e}function un(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function dn(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function hn(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function pn(e,t){switch(t.constructor){case Float32Array:return e;case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}function fn(e){let t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return t>>>0}function mn(e,t,n,i){let o=Math.exp(-n/i);return e*o+(1-o)*t}function gn(e,t,n,i,o){let r=mn(e,t,n,i);return Math.abs(e-t)<o&&(r=t),r}function vn(e){return nn(e-2*Math.PI*Math.floor(e/(2*Math.PI)),0,2*Math.PI)}function An(e){let t=e+Math.PI;return t%=2*Math.PI,t+=2*Math.PI,t%=2*Math.PI,t-=Math.PI,t}function _n(e,t,n){let i=vn(e-t),o=vn(n-t);return i>o&&(i=i<o/2+Math.PI?o:0),i+t}var xn=Object.freeze({__proto__:null,DEG2RAD:$t,RAD2DEG:en,generateUUID:tn,clamp:nn,euclideanModulo:on,mapLinear:function(e,t,n,i,o){return i+(e-t)*(o-i)/(n-t)},inverseLerp:function(e,t,n){return e!==t?(n-e)/(t-e):0},lerp:rn,damp:function(e,t,n,i){return rn(e,t,1-Math.exp(-n*i))},pingpong:function(e,t=1){return t-Math.abs(on(e,2*t)-t)},smoothstep:function(e,t,n){return e<=t?0:e>=n?1:(e=(e-t)/(n-t))*e*(3-2*e)},smootherstep:an,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){void 0!==e&&(Jt=e);let t=Jt+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:sn,radToDeg:ln,isPowerOfTwo:cn,ceilPowerOfTwo:un,floorPowerOfTwo:dn,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)}},normalize:pn,denormalize:hn,hashString:fn,expAverage:mn,expAverageClamp:gn,angleToRange_0_2Pi:vn,angleToRange_mPi_Pi:An,clampAngle:_n});class yn{constructor(e=0,t=0){yn.prototype.isVector2=!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){return 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){return 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){return 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}}class bn{constructor(){bn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1]}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){return this.premultiply(Cn.makeScale(e,t)),this}rotate(e){return this.premultiply(Cn.makeRotation(-e)),this}translate(e,t){return this.premultiply(Cn.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),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)}}const Cn=new bn;function Mn(e){if(0===e.length)return-1/0;let t=e[0];for(let n=1,i=e.length;n<i;++n)e[n]>t&&(t=e[n]);return t}function Sn(e){for(let t=e.length-1;t>=0;--t)if(e[t]>=65535)return!0;return!1}const En={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function wn(e,t){return new En[e](t)}function Tn(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function In(e){return void 0!==e}function Rn(e,t,n){for(let i=0;i<e.length;i++)e[i]=nn(e[i],t,n);return e}function Ln(){switch(jt){case"BLENDER":return"for Blender";case"MAX":return"for 3ds Max";case"MAYA":return"for Maya";case"ALL":return"Ultimate";default:return"Unknown"}}function Pn(e){var t,n;const i=null!=(t=e.match(/^(\d+).(\d+).(\d+)(?: (.*))?$/))?t:[];let o=Number(i[1]),r=Number(i[2]),a=Number(i[3]);o=Number.isNaN(o)?0:o,r=Number.isNaN(r)?0:r,a=Number.isNaN(a)?0:a;return{major:o,minor:r,patch:a,pre:null!=(n=i[4])?n:""}}function Bn(e){var t;if(""===e)return 1/0;const n=null!=(t=e.match(/^pre(\d+)$/))?t:[];let i=Number(n[1]);return i=Number.isNaN(i)?0:i,i}function Dn(e){return`${e%1?e:`${e}.0`}`}function Nn(){return"undefined"!=typeof window?window:"undefined"!=typeof self?self:global}const On={};function Fn(e=""){const t=document.getElementsByTagName("script");let n=e;for(let i=t.length-1;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 Un(e,t=function(e){},n=function(e){}){On[e]=On[e]||{status:0,loadCallbacks:[],errorCallbacks:[]};const i=On[e];if(4==i.status)return void t(e);if(i.loadCallbacks.push(t),i.errorCallbacks.push(n),i.status>0)return;let o=Fn(e);const r=document.createElement("script");r.type="text/javascript",r.src=o,function(e){r.onload=function(){On[e].loadCallbacks.forEach((function(t){t(e)})),On[e].status=4},r.onerror=function(){On[e].errorCallbacks.forEach((function(t){t(e)})),On[e].status=0}}(e),document.getElementsByTagName("head")[0].appendChild(r),i.status=3}function zn(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}function Vn(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function Gn(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}const kn={[Ft]:{[Ut]:Vn},[Ut]:{[Ft]:Gn}},Qn={legacyMode:!0,get workingColorSpace(){return Ut},set workingColorSpace(e){console.warn("v3d.ColorManagement: .workingColorSpace is readonly.")},convert:function(e,t,n){if(this.legacyMode||t===n||!t||!n)return e;if(kn[t]&&void 0!==kn[t][n]){const i=kn[t][n];return e.r=i(e.r),e.g=i(e.g),e.b=i(e.b),e}throw new Error("Unsupported color space conversion.")},fromWorkingColorSpace:function(e,t){return this.convert(e,this.workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this.workingColorSpace)}},Wn={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},Hn={r:0,g:0,b:0},jn={h:0,s:0,l:0},Yn={h:0,s:0,l:0};function Xn(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 Kn(e,t){return t.r=e.r,t.g=e.g,t.b=e.b,t}class qn{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,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,t=Ft){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,Qn.toWorkingColorSpace(this,t),this}setRGB(e,t,n,i=Qn.workingColorSpace){return this.r=e,this.g=t,this.b=n,Qn.toWorkingColorSpace(this,i),this}setHSL(e,t,n,i=Qn.workingColorSpace){if(e=on(e,1),t=nn(t,0,1),n=nn(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=Xn(o,i,e+1/3),this.g=Xn(o,i,e),this.b=Xn(o,i,e-1/3)}return Qn.toWorkingColorSpace(this,i),this}setStyle(e,t=Ft){function n(t){void 0!==t&&parseFloat(t)<1&&console.warn("v3d.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^((?:rgb|hsl)a?)\(([^\)]*)\)/.exec(e)){let e;const o=i[1],r=i[2];switch(o){case"rgb":case"rgba":if(e=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))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,Qn.toWorkingColorSpace(this,t),n(e[4]),this;if(e=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r))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,Qn.toWorkingColorSpace(this,t),n(e[4]),this;break;case"hsl":case"hsla":if(e=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(r)){const i=parseFloat(e[1])/360,o=parseFloat(e[2])/100,r=parseFloat(e[3])/100;return n(e[4]),this.setHSL(i,o,r,t)}}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const e=i[1],n=e.length;if(3===n)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,Qn.toWorkingColorSpace(this,t),this;if(6===n)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,Qn.toWorkingColorSpace(this,t),this}return e&&e.length>0?this.setColorName(e,t):this}setColorName(e,t=Ft){const n=Wn[e.toLowerCase()];return void 0!==n?this.setHex(n,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=Vn(e.r),this.g=Vn(e.g),this.b=Vn(e.b),this}copyLinearToSRGB(e){return this.r=Gn(e.r),this.g=Gn(e.g),this.b=Gn(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ft){return Qn.fromWorkingColorSpace(Kn(this,Hn),e),nn(255*Hn.r,0,255)<<16^nn(255*Hn.g,0,255)<<8^nn(255*Hn.b,0,255)<<0}getHexString(e=Ft){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Qn.workingColorSpace){Qn.fromWorkingColorSpace(Kn(this,Hn),t);const n=Hn.r,i=Hn.g,o=Hn.b,r=Math.max(n,i,o),a=Math.min(n,i,o);let s,l;const c=(a+r)/2;if(a===r)s=0,l=0;else{const e=r-a;switch(l=c<=.5?e/(r+a):e/(2-r-a),r){case n:s=(i-o)/e+(i<o?6:0);break;case i:s=(o-n)/e+2;break;case o:s=(n-i)/e+4}s/=6}return e.h=s,e.s=l,e.l=c,e}getRGB(e,t=Qn.workingColorSpace){return Qn.fromWorkingColorSpace(Kn(this,Hn),t),e.r=Hn.r,e.g=Hn.g,e.b=Hn.b,e}getStyle(e=Ft){return Qn.fromWorkingColorSpace(Kn(this,Hn),e),e!==Ft?`color(${e} ${Hn.r} ${Hn.g} ${Hn.b})`:`rgb(${255*Hn.r|0},${255*Hn.g|0},${255*Hn.b|0})`}offsetHSL(e,t,n){return this.getHSL(jn),jn.h+=e,jn.s+=t,jn.l+=n,this.setHSL(jn.h,jn.s,jn.l),this}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(jn),e.getHSL(Yn);const n=rn(jn.h,Yn.h,t),i=rn(jn.s,Yn.s,t),o=rn(jn.l,Yn.l,t);return this.setHSL(n,i,o),this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}let Zn;qn.NAMES=Wn;class Jn{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Zn&&(Zn=Tn("canvas")),Zn.width=e.width,Zn.height=e.height;const n=Zn.getContext("2d");e instanceof ImageData?n.putImageData(e,0,0):n.drawImage(e,0,0,e.width,e.height),t=Zn}return t.width>2048||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=Tn("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;e<o.length;e++)o[e]=255*Vn(o[e]/255);return n.putImageData(i,0,0),t}if(e.data){const t=e.data.slice(0);for(let e=0;e<t.length;e++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[e]=Math.floor(255*Vn(t[e]/255)):t[e]=Vn(t[e]);return{data:t,width:e.width,height:e.height}}return console.warn("v3d.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}class $n{constructor(e=null){this.isSource=!0,this.uuid=tn(),this.data=e,this.version=0}set needsUpdate(e){!0===e&&this.version++}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.images[this.uuid])return e.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(null!==i){let e;if(Array.isArray(i)){e=[];for(let t=0,n=i.length;t<n;t++)i[t].isDataTexture?e.push(ei(i[t].image)):e.push(ei(i[t]))}else e=ei(i);n.url=e}return t||(e.images[this.uuid]=n),n}}function ei(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?Jn.getDataURL(e):e.data?{data:Array.from(e.data),width:e.width,height:e.height,type:e.data.constructor.name}:(console.warn("v3d.Texture: Unable to serialize Texture."),{})}let ti=0;class ni extends qt{constructor(e=ni.DEFAULT_IMAGE,t=ni.DEFAULT_MAPPING,n=he,i=he,o=ve,r=_e,a=Be,s=xe,l=ni.DEFAULT_ANISOTROPY,c=It){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ti++}),this.uuid=tn(),this.name="",this.source=new $n(e),this.mipmaps=[],this.mapping=t,this.wrapS=n,this.wrapT=i,this.magFilter=o,this.minFilter=r,this.anisotropy=l,this.format=a,this.internalFormat=null,this.type=s,this.offset=new yn(0,0),this.repeat=new yn(1,1),this.center=new yn(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new bn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.encoding=c,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.needsPMREMUpdate=!1}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return(new this.constructor).copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.encoding=e.encoding,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}toJSON(e){const t=void 0===e||"string"==typeof e;if(!t&&void 0!==e.textures[this.uuid])return e.textures[this.uuid];const n={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==re)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case de:e.x=e.x-Math.floor(e.x);break;case he:e.x=e.x<0?0:1;break;case pe: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 de:e.y=e.y-Math.floor(e.y);break;case he:e.y=e.y<0?0:1;break;case pe: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++,this.source.needsUpdate=!0)}}ni.DEFAULT_IMAGE=null,ni.DEFAULT_MAPPING=re,ni.DEFAULT_ANISOTROPY=1;class ii{constructor(e=0,t=0,n=0,i=1){ii.prototype.isVector4=!0,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){return 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){return 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)<r&&Math.abs(u-f)<r&&Math.abs(p-m)<r){if(Math.abs(c+d)<a&&Math.abs(u+f)<a&&Math.abs(p+m)<a&&Math.abs(l+h+g-3)<a)return this.set(1,0,0,0),this;t=Math.PI;const e=(l+1)/2,s=(h+1)/2,v=(g+1)/2,A=(c+d)/4,_=(u+f)/4,x=(p+m)/4;return e>s&&e>v?e<r?(n=0,i=.707106781,o=.707106781):(n=Math.sqrt(e),i=A/n,o=_/n):s>v?s<r?(n=.707106781,i=0,o=.707106781):(i=Math.sqrt(s),n=A/i,o=x/i):v<r?(n=.707106781,i=.707106781,o=0):(o=Math.sqrt(v),n=_/o,i=x/o),this.set(n,i,o,t),this}let v=Math.sqrt((m-p)*(m-p)+(u-f)*(u-f)+(d-c)*(d-c));return Math.abs(v)<.001&&(v=1),this.x=(m-p)/v,this.y=(u-f)/v,this.z=(d-c)/v,this.w=Math.acos((l+h+g-1)/2),this}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.w=Math.min(this.w,e.w),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.w=Math.max(this.w,e.w),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.w=Math.max(e.w,Math.min(t.w,this.w)),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.w=Math.max(e,Math.min(t,this.w)),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.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),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.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}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.w+=(e.w-this.w)*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.w=e.w+(t.w-e.w)*n,this}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}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}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class oi extends qt{constructor(e=1,t=1,n={}){super(),this.isWebGLRenderTarget=!0,this.width=e,this.height=t,this.depth=1,this.scissor=new ii(0,0,e,t),this.scissorTest=!1,this.viewport=new ii(0,0,e,t);const i={width:e,height:t,depth:1};this.texture=new ni(i,n.mapping,n.wrapS,n.wrapT,n.magFilter,n.minFilter,n.format,n.type,n.anisotropy,n.encoding),this.texture.isRenderTargetTexture=!0,this.texture.flipY=!1,this.texture.generateMipmaps=void 0!==n.generateMipmaps&&n.generateMipmaps,this.texture.internalFormat=void 0!==n.internalFormat?n.internalFormat:null,this.texture.minFilter=void 0!==n.minFilter?n.minFilter:ve,this.depthBuffer=void 0===n.depthBuffer||n.depthBuffer,this.stencilBuffer=void 0!==n.stencilBuffer&&n.stencilBuffer,this.depthTexture=void 0!==n.depthTexture?n.depthTexture:null,this.samples=void 0!==n.samples?n.samples:0}setSize(e,t,n=1){this.width===e&&this.height===t&&this.depth===n||(this.width=e,this.height=t,this.depth=n,this.texture.image.width=e,this.texture.image.height=t,this.texture.image.depth=n,this.dispose()),this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return(new this.constructor).copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.copy(e.viewport),this.texture=e.texture.clone(),this.texture.isRenderTargetTexture=!0;const t=Object.assign({},e.texture.image);return this.texture.source=new $n(t),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class ri extends ni{constructor(e=null,t=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=fe,this.minFilter=fe,this.wrapR=he,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ai extends ni{constructor(e=null,t=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:i},this.magFilter=fe,this.minFilter=fe,this.wrapR=he,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class si extends oi{constructor(e=1,t=1,n=1,i={}){super(e,t,i),this.isWebGLMultipleRenderTargets=!0;const o=this.texture;this.texture=[];for(let e=0;e<n;e++)this.texture[e]=o.clone(),this.texture[e].isRenderTargetTexture=!0}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let i=0,o=this.texture.length;i<o;i++)this.texture[i].image.width=e,this.texture[i].image.height=t,this.texture[i].image.depth=n;this.dispose()}return this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t),this}copy(e){this.dispose(),this.width=e.width,this.height=e.height,this.depth=e.depth,this.viewport.set(0,0,this.width,this.height),this.scissor.set(0,0,this.width,this.height),this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,null!==e.depthTexture&&(this.depthTexture=e.depthTexture.clone()),this.texture.length=0;for(let t=0,n=e.texture.length;t<n;t++)this.texture[t]=e.texture[t].clone(),this.texture[t].isRenderTargetTexture=!0;return this}}class li{constructor(e=0,t=0,n=0,i=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=i}static slerpFlat(e,t,n,i,o,r,a){let s=n[i+0],l=n[i+1],c=n[i+2],u=n[i+3];const d=o[r+0],h=o[r+1],p=o[r+2],f=o[r+3];if(0===a)return e[t+0]=s,e[t+1]=l,e[t+2]=c,void(e[t+3]=u);if(1===a)return e[t+0]=d,e[t+1]=h,e[t+2]=p,void(e[t+3]=f);if(u!==f||s!==d||l!==h||c!==p){let e=1-a;const t=s*d+l*h+c*p+u*f,n=t>=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){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 n<Number.EPSILON?(n=0,Math.abs(e.x)>Math.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(nn(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){return 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(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ci{constructor(e=0,t=0,n=0){ci.prototype.isVector3=!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){return 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){return 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){return 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 this.applyQuaternion(di.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(di.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){return 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 ui.copy(this).projectOnVector(e),this.sub(ui)}reflect(e){return this.sub(ui.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(nn(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)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}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){return 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}}const ui=new ci,di=new li;class hi{constructor(e=new ci(1/0,1/0,1/0),t=new ci(-1/0,-1/0,-1/0)){this.isBox3=!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;s<l;s+=3){const l=e[s],c=e[s+1],u=e[s+2];l<t&&(t=l),c<n&&(n=c),u<i&&(i=u),l>o&&(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;s<l;s++){const l=e.getX(s),c=e.getY(s),u=e.getZ(s);l<t&&(t=l),c<n&&(n=c),u<i&&(i=u),l>o&&(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;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=fi.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(void 0!==n)if(t&&null!=n.attributes&&void 0!==n.attributes.position){const t=n.attributes.position;for(let n=0,i=t.count;n<i;n++)fi.fromBufferAttribute(t,n).applyMatrix4(e.matrixWorld),this.expandByPoint(fi)}else null===n.boundingBox&&n.computeBoundingBox(),mi.copy(n.boundingBox),mi.applyMatrix4(e.matrixWorld),this.union(mi);const i=e.children;for(let e=0,n=i.length;e<n;e++)this.expandByObject(i[e],t);return this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsSphere(e){return this.clampPoint(e.center,fi),fi.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(bi),Ci.subVectors(this.max,bi),gi.subVectors(e.a,bi),vi.subVectors(e.b,bi),Ai.subVectors(e.c,bi),_i.subVectors(vi,gi),xi.subVectors(Ai,vi),yi.subVectors(gi,Ai);let t=[0,-_i.z,_i.y,0,-xi.z,xi.y,0,-yi.z,yi.y,_i.z,0,-_i.x,xi.z,0,-xi.x,yi.z,0,-yi.x,-_i.y,_i.x,0,-xi.y,xi.x,0,-yi.y,yi.x,0];return!!Ei(t,gi,vi,Ai,Ci)&&(t=[1,0,0,0,1,0,0,0,1],!!Ei(t,gi,vi,Ai,Ci)&&(Mi.crossVectors(_i,xi),t=[Mi.x,Mi.y,Mi.z],Ei(t,gi,vi,Ai,Ci)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return fi.copy(e).clamp(this.min,this.max).sub(e).length()}getBoundingSphere(e){return this.getCenter(e.center),e.radius=.5*this.getSize(fi).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()||(pi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),pi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),pi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),pi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),pi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),pi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),pi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),pi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(pi)),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)}scale(e){return this.getCenter(bi),Ci.subVectors(this.max,bi),Ci.multiply(e),this.min.copy(bi).sub(Ci),this.max.copy(bi).add(Ci),this}}const pi=[new ci,new ci,new ci,new ci,new ci,new ci,new ci,new ci],fi=new ci,mi=new hi,gi=new ci,vi=new ci,Ai=new ci,_i=new ci,xi=new ci,yi=new ci,bi=new ci,Ci=new ci,Mi=new ci,Si=new ci;function Ei(e,t,n,i,o){for(let r=0,a=e.length-3;r<=a;r+=3){Si.fromArray(e,r);const a=o.x*Math.abs(Si.x)+o.y*Math.abs(Si.y)+o.z*Math.abs(Si.z),s=t.dot(Si),l=n.dot(Si),c=i.dot(Si);if(Math.max(-Math.max(s,l,c),Math.min(s,l,c))>a)return!1}return!0}const wi=new hi,Ti=new ci,Ii=new ci;class Ri{constructor(e=new ci,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):wi.setFromPoints(e).getCenter(n);let i=0;for(let t=0,o=e.length;t<o;t++)i=Math.max(i,n.distanceToSquared(e[t]));return this.radius=Math.sqrt(i),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.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){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Ti.subVectors(e,this.center);const t=Ti.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),n=.5*(e-this.radius);this.center.addScaledVector(Ti,n/e),this.radius+=n}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Ii.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Ti.copy(e.center).add(Ii)),this.expandByPoint(Ti.copy(e.center).sub(Ii))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Li=new ci,Pi=new ci,Bi=new ci,Di=new ci,Ni=new ci,Oi=new ci,Fi=new ci;class Ui{constructor(e=new ci,t=new ci(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,Li)),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=Li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Li.copy(this.direction).multiplyScalar(t).add(this.origin),Li.distanceToSquared(e))}distanceSqToSegment(e,t,n,i){Pi.copy(e).add(t).multiplyScalar(.5),Bi.copy(t).sub(e).normalize(),Di.copy(this.origin).sub(Pi);const o=.5*e.distanceTo(t),r=-this.direction.dot(Bi),a=Di.dot(this.direction),s=-Di.dot(Bi),l=Di.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(Bi).multiplyScalar(d).add(Pi),h}intersectSphere(e,t){Li.subVectors(e.center,this.origin);const n=Li.dot(this.direction),i=Li.dot(Li)-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||isNaN(n))&&(n=o),(r<i||isNaN(i))&&(i=r),u>=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<i||i!=i)&&(i=s),i<0?null:this.at(n>=0?n:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Li)}intersectTriangle(e,t,n,i,o){Ni.subVectors(t,e),Oi.subVectors(n,e),Fi.crossVectors(Ni,Oi);let r,a=this.direction.dot(Fi);if(a>0){if(i)return null;r=1}else{if(!(a<0))return null;r=-1,a=-a}Di.subVectors(this.origin,e);const s=r*this.direction.dot(Oi.crossVectors(Di,Oi));if(s<0)return null;const l=r*this.direction.dot(Ni.cross(Di));if(l<0)return null;if(s+l>a)return null;const c=-r*Di.dot(Fi);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 zi{constructor(){zi.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}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 zi).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/Vi.setFromMatrixColumn(e,0).length(),o=1/Vi.setFromMatrixColumn(e,1).length(),r=1/Vi.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){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(ki,e,Qi)}lookAt(e,t,n){const i=this.elements;return ji.subVectors(e,t),0===ji.lengthSq()&&(ji.z=1),ji.normalize(),Wi.crossVectors(n,ji),0===Wi.lengthSq()&&(1===Math.abs(n.z)?ji.x+=1e-4:ji.z+=1e-4,ji.normalize(),Wi.crossVectors(n,ji)),Wi.normalize(),Hi.crossVectors(ji,Wi),i[0]=Wi.x,i[4]=Hi.x,i[8]=ji.x,i[1]=Wi.y,i[5]=Hi.y,i[9]=ji.y,i[2]=Wi.z,i[6]=Hi.z,i[10]=ji.z,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[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],C=i[8],M=i[12],S=i[1],E=i[5],w=i[9],T=i[13],I=i[2],R=i[6],L=i[10],P=i[14],B=i[3],D=i[7],N=i[11],O=i[15];return o[0]=r*y+a*S+s*I+l*B,o[4]=r*b+a*E+s*R+l*D,o[8]=r*C+a*w+s*L+l*N,o[12]=r*M+a*T+s*P+l*O,o[1]=c*y+u*S+d*I+h*B,o[5]=c*b+u*E+d*R+h*D,o[9]=c*C+u*w+d*L+h*N,o[13]=c*M+u*T+d*P+h*O,o[2]=p*y+f*S+m*I+g*B,o[6]=p*b+f*E+m*R+g*D,o[10]=p*C+f*w+m*L+g*N,o[14]=p*M+f*T+m*P+g*O,o[3]=v*y+A*S+_*I+x*B,o[7]=v*b+A*E+_*R+x*D,o[11]=v*C+A*w+_*L+x*N,o[15]=v*M+A*T+_*P+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=Vi.set(i[0],i[1],i[2]).length();const r=Vi.set(i[4],i[5],i[6]).length(),a=Vi.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],Gi.copy(this);const s=1/o,l=1/r,c=1/a;return Gi.elements[0]*=s,Gi.elements[1]*=s,Gi.elements[2]*=s,Gi.elements[4]*=l,Gi.elements[5]*=l,Gi.elements[6]*=l,Gi.elements[8]*=c,Gi.elements[9]*=c,Gi.elements[10]*=c,t.setFromRotationMatrix(Gi),n.x=o,n.y=r,n.z=a,this}makePerspective(e,t,n,i,o,r){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=Vi.set(o[0],o[1],o[2]).length();const a=Vi.set(o[4],o[5],o[6]).length(),s=Vi.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],Gi.copy(this);const l=1/r,c=1/a,u=1/s;return Gi.elements[0]*=l,Gi.elements[1]*=l,Gi.elements[2]*=l,Gi.elements[4]*=c,Gi.elements[5]*=c,Gi.elements[6]*=c,Gi.elements[8]*=u,Gi.elements[9]*=u,Gi.elements[10]*=u,t.setFromRotationMatrix(Gi,i),n.x=r,n.y=a,n.z=s,this}}const Vi=new ci,Gi=new zi,ki=new ci(0,0,0),Qi=new ci(1,1,1),Wi=new ci,Hi=new ci,ji=new ci,Yi=new zi,Xi=new li;class Ki{constructor(e=0,t=0,n=0,i=Ki.DefaultOrder){this.isEuler=!0,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(nn(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(-nn(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(nn(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(-nn(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(nn(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(-nn(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 Yi.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Yi,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Xi.setFromEuler(this),this.setFromQuaternion(Xi,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}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}toVector3(e){return console.warn("v3d.Euler: .toVector3() has been removed. Use Vector3.setFromEuler() instead"),e?e.set(this._x,this._y,this._z):new ci(this._x,this._y,this._z)}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=An(e*(this._x+Math.PI)),this._y=An(t*(this._y+Math.PI)),this._z=An(n*(this._z+Math.PI)),this}equalsEps(e,t){return Math.abs(this._x-e._x)<t&&Math.abs(this._y-e._y)<t&&Math.abs(this._z-e._z)<t&&this._order===e._order}}Ki.DefaultOrder="XYZ",Ki.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"];class qi{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return 0!=(this.mask&e.mask)}isEnabled(e){return 0!=(this.mask&(1<<e|0))}}let Zi=0;const Ji=new ci,$i=new li,eo=new zi,to=new ci,no=new ci,io=new ci,oo=new li,ro=new ci(1,0,0),ao=new ci(0,1,0),so=new ci(0,0,1),lo={type:"added"},co={type:"removed"};class uo extends qt{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Zi++}),this.uuid=tn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=uo.DefaultUp.clone();const e=new ci,t=new Ki,n=new li,i=new ci(1,1,1);t._onChange((function(){n.setFromEuler(t,!1)})),n._onChange((function(){t.setFromQuaternion(n,void 0,!1)})),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new zi},normalMatrix:{value:new bn}}),this.matrix=new zi,this.matrixWorld=new zi,this.matrixAutoUpdate=uo.DefaultMatrixAutoUpdate,this.matrixWorldNeedsUpdate=!1,this.matrixWorldAutoUpdate=uo.DefaultMatrixWorldAutoUpdate,this.layers=new qi,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={},this.internVisible=!0,this.externVisible=!0,this.constraints=[],this.disableChildRendering=!1,this.hidpiCompositing=!1,this.groupNames=[],this.objectIndex=0,this.objectColor=new qn,this.objectAlpha=1}set visible(e){this.externVisible=e}get visible(){return this.internVisible&&this.externVisible}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return $i.setFromAxisAngle(e,t),this.quaternion.multiply($i),this}rotateOnWorldAxis(e,t){return $i.setFromAxisAngle(e,t),this.quaternion.premultiply($i),this}rotateX(e){return this.rotateOnAxis(ro,e)}rotateY(e){return this.rotateOnAxis(ao,e)}rotateZ(e){return this.rotateOnAxis(so,e)}translateOnAxis(e,t){return Ji.copy(e).applyQuaternion(this.quaternion),this.position.add(Ji.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(ro,e)}translateY(e){return this.translateOnAxis(ao,e)}translateZ(e){return this.translateOnAxis(so,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(eo.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?to.copy(e):to.set(e,t,n);const i=this.parent;this.updateWorldMatrix(!0,!1),no.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?eo.lookAt(no,to,this.up):eo.lookAt(to,no,this.up),this.quaternion.setFromRotationMatrix(eo),i&&(eo.extractRotation(i.matrixWorld),$i.setFromRotationMatrix(eo),this.quaternion.premultiply($i.invert()))}add(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return e===this?(console.error("v3d.Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(null!==e.parent&&e.parent.remove(e),e.parent=this,this.children.push(e),e.dispatchEvent(lo)):console.error("v3d.Object3D.add: object not an instance of v3d.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.remove(arguments[e]);return this}const t=this.children.indexOf(e);return-1!==t&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(co)),this}removeFromParent(){const e=this.parent;return null!==e&&e.remove(this),this}clear(){for(let e=0;e<this.children.length;e++){const t=this.children[e];t.parent=null,t.dispatchEvent(co)}return this.children.length=0,this}attach(e){return this.updateWorldMatrix(!0,!1),eo.copy(this.matrixWorld).invert(),null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),eo.multiply(e.parent.matrixWorld)),e.applyMatrix4(eo),this.add(e),e.updateWorldMatrix(!1,!0),this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,i=this.children.length;n<i;n++){const i=this.children[n].getObjectByProperty(e,t);if(void 0!==i)return i}}getObjectsByProperty(e,t){let n=[];this[e]===t&&n.push(this);for(let i=0,o=this.children.length;i<o;i++){const o=this.children[i].getObjectsByProperty(e,t);o.length>0&&(n=n.concat(o))}return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(no,e,io),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(no,oo,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[4],t[5],t[6]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverse(e)}traverseVisible(e){if(!1===this.visible)return;e(this);const t=this.children;for(let n=0,i=t.length;n<i;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;null!==t&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.updateConstraints(),this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,i=t.length;n<i;n++){const i=t[n];!0!==i.matrixWorldAutoUpdate&&!0!==e||i.updateMatrixWorld(e)}}updateWorldMatrix(e,t){const n=this.parent;if(!0===e&&null!==n&&!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),!0===t){const e=this.children;for(let t=0,n=e.length;t<n;t++){const n=e[t];!0===n.matrixWorldAutoUpdate&&n.updateWorldMatrix(!1,!0)}}}toJSON(e){const t=void 0===e||"string"==typeof e,n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});const i={};function o(t,n){return void 0===t[n.uuid]&&(t[n.uuid]=n.toJSON(e)),n.uuid}if(i.uuid=this.uuid,i.type=this.type,""!==this.name&&(i.name=this.name),!0===this.castShadow&&(i.castShadow=!0),!0===this.receiveShadow&&(i.receiveShadow=!0),!1===this.visible&&(i.visible=!1),!1===this.frustumCulled&&(i.frustumCulled=!1),0!==this.renderOrder&&(i.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(i.userData=this.userData),!1===this.disableChildRendering&&(i.disableChildRendering=!1),!0===this.hidpiCompositing&&(i.hidpiCompositing=!0),0!==this.objectIndex&&(i.objectIndex=this.objectIndex),this.objectColor&&this.objectColor.isColor&&(i.objectColor=this.objectColor.getHex()),1!==this.objectAlpha&&(i.objectAlpha=this.objectAlpha),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=o(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const n=t.shapes;if(Array.isArray(n))for(let t=0,i=n.length;t<i;t++){const i=n[t];o(e.shapes,i)}else o(e.shapes,n)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),void 0!==this.skeleton&&(o(e.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),void 0!==this.material)if(Array.isArray(this.material)){const t=[];for(let n=0,i=this.material.length;n<i;n++)t.push(o(e.materials,this.material[n]));i.material=t}else i.material=o(e.materials,this.material);if(this.children.length>0){i.children=[];for(let t=0;t<this.children.length;t++)i.children.push(this.children[t].toJSON(e).object)}if(this.animations.length>0){i.animations=[];for(let t=0;t<this.animations.length;t++){const n=this.animations[t];i.animations.push(o(e.animations,n))}}if(t){const t=r(e.geometries),i=r(e.materials),o=r(e.textures),a=r(e.images),s=r(e.shapes),l=r(e.skeletons),c=r(e.animations),u=r(e.nodes);t.length>0&&(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),u.length>0&&(n.nodes=u)}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.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,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;t<e.constraints.length;t++)this.constraints.push(e.constraints[t].clone());if(this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const n=e.children[t];this.add(n.clone())}return this}copyTransform(e){this.matrix.copy(e.matrixWorld),this.parent&&this.matrix.multiplyMatrices(eo.copy(this.parent.matrixWorld).invert(),this.matrix),this.matrix.decompose(this.position,this.quaternion,this.scale)}isVisible(){return this.visible}updateConstraints(){for(let e=0;e<this.constraints.length;e++)this.constraints[e].update(this)}getWorldPositionNU(e){return e.setFromMatrixPosition(this.matrixWorld)}getLocalDirection(e){const t=this.matrix.elements;return this.isCamera||this.isLight?e.set(-t[8],-t[9],-t[10]).normalize():e.set(t[8],t[9],t[10]).normalize()}lookAtLocal(e,t,n){e.isVector3?to.copy(e):to.set(e,t,n),no.setFromMatrixPosition(this.matrix),this.isCamera||this.isLight?eo.lookAt(no,to,this.up):eo.lookAt(to,no,this.up),this.quaternion.setFromRotationMatrix(eo)}findRoot(){let e=this;return this.traverseAncestors((function(t){e=t})),e}resolveMultiMaterial(){const e=[];for(let t=0;t<this.children.length;t++){const n=this.children[t];n.isMesh&&n.isMaterialGeneratedMesh&&e.push(n)}return e.length||e.push(this),e}getAuxClippingMeshes(){const e=[];for(let t=0;t<this.children.length;t++){const n=this.children[t];n.isMesh&&n.isAuxClippingMesh&&e.push(n)}return e}getWorldEuler(e,t=e._order){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decomposeE(no,e,io,t),e}}uo.DefaultUp=new ci(0,1,0),uo.DefaultMatrixAutoUpdate=!0,uo.DefaultMatrixWorldAutoUpdate=!0;const ho=new ci,po=new ci,fo=new ci,mo=new ci,go=new ci,vo=new ci,Ao=new ci,_o=new ci,xo=new ci,yo=new ci;class bo{constructor(e=new ci,t=new ci,n=new ci){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,i){i.subVectors(n,t),ho.subVectors(e,t),i.cross(ho);const o=i.lengthSq();return o>0?i.multiplyScalar(1/Math.sqrt(o)):i.set(0,0,0)}static getBarycoord(e,t,n,i,o){ho.subVectors(i,t),po.subVectors(n,t),fo.subVectors(e,t);const r=ho.dot(ho),a=ho.dot(po),s=ho.dot(fo),l=po.dot(po),c=po.dot(fo),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,mo),mo.x>=0&&mo.y>=0&&mo.x+mo.y<=1}static getUV(e,t,n,i,o,r,a,s){return this.getBarycoord(e,t,n,i,mo),s.set(0,0),s.addScaledVector(o,mo.x),s.addScaledVector(r,mo.y),s.addScaledVector(a,mo.z),s}static isFrontFacing(e,t,n,i){return ho.subVectors(n,t),po.subVectors(e,t),ho.cross(po).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 ho.subVectors(this.c,this.b),po.subVectors(this.a,this.b),.5*ho.cross(po).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return bo.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return bo.getBarycoord(e,this.a,this.b,this.c,t)}getUV(e,t,n,i,o){return bo.getUV(e,this.a,this.b,this.c,t,n,i,o)}containsPoint(e){return bo.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return bo.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;go.subVectors(i,n),vo.subVectors(o,n),_o.subVectors(e,n);const s=go.dot(_o),l=vo.dot(_o);if(s<=0&&l<=0)return t.copy(n);xo.subVectors(e,i);const c=go.dot(xo),u=vo.dot(xo);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(go,r);yo.subVectors(e,o);const h=go.dot(yo),p=vo.dot(yo);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(vo,a);const m=c*p-h*u;if(m<=0&&u-c>=0&&h-p>=0)return Ao.subVectors(o,i),a=(u-c)/(u-c+(h-p)),t.copy(i).addScaledVector(Ao,a);const g=1/(m+f+d);return r=f*g,a=d*g,t.copy(n).addScaledVector(go,r).addScaledVector(vo,a)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}let Co=0;class Mo extends qt{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Co++}),this.uuid=tn(),this.name="",this.type="Material",this.blending=A,this.side=p,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.blendSrc=P,this.blendDst=B,this.blendEquation=C,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.depthFunc=k,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=519,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=zt,this.stencilZFail=zt,this.stencilZPass=zt,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.depthPrepass=!1,this.receiveShadow=!1,this.castShadow=!1,this.profile="",this.defines={},this.definesFragOnly=[],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}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()),void 0!==this.iridescence&&(n.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(n.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),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&&this.attenuationDistance!==1/0&&(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),this.blending!==A&&(n.blending=this.blending),this.side!==p&&(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,void 0!==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),void 0!==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),!1===this.fog&&(n.fog=!1),Object.keys(this.userData).length>0&&(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.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.depthPrepass=e.depthPrepass,this.defines=Object.assign({},e.defines),this.definesFragOnly=e.definesFragOnly.slice(),this.receiveShadow=e.receiveShadow,this.castShadow=e.castShadow,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}}class So extends Mo{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new qn(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=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,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.fog=e.fog,this}}const Eo=new ci,wo=new yn;class To{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("v3d.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=n,this.usage=Qt,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;i<o;i++)this.array[e+i]=t.array[n+i];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(2===this.itemSize)for(let t=0,n=this.count;t<n;t++)wo.fromBufferAttribute(this,t),wo.applyMatrix3(e),this.setXY(t,wo.x,wo.y);else if(3===this.itemSize)for(let t=0,n=this.count;t<n;t++)Eo.fromBufferAttribute(this,t),Eo.applyMatrix3(e),this.setXYZ(t,Eo.x,Eo.y,Eo.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Eo.fromBufferAttribute(this,t),Eo.applyMatrix4(e),this.setXYZ(t,Eo.x,Eo.y,Eo.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Eo.fromBufferAttribute(this,t),Eo.applyNormalMatrix(e),this.setXYZ(t,Eo.x,Eo.y,Eo.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Eo.fromBufferAttribute(this,t),Eo.transformDirection(e),this.setXYZ(t,Eo.x,Eo.y,Eo.z);return this}set(e,t=0){return this.array.set(e,t),this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=hn(t,this.array)),t}setX(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=hn(t,this.array)),t}setY(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=hn(t,this.array)),t}setZ(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=hn(t,this.array)),t}setW(e,t){return this.normalized&&(t=pn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,i){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array),i=pn(i,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this}setXYZW(e,t,n,i,o){return e*=this.itemSize,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array),i=pn(i,this.array),o=pn(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=i,this.array[e+3]=o,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return""!==this.name&&(e.name=this.name),this.usage!==Qt&&(e.usage=this.usage),0===this.updateRange.offset&&-1===this.updateRange.count||(e.updateRange=this.updateRange),e}copyColorsArray(){console.error("v3d.BufferAttribute: copyColorsArray() was removed in r144.")}copyVector2sArray(){console.error("v3d.BufferAttribute: copyVector2sArray() was removed in r144.")}copyVector3sArray(){console.error("v3d.BufferAttribute: copyVector3sArray() was removed in r144.")}copyVector4sArray(){console.error("v3d.BufferAttribute: copyVector4sArray() was removed in r144.")}}class Io extends To{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Ro extends To{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Lo extends To{constructor(e,t,n){super(new Float32Array(e),t,n)}}let Po=0;const Bo=new zi,Do=new uo,No=new ci,Oo=new hi,Fo=new hi,Uo=new ci;class zo extends qt{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Po++}),this.uuid=tn(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Sn(e)?Ro:Io)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(void 0!==n){const t=(new bn).getNormalMatrix(e);n.applyNormalMatrix(t),n.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return Bo.makeRotationFromQuaternion(e),this.applyMatrix4(Bo),this}rotateX(e){return Bo.makeRotationX(e),this.applyMatrix4(Bo),this}rotateY(e){return Bo.makeRotationY(e),this.applyMatrix4(Bo),this}rotateZ(e){return Bo.makeRotationZ(e),this.applyMatrix4(Bo),this}translate(e,t,n){return Bo.makeTranslation(e,t,n),this.applyMatrix4(Bo),this}scale(e,t,n){return Bo.makeScale(e,t,n),this.applyMatrix4(Bo),this}lookAt(e){return Do.lookAt(e),Do.updateMatrix(),this.applyMatrix4(Do.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(No).negate(),this.translate(No.x,No.y,No.z),this}setFromPoints(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n];t.push(i.x,i.y,i.z||0)}return this.setAttribute("position",new Lo(t,3)),this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new hi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('v3d.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingBox.set(new ci(-1/0,-1/0,-1/0),new ci(1/0,1/0,1/0));if(void 0!==e){if(this.boundingBox.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Oo.setFromBufferAttribute(n),this.morphTargetsRelative?(Uo.addVectors(this.boundingBox.min,Oo.min),this.boundingBox.expandByPoint(Uo),Uo.addVectors(this.boundingBox.max,Oo.max),this.boundingBox.expandByPoint(Uo)):(this.boundingBox.expandByPoint(Oo.min),this.boundingBox.expandByPoint(Oo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('v3d.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new Ri);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute)return console.error('v3d.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere. Alternatively set "mesh.frustumCulled" to "false".',this),void this.boundingSphere.set(new ci,1/0);if(e){const n=this.boundingSphere.center;if(Oo.setFromBufferAttribute(e),t)for(let e=0,n=t.length;e<n;e++){const n=t[e];Fo.setFromBufferAttribute(n),this.morphTargetsRelative?(Uo.addVectors(Oo.min,Fo.min),Oo.expandByPoint(Uo),Uo.addVectors(Oo.max,Fo.max),Oo.expandByPoint(Uo)):(Oo.expandByPoint(Fo.min),Oo.expandByPoint(Fo.max))}Oo.getCenter(n);let i=0;for(let t=0,o=e.count;t<o;t++)Uo.fromBufferAttribute(e,t),i=Math.max(i,n.distanceToSquared(Uo));if(t)for(let o=0,r=t.length;o<r;o++){const r=t[o],a=this.morphTargetsRelative;for(let t=0,o=r.count;t<o;t++)Uo.fromBufferAttribute(r,t),a&&(No.fromBufferAttribute(e,t),Uo.add(No)),i=Math.max(i,n.distanceToSquared(Uo))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error('v3d.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(null===e||void 0===t.position||void 0===t.normal||void 0===t.uv)return void console.error("v3d.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");const n=e.array,i=t.position.array,o=t.normal.array,r=t.uv.array,a=i.length/3;!1===this.hasAttribute("tangent")&&this.setAttribute("tangent",new To(new Float32Array(4*a),4));const s=this.getAttribute("tangent").array,l=[],c=[];for(let e=0;e<a;e++)l[e]=new ci,c[e]=new ci;const u=new ci,d=new ci,h=new ci,p=new yn,f=new yn,m=new yn,g=new ci,v=new ci;function A(e,t,n){u.fromArray(i,3*e),d.fromArray(i,3*t),h.fromArray(i,3*n),p.fromArray(r,2*e),f.fromArray(r,2*t),m.fromArray(r,2*n),d.sub(u),h.sub(u),f.sub(p),m.sub(p);const o=1/(f.x*m.y-m.x*f.y);isFinite(o)&&(g.copy(d).multiplyScalar(m.y).addScaledVector(h,-f.y).multiplyScalar(o),v.copy(h).multiplyScalar(f.x).addScaledVector(d,-m.x).multiplyScalar(o),l[e].add(g),l[t].add(g),l[n].add(g),c[e].add(v),c[t].add(v),c[n].add(v))}let _=this.groups;0===_.length&&(_=[{start:0,count:n.length}]);for(let e=0,t=_.length;e<t;++e){const t=_[e],i=t.start;for(let e=i,o=i+t.count;e<o;e+=3)A(n[e+0],n[e+1],n[e+2])}const x=new ci,y=new ci,b=new ci,C=new ci;function M(e){b.fromArray(o,3*e),C.copy(b);const t=l[e];x.copy(t),x.sub(b.multiplyScalar(b.dot(t))).normalize(),y.crossVectors(C,t);const n=y.dot(c[e])<0?-1:1;s[4*e]=x.x,s[4*e+1]=x.y,s[4*e+2]=x.z,s[4*e+3]=n}for(let e=0,t=_.length;e<t;++e){const t=_[e],i=t.start;for(let e=i,o=i+t.count;e<o;e+=3)M(n[e+0]),M(n[e+1]),M(n[e+2])}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(void 0!==t){let n=this.getAttribute("normal");if(void 0===n)n=new To(new Float32Array(3*t.count),3),this.setAttribute("normal",n);else for(let e=0,t=n.count;e<t;e++)n.setXYZ(e,0,0,0);const i=new ci,o=new ci,r=new ci,a=new ci,s=new ci,l=new ci,c=new ci,u=new ci;if(e)for(let d=0,h=e.count;d<h;d+=3){const h=e.getX(d+0),p=e.getX(d+1),f=e.getX(d+2);i.fromBufferAttribute(t,h),o.fromBufferAttribute(t,p),r.fromBufferAttribute(t,f),c.subVectors(r,o),u.subVectors(i,o),c.cross(u),a.fromBufferAttribute(n,h),s.fromBufferAttribute(n,p),l.fromBufferAttribute(n,f),a.add(c),s.add(c),l.add(c),n.setXYZ(h,a.x,a.y,a.z),n.setXYZ(p,s.x,s.y,s.z),n.setXYZ(f,l.x,l.y,l.z)}else for(let e=0,a=t.count;e<a;e+=3)i.fromBufferAttribute(t,e+0),o.fromBufferAttribute(t,e+1),r.fromBufferAttribute(t,e+2),c.subVectors(r,o),u.subVectors(i,o),c.cross(u),n.setXYZ(e+0,c.x,c.y,c.z),n.setXYZ(e+1,c.x,c.y,c.z),n.setXYZ(e+2,c.x,c.y,c.z);this.normalizeNormals(),n.needsUpdate=!0}}merge(){return console.error("v3d.BufferGeometry.merge() has been removed. Use v3d.BufferGeometryUtils.mergeBufferGeometries() instead."),this}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Uo.fromBufferAttribute(e,t),Uo.normalize(),e.setXYZ(t,Uo.x,Uo.y,Uo.z)}toNonIndexed(){function e(e,t){const n=e.array,i=e.itemSize,o=e.normalized,r=new n.constructor(t.length*i);let a=0,s=0;for(let o=0,l=t.length;o<l;o++){a=e.isInterleavedBufferAttribute?t[o]*e.data.stride+e.offset:t[o]*i;for(let e=0;e<i;e++)r[s++]=n[a++]}return new To(r,i,o)}if(null===this.index)return console.warn("v3d.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new zo,n=this.index.array,i=this.attributes;for(const o in i){const r=e(i[o],n);t.setAttribute(o,r)}const o=this.morphAttributes;for(const i in o){const r=[],a=o[i];for(let t=0,i=a.length;t<i;t++){const i=e(a[t],n);r.push(i)}t.morphAttributes[i]=r}t.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let e=0,n=r.length;e<n;e++){const n=r[e];t.addGroup(n.start,n.count,n.materialIndex)}return t}toJSON(){const e={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),Object.keys(this.userData).length>0&&(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;t<i;t++){const i=n[t];r.push(i.toJSON(e.data))}r.length>0&&(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;e<o;e++)n.push(i[e].clone(t));this.morphAttributes[e]=n}this.morphTargetsRelative=e.morphTargetsRelative;const r=e.groups;for(let e=0,t=r.length;e<t;e++){const t=r[e];this.addGroup(t.start,t.count,t.materialIndex)}const a=e.boundingBox;null!==a&&(this.boundingBox=a.clone());const s=e.boundingSphere;return null!==s&&(this.boundingSphere=s.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,void 0!==e.parameters&&(this.parameters=Object.assign({},e.parameters)),this}dispose(){this.dispatchEvent({type:"dispose"})}}const Vo=new zi,Go=new Ui,ko=new Ri,Qo=new ci,Wo=new ci,Ho=new ci,jo=new ci,Yo=new ci,Xo=new ci,Ko=new ci,qo=new ci,Zo=new ci,Jo=new yn,$o=new yn,er=new yn,tr=new ci,nr=new ci;class ir extends uo{constructor(e=new zo,t=new So){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.updateMorphTargets(),this.isMaterialGeneratedMesh=!1,this.isAuxClippingMesh=!1}copy(e,t){return super.copy(e,t),void 0!==e.morphTargetInfluences&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),void 0!==e.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=e.material,this.geometry=e.geometry,this.isMaterialGeneratedMesh=e.isMaterialGeneratedMesh,this}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}getVertexPosition(e,t){const n=this.geometry,i=n.attributes.position,o=n.morphAttributes.position,r=n.morphTargetsRelative;t.fromBufferAttribute(i,e);const a=this.morphTargetInfluences;if(o&&a){Ko.set(0,0,0);for(let n=0,i=o.length;n<i;n++){const i=a[n],s=o[n];0!==i&&(jo.fromBufferAttribute(s,e),r?Ko.addScaledVector(jo,i):Ko.addScaledVector(jo.sub(t),i))}t.add(Ko)}return this.isSkinnedMesh&&this.boneTransform(e,t),t}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(),ko.copy(n.boundingSphere),ko.applyMatrix4(o),!1===e.ray.intersectsSphere(ko))return;if(Vo.copy(o).invert(),Go.copy(e.ray).applyMatrix4(Vo),null!==n.boundingBox&&!1===Go.intersectsBox(n.boundingBox))return;let r;const a=n.index,s=n.attributes.position,l=n.morphAttributes.position,c=n.morphTargetsRelative,u=n.attributes.uv,d=n.attributes.uv2,h=n.groups,p=n.drawRange;if(null!==a)if(Array.isArray(i))for(let n=0,o=h.length;n<o;n++){const o=h[n],f=i[o.materialIndex];for(let n=Math.max(o.start,p.start),i=Math.min(a.count,Math.min(o.start+o.count,p.start+p.count));n<i;n+=3){const i=a.getX(n),h=a.getX(n+1),p=a.getX(n+2);r=or(this,f,e,Go,s,l,c,u,d,i,h,p),r&&(r.faceIndex=Math.floor(n/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{for(let n=Math.max(0,p.start),o=Math.min(a.count,p.start+p.count);n<o;n+=3){const o=a.getX(n),h=a.getX(n+1),p=a.getX(n+2);r=or(this,i,e,Go,s,l,c,u,d,o,h,p),r&&(r.faceIndex=Math.floor(n/3),t.push(r))}}else if(void 0!==s)if(Array.isArray(i))for(let n=0,o=h.length;n<o;n++){const o=h[n],a=i[o.materialIndex];for(let n=Math.max(o.start,p.start),i=Math.min(s.count,Math.min(o.start+o.count,p.start+p.count));n<i;n+=3){r=or(this,a,e,Go,s,l,c,u,d,n,n+1,n+2),r&&(r.faceIndex=Math.floor(n/3),r.face.materialIndex=o.materialIndex,t.push(r))}}else{for(let n=Math.max(0,p.start),o=Math.min(s.count,p.start+p.count);n<o;n+=3){r=or(this,i,e,Go,s,l,c,u,d,n,n+1,n+2),r&&(r.faceIndex=Math.floor(n/3),t.push(r))}}}clone(){return new this.constructor(this.geometry,this.material).copy(this)}getWorldDirection(e){this.updateMatrixWorld(!0);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}isVisible(){return this.isMaterialGeneratedMesh&&this.parent?this.visible&&this.parent.visible:this.visible}}function or(e,t,n,i,o,r,a,s,l,c,u,d){Qo.fromBufferAttribute(o,c),Wo.fromBufferAttribute(o,u),Ho.fromBufferAttribute(o,d);const h=e.morphTargetInfluences;if(r&&h){Ko.set(0,0,0),qo.set(0,0,0),Zo.set(0,0,0);for(let e=0,t=r.length;e<t;e++){const t=h[e],n=r[e];0!==t&&(jo.fromBufferAttribute(n,c),Yo.fromBufferAttribute(n,u),Xo.fromBufferAttribute(n,d),a?(Ko.addScaledVector(jo,t),qo.addScaledVector(Yo,t),Zo.addScaledVector(Xo,t)):(Ko.addScaledVector(jo.sub(Qo),t),qo.addScaledVector(Yo.sub(Wo),t),Zo.addScaledVector(Xo.sub(Ho),t)))}Qo.add(Ko),Wo.add(qo),Ho.add(Zo)}e.isSkinnedMesh&&(e.boneTransform(c,Qo),e.boneTransform(u,Wo),e.boneTransform(d,Ho));const m=function(e,t,n,i,o,r,a,s){let l;if(l=t.side===f?i.intersectTriangle(a,r,o,!0,s):i.intersectTriangle(o,r,a,t.side===p,s),null===l)return null;nr.copy(s),nr.applyMatrix4(e.matrixWorld);const c=n.ray.origin.distanceTo(nr);return c<n.near||c>n.far?null:{distance:c,point:nr.clone(),object:e}}(e,t,n,i,Qo,Wo,Ho,tr);if(m){s&&(Jo.fromBufferAttribute(s,c),$o.fromBufferAttribute(s,u),er.fromBufferAttribute(s,d),m.uv=bo.getUV(tr,Qo,Wo,Ho,Jo,$o,er,new yn)),l&&(Jo.fromBufferAttribute(l,c),$o.fromBufferAttribute(l,u),er.fromBufferAttribute(l,d),m.uv2=bo.getUV(tr,Qo,Wo,Ho,Jo,$o,er,new yn));const e={a:c,b:u,c:d,normal:new ci,materialIndex:0};bo.getNormal(Qo,Wo,Ho,e.normal),m.face=e}return m}class rr extends zo{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,C=m+1,M=g+1;let S=0,E=0;const w=new ci;for(let r=0;r<M;r++){const a=r*_-y;for(let s=0;s<C;s++){const d=s*A-x;w[e]=d*i,w[t]=a*o,w[n]=b,l.push(w.x,w.y,w.z),w[e]=0,w[t]=0,w[n]=f>0?1:-1,c.push(w.x,w.y,w.z),u.push(s/m),u.push(1-r/g),S+=1}}for(let e=0;e<g;e++)for(let t=0;t<m;t++){const n=d+t+C*e,i=d+t+C*(e+1),o=d+(t+1)+C*(e+1),r=d+(t+1)+C*e;s.push(n,i,r),s.push(i,o,r),E+=6}a.addGroup(h,E,v),h+=E,d+=S}p("z","y","x",-1,-1,n,t,e,r,o,0),p("z","y","x",1,-1,n,t,-e,r,o,1),p("x","z","y",1,1,e,n,t,i,r,2),p("x","z","y",1,-1,e,n,-t,i,r,3),p("x","y","z",1,-1,e,t,n,i,o,4),p("x","y","z",-1,-1,e,t,-n,i,o,5),this.setIndex(s),this.setAttribute("position",new Lo(l,3)),this.setAttribute("normal",new Lo(c,3)),this.setAttribute("uv",new Lo(u,2))}static fromJSON(e){return new rr(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function ar(e){const t={};for(const n in e){t[n]={};for(const i in e[n]){const o=e[n][i];o&&(o.isColor||o.isMatrix3||o.isMatrix4||o.isVector2||o.isVector3||o.isVector4||o.isTexture||o.isQuaternion)?t[n][i]=o.clone():Array.isArray(o)?t[n][i]=o.slice():t[n][i]=o}}return t}function sr(e){const t={};for(let n=0;n<e.length;n++){const i=ar(e[n]);for(const e in i)t[e]=i[e]}return t}function lr(e){return null===e.getRenderTarget()&&e.outputEncoding===Rt?Ft:Ut}const cr={clone:ar,merge:sr};class ur extends Mo{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.customPrepTokens={},this.vertexShader="void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}",this.fragmentShader="void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n}",this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,void 0!==e&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=ar(e.uniforms),this.uniformsGroups=function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e[n].clone());return t}(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.customPrepTokens=Object.assign({},e.customPrepTokens),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const n in this.uniforms){const i=this.uniforms[n].value;i&&i.isTexture?t.uniforms[n]={type:"t",value:i.toJSON(e).uuid}:i&&i.isColor?t.uniforms[n]={type:"c",value:i.getHex()}:i&&i.isVector2?t.uniforms[n]={type:"v2",value:i.toArray()}:i&&i.isVector3?t.uniforms[n]={type:"v3",value:i.toArray()}:i&&i.isVector4?t.uniforms[n]={type:"v4",value:i.toArray()}:i&&i.isMatrix3?t.uniforms[n]={type:"m3",value:i.toArray()}:i&&i.isMatrix4?t.uniforms[n]={type:"m4",value:i.toArray()}:t.uniforms[n]={value:i}}Object.keys(this.defines).length>0&&(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}}class dr extends uo{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new zi,this.projectionMatrix=new zi,this.projectionMatrixInverse=new zi,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)}}class hr extends dr{constructor(e=50,t=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,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*en*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*$t*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*en*Math.atan(Math.tan(.5*$t*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*$t*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}}const pr=-90;class fr extends uo{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n;const i=new hr(pr,1,e,t);i.layers=this.layers,i.up.set(0,1,0),i.lookAt(1,0,0),this.add(i);const o=new hr(pr,1,e,t);o.layers=this.layers,o.up.set(0,1,0),o.lookAt(-1,0,0),this.add(o);const r=new hr(pr,1,e,t);r.layers=this.layers,r.up.set(0,0,-1),r.lookAt(0,1,0),this.add(r);const a=new hr(pr,1,e,t);a.layers=this.layers,a.up.set(0,0,1),a.lookAt(0,-1,0),this.add(a);const s=new hr(pr,1,e,t);s.layers=this.layers,s.up.set(0,1,0),s.lookAt(0,0,1),this.add(s);const l=new hr(pr,1,e,t);l.layers=this.layers,l.up.set(0,1,0),l.lookAt(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.getRenderTarget(),u=e.toneMapping,d=e.xr.enabled;e.toneMapping=q,e.xr.enabled=!1;const h=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=h,e.setRenderTarget(n,5),e.render(t,l),e.setRenderTarget(c),e.toneMapping=u,e.xr.enabled=d,n.texture.needsPMREMUpdate=!0}}class mr extends ni{constructor(e,t,n,i,o,r,a,s,l,c){super(e=void 0!==e?e:[],t=void 0!==t?t:ae,n,i,o,r,a,s,l,c),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.source.data}set images(e){this.source.data=e}}class gr extends oi{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},i=[n,n,n,n,n,n];this.texture=new mr(i,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:ve}fromEquirectangularTexture(e,t){this.texture.type=t.type,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 <begin_vertex>\n                    #include <project_vertex>\n\n                }\n            ",fragmentShader:"\n\n                uniform sampler2D tEquirect;\n\n                varying vec3 vWorldDirection;\n\n                #include <common>\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 rr(5,5,5),o=new ur({name:"CubemapFromEquirect",uniforms:ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:f,blending:v});o.uniforms.tEquirect.value=t;const r=new ir(i,o),a=t.minFilter;t.minFilter===_e&&(t.minFilter=ve);return new fr(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)}}const vr=new ci,Ar=new ci,_r=new bn;class xr{constructor(e=new ci(1,0,0),t=0){this.isPlane=!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=vr.subVectors(n,t).cross(Ar.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(vr),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||_r.getNormalMatrix(e),i=this.coplanarPoint(vr).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)}}const yr=new Ri,br=new ci;class Cr{constructor(e=new xr,t=new xr,n=new xr,i=new xr,o=new xr,r=new xr){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(),yr.copy(t.boundingSphere).applyMatrix4(e.matrixWorld),this.intersectsSphere(yr)}intersectsSprite(e){return yr.center.set(0,0,0),yr.radius=.7071067811865476,yr.applyMatrix4(e.matrixWorld),this.intersectsSphere(yr)}intersectsSphere(e){const t=this.planes,n=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(n)<i)return!1}return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const i=t[n];if(br.x=i.normal.x>0?e.max.x:e.min.x,br.y=i.normal.y>0?e.max.y:e.min.y,br.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(br)<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 Mr(){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 Sr(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<t.version)&&i.set(t,{buffer:t.buffer,type:t.type,bytesPerElement:t.elementSize,version:t.version}))}t.isInterleavedBufferAttribute&&(t=t.data);const r=i.get(t);void 0===r?i.set(t,function(t,i){const o=t.array,r=t.usage,a=e.createBuffer();let s;if(e.bindBuffer(i,a),e.bufferData(i,o,r),t.onUploadCallback(),o instanceof Float32Array)s=5126;else if(o instanceof Uint16Array)if(t.isFloat16BufferAttribute){if(!n)throw new Error("v3d.WebGLAttributes: Usage of Float16BufferAttribute requires WebGL2.");s=5131}else s=5123;else if(o instanceof Int16Array)s=5122;else if(o instanceof Uint32Array)s=5125;else if(o instanceof Int32Array)s=5124;else if(o instanceof Int8Array)s=5120;else if(o instanceof Uint8Array)s=5121;else{if(!(o instanceof Uint8ClampedArray))throw new Error("v3d.WebGLAttributes: Unsupported buffer data format: "+o);s=5121}return{buffer:a,type:s,bytesPerElement:o.BYTES_PER_ELEMENT,version:t.version}}(t,o)):r.version<t.version&&(!function(t,i,o){const r=i.array,a=i.updateRange;e.bindBuffer(o,t),-1===a.count?e.bufferSubData(o,0,r):(n?e.bufferSubData(o,a.offset*r.BYTES_PER_ELEMENT,r,a.offset,a.count):e.bufferSubData(o,a.offset*r.BYTES_PER_ELEMENT,r.subarray(a.offset,a.offset+a.count)),a.count=-1),i.onUploadCallback()}(r.buffer,t,o),r.version=t.version)},dispose:function(){i=new WeakMap}}}class Er extends zo{constructor(e=1,t=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:i};const o=e/2,r=t/2,a=Math.floor(n),s=Math.floor(i),l=a+1,c=s+1,u=e/a,d=t/s,h=[],p=[],f=[],m=[];for(let e=0;e<c;e++){const t=e*d-r;for(let n=0;n<l;n++){const i=n*u-o;p.push(i,-t,0),f.push(0,0,1),m.push(n/a),m.push(1-e/s)}}for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=t+l*e,i=t+l*(e+1),o=t+1+l*(e+1),r=t+1+l*e;h.push(n,i,r),h.push(i,o,r)}this.setIndex(h),this.setAttribute("position",new Lo(p,3)),this.setAttribute("normal",new Lo(f,3)),this.setAttribute("uv",new Lo(m,2))}static fromJSON(e){return new Er(e.width,e.height,e.widthSegments,e.heightSegments)}}const wr={alphamap_fragment:"#ifdef USE_ALPHAMAP\ndiffuseColor.a *= texture2D(alphaMap, vUv).g;\n#endif",alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\nuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef USE_ALPHATEST\nif (diffuseColor.a < alphaTest)\ndiscard;\nelse\ndiffuseColor.a = 1.0;\n#endif",alphatest_pars_fragment:"#ifdef USE_ALPHATEST\nuniform float alphaTest;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\nfloat ambientOcclusion = (texture2D(aoMap, vUv2).r - 1.0) * aoMapIntensity + 1.0;\nreflectedLight.indirectDiffuse *= ambientOcclusion;\n#if defined(USE_ENVMAP) && defined(STANDARD)\nfloat dotNV = saturate(dot(geometry.normal, geometry.viewDir));\nreflectedLight.indirectSpecular *= computeSpecularOcclusion(dotNV, ambientOcclusion, material.roughness);\n#endif\n#endif",aomap_pars_fragment:"#ifdef USE_AOMAP\nuniform sampler2D aoMap;\nuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3(position);",beginnormal_vertex:"vec3 objectNormal = vec3(normal);\n#ifdef USE_TANGENT\nvec3 objectTangent = vec3(tangent.xyz);\n#endif",bsdfs:"\nvec2 integrateSpecularBRDF(const in float dotNV, const in float roughness) {\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;\nreturn vec2(-1.04, 1.04) * a004 + r.zw;\n}\nvec3 BRDF_Lambert(const in vec3 diffuseColor) {\nreturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick(const in vec3 f0, const in float f90, const in float dotVH) {\nfloat fresnel = exp2((- 5.55473 * dotVH - 6.98316) * dotVH);\nreturn f0 * (1.0 - fresnel) + (f90 * fresnel);\n}\nfloat F_Schlick(const in float f0, const in float f90, const in float dotVH) {\nfloat fresnel = exp2((- 5.55473 * dotVH - 6.98316) * dotVH);\nreturn f0 * (1.0 - fresnel) + (f90 * fresnel);\n}\nvec3 Schlick_to_F0(const in vec3 f, const in float f90, const in float dotVH) {\nfloat x = clamp(1.0 - dotVH, 0.0, 1.0);\nfloat x2 = x * x;\nfloat x5 = clamp(x * x2 * x2, 0.0, 0.9999);\nreturn (f - vec3(f90) * x5) / (1.0 - x5);\n}\nvec3 F_Schlick_RoughnessDependent(const in vec3 F0, const in float dotNV, const in float roughness) {\nfloat fresnel = exp2((-5.55473 * dotNV - 6.98316) * dotNV);\nvec3 Fr = max(vec3(1.0 - roughness), F0) - F0;\nreturn Fr * fresnel + F0;\n}\nfloat V_GGX_SmithCorrelated(const in float alpha, const in float dotNL, const in float dotNV) {\nfloat a2 = pow2(alpha);\nfloat gv = dotNL * sqrt(a2 + (1.0 - a2) * pow2(dotNV));\nfloat gl = dotNV * sqrt(a2 + (1.0 - a2) * pow2(dotNL));\nreturn 0.5 / max(gv + gl, EPSILON);\n}\nfloat D_GGX(const in float alpha, const in float dotNH) {\nfloat a2 = pow2(alpha);\nfloat denom = pow2(dotNH) * (a2 - 1.0) + 1.0;\nreturn RECIPROCAL_PI * a2 / pow2(denom);\n}\nvec3 BRDF_GGX(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float roughness) {\nfloat alpha = pow2(clamp(roughness, 0.04, 1.0));\nvec3 halfDir = normalize(lightDir + viewDir);\nfloat dotNL = saturate(dot(normal, lightDir));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotVH = saturate(dot(viewDir, halfDir));\nvec3 F = F_Schlick(f0, f90, dotVH);\nfloat V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV);\nfloat D = D_GGX(alpha, dotNH);\nreturn F * (V * D);\n}\n#ifdef USE_IRIDESCENCE\nvec3 BRDF_GGX_Iridescence(const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 f0, const in float f90, const in float iridescence, const in vec3 iridescenceFresnel, const in float roughness) {\nfloat alpha = pow2(roughness);\nvec3 halfDir = normalize(lightDir + viewDir);\nfloat dotNL = saturate(dot(normal, lightDir));\nfloat dotNV = saturate(dot(normal, viewDir));\nfloat dotNH = saturate(dot(normal, halfDir));\nfloat dotVH = saturate(dot(viewDir, halfDir));\nvec3 F = mix(F_Schlick(f0, f90, dotVH), iridescenceFresnel, iridescence);\nfloat V = V_GGX_SmithCorrelated(alpha, dotNL, dotNV);\nfloat D = D_GGX(alpha, dotNH);\nreturn F * (V * D);\n}\n#endif\nvec2 LTC_Uv(const in vec3 N, const in vec3 V, const in float roughness) {\nconst float LUT_SIZE = 64.0;\nconst float LUT_SCALE = (LUT_SIZE - 1.0) / LUT_SIZE;\nconst float LUT_BIAS = 0.5 / LUT_SIZE;\nfloat dotNV = saturate(dot(N, V));\nvec2 uv = vec2(roughness, sqrt(1.0 - dotNV));\nuv = uv * LUT_SCALE + LUT_BIAS;\nreturn uv;\n}\nfloat LTC_ClippedSphereFormFactor(const in vec3 f) {\nfloat l = length(f);\nreturn max((l * l + f.z) / (l + 1.0), 0.0);\n}\nvec3 LTC_EdgeVectorFormFactor(const in vec3 v1, const in vec3 v2) {\nfloat x = dot(v1, v2);\nfloat y = abs(x);\nfloat a = 0.8543985 + (0.4965155 + 0.0145206 * y) * y;\nfloat b = 3.4175940 + (4.1616724 + y) * y;\nfloat v = a / b;\nfloat theta_sintheta = (x > 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",iridescence_fragment:"#ifdef USE_IRIDESCENCE\nconst mat3 XYZ_TO_REC709 = mat3(\n3.2404542, -0.9692660, 0.0556434,\n-1.5371385, 1.8760108, -0.2040259,\n-0.4985314, 0.0415560, 1.0572252\n);\nvec3 Fresnel0ToIor(vec3 fresnel0) {\nvec3 sqrtF0 = sqrt(fresnel0);\nreturn (vec3(1.0) + sqrtF0) / (vec3(1.0) - sqrtF0);\n}\nvec3 IorToFresnel0(vec3 transmittedIor, float incidentIor) {\nreturn pow2((transmittedIor - vec3(incidentIor)) / (transmittedIor + vec3(incidentIor)));\n}\nfloat IorToFresnel0(float transmittedIor, float incidentIor) {\nreturn pow2((transmittedIor - incidentIor) / (transmittedIor + incidentIor));\n}\nvec3 evalSensitivity(float OPD, vec3 shift) {\nfloat phase = 2.0 * PI * OPD * 1.0e-9;\nvec3 val = vec3(5.4856e-13, 4.4201e-13, 5.2481e-13);\nvec3 pos = vec3(1.6810e+06, 1.7953e+06, 2.2084e+06);\nvec3 var = vec3(4.3278e+09, 9.3046e+09, 6.6121e+09);\nvec3 xyz = val * sqrt(2.0 * PI * var) * cos(pos * phase + shift) * exp(- pow2(phase) * var);\nxyz.x += 9.7470e-14 * sqrt(2.0 * PI * 4.5282e+09) * cos(2.2399e+06 * phase + shift[0]) * exp(- 4.5282e+09 * pow2(phase));\nxyz /= 1.0685e-7;\nvec3 rgb = XYZ_TO_REC709 * xyz;\nreturn rgb;\n}\nvec3 evalIridescence(float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0) {\nvec3 I;\nfloat iridescenceIOR = mix(outsideIOR, eta2, smoothstep(0.0, 0.03, thinFilmThickness));\nfloat sinTheta2Sq = pow2(outsideIOR / iridescenceIOR) * (1.0 - pow2(cosTheta1));\nfloat cosTheta2Sq = 1.0 - sinTheta2Sq;\nif (cosTheta2Sq < 0.0) {\nreturn vec3(1.0);\n}\nfloat cosTheta2 = sqrt(cosTheta2Sq);\nfloat R0 = IorToFresnel0(iridescenceIOR, outsideIOR);\nfloat R12 = F_Schlick(R0, 1.0, cosTheta1);\nfloat R21 = R12;\nfloat T121 = 1.0 - R12;\nfloat phi12 = 0.0;\nif (iridescenceIOR < outsideIOR) phi12 = PI;\nfloat phi21 = PI - phi12;\nvec3 baseIOR = Fresnel0ToIor(clamp(baseF0, 0.0, 0.9999));\nvec3 R1 = IorToFresnel0(baseIOR, iridescenceIOR);\nvec3 R23 = F_Schlick(R1, 1.0, cosTheta2);\nvec3 phi23 = vec3(0.0);\nif (baseIOR[0] < iridescenceIOR) phi23[0] = PI;\nif (baseIOR[1] < iridescenceIOR) phi23[1] = PI;\nif (baseIOR[2] < iridescenceIOR) phi23[2] = PI;\nfloat OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;\nvec3 phi = vec3(phi21) + phi23;\nvec3 R123 = clamp(R12 * R23, 1e-5, 0.9999);\nvec3 r123 = sqrt(R123);\nvec3 Rs = pow2(T121) * R23 / (vec3(1.0) - R123);\nvec3 C0 = R12 + Rs;\nI = C0;\nvec3 Cm = Rs - T121;\nfor (int m = 1; m <= 2; ++ m) {\nCm *= r123;\nvec3 Sm = 2.0 * evalSensitivity(float(m) * OPD, float(m) * phi);\nI += Cm * Sm;\n}\nreturn max(I, vec3(0.0));\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 = dFdx(surf_pos.xyz);\nvec3 vSigmaY = dFdy(surf_pos.xyz);\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; }\nvec3 pow2(const in vec3 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 v) { return dot(v, vec3(0.3333333)); }\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) {\nconst vec3 weights = vec3(0.2126729, 0.7151522, 0.0721750);\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 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}\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 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\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#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;\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) || defined(LAMBERT)\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) || defined(LAMBERT)\n#define ENV_WORLDPOS\n#endif\n#ifdef ENV_WORLDPOS\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\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 vec3 normal) {\n#if defined(ENVMAP_TYPE_CUBE_UV)\nvec3 worldNormal = inverseTransformDirection(normal, viewMatrix);\nvec4 envMapColor = textureCubeUV(envMap, worldNormal, 1.0);\nreturn PI * envMapColor.rgb * envMapIntensity;\n#else\nreturn vec3(0.0);\n#endif\n}\nvec3 getIBLRadiance(const in vec3 viewDir, const in vec3 normal, const in float roughness, vec3 position) {\n#if defined(ENVMAP_TYPE_CUBE_UV)\nvec3 reflectVec = reflect(-viewDir, normal);\nreflectVec = inverseTransformDirection(reflectVec, viewMatrix);\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\nvec3 posWorld = (invViewMatrix * vec4(position, 1.0)).xyz;\nreflectVec = correctParallax(reflectVec, posWorld, envMapParallaxType);\n}\nvec4 envMapColor = textureCubeUV(envMap, reflectVec, roughness);\nreturn envMapColor.rgb * envMapIntensity;\n#else\nreturn vec3(0.0);\n#endif\n}\nvec3 getIBLRefraction(const in vec3 viewDir, const in vec3 normal, const in float roughness, const float refrRatio, vec3 position) {\n#if defined(ENVMAP_TYPE_CUBE_UV)\nvec3 refractVec = refract(-viewDir, normal, refrRatio);\nrefractVec = inverseTransformDirection(refractVec, viewMatrix);\nif (envMapParallaxType != ENVMAP_PARALLAX_INFINITE) {\nvec3 posWorld = (invViewMatrix * vec4(position, 1.0)).xyz;\nrefractVec = correctParallax(refractVec, posWorld, envMapParallaxType);\n}\nvec4 envMapColor = textureCubeUV(envMap, refractVec, roughness);\nreturn envMapColor.rgb * envMapIntensity;\n#else\nreturn vec3(0.0);\n#endif\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\nvec2 fw = fwidth(coord) * 0.5;\nreturn mix(vec3(0.7), vec3(1.0), smoothstep(0.7 - fw.x, 0.7 + fw.x, coord.x));\n#endif\n}",lightmap_fragment:"#ifdef USE_LIGHTMAP\nvec4 lightMapTexel = texture2D(lightMap, vUv2);\nvec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;\nreflectedLight.indirectDiffuse += lightMapIrradiance;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nuniform sampler2D lightMap;\nuniform float lightMapIntensity;\n#endif",lights_lambert_fragment:"LambertMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularStrength = specularStrength;",lights_lambert_pars_fragment:"varying vec3 vViewPosition;\nstruct LambertMaterial {\nvec3 diffuseColor;\nfloat specularStrength;\n};\nvoid RE_Direct_Lambert(const in IncidentLight directLight, const in GeometricContext geometry, const in LambertMaterial material, inout 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_IndirectDiffuse_Lambert(const in vec3 irradiance, const in GeometricContext geometry, const in LambertMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Lambert\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert",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 / (UNITS_SCALE_FACTOR * 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 GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\n#define RE_Direct RE_Direct_Toon\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon",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 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",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\nmaterial.ior = 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((material.ior - 1.0) / (material.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_IRIDESCENCE\nmaterial.iridescence = iridescence;\nmaterial.iridescenceIOR = iridescenceIOR;\n#ifdef USE_IRIDESCENCEMAP\nmaterial.iridescence *= texture2D(iridescenceMap, vUv).r;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\nmaterial.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D(iridescenceThicknessMap, vUv).g + iridescenceThicknessMinimum;\n#else\nmaterial.iridescenceThickness = iridescenceThicknessMaximum;\n#endif\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_IRIDESCENCE\nfloat iridescence;\nfloat iridescenceIOR;\nfloat iridescenceThickness;\nvec3 iridescenceFresnel;\nvec3 iridescenceF0;\n#endif\n#ifdef USE_SHEEN\nvec3 sheenColor;\nfloat sheenRoughness;\n#endif\n#ifdef IOR\nfloat ior;\n#endif\n#ifdef USE_TRANSMISSION\nfloat transmission;\nfloat transmissionAlpha;\nfloat thickness;\nfloat attenuationDistance;\nvec3 attenuationColor;\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}\n#ifdef USE_IRIDESCENCE\nvoid computeMultiscatteringIridescence(const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter) {\n#else\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) {\n#endif\nvec2 fab = DFGApprox(normal, viewDir, roughness);\n#ifdef USE_IRIDESCENCE\nvec3 Fr = mix(specularColor, iridescenceF0, iridescence);\n#else\nvec3 Fr = specularColor;\n#endif\nvec3 FssEss = Fr * fab.x + specularF90 * fab.y;\nfloat Ess = fab.x + fab.y;\nfloat Ems = 1.0 - Ess;\nvec3 Favg = Fr + (1.0 - Fr) * 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\n#ifdef USE_IRIDESCENCE\nreflectedLight.directSpecular += irradiance * BRDF_GGX_Iridescence(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness);\n#else\nreflectedLight.directSpecular += irradiance * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, material.specularColor, material.specularF90, material.roughness);\n#endif\nreflectedLight.directDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectDiffuse_Physical(const in vec3 irradiance, 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;\n#ifdef USE_IRIDESCENCE\ncomputeMultiscatteringIridescence(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering);\n#else\ncomputeMultiscattering(geometry.normal, geometry.viewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering);\n#endif\nvec3 totalScattering = singleScattering + multiScattering;\nvec3 diffuse = material.diffuseColor * (1.0 - max(max(totalScattering.r, totalScattering.g), totalScattering.b));\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\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\n#ifdef USE_IRIDESCENCE\nfloat dotNVi = saturate(dot(normal, geometry.viewDir));\nif (material.iridescenceThickness == 0.0) {\nmaterial.iridescence = 0.0;\n} else {\nmaterial.iridescence = saturate(material.iridescence);\n}\nif (material.iridescence > 0.0) {\nmaterial.iridescenceFresnel = evalIridescence(1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor);\nmaterial.iridescenceF0 = Schlick_to_F0(material.iridescenceFresnel, 1.0, dotNVi);\n}\n#endif\nIncidentLight directLight;\n#if (NUM_POINT_LIGHTS > 0) && defined(RE_Direct)\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 *= (directLight.visible && receiveShadow) ? getPointShadow(pointLightShadow, pointShadowMap[i], vPointShadowCoord[i]) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_SPOT_LIGHTS > 0) && defined(RE_Direct)\nSpotLight spotLight;\nvec4 spotColor;\nvec3 spotLightCoord;\nbool inSpotLightMap;\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 (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],\nvSpotLightCoord[i], distWorld);\n} else if (spotLightShadow.shadow == 2) {\ndirectLight.color *= getSpotOmniShadow(spotLightShadow,\nspotShadowMap[i], vSpotLightCoord[i]);\n}\n}\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\n}\n#pragma unroll_loop_end\n#endif\n#if (NUM_DIR_LIGHTS > 0) && defined(RE_Direct)\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 *= (directLight.visible && receiveShadow && (vViewPosition.z < directionalLightShadow.maxDistance))\n? getDirShadow(directionalLightShadow, directionalShadowMap[i],\nvDirectionalShadowCoord[i], distWorld) : 1.0;\n#endif\nRE_Direct(directLight, geometry, material, reflectedLight);\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)\nvec3 iblIrradiance = vec3(0.0);\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;\nirradiance += lightMapIrradiance;\n#endif\n#if defined(USE_ENVMAP) && defined(STANDARD) && defined(ENVMAP_TYPE_CUBE_UV)\niblIrradiance += getIBLIrradiance(geometry.probeNormal);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_IndirectSpecular)\nradiance += getIBLRadiance(geometry.viewDir, geometry.normal, material.roughness, geometry.position);\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.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, geometry.position);\n#endif\n#endif\n#if defined(USE_ENVMAP) && defined(RE_Refraction)\nrefraction += getIBLRefraction(geometry.viewDir, geometry.normal, material.refractionRoughness, 1.0 / material.refractionIOR, geometry.position);\n#ifdef USE_SSR_REFRACT\nrefraction = computeSSR(refraction, geometry.normal, material.refractionIOR);\n#endif\n#endif",lights_fragment_end:"#if defined(RE_IndirectDiffuse)\n#ifdef NODE\nirradiance += iblIrradiance;\n#endif\nRE_IndirectDiffuse(irradiance, 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",morphcolor_vertex:"#if defined(USE_MORPHCOLORS) && defined(MORPHTARGETS_TEXTURE)\nvColor *= morphTargetBaseInfluence;\nfor (int i = 0; i < MORPHTARGETS_COUNT; i++) {\n#if defined(USE_COLOR_ALPHA)\nif (morphTargetInfluences[i] != 0.0) vColor += getMorph(gl_VertexID, i, 2) * morphTargetInfluences[i];\n#elif defined(USE_COLOR)\nif (morphTargetInfluences[i] != 0.0) vColor += getMorph(gl_VertexID, i, 2).rgb * morphTargetInfluences[i];\n#endif\n}\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 = dFdx(vViewPosition);\nvec3 fdy = dFdy(vViewPosition);\nvec3 normal = normalize(cross(fdx, fdy));\n#else\nvec3 normal = normalize(vNormal);\n#ifdef DOUBLE_SIDED\nnormal = normal * faceDirection;\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 = dFdx(eye_pos.xyz);\nvec3 q1 = dFdy(eye_pos.xyz);\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",iridescence_pars_fragment:"#ifdef USE_IRIDESCENCEMAP\nuniform sampler2D iridescenceMap;\n#endif\n#ifdef USE_IRIDESCENCE_THICKNESSMAP\nuniform sampler2D iridescenceThicknessMap;\n#endif",output_fragment:"#ifdef OPAQUE\ndiffuseColor.a = 1.0;\n#endif\n#ifdef USE_TRANSMISSION\ndiffuseColor.a *= material.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}\nvec2 packDepthToRG(in highp float v) {\nreturn packDepthToRGBA(v).yx;\n}\nfloat unpackRGToDepth(const in highp vec2 v) {\nreturn unpackRGBAToDepth(vec4(v.xy, 0.0, 0.0));\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:"#if NUM_SPOT_LIGHT_COORDS > 0\nvarying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS];\n#endif\n#if NUM_SPOT_LIGHT_MAPS > 0\nuniform sampler2D spotLightMap[NUM_SPOT_LIGHT_MAPS];\n#endif\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];\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;\nbool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;\nbool frustumTest = inFrustum && shadowCoord.z <= 1.0 && shadowCoord.z >= 0.0;\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);\nbool frustumTest = dp <= 1.0 && dp >= 0.0;\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:"#if NUM_SPOT_LIGHT_COORDS > 0\nuniform mat4 spotLightMatrix[NUM_SPOT_LIGHT_COORDS];\nvarying vec4 vSpotLightCoord[NUM_SPOT_LIGHT_COORDS];\n#endif\n#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\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:"#if defined(USE_SHADOWMAP) || (NUM_SPOT_LIGHT_COORDS > 0)\n#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_COORDS > 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_COORDS > 0\n#pragma unroll_loop_start\nfor (int i = 0; i < NUM_SPOT_LIGHT_COORDS; i++) {\nshadowWorldPosition = worldPosition + vec4(shadowWorldNormal * spotLightShadows[i].shadowNormalBias, 0);\nvSpotLightCoord[i] = spotLightMatrix[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 *= ((vViewPosition.z < directionalLight.maxDistance) && receiveShadow) ?\ngetDirShadow(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], vSpotLightCoord[i],\ndistWorld);\n} else if (spotLight.shadow == 2) {\nshadow *= getSpotOmniShadow(spotLight, spotShadowMap[i],\nvSpotLightCoord[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;\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#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\nmaterial.transmission = transmission;\nmaterial.transmissionAlpha = 1.0;\nmaterial.thickness = thickness;\nmaterial.attenuationDistance = attenuationDistance;\nmaterial.attenuationColor = attenuationColor;\n#ifdef USE_TRANSMISSIONMAP\nmaterial.transmission *= texture2D(transmissionMap, vUv).r;\n#endif\n#ifdef USE_THICKNESSMAP\nmaterial.thickness *= texture2D(thicknessMap, vUv).g;\n#endif\nvec3 pos = vWorldPosition;\nvec3 v = normalize(cameraPosition - pos);\nvec3 n = inverseTransformDirection(normal, viewMatrix);\nvec4 transmission = getIBLVolumeRefraction(\nn, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,\npos, modelMatrix, viewMatrix, projectionMatrix, material.ior, material.thickness,\nmaterial.attenuationColor, material.attenuationDistance);\nmaterial.transmissionAlpha = mix(material.transmissionAlpha, transmission.a, material.transmission);\ntotalDiffuse = mix(totalDiffuse, transmission.rgb, material.transmission);\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 texture2DLodEXT\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 (isinf(attenuationDistance)) {\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) || NUM_SPOT_LIGHT_COORDS > 0 || 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;\nuniform float backgroundIntensity;\nvarying vec2 vUv;\nvoid main() {\nvec4 texColor = texture2D(t2D, vUv);\n#ifdef DECODE_VIDEO_TEXTURE\ntexColor = vec4(mix(pow(texColor.rgb * 0.9478672986 + vec3(0.0521327014), vec3(2.4)), texColor.rgb * 0.0773993808, vec3(lessThanEqual(texColor.rgb, vec3(0.04045)))), texColor.w);\n#endif\ntexColor.rgb *= backgroundIntensity;\ngl_FragColor = texColor;\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",backgroundCube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_vertex>\ngl_Position.z = gl_Position.w;\n}",backgroundCube_frag:"#ifdef ENVMAP_TYPE_CUBE\nuniform samplerCube envMap;\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nuniform sampler2D envMap;\n#endif\nuniform float flipEnvMap;\nuniform float backgroundBlurriness;\nuniform float backgroundIntensity;\nvarying vec3 vWorldDirection;\n#include <cube_uv_reflection_fragment>\nvoid main() {\n#ifdef ENVMAP_TYPE_CUBE\nvec4 texColor = textureCube(envMap, vec3(flipEnvMap * vWorldDirection.x, vWorldDirection.yz));\n#elif defined(ENVMAP_TYPE_CUBE_UV)\nvec4 texColor = textureCubeUV(envMap, vWorldDirection, backgroundBlurriness);\n#else\nvec4 texColor = vec4(0.0, 0.0, 0.0, 1.0);\n#endif\ntexColor.rgb *= backgroundIntensity;\ngl_FragColor = texColor;\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_vertex>\ngl_Position.z = gl_Position.w;\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\nvec4 texColor = textureCube(tCube, vec3(tFlip * vWorldDirection.x, vWorldDirection.yz));\ngl_FragColor = texColor;\ngl_FragColor.a *= opacity;\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n}",depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\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 <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvarying vec3 vViewPosition;\nvarying vec2 vProjectedPosZW;\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\n#if DEPTH_PACKING == 3200\ndiffuseColor.a = opacity;\n#endif\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <logdepthbuf_fragment>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <worldpos_vertex>\n#include <clipping_planes_vertex>\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 <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#ifndef DISTANCE_SCALE\n#define DISTANCE_SCALE 1.0\n#endif\nvoid main () {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\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 <common>\nvoid main() {\nvWorldDirection = transformDirection(position, modelMatrix);\n#include <begin_vertex>\n#include <project_vertex>\n}",equirect_frag:"uniform sampler2D tEquirect;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec3 vWorldDirection;\n#include <common>\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 <tonemapping_fragment>\n#include <encodings_fragment>\n}",linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\nvLineDistance = scale * lineDistance;\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nif (mod(vLineDistance, totalSize) > dashSize) {\ndiscard;\n}\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <color_fragment>\noutgoingLight = diffuseColor.rgb;\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#if defined (USE_ENVMAP) || defined (USE_SKINNING)\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <fog_vertex>\n}",meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\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 * RECIPROCAL_PI;\n#else\nreflectedLight.indirectDiffuse += vec3(1.0);\n#endif\n#include <aomap_fragment>\nreflectedLight.indirectDiffuse *= diffuseColor.rgb;\nvec3 outgoingLight = reflectedLight.indirectDiffuse;\n#include <envmap_fragment>\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshlambert_vert:"#define LAMBERT\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshlambert_frag:"#define LAMBERT\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_lambert_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_lambert_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include <envmap_fragment>\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <color_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\nvViewPosition = -mvPosition.xyz;\n}",meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#include <common>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\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 <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshnormal_vert:"#define NORMAL\n#if defined(FLAT_SHADED) || defined(USE_BUMPMAP) || defined(TANGENTSPACE_NORMALMAP)\nvarying vec3 vViewPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\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 <packing>\n#include <uv_pars_fragment>\n#include <normal_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\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 <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\n#include <envmap_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <specularmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_phong_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n#include <envmap_fragment>\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifdef USE_TRANSMISSION\nvarying vec3 vWorldPosition;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#include <plane_reflection_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <plane_reflection_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\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_IRIDESCENCE\nuniform float iridescence;\nuniform float iridescenceIOR;\nuniform float iridescenceThicknessMinimum;\nuniform float iridescenceThicknessMaximum;\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\n#if defined(USE_PLANE_REFLECTION) && !defined(USE_TRANSMISSION)\nuniform mat4 modelMatrix;\n#endif\nvarying vec3 vViewPosition;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <iridescence_fragment>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_physical_pars_fragment>\n#include <transmission_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_pars_fragment>\n#include <iridescence_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#include <plane_reflection_pars_fragment>\n#include <oit_weighted_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <roughnessmap_fragment>\n#include <metalnessmap_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <clearcoat_normal_fragment_begin>\n#include <clearcoat_normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_physical_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;\nvec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;\n#include <transmission_fragment>\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 <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n#include <oit_weighted_fragment>\n}",meshtoon_vert:"#define TOON\nvarying vec3 vViewPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <normal_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\n#include <uv2_vertex>\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <normal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\n}",meshtoon_frag:"#define TOON\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <normal_pars_fragment>\n#include <lights_toon_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\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 <logdepthbuf_fragment>\n#include <map_fragment>\n#include <color_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <normal_fragment_begin>\n#include <normal_fragment_maps>\n#include <emissivemap_fragment>\n#include <lights_toon_fragment>\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#include <aomap_fragment>\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n}",points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <color_vertex>\n#include <morphcolor_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <project_vertex>\ngl_PointSize = size;\n#ifdef USE_SIZEATTENUATION\nbool isPerspective = isPerspectiveMatrix(projectionMatrix);\nif (isPerspective) gl_PointSize *= (scale / - mvPosition.z);\n#endif\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <worldpos_vertex>\n#include <fog_vertex>\n}",points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_particle_fragment>\n#include <color_fragment>\n#include <alphatest_fragment>\noutgoingLight = diffuseColor.rgb;\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n}",shadow_vert:"#include <common>\n#ifdef USE_SHADOWMAP\nvarying vec3 vViewPosition;\n#endif\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <project_vertex>\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\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 <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\ngl_FragColor = vec4(color, opacity * (1.0 - getShadowMask()));\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n}",sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n#include <uv_vertex>\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 <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n#include <fog_vertex>\n}",sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\nvec3 outgoingLight = vec3(0.0);\nvec4 diffuseColor = vec4(diffuse, opacity);\n#include <logdepthbuf_fragment>\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\noutgoingLight = diffuseColor.rgb;\n#include <output_fragment>\n#include <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n}",equicube_vert:"varying vec2 vUv;\n#include <common>\nvoid main() {\nvUv = uv;\n#include <begin_vertex>\n#include <project_vertex>\n}",equicube_frag:"uniform sampler2D tEquirect;\nuniform int faceIndex;\nuniform bool invertU;\nuniform float offsetU;\nvarying vec2 vUv;\n#include <common>\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 <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nuniform mat4 textureMatrix;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include <uv_vertex>\n#include <skinbase_vertex>\n#ifdef USE_DISPLACEMENTMAP\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinnormal_vertex>\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\nprojTexCoord = textureMatrix * worldPosition;\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\n}",mask_frag:"#define MASK\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nuniform float opacity;\nuniform sampler2D depthTexture;\nuniform vec2 cameraNearFar;\nvarying vec3 vViewPosition;\nvarying vec4 projTexCoord;\nvoid main() {\n#include <clipping_planes_fragment>\nvec4 diffuseColor = vec4(1.0);\ndiffuseColor.a = opacity;\n#include <map_fragment>\n#include <alphamap_fragment>\n#include <alphatest_fragment>\n#include <logdepthbuf_fragment>\nfloat depth = unpackRGBAToDepth(texture2DProj(depthTexture, projTexCoord));\nfloat viewZ;\nif (isOrthographic)\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 <common>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\n#include <plane_reflection_pars_vertex>\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 <node_pars_vertex>\nvoid main() {\n#include <beginnormal_vertex>\n#include <morphnormal_vertex>\n#include <skinbase_vertex>\n#include <skinnormal_vertex>\n#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\nvNormal = normalize(transformedNormal);\n#endif\n#include <begin_vertex>\n#include <morphtarget_vertex>\n#include <skinning_vertex>\n#include <displacementmap_vertex>\n#include <project_vertex>\n#include <plane_reflection_vertex>\n#include <logdepthbuf_vertex>\n#include <clipping_planes_vertex>\nvViewPosition = -mvPosition.xyz;\n#include <worldpos_vertex>\n#include <shadowmap_vertex>\n#include <fog_vertex>\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 <node_vertex>\n}",meshnode_frag:"#define NODE\n#define STANDARD\n#define PHYSICAL\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <alphatest_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\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 <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_node_pars_fragment>\n#include <lights_node_gtao_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\n#if defined(USE_SSR)\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 <ssr_pars_fragment>\n#include <plane_reflection_pars_fragment>\n#include <node_common_frag>\n#include <node_pars_fragment>\n#include <oit_weighted_pars_fragment>\nvoid main() {\n#include <clipping_planes_fragment>\n#include <logdepthbuf_fragment>\n#include <normal_fragment_begin>\nvec4 outgoingLight = vec4(0.0);\n#include <node_fragment>\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_HOLDOUT_BL) || 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 <tonemapping_fragment>\n#include <encodings_fragment>\n#include <fog_fragment>\n#include <premultiplied_alpha_fragment>\n#include <dithering_fragment>\n#include <normal_output_fragment>\n#include <oit_weighted_fragment>\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_Direct_Node(const in IncidentLight directLight, const in GeometricContext geometry, const in NodeMaterial 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_Node(const in vec3 irradiance, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {\nreflectedLight.indirectDiffuse += irradiance * BRDF_Lambert(material.diffuseColor);\n}\nvoid RE_IndirectSpecular_Node(const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const 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, inout 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}\nvoid RE_DirectDiffuseOnly_Node(const in IncidentLight directLight, const in GeometricContext geometry, const in NodeMaterial material, inout 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_IndirectDiffuse_Empty(const in vec3 irradiance, const in GeometricContext geometry, const in NodeMaterial material, inout ReflectedLight reflectedLight) {}\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",oit_weighted_pars_fragment:"#ifdef USE_OIT_WEIGHTED\nlayout(location = 1) out float outBufferR;\n#endif",oit_weighted_fragment:"#ifdef USE_OIT_WEIGHTED\nfloat weight = 1.0 - gl_FragCoord.z;\noutBufferR = gl_FragColor.a * weight;\npc_fragColor = vec4(gl_FragColor.rgb * weight, gl_FragColor.a);\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}\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}\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}\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\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",node_osl_frag:"#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",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 = isOrthographic ? 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:"uniform 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_Direct RE_DirectDiffuseOnly_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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:"void 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 <shadowmask_pars_fragment>\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;\n#if __VERSION__ == 100\noutColor.r = choose[0];\noutColor.g = choose[1];\noutColor.b = choose[2];\noutAlpha = choose[3];\n#else\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutAlpha = choose[channelA];\n#endif\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);\n#if __VERSION__ == 100\noutColor.r = choose[0];\noutColor.g = choose[1];\noutColor.b = choose[2];\noutColor.a = choose[3];\n#else\noutColor.r = choose[channelR];\noutColor.g = choose[channelG];\noutColor.b = choose[channelB];\noutColor.a = choose[channelA];\n#endif\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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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 <lights_fragment_gtso>\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(\nfloat frontFacing,\nvec3 front, vec3 back,\nout vec3 outColor)\n{\noutColor = (frontFacing > 0.0) ? 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:"void 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:"void 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_Direct RE_DirectDiffuseOnly_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Empty\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\n#undef RE_IndirectDiffuse\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 <lights_fragment_gtso>\nvec3 viewWorld;\nif (isOrthographic)\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 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:"void 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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Empty\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\n#undef RE_IndirectDiffuse\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 <lights_fragment_gtso>\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:"vec3 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 (isOrthographic)\nviewWorld = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nelse\nviewWorld = (invViewMatrix * vec4(-vViewPosition, 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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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 <lights_fragment_gtso>\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 <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\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_Direct RE_DirectDiffuseOnly_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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:"void 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:"void 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:"void 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(bool clampRange, float value, float minVal, float maxVal, out float result) {\nif (clampRange)\nresult = (maxVal > minVal) ? clamp(value, minVal, maxVal) : clamp(value, maxVal, minVal);\nelse\nresult = min(max(value, minVal), maxVal);\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:"void 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:"void 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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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 <lights_fragment_gtso>\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:"void 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 (isOrthographic)\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\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:"void 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:"void 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:"void 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:"void node_layer_weight(vec3 viewPos, float blend, vec3 normal, out float fresnel, out float facing)\n{\nvec3 worldDir;\nif (isOrthographic)\nworldDir = (invViewMatrix * vec4(0.0, 0.0, -1.0, 0.0)).xyz;\nelse\nworldDir = (invViewMatrix * vec4(-viewPos, 0.0)).xyz;\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:"void 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\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}\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:"void 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_bl_frag:"void node_mix_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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_rgba_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}\nvoid node_mix_vector_uniform(float fac, vec3 facVec, vec3 v1, vec3 v2, out vec3 outVec)\n{\nfac = clamp(fac, 0.0, 1.0);\noutVec = mix(v1, v2, fac);\n}\nvoid node_mix_vector_non_uniform(float fac, vec3 facVec, vec3 v1, vec3 v2, out vec3 outVec)\n{\nfacVec = clamp(facVec, 0.0, 1.0);\noutVec = mix(v1, v2, facVec);\n}\nvoid node_mix_float(float fac, float val1, float val2, out float outVal)\n{\nfac = clamp(fac, 0.0, 1.0);\noutVal = mix(val1, val2, fac);\n}",node_mix_rgb_bl_frag:"void 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:"void 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(\nfloat 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 = isOrthographic ? 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) ? 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:"void 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:"void 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:"void 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:"uniform vec4 nodeRGB[NODE_RGB_NUM];\nvoid node_rgb(vec4 color, out vec4 outColor)\n{\noutColor = color;\n}",node_rgbtobw_bl_frag:"void 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:"void 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\n#define TEX_ALPHA_CLEAR 0\n#define TEX_ALPHA_PREMUL 1\n#define TEX_ALPHA_UNPREMUL 2\n#define TEX_ALPHA_ONE 3\nvec4 applyAlphaMode(vec4 color, const int alphaMode) {\nif (alphaMode == TEX_ALPHA_CLEAR) {\n} else if (alphaMode == TEX_ALPHA_PREMUL) {\ncolor.rgb = color.rgb * color.a;\n} else if (alphaMode == TEX_ALPHA_UNPREMUL) {\nfloat alpha = color.a;\ncolor.rgb = clamp(color.rgb, 0.0, alpha);\nif (alpha == 0.0)\ncolor.rgb = vec3(0.0);\nelse\ncolor.rgb /= alpha;\n}\nreturn color;\n}\nvoid node_tex_image(sampler2D ima, const int encoding, const int alphaMode, 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}\noutColor = applyAlphaMode(outColor, alphaMode);\nif (alphaMode == TEX_ALPHA_ONE)\noutAlpha = 1.0;\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:"void 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};\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 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:"#if __VERSION__ == 300\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}\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:"void 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:"uniform 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:"#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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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 <shadowmask_pars_fragment>\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;\n#if __VERSION__ == 100\nfor (float l = 3.0; l >= 1.0; l-=1.0) {\n#else\nfor (l = levels; l >= 1.0; l-=1.0) {\n#endif\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;\n#if __VERSION__ == 100\nfor (float l = 3.0; l >= 1.0; l-=1.0) {\n#else\nfor (l = levels; l >= 1.0; l-=1.0, ml-=1.0) {\n#endif\nn += abs(snoise(vec4(vec * f, phase))) / f;\nf *= 2.0;\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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#define RE_Refraction RE_Refraction_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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 <lights_fragment_gtso>\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_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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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\nif (length(tangent.xyz) == 0.0)\ntangent.x = 1.0;\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:"void 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_Direct RE_DirectDiffuseOnly_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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);\n#if __VERSION__ == 300\nfor (int depthId = 0; depthId < depthMax; depthId++) {\n#else\nfor (int depthId = 0; depthId < 3; depthId++) {\n#endif\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);\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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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_Direct RE_Direct_Node\n#define RE_IndirectDiffuse RE_IndirectDiffuse_Node\n#define RE_IndirectSpecular RE_IndirectSpecular_Node\n#include <lights_fragment_begin>\n#include <lights_fragment_maps>\n#include <lights_fragment_end>\n#undef RE_Direct\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(\nfloat 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 > 0.0);\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 <common>\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 <common>\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 <common>\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 <packing>\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 <common>\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 <packing>\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 <common>\n#include <packing>\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 <common>\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 <common>\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 <tonemapping_fragment>\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}",pp_oit_weighted_frag:"varying vec2 vUv;\nuniform sampler2D tRGBABuffer;\nuniform sampler2D tFloatBuffer;\nvoid main() {\nvec4 color = texture2D(tRGBABuffer, vUv);\nvec3 colorSum = color.rgb;\nfloat alphaProduct = color.a;\nfloat alphaSum = texture2D(tFloatBuffer, vUv).r;\ngl_FragColor = vec4(colorSum.rgb / max(alphaSum, 1e-5), 1.0 - alphaProduct);\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 <encodings_pars_fragment>\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}"},Tr={common:{diffuse:{value:new qn(16777215)},opacity:{value:1},map:{value:null},uvTransform:{value:new bn},uv2Transform:{value:new bn},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 yn(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 qn(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:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{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 qn(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new bn}},sprite:{diffuse:{value:new qn(16777215)},opacity:{value:1},center:{value:new yn(.5,.5)},rotation:{value:0},map:{value:null},alphaMap:{value:null},alphaTest:{value:0},uvTransform:{value:new bn}},mask:{depthTexture:{value:null},cameraNearFar:{value:new yn(.5,.5)},textureMatrix:{value:new zi}},node:{nodeRGB:{value:[]},nodeValue:{value:[]},flipCubeMap:{value:-1},materialIndex:{value:0}},nodeGTAO:{gtaoMap:{value:null}},ssr:{invProjectionMatrix:{value:new zi},ssrSourceBuffer:{value:null},ssrDepthBuffer:{value:null},ssrBackfaceDepthBuffer:{value:null},ssrStride:{value:20},ssrResolution:{value:new yn},ssrThickness:{value:.01},ssrJitter:{value:1},ssrMaxDistance:{value:100}},planeReflectionProbe:{planeReflTexture:{value:null},planeReflTextureMatrix:{value:new zi},planeReflDir:{value:new ci},planeReflBoundingBoxMin:{value:new ci},planeReflBoundingBoxMax:{value:new ci},planeReflInvModelMatrix:{value:new zi},planeReflFalloff:{value:0}}},Ir={basic:{uniforms:sr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.fog]),vertexShader:wr.meshbasic_vert,fragmentShader:wr.meshbasic_frag},lambert:{uniforms:sr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.fog,Tr.lights,{emissive:{value:new qn(0)}}]),vertexShader:wr.meshlambert_vert,fragmentShader:wr.meshlambert_frag},phong:{uniforms:sr([Tr.common,Tr.specularmap,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.fog,Tr.lights,{emissive:{value:new qn(0)},specular:{value:new qn(1118481)},shininess:{value:30}}]),vertexShader:wr.meshphong_vert,fragmentShader:wr.meshphong_frag},standard:{uniforms:sr([Tr.common,Tr.envmap,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.roughnessmap,Tr.metalnessmap,Tr.fog,Tr.lights,Tr.planeReflectionProbe,{emissive:{value:new qn(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new zi},envMapParallaxMatrixInv:{value:new zi}}]),vertexShader:wr.meshphysical_vert,fragmentShader:wr.meshphysical_frag},toon:{uniforms:sr([Tr.common,Tr.aomap,Tr.lightmap,Tr.emissivemap,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.gradientmap,Tr.fog,Tr.lights,{emissive:{value:new qn(0)}}]),vertexShader:wr.meshtoon_vert,fragmentShader:wr.meshtoon_frag},matcap:{uniforms:sr([Tr.common,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,Tr.fog,{matcap:{value:null}}]),vertexShader:wr.meshmatcap_vert,fragmentShader:wr.meshmatcap_frag},points:{uniforms:sr([Tr.points,Tr.fog]),vertexShader:wr.points_vert,fragmentShader:wr.points_frag},dashed:{uniforms:sr([Tr.common,Tr.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:wr.linedashed_vert,fragmentShader:wr.linedashed_frag},depth:{uniforms:sr([Tr.common,Tr.displacementmap,{slopeScaledBias:{value:0}}]),vertexShader:wr.depth_vert,fragmentShader:wr.depth_frag},normal:{uniforms:sr([Tr.common,Tr.bumpmap,Tr.normalmap,Tr.displacementmap,{opacity:{value:1}}]),vertexShader:wr.meshnormal_vert,fragmentShader:wr.meshnormal_frag},sprite:{uniforms:sr([Tr.sprite,Tr.fog]),vertexShader:wr.sprite_vert,fragmentShader:wr.sprite_frag},background:{uniforms:{uvTransform:{value:new bn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:wr.background_vert,fragmentShader:wr.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1}},vertexShader:wr.backgroundCube_vert,fragmentShader:wr.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:wr.cube_vert,fragmentShader:wr.cube_frag},equirect:{uniforms:{tEquirect:{value:null},invertU:{value:!1},offsetU:{value:0}},vertexShader:wr.equirect_vert,fragmentShader:wr.equirect_frag},distanceRGBA:{uniforms:sr([Tr.common,Tr.displacementmap,{referencePosition:{value:new ci},nearDistance:{value:1},farDistance:{value:1e3},slopeScaledBias:{value:0}}]),vertexShader:wr.distanceRGBA_vert,fragmentShader:wr.distanceRGBA_frag},shadow:{uniforms:sr([Tr.lights,Tr.fog,{color:{value:new qn(0)},opacity:{value:1}}]),vertexShader:wr.shadow_vert,fragmentShader:wr.shadow_frag},mask:{uniforms:sr([Tr.common,Tr.displacementmap,Tr.mask]),vertexShader:wr.mask_vert,fragmentShader:wr.mask_frag},equicube:{uniforms:{tEquirect:{value:null},faceIndex:{value:0},invertU:{value:!1},offsetU:{value:0}},vertexShader:wr.equicube_vert,fragmentShader:wr.equicube_frag},node:{uniforms:sr([Tr.common,Tr.displacementmap,Tr.envmap,Tr.fog,Tr.lights,Tr.ssr,Tr.planeReflectionProbe,Tr.node,Tr.nodeGTAO,{envMapIntensity:{value:1},envMapParallaxType:{value:0},envMapParallaxMatrix:{value:new zi},envMapParallaxMatrixInv:{value:new zi}}]),vertexShader:wr.meshnode_vert,fragmentShader:wr.meshnode_frag},cubeOctahedral:{uniforms:{tCube:{value:null},texelSize:{value:new yn(.5,.5)}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_cube_octahedral_proj_frag}};Ir.physical={uniforms:sr([Ir.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatNormalScale:{value:new yn(1,1)},clearcoatNormalMap:{value:null},iridescence:{value:0},iridescenceMap:{value:null},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},sheen:{value:0},sheenColor:{value:new qn(0)},sheenColorMap:{value:null},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},transmission:{value:0},transmissionMap:{value:null},transmissionSamplerSize:{value:new yn},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},attenuationDistance:{value:0},attenuationColor:{value:new qn(0)},specularIntensity:{value:1},specularIntensityMap:{value:null},specularColor:{value:new qn(1,1,1)},specularColorMap:{value:null}}]),vertexShader:wr.meshphysical_vert,fragmentShader:wr.meshphysical_frag},Ir.copy={uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_copy_frag},Ir.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:wr.pp_plane_vert,fragmentShader:wr.pp_bokeh_frag},Ir.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 yn(1/1024,1/512)}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_fxaa_frag},Ir.grayscale={uniforms:{tDiffuse:{value:null}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_grayscale_frag},Ir.brightness_contrast={uniforms:{tDiffuse:{value:null},brightness:{value:0},contrast:{value:0}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_brightness_contrast_frag},Ir.bloomLumHighPass={uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new qn(0)},defaultOpacity:{type:"f",value:0}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_bloom_lum_high_pass_frag},Ir.blur={defines:{LOG_SPACE:0,OCTAHEDRAL_MAP:0},uniforms:{colorTexture:{value:null},texSize:{value:new yn(.5,.5)},direction:{value:new yn(.5,.5)},kernelRadius:{value:1}},customPrepTokens:{MAX_SAMPLE_RADIUS:4},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_blur_frag},Ir.tonemap={defines:{ALPHA_AS_LUMA:0},uniforms:{tDiffuse:{value:null}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_tonemap_frag},Ir.afterimage={uniforms:{damp:{value:.96},tOld:{value:null},tNew:{value:null}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_afterimage_frag},Ir.oitWeighted={uniforms:{tRGBABuffer:{value:null},tFloatBuffer:{value:null}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_oit_weighted_frag};const Rr={r:0,b:0,g:0};function Lr(e,t,n,i,o,r,a){const s=new qn(0);let l,c,u=!0===r?0:1,d=null,h=0,m=null;function g(t,n){t.getRGB(Rr,lr(e)),i.buffers.color.setClear(Rr.r,Rr.g,Rr.b,n,a)}return{getClearColor:function(){return s},setClearColor:function(e,t=1){s.set(e),u=t,g(s,u)},getClearAlpha:function(){return u},setClearAlpha:function(e){u=e,g(s,u)},dispose:function(){l&&(l.geometry.dispose(),l.material.dispose()),l=void 0,c&&(c.geometry.dispose(),c.material.dispose()),c=void 0},render:function(i,r){let a=!1,v=!0===r.isScene?r.background:null;if(v&&v.isTexture){v=(r.backgroundBlurriness>0?n:t).get(v)}const A=e.xr,_=A.getSession&&A.getSession();_&&"additive"===_.environmentBlendMode&&(v=null),null===v?g(s,u):v&&v.isColor&&(g(v,1),a=!0),(e.autoClear||a)&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),v&&(v.isCubeTexture||v.mapping===ue)?(void 0===c&&(c=new ir(new rr(1,1,1),new ur({name:"BackgroundCubeMaterial",uniforms:ar(Ir.backgroundCube.uniforms),vertexShader:Ir.backgroundCube.vertexShader,fragmentShader:Ir.backgroundCube.fragmentShader,side:f,depthTest:!1,depthWrite:!1,fog:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(e,t,n){const i=n.far;this.matrixWorld.makeScale(i,i,i),this.matrixWorld.copyPosition(n.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),o.update(c)),c.material.uniforms.envMap.value=v,c.material.uniforms.flipEnvMap.value=v.isCubeTexture&&!1===v.isRenderTargetTexture?-1:1,c.material.uniforms.backgroundBlurriness.value=r.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=r.backgroundIntensity,c.material.toneMapped=r.backgroundToneMapped,d===v&&h===v.version&&m===e.toneMapping||(c.material.needsUpdate=!0,d=v,h=v.version,m=e.toneMapping),c.layers.enableAll(),i.unshift(c,c.geometry,c.material,0,0,null)):v&&v.isTexture&&(void 0===l&&(l=new ir(new Er(2,2),new ur({name:"BackgroundMaterial",uniforms:ar(Ir.background.uniforms),vertexShader:Ir.background.vertexShader,fragmentShader:Ir.background.fragmentShader,side:p,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),o.update(l)),l.material.uniforms.t2D.value=v,l.material.uniforms.backgroundIntensity.value=r.backgroundIntensity,l.material.toneMapped=r.backgroundToneMapped,!0===v.matrixAutoUpdate&&v.updateMatrix(),l.material.uniforms.uvTransform.value.copy(v.matrix),d===v&&h===v.version&&m===e.toneMapping||(l.material.needsUpdate=!0,d=v,h=v.version,m=e.toneMapping),l.layers.enableAll(),i.unshift(l,l.geometry,l.material,0,0,null))}}}function Pr(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=p(null);let c=l,u=!1;function d(t){return i.isWebGL2?e.bindVertexArray(t):r.bindVertexArrayOES(t)}function h(t){return i.isWebGL2?e.deleteVertexArray(t):r.deleteVertexArrayOES(t)}function p(e){const t=[],n=[],i=[];for(let e=0;e<o;e++)t[e]=0,n[e]=0,i[e]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:t,enabledAttributes:n,attributeDivisors:i,object:e,attributes:{},index:null}}function f(){const e=c.newAttributes;for(let t=0,n=e.length;t<n;t++)e[t]=0}function m(e){g(e,0)}function g(n,o){const r=c.newAttributes,a=c.enabledAttributes,s=c.attributeDivisors;if(r[n]=1,0===a[n]&&(e.enableVertexAttribArray(n),a[n]=1),s[n]!==o){(i.isWebGL2?e:t.get("ANGLE_instanced_arrays"))[i.isWebGL2?"vertexAttribDivisor":"vertexAttribDivisorANGLE"](n,o),s[n]=o}}function v(){const t=c.newAttributes,n=c.enabledAttributes;for(let i=0,o=n.length;i<o;i++)n[i]!==t[i]&&(e.disableVertexAttribArray(i),n[i]=0)}function A(t,n,o,r,a,s){!0!==i.isWebGL2||5124!==o&&5125!==o?e.vertexAttribPointer(t,n,o,r,a,s):e.vertexAttribIPointer(t,n,o,a,s)}function _(){x(),u=!0,c!==l&&(c=l,d(c.object))}function x(){l.geometry=null,l.program=null,l.wireframe=!1}return{setup:function(o,l,h,_,x){let y=!1;if(a){const t=function(t,n,o){const a=!0===o.wireframe;let l=s[t.id];void 0===l&&(l={},s[t.id]=l);let c=l[n.id];void 0===c&&(c={},l[n.id]=c);let u=c[a];void 0===u&&(u=p(i.isWebGL2?e.createVertexArray():r.createVertexArrayOES()),c[a]=u);return u}(_,h,l);c!==t&&(c=t,d(c.object)),y=function(e,t,n,i){const o=c.attributes,r=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){const n=o[t];let i=r[t];if(void 0===i&&("instanceMatrix"===t&&e.instanceMatrix&&(i=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(i=e.instanceColor)),void 0===n)return!0;if(n.attribute!==i)return!0;if(i&&n.data!==i.data)return!0;a++}}return c.attributesNum!==a||c.index!==i}(o,_,h,x),y&&function(e,t,n,i){const o={},r=t.attributes;let a=0;const s=n.getAttributes();for(const t in s){if(s[t].location>=0){let n=r[t];void 0===n&&("instanceMatrix"===t&&e.instanceMatrix&&(n=e.instanceMatrix),"instanceColor"===t&&e.instanceColor&&(n=e.instanceColor));const i={};i.attribute=n,n&&n.data&&(i.data=n.data),o[t]=i,a++}}c.attributes=o,c.attributesNum=a,c.index=i}(o,_,h,x)}else{const e=!0===l.wireframe;c.geometry===_.id&&c.program===h.id&&c.wireframe===e||(c.geometry=_.id,c.program=h.id,c.wireframe=e,y=!0)}null!==x&&n.update(x,34963),(y||u)&&(u=!1,function(o,r,a,s){if(!1===i.isWebGL2&&(o.isInstancedMesh||s.isInstancedBufferGeometry)&&null===t.get("ANGLE_instanced_arrays"))return;f();const l=s.attributes,c=a.getAttributes(),u=r.defaultAttributeValues;for(const t in c){const i=c[t];if(i.location>=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.isInstancedInterleavedBuffer){for(let e=0;e<i.locationSize;e++)g(i.location+e,n.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=n.meshPerAttribute*n.count)}else for(let e=0;e<i.locationSize;e++)m(i.location+e);e.bindBuffer(34962,c);for(let e=0;e<i.locationSize;e++)A(i.location+e,a/i.locationSize,u,t,l*d,(h+a/i.locationSize*e)*d)}else{if(r.isInstancedBufferAttribute){for(let e=0;e<i.locationSize;e++)g(i.location+e,r.meshPerAttribute);!0!==o.isInstancedMesh&&void 0===s._maxInstanceCount&&(s._maxInstanceCount=r.meshPerAttribute*r.count)}else for(let e=0;e<i.locationSize;e++)m(i.location+e);e.bindBuffer(34962,c);for(let e=0;e<i.locationSize;e++)A(i.location+e,a/i.locationSize,u,t,a*d,a/i.locationSize*e*d)}}else if(void 0!==u){const n=u[t];if(void 0!==n)switch(n.length){case 2:e.vertexAttrib2fv(i.location,n);break;case 3:e.vertexAttrib3fv(i.location,n);break;case 4:e.vertexAttrib4fv(i.location,n);break;default:e.vertexAttrib1fv(i.location,n)}}}}v()}(o,l,h,_),null!==x&&e.bindBuffer(34963,n.get(x).buffer))},reset:_,resetDefaultState:x,dispose:function(){_();for(const e in s){const t=s[e];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e]}},releaseStatesOfGeometry:function(e){if(void 0===s[e.id])return;const t=s[e.id];for(const e in t){const n=t[e];for(const e in n)h(n[e].object),delete n[e];delete t[e]}delete s[e.id]},releaseStatesOfProgram:function(e){for(const t in s){const n=s[t];if(void 0===n[e.id])continue;const i=n[e.id];for(const e in i)h(i[e].object),delete i[e];delete n[e.id]}},initAttributes:f,enableAttribute:m,disableUnusedAttributes:v}}function Br(e,t,n,i){const o=i.isWebGL2;let r;this.setMode=function(e){r=e},this.render=function(t,i){e.drawArrays(r,t,i),n.update(i,r,1)},this.renderInstances=function(i,a,s){if(0===s)return;let l,c;if(o)l=e,c="drawArraysInstanced";else if(l=t.get("ANGLE_instanced_arrays"),c="drawArraysInstancedANGLE",null===l)return void console.error("v3d.WebGLBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");l[c](r,i,a,s),n.update(a,r,s)}}function Dr(e,t,n){let i;function o(t){if("highp"===t){if(e.getShaderPrecisionFormat(35633,36338).precision>0&&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 Nr(e){const t=this;let n=null,i=0,o=!1,r=!1;const a=new xr,s=new bn,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.length<t)&&(c=new Float32Array(t));for(let t=0,n=i;t!==r;++t,n+=4)a.copy(e[t]).applyMatrix4(o,s),a.normal.toArray(c,n),c[n+3]=a.constant}l.value=c,l.needsUpdate=!0}return t.numPlanes=r,t.numIntersection=0,c}this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(e,t,r){const a=0!==e.length||t||0!==i||o;return o=t,n=u(e,r,0),i=e.length,a},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1,c()},this.setState=function(t,a,s){const d=t.clippingPlanes,h=t.clipIntersection,p=t.clipShadows,f=e.get(t);if(!o||null===d||0===d.length||r&&!p)r?u(null):c();else{const e=r?0:i,t=4*e;let o=f.clippingState||null;l.value=o,o=u(d,a,t,s);for(let e=0;e!==t;++e)o[e]=n[e];f.clippingState=o,this.numIntersection=h?this.numPlanes:0,this.numPlanes+=e}}}function Or(e){let t=new WeakMap;function n(e,t){return t===le?e.mapping=ae:t===ce&&(e.mapping=se),e}function i(e){const n=e.target;n.removeEventListener("dispose",i);const o=t.get(n);void 0!==o&&(t.delete(n),o.dispose())}return{get:function(o){if(o&&o.isTexture&&!1===o.isRenderTargetTexture){const r=o.mapping;if(r===le||r===ce){if(t.has(o)){return n(t.get(o).texture,o.mapping)}{const r=o.image;if(r&&r.height>0){const a=new gr(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}}}class Fr extends dr{constructor(e=-1,t=1,n=1,i=-1,o=.1,r=2e3){super(),this.isOrthographicCamera=!0,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}}class Ur extends ur{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class zr extends uo{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.overrideMaterial=null,this.backgroundToneMapped=!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()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundToneMapped=e.backgroundToneMapped,null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.backgroundIntensity=this.backgroundIntensity),!1===this.backgroundToneMapped&&(t.backgroundToneMapped=!1),t}get autoUpdate(){return console.warn("v3d.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate}set autoUpdate(e){console.warn("v3d.Scene: autoUpdate was renamed to matrixWorldAutoUpdate in r144."),this.matrixWorldAutoUpdate=e}dispose(){this.dispatchEvent({type:"dispose"})}}let Vr=256;const Gr=[{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 kr(e){return Gr[e].relSize*Vr}const Qr=20,Wr=new Fr,Hr=Gr.map((function(e,t){const n=1/(kr(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 zo;return c.setAttribute("position",new To(a,3)),c.setAttribute("uv",new To(s,2)),c.setAttribute("faceIndex",new To(l,1)),c})),jr=new qn;let Yr=null;const Xr=(1+Math.sqrt(5))/2,Kr=1/Xr,qr=[new ci(1,1,1),new ci(-1,1,1),new ci(1,1,-1),new ci(-1,1,-1),new ci(0,Xr,Kr),new ci(0,Xr,-Kr),new ci(Kr,0,Xr),new ci(-Kr,0,Xr),new ci(Xr,Kr,0),new ci(-Xr,Kr,0)];class Zr{constructor(e,t){this._renderer=e,this._pingPongRenderTarget=null,this._equirectShader=null,this._cubemapShader=null,this.flipCubemapX=!0,Object.defineProperties(this,{maxTileSize:{get:function(){return Vr},set:function(e){Vr=e}}}),void 0!==t&&(this.maxTileSize=t),this._blurMaterial=function(e,t){const n=new Float32Array(e),i=new ci(0,1,0),o=new Ur({defines:{n:e,cubeUV_maxTileSize:Dn(t)},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},lodIdx:{value:0},poleAxis:{value:i}},vertexShader:na(),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 <cube_uv_reflection_fragment>\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:v,depthTest:!1,depthWrite:!1});return o.type="SphericalGaussianBlur",o}(Qr,this.maxTileSize),this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,i=100){Yr=this._renderer.getRenderTarget();const o=this._allocateTargets();return this._sceneToCubeUV(e,n,i,o),t>0&&this._blur(o,0,0,t),this._applyPMREM(o),this._cleanup(o),o}fromEquirectangular(e){return e.magFilter=ve,e.minFilter=ve,e.generateMipmaps=!1,this.fromCubemap(e)}fromCubemap(e){Yr=this._renderer.getRenderTarget();const t=this._allocateTargets(e);return this._textureToCubeUV(e,t,this.flipCubemapX),this._applyPMREM(t),this._cleanup(t),t}fromCubeRenderTarget(e,t){const n=this._allocateTargets(e.texture,t);return this._cubeRTToCubeUV(e,n,this.flipCubemapX),this._applyPMREM(n),this._cleanup(n),n}compileCubemapShader(){null===this._cubemapShader&&(this._cubemapShader=ta(),this._compileMaterial(this._cubemapShader))}compileEquirectangularShader(){null===this._equirectShader&&(this._equirectShader=ea(),this._compileMaterial(this._equirectShader))}dispose(){this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose(),null!==this._cubemapShader&&this._cubemapShader.dispose(),null!==this._equirectShader&&this._equirectShader.dispose();for(let e=0;e<Hr.length;e++)Hr[e].dispose();this._renderer=null}_cleanup(e){this._renderer.setRenderTarget(Yr),e.scissorTest=!1,e.setSize(e.width,e.height)}_allocateTargets(e,t){const n={magFilter:ve,minFilter:ve,generateMipmaps:!1,type:e?e.type:we,format:e?e.format:Be,encoding:e?e.encoding:It,depthBuffer:!1,stencilBuffer:!1};void 0!==t&&Object.assign(n,t);const i=Jr(n);return i.depthBuffer=!e,null===this._pingPongRenderTarget&&(this._pingPongRenderTarget=Jr(n)),i}_compileMaterial(e){const t=new zr;t.add(new ir(Hr[0],e)),this._renderer.compile(t,Wr)}_sceneToCubeUV(e,t,n,i){const o=new hr(90,1,t,n),r=[1,1,1,1,-1,1],a=[1,1,-1,-1,-1,1],s=this._renderer,l=s.outputEncoding,c=s.toneMapping,u=s.toneMappingExposure;s.getClearColor(jr);const d=s.getClearAlpha();s.toneMapping=Z,s.toneMappingExposure=1,s.outputEncoding=It,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;s.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 l=kr(0);$r(i,n*l,t>2?l:0,l,l),s.setRenderTarget(i),s.render(e,o)}s.toneMapping=c,s.toneMappingExposure=u,s.outputEncoding=l,s.setClearColor(jr,d),e.scale.z*=-1}_textureToCubeUV(e,t,n){const i=this._renderer,o=new zr;e.isCubeTexture?null===this._cubemapShader&&(this._cubemapShader=ta()):null===this._equirectShader&&(this._equirectShader=ea());const r=e.isCubeTexture?this._cubemapShader:this._equirectShader;o.add(new ir(Hr[0],r));const a=r.uniforms;a.envMap.value=e,e.isCubeTexture?a.flipCubemapX.value=n||!1:a.texelSize.value.set(1/e.image.width,1/e.image.height);const s=kr(0);$r(t,0,0,3*s,2*s),i.setRenderTarget(t),i.render(o,Wr)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;for(let t=1;t<Gr.length;t++){const n=Gr[t].sigma,i=Gr[t-1].sigma,o=Math.sqrt(n*n-i*i),r=qr[(t-1)%qr.length];this._blur(e,t-1,t,o,r)}t.autoClear=n}_blur(e,t,n,i,o){const r=this._pingPongRenderTarget;this._halfBlur(e,r,t,n,i,"latitudinal",o),this._halfBlur(r,e,n,n,i,"longitudinal",o)}_halfBlur(e,t,n,i,o,r,a){const s=this._renderer,l=this._blurMaterial;"latitudinal"!==r&&"longitudinal"!==r&&console.error("blur direction must be either latitudinal or longitudinal!");const c=new zr;c.add(new ir(Hr[i],l));const u=l.uniforms,d=kr(n)-1;let h=isFinite(o)?Math.PI/(2*d):2*Math.PI/39,p=o/h,f=isFinite(o)?1+Math.floor(3*p):Qr;f>Qr&&(f=Qr,p=19/3,h=o/p);const m=[];let g=0;for(let e=0;e<Qr;++e){const t=e/p,n=Math.exp(-t*t/2);m.push(n),0===e?g+=n:e<f&&(g+=2*n)}for(let e=0;e<m.length;e++)m[e]=m[e]/g;u.envMap.value=e.texture,u.samples.value=f,u.weights.value=m,u.latitudinal.value="latitudinal"===r,a&&(u.poleAxis.value=a),u.dTheta.value=h,u.lodIdx.value=n;l.defines.cubeUV_maxTileSize=Dn(kr(0));const[v,A]=Gr[i].origin.map((function(e){return e*Vr*3}));const _=kr(i);$r(t,v,A,3*_,2*_),s.setRenderTarget(t),s.render(c,Wr)}_cubeRTToCubeUV(e,t,n){const i=this._renderer,o=new zr;null==this._cubemapShader&&(this._cubemapShader=ta());const r=this._cubemapShader;o.add(new ir(Hr[0],r));const a=r.uniforms;a.envMap.value=e.texture,a.flipCubemapX.value=n||!1;const s=kr(0);$r(t,0,0,3*s,2*s),i.setRenderTarget(t),i.render(o,Wr)}}function Jr(e){const t=kr(0),n=new oi(3*t,3*t,e);return n.texture.mapping=ue,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function $r(e,t,n,i,o){e.viewport.set(t,n,i,o),e.scissor.set(t,n,i,o)}function ea(){const e=new yn(1,1),t=new Ur({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null},texelSize:{value:e}},vertexShader:na(),fragmentShader:"\n\n            precision mediump float;\n            precision mediump int;\n\n            varying vec3 vOutputDirection;\n\n            uniform sampler2D envMap;\n            uniform vec2 texelSize;\n\n            #define RECIPROCAL_PI 0.31830988618\n            #define RECIPROCAL_PI2 0.15915494\n\n            void main() {\n\n                gl_FragColor = vec4(0.0);\n\n                vec3 outputDirection = normalize(vOutputDirection);\n                vec2 uv;\n                uv.y = asin(clamp(outputDirection.y, -1.0, 1.0)) * RECIPROCAL_PI + 0.5;\n                uv.x = atan(outputDirection.z, outputDirection.x) * RECIPROCAL_PI2 + 0.5;\n\n                vec2 f = fract(uv / texelSize - 0.5);\n                uv -= f * texelSize;\n                vec3 tl = texture2D(envMap, uv).rgb;\n                uv.x += texelSize.x;\n                vec3 tr = texture2D(envMap, uv).rgb;\n                uv.y += texelSize.y;\n                vec3 br = texture2D(envMap, uv).rgb;\n                uv.x -= texelSize.x;\n                vec3 bl = texture2D(envMap, uv).rgb;\n\n                vec3 tm = mix(tl, tr, f.x);\n                vec3 bm = mix(bl, br, f.x);\n                gl_FragColor.rgb = mix(tm, bm, f.y);\n\n            }\n        ",blending:v,depthTest:!1,depthWrite:!1});return t.type="EquirectangularToCubeUV",t}function ta(){const e=new Ur({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipCubemapX:{value:!0}},vertexShader:na(),fragmentShader:"\n\n            precision mediump float;\n            precision mediump int;\n\n            uniform bool flipCubemapX;\n\n            varying vec3 vOutputDirection;\n\n            uniform samplerCube envMap;\n\n            void main() {\n\n                gl_FragColor = textureCube(envMap, vec3(vOutputDirection.x * (flipCubemapX ? -1.0 : 1.0), vOutputDirection.yz));\n\n            }\n        ",blending:v,depthTest:!1,depthWrite:!1});return e.type="CubemapToCubeUV",e}function na(){return"\n\n        precision mediump float;\n        precision mediump int;\n\n        attribute vec3 position;\n        attribute vec2 uv;\n        attribute float faceIndex;\n\n        varying vec3 vOutputDirection;\n\n        // RH coordinate system; PMREM face-indexing convention\n        vec3 getDirection(vec2 uv, float face) {\n\n            uv = 2.0 * uv - 1.0;\n\n            vec3 direction = vec3(uv, 1.0);\n\n            if (face == 0.0) {\n\n                direction = direction.zyx;\n                direction.z *= -1.0;\n\n            } else if (face == 1.0) {\n\n                direction = direction.xzy;\n                direction.z *= -1.0;\n\n            } else if (face == 3.0) {\n\n                direction = direction.zyx;\n                direction.x *= -1.0;\n\n            } else if (face == 4.0) {\n\n                direction = direction.xzy;\n                direction.y *= -1.0;\n\n            } else if (face == 5.0) {\n\n                direction.xz *= -1.0;\n\n            }\n\n            return direction;\n\n        }\n\n        void main() {\n\n            vOutputDirection = getDirection(uv, faceIndex);\n            gl_Position = vec4(position, 1.0);\n\n        }\n    "}function ia(e){let t=new WeakMap,n=null;function i(e){const n=e.target;n.removeEventListener("dispose",i);const o=t.get(n);void 0!==o&&(t.delete(n),o.dispose())}return{get:function(o){if(o&&o.isTexture){const r=o.mapping,a=r===le||r===ce,s=r===ae||r===se;if(a||s){if(o.isRenderTargetTexture&&!0===o.needsPMREMUpdate){o.needsPMREMUpdate=!1;let i=t.get(o);return null===n&&(n=new Zr(e)),i=a?n.fromEquirectangular(o,i):n.fromCubemap(o,i),t.set(o,i),i.texture}if(t.has(o))return t.get(o).texture;{const r=o.image;if(a&&r&&r.height>0||s&&r&&function(e){let t=0;const n=6;for(let i=0;i<n;i++)void 0!==e[i]&&t++;return t===n}(r)){null===n&&(n=new Zr(e));const r=a?n.fromEquirectangular(o):n.fromCubemap(o);return t.set(o,r),o.addEventListener("dispose",i),r.texture}return null}}}return o},dispose:function(){t=new WeakMap,null!==n&&(n.dispose(),n=null)}}}function oa(e){const t={};function n(n){if(void 0!==t[n])return t[n];let i;switch(n){case"WEBGL_depth_texture":i=e.getExtension("WEBGL_depth_texture")||e.getExtension("MOZ_WEBGL_depth_texture")||e.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":i=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":i=e.getExtension("WEBGL_compressed_texture_s3tc")||e.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":i=e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:i=e.getExtension(n)}return t[n]=i,i}return{has:function(e){return null!==n(e)},init:function(e){e.isWebGL2?n("EXT_color_buffer_float"):(n("WEBGL_depth_texture"),n("OES_texture_float"),n("OES_texture_half_float"),n("OES_texture_half_float_linear"),n("OES_standard_derivatives"),n("OES_element_index_uint"),n("OES_vertex_array_object"),n("ANGLE_instanced_arrays")),n("OES_texture_float_linear"),n("EXT_color_buffer_half_float"),n("WEBGL_multisampled_render_to_texture")},get:function(e){const t=n(e);return null===t&&console.warn("v3d.WebGLRenderer: "+e+" extension not supported."),t}}}function ra(e,t,n,i){const o={},r=new WeakMap;function a(e){const s=e.target;null!==s.index&&t.remove(s.index);for(const e in s.attributes)t.remove(s.attributes[e]);s.removeEventListener("dispose",a),delete o[s.id];const l=r.get(s);l&&(t.remove(l),r.delete(s)),i.releaseStatesOfGeometry(s),!0===s.isInstancedBufferGeometry&&delete s._maxInstanceCount,n.memory.geometries--}function s(e){const n=[],i=e.index,o=e.attributes.position;let a=0;if(null!==i){const e=i.array;a=i.version;for(let t=0,i=e.length;t<i;t+=3){const i=e[t+0],o=e[t+1],r=e[t+2];n.push(i,o,o,r,r,i)}}else{const e=o.array;a=o.version;for(let t=0,i=e.length/3-1;t<i;t+=3){const e=t+0,i=t+1,o=t+2;n.push(e,i,i,o,o,e)}}const s=new(Sn(n)?Ro:Io)(n,1);s.version=a;const l=r.get(e);l&&t.remove(l),r.set(e,s)}return{get:function(e,t){return!0===o[t.id]||(t.addEventListener("dispose",a),o[t.id]=!0,n.memory.geometries++),t},update:function(e){const n=e.attributes;for(const e in n)t.update(n[e],34962);const i=e.morphAttributes;for(const e in i){const n=i[e];for(let e=0,i=n.length;e<i;e++)t.update(n[e],34962)}},getWireframeAttribute:function(e){const t=r.get(e);if(t){const n=e.index;null!==n&&t.version<n.version&&s(e)}else s(e);return r.get(e)}}}function aa(e,t,n,i){const o=i.isWebGL2;let r,a,s;this.setMode=function(e){r=e},this.setIndex=function(e){a=e.type,s=e.bytesPerElement},this.render=function(t,i){e.drawElements(r,i,a,t*s),n.update(i,r,1)},this.renderInstances=function(i,l,c){if(0===c)return;let u,d;if(o)u=e,d="drawElementsInstanced";else if(u=t.get("ANGLE_instanced_arrays"),d="drawElementsInstancedANGLE",null===u)return void console.error("v3d.WebGLIndexedBufferRenderer: using v3d.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");u[d](r,l,a,i*s,c),n.update(l,r,c)}}function sa(e){const t={geometries:0,textures:0,textureSpecs:new Map},n={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:t,render:n,programs:null,autoReset:!0,reset:function(){n.frame++,n.calls=0,n.triangles=0,n.points=0,n.lines=0},update:function(e,t,i){switch(n.calls++,t){case 4:n.triangles+=i*(e/3);break;case 1:n.lines+=i*(e/2);break;case 3:n.lines+=i*(e-1);break;case 2:n.lines+=i*e;break;case 0:n.points+=i*e;break;default:console.error("v3d.WebGLInfo: Unknown draw mode:",t)}},addTextureSpec:function(e){let n,i,o,r,a;e.isWebGLRenderTarget?(n=e.texture.name,i="RenderTarget",o=e.width,r=e.height,a=e.texture.format):(n=e.name,i="Texture",o=e.image.width,r=e.image.height,a=e.format),t.textureSpecs.set(e,{name:n,type:i,width:o,height:r,format:a})},removeTextureSpec:function(e){t.textureSpecs.delete(e)}}}function la(e,t){return e[0]-t[0]}function ca(e,t){return Math.abs(t[1])-Math.abs(e[1])}function ua(e,t,n){const i={},o=new Float32Array(12),r=new WeakMap,a=new ii,s=[];for(let e=0;e<12;e++)s[e]=[e,0];return{update:function(l,c,u,d){const h=l.morphTargetInfluences;if(!0===t.isWebGL2){const p=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,f=void 0!==p?p.length:0;let m=r.get(c);if(void 0===m||m.count!==f){void 0!==m&&m.texture.dispose();const A=void 0!==c.morphAttributes.position,_=void 0!==c.morphAttributes.normal,x=void 0!==c.morphAttributes.color,y=c.morphAttributes.position||[],b=c.morphAttributes.normal||[],C=c.morphAttributes.color||[];let M=0;!0===A&&(M=1),!0===_&&(M=2),!0===x&&(M=3);let S=c.attributes.position.count*M,E=1;S>t.maxTextureSize&&(E=Math.ceil(S/t.maxTextureSize),S=t.maxTextureSize);const w=new Float32Array(S*E*4*f),T=new ri(w,S,E,f);T.type=Ee,T.needsUpdate=!0;const I=4*M;for(let L=0;L<f;L++){const P=y[L],B=b[L],D=C[L],N=S*E*4*L;for(let O=0;O<P.count;O++){const F=O*I;!0===A&&(a.fromBufferAttribute(P,O),w[N+F+0]=a.x,w[N+F+1]=a.y,w[N+F+2]=a.z,w[N+F+3]=0),!0===_&&(a.fromBufferAttribute(B,O),w[N+F+4]=a.x,w[N+F+5]=a.y,w[N+F+6]=a.z,w[N+F+7]=0),!0===x&&(a.fromBufferAttribute(D,O),w[N+F+8]=a.x,w[N+F+9]=a.y,w[N+F+10]=a.z,w[N+F+11]=4===D.itemSize?a.w:1)}}function R(){T.dispose(),r.delete(c),c.removeEventListener("dispose",R)}m={count:f,texture:T,size:new yn(S,E)},r.set(c,m),c.addEventListener("dispose",R)}let g=0;for(let U=0;U<h.length;U++)g+=h[U];const v=c.morphTargetsRelative?1:1-g;d.getUniforms().setValue(e,"morphTargetBaseInfluence",v),d.getUniforms().setValue(e,"morphTargetInfluences",h),d.getUniforms().setValue(e,"morphTargetsTexture",m.texture,n),d.getUniforms().setValue(e,"morphTargetsTextureSize",m.size)}else{const z=void 0===h?0:h.length;let V=i[c.id];if(void 0===V||V.length!==z){V=[];for(let H=0;H<z;H++)V[H]=[H,0];i[c.id]=V}for(let j=0;j<z;j++){const Y=V[j];Y[0]=j,Y[1]=h[j]}V.sort(ca);for(let X=0;X<12;X++)X<z&&V[X][1]?(s[X][0]=V[X][0],s[X][1]=V[X][1]):(s[X][0]=Number.MAX_SAFE_INTEGER,s[X][1]=0);s.sort(la);const G=c.morphAttributes.position,k=c.morphAttributes.normal;let Q=0;for(let K=0;K<12;K++){const q=s[K],Z=q[0],J=q[1];Z!==Number.MAX_SAFE_INTEGER&&J?(G&&c.getAttribute("morphTarget"+K)!==G[Z]&&c.setAttribute("morphTarget"+K,G[Z]),k&&c.getAttribute("morphNormal"+K)!==k[Z]&&c.setAttribute("morphNormal"+K,k[Z]),o[K]=J,Q+=J):(G&&!0===c.hasAttribute("morphTarget"+K)&&c.deleteAttribute("morphTarget"+K),k&&!0===c.hasAttribute("morphNormal"+K)&&c.deleteAttribute("morphNormal"+K),o[K]=0)}const W=c.morphTargetsRelative?1:1-Q;d.getUniforms().setValue(e,"morphTargetBaseInfluence",W),d.getUniforms().setValue(e,"morphTargetInfluences",o)}}}}function da(e,t,n,i){let o=new WeakMap;function r(e){const t=e.target;t.removeEventListener("dispose",r),n.remove(t.instanceMatrix),null!==t.instanceColor&&n.remove(t.instanceColor)}return{update:function(e){const a=i.render.frame,s=e.geometry,l=t.get(e,s);return o.get(l)!==a&&(t.update(l),o.set(l,a)),e.isInstancedMesh&&(!1===e.hasEventListener("dispose",r)&&e.addEventListener("dispose",r),n.update(e.instanceMatrix,34962),null!==e.instanceColor&&n.update(e.instanceColor,34962)),l},dispose:function(){o=new WeakMap}}}const ha=new ni,pa=new ri,fa=new ai,ma=new mr,ga=[],va=[],Aa=new Float32Array(16),_a=new Float32Array(9),xa=new Float32Array(4);function ya(e,t,n){const i=e[0];if(i<=0||i>0)return e;const o=t*n;let r=ga[o];if(void 0===r&&(r=new Float32Array(o),ga[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 ba(e,t){if(e.length!==t.length)return!1;for(let n=0,i=e.length;n<i;n++)if(e[n]!==t[n])return!1;return!0}function Ca(e,t){for(let n=0,i=t.length;n<i;n++)e[n]=t[n]}function Ma(e,t){let n=va[t];void 0===n&&(n=new Int32Array(t),va[t]=n);for(let i=0;i!==t;++i)n[i]=e.allocateTextureUnit();return n}function Sa(e,t){const n=this.cache;n[0]!==t&&(e.uniform1f(this.addr,t),n[0]=t)}function Ea(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2f(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ba(n,t))return;e.uniform2fv(this.addr,t),Ca(n,t)}}function wa(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3f(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else if(void 0!==t.r)n[0]===t.r&&n[1]===t.g&&n[2]===t.b||(e.uniform3f(this.addr,t.r,t.g,t.b),n[0]=t.r,n[1]=t.g,n[2]=t.b);else{if(ba(n,t))return;e.uniform3fv(this.addr,t),Ca(n,t)}}function Ta(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4f(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ba(n,t))return;e.uniform4fv(this.addr,t),Ca(n,t)}}function Ia(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(ba(n,t))return;e.uniformMatrix2fv(this.addr,!1,t),Ca(n,t)}else{if(ba(n,i))return;xa.set(i),e.uniformMatrix2fv(this.addr,!1,xa),Ca(n,i)}}function Ra(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(ba(n,t))return;e.uniformMatrix3fv(this.addr,!1,t),Ca(n,t)}else{if(ba(n,i))return;_a.set(i),e.uniformMatrix3fv(this.addr,!1,_a),Ca(n,i)}}function La(e,t){const n=this.cache,i=t.elements;if(void 0===i){if(ba(n,t))return;e.uniformMatrix4fv(this.addr,!1,t),Ca(n,t)}else{if(ba(n,i))return;Aa.set(i),e.uniformMatrix4fv(this.addr,!1,Aa),Ca(n,i)}}function Pa(e,t){const n=this.cache;n[0]!==t&&(e.uniform1i(this.addr,t),n[0]=t)}function Ba(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2i(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ba(n,t))return;e.uniform2iv(this.addr,t),Ca(n,t)}}function Da(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3i(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ba(n,t))return;e.uniform3iv(this.addr,t),Ca(n,t)}}function Na(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4i(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ba(n,t))return;e.uniform4iv(this.addr,t),Ca(n,t)}}function Oa(e,t){const n=this.cache;n[0]!==t&&(e.uniform1ui(this.addr,t),n[0]=t)}function Fa(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y||(e.uniform2ui(this.addr,t.x,t.y),n[0]=t.x,n[1]=t.y);else{if(ba(n,t))return;e.uniform2uiv(this.addr,t),Ca(n,t)}}function Ua(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z||(e.uniform3ui(this.addr,t.x,t.y,t.z),n[0]=t.x,n[1]=t.y,n[2]=t.z);else{if(ba(n,t))return;e.uniform3uiv(this.addr,t),Ca(n,t)}}function za(e,t){const n=this.cache;if(void 0!==t.x)n[0]===t.x&&n[1]===t.y&&n[2]===t.z&&n[3]===t.w||(e.uniform4ui(this.addr,t.x,t.y,t.z,t.w),n[0]=t.x,n[1]=t.y,n[2]=t.z,n[3]=t.w);else{if(ba(n,t))return;e.uniform4uiv(this.addr,t),Ca(n,t)}}function Va(e,t,n){const i=this.cache,o=n.allocateTextureUnit();i[0]!==o&&(e.uniform1i(this.addr,o),i[0]=o),n.setTexture2D(t||ha,o)}function Ga(e,t,n){const i=this.cache,o=n.allocateTextureUnit();i[0]!==o&&(e.uniform1i(this.addr,o),i[0]=o),n.setTexture3D(t||fa,o)}function ka(e,t,n){const i=this.cache,o=n.allocateTextureUnit();i[0]!==o&&(e.uniform1i(this.addr,o),i[0]=o),n.setTextureCube(t||ma,o)}function Qa(e,t,n){const i=this.cache,o=n.allocateTextureUnit();i[0]!==o&&(e.uniform1i(this.addr,o),i[0]=o),n.setTexture2DArray(t||pa,o)}function Wa(e,t){e.uniform1fv(this.addr,t)}function Ha(e,t){const n=ya(t,this.size,2);e.uniform2fv(this.addr,n)}function ja(e,t){const n=ya(t,this.size,3);e.uniform3fv(this.addr,n)}function Ya(e,t){const n=ya(t,this.size,4);e.uniform4fv(this.addr,n)}function Xa(e,t){const n=ya(t,this.size,4);e.uniformMatrix2fv(this.addr,!1,n)}function Ka(e,t){const n=ya(t,this.size,9);e.uniformMatrix3fv(this.addr,!1,n)}function qa(e,t){const n=ya(t,this.size,16);e.uniformMatrix4fv(this.addr,!1,n)}function Za(e,t){e.uniform1iv(this.addr,t)}function Ja(e,t){e.uniform2iv(this.addr,t)}function $a(e,t){e.uniform3iv(this.addr,t)}function es(e,t){e.uniform4iv(this.addr,t)}function ts(e,t){e.uniform1uiv(this.addr,t)}function ns(e,t){e.uniform2uiv(this.addr,t)}function is(e,t){e.uniform3uiv(this.addr,t)}function os(e,t){e.uniform4uiv(this.addr,t)}function rs(e,t,n){const i=this.cache,o=t.length,r=Ma(n,o);ba(i,r)||(e.uniform1iv(this.addr,r),Ca(i,r));for(let e=0;e!==o;++e)n.setTexture2D(t[e]||ha,r[e])}function as(e,t,n){const i=this.cache,o=t.length,r=Ma(n,o);ba(i,r)||(e.uniform1iv(this.addr,r),Ca(i,r));for(let e=0;e!==o;++e)n.setTexture3D(t[e]||fa,r[e])}function ss(e,t,n){const i=this.cache,o=t.length,r=Ma(n,o);ba(i,r)||(e.uniform1iv(this.addr,r),Ca(i,r));for(let e=0;e!==o;++e)n.setTextureCube(t[e]||ma,r[e])}function ls(e,t,n){const i=this.cache,o=t.length,r=Ma(n,o);ba(i,r)||(e.uniform1iv(this.addr,r),Ca(i,r));for(let e=0;e!==o;++e)n.setTexture2DArray(t[e]||pa,r[e])}class cs{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.setValue=function(e){switch(e){case 5126:return Sa;case 35664:return Ea;case 35665:return wa;case 35666:return Ta;case 35674:return Ia;case 35675:return Ra;case 35676:return La;case 5124:case 35670:return Pa;case 35667:case 35671:return Ba;case 35668:case 35672:return Da;case 35669:case 35673:return Na;case 5125:return Oa;case 36294:return Fa;case 36295:return Ua;case 36296:return za;case 35678:case 36198:case 36298:case 36306:case 35682:return Va;case 35679:case 36299:case 36307:return Ga;case 35680:case 36300:case 36308:case 36293:return ka;case 36289:case 36303:case 36311:case 36292:return Qa}}(t.type)}}class us{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.size=t.size,this.setValue=function(e){switch(e){case 5126:return Wa;case 35664:return Ha;case 35665:return ja;case 35666:return Ya;case 35674:return Xa;case 35675:return Ka;case 35676:return qa;case 5124:case 35670:return Za;case 35667:case 35671:return Ja;case 35668:case 35672:return $a;case 35669:case 35673:return es;case 5125:return ts;case 36294:return ns;case 36295:return is;case 36296:return os;case 35678:case 36198:case 36298:case 36306:case 35682:return rs;case 35679:case 36299:case 36307:return as;case 35680:case 36300:case 36308:case 36293:return ss;case 36289:case 36303:case 36311:case 36292:return ls}}(t.type)}}class ds{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const i=this.seq;for(let o=0,r=i.length;o!==r;++o){const r=i[o];r.setValue(e,t[r.id],n)}}}const hs=/(\w+)(\])?(\[|\.)?/g;function ps(e,t){e.seq.push(t),e.map[t.id]=t}function fs(e,t,n){const i=e.name,o=i.length;for(hs.lastIndex=0;;){const r=hs.exec(i),a=hs.lastIndex;let s=r[1];const l="]"===r[2],c=r[3];if(l&&(s|=0),void 0===c||"["===c&&a+2===o){ps(n,void 0===c?new cs(s,e,t):new us(s,e,t));break}{let e=n.map[s];void 0===e&&(e=new ds(s),ps(n,e)),n=e}}}class ms{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,35718);for(let i=0;i<n;++i){const n=e.getActiveUniform(t,i);fs(n,e.getUniformLocation(t,n.name),this)}}setValue(e,t,n,i){const o=this.map[t];void 0!==o&&o.setValue(e,n,i)}setOptional(e,t,n){const i=t[n];void 0!==i&&this.setValue(e,n,i)}static upload(e,t,n,i){for(let o=0,r=t.length;o!==r;++o){const r=t[o],a=n[r.id];!1!==a.needsUpdate&&r.setValue(e,a.value,i)}}static seqWithValue(e,t){const n=[];for(let i=0,o=e.length;i!==o;++i){const o=e[i];o.id in t&&n.push(o)}return n}}function gs(e,t,n){const i=e.createShader(t);return e.shaderSource(i,n),e.compileShader(i),i}let vs=0;function As(e,t,n){const i=e.getShaderParameter(t,35713),o=e.getShaderInfoLog(t).trim();if(i&&""===o)return"";const r=/ERROR: 0:(\d+)/.exec(o);if(r){const i=parseInt(r[1]);return n.toUpperCase()+"\n\n"+o+"\n\n"+function(e,t){const n=e.split("\n"),i=[],o=Math.max(t-6,0),r=Math.min(t+6,n.length);for(let e=o;e<r;e++){const o=e+1;i.push(`${o===t?">":" "} ${o}: ${n[e]}`)}return i.join("\n")}(e.getShaderSource(t),i)}return o}function _s(e,t){const n=function(e){switch(e){case It:return["Linear","(value)"];case Rt:return["sRGB","(value)"];default:return console.warn("v3d.WebGLProgram: Unsupported encoding:",e),["Linear","(value)"]}}(t);return"vec4 "+e+"(vec4 value) { return LinearTo"+n[0]+n[1]+"; }"}function xs(e,t){let n;switch(t){case Z:n="Linear";break;case J:n="Reinhard";break;case $:n="OptimizedCineon";break;case ee:n="ACESFilmic";break;case te:n="Custom";break;case ne:n="LogarithmicMax";break;case ie:n="PhysicalMax";break;case oe:n="FilmicBlender";break;default:console.warn("v3d.WebGLProgram: Unsupported toneMapping:",t),n="Linear"}return"vec3 "+e+"(vec3 color) { return "+n+"ToneMapping(color); }"}function ys(e,t=[]){const n=[];for(const i in e){const o=e[i];!1===o||t.indexOf(i)>-1||n.push("#define "+i+" "+o)}return n.join("\n")}function bs(e){return""!==e}function Cs(e,t){const n=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return e.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,n).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows).replace(/NUM_RECT_AREA_LIGHT_SHADOWS/g,t.numRectAreaLightShadows)}function Ms(e,t){return e.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}function Ss(e,t){const n=Object.keys(t);if(n.length){const i=new RegExp(n.join("|"),"g");return e.replace(i,(function(e){return t[e]}))}return e}function Es(e){switch(e){case"blender":return"#define MT_BLENDER";case"max":return"#define MT_MAX";case"maya":return"#define MT_MAYA";default:return""}}function ws(e,t){for(const n in t){const i="undefined"!=typeof __V3D_DEVTOOLS__?`// included: "${n}"\n`:"";e=e.replace(`#include <${n}>`,i+t[n])}return e}const Ts=/^[ \t]*#include +<([\w\d./]+)>/gm;function Is(e){return e.replace(Ts,Rs)}function Rs(e,t){const n=wr[t];if(void 0===n)throw new Error("Can not resolve #include <"+t+">");return Is(("undefined"!=typeof __V3D_DEVTOOLS__?`// included: "${t}"\n`:"")+n)}function Ls(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;e<d;e++)c+="{"+a.replace(s,`[${e}]`).replace(l,`(${e})`)+"}";e=e.replace(r,c)}}return e=e.replace(/#pragma unroll_loop_end/g,"")}function Ps(e){let t="precision "+e.precision+" float;\nprecision "+e.precision+" int;";return"highp"===e.precision?t+="\n#define HIGH_PRECISION":"mediump"===e.precision?t+="\n#define MEDIUM_PRECISION":"lowp"===e.precision&&(t+="\n#define LOW_PRECISION"),t}function Bs(e,t,n,i){const o=e.getContext(),r=n.defines;let a=n.vertexShader,p=n.fragmentShader;const f=function(e){let t="SHADOWMAP_TYPE_BASIC";return e.shadowMapType===s?t="SHADOWMAP_TYPE_PCF":e.shadowMapType===l?t="SHADOWMAP_TYPE_PCF_SOFT":e.shadowMapType===c?t="SHADOWMAP_TYPE_VSM":e.shadowMapType===u?t="SHADOWMAP_TYPE_ESM":e.shadowMapType===d?t="SHADOWMAP_TYPE_PCF_POISSON_DISK":e.shadowMapType===h&&(t="SHADOWMAP_TYPE_BILINEAR"),t}(n),m=function(e){let t="ENVMAP_TYPE_CUBE";if(e.envMap)switch(e.envMapMode){case ae:case se:t="ENVMAP_TYPE_CUBE";break;case ue:t="ENVMAP_TYPE_CUBE_UV"}return t}(n),g=function(e){let t="ENVMAP_MODE_REFLECTION";e.envMap&&e.envMapMode===se&&(t="ENVMAP_MODE_REFRACTION");return t}(n),v=function(e){let t="ENVMAP_BLENDING_NONE";if(e.envMap)switch(e.combine){case Y:t="ENVMAP_BLENDING_MULTIPLY";break;case X:t="ENVMAP_BLENDING_MIX";break;case K:t="ENVMAP_BLENDING_ADD"}return t}(n),A=function(e){const t=e.envMapCubeUVHeight;if(null===t)return null;const n=Math.log2(t)-2,i=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,n),112)),texelHeight:i,maxMip:n}}(n),_=n.unitsScaleFactor%1?String(n.unitsScaleFactor):String(n.unitsScaleFactor)+".0",x=n.isWebGL2?"":function(e){return[e.extensionDerivatives||e.envMapCubeUVHeight||e.bumpMap||e.tangentSpaceNormalMap||e.clearcoatNormalMap||e.flatShading||"physical"===e.shaderID||e.useSlopeScaledBias?"#extension GL_OES_standard_derivatives : enable":"",(e.extensionFragDepth||e.logarithmicDepthBuffer)&&e.rendererExtensionFragDepth?"#extension GL_EXT_frag_depth : enable":"",e.extensionDrawBuffers&&e.rendererExtensionDrawBuffers?"#extension GL_EXT_draw_buffers : require":"",(e.extensionShaderTextureLOD||e.envMap||e.transmission)&&e.rendererExtensionShaderTextureLod?"#extension GL_EXT_shader_texture_lod : enable":""].filter(bs).join("\n")}(n),y=ys(r),b=ys(r,n.definesFragOnly),C=o.createProgram(),M=this;let S,E,w=n.glslVersion?"#version "+n.glslVersion+"\n":"";n.isRawShaderMaterial?(S=[b].filter(bs).join("\n"),S.length>0&&(S+="\n"),E=[x,y].filter(bs).join("\n"),E.length>0&&(E+="\n")):(S=[Ps(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":"",b,n.instancing?"#define USE_INSTANCING":"",n.instancingColor?"#define USE_INSTANCING_COLOR":"",n.supportsVertexTextures?"#define VERTEX_TEXTURES":"",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 "+g:"",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.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",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.morphTargets?"#define USE_MORPHTARGETS":"",n.morphNormals&&!1===n.flatShading?"#define USE_MORPHNORMALS":"",n.morphColors&&n.isWebGL2?"#define USE_MORPHCOLORS":"",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 "+f:"",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(bs).join("\n"),E=[x,Ps(n),"#define SHADER_NAME "+n.shaderName,y,Es(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 "+m:"",n.envMap?"#define "+g:"",n.envMap?"#define "+v:"",A?"#define CUBEUV_TEXEL_WIDTH "+A.texelWidth:"",A?"#define CUBEUV_TEXEL_HEIGHT "+A.texelHeight:"",A?"#define CUBEUV_MAX_MIP "+A.maxMip+".0":"",0!==n.envMapCubeUVTileSize?`#define cubeUV_maxTileSize ${Dn(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.iridescence?"#define USE_IRIDESCENCE":"",n.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",n.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",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.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",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 "+f:"",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 "+_:"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",n.toneMapping!==q?"#define TONE_MAPPING":"",n.toneMapping!==q?wr.tonemapping_pars_fragment:"",n.toneMapping!==q?xs("toneMapping",n.toneMapping):"",n.dithering?"#define DITHERING":"",n.opaque&&!n.alphaToCoverage?"#define OPAQUE":"",wr.encodings_pars_fragment,_s("linearToOutputTexel",n.outputEncoding),n.useDepthPacking?"#define DEPTH_PACKING "+n.depthPacking:"",n.distancePacking?"#define DISTANCE_PACKING "+n.distancePacking:"",n.useSlopeScaledBias?"#define USE_SLOPE_SCALED_BIAS":"",`#define ESM_DISTANCE_SCALE ${Dn(n.esmDistanceScale)}`,n.planeReflProbe?"#define USE_PLANE_REFLECTION":"",n.useGTAO?"#define USE_GTAO":"",e.compatSettings.gtaoDisableBkgFix?"#define GTAO_DISABLE_BKG_FIX":"","\n"].filter(bs).join("\n")),n.isMeshNodeMaterial&&(a=ws(a,n.nodeChunks),p=ws(p,n.nodeChunks)),a=Is(a),a=Cs(a,n),a=Ms(a,n),n.customPrepTokens&&(a=Ss(a,n.customPrepTokens)),p=Is(p),p=Cs(p,n),p=Ms(p,n),n.customPrepTokens&&(p=Ss(p,n.customPrepTokens)),a=Ls(a),p=Ls(p),n.isWebGL2&&!0!==n.isRawShaderMaterial&&(w="#version 300 es\n",S=["precision mediump sampler2DArray;","#define attribute in","#define varying out","#define texture2D texture"].join("\n")+"\n"+S,E=["#define varying in",n.glslVersion===Wt?"":"layout(location = 0) out highp vec4 pc_fragColor;",n.glslVersion===Wt?"":"#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"+E);let T=w+S+a,I=w+E+p;e.debug.disableCompiledShaderCache&&(T+="\nconst float ANTI_CACHE = "+Math.random()+";",I+="\nconst float ANTI_CACHE = "+Math.random()+";");const R=gs(o,35633,T),L=gs(o,35632,I);"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:{shaderName:n.shaderName,materialName:n.materialName,vertex:T,fragment:I}})),o.attachShader(C,R),o.attachShader(C,L),void 0!==n.index0AttributeName?o.bindAttribLocation(C,0,n.index0AttributeName):!0===n.morphTargets&&o.bindAttribLocation(C,0,"position"),o.linkProgram(C);let P,B,D=!0;function N(){if(D=!1,e.debug.checkShaderErrors){const e=o.getProgramInfoLog(C).trim(),t=o.getShaderInfoLog(R).trim(),n=o.getShaderInfoLog(L).trim();let i=!0,r=!0;if(!1===o.getProgramParameter(C,35714)){i=!1;const t=As(o,R,"vertex"),n=As(o,L,"fragment");console.error("v3d.WebGLProgram: shader error: ",o.getError(),"35715",o.getProgramParameter(C,35715),"gl.getProgramInfoLog",e,t,n)}else""!==e?console.warn("v3d.WebGLProgram: gl.getProgramInfoLog()",e):""!==t&&""!==n||(r=!1);r&&(M.diagnostics={runnable:i,programLog:e,vertexShader:{log:t,prefix:S},fragmentShader:{log:n,prefix:E}})}o.deleteShader(R),o.deleteShader(L)}return this.getUniforms=function(){return void 0===P&&(D&&N(),P=new ms(o,C)),P},this.getAttributes=function(){return void 0===B&&(D&&N(),B=function(e,t){const n={},i=e.getProgramParameter(t,35721);for(let o=0;o<i;o++){const i=e.getActiveAttrib(t,o),r=i.name;let a=1;35674===i.type&&(a=2),35675===i.type&&(a=3),35676===i.type&&(a=4),n[r]={type:i.type,location:e.getAttribLocation(t,r),locationSize:a}}return n}(o,C)),B},this.destroy=function(){i.releaseStatesOfProgram(this),o.deleteProgram(C),this.program=void 0},this.name=n.shaderName,this.id=vs++,this.cacheKey=t,this.usedTimes=1,this.program=C,this.vertexShader=R,this.fragmentShader=L,this.profile={calcRenderTime:!1,renderTime:0,timerQueries:[],materials:[]},this.getTexUniformCount=function(){return this.getUniforms().seq.reduce((function(e,t){if(t.info)switch(t.info.type){case 35678:case 35679:case 35680:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:e+=t.info.size}return e}),0)},this.beginTimerQuery=function(e,t){if(!this.profile.calcRenderTime)return;const n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(!n)return;let i;t?(i=e.createQuery(),e.beginQuery(n.TIME_ELAPSED_EXT,i)):(i=n.createQueryEXT(),n.beginQueryEXT(n.TIME_ELAPSED_EXT,i)),this.profile.timerQueries.push(i)},this.endTimerQuery=function(e,t){if(!this.profile.calcRenderTime)return;const n=e.getExtension(t?"EXT_disjoint_timer_query_webgl2":"EXT_disjoint_timer_query");if(!n)return;t?e.endQuery(n.TIME_ELAPSED_EXT):n.endQueryEXT(n.TIME_ELAPSED_EXT);const i=this.profile.timerQueries;for(let o=i.length-1;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 Ds=0;class Ns{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.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return void 0===n&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return void 0===n&&(n=new Os(e),t.set(e,n)),n}}class Os{constructor(e){this.id=Ds++,this.code=e,this.usedTimes=0}}function Fs(e,t,n,i,o,r,a){const s=new qi,l=new Ns,c=[],u=o.isWebGL2,d=o.logarithmicDepthBuffer,h=o.vertexTextures;let p=o.precision;const g={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,v,_,x){const y=v.fog,b=_.geometry,C=r.isMeshStandardMaterial||r.isMeshNodeMaterial?v.environment:null,M=(r.isMeshStandardMaterial||r.isMeshNodeMaterial?n:t).get(r.envMap||C),S=M&&M.mapping===ue?M.image.height:null,E=g[r.type];null!==r.precision&&(p=o.getMaxPrecision(r.precision),p!==r.precision&&console.warn("v3d.WebGLProgram.getParameters:",r.precision,"not supported, using",p,"instead."));const w=b.morphAttributes.position||b.morphAttributes.normal||b.morphAttributes.color,T=void 0!==w?w.length:0;let I,R,L,P,B=0;if(void 0!==b.morphAttributes.position&&(B=1),void 0!==b.morphAttributes.normal&&(B=2),void 0!==b.morphAttributes.color&&(B=3),E){const e=Ir[E];I=e.vertexShader,R=e.fragmentShader}else I=r.vertexShader,R=r.fragmentShader,l.update(r),L=l.getVertexShaderID(r),P=l.getFragmentShaderID(r);const D=e.getRenderTarget(),N=r.alphaTest>0,O=r.clearcoat>0,F=r.iridescence>0;return{isWebGL2:u,shaderID:E,shaderName:r.type,vertexShader:I,fragmentShader:R,defines:r.defines,customVertexShaderID:L,customFragmentShaderID:P,isRawShaderMaterial:!0===r.isRawShaderMaterial,glslVersion:r.glslVersion,precision:p,instancing:!0===_.isInstancedMesh,instancingColor:!0===_.isInstancedMesh&&null!==_.instanceColor,supportsVertexTextures:h,outputEncoding:null===D?e.outputEncoding:!0===D.isXRRenderTarget?D.texture.encoding:It,map:!!r.map,matcap:!!r.matcap,envMap:!!M,envMapMode:M&&M.mapping,envMapCubeUVHeight:S,lightMap:!!r.lightMap,aoMap:!!r.aoMap,emissiveMap:!!r.emissiveMap,bumpMap:!!r.bumpMap,normalMap:!!r.normalMap,objectSpaceNormalMap:r.normalMapType===Ot,tangentSpaceNormalMap:r.normalMapType===Nt,decodeVideoTexture:!!r.map&&!0===r.map.isVideoTexture&&r.map.encoding===Rt,clearcoat:O,clearcoatMap:O&&!!r.clearcoatMap,clearcoatRoughnessMap:O&&!!r.clearcoatRoughnessMap,clearcoatNormalMap:O&&!!r.clearcoatNormalMap,iridescence:F,iridescenceMap:F&&!!r.iridescenceMap,iridescenceThicknessMap:F&&!!r.iridescenceThicknessMap,displacementMap:!!r.displacementMap,roughnessMap:!!r.roughnessMap,metalnessMap:!!r.metalnessMap,specularMap:!!r.specularMap,specularIntensityMap:!!r.specularIntensityMap,specularColorMap:!!r.specularColorMap,opaque:!1===r.transparent&&r.blending===A,alphaMap:!!r.alphaMap,alphaTest:N,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&&!!b.attributes.tangent,vertexColors:r.vertexColors,vertexAlphas:!0===r.vertexColors&&!!b.attributes.color&&4===b.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.iridescenceMap||r.iridescenceThicknessMap||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.iridescenceMap||r.iridescenceThicknessMap||r.transmission>0||r.transmissionMap||r.thicknessMap||r.specularIntensityMap||r.specularColorMap||r.sheen>0||r.sheenColorMap||r.sheenRoughnessMap||!r.displacementMap),fog:!!y,useFog:!0===r.fog,fogExp2:y&&y.isFogExp2,flatShading:!!r.flatShading,sizeAttenuation:r.sizeAttenuation,logarithmicDepthBuffer:d,skinning:!0===_.isSkinnedMesh,morphTargets:void 0!==b.morphAttributes.position,morphNormals:void 0!==b.morphAttributes.normal,morphColors:void 0!==b.morphAttributes.color,morphTargetsCount:T,morphTextureStride:B,numDirLights:s.directional.length,numPointLights:s.point.length,numSpotLights:s.spot.length,numSpotLightMaps:s.spotLightMap.length,numRectAreaLights:s.rectArea.length,numHemiLights:s.hemi.length,numDirLightShadows:s.directionalShadowMap.length,numPointLightShadows:s.pointShadowMap.length,numSpotLightShadows:s.spotShadowMap.length,numSpotLightShadowsWithMaps:s.numSpotLightShadowsWithMaps,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:q,physicallyCorrectLights:e.physicallyCorrectLights,premultipliedAlpha:r.premultipliedAlpha,doubleSided:r.side===m,flipSided:r.side===f,useDepthPacking:!!r.depthPacking,depthPacking:r.depthPacking||0,envMapCubeUVTileSize:S&&void 0!==M.image?M.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:!!x,materialName:r.name,materialProfile:r.profile,unitsScaleFactor:e.unitsScaleFactor,alphaToCoverage:!!r.alphaToCoverage,customPrepTokens:r.customPrepTokens,definesFragOnly:r.definesFragOnly,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 void 0!==t.definesFragOnly&&n.push(t.definesFragOnly.join()),!1===t.isRawShaderMaterial&&(!function(e,t){e.push(t.precision),e.push(t.outputEncoding),e.push(t.envMapMode),e.push(t.envMapCubeUVHeight),e.push(t.combine),e.push(t.vertexUvs),e.push(t.fogExp2),e.push(t.sizeAttenuation),e.push(t.morphTargetsCount),e.push(t.morphAttributeCount),e.push(t.numDirLights),e.push(t.numPointLights),e.push(t.numSpotLights),e.push(t.numSpotLightMaps),e.push(t.numHemiLights),e.push(t.numRectAreaLights),e.push(t.numDirLightShadows),e.push(t.numPointLightShadows),e.push(t.numSpotLightShadows),e.push(t.numSpotLightShadowsWithMaps),e.push(t.shadowMapType),e.push(t.toneMapping),e.push(t.numClippingPlanes),e.push(t.numClipIntersection),e.push(t.depthPacking),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.lightMap&&s.enable(7);t.aoMap&&s.enable(8);t.emissiveMap&&s.enable(9);t.bumpMap&&s.enable(10);t.normalMap&&s.enable(11);t.objectSpaceNormalMap&&s.enable(12);t.tangentSpaceNormalMap&&s.enable(13);t.clearcoat&&s.enable(14);t.clearcoatMap&&s.enable(15);t.clearcoatRoughnessMap&&s.enable(16);t.clearcoatNormalMap&&s.enable(17);t.iridescence&&s.enable(18);t.iridescenceMap&&s.enable(19);t.iridescenceThicknessMap&&s.enable(20);t.displacementMap&&s.enable(21);t.specularMap&&s.enable(22);t.roughnessMap&&s.enable(23);t.metalnessMap&&s.enable(24);t.gradientMap&&s.enable(25);t.alphaMap&&s.enable(26);t.alphaTest&&s.enable(27);t.vertexColors&&s.enable(28);t.vertexAlphas&&s.enable(29);t.vertexUvs&&s.enable(30);t.vertexTangents&&s.enable(31);t.uvsVertexOnly&&s.enable(32);e.push(s.mask),s.disableAll(),t.fog&&s.enable(0);t.useFog&&s.enable(1);t.flatShading&&s.enable(2);t.logarithmicDepthBuffer&&s.enable(3);t.skinning&&s.enable(4);t.morphTargets&&s.enable(5);t.morphNormals&&s.enable(6);t.morphColors&&s.enable(7);t.premultipliedAlpha&&s.enable(8);t.shadowMapEnabled&&s.enable(9);t.physicallyCorrectLights&&s.enable(10);t.doubleSided&&s.enable(11);t.flipSided&&s.enable(12);t.useDepthPacking&&s.enable(13);t.dithering&&s.enable(14);t.specularIntensityMap&&s.enable(15);t.specularColorMap&&s.enable(16);t.transmission&&s.enable(17);t.transmissionMap&&s.enable(18);t.thicknessMap&&s.enable(19);t.sheen&&s.enable(20);t.sheenColorMap&&s.enable(21);t.sheenRoughnessMap&&s.enable(22);t.decodeVideoTexture&&s.enable(23);t.opaque&&s.enable(24);e.push(s.mask),s.disableAll(),t.distancePacking&&s.enable(0);t.useSlopeScaledBias&&s.enable(1);t.useGTAO&&s.enable(2);t.planeReflProbe&&s.enable(3);t.alphaToCoverage&&s.enable(4);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=g[e.type];let n;if(t){const e=Ir[t];n=cr.clone(e.uniforms)}else n=e.uniforms;return n},acquireProgram:function(t,n){let i;for(let e=0,t=c.length;e<t;e++){const t=c[e];if(t.cacheKey===n){i=t,++i.usedTimes;break}}void 0===i&&(i=new Bs(e,n,t,r),c.push(i));const o=i.profile.materials;return t.materialName&&o.indexOf(t.materialName)<0&&o.push(t.materialName),i},releaseProgram:function(e){if(0==--e.usedTimes){const t=c.indexOf(e);c[t]=c[c.length-1],c.pop(),e.destroy()}},releaseShaderCache:function(e){l.remove(e)},programs:c,dispose:function(){l.dispose()}}}function Us(){let e=new WeakMap;return{get:function(t){let n=e.get(t);return void 0===n&&(n={},e.set(t,n)),n},remove:function(t){e.delete(t)},update:function(t,n,i){e.get(t)[n]=i},dispose:function(){e=new WeakMap}}}function zs(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.material.id!==t.material.id?e.material.id-t.material.id:e.z!==t.z?e.z-t.z:e.id-t.id}function Vs(e,t){return e.groupOrder!==t.groupOrder?e.groupOrder-t.groupOrder:e.renderOrder!==t.renderOrder?e.renderOrder-t.renderOrder:e.z!==t.z?t.z-e.z:e.id-t.id}function Gs(){const e=[];let t=0;const n=[],i=[],o=[];function r(n,i,o,r,a,s){let l=e[t];return void 0===l?(l={id:n.id,object:n,geometry:i,material:o,groupOrder:r,renderOrder:n.renderOrder,z:a,group:s},e[t]=l):(l.id=n.id,l.object=n,l.geometry=i,l.material=o,l.groupOrder=r,l.renderOrder=n.renderOrder,l.z=a,l.group=s),t++,l}return{opaque:n,transmissive:i,transparent:o,init:function(){t=0,n.length=0,i.length=0,o.length=0},push:function(e,t,a,s,l,c){const u=r(e,t,a,s,l,c);a.transmission>0?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;n<i;n++){const t=e[n];if(null===t.id)break;t.id=null,t.object=null,t.geometry=null,t.material=null,t.group=null}},sort:function(e,t){n.length>1&&n.sort(e||zs),i.length>1&&i.sort(t||Vs),o.length>1&&o.sort(t||Vs)}}}function ks(){let e=new WeakMap;return{get:function(t,n){const i=e.get(t);let o;return void 0===i?(o=new Gs,e.set(t,[o])):n>=i.length?(o=new Gs,i.push(o)):o=i[n],o},dispose:function(){e=new WeakMap}}}function Qs(){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 ci,color:new qn};break;case"SpotLight":n={position:new ci,direction:new ci,color:new qn,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":n={position:new ci,color:new qn,distance:0,decay:0};break;case"HemisphereLight":n={direction:new ci,skyColor:new qn,groundColor:new qn};break;case"RectAreaLight":n={color:new qn,position:new ci,halfWidth:new ci,halfHeight:new ci}}return e[t.id]=n,n}}}let Ws=0;function Hs(e,t){return(t.castShadow?2:0)-(e.castShadow?2:0)+(t.map?1:0)-(e.map?1:0)}function js(e,t){const n=new Qs,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 yn,position:new ci,shadowCameraNear:1,maxDistance:0,expBias:1};break;case"SpotLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn,shadow:0,shadowCameraNear:1,shadowCameraFar:1e3,expBias:1};break;case"PointLight":case"RectAreaLight":n={shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new yn,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,numSpotMaps:-1,numRectAreaShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,rectAreaShadow:[],rectAreaShadowMap:[],rectAreaShadowMatrix:[]};for(let e=0;e<9;e++)o.probe.push(new ci);const r=new ci,a=new zi,s=new zi;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,_=0,x=0;r.sort(Hs);const y=!0!==a?Math.PI:1;for(let e=0,t=r.length;e<t;e++){const t=r[e],a=t.color,b=t.intensity,C=t.distance,M=t.shadow&&t.shadow.map?t.shadow.map.texture:null;if(t.isAmbientLight)s+=a.r*b*y,l+=a.g*b*y,c+=a.b*b*y;else if(t.isLightProbe)for(let e=0;e<9;e++)o.probe[e].addScaledVector(t.sh.coefficients[e],b);else if(t.isDirectionalLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,o.directionalShadow[u]=n,o.directionalShadowMap[u]=M,o.directionalShadowMatrix[u]=t.shadow.matrix,n.shadowCameraNear=e.camera.near,n.expBias=e.expBias,m++}o.directional[u]=e,u++}else if(t.isSpotLight){const e=n.get(t);e.position.setFromMatrixPosition(t.matrixWorld),e.color.copy(a).multiplyScalar(b*y),e.distance=C,e.coneCos=Math.cos(t.angle),e.penumbraCos=Math.cos(t.angle*(1-t.penumbra)),e.decay=t.decay,o.spot[h]=e;const r=t.shadow;if(t.map&&(o.spotLightMap[A]=t.map,A++,r.updateMatrices(t),t.castShadow&&_++),o.spotLightMatrix[h]=r.matrix,t.castShadow){const e=i.get(t);e.shadowBias=r.bias,e.shadowNormalBias=r.normalBias,e.shadowRadius=r.radius,e.shadowMapSize=r.mapSize,o.spotShadow[h]=e,o.spotShadowMap[h]=M,e.shadow=t.castShadow?r.calcUseOmniMaps(t.angle)?2:1:0,e.shadowCameraNear=r.camera.near,e.shadowCameraFar=r.camera.far,e.expBias=r.expBias,v++}h++}else if(t.isRectAreaLight){const e=n.get(t);if(e.color.copy(a).multiplyScalar(b),e.halfWidth.set(.5*t.width,0,0),e.halfHeight.set(0,.5*t.height,0),t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,n.expBias=e.expBias,o.rectAreaShadow[p]=n,o.rectAreaShadowMap[p]=M,o.rectAreaShadowMatrix[p]=t.shadow.matrix,x++}o.rectArea[p]=e,p++}else if(t.isPointLight){const e=n.get(t);if(e.color.copy(t.color).multiplyScalar(t.intensity*y),e.distance=t.distance,e.decay=t.decay,t.castShadow){const e=t.shadow,n=i.get(t);n.shadowBias=e.bias,n.shadowNormalBias=e.normalBias,n.shadowRadius=e.radius,n.shadowMapSize=e.mapSize,n.shadowCameraNear=e.camera.near,n.shadowCameraFar=e.camera.far,n.expBias=e.expBias,o.pointShadow[d]=n,o.pointShadowMap[d]=M,o.pointShadowMatrix[d]=t.shadow.matrix,g++}o.point[d]=e,d++}else if(t.isHemisphereLight){const e=n.get(t);e.skyColor.copy(t.color).multiplyScalar(b*y),e.groundColor.copy(t.groundColor).multiplyScalar(b*y),o.hemi[f]=e,f++}}p>0&&(t.isWebGL2||!0===e.has("OES_texture_float_linear")?(o.rectAreaLTC1=Tr.LTC_FLOAT_1,o.rectAreaLTC2=Tr.LTC_FLOAT_2):!0===e.has("OES_texture_half_float_linear")?(o.rectAreaLTC1=Tr.LTC_HALF_1,o.rectAreaLTC2=Tr.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 b=o.hash;b.directionalLength===u&&b.pointLength===d&&b.spotLength===h&&b.rectAreaLength===p&&b.hemiLength===f&&b.numDirectionalShadows===m&&b.numPointShadows===g&&b.numSpotShadows===v&&b.numSpotMaps===A&&b.numRectAreaShadows===x||(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.spotLightMatrix.length=v+A-_,o.spotLightMap.length=A,o.numSpotLightShadowsWithMaps=_,b.directionalLength=u,b.pointLength=d,b.spotLength=h,b.rectAreaLength=p,b.hemiLength=f,b.numDirectionalShadows=m,b.numPointShadows=g,b.numSpotShadows=v,b.numSpotMaps=A,o.rectAreaShadow.length=x,o.rectAreaShadowMap.length=x,o.rectAreaShadowMatrix.length=x,b.numRectAreaShadows=x,o.version=Ws++)},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;p<f;p++){const f=e[p];if(f.isDirectionalLight){const e=o.directional[n];if(e.direction.setFromMatrixPosition(f.matrixWorld),r.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),f.castShadow){const e=f.shadow,n=i.get(f);n.position.setFromMatrixPosition(f.matrixWorld),n.position.applyMatrix4(h),n.maxDistance=e.isDirectionalLightShadowCSM?e.maxDistance:t.far}n++}else if(f.isSpotLight){const e=o.spot[c];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(h),e.direction.setFromMatrixPosition(f.matrixWorld),r.setFromMatrixPosition(f.target.matrixWorld),e.direction.sub(r),e.direction.transformDirection(h),c++}else if(f.isRectAreaLight){const e=o.rectArea[u];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(h),s.identity(),a.copy(f.matrixWorld),a.premultiply(h),s.extractRotation(a),e.halfWidth.set(.5*f.width,0,0),e.halfHeight.set(0,.5*f.height,0),e.halfWidth.applyMatrix4(s),e.halfHeight.applyMatrix4(s),u++}else if(f.isPointLight){const e=o.point[l];e.position.setFromMatrixPosition(f.matrixWorld),e.position.applyMatrix4(h),l++}else if(f.isHemisphereLight){const e=o.hemi[d];e.direction.setFromMatrixPosition(f.matrixWorld),e.direction.transformDirection(h),d++}}},state:o}}function Ys(e,t){const n=new js(e,t),i=[],o=[],r=[],a=[];return{init:function(){i.length=0,o.length=0,r.length=0,a.length=0},state:{lightsArray:i,shadowsArray:o,envMapProbeArray:r,planeReflProbeArray:a,lights:n},setupLights:function(e){n.setup(i,e)},setupLightsView:function(e){n.setupView(i,e)},pushLight:function(e){i.push(e)},pushShadow:function(e){o.push(e)},pushEnvMapProbe:function(e){r.push(e)},sortEnvMapProbes:function(){r.sort(((e,t)=>e.influenceDistance-t.influenceDistance))},pushPlaneReflProbe:function(e){a.push(e)}}}function Xs(e,t){let n=new WeakMap;return{get:function(i,o=0){const r=n.get(i);let a;return void 0===r?(a=new Ys(e,t),n.set(i,[a])):o>=r.length?(a=new Ys(e,t),r.push(a)):a=r[o],a},dispose:function(){n=new WeakMap}}}class Ks extends Mo{constructor(e){super(),this.isMeshDepthMaterial=!0,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.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}}class qs extends Mo{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.referencePosition=new ci,this.nearDistance=1,this.farDistance=1e3,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.defines={DISTANCE_SCALE:"1.0"},this.distancePacking=Bt,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}}const Zs="void main() {\ngl_Position = vec4(position, 1.0);\n}",Js="uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\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}",$s=new zi,el=new ci,tl=new ci;class nl{constructor(e){this.camera=e,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new yn(512,512),this.map=null,this.mapPass=null,this.matrix=new zi,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Cr,this._frameExtents=new yn(1,1),this._viewportCount=1,this._viewports=[new ii(0,0,1,1)],this.expBias=1,this.slopeScaledBias=0,this._additionalMap2D=null,this._additionalMapCube=null,this.isLightShadow=!0}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;el.setFromMatrixPosition(e.matrixWorld),t.position.copy(el),tl.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(tl),t.updateMatrixWorld(),$s.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix($s),n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply($s)}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}}const il=Math.PI/4,ol=new zi,rl=new ci,al=new ci;class sl extends nl{constructor(){super(new hr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.useOmniMaps=!1,this.useMinFov90=!1,this._frameExtentsOmni=new yn(4,2),this._viewportCountOmni=6,this._viewportsOmni=[new ii(2,1,1,1),new ii(0,1,1,1),new ii(3,1,1,1),new ii(1,1,1,1),new ii(3,0,1,1),new ii(1,0,1,1)],this._cubeDirections=[new ci(1,0,0),new ci(-1,0,0),new ci(0,0,1),new ci(0,0,-1),new ci(0,1,0),new ci(0,-1,0)],this._cubeUps=[new ci(0,1,0),new ci(0,1,0),new ci(0,1,0),new ci(0,1,0),new ci(0,0,1),new ci(0,0,-1)]}updateMatrices(e,t=0){if(this.useOmniMaps){const n=this.camera,i=this.matrix;rl.setFromMatrixPosition(e.matrixWorld),n.position.copy(rl),al.copy(n.position),al.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(al),n.updateMatrixWorld(),i.makeTranslation(-rl.x,-rl.y,-rl.z),ol.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ol)}else{const t=this.camera,n=2*en*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>il,this.useOmniMaps}copy(e){return super.copy(e),this.focus=e.focus,this.useOmniMaps=e.useOmniMaps,this.useMinFov90=e.useMinFov90,this}}const ll=.8,cl=.2,ul=.8,dl=50;function hl(e,t,n){let i=new Cr;const o=new yn,r=new yn,g=new ii,A=new Ks({depthPacking:Lt}),_=new qs,x={},y=n.maxTextureSize,b=n.isWebGL2,C={0:f,1:p,2:m},M=new ur({defines:{SAMPLE_RATE:2/8,HALF_SAMPLE_RATE:1/8,VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new yn},radius:{value:4}},vertexShader:Zs,fragmentShader:Js}),S=M.clone();S.defines.HORIZONTAL_PASS=1;const E=new zo;E.setAttribute("position",new To(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new ir(E,M),T=new zi,I=new zi,R=new yn(y,y),L=new ci,P=new ci,B=new ci,D=[new ci(1,0,0),new ci(-1,0,0),new ci(0,1,0),new ci(0,-1,0),new ci(0,0,1),new ci(0,0,-1)],N=[new ci(0,1,0),new ci(0,1,0),new ci(0,0,1),new ci(0,0,-1),new ci(0,1,0),new ci(0,1,0)],O=(new ii,new ii,new ii,new ii,new ii,new ii,new Ri),F=[new ci,new ci,new ci,new ci,new ci,new ci,new ci,new ci],U=new ir(new Er(1,1,1,1));U.name="esmFarPlane",U.castShadow=!0,U.material.shadowSide=p;const z=0,V=1,G=0,k=1,Q=new Fr(-1,1,1,-1,0,10),W=new ir(new Er(2,2)),H=new ur({type:"ShadowCubeOctahedral",defines:Object.assign({},Ir.cubeOctahedral.defines),uniforms:cr.clone(Ir.cubeOctahedral.uniforms),vertexShader:Ir.cubeOctahedral.vertexShader,fragmentShader:Ir.cubeOctahedral.fragmentShader}),j={},Y={},X=this;function K(t,n,i,o,r,p,f,m,g){let v=null;const y=m||f===u?t.customDistanceMaterial:t.customDepthMaterial;if(v=void 0!==y?y:m||f===u?_:A,e.localClippingEnabled&&!0===i.clipShadows&&Array.isArray(i.clippingPlanes)&&0!==i.clippingPlanes.length||i.displacementMap&&0!==i.displacementScale||i.alphaMap&&i.alphaTest>0||i.map&&i.alphaTest>0){const e=v.uuid,t=i.uuid;let n=x[e];void 0===n&&(n={},x[e]=n);let o=n[t];void 0===o&&(o=v.clone(),n[t]=o),v=o}switch(v.visible=i.visible,v.wireframe=i.wireframe,v.side=f===c?null!==i.shadowSide?i.shadowSide:i.side:null!==i.shadowSide?i.shadowSide:C[i.side],v.alphaMap=i.alphaMap,v.alphaTest=i.alphaTest,v.map=i.map,v.clipShadows=i.clipShadows,v.clippingPlanes=i.clippingPlanes,v.clipIntersection=i.clipIntersection,v.displacementMap=i.displacementMap,v.displacementScale=i.displacementScale,v.displacementBias=i.displacementBias,v.wireframeLinewidth=i.wireframeLinewidth,v.linewidth=i.linewidth,!m&&f!==u||!0!==v.isMeshDistanceMaterial||(v.referencePosition.copy(g),v.nearDistance=r,v.farDistance=p,v.distancePacking=f===u?Dt:Bt),f===u&&(v.defines.DISTANCE_SCALE=Dn(X.esmDistanceScale)),f){case a:case h:case s:case l:case d:v.useSlopeScaledBias=!0,v.slopeScaledBias=o.shadow.slopeScaledBias;break;case u:v.useSlopeScaledBias=!0,v.slopeScaledBias=.5}return v}function q(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&&s===c)&&(!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;c<u;c++){const u=t[c],d=o[u.materialIndex];if(d&&d.visible){const t=K(n,0,d,a,r.near,r.far,s,l,P);e.renderBufferDirect(r,null,i,t,n,u)}}}else if(o.visible){const t=K(n,0,o,a,r.near,r.far,s,l,P);e.renderBufferDirect(r,null,i,t,n,null)}}const u=n.children;for(let e=0,t=u.length;e<t;e++)q(u[e],o,r,a,s,l)}function Z(n,a,s,l){const u=s.shadow,d=u.camera;P.setFromMatrixPosition(s.matrixWorld),o.copy(u.mapSize);const h=u.getFrameExtents();if(o.multiply(h),r.copy(u.mapSize),(o.x>y||o.y>y)&&(o.x>y&&(r.x=Math.floor(y/h.x),o.x=r.x*h.x,u.mapSize.x=r.x),o.y>y&&(r.y=Math.floor(y/h.y),o.y=r.y*h.y,u.mapSize.y=r.y)),s.isSpotLight&&u.map&&u.map.width/u.map.height!=2){const e=u.map;u.map=u._additionalMap2D,u._additionalMap2D=e}const p=s.isPointLight||s.isRectAreaLight||s.isSpotLight&&u.useOmniMaps;if(p)s.isSpotLight&&(d.fov=90,d.updateProjectionMatrix());else if(s.isDirectionalLight){if(s.shadow.isDirectionalLightShadowCSM){const e=te(a,u,o,O);d.left=e.center.x-e.radius,d.right=e.center.x+e.radius,d.top=e.center.y+e.radius,d.bottom=e.center.y-e.radius,d.near=-e.center.z-e.radius,d.far=-e.center.z+e.radius,d.updateProjectionMatrix()}const e=s.getWorldDirection(B);P.addScaledVector(e,d.near)}else s.isSpotLight&&u.useMinFov90&&(d.fov=90,d.updateProjectionMatrix());if(null===u.map&&!p&&l===c){const e={minFilter:ve,magFilter:ve,format:Be};u.map=new oi(o.x,o.y,e),u.map.texture.name=s.name+".shadowMap",u.mapPass=new oi(o.x,o.y,e),d.updateProjectionMatrix()}if(null===u.map){const e={minFilter:fe,magFilter:fe,format:Be};u.map=new oi(o.x,o.y,e),u.map.texture.name=s.name+".shadowMap",d.updateProjectionMatrix()}e.state.buffers.color.setClear(1,1,1,1),e.setRenderTarget(u.map),e.clear();const f=u.getViewportCount();for(let t=0;t<f;t++){const o=u.getViewport(t);g.set(r.x*o.x,r.y*o.y,r.x*o.z,r.y*o.w),e.state.viewport(g),u.updateMatrices(s,t),i=u.getFrustum(),q(n,a,u.camera,s,l,p)}p||l!==c||function(n,i){const o=t.update(w);M.uniforms.shadow_pass.value=n.map.texture,M.uniforms.resolution.value=n.mapSize,M.uniforms.radius.value=n.radius,e.setRenderTarget(n.mapPass),e.clear(),e.renderBufferDirect(i,null,o,M,w,null),S.uniforms.shadow_pass.value=n.mapPass.texture,S.uniforms.resolution.value=n.mapSize,S.uniforms.radius.value=n.radius,e.setRenderTarget(n.map),e.clear(),e.renderBufferDirect(i,null,o,S,w,null)}(u,a)}function J(t,n,r,a){const s=r.shadow,l=s.camera,c=s.matrix,u=r.isPointLight||r.isRectAreaLight?2:1,d=o.copy(s.mapSize).multiplyScalar(u).min(R).multiplyScalar(1/u);null===s._additionalMapCube&&(s._additionalMapCube=new gr(d.x,{minFilter:ve,magFilter:ve,format:b?Ue:Be,type:we}),s._additionalMapCube.texture.name=r.name+".shadowMap.tmpCube"),null===s._additionalMap2D&&(s._additionalMap2D=new oi(d.x*u,d.y*u,{minFilter:ve,magFilter:ve,format:b?Ue:Be,type:we}),s._additionalMap2D.texture.name=r.name+".shadowMap.tmp2D"),null===s.map&&(s.map=new oi(d.x*u,d.y*u,{minFilter:ve,magFilter:ve,format:b?Ue:Be,type:we}),s.map.texture.name=r.name+".shadowMap"),P.setFromMatrixPosition(r.matrixWorld),l.position.copy(P),r.isSpotLight&&(l.fov=90,l.updateProjectionMatrix()),c.makeTranslation(-P.x,-P.y,-P.z);for(let o=0;o<6;o++)L.copy(l.position),L.add(D[o]),l.up.copy(N[o]),2!==o&&3!==o&&l.up.multiplyScalar(-1),l.lookAt(L),l.updateMatrixWorld(),T.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),i.setFromProjectionMatrix(T),e.setRenderTarget(s._additionalMapCube,o),e.clearDepth(),ne(n,l,r,a),q(t,n,l,r,a,!0);const h=Math.max(s.radius*u,.001),p=function(e){return Math.ceil(cl*e)}(h);!function(e,t,n){const i=W.material=H;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(W),e.renderBufferDirect(Q,!1,W.geometry,i,W,null)}(e,s._additionalMapCube,s.map),$(e,s.map,s._additionalMap2D,p,h,V,G),$(e,s._additionalMap2D,s.map,p,h,z,G)}function $(e,t,n,i,o,r,a){const s=W.material=a===G?function(e){if(!(e in j)){(j[e]=new ur({type:"ShadowBlur",defines:Object.assign({},Ir.blur.defines,{LOG_SPACE:1,OCTAHEDRAL_MAP:1}),uniforms:cr.clone(Ir.blur.uniforms),customPrepTokens:Object.assign({},Ir.blur.customPrepTokens),vertexShader:Ir.blur.vertexShader,fragmentShader:Ir.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=e}return j[e]}(i):function(e){if(!(e in Y)){(Y[e]=new ur({type:"ShadowBlur",defines:Object.assign({},Ir.blur.defines,{LOG_SPACE:1}),uniforms:cr.clone(Ir.blur.uniforms),customPrepTokens:Object.assign({},Ir.blur.customPrepTokens),vertexShader:Ir.blur.vertexShader,fragmentShader:Ir.blur.fragmentShader})).customPrepTokens.MAX_SAMPLE_RADIUS=e}return Y[e]}(i);s.uniforms.direction.value.set(+(r===z),+(r===V)),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(W),e.renderBufferDirect(Q,!1,W.geometry,s,W,null)}function ee(t,n,r,a){const s=r.shadow,l=s.camera,c=s.matrix,u=o.copy(s.mapSize).min(R);if(null===s._additionalMap2D&&(s._additionalMap2D=new oi(u.x,u.y,{minFilter:ve,magFilter:ve,format:b?Ue:Be,type:we}),s._additionalMap2D.texture.name=r.name+".shadowMap.tmp2D"),null===s.map&&(s.map=new oi(u.x,u.y,{minFilter:ve,magFilter:ve,format:b?Ue:Be,type:we}),s.map.texture.name=r.name+".shadowMap"),P.setFromMatrixPosition(r.matrixWorld),l.position.copy(P),L.setFromMatrixPosition(r.target.matrixWorld),l.lookAt(L),l.updateMatrixWorld(),r.isDirectionalLight){if(r.shadow.isDirectionalLightShadowCSM){const e=te(n,s,u,O);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(B);P.addScaledVector(e,l.near)}else r.isSpotLight&&s.useMinFov90&&(l.fov=90,l.updateProjectionMatrix());let d;var h,p;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),T.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),i.setFromProjectionMatrix(T),e.setRenderTarget(s.map),e.clearDepth(),ne(n,l,r,a),q(t,n,l,r,a,!1),r.isDirectionalLight&&r.shadow.isDirectionalLightShadowCSM?(h=s.radius,p=(l.right-l.left)/2,d=dl*h/p):d=r.isSpotLight?s.radius*ul:s.radius,d=Math.max(d,.001);const f=function(e){return Math.ceil(ll*e)}(d);$(e,s.map,s._additionalMap2D,f,d,z,k),$(e,s._additionalMap2D,s.map,f,d,V,k)}function te(e,t,n,i){const o=nn(t.maxDistance,e.near,e.far)/e.far;for(let t=0;t<F.length;t++){const n=F[t],i=1&t;n.set(t>>2&1,t>>1&1,i).multiplyScalar(2).subScalar(1).applyMatrix4(e.projectionMatrixInverse),1===i&&n.multiplyScalar(o)}i.setFromPoints(F),I.multiplyMatrices(t.camera.matrixWorldInverse,e.matrixWorld);const r=i.center.applyMatrix4(I),a=i.radius*=I.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 ne(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(sn(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(U),U.scale.set(s,l,c),U.position.set(o,r,a),U.updateMatrixWorld(),q(U,e,t,n,i,!0)}this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=s,this.esmDistanceScale=1,this.render=function(t,n,i){if(!1===X.enabled)return;if(!1===X.autoUpdate&&!1===X.needsUpdate)return;if(0===t.length)return;const o=e.getRenderTarget(),r=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),f=e.state;f.setBlending(v),f.buffers.color.setClear(1,1,1,1),f.buffers.depth.setTest(!0),f.setScissorTest(!1);for(let e=0,o=t.length;e<o;e++){const o=t[e],r=o.shadow;if(void 0!==r){if(!1!==r.autoUpdate||!1!==r.needsUpdate){if(o.isSpotLight&&r.calcUseOmniMaps(o.angle),o.isPointLight||o.isRectAreaLight||o.isSpotLight&&r.useOmniMaps)switch(X.type){case a:case h:case s:case l:case d:Z(n,i,o,X.type);break;case u:J(n,i,o,X.type);break;default:continue}else{if(!o.isSpotLight&&!o.isDirectionalLight)continue;switch(X.type){case a:case h:case s:case l:case d:case c:Z(n,i,o,X.type);break;case u:ee(n,i,o,X.type);break;default:continue}}r.needsUpdate=!1}}else console.warn("v3d.WebGLShadowMap:",o,"has no shadow.")}X.needsUpdate=!1,e.setRenderTarget(o,r,p)}}function pl(e,t,n){const a=n.isWebGL2;const s=new function(){let t=!1;const n=new ii;let i=null;const o=new ii(0,0,0,0);return{setMask:function(n){i===n||t||(e.colorMask(n,n,n,n),i=n)},getMask:function(){return i},setLocked:function(e){t=e},setClear:function(t,i,r,a,s){!0===s&&(t*=a,i*=a,r*=a),n.set(t,i,r,a),!1===o.equals(n)&&(e.clearColor(t,i,r,a),o.copy(n))},reset:function(){t=!1,i=null,o.set(-1,0,0,0)}}},l=new function(){let t=!1,n=null,i=null,o=null,r=null;return{setTest:function(e){e!==r&&(e?ye(2929):be(2929),r=e)},getTest:function(){return r},setMask:function(i){n===i||t||(e.depthMask(i),n=i)},setFunc:function(t){if(i!==t){switch(t){case z:e.depthFunc(512);break;case V:e.depthFunc(519);break;case G:e.depthFunc(513);break;case k:e.depthFunc(515);break;case Q:e.depthFunc(514);break;case W:e.depthFunc(518);break;case H:e.depthFunc(516);break;case j:e.depthFunc(517);break;default:e.depthFunc(515)}i=t}},setLocked:function(e){t=e},setClear:function(t){o!==t&&(e.clearDepth(t),o=t)},reset:function(){t=!1,n=null,i=null,o=null}}},c=new function(){let t=!1,n=null,i=null,o=null,r=null,a=null,s=null,l=null,c=null;return{setTest:function(e){t||(e?ye(2960):be(2960))},setMask:function(i){n===i||t||(e.stencilMask(i),n=i)},setFunc:function(t,n,a){i===t&&o===n&&r===a||(e.stencilFunc(t,n,a),i=t,o=n,r=a)},setOp:function(t,n,i){a===t&&s===n&&l===i||(e.stencilOp(t,n,i),a=t,s=n,l=i)},setLocked:function(e){t=e},setClear:function(t){c!==t&&(e.clearStencil(t),c=t)},reset:function(){t=!1,n=null,i=null,o=null,r=null,a=null,s=null,l=null,c=null}}},u=new WeakMap,d=new WeakMap;let h={},p={},g=new WeakMap,Y=[],X=null,K=!1,q=null,Z=null,J=null,$=null,ee=null,te=null,ne=null,ie=!1,oe=null,re=null,ae=null,se=null,le=null;const ce=e.getParameter(35661);let ue=!1,de=0;const he=e.getParameter(7938);-1!==he.indexOf("WebGL")?(de=parseFloat(/^WebGL (\d)/.exec(he)[1]),ue=de>=1):-1!==he.indexOf("OpenGL ES")&&(de=parseFloat(/^OpenGL ES (\d)/.exec(he)[1]),ue=de>=2);let pe=null,fe={};const me=e.getParameter(3088),ge=e.getParameter(2978),ve=(new ii).fromArray(me),Ae=(new ii).fromArray(ge);function _e(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;t<i;t++)e.texImage2D(n+t,0,6408,1,1,0,6408,5121,o);return r}const xe={};function ye(t){!0!==h[t]&&(e.enable(t),h[t]=!0)}function be(t){!1!==h[t]&&(e.disable(t),h[t]=!1)}xe[3553]=_e(3553,3553,1),xe[34067]=_e(34067,34069,6),s.setClear(0,0,0,1),l.setClear(1),c.setClear(0),ye(2929),l.setFunc(k),Ee(!1),we(o),ye(2884),Se(v);const Ce={[C]:32774,[M]:32778,[S]:32779};if(a)Ce[E]=32775,Ce[w]=32776;else{const e=t.get("EXT_blend_minmax");null!==e&&(Ce[E]=e.MIN_EXT,Ce[w]=e.MAX_EXT)}const Me={[T]:0,[I]:1,[R]:768,[P]:770,[U]:776,[O]:774,[D]:772,[L]:769,[B]:771,[F]:775,[N]:773};function Se(t,n,i,o,r,a,s,l){if(t!==v){if(!1===K&&(ye(3042),K=!0),t===b)r=r||n,a=a||i,s=s||o,n===Z&&r===ee||(e.blendEquationSeparate(Ce[n],Ce[r]),Z=n,ee=r),i===J&&o===$&&a===te&&s===ne||(e.blendFuncSeparate(Me[i],Me[o],Me[a],Me[s]),J=i,$=o,te=a,ne=s),q=t,ie=!1;else if(t!==q||l!==ie){if(Z===C&&ee===C||(e.blendEquation(32774),Z=C,ee=C),l)switch(t){case A:e.blendFuncSeparate(1,771,1,771);break;case _:e.blendFunc(1,1);break;case x:e.blendFuncSeparate(0,769,0,1);break;case y:e.blendFuncSeparate(0,768,0,770);break;default:console.error("v3d.WebGLState: Invalid blending: ",t)}else switch(t){case A:e.blendFuncSeparate(770,771,1,771);break;case _:e.blendFunc(770,1);break;case x:e.blendFuncSeparate(0,769,0,1);break;case y:e.blendFunc(0,768);break;default:console.error("v3d.WebGLState: Invalid blending: ",t)}J=null,$=null,te=null,ne=null,q=t,ie=l}}else!0===K&&(be(3042),K=!1)}function Ee(t){oe!==t&&(t?e.frontFace(2304):e.frontFace(2305),oe=t)}function we(t){t!==i?(ye(2884),t!==re&&(t===o?e.cullFace(1029):t===r?e.cullFace(1028):e.cullFace(1032))):be(2884),re=t}function Te(t,n,i){t?(ye(32823),se===n&&le===i||(e.polygonOffset(n,i),se=n,le=i)):be(32823)}return{buffers:{color:s,depth:l,stencil:c},enable:ye,disable:be,bindFramebuffer:function(t,n){return p[t]!==n&&(e.bindFramebuffer(t,n),p[t]=n,a&&(36009===t&&(p[36160]=n),36160===t&&(p[36009]=n)),!0)},drawBuffers:function(i,o){let r=Y,a=!1;if(i)if(r=g.get(o),void 0===r&&(r=[],g.set(o,r)),i.isWebGLMultipleRenderTargets){const e=i.texture;if(r.length!==e.length||36064!==r[0]){for(let t=0,n=e.length;t<n;t++)r[t]=36064+t;r.length=e.length,a=!0}}else 36064!==r[0]&&(r[0]=36064,a=!0);else 1029!==r[0]&&(r[0]=1029,a=!0);a&&(n.isWebGL2?e.drawBuffers(r):t.get("WEBGL_draw_buffers").drawBuffersWEBGL(r))},useProgram:function(t){return X!==t&&(e.useProgram(t),X=t,!0)},setBlending:Se,setMaterial:function(e,t){e.side===m?be(2884):ye(2884);let n=e.side===f;t&&(n=!n),Ee(n),e.blending===A&&!1===e.transparent?Se(v):Se(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),l.setFunc(e.depthFunc),l.setTest(e.depthTest),l.setMask(e.depthWrite),s.setMask(e.colorWrite);const i=e.stencilWrite;c.setTest(i),i&&(c.setMask(e.stencilWriteMask),c.setFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),c.setOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),Te(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),!0===e.alphaToCoverage?ye(32926):be(32926)},setFlipSided:Ee,setCullFace:we,setLineWidth:function(t){t!==ae&&(ue&&e.lineWidth(t),ae=t)},setPolygonOffset:Te,setScissorTest:function(e){e?ye(3089):be(3089)},activeTexture:function(t){void 0===t&&(t=33984+ce-1),pe!==t&&(e.activeTexture(t),pe=t)},bindTexture:function(t,n,i){void 0===i&&(i=null===pe?33984+ce-1:pe);let o=fe[i];void 0===o&&(o={type:void 0,texture:void 0},fe[i]=o),o.type===t&&o.texture===n||(pe!==i&&(e.activeTexture(i),pe=i),e.bindTexture(t,n||xe[t]),o.type=t,o.texture=n)},unbindTexture:function(){const t=fe[pe];void 0!==t&&void 0!==t.type&&(e.bindTexture(t.type,null),t.type=void 0,t.texture=void 0)},compressedTexImage2D:function(){try{e.compressedTexImage2D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},compressedTexImage3D:function(){try{e.compressedTexImage3D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage2D:function(){try{e.texImage2D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texImage3D:function(){try{e.texImage3D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},updateUBOMapping:function(t,n){let i=d.get(n);void 0===i&&(i=new WeakMap,d.set(n,i));let o=i.get(t);void 0===o&&(o=e.getUniformBlockIndex(n,t.name),i.set(t,o))},uniformBlockBinding:function(t,n){const i=d.get(n).get(t);u.get(t)!==i&&(e.uniformBlockBinding(n,i,t.__bindingPointIndex),u.set(t,i))},texStorage2D:function(){try{e.texStorage2D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texStorage3D:function(){try{e.texStorage3D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texSubImage2D:function(){try{e.texSubImage2D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},texSubImage3D:function(){try{e.texSubImage3D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},compressedTexSubImage2D:function(){try{e.compressedTexSubImage2D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},compressedTexSubImage3D:function(){try{e.compressedTexSubImage3D.apply(e,arguments)}catch(e){console.error("v3d.WebGLState:",e)}},scissor:function(t){!1===ve.equals(t)&&(e.scissor(t.x,t.y,t.z,t.w),ve.copy(t))},viewport:function(t){!1===Ae.equals(t)&&(e.viewport(t.x,t.y,t.z,t.w),Ae.copy(t))},reset:function(){e.disable(3042),e.disable(2884),e.disable(2929),e.disable(32823),e.disable(3089),e.disable(2960),e.disable(32926),e.blendEquation(32774),e.blendFunc(1,0),e.blendFuncSeparate(1,0,1,0),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.depthMask(!0),e.depthFunc(513),e.clearDepth(1),e.stencilMask(4294967295),e.stencilFunc(519,0,4294967295),e.stencilOp(7680,7680,7680),e.clearStencil(0),e.cullFace(1029),e.frontFace(2305),e.polygonOffset(0,0),e.activeTexture(33984),e.bindFramebuffer(36160,null),!0===a&&(e.bindFramebuffer(36009,null),e.bindFramebuffer(36008,null)),e.useProgram(null),e.lineWidth(1),e.scissor(0,0,e.canvas.width,e.canvas.height),e.viewport(0,0,e.canvas.width,e.canvas.height),h={},pe=null,fe={},p={},g=new WeakMap,Y=[],X=null,K=!1,q=null,Z=null,J=null,$=null,ee=null,te=null,ne=null,ie=!1,oe=null,re=null,ae=null,se=null,le=null,ve.set(0,0,e.canvas.width,e.canvas.height),Ae.set(0,0,e.canvas.width,e.canvas.height),s.reset(),l.reset(),c.reset()}}}function fl(e,t,n,i,o,r,a){const s=o.isWebGL2,l=o.maxTextures,c=o.maxCubemapSize,u=o.maxTextureSize,d=o.maxSamples,h=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,p="undefined"!=typeof navigator&&/OculusBrowser/g.test(navigator.userAgent),f=new WeakMap;let m;const g=new WeakMap;let v=!1;try{v="undefined"!=typeof OffscreenCanvas&&null!==new OffscreenCanvas(1,1).getContext("2d")}catch(e){}function A(e,t){return v?new OffscreenCanvas(e,t):Tn("canvas")}function _(e,t,n,i){let o=1;if((e.width>i||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?dn:Math.floor,r=i(o*e.width),a=i(o*e.height);void 0===m&&(m=A(r,a));const s=n?A(r,a):m;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 x(e){return cn(e.width)&&cn(e.height)}function y(e,t){return e.generateMipmaps&&t&&e.minFilter!==fe&&e.minFilter!==ve}function b(t){e.generateMipmap(t)}function C(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===Rt&&!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 M(e,t,n){return!0===y(e,n)||e.isFramebufferTexture&&e.minFilter!==fe&&e.minFilter!==ve?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 S(e){return e===fe||e===me||e===ge?9728:9729}function E(e){const t=e.target;t.removeEventListener("dispose",E),function(e){const t=i.get(e);if(void 0===t.__webglInit)return;const n=e.source,o=g.get(n);if(o){const i=o[t.__cacheKey];i.usedTimes--,0===i.usedTimes&&T(e),0===Object.keys(o).length&&g.delete(n)}i.remove(e)}(t),t.isVideoTexture&&f.delete(t)}function w(t){const n=t.target;n.removeEventListener("dispose",w),function(t){const n=t.texture,o=i.get(t),r=i.get(n);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{if(e.deleteFramebuffer(o.__webglFramebuffer),o.__webglDepthbuffer&&e.deleteRenderbuffer(o.__webglDepthbuffer),o.__webglMultisampledFramebuffer&&e.deleteFramebuffer(o.__webglMultisampledFramebuffer),o.__webglColorRenderbuffer)for(let t=0;t<o.__webglColorRenderbuffer.length;t++)o.__webglColorRenderbuffer[t]&&e.deleteRenderbuffer(o.__webglColorRenderbuffer[t]);o.__webglDepthRenderbuffer&&e.deleteRenderbuffer(o.__webglDepthRenderbuffer)}if(t.isWebGLMultipleRenderTargets)for(let t=0,o=n.length;t<o;t++){const o=i.get(n[t]);o.__webglTexture&&(e.deleteTexture(o.__webglTexture),a.memory.textures--),i.remove(n[t])}i.remove(n),i.remove(t)}(n),a.removeTextureSpec(n)}function T(t){const n=i.get(t);e.deleteTexture(n.__webglTexture);const o=t.source;delete g.get(o)[n.__cacheKey],a.memory.textures--,a.removeTextureSpec(t)}let I=0;function R(e,t){const o=i.get(e);if(e.isVideoTexture&&function(e){const t=a.render.frame;f.get(e)!==t&&(f.set(e,t),e.update())}(e),!1===e.isRenderTargetTexture&&e.version>0&&o.__version!==e.version){const n=e.image;if(null===n)console.warn("v3d.WebGLRenderer: Texture marked for update but no image data found.");else{if(!1!==n.complete)return void N(o,e,t);console.warn("v3d.WebGLRenderer: Texture marked for update but image is incomplete")}}n.bindTexture(3553,o.__webglTexture,33984+t)}const L={[de]:10497,[he]:33071,[pe]:33648},P={[fe]:9728,[me]:9984,[ge]:9986,[ve]:9729,[Ae]:9985,[_e]:9987};function B(n,r,a){if(a?(e.texParameteri(n,10242,L[r.wrapS]),e.texParameteri(n,10243,L[r.wrapT]),32879!==n&&35866!==n||e.texParameteri(n,32882,L[r.wrapR]),e.texParameteri(n,10240,P[r.magFilter]),e.texParameteri(n,10241,P[r.minFilter])):(e.texParameteri(n,10242,33071),e.texParameteri(n,10243,33071),32879!==n&&35866!==n||e.texParameteri(n,32882,33071),r.wrapS===he&&r.wrapT===he||console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to v3d.ClampToEdgeWrapping."),e.texParameteri(n,10240,S(r.magFilter)),e.texParameteri(n,10241,S(r.minFilter)),r.minFilter!==fe&&r.minFilter!==ve&&console.warn("v3d.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to v3d.NearestFilter or v3d.LinearFilter.")),!0===t.has("EXT_texture_filter_anisotropic")){const a=t.get("EXT_texture_filter_anisotropic");if(r.magFilter===fe)return;if(r.minFilter!==ge&&r.minFilter!==_e)return;if(r.type===Ee&&!1===t.has("OES_texture_float_linear"))return;if(!1===s&&r.type===we&&!1===t.has("OES_texture_half_float_linear"))return;(r.anisotropy>1||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 D(t,n){let i=!1;void 0===t.__webglInit&&(t.__webglInit=!0,n.addEventListener("dispose",E));const o=n.source;let r=g.get(o);void 0===r&&(r={},g.set(o,r));const s=function(e){const t=[];return t.push(e.wrapS),t.push(e.wrapT),t.push(e.wrapR||0),t.push(e.magFilter),t.push(e.minFilter),t.push(e.anisotropy),t.push(e.internalFormat),t.push(e.format),t.push(e.type),t.push(e.generateMipmaps),t.push(e.premultiplyAlpha),t.push(e.flipY),t.push(e.unpackAlignment),t.push(e.encoding),t.join()}(n);if(s!==t.__cacheKey){void 0===r[s]&&(r[s]={texture:e.createTexture(),usedTimes:0},a.memory.textures++,a.addTextureSpec(n),i=!0),r[s].usedTimes++;const o=r[t.__cacheKey];void 0!==o&&(r[t.__cacheKey].usedTimes--,0===o.usedTimes&&T(n)),t.__cacheKey=s,t.__webglTexture=r[s].texture}return i}function N(t,o,a){let l=3553;(o.isDataArrayTexture||o.isCompressedArrayTexture)&&(l=35866),o.isData3DTexture&&(l=32879);const c=D(t,o),d=o.source;n.bindTexture(l,t.__webglTexture,33984+a);const h=i.get(d);if(d.version!==h.__version||!0===c){n.activeTexture(33984+a),e.pixelStorei(37440,o.flipY),e.pixelStorei(37441,o.premultiplyAlpha),e.pixelStorei(3317,o.unpackAlignment),e.pixelStorei(37443,0);const t=function(e){return!s&&(e.wrapS!==he||e.wrapT!==he||e.minFilter!==fe&&e.minFilter!==ve)}(o)&&!1===x(o.image);let i=_(o.image,t,!1,u);i=G(o,i);const p=x(i)||s,f=r.convert(o.format,o.encoding);let m,g=r.convert(o.type),v=C(o.internalFormat,f,g,o.encoding,o.isVideoTexture);B(l,o,p);const A=o.mipmaps,S=s&&!0!==o.isVideoTexture,E=void 0===h.__version||!0===c,w=M(o,i,p);if(o.isDepthTexture)v=6402,s?v=o.type===Ee?36012:o.type===Se?33190:o.type===Re?35056:33189:o.type===Ee&&console.error("WebGLRenderer: Floating point depth texture requires WebGL2."),o.format===Oe&&6402===v&&o.type!==Ce&&o.type!==Se&&(console.warn("v3d.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),o.type=Se,g=r.convert(o.type)),o.format===Fe&&6402===v&&(v=34041,o.type!==Re&&(console.warn("v3d.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),o.type=Re,g=r.convert(o.type))),E&&(S?n.texStorage2D(3553,1,v,i.width,i.height):n.texImage2D(3553,0,v,i.width,i.height,0,f,g,null));else if(o.isDataTexture)if(A.length>0&&p){S&&E&&n.texStorage2D(3553,w,v,A[0].width,A[0].height);for(let e=0,t=A.length;e<t;e++)m=A[e],S?n.texSubImage2D(3553,e,0,0,m.width,m.height,f,g,m.data):n.texImage2D(3553,e,v,m.width,m.height,0,f,g,m.data);o.generateMipmaps=!1}else S?(E&&n.texStorage2D(3553,w,v,i.width,i.height),n.texSubImage2D(3553,0,0,0,i.width,i.height,f,g,i.data)):n.texImage2D(3553,0,v,i.width,i.height,0,f,g,i.data);else if(o.isCompressedTexture)if(o.isCompressedArrayTexture){S&&E&&n.texStorage3D(35866,w,v,A[0].width,A[0].height,i.depth);for(let e=0,t=A.length;e<t;e++)m=A[e],o.format!==Be?null!==f?S?n.compressedTexSubImage3D(35866,e,0,0,0,m.width,m.height,i.depth,f,m.data,0,0):n.compressedTexImage3D(35866,e,v,m.width,m.height,i.depth,0,m.data,0,0):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):S?n.texSubImage3D(35866,e,0,0,0,m.width,m.height,i.depth,f,g,m.data):n.texImage3D(35866,e,v,m.width,m.height,i.depth,0,f,g,m.data)}else{S&&E&&n.texStorage2D(3553,w,v,A[0].width,A[0].height);for(let e=0,t=A.length;e<t;e++)m=A[e],o.format!==Be?null!==f?S?n.compressedTexSubImage2D(3553,e,0,0,m.width,m.height,f,m.data):n.compressedTexImage2D(3553,e,v,m.width,m.height,0,m.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):S?n.texSubImage2D(3553,e,0,0,m.width,m.height,f,g,m.data):n.texImage2D(3553,e,v,m.width,m.height,0,f,g,m.data)}else if(o.isDataArrayTexture)S?(E&&n.texStorage3D(35866,w,v,i.width,i.height,i.depth),n.texSubImage3D(35866,0,0,0,0,i.width,i.height,i.depth,f,g,i.data)):n.texImage3D(35866,0,v,i.width,i.height,i.depth,0,f,g,i.data);else if(o.isData3DTexture)S?(E&&n.texStorage3D(32879,w,v,i.width,i.height,i.depth),n.texSubImage3D(32879,0,0,0,0,i.width,i.height,i.depth,f,g,i.data)):n.texImage3D(32879,0,v,i.width,i.height,i.depth,0,f,g,i.data);else if(o.isFramebufferTexture){if(E)if(S)n.texStorage2D(3553,w,v,i.width,i.height);else{let e=i.width,t=i.height;for(let i=0;i<w;i++)n.texImage2D(3553,i,v,e,t,0,f,g,null),e>>=1,t>>=1}}else if(A.length>0&&p){S&&E&&n.texStorage2D(3553,w,v,A[0].width,A[0].height);for(let e=0,t=A.length;e<t;e++)m=A[e],S?n.texSubImage2D(3553,e,0,0,f,g,m):n.texImage2D(3553,e,v,f,g,m);o.generateMipmaps=!1}else S?(E&&n.texStorage2D(3553,w,v,i.width,i.height),n.texSubImage2D(3553,0,0,0,f,g,i)):n.texImage2D(3553,0,v,f,g,i);y(o,p)&&b(l),h.__version=d.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}function O(t,o,a,s,l){const c=r.convert(a.format,a.encoding),u=r.convert(a.type),d=C(a.internalFormat,c,u,a.encoding);i.get(o).__hasExternalTextures||(32879===l||35866===l?n.texImage3D(l,0,d,o.width,o.height,o.depth,0,c,u,null):n.texImage2D(l,0,d,o.width,o.height,0,c,u,null)),n.bindFramebuffer(36160,t),V(o)?h.framebufferTexture2DMultisampleEXT(36160,s,l,i.get(a).__webglTexture,0,z(o)):(3553===l||l>=34069&&l<=34074)&&e.framebufferTexture2D(36160,s,l,i.get(a).__webglTexture,0),n.bindFramebuffer(36160,null)}function F(t,n,i){if(e.bindRenderbuffer(36161,t),n.depthBuffer&&!n.stencilBuffer){let o=33189;if(s&&(o=33190),i||V(n)){const t=n.depthTexture;t&&t.isDepthTexture&&(t.type===Ee?o=36012:t.type===Se&&(o=33190));const i=z(n);V(n)?h.renderbufferStorageMultisampleEXT(36161,i,o,n.width,n.height):e.renderbufferStorageMultisample(36161,i,o,n.width,n.height)}else e.renderbufferStorage(36161,o,n.width,n.height);e.framebufferRenderbuffer(36160,36096,36161,t)}else if(n.depthBuffer&&n.stencilBuffer){const o=z(n);i&&!1===V(n)?e.renderbufferStorageMultisample(36161,o,35056,n.width,n.height):V(n)?h.renderbufferStorageMultisampleEXT(36161,o,35056,n.width,n.height):e.renderbufferStorage(36161,34041,n.width,n.height),e.framebufferRenderbuffer(36160,33306,36161,t)}else{const t=!0===n.isWebGLMultipleRenderTargets?n.texture:[n.texture];for(let o=0;o<t.length;o++){const a=t[o],s=r.convert(a.format,a.encoding),l=r.convert(a.type),c=C(a.internalFormat,s,l,a.encoding),u=z(n);i&&!1===V(n)?e.renderbufferStorageMultisample(36161,u,c,n.width,n.height):V(n)?h.renderbufferStorageMultisampleEXT(36161,u,c,n.width,n.height):e.renderbufferStorage(36161,c,n.width,n.height)}}e.bindRenderbuffer(36161,null)}function U(t){const o=i.get(t),r=!0===t.isWebGLCubeRenderTarget;if(t.depthTexture&&!o.__autoAllocateDepthBuffer){if(r)throw new Error("target.depthTexture not supported in Cube render targets");!function(t,o){if(o&&o.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(n.bindFramebuffer(36160,t),!o.depthTexture||!o.depthTexture.isDepthTexture)throw new Error("renderTarget.depthTexture must be an instance of v3d.DepthTexture");i.get(o.depthTexture).__webglTexture&&o.depthTexture.image.width===o.width&&o.depthTexture.image.height===o.height||(o.depthTexture.image.width=o.width,o.depthTexture.image.height=o.height,o.depthTexture.needsUpdate=!0),R(o.depthTexture,0);const r=i.get(o.depthTexture).__webglTexture,a=z(o);if(o.depthTexture.format===Oe)V(o)?h.framebufferTexture2DMultisampleEXT(36160,36096,3553,r,0,a):e.framebufferTexture2D(36160,36096,3553,r,0);else{if(o.depthTexture.format!==Fe)throw new Error("Unknown depthTexture format");V(o)?h.framebufferTexture2DMultisampleEXT(36160,33306,3553,r,0,a):e.framebufferTexture2D(36160,33306,3553,r,0)}}(o.__webglFramebuffer,t)}else if(r){o.__webglDepthbuffer=[];for(let i=0;i<6;i++)n.bindFramebuffer(36160,o.__webglFramebuffer[i]),o.__webglDepthbuffer[i]=e.createRenderbuffer(),F(o.__webglDepthbuffer[i],t,!1)}else n.bindFramebuffer(36160,o.__webglFramebuffer),o.__webglDepthbuffer=e.createRenderbuffer(),F(o.__webglDepthbuffer,t,!1);n.bindFramebuffer(36160,null)}function z(e){return Math.min(d,e.samples)}function V(e){const n=i.get(e);return s&&e.samples>0&&!0===t.has("WEBGL_multisampled_render_to_texture")&&!1!==n.__useRenderToTexture}function G(e,n){const i=e.encoding,o=e.format,r=e.type;return!0===e.isCompressedTexture||!0===e.isVideoTexture||e.format===Ht||i!==It&&(i===Rt?!1===s?!0===t.has("EXT_sRGB")&&o===Be?(e.format=Ht,e.minFilter=ve,e.generateMipmaps=!1):n=Jn.sRGBToLinear(n):o===Be&&r===xe||console.warn("v3d.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("v3d.WebGLTextures: Unsupported texture encoding:",i)),n}this.allocateTextureUnit=function(){const e=I;return e>=l&&console.warn("v3d.WebGLTextures: Trying to use "+e+" texture units while this GPU supports only "+l),I+=1,e},this.resetTextureUnits=function(){I=0},this.setTexture2D=R,this.setTexture2DArray=function(e,t){const o=i.get(e);e.version>0&&o.__version!==e.version?N(o,e,t):n.bindTexture(35866,o.__webglTexture,33984+t)},this.setTexture3D=function(e,t){const o=i.get(e);e.version>0&&o.__version!==e.version?N(o,e,t):n.bindTexture(32879,o.__webglTexture,33984+t)},this.setTextureCube=function(t,o){const a=i.get(t);t.version>0&&a.__version!==t.version?function(t,o,a){if(6!==o.image.length)return;const l=D(t,o),u=o.source;n.bindTexture(34067,t.__webglTexture,33984+a);const d=i.get(u);if(u.version!==d.__version||!0===l){n.activeTexture(33984+a),e.pixelStorei(37440,o.flipY),e.pixelStorei(37441,o.premultiplyAlpha),e.pixelStorei(3317,o.unpackAlignment),e.pixelStorei(37443,0);const t=o.isCompressedTexture||o.image[0].isCompressedTexture,i=o.image[0]&&o.image[0].isDataTexture,h=[];for(let e=0;e<6;e++)h[e]=t||i?i?o.image[e].image:o.image[e]:_(o.image[e],!1,!0,c),h[e]=G(o,h[e]);const p=h[0],f=x(p)||s,m=r.convert(o.format,o.encoding),g=r.convert(o.type),v=C(o.internalFormat,m,g,o.encoding),A=s&&!0!==o.isVideoTexture,S=void 0===d.__version||!0===l;let E,w=M(o,p,f);if(B(34067,o,f),t){A&&S&&n.texStorage2D(34067,w,v,p.width,p.height);for(let e=0;e<6;e++){E=h[e].mipmaps;for(let t=0;t<E.length;t++){const i=E[t];o.format!==Be?null!==m?A?n.compressedTexSubImage2D(34069+e,t,0,0,i.width,i.height,m,i.data):n.compressedTexImage2D(34069+e,t,v,i.width,i.height,0,i.data):console.warn("v3d.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):A?n.texSubImage2D(34069+e,t,0,0,i.width,i.height,m,g,i.data):n.texImage2D(34069+e,t,v,i.width,i.height,0,m,g,i.data)}}}else{E=o.mipmaps,A&&S&&(E.length>0&&w++,n.texStorage2D(34067,w,v,h[0].width,h[0].height));for(let e=0;e<6;e++)if(i){A?n.texSubImage2D(34069+e,0,0,0,h[e].width,h[e].height,m,g,h[e].data):n.texImage2D(34069+e,0,v,h[e].width,h[e].height,0,m,g,h[e].data);for(let t=0;t<E.length;t++){const i=E[t].image[e].image;A?n.texSubImage2D(34069+e,t+1,0,0,i.width,i.height,m,g,i.data):n.texImage2D(34069+e,t+1,v,i.width,i.height,0,m,g,i.data)}}else{A?n.texSubImage2D(34069+e,0,0,0,m,g,h[e]):n.texImage2D(34069+e,0,v,m,g,h[e]);for(let t=0;t<E.length;t++){const i=E[t];A?n.texSubImage2D(34069+e,t+1,0,0,m,g,i.image[e]):n.texImage2D(34069+e,t+1,v,m,g,i.image[e])}}}y(o,f)&&b(34067),d.__version=u.version,o.onUpdate&&o.onUpdate(o)}t.__version=o.version}(a,t,o):n.bindTexture(34067,a.__webglTexture,33984+o)},this.rebindTextures=function(e,t,n){const o=i.get(e);void 0!==t&&O(o.__webglFramebuffer,e,e.texture,36064,3553),void 0!==n&&U(e)},this.setupRenderTarget=function(t){const l=t.texture,c=i.get(t),u=i.get(l);t.addEventListener("dispose",w),!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=x(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;t<o;t++){const o=i.get(n[t]);void 0===o.__webglTexture&&(o.__webglTexture=e.createTexture(),a.memory.textures++)}}else console.warn("v3d.WebGLRenderer: WebGLMultipleRenderTargets can only be used with WebGL2 or WEBGL_draw_buffers extension.");if(s&&t.samples>0&&!1===V(t)){const i=h?l:[l];c.__webglMultisampledFramebuffer=e.createFramebuffer(),c.__webglColorRenderbuffer=[],n.bindFramebuffer(36160,c.__webglMultisampledFramebuffer);for(let n=0;n<i.length;n++){const o=i[n];c.__webglColorRenderbuffer[n]=e.createRenderbuffer(),e.bindRenderbuffer(36161,c.__webglColorRenderbuffer[n]);const a=r.convert(o.format,o.encoding),s=r.convert(o.type),l=C(o.internalFormat,a,s,o.encoding,!0===t.isXRRenderTarget),u=z(t);e.renderbufferStorageMultisample(36161,u,l,t.width,t.height),e.framebufferRenderbuffer(36160,36064+n,36161,c.__webglColorRenderbuffer[n])}e.bindRenderbuffer(36161,null),t.depthBuffer&&(c.__webglDepthRenderbuffer=e.createRenderbuffer(),F(c.__webglDepthRenderbuffer,t,!0)),n.bindFramebuffer(36160,null)}}if(d){n.bindTexture(34067,u.__webglTexture),B(34067,l,p);for(let e=0;e<6;e++)O(c.__webglFramebuffer[e],t,l,36064,34069+e);y(l,p)&&b(34067),n.unbindTexture()}else if(h){const e=t.texture;for(let o=0,r=e.length;o<r;o++){const r=e[o],a=i.get(r);n.bindTexture(3553,a.__webglTexture),B(3553,r,p),O(c.__webglFramebuffer,t,r,36064+o,3553),y(r,p)&&b(3553)}n.unbindTexture()}else{let e=3553;(t.isWebGL3DRenderTarget||t.isWebGLArrayRenderTarget)&&(s?e=t.isWebGL3DRenderTarget?32879:35866:console.error("v3d.WebGLTextures: v3d.Data3DTexture and v3d.DataArrayTexture only supported with WebGL2.")),n.bindTexture(e,u.__webglTexture),B(e,l,p),O(c.__webglFramebuffer,t,l,36064,e),y(l,p)&&b(e),n.unbindTexture()}t.depthBuffer&&U(t)},this.updateRenderTargetMipmap=function(e){const t=x(e)||s,o=!0===e.isWebGLMultipleRenderTargets?e.texture:[e.texture];for(let r=0,a=o.length;r<a;r++){const a=o[r];if(y(a,t)){const t=e.isWebGLCubeRenderTarget?34067:3553,o=i.get(a).__webglTexture;n.bindTexture(t,o),b(t),n.unbindTexture()}}},this.updateMultisampleRenderTarget=function(t){if(s&&t.samples>0&&!1===V(t)){const o=t.isWebGLMultipleRenderTargets?t.texture:[t.texture],r=t.width,a=t.height;let s=16384;const l=[],c=t.stencilBuffer?33306:36096,u=i.get(t),d=!0===t.isWebGLMultipleRenderTargets;if(d)for(let t=0;t<o.length;t++)n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,null),n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,null,0);n.bindFramebuffer(36008,u.__webglMultisampledFramebuffer),n.bindFramebuffer(36009,u.__webglFramebuffer);for(let n=0;n<o.length;n++){l.push(36064+n),t.depthBuffer&&l.push(c);const h=void 0!==u.__ignoreDepthValues&&u.__ignoreDepthValues;if(!1===h&&(t.depthBuffer&&(s|=256),t.stencilBuffer&&(s|=1024)),d&&e.framebufferRenderbuffer(36008,36064,36161,u.__webglColorRenderbuffer[n]),!0===h&&(e.invalidateFramebuffer(36008,[c]),e.invalidateFramebuffer(36009,[c])),d){const t=i.get(o[n]).__webglTexture;e.framebufferTexture2D(36009,36064,3553,t,0)}e.blitFramebuffer(0,0,r,a,0,0,r,a,s,9728),p&&e.invalidateFramebuffer(36008,l)}if(n.bindFramebuffer(36008,null),n.bindFramebuffer(36009,null),d)for(let t=0;t<o.length;t++){n.bindFramebuffer(36160,u.__webglMultisampledFramebuffer),e.framebufferRenderbuffer(36160,36064+t,36161,u.__webglColorRenderbuffer[t]);const r=i.get(o[t]).__webglTexture;n.bindFramebuffer(36160,u.__webglFramebuffer),e.framebufferTexture2D(36009,36064+t,3553,r,0)}n.bindFramebuffer(36009,u.__webglMultisampledFramebuffer)}},this.setupDepthRenderbuffer=U,this.setupFrameBufferTexture=O,this.useMultisampledRTT=V}function ml(e,t,n){const i=n.isWebGL2;return{convert:function(n,o=null){let r;if(n===xe)return 5121;if(n===Te)return 32819;if(n===Ie)return 32820;if(n===ye)return 5120;if(n===be)return 5122;if(n===Ce)return 5123;if(n===Me)return 5124;if(n===Se)return 5125;if(n===Ee)return 5126;if(n===we)return i?5131:(r=t.get("OES_texture_half_float"),null!==r?r.HALF_FLOAT_OES:null);if(n===Le)return 6406;if(n===Be)return 6408;if(n===De)return 6409;if(n===Ne)return 6410;if(n===Oe)return 6402;if(n===Fe)return 34041;if(n===Pe)return console.warn("v3d.WebGLRenderer: v3d.RGBFormat has been removed. Use v3d.RGBAFormat instead. https://github.com/mrdoob/three.js/pull/23228"),6408;if(n===Ht)return r=t.get("EXT_sRGB"),null!==r?r.SRGB_ALPHA_EXT:null;if(n===Ue)return 6403;if(n===ze)return 36244;if(n===Ve)return 33319;if(n===Ge)return 33320;if(n===ke)return 36249;if(n===Qe||n===We||n===He||n===je)if(o===Rt){if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),null===r)return null;if(n===Qe)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===We)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===He)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===je)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else{if(r=t.get("WEBGL_compressed_texture_s3tc"),null===r)return null;if(n===Qe)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===We)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===He)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===je)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(n===Ye||n===Xe||n===Ke||n===qe){if(r=t.get("WEBGL_compressed_texture_pvrtc"),null===r)return null;if(n===Ye)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Xe)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Ke)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===qe)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(n===Ze)return r=t.get("WEBGL_compressed_texture_etc1"),null!==r?r.COMPRESSED_RGB_ETC1_WEBGL:null;if(n===Je||n===$e){if(r=t.get("WEBGL_compressed_texture_etc"),null===r)return null;if(n===Je)return o===Rt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===$e)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC}if(n===et||n===tt||n===nt||n===it||n===ot||n===rt||n===at||n===st||n===lt||n===ct||n===ut||n===dt||n===ht||n===pt){if(r=t.get("WEBGL_compressed_texture_astc"),null===r)return null;if(n===et)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===tt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===nt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===it)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ot)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===rt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===at)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===st)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===lt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===ct)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ut)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===dt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ht)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===pt)return o===Rt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}if(n===ft){if(r=t.get("EXT_texture_compression_bptc"),null===r)return null;if(n===ft)return o===Rt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT}return n===Re?i?34042:(r=t.get("WEBGL_depth_texture"),null!==r?r.UNSIGNED_INT_24_8_WEBGL:null):void 0!==e[n]?e[n]:null}}}class gl extends hr{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class vl extends uo{constructor(){super(),this.isGroup=!0,this.type="Group"}getWorldDirection(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}}const Al={type:"move"};class _l{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return null===this._hand&&(this._hand=new vl,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(e){return null===this._targetRay&&(this._targetRay=new vl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ci,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ci,this._targetRay.name="XR_CONTROLLER_"+String(e)),this._targetRay}getGripSpace(){return null===this._grip&&(this._grip=new vl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ci,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ci),this._grip}dispatchEvent(e){return null!==this._targetRay&&this._targetRay.dispatchEvent(e),null!==this._grip&&this._grip.dispatchEvent(e),null!==this._hand&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),null!==this._targetRay&&(this._targetRay.visible=!1),null!==this._grip&&(this._grip.visible=!1),null!==this._hand&&(this._hand.visible=!1),this}update(e,t,n){let i=null,o=null,r=null;const a=this._targetRay,s=this._grip,l=this._hand;if(e&&"visible-blurred"!==t.session.visibilityState){if(l&&e.hand){r=!0;for(const i of e.hand.values()){const e=t.getJointPose(i,n),o=this._getHandJoint(l,i);null!==e&&(o.matrix.fromArray(e.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.jointRadius=e.radius),o.visible=null!==e}const i=l.joints["index-finger-tip"],o=l.joints["thumb-tip"],a=i.position.distanceTo(o.position),s=.02,c=.005;l.inputState.pinching&&a>s+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));null!==a&&(i=t.getPose(e.targetRaySpace,n),null===i&&null!==o&&(i=o),null!==i&&(a.matrix.fromArray(i.transform.matrix),a.matrix.decompose(a.position,a.rotation,a.scale),i.linearVelocity?(a.hasLinearVelocity=!0,a.linearVelocity.copy(i.linearVelocity)):a.hasLinearVelocity=!1,i.angularVelocity?(a.hasAngularVelocity=!0,a.angularVelocity.copy(i.angularVelocity)):a.hasAngularVelocity=!1,this.dispatchEvent(Al)))}return null!==a&&(a.visible=null!==i),null!==s&&(s.visible=null!==o),null!==l&&(l.visible=null!==r),this}_getHandJoint(e,t){if(void 0===e.joints[t.jointName]){const n=new vl;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class xl extends ni{constructor(e,t,n,i,o,r,a,s,l,c){if((c=void 0!==c?c:Oe)!==Oe&&c!==Fe)throw new Error("DepthTexture format must be either v3d.DepthFormat or v3d.DepthStencilFormat");void 0===n&&c===Oe&&(n=Se),void 0===n&&c===Fe&&(n=Re),super(null,i,o,r,a,s,c,n,l),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==a?a:fe,this.minFilter=void 0!==s?s:fe,this.flipY=!1,this.generateMipmaps=!1}}class yl{constructor(e,t,n=0,i=1/0){this.ray=new Ui(e,t),this.near=n,this.far=i,this.camera=null,this.layers=new qi,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.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.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 Cl(e,this,n,t,this.params.checkVisibility),n.sort(bl),n}intersectObjects(e,t=!0,n=[]){for(let i=0,o=e.length;i<o;i++)Cl(e[i],this,n,t,this.params.checkVisibility);return n.sort(bl),n}}function bl(e,t){return e.distance-t.distance}function Cl(e,t,n,i,o){if(!(o&&(!1===e.visible||e.isMesh&&e.isMaterialGeneratedMesh&&e.parent&&!e.parent.visible)||(e.layers.test(t.layers)&&e.raycast(t,n),!0!==i))){const i=e.children;for(let e=0,r=i.length;e<r;e++)Cl(i[e],t,n,!0,o)}}class Ml extends qt{constructor(e,t){super();const n=this;let i=null,o=1,r=null,a="local-floor",s=null,l=null,c=null,u=null,d=null,h=null;const p=t.getContextAttributes();let f=null,m=null;const g=[],v=[],A=new Set,_=new Map,x=new hr;x.layers.enable(1),x.viewport=new ii;const y=new hr;y.layers.enable(2),y.viewport=new ii;const b=[x,y],C=new gl;C.layers.enable(1),C.layers.enable(2);let M=null,S=null,E=null,w=null,T=null,I=new zi;const R=new ci,L=new ci,P=new li;function B(e){const t=v.indexOf(e.inputSource);if(-1===t)return;const n=g[t];void 0!==n&&n.dispatchEvent({type:e.type,data:e.inputSource})}function D(){i.removeEventListener("select",B),i.removeEventListener("selectstart",B),i.removeEventListener("selectend",B),i.removeEventListener("squeeze",B),i.removeEventListener("squeezestart",B),i.removeEventListener("squeezeend",B),i.removeEventListener("end",D),i.removeEventListener("inputsourceschange",N);for(let e=0;e<g.length;e++){const t=v[e];null!==t&&(v[e]=null,g[e].disconnect(t))}M=null,S=null,e.setRenderTarget(f),d=null,u=null,c=null,i=null,m=null,E=null,V.stop(),n.isPresenting=!1,n.dispatchEvent({type:"sessionend"})}function N(e){for(let t=0;t<e.removed.length;t++){const n=e.removed[t],i=v.indexOf(n);i>=0&&(v[i]=null,g[i].disconnect(n))}for(let t=0;t<e.added.length;t++){const n=e.added[t];let i=v.indexOf(n);if(-1===i){for(let e=0;e<g.length;e++){if(e>=v.length){v.push(n),i=e;break}if(null===v[e]){v[e]=n,i=e;break}}if(-1===i)break}const o=g[i];o&&o.connect(n)}}this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=g[e];return void 0===t&&(t=new _l,g[e]=t),t.getTargetRaySpace(e)},this.getControllerGrip=function(e){let t=g[e];return void 0===t&&(t=new _l,g[e]=t),t.getGripSpace()},this.getHand=function(e){let t=g[e];return void 0===t&&(t=new _l,g[e]=t),t.getHandSpace()},this.setFramebufferScaleFactor=function(e){o=e,!0===n.isPresenting&&console.warn("v3d.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(e){a=e,!0===n.isPresenting&&console.warn("v3d.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return s||r},this.setReferenceSpace=function(e){s=e},this.getBaseLayer=function(){return null!==u?u:d},this.getBinding=function(){return c},this.getFrame=function(){return h},this.getSession=function(){return i},this.setSession=async function(l){if(i=l,null!==i){if(f=e.getRenderTarget(),i.addEventListener("select",B),i.addEventListener("selectstart",B),i.addEventListener("selectend",B),i.addEventListener("squeeze",B),i.addEventListener("squeezestart",B),i.addEventListener("squeezeend",B),i.addEventListener("end",D),i.addEventListener("inputsourceschange",N),!0!==p.xrCompatible&&await t.makeXRCompatible(),void 0===i.renderState.layers||!1===e.capabilities.isWebGL2){const n={antialias:void 0!==i.renderState.layers||p.antialias,alpha:p.alpha,depth:p.depth,stencil:p.stencil,framebufferScaleFactor:o};d=new XRWebGLLayer(i,t,n),i.updateRenderState({baseLayer:d}),m=new oi(d.framebufferWidth,d.framebufferHeight,{format:Be,type:xe,encoding:e.outputEncoding,stencilBuffer:p.stencil})}else{let n=null,r=null,a=null;p.depth&&(a=p.stencil?35056:33190,n=p.stencil?Fe:Oe,r=p.stencil?Re:Se);const s={colorFormat:32856,depthFormat:a,scaleFactor:o};c=new XRWebGLBinding(i,t),u=c.createProjectionLayer(s),i.updateRenderState({layers:[u]}),m=new oi(u.textureWidth,u.textureHeight,{format:Be,type:xe,depthTexture:new xl(u.textureWidth,u.textureHeight,r,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:p.stencil,encoding:e.outputEncoding,samples:p.antialias?4:0});e.properties.get(m).__ignoreDepthValues=u.ignoreDepthValues}m.isXRRenderTarget=!0,this.setFoveation(1),s=null,r=await i.requestReferenceSpace(a),V.setContext(i),V.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}};const O=new ci,F=new ci;function U(e,t){if(null===t)e.matrixWorld.copy(e.matrix),I.identity(),s=null;else{e.matrixWorld.copy(e.matrix),I.copy(t.matrixWorld).invert().decompose(R,P,L);var n=new XRRigidTransform({x:R.x,y:R.y,z:R.z},{x:P.x,y:P.y,z:P.z,w:P.w});s=r.getOffsetReferenceSpace(n)}e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(null===i)return;C.near=y.near=x.near=e.near,C.far=y.far=x.far=e.far,M===C.near&&S===C.far||(i.updateRenderState({depthNear:C.near,depthFar:C.far}),M=C.near,S=C.far);const t=e.parent,n=C.cameras;U(C,t);for(let e=0;e<n.length;e++)U(n[e],t);C.matrixWorld.decompose(C.position,C.quaternion,C.scale),e.matrixWorld.copy(C.matrixWorld),null===t?e.matrix.copy(e.matrixWorld):(e.matrix.copy(t.matrixWorld).invert(),e.matrix.multiply(e.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale);const o=e.children;for(let e=0,t=o.length;e<t;e++)o[e].updateMatrixWorld(!0);2===n.length?function(e,t,n){O.setFromMatrixPosition(t.matrixWorld),F.setFromMatrixPosition(n.matrixWorld);const i=O.distanceTo(F),o=t.projectionMatrix.elements,r=n.projectionMatrix.elements,a=o[14]/(o[10]-1),s=o[14]/(o[10]+1),l=(o[9]+1)/o[5],c=(o[9]-1)/o[5],u=(o[8]-1)/o[0],d=(r[8]+1)/r[0],h=a*u,p=a*d,f=i/(-u+d),m=f*-u;t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(m),e.translateZ(f),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert();const g=a+f,v=s+f,A=h-m,_=p+(i-m),x=l*s/v*g,y=c*s/v*g;e.projectionMatrix.makePerspective(A,_,x,y,g,v)}(C,x,y):C.projectionMatrix.copy(x.projectionMatrix),C.projectionMatrixInverse.copy(C.projectionMatrix).invert()},this.getCamera=function(){return C},this.getFoveation=function(){return null!==u?u.fixedFoveation:null!==d?d.fixedFoveation:void 0},this.setFoveation=function(e){null!==u&&(u.fixedFoveation=e),null!==d&&void 0!==d.fixedFoveation&&(d.fixedFoveation=e)},this.getPlanes=function(){return A};let z=null;const V=new Mr;function G(e){if(E){const t=e.getHitTestResults(E);if(t.length){const e=t[0].getPose(n.getReferenceSpace()),i=(new zi).fromArray(e.transform.matrix),o=new ci;o.setFromMatrixPosition(i);const r=new ci(0,1,0);r.applyNormalMatrix((new bn).setFromMatrix4(i)),w(o,r)}else T()}}V.setAnimationLoop((function(t,i){if(l=i.getViewerPose(s||r),h=i,null!==l){const t=l.views;null!==d&&(e.setRenderTargetFramebuffer(m,d.framebuffer),e.setRenderTarget(m));let n=!1;t.length!==C.cameras.length&&(C.cameras.length=0,n=!0);for(let i=0;i<t.length;i++){const o=t[i];let r=null;if(null!==d)r=d.getViewport(o);else{const t=c.getViewSubImage(u,o);r=t.viewport,0===i&&(e.setRenderTargetTextures(m,t.colorTexture,u.ignoreDepthValues?void 0:t.depthStencilTexture),e.setRenderTarget(m))}let a=b[i];void 0===a&&(a=new hr,a.layers.enable(i),a.viewport=new ii,b[i]=a),a.matrix.fromArray(o.transform.matrix),a.projectionMatrix.fromArray(o.projectionMatrix),a.viewport.set(r.x,r.y,r.width,r.height),0===i&&C.matrix.copy(a.matrix),!0===n&&C.cameras.push(a)}}for(let e=0;e<g.length;e++){const t=v[e],n=g[e];null!==t&&void 0!==n&&n.update(t,i,s||r),G(i)}if(z&&z(t,i),i.detectedPlanes){n.dispatchEvent({type:"planesdetected",data:i.detectedPlanes});let e=null;for(const t of A)i.detectedPlanes.has(t)||(null===e&&(e=[]),e.push(t));if(null!==e)for(const t of e)A.delete(t),_.delete(t),n.dispatchEvent({type:"planeremoved",data:t});for(const e of i.detectedPlanes)if(A.has(e)){const t=_.get(e);e.lastChangedTime>t&&(_.set(e,e.lastChangedTime),n.dispatchEvent({type:"planechanged",data:e}))}else A.add(e),_.set(e,i.lastChangedTime),n.dispatchEvent({type:"planeadded",data:e})}h=null})),this.setAnimationLoop=function(e){z=e},this.dispose=function(){},this.arHitTest=function(e,t,n,o){if(!i||!XRSession.prototype.requestHitTestSource)return;w=n||function(){},T=o||function(){},this.raycaster=this.raycaster||new yl,this.raycaster.setFromCamera({x:e,y:t},b[0]);const r=this.raycaster.ray;new XRRay(r.origin,r.direction);i.requestReferenceSpace("viewer").then((function(e){const t={space:e};i.requestHitTestSource(t).then((function(e){E=e}))}))}}}function Sl(e,t){function n(n,i){n.opacity.value=i.opacity,i.color&&n.diffuse.value.copy(i.color),i.emissive&&n.emissive.value.copy(i.emissive).multiplyScalar(i.emissiveIntensity),i.map&&(n.map.value=i.map),i.alphaMap&&(n.alphaMap.value=i.alphaMap),i.bumpMap&&(n.bumpMap.value=i.bumpMap,n.bumpScale.value=i.bumpScale,i.side===f&&(n.bumpScale.value*=-1)),i.displacementMap&&(n.displacementMap.value=i.displacementMap,n.displacementScale.value=i.displacementScale,n.displacementBias.value=i.displacementBias),i.emissiveMap&&(n.emissiveMap.value=i.emissiveMap),i.normalMap&&(n.normalMap.value=i.normalMap,n.normalScale.value.copy(i.normalScale),i.side===f&&n.normalScale.value.negate()),i.specularMap&&(n.specularMap.value=i.specularMap),i.alphaTest>0&&(n.alphaTest.value=i.alphaTest);const o=t.get(i).envMap;if(o&&(n.envMap.value=o,n.flipEnvMap.value=o.isCubeTexture&&!1===o.isRenderTargetTexture?-1:1,n.reflectivity.value=i.reflectivity,n.ior.value=i.ior,n.refractionRatio.value=i.refractionRatio),i.lightMap){n.lightMap.value=i.lightMap;const t=!0!==e.physicallyCorrectLights?Math.PI:1;n.lightMapIntensity.value=i.lightMapIntensity*t}let r,a;i.aoMap&&(n.aoMap.value=i.aoMap,n.aoMapIntensity.value=i.aoMapIntensity),i.map?r=i.map:i.specularMap?r=i.specularMap:i.displacementMap?r=i.displacementMap:i.normalMap?r=i.normalMap:i.bumpMap?r=i.bumpMap:i.roughnessMap?r=i.roughnessMap:i.metalnessMap?r=i.metalnessMap:i.alphaMap?r=i.alphaMap:i.emissiveMap?r=i.emissiveMap:i.clearcoatMap?r=i.clearcoatMap:i.clearcoatNormalMap?r=i.clearcoatNormalMap:i.clearcoatRoughnessMap?r=i.clearcoatRoughnessMap:i.iridescenceMap?r=i.iridescenceMap:i.iridescenceThicknessMap?r=i.iridescenceThicknessMap:i.specularIntensityMap?r=i.specularIntensityMap:i.specularColorMap?r=i.specularColorMap:i.transmissionMap?r=i.transmissionMap:i.thicknessMap?r=i.thicknessMap:i.sheenColorMap?r=i.sheenColorMap:i.sheenRoughnessMap&&(r=i.sheenRoughnessMap),void 0!==r&&(r.isWebGLRenderTarget&&(r=r.texture),!0===r.matrixAutoUpdate&&r.updateMatrix(),n.uvTransform.value.copy(r.matrix)),i.aoMap?a=i.aoMap:i.lightMap&&(a=i.lightMap),void 0!==a&&(a.isWebGLRenderTarget&&(a=a.texture),!0===a.matrixAutoUpdate&&a.updateMatrix(),n.uv2Transform.value.copy(a.matrix))}return{refreshFogUniforms:function(t,n){n.color.getRGB(t.fogColor.value,lr(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)},refreshMaterialUniforms:function(e,i,o,r,a){i.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}(e,i),i.isMeshBasicMaterial||i.isMeshLambertMaterial?n(e,i):i.isMeshToonMaterial?(n(e,i),function(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}(e,i)):i.isMeshPhongMaterial?(n(e,i),function(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}(e,i)):i.isMeshStandardMaterial?(n(e,i),function(e,n){e.roughness.value=n.roughness,e.metalness.value=n.metalness,n.roughnessMap&&(e.roughnessMap.value=n.roughnessMap);n.metalnessMap&&(e.metalnessMap.value=n.metalnessMap);const i=t.get(n).envMap;i&&(e.envMapIntensity.value=n.envMapIntensity,e.envMapParallaxType.value=n.envMapParallaxType,e.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv))}(e,i),i.isMeshPhysicalMaterial&&function(e,t,n){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,t.side===f&&e.clearcoatNormalScale.value.negate()));t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap));t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=n.texture,e.transmissionSamplerSize.value.set(n.width,n.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)}(e,i,a)):i.isMeshMatcapMaterial?(n(e,i),function(e,t){t.matcap&&(e.matcap.value=t.matcap)}(e,i)):i.isMeshDepthMaterial?(n(e,i),function(e,t){e.slopeScaledBias.value=t.slopeScaledBias}(e,i)):i.isMeshDistanceMaterial?(n(e,i),function(e,t){e.referencePosition.value.copy(t.referencePosition),e.nearDistance.value=t.nearDistance,e.farDistance.value=t.farDistance,e.slopeScaledBias.value=t.slopeScaledBias}(e,i)):i.isMeshNormalMaterial?n(e,i):i.isLineBasicMaterial?(function(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity}(e,i),i.isLineDashedMaterial&&function(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}(e,i)):i.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))}(e,i,o,r):i.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))}(e,i):i.isShadowMaterial?(e.color.value.copy(i.color),e.opacity.value=i.opacity):i.isMeshMaskMaterial?(n(e,i),function(e,t){t.cameraNearFar&&(e.cameraNearFar.value=t.cameraNearFar);e.depthTexture.value=t.depthTexture,t.textureMatrix&&(e.textureMatrix.value=t.textureMatrix)}(e,i)):i.isMeshNodeMaterial?function(e,n){n.alphaTest>0&&(e.alphaTest.value=n.alphaTest);const i=t.get(n).envMap;i&&(e.envMap.value=i,e.flipEnvMap.value=i.isCubeTexture&&i.isRenderTargetTexture?-1:1,e.reflectivity.value=n.reflectivity,e.refractionRatio.value=n.refractionRatio,e.envMapIntensity.value=n.envMapIntensity,e.envMapParallaxType.value=n.envMapParallaxType,e.envMapParallaxMatrix.value.copy(n.envMapParallaxMatrix),e.envMapParallaxMatrixInv.value.copy(n.envMapParallaxMatrixInv));n.displacementMap&&(e.displacementMap.value=n.displacementMap,e.displacementScale.value=n.displacementScale,e.displacementBias.value=n.displacementBias);e.materialIndex.value=n.materialIndex}(e,i):i.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}(e,i):i.isShaderMaterial&&(i.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}}}function El(e,t,n,i){let o={},r={},a=[];const s=n.isWebGL2?e.getParameter(35375):0;function l(e,t,n){const i=e.value;if(void 0===n[t]){if("number"==typeof i)n[t]=i;else{const e=Array.isArray(i)?i:[i],o=[];for(let t=0;t<e.length;t++)o.push(e[t].clone());n[t]=o}return!0}if("number"==typeof i){if(n[t]!==i)return n[t]=i,!0}else{const e=Array.isArray(n[t])?n[t]:[n[t]],o=Array.isArray(i)?i:[i];for(let t=0;t<e.length;t++){const n=e[t];if(!1===n.equals(o[t]))return n.copy(o[t]),!0}}return!1}function c(e){const t={boundary:0,storage:0};return"number"==typeof e?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn("v3d.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("v3d.WebGLRenderer: Unsupported uniform value type.",e),t}function u(t){const n=t.target;n.removeEventListener("dispose",u);const i=a.indexOf(n.__bindingPointIndex);a.splice(i,1),e.deleteBuffer(o[n.id]),delete o[n.id],delete r[n.id]}return{bind:function(e,t){const n=t.program;i.uniformBlockBinding(e,n)},update:function(n,d){let h=o[n.id];void 0===h&&(!function(e){const t=e.uniforms;let n=0;const i=16;let o=0;for(let e=0,r=t.length;e<r;e++){const r=t[e],a={boundary:0,storage:0},s=Array.isArray(r.value)?r.value:[r.value];for(let e=0,t=s.length;e<t;e++){const t=c(s[e]);a.boundary+=t.boundary,a.storage+=t.storage}if(r.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),r.__offset=n,e>0){o=n%i;0!==o&&i-o-a.boundary<0&&(n+=i-o,r.__offset=n)}n+=a.storage}o=n%i,o>0&&(n+=i-o);e.__size=n,e.__cache={}}(n),h=function(t){const n=function(){for(let e=0;e<s;e++)if(-1===a.indexOf(e))return a.push(e),e;return console.error("v3d.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}();t.__bindingPointIndex=n;const i=e.createBuffer(),o=t.__size,r=t.usage;return e.bindBuffer(35345,i),e.bufferData(35345,o,r),e.bindBuffer(35345,null),e.bindBufferBase(35345,n,i),i}(n),o[n.id]=h,n.addEventListener("dispose",u));const p=d.program;i.updateUBOMapping(n,p);const f=t.render.frame;r[n.id]!==f&&(!function(t){const n=o[t.id],i=t.uniforms,r=t.__cache;e.bindBuffer(35345,n);for(let t=0,n=i.length;t<n;t++){const n=i[t];if(!0===l(n,t,r)){const t=n.__offset,i=Array.isArray(n.value)?n.value:[n.value];let o=0;for(let r=0;r<i.length;r++){const a=i[r],s=c(a);"number"==typeof a?(n.__data[0]=a,e.bufferSubData(35345,t+o,n.__data)):a.isMatrix3?(n.__data[0]=a.elements[0],n.__data[1]=a.elements[1],n.__data[2]=a.elements[2],n.__data[3]=a.elements[0],n.__data[4]=a.elements[3],n.__data[5]=a.elements[4],n.__data[6]=a.elements[5],n.__data[7]=a.elements[0],n.__data[8]=a.elements[6],n.__data[9]=a.elements[7],n.__data[10]=a.elements[8],n.__data[11]=a.elements[0]):(a.toArray(n.__data,o),o+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(35345,t,n.__data)}}e.bindBuffer(35345,null)}(n),r[n.id]=f)},dispose:function(){for(const t in o)e.deleteBuffer(o[t]);a=[],o={},r={}}}}const wl={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.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.'].join("\n"):["Ouch! Your browser does not support WebGL.<br/>",'Find out how to fix it <a href="https://www.soft8soft.com/webgl-supported-browsers-and-troubleshooting/" target="_top" class="v3d-webgl-error-link">here</a>.'].join("\n"),e},showWebGLErrorMessage:function(e){(e=e||document.body).appendChild(wl.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/))},isTouchDevice:function(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}};class Tl extends qt{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 Il=new Fr(-1,1,1,-1,0,1),Rl=new zo;Rl.setAttribute("position",new Lo([-1,3,0,-1,-1,0,3,-1,0],3)),Rl.setAttribute("uv",new Lo([0,2,0,0,2,0],2));class Ll{constructor(e){this._mesh=new ir(Rl,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Il)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}static dispose(){Rl.dispose()}}const Pl=new qn,Bl=new qi;class Dl{constructor(e,t){this.resolution=e,this.textureType=t,this.type="WebGLOITMethod",this.mute=!1}render(){this.mute}dispose(){}setSize(e,t){this.resolution.set(e,t)}_ensureProperBuffersClearing(e){e.state.buffers.depth.setTest(!0),e.state.buffers.depth.setMask(!0),e.state.buffers.color.setMask(!0)}}Dl.prototype.isWebGLOITMethod=!0;class Nl extends Dl{constructor(e,t,n){super(e,t),this.type="WebGLOITWeighted",this.shader=Ir.oitWeighted,this.uniforms=cr.clone(this.shader.uniforms),this.scene=null,this.camera=null,this.aaSamples=n||0,this.renderTargetMRT=new si(this.resolution.x,this.resolution.y,2),this.renderTargetMRT.texture[0].name="wboit_rgba",this.renderTargetMRT.texture[0].format=Be,this.renderTargetMRT.texture[0].type=t,this.renderTargetMRT.texture[1].name="wboit_r",this.renderTargetMRT.texture[1].format=Ue,this.renderTargetMRT.texture[1].type=t,this.aaSamples>0&&(this.renderTargetMRTMSAA=new si(this.resolution.x,this.resolution.y,2,{samples:n}),this.renderTargetMRTMSAA.texture[0].name="wboit_rgba",this.renderTargetMRTMSAA.texture[0].format=Be,this.renderTargetMRTMSAA.texture[0].type=t,this.renderTargetMRTMSAA.texture[1].name="wboit_r",this.renderTargetMRTMSAA.texture[1].format=Ue,this.renderTargetMRTMSAA.texture[1].type=t),this.fsQuadSolver=new Ll(new ur({defines:Object.assign({},this.shader.defines),uniforms:cr.clone(this.shader.uniforms),vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader,depthTest:!1,depthWrite:!1,blending:b,blendEquation:C,blendSrc:P,blendDst:B,blendEquationAlpha:C,blendSrcAlpha:I,blendDstAlpha:B})),this._layerMasks={},this._matSettings={},this._savedCameraLayers=new qi}dispose(){super.dispose(),this.renderTargetMRT.dispose(),this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.dispose()}setSize(e,t){super.setSize(e,t),this.renderTargetMRT.setSize(e,t),this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.setSize(e,t)}render(e,t,n,i,o){if(this.mute)return;this._ensureProperBuffersClearing(e);const r=e.getRenderTarget();if(r.isWebGLCubeRenderTarget)return void t(n,i,o);const a=i.overrideMaterial;if(a&&!this.isSupportedMaterial(a))return void t(n,i,o);if(this.resolution.x!==r.width&&this.resolution.y!==r.height)return console.warn("v3d.WebGLOITRenderer: render target size mismatch in v3d.WebGLOITWeighted."),void t(n,i,o);this.scene=i,this.camera=o,this._savedCameraLayers.mask=this.camera.layers.mask;const s=e.getClearColor(Pl),l=e.getClearAlpha(),c=e.autoClear,u=e.useOIT,d=e.sortObjects;e.setClearColor(0),e.setClearAlpha(0),e.autoClear=!1,e.sortObjects=!1,e.useOIT=!1;const h=this.renderTargetMRTMSAA&&this.renderTargetMRTMSAA.samples==r.samples;if(a){const s=[{object:i,material:a}];this._accumulationPass(e,t,h,n,s);const l=a.colorWrite;a.colorWrite=!1,a.needsUpdate=!0,e.setRenderTarget(r),t(n,i,o),a.colorWrite=l,a.needsUpdate=!0}else this._saveLayers(n),this._setupLayers(n),o.layers.disableAll(),o.layers.enable(2),t(n,i,o),o.layers.disableAll(),o.layers.enable(1),this._accumulationPass(e,t,h,n),e.setRenderTarget(r),this._renderOnlyDepth(e,t,n,i,o),this._restoreLayers(n);e.setRenderTarget(r),this._solverPass(e,h),e.setClearColor(s),e.setClearAlpha(l),e.sortObjects=d,e.autoClear=c,e.useOIT=u}isSupportedMaterial(e){return!(!e||!e.isMeshStandardMaterial&&!e.isMeshNodeMaterial)}_accumulationPass(e,t,n,i,o){o||(o=i);const r=e.getContext(),a=e.getRenderTarget(),s=e.getClearAlpha();if(this._saveMatSettings(o),this._setupMatSettings(o),e.setClearAlpha(1),a)if(n){e.setRenderTarget(this.renderTargetMRTMSAA),e.clear();const n=e.properties.get(this.renderTargetMRTMSAA).__webglDepthRenderbuffer,o=e.properties.get(a).__webglDepthRenderbuffer;if(o&&(r.framebufferRenderbuffer(36160,36096,36161,o),36053!==r.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.");t(i,this.scene,this.camera);if(e.getTextureUtils().updateMultisampleRenderTarget(this.renderTargetMRTMSAA),o&&(r.framebufferRenderbuffer(36160,36096,36161,n||null),36053!==r.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.samples>0){e.setRenderTarget(this.renderTargetMRT),e.clear();const n=e.properties.get(this.renderTargetMRT).__webglFramebuffer,o=e.properties.get(a).__webglMultisampledFramebuffer;if(o&&(r.bindFramebuffer(36008,o),r.bindFramebuffer(36009,n),r.blitFramebuffer(0,0,this.resolution.x,this.resolution.y,0,0,this.resolution.x,this.resolution.y,256,9728),r.bindFramebuffer(36160,n),36053!==r.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted. Can not blit depth buffer from v3d.WebGLMultisampleRenderTarget.");t(i,this.scene,this.camera)}else{e.setRenderTarget(this.renderTargetMRT),e.clear();const n=e.properties.get(this.renderTargetMRT),o=n.__webglDepthRenderbuffer||n.__webglDepthbuffer,s=e.properties.get(a),l=s.__webglDepthRenderbuffer||s.__webglDepthbuffer;if(l){if(r.framebufferRenderbuffer(36160,36096,36161,l),36053!==r.checkFramebufferStatus(36160))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.depthTexture){const t=e.properties.get(a.depthTexture).__webglTexture;r.framebufferTexture2D(36160,36096,3553,t,0)}if(t(i,this.scene,this.camera),l){if(r.framebufferRenderbuffer(36160,36096,36161,o||null),36053!==r.checkFramebufferStatus(36160))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else if(a.depthTexture&&(r.framebufferRenderbuffer(36160,36096,36161,o||null),36053!==r.checkFramebufferStatus(36160)))return void console.error("v3d.WebGLOITRenderer: incomplete framebuffer in v3d.WebGLOITWeighted.")}else console.error("v3d.WebGLOITRenderer: undefined render target in v3d.WebGLOITWeighted.");this._restoreMatSettings(o),e.setClearAlpha(s),e.setRenderTarget(a)}_solverPass(e,t){const n=t?this.renderTargetMRTMSAA:this.renderTargetMRT;this.fsQuadSolver.material.uniforms.tRGBABuffer.value=n.texture[0],this.fsQuadSolver.material.uniforms.tFloatBuffer.value=n.texture[1],this.fsQuadSolver.render(e)}_testInitialLayersWithInitialCameraLayers(e){const t=this._layerMasks[e.id];return Bl.mask=void 0!==t?t:e.layers.mask,this._savedCameraLayers.test(Bl)}_saveLayers(e){this._layerMasks[this.camera.id]=this.camera.layers.mask;for(let t=0,n=e.length;t<n;t++){const n=e[t].object;this._layerMasks[n.id]=n.layers.mask}}_setupLayers(e){for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.object,o=n.material;this._testInitialLayersWithInitialCameraLayers(i)?(i.layers.disableAll(),this.isSupportedMaterial(o)?i.layers.enable(1):i.layers.enable(2)):i.layers.disableAll()}}_restoreLayers(e){for(let t=0,n=e.length;t<n;t++){const n=e[t].object;n.layers.mask=this._layerMasks[n.id],delete this._layerMasks[n.id]}this.camera.layers.mask=this._layerMasks[this.camera.id],delete this._layerMasks[this.camera.id]}_saveMatSettings(e){for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.object,o=n.material;o&&o.id in this._matSettings||this._testInitialLayersWithInitialCameraLayers(i)&&this.isSupportedMaterial(o)&&(this._matSettings[o.id]={defines:{PREMULTIPLIED_ALPHA:o.defines.PREMULTIPLIED_ALPHA},properties:{blending:o.blending,blendEquation:o.blendEquation,blendSrc:o.blendSrc,blendDst:o.blendDst,blendEquationAlpha:o.blendEquationAlpha,blendSrcAlpha:o.blendSrcAlpha,blendDstAlpha:o.blendDstAlpha,depthTest:o.depthTest,depthWrite:o.depthWrite}})}}_setupMatSettings(e){for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.object,o=n.material;this._testInitialLayersWithInitialCameraLayers(i)&&(this.isSupportedMaterial(o)&&(o.defines.PREMULTIPLIED_ALPHA="",o.defines.USE_OIT_WEIGHTED="",o.blending=b,o.blendEquation=C,o.blendSrc=I,o.blendDst=I,o.blendEquationAlpha=C,o.blendSrcAlpha=T,o.blendDstAlpha=B,o.depthTest=!0,o.depthWrite=!1,o.needsUpdate=!0))}}_restoreMatSettings(e){for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.object,o=n.material;if(!o||!(o.id in this._matSettings))continue;if(!this._testInitialLayersWithInitialCameraLayers(i))continue;if(!this.isSupportedMaterial(o))continue;delete o.defines.USE_OIT_WEIGHTED;const r=this._matSettings[o.id];for(let e in r.properties)o[e]=r.properties[e];for(let e in r.defines)r.defines[e]?o.defines[e]=r.defines[e]:delete o.defines[e];o.needsUpdate=!0,delete this._matSettings[o.id]}}_renderOnlyDepth(e,t,n,i,o){const r={};for(let e=0,t=n.length;e<t;e++){const t=n[e],i=t.object,o=t.material;o&&o.id in r||this._testInitialLayersWithInitialCameraLayers(i)&&this.isSupportedMaterial(o)&&(r[o.id]={properties:{colorWrite:o.colorWrite}},o.colorWrite=!1,o.needsUpdate=!0)}t(n,i,o);for(let e=0,t=n.length;e<t;e++){const t=n[e],i=(t.object,t.material);if(!i||!(i.id in r))continue;const o=r[i.id];for(let e in o.properties)i[e]=o.properties[e];i.needsUpdate=!0,delete r[i.id]}}}Nl.prototype.isWebGLOITWeighted=!0;class Ol{constructor(e){this.resolution=e,this.texType=xe,this.mute=!1,this.method=Kt,this.oitRenderer=null}render(e,t,n,i,o){this.mute||this.oitRenderer&&this.oitRenderer.render(e,t,n,i,o)}setMethod(e,t){this.method!==e&&(this.oitRenderer&&this.oitRenderer.dispose(),this.oitRenderer=null,this.method=e,e!==Kt&&1===e&&(this.oitRenderer=new Nl(this.resolution,this.texType,t)))}isMethodCompatible(e,t){return e===Kt||!(1!==e||!t.isWebGL2)}dispose(){this.oitRenderer&&this.oitRenderer.dispose(),this.method=Kt}setSize(e,t){this.resolution.set(e,t),this.oitRenderer&&this.oitRenderer.setSize(e,t)}}Ol.prototype.isWebGLOITRenderer=!0;const Fl=16,Ul=16;function zl(e={}){this.isWebGLRenderer=!0;const n=void 0!==e.canvas?e.canvas:function(){const e=Tn("canvas");return e.style.display="block",e}(),i=void 0!==e.context?e.context:null,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;d=null!==i?i.getContextAttributes().alpha:void 0!==e.alpha&&e.alpha;let h=null,m=null;const v=[],A=[];this.domElement=n,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=It,this.physicallyCorrectLights=!1,this.unitsScaleFactor=1,this.toneMapping=q,this.toneMappingExposure=1,this.gtaoMap=null,this.gtaoMapEnabled=!1,this.compatSettings={useSpecEnvBlenderApprox:!0,saturateSpecEnvBlenderApprox:!1,gtaoDisableBkgFix:!1};const _=this;let x=!1,y=0,b=0,C=null,M=-1,S=null;const E=new ii,w=new ii;let T=null,I=n.width,R=n.height,L=1,P=null,B=null;const D=new ii(0,0,I,R),N=new ii(0,0,I,R);let O=!1;const F=new Cr;let U=!1,z=!1,V=null;const G=new zi,k=new yn,Q=new ci,W={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},H=new zi,j=new zi,Y=new ii,X=new zi;new hi;let K=!1;function Z(){return null===C?L:1}this.oitRenderer=new Ol(new yn(I,R));let J,$,ee,te,oe,re,ae,se,le,ce,ue,de,he,pe,fe,me,ge,ve,Ae,ye,be,Ce,Me,Se,Te=i;function Ie(e,t){for(let i=0;i<e.length;i++){const o=e[i],r=n.getContext(o,t);if(null!==r)return r}return null}try{const e={alpha:!0,depth:o,stencil:r,antialias:a,premultipliedAlpha:s,preserveDrawingBuffer:l,powerPreference:c,xrCompatible:!wl.checkSafari(),failIfMajorPerformanceCaveat:u};if("setAttribute"in n&&n.setAttribute("data-engine",`Verge3D ${t}`),n.addEventListener("webglcontextlost",Pe,!1),n.addEventListener("webglcontextrestored",De,!1),n.addEventListener("webglcontextcreationerror",Ne,!1),null===Te){const n=["webgl2","webgl","experimental-webgl"];if(!0===_.isWebGL1Renderer&&n.shift(),Te=Ie(n,e),null===Te)throw Ie(n)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.");const i="undefined"!=typeof WebGL2RenderingContext&&Te instanceof WebGL2RenderingContext;console.log("Verge3D "+t+" "+Ln()+" ("+(3483952072==fn(Yt)?"Trial":"License")+", "+(i?"WebGL 2.0":"WebGL 1.0")+")")}void 0===Te.getShaderPrecisionFormat&&(Te.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(e){throw console.error("v3d.WebGLRenderer: "+e.message),e}function Re(){J=new oa(Te),$=new Dr(Te,J,e),J.init($),Ce=new ml(Te,J,$),ee=new pl(Te,J,$),te=new sa(Te),oe=new Us,re=new fl(Te,J,ee,oe,$,Ce,te),ae=new Or(_),se=new ia(_),le=new Sr(Te,$),Me=new Pr(Te,J,le,$),ce=new ra(Te,le,te,Me),ue=new da(Te,ce,le,te),Ae=new ua(Te,$,re),me=new Nr(oe),de=new Fs(_,ae,se,J,$,Me,me),he=new Sl(_,oe),pe=new ks(oe),fe=new Xs(J,$),ve=new Lr(_,ae,se,ee,ue,d,s),ge=new hl(_,ue,$),Se=new El(Te,te,$,ee),ye=new Br(Te,J,te,$),be=new aa(Te,J,te,$),te.programs=de.programs,_.capabilities=$,_.extensions=J,_.properties=oe,_.renderLists=pe,_.shadowMap=ge,_.state=ee,_.info=te}Re();const Le=new Ml(_,Te);function Pe(e){e.preventDefault(),console.log("v3d.WebGLRenderer: Context Lost."),x=!0}function De(){console.log("v3d.WebGLRenderer: Context Restored."),x=!1;const e=te.autoReset,t=ge.enabled,n=ge.autoUpdate,i=ge.needsUpdate,o=ge.type;Re(),te.autoReset=e,ge.enabled=t,ge.autoUpdate=n,ge.needsUpdate=i,ge.type=o}function Ne(e){console.error("v3d.WebGLRenderer: A WebGL context could not be created. Reason: ",e.statusMessage)}function Oe(e){const t=e.target;t.removeEventListener("dispose",Oe),function(e){(function(e){const t=oe.get(e).programs;void 0!==t&&(t.forEach((function(e){de.releaseProgram(e)})),e.isShaderMaterial&&de.releaseShaderCache(e))})(e),oe.remove(e)}(t)}this.xr=Le,this.getContext=function(){return Te},this.getContextAttributes=function(){return Te.getContextAttributes()},this.forceContextLoss=function(){const e=J.get("WEBGL_lose_context");e&&e.loseContext()},this.forceContextRestore=function(){const e=J.get("WEBGL_lose_context");e&&e.restoreContext()},this.getTextureUtils=function(){return re},this.getPixelRatio=function(){return L},this.setPixelRatio=function(e){void 0!==e&&(L=e,this.setSize(I,R,!1))},this.getSize=function(e){return e.set(I,R)},this.setSize=function(e,t,i){Le.isPresenting?console.warn("v3d.WebGLRenderer: Can't change size while VR device is presenting."):(I=e,R=t,n.width=Math.floor(e*L),n.height=Math.floor(t*L),!1!==i&&(n.style.width=e+"px",n.style.height=t+"px"),this.setViewport(0,0,e,t),this.oitRenderer&&this.oitRenderer.setSize(e,t))},this.getDrawingBufferSize=function(e){return e.set(I*L,R*L).floor()},this.setDrawingBufferSize=function(e,t,i){I=e,R=t,L=i,n.width=Math.floor(e*i),n.height=Math.floor(t*i),this.setViewport(0,0,e,t)},this.getCurrentViewport=function(e){return e.copy(E)},this.getViewport=function(e){return e.copy(D)},this.setViewport=function(e,t,n,i){e.isVector4?D.set(e.x,e.y,e.z,e.w):D.set(e,t,n,i),ee.viewport(E.copy(D).multiplyScalar(L).floor())},this.getScissor=function(e){return e.copy(N)},this.setScissor=function(e,t,n,i){e.isVector4?N.set(e.x,e.y,e.z,e.w):N.set(e,t,n,i),ee.scissor(w.copy(N).multiplyScalar(L).floor())},this.getScissorTest=function(){return O},this.setScissorTest=function(e){ee.setScissorTest(O=e)},this.setOpaqueSort=function(e){P=e},this.setTransparentSort=function(e){B=e},this.getClearColor=function(e){return e.copy(ve.getClearColor())},this.setClearColor=function(){ve.setClearColor.apply(ve,arguments)},this.getClearAlpha=function(){return ve.getClearAlpha()},this.setClearAlpha=function(){ve.setClearAlpha.apply(ve,arguments)},this.clear=function(e=!0,t=!0,n=!0){let i=0;e&&(i|=16384),t&&(i|=256),n&&(i|=1024),Te.clear(i)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){n.removeEventListener("webglcontextlost",Pe,!1),n.removeEventListener("webglcontextrestored",De,!1),n.removeEventListener("webglcontextcreationerror",Ne,!1),this.disposeGTAO(),this.disposeOIT(),this.disposeInternalCaches(),Le.dispose(),Le.removeEventListener("sessionstart",Ue),Le.removeEventListener("sessionend",ze),V&&(V.dispose(),V=null),Ve.stop()},this.canUseGTAO=function(){return this.gtaoMap&&this.gtaoMapEnabled},this.disposeGTAO=function(){var e;null==(e=this.gtaoMap)||e.dispose(),this.gtaoMap=null},this.disposeOIT=function(){this.oitRenderer&&this.oitRenderer.dispose(),this.useOIT=!1},this.disposeInternalCaches=function(){pe.dispose(),fe.dispose(),oe.dispose(),ae.dispose(),se.dispose(),ue.dispose(),Me.dispose(),de.dispose(),Se.dispose(),ve.dispose(),le.dispose()},this.renderBufferDirect=function(e,t,n,i,o,r){null===t&&(t=W);const a=o.isMesh&&o.matrixWorld.determinant()<0,s=function(e,t,n,i,o){!0!==t.isScene&&(t=W);re.resetTextureUnits();const r=t.fog,a=i.isMeshStandardMaterial||i.isMeshNodeMaterial?t.environment:null,s=null===C?_.outputEncoding:!0===C.isXRRenderTarget?C.texture.encoding:It;if(i.envMapAutoAssign&&(i.isMeshStandardMaterial||i.isMeshPhysicalMaterial||i.isMeshNodeMaterial)){const e=m.state.envMapProbeArray.find((e=>{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(X.makeScale(1/t,1/t,1/t)),i.envMapParallaxMatrixInv.copy(e.matrixWorld).multiply(X.makeScale(t,t,t)),i.envMapParallaxType=e.parallaxType}}const c=(i.isMeshStandardMaterial||i.isMeshNodeMaterial?se:ae).get(i.envMap||a),u=!0===i.vertexColors&&!!n.attributes.color&&4===n.attributes.color.itemSize,d=!!i.normalMap&&!!n.attributes.tangent,h=!!n.morphAttributes.position,p=!!n.morphAttributes.normal,g=!!n.morphAttributes.color,v=i.toneMapped?_.toneMapping:q,A=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,x=void 0!==A?A.length:0,y=i.side===f,b=oe.get(i),w=m.state.lights;if(!0===U&&(!0===z||e!==S)){const t=e===S&&i.id===M;me.setState(i,e,t)}const T=Xe(o,i,m),P=i.isMeshNodeMaterial&&i.canUseGTAO()&&_.canUseGTAO();let B=!1,D=!1;if(i.version===b.__version)b.needsLights&&b.lightsStateVersion!==w.state.version||b.outputEncoding!==s||o.isInstancedMesh&&!1===b.instancing?B=!0:o.isInstancedMesh||!0!==b.instancing?o.isSkinnedMesh&&!1===b.skinning?B=!0:o.isSkinnedMesh||!0!==b.skinning?b.envMap!==c?(B=!0,D=!0):!0===i.fog&&b.fog!==r?B=!0:void 0===b.numClippingPlanes||b.numClippingPlanes===me.numPlanes&&b.numIntersection===me.numIntersection?(b.vertexAlphas!==u||b.vertexTangents!==d||b.morphTargets!==h||b.morphNormals!==p||b.morphColors!==g||b.toneMapping!==v||!0===$.isWebGL2&&b.morphTargetsCount!==x||b.planeReflProbe!==T||i.isMeshNormalMaterial&&b.flipSided!==y||b.useGTAO!==P)&&(B=!0):B=!0:B=!0:B=!0;else if(B=!0,b.__version=i.version,i.nodeRGBArr)for(let e=0;e<i.nodeRGB.length;e++){i.nodeRGB[e].toArray(i.nodeRGBArr,4*e)}let N=b.currentProgram;!0===B&&(N=He(i,t,o,m));let O=!1,F=!1,G=!1;const K=N.getUniforms(),Z=b.uniforms;ee.useProgram(N.program)&&(O=!0,F=!0,G=!0);i.id!==M&&(M=i.id,F=!0);D&&(F=!0);if(O||S!==e){if(K.setValue(Te,"projectionMatrix",e.projectionMatrix),$.logarithmicDepthBuffer&&K.setValue(Te,"logDepthBufFC",2/(Math.log(e.far+1)/Math.LN2)),S!==e&&(S=e,F=!0,G=!0),i.isShaderMaterial||i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshStandardMaterial||i.isMeshNodeMaterial||i.envMap){const t=K.map.cameraPosition;void 0!==t&&t.setValue(Te,Q.setFromMatrixPosition(e.matrixWorld))}(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isMeshNodeMaterial)&&K.setValue(Te,"isOrthographic",!0===e.isOrthographicCamera),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshBasicMaterial||i.isMeshStandardMaterial||i.isShaderMaterial||i.isMeshNodeMaterial||i.isShadowMaterial||o.isSkinnedMesh)&&K.setValue(Te,"viewMatrix",e.matrixWorldInverse),(i.isMeshPhongMaterial||i.isMeshToonMaterial||i.isMeshLambertMaterial||i.isMeshNodeMaterial||i.isMeshStandardMaterial||i.isMeshPhysicalMaterial||i.isShadowMaterial)&&K.setValue(Te,"invViewMatrix",e.matrixWorld)}if(o.isSkinnedMesh){K.setOptional(Te,o,"bindMatrix"),K.setOptional(Te,o,"bindMatrixInverse");const e=o.skeleton;e&&($.floatVertexTextures?(null===e.boneTexture&&e.computeBoneTexture(),K.setValue(Te,"boneTexture",e.boneTexture,re),K.setValue(Te,"boneTextureSize",e.boneTextureSize)):console.warn("v3d.WebGLRenderer: SkinnedMesh can only be used with WebGL 2. With WebGL 1 OES_texture_float and vertex textures support is required."))}const J=n.morphAttributes;(void 0!==J.position||void 0!==J.normal||void 0!==J.color&&!0===$.isWebGL2)&&Ae.update(o,n,i,N);(F||b.receiveShadow!==o.receiveShadow)&&(b.receiveShadow=o.receiveShadow,K.setValue(Te,"receiveShadow",o.receiveShadow));if(i.needsBoundingBox){const e=o.geometry;e&&(null===e.boundingBox&&e.computeBoundingBox(),K.setValue(Te,"boundingBoxMin",e.boundingBox.min),K.setValue(Te,"boundingBoxMax",e.boundingBox.max))}if(F){if(K.setValue(Te,"toneMappingExposure",_.toneMappingExposure),_.toneMapping==ne?(K.setValue(Te,"toneMappingBrightness",_.toneMappingBrightness),K.setValue(Te,"toneMappingContrast",_.toneMappingContrast),K.setValue(Te,"toneMappingMidTones",_.toneMappingMidTones),K.setValue(Te,"toneMappingPhysicalScale",_.toneMappingPhysicalScale),K.setValue(Te,"toneMappingChromaticAdaptation",_.toneMappingChromaticAdaptation),K.setValue(Te,"toneMappingWhiteColor",_.toneMappingWhiteColor),K.setValue(Te,"toneMappingColorDifferentiation",_.toneMappingColorDifferentiation),K.setValue(Te,"toneMappingExteriorDaylight",_.toneMappingExteriorDaylight)):_.toneMapping==ie&&(K.setValue(Te,"toneMappingResolution",k.set(I,R)),K.setValue(Te,"toneMappingWhiteBalance",_.toneMappingWhiteBalance),K.setValue(Te,"toneMappingHighlights",_.toneMappingHighlights),K.setValue(Te,"toneMappingMidTones",_.toneMappingMidTones),K.setValue(Te,"toneMappingShadows",_.toneMappingShadows),K.setValue(Te,"toneMappingSaturation",_.toneMappingSaturation),K.setValue(Te,"toneMappingPhysicalScale",_.toneMappingPhysicalScale),K.setValue(Te,"toneMappingAperture",_.toneMappingAperture),K.setValue(Te,"toneMappingShutter",_.toneMappingShutter),K.setValue(Te,"toneMappingISO",_.toneMappingISO),K.setValue(Te,"toneMappingVignetting",_.toneMappingVignetting)),b.needsLights&&(pe=G,(de=Z).ambientLightColor.needsUpdate=pe,de.lightProbe.needsUpdate=pe,de.directionalLights.needsUpdate=pe,de.directionalLightShadows.needsUpdate=pe,de.pointLights.needsUpdate=pe,de.pointLightShadows.needsUpdate=pe,de.spotLights.needsUpdate=pe,de.spotLightShadows.needsUpdate=pe,de.rectAreaLights.needsUpdate=pe,de.hemisphereLights.needsUpdate=pe,de.rectAreaLightShadows.needsUpdate=pe),r&&!0===i.fog&&he.refreshFogUniforms(Z,r),b.useGTAO){var te,le,ce,ue;const e=null!=(te=null==(le=C)?void 0:le.width)?te:I,t=null!=(ce=null==(ue=C)?void 0:ue.height)?ce:R;K.setValue(Te,"currResolution",k.set(e,t)),he.refreshGTAOUniforms(Z,_.gtaoMap)}if(he.refreshMaterialUniforms(Z,i,L,R,V),T&&he.refreshPlaneReflProbeUniforms(Z,T),i.isMeshNodeMaterial)for(const e in i.nodeTextures)K.setValue(Te,e,i.nodeTextures[e],re);i.isMeshLineMaterial&&K.setValue(Te,"resolution",k.set(I,R)),ms.upload(Te,je(b),Z,re)}var de,pe;i.isShaderMaterial&&!0===i.uniformsNeedUpdate&&(ms.upload(Te,je(b),Z,re),i.uniformsNeedUpdate=!1);i.isSpriteMaterial&&K.setValue(Te,"center",o.center);if(i.isMeshNodeMaterial){H.copy(o.matrixWorld).invert(),K.setValue(Te,"invModelMatrix",H),K.setValue(Te,"viewWidthHeight",k.set(E.z-E.x,E.w-E.y)),i.nodeTexCoordObject.forEach((function(e,t){(null===e?H:j.copy(e.matrixWorld).invert()).toArray(i.nodeTexCoordObjectArr,16*t)})),i.nodeTexCoordObjectArr&&K.setValue(Te,"nodeTexCoordObjectMatrices",i.nodeTexCoordObjectArr),K.setValue(Te,"objectIndex",o.objectIndex);const e=o.objectColor;K.setValue(Te,"objectColor",Y.set(e.r,e.g,e.b,o.objectAlpha)),K.setValue(Te,"objectRandom",fn(o.uuid)/Math.pow(2,32))}if(K.setValue(Te,"modelViewMatrix",o.modelViewMatrix),K.setValue(Te,"normalMatrix",o.normalMatrix),K.setValue(Te,"modelMatrix",o.matrixWorld),i.isShaderMaterial||i.isRawShaderMaterial){const e=i.uniformsGroups;for(let t=0,n=e.length;t<n;t++)if($.isWebGL2){const n=e[t];Se.update(n,N),Se.bind(n,N)}else console.warn("v3d.WebGLRenderer: Uniform Buffer Objects can only be used with WebGL 2.")}return N}(e,t,n,i,o);ee.setMaterial(i,a);let l=n.index,c=1;!0===i.wireframe&&(l=ce.getWireframeAttribute(n),c=2);const u=n.drawRange,d=n.attributes.position;let h=u.start*c,p=(u.start+u.count)*c;null!==r&&(h=Math.max(h,r.start*c),p=Math.min(p,(r.start+r.count)*c)),null!==l?(h=Math.max(h,0),p=Math.min(p,l.count)):null!=d&&(h=Math.max(h,0),p=Math.min(p,d.count));const g=p-h;if(g<0||g===1/0)return;let v;Me.setup(o,i,s,n,l);let A=ye;if(null!==l&&(v=le.get(l),A=be,A.setIndex(v)),o.isMesh)!0===i.wireframe?(ee.setLineWidth(i.wireframeLinewidth*Z()),A.setMode(1)):A.setMode(4);else if(o.isLine){let e=i.linewidth;void 0===e&&(e=1),ee.setLineWidth(e*Z()),o.isLineSegments?A.setMode(1):o.isLineLoop?A.setMode(2):A.setMode(3)}else o.isPoints?A.setMode(0):o.isSprite&&A.setMode(4);if(s.beginTimerQuery(Te,$.isWebGL2),i.depthPrepass&&i.transparent){const e=ee.buffers.depth.getTest(),t=ee.buffers.color.getMask();if(ee.buffers.depth.setTest(!0),ee.buffers.color.setMask(0),o.isInstancedMesh)A.renderInstances(h,g,o.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);A.renderInstances(h,g,t)}else A.render(h,g);ee.buffers.depth.setTest(e),ee.buffers.color.setMask(t)}if(o.isInstancedMesh)A.renderInstances(h,g,o.count);else if(n.isInstancedBufferGeometry){const e=void 0!==n._maxInstanceCount?n._maxInstanceCount:1/0,t=Math.min(n.instanceCount,e);A.renderInstances(h,g,t)}else A.render(h,g);s.endTimerQuery(Te,$.isWebGL2)},this._compilePrepareRenderState=function(e,t,n){n.init(),e.traverse((e=>{e.isLight?(n.pushLight(e),e.castShadow&&n.pushShadow(e)):e.isCubeReflectionProbe?n.pushEnvMapProbe(e):e.isPlaneReflectionProbe&&n.pushPlaneReflProbe(e)})),n.setupLights(_.physicallyCorrectLights),n.sortEnvMapProbes();let i=null;return 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=fe.get(e,A.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;r<o.length;r++){const a=o[r];a.uuid in i==!1&&(He(a,e,t,n),i[a.uuid]=!0)}else o.uuid in i==!1&&(He(o,e,t,n),i[o.uuid]=!0)})),this.gtaoMapEnabled=!1},this.compileAsync=function(e,t,n){const i=new Ys(J,$);this._compilePrepareRenderState(e,t,i);const o=[];if(e.traverse((function(t){if(t.material){(Array.isArray(t.material)?t.material:[t.material]).forEach((function(n){o.push({scene:e,obj:t,mat:n})}))}})),0===o.length)n(1);else{const e=J.get("KHR_parallel_shader_compile"),t=(null===e?1:2)*o.length;let r=0,a=0;const s={};if(zn(o,(function(o,l,c){_.gtaoMapEnabled=!0;var u=He(o.mat,o.scene,o.obj,i);if(_.gtaoMapEnabled=!1,e){const e=u.id;e in s||(s[e]={program:u,weight:0}),s[e].weight++}n&&(r++,n((r+a)/t))}),Fl),e){const i=setInterval((function(){let l=0;for(let t in s){const n=s[t];(void 0===n.program.program||Te.getProgramParameter(n.program.program,e.COMPLETION_STATUS_KHR))&&(l+=n.weight)}a=Math.max(a,l),n&&n((r+a)/t),a===o.length&&clearInterval(i)}),Ul)}}};let Fe=null;function Ue(){Ve.stop()}function ze(){Ve.start()}const Ve=new Mr;function Ge(e,t,n,i){e.isAnnotationControl&&e.update(t);let o=!1;if(e.visible&&(o=e.layers.test(t.layers),o))if(e.isGroup)n=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)m.pushLight(e),e.castShadow&&m.pushShadow(e);else if(e.isCubeReflectionProbe)m.pushEnvMapProbe(e);else if(e.isPlaneReflectionProbe)m.pushPlaneReflProbe(e);else if(e.isSprite){if(!e.frustumCulled||F.intersectsSprite(e)){i&&Q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(G);const t=ue.update(e),o=e.material;h.push(e,t,o,n,Q.z,null)}}else if(e.isImmediateRenderObject)i&&Q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(G),h.push(e,null,e.material,n,Q.z,null);else if((e.isMesh||e.isLine||e.isPoints)&&(e.isSkinnedMesh&&e.skeleton.frame!==te.render.frame&&(e.skeleton.update(),e.skeleton.frame=te.render.frame),!e.frustumCulled||F.intersectsObject(e))){i&&Q.setFromMatrixPosition(e.matrixWorld).applyMatrix4(G);const t=ue.update(e),o=e.material;if(Array.isArray(o)){const i=t.groups;for(let r=0,a=i.length;r<a;r++){const a=i[r],s=o[a.materialIndex];s&&s.visible&&h.push(e,t,s,n,Q.z,a)}}else o.visible&&h.push(e,t,o,n,Q.z,null)}if(e.disableChildRendering)return;const r=e.children;for(let e=0,a=r.length;e<a;e++){const a=r[e];!o&&a.isMesh&&a.isMaterialGeneratedMesh||Ge(a,t,n,i)}}function ke(e,t,n,i){const o=e.opaque,r=e.transmissive,s=e.transparent;m.setupLightsView(n),r.length>0&&function(e,t,n){const i=$.isWebGL2;null===V&&(V=new oi(1,1,{generateMipmaps:!0,type:J.has("EXT_color_buffer_half_float")?we:xe,minFilter:_e,samples:i&&!0===a?4:0}));_.getDrawingBufferSize(k),i?V.setSize(k.x,k.y):V.setSize(dn(k.x),dn(k.y));const o=_.getRenderTarget();_.setRenderTarget(V),_.clear();const r=_.toneMapping;_.toneMapping=q,Qe(e,t,n),_.toneMapping=r,re.updateMultisampleRenderTarget(V),re.updateRenderTargetMipmap(V),_.setRenderTarget(o)}(o,t,n),i&&ee.viewport(E.copy(i)),o.length>0&&Qe(o,t,n),r.length>0&&Qe(r,t,n),s.length>0&&(K&&_.oitRenderer.method!==Kt?_.oitRenderer.render(_,Qe,s,t,n):Qe(s,t,n)),ee.buffers.depth.setTest(!0),ee.buffers.depth.setMask(!0),ee.buffers.color.setMask(!0),ee.setPolygonOffset(!1)}function Qe(e,t,n){const i=!0===t.isScene?t.overrideMaterial:null;for(let o=0,r=e.length;o<r;o++){const r=e[o],a=r.object,s=r.geometry,l=null===i?r.material:i,c=r.group;a.layers.test(n.layers)&&We(a,t,n,s,l,c)}}function We(e,t,n,i,o,r){e.onBeforeRender(_,t,n,i,o,r),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),o.onBeforeRender(_,t,n,i,e,r),!0===o.transparent&&o.side===g?(o.side=f,o.needsUpdate=!0,_.renderBufferDirect(n,t,i,o,e,r),o.side=p,o.needsUpdate=!0,_.renderBufferDirect(n,t,i,o,e,r),o.side=g):_.renderBufferDirect(n,t,i,o,e,r),e.onAfterRender(_,t,n,i,o,r)}function He(e,t,n,i){!0!==t.isScene&&(t=W);const o=oe.get(e),r=i.state.lights,a=i.state.shadowsArray,s=r.state.version,l=Xe(n,e,i);o.planeReflProbe=l;const c=de.getParameters(e,r.state,a,t,n,l),u=de.getProgramCacheKey(c);let d=o.programs;o.environment=e.isMeshStandardMaterial||e.isMeshNodeMaterial?t.environment:null,o.fog=t.fog,o.envMap=(e.isMeshStandardMaterial||e.isMeshNodeMaterial?se:ae).get(e.envMap||o.environment),o.useGTAO=e.isMeshNodeMaterial&&e.canUseGTAO()&&_.canUseGTAO(),void 0===d&&(e.addEventListener("dispose",Oe),d=new Map,o.programs=d);let h=d.get(u);if(void 0!==h){if(o.currentProgram===h&&o.lightsStateVersion===s)return Ye(e,c),h}else c.uniforms=de.getUniforms(e),e.onBuild(n,c,_),e.onBeforeCompile(c,_),h=de.acquireProgram(c,u),d.set(u,h),o.uniforms=c.uniforms;const p=o.uniforms;return(e.isShaderMaterial||e.isRawShaderMaterial)&&!0!==e.clipping||e.defines.WORLD_NODES||(p.clippingPlanes=me.uniform),Ye(e,c),o.needsLights=function(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&!0===e.lights||e.isMeshNodeMaterial}(e),o.lightsStateVersion=s,o.needsLights&&(p.ambientLightColor.value=r.state.ambient,p.lightProbe.value=r.state.probe,p.directionalLights.value=r.state.directional,p.directionalLightShadows.value=r.state.directionalShadow,p.spotLights.value=r.state.spot,p.spotLightShadows.value=r.state.spotShadow,p.rectAreaLights.value=r.state.rectArea,p.ltc_1.value=r.state.rectAreaLTC1,p.ltc_2.value=r.state.rectAreaLTC2,p.pointLights.value=r.state.point,p.pointLightShadows.value=r.state.pointShadow,p.hemisphereLights.value=r.state.hemi,p.directionalShadowMap.value=r.state.directionalShadowMap,p.directionalShadowMatrix.value=r.state.directionalShadowMatrix,p.spotShadowMap.value=r.state.spotShadowMap,p.spotLightMatrix.value=r.state.spotLightMatrix,p.spotLightMap.value=r.state.spotLightMap,p.pointShadowMap.value=r.state.pointShadowMap,p.pointShadowMatrix.value=r.state.pointShadowMatrix,p.rectAreaLightShadows.value=r.state.rectAreaShadow,p.rectAreaShadowMap.value=r.state.rectAreaShadowMap,p.rectAreaShadowMatrix.value=r.state.rectAreaShadowMatrix),e.nodeValue&&(p.nodeValue.value=e.nodeValue),e.nodeRGBArr&&(p.nodeRGB.value=e.nodeRGBArr),o.currentProgram=h,o.uniformsList=null,h}function je(e){if(null===e.uniformsList){const t=e.currentProgram.getUniforms();e.uniformsList=ms.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function Ye(e,t){const n=oe.get(e);n.outputEncoding=t.outputEncoding,n.instancing=t.instancing,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping,n.flipSided=t.flipSided}function Xe(e,t,n){return(t.isMeshStandardMaterial||t.isMeshPhysicalMaterial||t.isMeshNodeMaterial)&&n.state.planeReflProbeArray.find((t=>t.intersectsMesh(e)))||null}Ve.setAnimationLoop((function(e){Fe&&Fe(e)})),"undefined"!=typeof self&&Ve.setContext(self),this.setAnimationLoop=function(e){Fe=e,Le.setAnimationLoop(e),null===e?Ve.stop():Ve.start()},Le.addEventListener("sessionstart",Ue),Le.addEventListener("sessionend",ze),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===x)return;!0===e.matrixWorldAutoUpdate&&e.updateMatrixWorld(),null===t.parent&&!0===t.matrixWorldAutoUpdate&&t.updateMatrixWorld(),!0===Le.enabled&&!0===Le.isPresenting&&(!0===Le.cameraAutoUpdate&&Le.updateCamera(t),t=Le.getCamera()),!0===e.isScene&&e.onBeforeRender(_,e,t,C),m=fe.get(e,A.length),m.init(),A.push(m),G.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),F.setFromProjectionMatrix(G),z=this.localClippingEnabled,U=me.init(this.clippingPlanes,z,t),h=pe.get(e,v.length),h.init(),v.push(h),Ge(e,t,0,_.sortObjects),h.finish(),!0===_.sortObjects&&h.sort(P,B),!0===U&&me.beginShadows();const n=m.state.shadowsArray;if(ge.render(n,e,t),!0===U&&me.endShadows(),!0===this.info.autoReset&&this.info.reset(),ve.render(h,e),m.setupLights(_.physicallyCorrectLights),m.sortEnvMapProbes(),t.isArrayCamera){const n=t.cameras;for(let t=0,i=n.length;t<i;t++){const i=n[t];ke(h,e,i,i.viewport)}}else ke(h,e,t);null!==C&&(re.updateMultisampleRenderTarget(C),re.updateRenderTargetMipmap(C)),!0===e.isScene&&e.onAfterRender(_,e,t),Me.resetDefaultState(),M=-1,S=null,A.pop(),m=A.length>0?A[A.length-1]:null,v.pop(),h=v.length>0?v[v.length-1]:null},this.getActiveCubeFace=function(){return y},this.getActiveMipmapLevel=function(){return b},this.getRenderTarget=function(){return C},this.setRenderTargetTextures=function(e,t,n){oe.get(e.texture).__webglTexture=t,oe.get(e.depthTexture).__webglTexture=n;const i=oe.get(e);i.__hasExternalTextures=!0,i.__hasExternalTextures&&(i.__autoAllocateDepthBuffer=void 0===n,i.__autoAllocateDepthBuffer||!0===J.has("WEBGL_multisampled_render_to_texture")&&(console.warn("v3d.WebGLRenderer: Render-to-texture extension was disabled because an external texture was provided"),i.__useRenderToTexture=!1))},this.setRenderTargetFramebuffer=function(e,t){const n=oe.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=void 0===t},this.setRenderTarget=function(e,t=0,n=0){C=e,y=t,b=n;let i=!0,o=null,r=!1,a=!1;if(e){const n=oe.get(e);void 0!==n.__useDefaultFramebuffer?(ee.bindFramebuffer(36160,null),i=!1):void 0===n.__webglFramebuffer?re.setupRenderTarget(e):n.__hasExternalTextures&&re.rebindTextures(e,oe.get(e.texture).__webglTexture,oe.get(e.depthTexture).__webglTexture);const s=e.texture;(s.isData3DTexture||s.isDataArrayTexture||s.isCompressedArrayTexture)&&(a=!0);const l=oe.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(o=l[t],r=!0):o=$.isWebGL2&&e.samples>0&&!1===re.useMultisampledRTT(e)?oe.get(e).__webglMultisampledFramebuffer:l,E.copy(e.viewport),w.copy(e.scissor),T=e.scissorTest}else E.copy(D).multiplyScalar(L).floor(),w.copy(N).multiplyScalar(L).floor(),T=O;if(ee.bindFramebuffer(36160,o)&&$.drawBuffers&&i&&ee.drawBuffers(e,o),ee.viewport(E),ee.scissor(w),ee.setScissorTest(T),r){const i=oe.get(e.texture);Te.framebufferTexture2D(36160,36064,34069+t,i.__webglTexture,n)}else if(a){const i=oe.get(e.texture),o=t||0;Te.framebufferTextureLayer(36160,36064,i.__webglTexture,n||0,o)}M=-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=oe.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&void 0!==a&&(s=s[a]),s){ee.bindFramebuffer(36160,s);try{const a=e.texture,s=a.format,l=a.type;if(s!==Be&&Ce.convert(s)!==Te.getParameter(35739))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");const c=l===we&&(J.has("EXT_color_buffer_half_float")||$.isWebGL2&&J.has("EXT_color_buffer_float"));if(!(l===xe||Ce.convert(l)===Te.getParameter(35738)||l===Ee&&($.isWebGL2||J.has("OES_texture_float")||J.has("WEBGL_color_buffer_float"))||c))return void console.error("v3d.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");t>=0&&t<=e.width-i&&n>=0&&n<=e.height-o&&Te.readPixels(t,n,i,o,Ce.convert(s),Ce.convert(l),r)}finally{const e=null!==C?oe.get(C).__webglFramebuffer:null;ee.bindFramebuffer(36160,e)}}},this.copyFramebufferToTexture=function(e,t,n=0){const i=Math.pow(2,-n),o=Math.floor(t.image.width*i),r=Math.floor(t.image.height*i);re.setTexture2D(t,0),Te.copyTexSubImage2D(3553,n,0,0,e.x,e.y,o,r),ee.unbindTexture()},this.copyTextureToTexture=function(e,t,n,i=0){const o=t.image.width,r=t.image.height,a=Ce.convert(n.format),s=Ce.convert(n.type);re.setTexture2D(n,0),Te.pixelStorei(37440,n.flipY),Te.pixelStorei(37441,n.premultiplyAlpha),Te.pixelStorei(3317,n.unpackAlignment),t.isDataTexture?Te.texSubImage2D(3553,i,e.x,e.y,o,r,a,s,t.image.data):t.isCompressedTexture?Te.compressedTexSubImage2D(3553,i,e.x,e.y,t.mipmaps[0].width,t.mipmaps[0].height,a,t.mipmaps[0].data):Te.texSubImage2D(3553,i,e.x,e.y,a,s,t.image),0===i&&n.generateMipmaps&&Te.generateMipmap(3553),ee.unbindTexture()},this.copyTextureToTexture3D=function(e,t,n,i,o=0){if(_.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=Ce.convert(i.format),c=Ce.convert(i.type);let u;if(i.isData3DTexture)re.setTexture3D(i,0),u=32879;else{if(!i.isDataArrayTexture)return void console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: only supports v3d.DataTexture3D and v3d.DataTexture2DArray.");re.setTexture2DArray(i,0),u=35866}Te.pixelStorei(37440,i.flipY),Te.pixelStorei(37441,i.premultiplyAlpha),Te.pixelStorei(3317,i.unpackAlignment);const d=Te.getParameter(3314),h=Te.getParameter(32878),p=Te.getParameter(3316),f=Te.getParameter(3315),m=Te.getParameter(32877),g=n.isCompressedTexture?n.mipmaps[0]:n.image;Te.pixelStorei(3314,g.width),Te.pixelStorei(32878,g.height),Te.pixelStorei(3316,e.min.x),Te.pixelStorei(3315,e.min.y),Te.pixelStorei(32877,e.min.z),n.isDataTexture||n.isData3DTexture?Te.texSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,c,g.data):n.isCompressedArrayTexture?(console.warn("v3d.WebGLRenderer.copyTextureToTexture3D: untested support for compressed srcTexture."),Te.compressedTexSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,g.data)):Te.texSubImage3D(u,o,t.x,t.y,t.z,r,a,s,l,c,g),Te.pixelStorei(3314,d),Te.pixelStorei(32878,h),Te.pixelStorei(3316,p),Te.pixelStorei(3315,f),Te.pixelStorei(32877,m),0===o&&i.generateMipmaps&&Te.generateMipmap(u),ee.unbindTexture()},this.initTexture=function(e){e.isCubeTexture?re.setTextureCube(e,0):e.isData3DTexture?re.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?re.setTexture2DArray(e,0):re.setTexture2D(e,0),ee.unbindTexture()},this.resetState=function(){y=0,b=0,C=null,ee.reset(),Me.reset()},"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this})),this.updateGeometry=function(e){return ue.update(e)},this.setOIT=function(e,t){this.oitRenderer.setSize(I,R),this.oitRenderer.texType=null!==Ce.convert(we)?we:xe;let n=t||(!0===a?4:0);this.oitRenderer.isMethodCompatible(e,$)?this.oitRenderer.setMethod(e,n):console.log("v3d.WebGLRenderer: the OIT method is not compatible.")},this.getOIT=function(){return this.oitRenderer.method},Object.defineProperty(this,"useOIT",{get:function(){return K},set:function(e){this.setTransparentSort(e?function(){}:null),K=e}})}class Vl extends zl{}Vl.prototype.isWebGL1Renderer=!0;class Gl{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new qn(e),this.density=t}clone(){return new Gl(this.color,this.density)}toJSON(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}}class kl{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new qn(e),this.near=t,this.far=n}clone(){return new kl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}}class Ql{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Qt,this.updateRange={offset:0,count:-1},this.version=0,this.uuid=tn()}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;i<o;i++)this.array[e+i]=t.array[n+i];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=tn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return void 0===e.arrayBuffers&&(e.arrayBuffers={}),void 0===this.array.buffer._uuid&&(this.array.buffer._uuid=tn()),void 0===e.arrayBuffers[this.array.buffer._uuid]&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Wl=new ci;class Hl{constructor(e,t,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wl.fromBufferAttribute(this,t),Wl.applyMatrix4(e),this.setXYZ(t,Wl.x,Wl.y,Wl.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wl.fromBufferAttribute(this,t),Wl.applyNormalMatrix(e),this.setXYZ(t,Wl.x,Wl.y,Wl.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wl.fromBufferAttribute(this,t),Wl.transformDirection(e),this.setXYZ(t,Wl.x,Wl.y,Wl.z);return this}setX(e,t){return this.normalized&&(t=pn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=pn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=pn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=pn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=hn(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=hn(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=hn(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=hn(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,i){return e=e*this.data.stride+this.offset,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array),i=pn(i,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this}setXYZW(e,t,n,i,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=pn(t,this.array),n=pn(n,this.array),i=pn(i,this.array),o=pn(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=i,this.data.array[e+3]=o,this}clone(e){if(void 0===e){console.log("v3d.InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return new To(new this.array.constructor(e),this.itemSize,this.normalized)}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Hl(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(void 0===e){console.log("v3d.InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let t=0;t<this.count;t++){const n=t*this.data.stride+this.offset;for(let t=0;t<this.itemSize;t++)e.push(this.data.array[n+t])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}return void 0===e.interleavedBuffers&&(e.interleavedBuffers={}),void 0===e.interleavedBuffers[this.data.uuid]&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class jl extends Mo{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new qn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Yl;const Xl=new ci,Kl=new ci,ql=new ci,Zl=new yn,Jl=new yn,$l=new zi,ec=new ci,tc=new ci,nc=new ci,ic=new yn,oc=new yn,rc=new yn;class ac extends uo{constructor(e){if(super(),this.isSprite=!0,this.type="Sprite",void 0===Yl){Yl=new zo;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),t=new Ql(e,5);Yl.setIndex([0,1,2,0,2,3]),Yl.setAttribute("position",new Hl(t,3,0,!1)),Yl.setAttribute("uv",new Hl(t,2,3,!1))}this.geometry=Yl,this.material=void 0!==e?e:new jl,this.center=new yn(.5,.5)}raycast(e,t){null===e.camera&&console.error('v3d.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Kl.setFromMatrixScale(this.matrixWorld),$l.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ql.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&Kl.multiplyScalar(-ql.z);const n=this.material.rotation;let i,o;0!==n&&(o=Math.cos(n),i=Math.sin(n));const r=this.center;sc(ec.set(-.5,-.5,0),ql,r,Kl,i,o),sc(tc.set(.5,-.5,0),ql,r,Kl,i,o),sc(nc.set(.5,.5,0),ql,r,Kl,i,o),ic.set(0,0),oc.set(1,0),rc.set(1,1);let a=e.ray.intersectTriangle(ec,tc,nc,!1,Xl);if(null===a&&(sc(tc.set(-.5,.5,0),ql,r,Kl,i,o),oc.set(0,1),a=e.ray.intersectTriangle(ec,nc,tc,!1,Xl),null===a))return;const s=e.ray.origin.distanceTo(Xl);s<e.near||s>e.far||t.push({distance:s,point:Xl.clone(),uv:bo.getUV(Xl,ec,tc,nc,ic,oc,rc,new yn),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function sc(e,t,n,i,o,r){Zl.subVectors(e,n).addScalar(.5).multiply(i),void 0!==o?(Jl.x=r*Zl.x-o*Zl.y,Jl.y=o*Zl.x+r*Zl.y):Jl.copy(Zl),e.copy(t),e.x+=Jl.x,e.y+=Jl.y,e.applyMatrix4($l)}const lc=new ci,cc=new ci;class uc extends uo{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;e<n;e++){const n=t[e];this.addLevel(n.object.clone(),n.distance,n.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const i=this.levels;let o;for(o=0;o<i.length&&!(t<i[o].distance);o++);return i.splice(o,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,i;for(n=1,i=t.length;n<i;n++){let i=t[n].distance;if(t[n].object.visible&&(i-=i*t[n].hysteresis),e<i)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){lc.setFromMatrixPosition(this.matrixWorld);const n=e.ray.origin.distanceTo(lc);this.getObjectForDistance(n).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){lc.setFromMatrixPosition(e.matrixWorld),cc.setFromMatrixPosition(this.matrixWorld);const n=lc.distanceTo(cc)/e.zoom;let i,o;for(t[0].object.visible=!0,i=1,o=t.length;i<o;i++){let e=t[i].distance;if(t[i].object.visible&&(e-=e*t[i].hysteresis),!(n>=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;i<o;i++)t[i].object.visible=!1}}toJSON(e){const t=super.toJSON(e);!1===this.autoUpdate&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let e=0,i=n.length;e<i;e++){const i=n[e];t.object.levels.push({object:i.object.uuid,distance:i.distance,hysteresis:i.hysteresis})}return t}}const dc=new ci,hc=new ii,pc=new ii,fc=new ci,mc=new zi;class gc extends ir{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode="attached",this.bindMatrix=new zi,this.bindMatrixInverse=new zi,this.normalizeSkinWeights()}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,this}bind(e,t){this.skeleton=e,void 0===t&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new ii,t=this.geometry.attributes.skinWeight;for(let n=0,i=t.count;n<i;n++){e.fromBufferAttribute(t,n);const i=1/e.manhattanLength();i!==1/0?e.multiplyScalar(i):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),"attached"===this.bindMode?this.bindMatrixInverse.copy(this.matrixWorld).invert():"detached"===this.bindMode?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("v3d.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}boneTransform(e,t){const n=this.skeleton,i=this.geometry;hc.fromBufferAttribute(i.attributes.skinIndex,e),pc.fromBufferAttribute(i.attributes.skinWeight,e),dc.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let e=0;e<4;e++){const i=pc.getComponent(e);if(0!==i){const o=hc.getComponent(e);mc.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),t.addScaledVector(fc.copy(dc).applyMatrix4(mc),i)}}return t.applyMatrix4(this.bindMatrixInverse)}}class vc extends uo{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ac extends ni{constructor(e=null,t=1,n=1,i,o,r,a,s,l=fe,c=fe,u,d){super(null,r,a,s,l,c,i,o,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const _c=new zi,xc=new zi;class yc{constructor(e=[],t=[]){this.uuid=tn(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.boneTexture=null,this.boneTextureSize=0,this.frame=-1,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(16*e.length),0===t.length)this.calculateInverses();else if(e.length!==t.length){console.warn("v3d.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let e=0,t=this.bones.length;e<t;e++)this.boneInverses.push(new zi)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const t=new zi;this.bones[e]&&t.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(t)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&t.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const t=this.bones[e];t&&(t.parent&&t.parent.isBone?(t.matrix.copy(t.parent.matrixWorld).invert(),t.matrix.multiply(t.matrixWorld)):t.matrix.copy(t.matrixWorld),t.matrix.decompose(t.position,t.quaternion,t.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let i=0,o=e.length;i<o;i++){const o=e[i]?e[i].matrixWorld:xc;_c.multiplyMatrices(o,t[i]),_c.toArray(n,16*i)}null!==i&&(i.needsUpdate=!0)}clone(){return new yc(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(4*this.bones.length);e=un(e),e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new Ac(t,e,e,Be,Ee);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this.boneTextureSize=e,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const n=this.bones[t];if(n.name===e)return n}}dispose(){null!==this.boneTexture&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,i=e.bones.length;n<i;n++){const i=e.bones[n];let o=t[i];void 0===o&&(console.warn("v3d.Skeleton: No bone found with UUID:",i),o=new vc),this.bones.push(o),this.boneInverses.push((new zi).fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.5,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let i=0,o=t.length;i<o;i++){const o=t[i];e.bones.push(o.uuid);const r=n[i];e.boneInverses.push(r.toArray())}return e}}class bc extends To{constructor(e,t,n,i=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const Cc=new zi,Mc=new zi,Sc=[],Ec=new zi,wc=new ir;class Tc extends ir{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new bc(new Float32Array(16*n),16),this.instanceColor=null,this.count=n,this.frustumCulled=!1;for(let e=0;e<n;e++)this.setMatrixAt(e,Ec)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),null!==e.instanceColor&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,this}getColorAt(e,t){t.fromArray(this.instanceColor.array,3*e)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,16*e)}raycast(e,t){const n=this.matrixWorld,i=this.count;if(wc.geometry=this.geometry,wc.material=this.material,void 0!==wc.material)for(let o=0;o<i;o++){this.getMatrixAt(o,Cc),Mc.multiplyMatrices(n,Cc),wc.matrixWorld=Mc,wc.raycast(e,Sc);for(let e=0,n=Sc.length;e<n;e++){const n=Sc[e];n.instanceId=o,n.object=this,t.push(n)}Sc.length=0}}setColorAt(e,t){null===this.instanceColor&&(this.instanceColor=new bc(new Float32Array(3*this.instanceMatrix.count),3)),t.toArray(this.instanceColor.array,3*e)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,16*e)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"})}}class Ic extends Mo{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new qn(16777215),this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Rc=new ci,Lc=new ci,Pc=new zi,Bc=new Ui,Dc=new Ri;class Nc extends uo{constructor(e=new zo,t=new Ic){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[0];for(let e=1,i=t.count;e<i;e++)Rc.fromBufferAttribute(t,e-1),Lc.fromBufferAttribute(t,e),n[e]=n[e-1],n[e]+=Rc.distanceTo(Lc);e.setAttribute("lineDistance",new Lo(n,1))}else console.warn("v3d.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Line.threshold,r=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Dc.copy(n.boundingSphere),Dc.applyMatrix4(i),Dc.radius+=o,!1===e.ray.intersectsSphere(Dc))return;Pc.copy(i).invert(),Bc.copy(e.ray).applyMatrix4(Pc);const a=o/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=new ci,c=new ci,u=new ci,d=new ci,h=this.isLineSegments?2:1,p=n.index,f=n.attributes.position;if(null!==p){for(let n=Math.max(0,r.start),i=Math.min(p.count,r.start+r.count)-1;n<i;n+=h){const i=p.getX(n),o=p.getX(n+1);l.fromBufferAttribute(f,i),c.fromBufferAttribute(f,o);if(Bc.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const r=e.ray.origin.distanceTo(d);r<e.near||r>e.far||t.push({distance:r,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(f.count,r.start+r.count)-1;n<i;n+=h){l.fromBufferAttribute(f,n),c.fromBufferAttribute(f,n+1);if(Bc.distanceSqToSegment(l,c,d,u)>s)continue;d.applyMatrix4(this.matrixWorld);const i=e.ray.origin.distanceTo(d);i<e.near||i>e.far||t.push({distance:i,point:u.clone().applyMatrix4(this.matrixWorld),index:n,face:null,faceIndex:null,object:this})}}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}const Oc=new ci,Fc=new ci;class Uc extends Nc{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,n=[];for(let e=0,i=t.count;e<i;e+=2)Oc.fromBufferAttribute(t,e),Fc.fromBufferAttribute(t,e+1),n[e]=0===e?0:n[e-1],n[e+1]=n[e]+Oc.distanceTo(Fc);e.setAttribute("lineDistance",new Lo(n,1))}else console.warn("v3d.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zc extends Nc{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Vc extends Mo{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new qn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Gc=new zi,kc=new Ui,Qc=new Ri,Wc=new ci;class Hc extends uo{constructor(e=new zo,t=new Vc){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,i=this.matrixWorld,o=e.params.Points.threshold,r=n.drawRange;if(null===n.boundingSphere&&n.computeBoundingSphere(),Qc.copy(n.boundingSphere),Qc.applyMatrix4(i),Qc.radius+=o,!1===e.ray.intersectsSphere(Qc))return;Gc.copy(i).invert(),kc.copy(e.ray).applyMatrix4(Gc);const a=o/((this.scale.x+this.scale.y+this.scale.z)/3),s=a*a,l=n.index,c=n.attributes.position;if(null!==l){for(let n=Math.max(0,r.start),o=Math.min(l.count,r.start+r.count);n<o;n++){const o=l.getX(n);Wc.fromBufferAttribute(c,o),jc(Wc,o,s,i,e,t,this)}}else{for(let n=Math.max(0,r.start),o=Math.min(c.count,r.start+r.count);n<o;n++)Wc.fromBufferAttribute(c,n),jc(Wc,n,s,i,e,t,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,t=Object.keys(e);if(t.length>0){const n=e[t[0]];if(void 0!==n){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=n.length;e<t;e++){const t=n[e].name||String(e);this.morphTargetInfluences.push(0),this.morphTargetDictionary[t]=e}}}}}function jc(e,t,n,i,o,r,a){const s=kc.distanceSqToPoint(e);if(s<n){const n=new ci;kc.closestPointToPoint(e,n),n.applyMatrix4(i);const l=o.ray.origin.distanceTo(n);if(l<o.near||l>o.far)return;r.push({distance:l,distanceToRay:Math.sqrt(s),point:n,index:t,face:null,object:a})}}class Yc extends ni{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.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Xc{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("v3d.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,i=this.getPoint(0),o=0;t.push(0);for(let r=1;r<=e;r++)n=this.getPoint(r/e),o+=n.distanceTo(i),t.push(o),i=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const n=this.getLengths();let i=0;const o=n.length;let r;r=t||e*n[o-1];let a,s=0,l=o-1;for(;s<=l;)if(i=Math.floor(s+(l-s)/2),a=n[i]-r,a<0)s=i+1;else{if(!(a>0)){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 yn:new ci);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 ci,i=[],o=[],r=[],a=new ci,s=new zi;for(let t=0;t<=e;t++){const n=t/e;i[t]=this.getTangentAt(n,new ci)}o[0]=new ci,r[0]=new ci;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(nn(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(nn(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 Kc extends Xc{constructor(e=0,t=0,n=1,i=1,o=0,r=2*Math.PI,a=!1,s=0){super(),this.isEllipseCurve=!0,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 yn,i=2*Math.PI;let o=this.aEndAngle-this.aStartAngle;const r=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=i;for(;o>i;)o-=i;o<Number.EPSILON&&(o=r?0:i),!0!==this.aClockwise||r||(o===i?o=-i:o-=i);const a=this.aStartAngle+e*o;let s=this.aX+this.xRadius*Math.cos(a),l=this.aY+this.yRadius*Math.sin(a);if(0!==this.aRotation){const e=Math.cos(this.aRotation),t=Math.sin(this.aRotation),n=s-this.aX,i=l-this.aY;s=n*e-i*t+this.aX,l=n*t+i*e+this.aY}return n.set(s,l)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class qc extends Kc{constructor(e,t,n,i,o,r){super(e,t,n,n,i,o,r),this.isArcCurve=!0,this.type="ArcCurve"}}function Zc(){let e=0,t=0,n=0,i=0;function o(o,r,a,s){e=o,t=a,n=-3*o+3*r-2*a-s,i=2*o-2*r+a+s}return{initCatmullRom:function(e,t,n,i,r){o(t,n,r*(n-e),r*(i-t))},initNonuniformCatmullRom:function(e,t,n,i,r,a,s){let l=(t-e)/r-(n-e)/(r+a)+(n-t)/a,c=(n-t)/a-(i-t)/(a+s)+(i-n)/s;l*=a,c*=a,o(t,n,l,c)},calc:function(o){const r=o*o;return e+t*o+n*r+i*(r*o)}}}const Jc=new ci,$c=new Zc,eu=new Zc,tu=new Zc;class nu extends Xc{constructor(e=[],t=!1,n="centripetal",i=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=i}getPoint(e,t=new ci){const n=t,i=this.points,o=i.length,r=(o-(this.closed?0:1))*e;let a,s,l=Math.floor(r),c=r-l;this.closed?l+=l>0?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]:(Jc.subVectors(i[0],i[1]).add(i[0]),a=Jc);const u=i[l%o],d=i[(l+1)%o];if(this.closed||l+2<o?s=i[(l+2)%o]:(Jc.subVectors(i[o-1],i[o-2]).add(i[o-1]),s=Jc),"centripetal"===this.curveType||"chordal"===this.curveType){const e="chordal"===this.curveType?.5:.25;let t=Math.pow(a.distanceToSquared(u),e),n=Math.pow(u.distanceToSquared(d),e),i=Math.pow(d.distanceToSquared(s),e);n<1e-4&&(n=1),t<1e-4&&(t=n),i<1e-4&&(i=n),$c.initNonuniformCatmullRom(a.x,u.x,d.x,s.x,t,n,i),eu.initNonuniformCatmullRom(a.y,u.y,d.y,s.y,t,n,i),tu.initNonuniformCatmullRom(a.z,u.z,d.z,s.z,t,n,i)}else"catmullrom"===this.curveType&&($c.initCatmullRom(a.x,u.x,d.x,s.x,this.tension),eu.initCatmullRom(a.y,u.y,d.y,s.y,this.tension),tu.initCatmullRom(a.z,u.z,d.z,s.z,this.tension));return n.set($c.calc(c),eu.calc(c),tu.calc(c)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push(n.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new ci).fromArray(n))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function iu(e,t,n,i,o){const r=.5*(i-t),a=.5*(o-n),s=e*e;return(2*n-2*i+r+a)*(e*s)+(-3*n+3*i-2*r-a)*s+r*e+n}function ou(e,t,n,i){return function(e,t){const n=1-e;return n*n*t}(e,t)+function(e,t){return 2*(1-e)*e*t}(e,n)+function(e,t){return e*e*t}(e,i)}function ru(e,t,n,i,o){return function(e,t){const n=1-e;return n*n*n*t}(e,t)+function(e,t){const n=1-e;return 3*n*n*e*t}(e,n)+function(e,t){return 3*(1-e)*e*e*t}(e,i)+function(e,t){return e*e*e*t}(e,o)}class au extends Xc{constructor(e=new yn,t=new yn,n=new yn,i=new yn){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new yn){const n=t,i=this.v0,o=this.v1,r=this.v2,a=this.v3;return n.set(ru(e,i.x,o.x,r.x,a.x),ru(e,i.y,o.y,r.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class su extends Xc{constructor(e=new ci,t=new ci,n=new ci,i=new ci){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=i}getPoint(e,t=new ci){const n=t,i=this.v0,o=this.v1,r=this.v2,a=this.v3;return n.set(ru(e,i.x,o.x,r.x,a.x),ru(e,i.y,o.y,r.y,a.y),ru(e,i.z,o.z,r.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class lu extends Xc{constructor(e=new yn,t=new yn){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new yn){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t){const n=t||new yn;return n.copy(this.v2).sub(this.v1).normalize(),n}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class cu extends Xc{constructor(e=new ci,t=new ci){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new ci){const n=t;return 1===e?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class uu extends Xc{constructor(e=new yn,t=new yn,n=new yn){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new yn){const n=t,i=this.v0,o=this.v1,r=this.v2;return n.set(ou(e,i.x,o.x,r.x),ou(e,i.y,o.y,r.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class du extends Xc{constructor(e=new ci,t=new ci,n=new ci){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ci){const n=t,i=this.v0,o=this.v1,r=this.v2;return n.set(ou(e,i.x,o.x,r.x),ou(e,i.y,o.y,r.y),ou(e,i.z,o.z,r.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class hu extends Xc{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new yn){const n=t,i=this.points,o=(i.length-1)*e,r=Math.floor(o),a=o-r,s=i[0===r?r:r-1],l=i[r],c=i[r>i.length-2?i.length-1:r+1],u=i[r>i.length-3?i.length-1:r+2];return n.set(iu(a,s.x,l.x,c.x,u.x),iu(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;t++){const n=e.points[t];this.points.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const n=this.points[t];e.points.push(n.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const n=e.points[t];this.points.push((new yn).fromArray(n))}return this}}var pu=Object.freeze({__proto__:null,ArcCurve:qc,CatmullRomCurve3:nu,CubicBezierCurve:au,CubicBezierCurve3:su,EllipseCurve:Kc,LineCurve:lu,LineCurve3:cu,QuadraticBezierCurve:uu,QuadraticBezierCurve3:du,SplineCurve:hu});class fu extends Xc{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);e.equals(t)||this.curves.push(new lu(t,e))}getPoint(e,t){const n=e*this.getLength(),i=this.getCurveLengths();let o=0;for(;o<i.length;){if(i[o]>=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;n<i;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let i=0,o=this.curves;i<o.length;i++){const r=o[i],a=r.isEllipseCurve?2*e:r.isLineCurve||r.isLineCurve3?1:r.isSplineCurve?e*r.points.length:e,s=r.getPoints(a);for(let e=0;e<s.length;e++){const i=s[e];n&&n.equals(i)||(t.push(i),n=i)}}return this.autoClose&&t.length>1&&!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;t<n;t++){const n=e.curves[t];this.curves.push(n.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const n=this.curves[t];e.curves.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const n=e.curves[t];this.curves.push((new pu[n.type]).fromJSON(n))}return this}}class mu extends fu{constructor(e){super(),this.type="Path",this.currentPoint=new yn,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new lu(this.currentPoint.clone(),new yn(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,i){const o=new uu(this.currentPoint.clone(),new yn(e,t),new yn(n,i));return this.curves.push(o),this.currentPoint.set(n,i),this}bezierCurveTo(e,t,n,i,o,r){const a=new au(this.currentPoint.clone(),new yn(e,t),new yn(n,i),new yn(o,r));return this.curves.push(a),this.currentPoint.set(o,r),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new hu(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,i,o,r){const a=this.currentPoint.x,s=this.currentPoint.y;return this.absarc(e+a,t+s,n,i,o,r),this}absarc(e,t,n,i,o,r){return this.absellipse(e,t,n,n,i,o,r),this}ellipse(e,t,n,i,o,r,a,s){const l=this.currentPoint.x,c=this.currentPoint.y;return this.absellipse(e+l,t+c,n,i,o,r,a,s),this}absellipse(e,t,n,i,o,r,a,s){const l=new Kc(e,t,n,i,o,r,a,s);if(this.curves.length>0){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 gu extends zo{constructor(e=[new yn(0,-.5),new yn(.5,0),new yn(0,.5)],t=12,n=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:i},t=Math.floor(t),i=nn(i,0,2*Math.PI);const o=[],r=[],a=[],s=[],l=[],c=1/t,u=new ci,d=new yn,h=new ci,p=new ci,f=new ci;let m=0,g=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-m,h.z=0*g,f.copy(h),h.normalize(),s.push(h.x,h.y,h.z);break;case e.length-1:s.push(f.x,f.y,f.z);break;default:m=e[t+1].x-e[t].x,g=e[t+1].y-e[t].y,h.x=1*g,h.y=-m,h.z=0*g,p.copy(h),h.x+=f.x,h.y+=f.y,h.z+=f.z,h.normalize(),s.push(h.x,h.y,h.z),f.copy(p)}for(let o=0;o<=t;o++){const h=n+o*c*i,p=Math.sin(h),f=Math.cos(h);for(let n=0;n<=e.length-1;n++){u.x=e[n].x*p,u.y=e[n].y,u.z=e[n].x*f,r.push(u.x,u.y,u.z),d.x=o/t,d.y=n/(e.length-1),a.push(d.x,d.y);const i=s[3*n+0]*p,c=s[3*n+1],h=s[3*n+0]*f;l.push(i,c,h)}}for(let n=0;n<t;n++)for(let t=0;t<e.length-1;t++){const i=t+n*e.length,r=i,a=i+e.length,s=i+e.length+1,l=i+1;o.push(r,a,l),o.push(s,l,a)}this.setIndex(o),this.setAttribute("position",new Lo(r,3)),this.setAttribute("uv",new Lo(a,2)),this.setAttribute("normal",new Lo(l,3))}static fromJSON(e){return new gu(e.points,e.segments,e.phiStart,e.phiLength)}}class vu extends gu{constructor(e=1,t=1,n=4,i=8){const o=new mu;o.absarc(0,-t/2,e,1.5*Math.PI,0),o.absarc(0,t/2,e,0,.5*Math.PI),super(o.getPoints(n),i),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:i}}static fromJSON(e){return new vu(e.radius,e.length,e.capSegments,e.radialSegments)}}class Au extends zo{constructor(e=1,t=32,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 ci,c=new yn;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 Lo(r,3)),this.setAttribute("normal",new Lo(a,3)),this.setAttribute("uv",new Lo(s,2))}static fromJSON(e){return new Au(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class _u extends zo{constructor(e=1,t=1,n=1,i=32,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 yn,f=new ci;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;e<i;e++){const t=o+e,i=x+e;!0===n?c.push(i,i+1,t):c.push(i+1,i,t),v+=3}l.addGroup(g,v,!0===n?1:2),g+=v}!function(){const r=new ci,v=new ci;let A=0;const _=(t-e)/n;for(let l=0;l<=o;l++){const c=[],g=l/o,A=g*(t-e)+e;for(let e=0;e<=i;e++){const t=e/i,o=t*s+a,l=Math.sin(o),f=Math.cos(o);v.x=A*l,v.y=-g*n+m,v.z=A*f,u.push(v.x,v.y,v.z),r.set(l,_,f).normalize(),d.push(r.x,r.y,r.z),h.push(t,1-g),c.push(p++)}f.push(c)}for(let e=0;e<i;e++)for(let t=0;t<o;t++){const n=f[t][e],i=f[t+1][e],o=f[t+1][e+1],r=f[t][e+1];c.push(n,i,r),c.push(i,o,r),A+=6}l.addGroup(g,A,0),g+=A}(),!1===r&&(e>0&&v(!0),t>0&&v(!1)),this.setIndex(c),this.setAttribute("position",new Lo(u,3)),this.setAttribute("normal",new Lo(d,3)),this.setAttribute("uv",new Lo(h,2))}static fromJSON(e){return new _u(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class xu extends _u{constructor(e=1,t=1,n=32,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 xu(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class yu extends zo{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<o;e++)for(let t=0;t<2*(o-e)-1;t++){const n=Math.floor(t/2);t%2==0?(s(r[e][n+1]),s(r[e+1][n]),s(r[e][n])):(s(r[e][n+1]),s(r[e+1][n+1]),s(r[e+1][n]))}}function s(e){o.push(e.x,e.y,e.z)}function l(t,n){const i=3*t;n.x=e[i+0],n.y=e[i+1],n.z=e[i+2]}function c(e,t,n,i){i<0&&1===e.x&&(r[t]=e.x-1),0===n.x&&0===n.z&&(r[t]=i/2/Math.PI+.5)}function u(e){return Math.atan2(e.z,-e.x)}!function(e){const n=new ci,i=new ci,o=new ci;for(let r=0;r<t.length;r+=3)l(t[r+0],n),l(t[r+1],i),l(t[r+2],o),a(n,i,o,e)}(i),function(e){const t=new ci;for(let n=0;n<o.length;n+=3)t.x=o[n+0],t.y=o[n+1],t.z=o[n+2],t.normalize().multiplyScalar(e),o[n+0]=t.x,o[n+1]=t.y,o[n+2]=t.z}(n),function(){const e=new ci;for(let n=0;n<o.length;n+=3){e.x=o[n+0],e.y=o[n+1],e.z=o[n+2];const i=u(e)/2/Math.PI+.5,a=(t=e,Math.atan2(-t.y,Math.sqrt(t.x*t.x+t.z*t.z))/Math.PI+.5);r.push(i,1-a)}var t;(function(){const e=new ci,t=new ci,n=new ci,i=new ci,a=new yn,s=new yn,l=new yn;for(let d=0,h=0;d<o.length;d+=9,h+=6){e.set(o[d+0],o[d+1],o[d+2]),t.set(o[d+3],o[d+4],o[d+5]),n.set(o[d+6],o[d+7],o[d+8]),a.set(r[h+0],r[h+1]),s.set(r[h+2],r[h+3]),l.set(r[h+4],r[h+5]),i.copy(e).add(t).add(n).divideScalar(3);const p=u(i);c(a,h+0,e,p),c(s,h+2,t,p),c(l,h+4,n,p)}})(),function(){for(let e=0;e<r.length;e+=6){const t=r[e+0],n=r[e+2],i=r[e+4],o=Math.max(t,n,i),a=Math.min(t,n,i);o>.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 Lo(o,3)),this.setAttribute("normal",new Lo(o.slice(),3)),this.setAttribute("uv",new Lo(r,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}static fromJSON(e){return new yu(e.vertices,e.indices,e.radius,e.details)}}class bu extends yu{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 bu(e.radius,e.detail)}}const Cu=new ci,Mu=new ci,Su=new ci,Eu=new bo;class wu extends zo{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($t*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;e<s;e+=3){r?(l[0]=r.getX(e),l[1]=r.getX(e+1),l[2]=r.getX(e+2)):(l[0]=e,l[1]=e+1,l[2]=e+2);const{a:t,b:n,c:s}=Eu;if(t.fromBufferAttribute(a,l[0]),n.fromBufferAttribute(a,l[1]),s.fromBufferAttribute(a,l[2]),Eu.getNormal(Su),u[0]=`${Math.round(t.x*i)},${Math.round(t.y*i)},${Math.round(t.z*i)}`,u[1]=`${Math.round(n.x*i)},${Math.round(n.y*i)},${Math.round(n.z*i)}`,u[2]=`${Math.round(s.x*i)},${Math.round(s.y*i)},${Math.round(s.z*i)}`,u[0]!==u[1]&&u[1]!==u[2]&&u[2]!==u[0])for(let e=0;e<3;e++){const t=(e+1)%3,n=u[e],i=u[t],r=Eu[c[e]],a=Eu[c[t]],s=`${n}_${i}`,p=`${i}_${n}`;p in d&&d[p]?(Su.dot(d[p].normal)<=o&&(h.push(r.x,r.y,r.z),h.push(a.x,a.y,a.z)),d[p]=null):s in d||(d[s]={index0:l[e],index1:l[t],normal:Su.clone()})}}for(const e in d)if(d[e]){const{index0:t,index1:n}=d[e];Cu.fromBufferAttribute(a,t),Mu.fromBufferAttribute(a,n),h.push(Cu.x,Cu.y,Cu.z),h.push(Mu.x,Mu.y,Mu.z)}this.setAttribute("position",new Lo(h,3))}}}class Tu extends mu{constructor(e){super(e),this.uuid=tn(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,i=this.holes.length;n<i;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push(n.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const n=this.holes[t];e.holes.push(n.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const n=e.holes[t];this.holes.push((new mu).fromJSON(n))}return this}}const Iu=function(e,t,n=2){const i=t&&t.length,o=i?t[0]*n:e.length;let r=Ru(e,0,o,n,!0);const a=[];if(!r||r.next===r.prev)return a;let s,l,c,u,d,h,p;if(i&&(r=function(e,t,n,i){const o=[];let r,a,s,l,c;for(r=0,a=t.length;r<a;r++)s=t[r]*i,l=r<a-1?t[r+1]*i:e.length,c=Ru(e,s,l,i,!1),c===c.next&&(c.steiner=!0),o.push(Gu(c));for(o.sort(Fu),r=0;r<o.length;r++)n=Uu(o[r],n);return n}(e,t,r,n)),e.length>80*n){s=c=e[0],l=u=e[1];for(let t=n;t<o;t+=n)d=e[t],h=e[t+1],d<s&&(s=d),h<l&&(l=h),d>c&&(c=d),h>u&&(u=h);p=Math.max(c-s,u-l),p=0!==p?32767/p:0}return Pu(r,a,n,s,l,p,0),a};function Ru(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;r<n;r+=i)o+=(e[a]-e[r])*(e[r+1]+e[a+1]),a=r;return o}(e,t,n,i)>0)for(r=t;r<n;r+=i)a=Zu(r,e[r],e[r+1],a);else for(r=n-i;r>=t;r-=i)a=Zu(r,e[r],e[r+1],a);return a&&Hu(a,a.next)&&(Ju(a),a=a.next),a}function Lu(e,t){if(!e)return e;t||(t=e);let n,i=e;do{if(n=!1,i.steiner||!Hu(i,i.next)&&0!==Wu(i.prev,i,i.next))i=i.next;else{if(Ju(i),i=t=i.prev,i===i.next)break;n=!0}}while(n||i!==t);return t}function Pu(e,t,n,i,o,r,a){if(!e)return;!a&&r&&function(e,t,n,i){let o=e;do{0===o.z&&(o.z=Vu(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;t<c&&(s++,i=i.nextZ,i);t++);for(l=c;s>0||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?Du(e,i,o,r):Bu(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Ju(e),e=l.next,c=l.next;else if((e=l)===c){a?1===a?Pu(e=Nu(Lu(e),t,n),t,n,i,o,r,2):2===a&&Ou(e,t,n,i,o,r):Pu(Lu(e),t,n,i,o,r,1);break}}function Bu(e){const t=e.prev,n=e,i=e.next;if(Wu(t,n,i)>=0)return!1;const o=t.x,r=n.x,a=i.x,s=t.y,l=n.y,c=i.y,u=o<r?o<a?o:a:r<a?r:a,d=s<l?s<c?s:c:l<c?l:c,h=o>r?o>a?o:a:r>a?r:a,p=s>l?s>c?s:c:l>c?l:c;let f=i.next;for(;f!==t;){if(f.x>=u&&f.x<=h&&f.y>=d&&f.y<=p&&ku(o,s,r,l,a,c,f.x,f.y)&&Wu(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Du(e,t,n,i){const o=e.prev,r=e,a=e.next;if(Wu(o,r,a)>=0)return!1;const s=o.x,l=r.x,c=a.x,u=o.y,d=r.y,h=a.y,p=s<l?s<c?s:c:l<c?l:c,f=u<d?u<h?u:h:d<h?d:h,m=s>l?s>c?s:c:l>c?l:c,g=u>d?u>h?u:h:d>h?d:h,v=Vu(p,f,t,n,i),A=Vu(m,g,t,n,i);let _=e.prevZ,x=e.nextZ;for(;_&&_.z>=v&&x&&x.z<=A;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==o&&_!==a&&ku(s,u,l,d,c,h,_.x,_.y)&&Wu(_.prev,_,_.next)>=0)return!1;if(_=_.prevZ,x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&x!==a&&ku(s,u,l,d,c,h,x.x,x.y)&&Wu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;_&&_.z>=v;){if(_.x>=p&&_.x<=m&&_.y>=f&&_.y<=g&&_!==o&&_!==a&&ku(s,u,l,d,c,h,_.x,_.y)&&Wu(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;x&&x.z<=A;){if(x.x>=p&&x.x<=m&&x.y>=f&&x.y<=g&&x!==o&&x!==a&&ku(s,u,l,d,c,h,x.x,x.y)&&Wu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Nu(e,t,n){let i=e;do{const o=i.prev,r=i.next.next;!Hu(o,r)&&ju(o,i,i.next,r)&&Ku(o,r)&&Ku(r,o)&&(t.push(o.i/n|0),t.push(i.i/n|0),t.push(r.i/n|0),Ju(i),Ju(i.next),i=e=r),i=i.next}while(i!==e);return Lu(i)}function Ou(e,t,n,i,o,r){let a=e;do{let e=a.next.next;for(;e!==a.prev;){if(a.i!==e.i&&Qu(a,e)){let s=qu(a,e);return a=Lu(a,a.next),s=Lu(s,s.next),Pu(a,t,n,i,o,r,0),void Pu(s,t,n,i,o,r,0)}e=e.next}a=a.next}while(a!==e)}function Fu(e,t){return e.x-t.x}function Uu(e,t){const n=function(e,t){let n,i=t,o=-1/0;const r=e.x,a=e.y;do{if(a<=i.y&&a>=i.next.y&&i.next.y!==i.y){const e=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>o&&(o=e,n=i.x<i.next.x?i:i.next,e===r))return n}i=i.next}while(i!==t);if(!n)return null;const s=n,l=n.x,c=n.y;let u,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&ku(a<c?r:o,a,l,c,a<c?o:r,a,i.x,i.y)&&(u=Math.abs(a-i.y)/(r-i.x),Ku(i,e)&&(u<d||u===d&&(i.x>n.x||i.x===n.x&&zu(n,i)))&&(n=i,d=u)),i=i.next}while(i!==s);return n}(e,t);if(!n)return t;const i=qu(n,e);return Lu(i,i.next),Lu(n,n.next)}function zu(e,t){return Wu(e.prev,e,t.prev)<0&&Wu(t.next,e,e.next)<0}function Vu(e,t,n,i,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*o|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*o|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Gu(e){let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function ku(e,t,n,i,o,r,a,s){return(o-a)*(t-s)>=(e-a)*(r-s)&&(e-a)*(i-s)>=(n-a)*(t-s)&&(n-a)*(r-s)>=(o-a)*(i-s)}function Qu(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&&ju(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Ku(e,t)&&Ku(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)&&(Wu(e.prev,e,t.prev)||Wu(e,t.prev,t))||Hu(e,t)&&Wu(e.prev,e,e.next)>0&&Wu(t.prev,t,t.next)>0)}function Wu(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Hu(e,t){return e.x===t.x&&e.y===t.y}function ju(e,t,n,i){const o=Xu(Wu(e,t,n)),r=Xu(Wu(e,t,i)),a=Xu(Wu(n,i,e)),s=Xu(Wu(n,i,t));return o!==r&&a!==s||(!(0!==o||!Yu(e,n,t))||(!(0!==r||!Yu(e,i,t))||(!(0!==a||!Yu(n,e,i))||!(0!==s||!Yu(n,t,i)))))}function Yu(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 Xu(e){return e>0?1:e<0?-1:0}function Ku(e,t){return Wu(e.prev,e,e.next)<0?Wu(e,t,e.next)>=0&&Wu(e,e.prev,t)>=0:Wu(e,t,e.prev)<0||Wu(e,e.next,t)<0}function qu(e,t){const n=new $u(e.i,e.x,e.y),i=new $u(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 Zu(e,t,n,i){const o=new $u(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 Ju(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 $u(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ed{static area(e){const t=e.length;let n=0;for(let i=t-1,o=0;o<t;i=o++)n+=e[i].x*e[o].y-e[o].x*e[i].y;return.5*n}static isClockWise(e){return ed.area(e)<0}static triangulateShape(e,t){const n=[],i=[],o=[];td(e),nd(n,e);let r=e.length;t.forEach(td);for(let e=0;e<t.length;e++)i.push(r),r+=t[e].length,nd(n,t[e]);const a=Iu(n,i);for(let e=0;e<a.length;e+=3)o.push(a.slice(e,e+3));return o}}function td(e){const t=e.length;t>2&&e[t-1].equals(e[0])&&e.pop()}function nd(e,t){for(let n=0;n<t.length;n++)e.push(t[n].x),e.push(t[n].y)}class id extends zo{constructor(e=new Tu([new yn(.5,.5),new yn(-.5,.5),new yn(-.5,-.5),new yn(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,i=[],o=[];for(let t=0,n=e.length;t<n;t++){r(e[t])}function r(e){const r=[],a=void 0!==t.curveSegments?t.curveSegments:12,s=void 0!==t.steps?t.steps:1,l=void 0!==t.depth?t.depth:1;let c=void 0===t.bevelEnabled||t.bevelEnabled,u=void 0!==t.bevelThickness?t.bevelThickness:.2,d=void 0!==t.bevelSize?t.bevelSize:u-.1,h=void 0!==t.bevelOffset?t.bevelOffset:0,p=void 0!==t.bevelSegments?t.bevelSegments:3;const f=t.extrudePath,m=void 0!==t.UVGenerator?t.UVGenerator:od;let g,v,A,_,x,y=!1;f&&(g=f.getSpacedPoints(s),y=!0,c=!1,v=f.computeFrenetFrames(s,!1),A=new ci,_=new ci,x=new ci),c||(p=0,u=0,d=0,h=0);const b=e.extractPoints(a);let C=b.shape;const M=b.holes;if(!ed.isClockWise(C)){C=C.reverse();for(let e=0,t=M.length;e<t;e++){const t=M[e];ed.isClockWise(t)&&(M[e]=t.reverse())}}const S=ed.triangulateShape(C,M),E=C;for(let e=0,t=M.length;e<t;e++){const t=M[e];C=C.concat(t)}function w(e,t,n){return t||console.error("v3d.ExtrudeGeometry: vec does not exist"),t.clone().multiplyScalar(n).add(e)}const T=C.length,I=S.length;function R(e,t,n){let i,o,r;const a=e.x-t.x,s=e.y-t.y,l=n.x-e.x,c=n.y-e.y,u=a*a+s*s,d=a*c-s*l;if(Math.abs(d)>Number.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 yn(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 yn(i/r,o/r)}const L=[];for(let e=0,t=E.length,n=t-1,i=e+1;e<t;e++,n++,i++)n===t&&(n=0),i===t&&(i=0),L[e]=R(E[e],E[n],E[i]);const P=[];let B,D=L.concat();for(let e=0,t=M.length;e<t;e++){const t=M[e];B=[];for(let e=0,n=t.length,i=n-1,o=e+1;e<n;e++,i++,o++)i===n&&(i=0),o===n&&(o=0),B[e]=R(t[e],t[i],t[o]);P.push(B),D=D.concat(B)}for(let e=0;e<p;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=E.length;e<t;e++){const t=w(E[e],L[e],i);F(t.x,t.y,-n)}for(let e=0,t=M.length;e<t;e++){const t=M[e];B=P[e];for(let e=0,o=t.length;e<o;e++){const o=w(t[e],B[e],i);F(o.x,o.y,-n)}}}const N=d+h;for(let e=0;e<T;e++){const t=c?w(C[e],D[e],N):C[e];y?(_.copy(v.normals[0]).multiplyScalar(t.x),A.copy(v.binormals[0]).multiplyScalar(t.y),x.copy(g[0]).add(_).add(A),F(x.x,x.y,x.z)):F(t.x,t.y,0)}for(let e=1;e<=s;e++)for(let t=0;t<T;t++){const n=c?w(C[t],D[t],N):C[t];y?(_.copy(v.normals[e]).multiplyScalar(n.x),A.copy(v.binormals[e]).multiplyScalar(n.y),x.copy(g[e]).add(_).add(A),F(x.x,x.y,x.z)):F(n.x,n.y,l/s*e)}for(let e=p-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=E.length;e<t;e++){const t=w(E[e],L[e],i);F(t.x,t.y,l+n)}for(let e=0,t=M.length;e<t;e++){const t=M[e];B=P[e];for(let e=0,o=t.length;e<o;e++){const o=w(t[e],B[e],i);y?F(o.x,o.y+g[s-1].y,g[s-1].x+n):F(o.x,o.y,l+n)}}}function O(e,t){let n=e.length;for(;--n>=0;){const i=n;let o=n-1;o<0&&(o=e.length-1);for(let e=0,n=s+2*p;e<n;e++){const n=T*e,r=T*(e+1);z(t+i+n,t+o+n,t+o+r,t+i+r)}}}function F(e,t,n){r.push(e),r.push(t),r.push(n)}function U(e,t,o){V(e),V(t),V(o);const r=i.length/3,a=m.generateTopUV(n,i,r-3,r-2,r-1);G(a[0]),G(a[1]),G(a[2])}function z(e,t,o,r){V(e),V(t),V(r),V(t),V(o),V(r);const a=i.length/3,s=m.generateSideWallUV(n,i,a-6,a-3,a-2,a-1);G(s[0]),G(s[1]),G(s[3]),G(s[1]),G(s[2]),G(s[3])}function V(e){i.push(r[3*e+0]),i.push(r[3*e+1]),i.push(r[3*e+2])}function G(e){o.push(e.x),o.push(e.y)}!function(){const e=i.length/3;if(c){let e=0,t=T*e;for(let e=0;e<I;e++){const n=S[e];U(n[2]+t,n[1]+t,n[0]+t)}e=s+2*p,t=T*e;for(let e=0;e<I;e++){const n=S[e];U(n[0]+t,n[1]+t,n[2]+t)}}else{for(let e=0;e<I;e++){const t=S[e];U(t[2],t[1],t[0])}for(let e=0;e<I;e++){const t=S[e];U(t[0]+T*s,t[1]+T*s,t[2]+T*s)}}n.addGroup(e,i.length/3-e,0)}(),function(){const e=i.length/3;let t=0;O(E,t),t+=E.length;for(let e=0,n=M.length;e<n;e++){const n=M[e];O(n,t),t+=n.length}n.addGroup(e,i.length/3-e,1)}()}this.setAttribute("position",new Lo(i,3)),this.setAttribute("uv",new Lo(o,2)),this.computeVertexNormals()}toJSON(){const e=super.toJSON();return function(e,t,n){if(n.shapes=[],Array.isArray(e))for(let t=0,i=e.length;t<i;t++){const i=e[t];n.shapes.push(i.uuid)}else n.shapes.push(e.uuid);n.options=Object.assign({},t),void 0!==t.extrudePath&&(n.options.extrudePath=t.extrudePath.toJSON());return n}(this.parameters.shapes,this.parameters.options,e)}static fromJSON(e,t){const n=[];for(let i=0,o=e.shapes.length;i<o;i++){const o=t[e.shapes[i]];n.push(o)}const i=e.options.extrudePath;return void 0!==i&&(e.options.extrudePath=(new pu[i.type]).fromJSON(i)),new id(n,e.options)}}const od={generateTopUV:function(e,t,n,i,o){const r=t[3*n],a=t[3*n+1],s=t[3*i],l=t[3*i+1],c=t[3*o],u=t[3*o+1];return[new yn(r,a),new yn(s,l),new yn(c,u)]},generateSideWallUV:function(e,t,n,i,o,r){const a=t[3*n],s=t[3*n+1],l=t[3*n+2],c=t[3*i],u=t[3*i+1],d=t[3*i+2],h=t[3*o],p=t[3*o+1],f=t[3*o+2],m=t[3*r],g=t[3*r+1],v=t[3*r+2];return Math.abs(s-u)<Math.abs(a-c)?[new yn(a,1-l),new yn(c,1-d),new yn(h,1-f),new yn(m,1-v)]:[new yn(s,1-l),new yn(u,1-d),new yn(p,1-f),new yn(g,1-v)]}};class rd extends yu{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2;super([-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new rd(e.radius,e.detail)}}class ad extends yu{constructor(e=1,t=0){super([1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ad(e.radius,e.detail)}}class sd extends zo{constructor(e=.5,t=1,n=32,i=1,o=0,r=2*Math.PI){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:i,thetaStart:o,thetaLength:r},n=Math.max(3,n);const a=[],s=[],l=[],c=[];let u=e;const d=(t-e)/(i=Math.max(1,i)),h=new ci,p=new yn;for(let e=0;e<=i;e++){for(let e=0;e<=n;e++){const i=o+e/n*r;h.x=u*Math.cos(i),h.y=u*Math.sin(i),s.push(h.x,h.y,h.z),l.push(0,0,1),p.x=(h.x/t+1)/2,p.y=(h.y/t+1)/2,c.push(p.x,p.y)}u+=d}for(let e=0;e<i;e++){const t=e*(n+1);for(let e=0;e<n;e++){const i=e+t,o=i,r=i+n+1,s=i+n+2,l=i+1;a.push(o,r,l),a.push(r,s,l)}}this.setIndex(a),this.setAttribute("position",new Lo(s,3)),this.setAttribute("normal",new Lo(l,3)),this.setAttribute("uv",new Lo(c,2))}static fromJSON(e){return new sd(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ld extends zo{constructor(e=new Tu([new yn(0,.5),new yn(-.5,-.5),new yn(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],i=[],o=[],r=[];let a=0,s=0;if(!1===Array.isArray(e))l(e);else for(let t=0;t<e.length;t++)l(e[t]),this.addGroup(a,s,t),a+=s,s=0;function l(e){const a=i.length/3,l=e.extractPoints(t);let c=l.shape;const u=l.holes;!1===ed.isClockWise(c)&&(c=c.reverse());for(let e=0,t=u.length;e<t;e++){const t=u[e];!0===ed.isClockWise(t)&&(u[e]=t.reverse())}const d=ed.triangulateShape(c,u);for(let e=0,t=u.length;e<t;e++){const t=u[e];c=c.concat(t)}for(let e=0,t=c.length;e<t;e++){const t=c[e];i.push(t.x,t.y,0),o.push(0,0,1),r.push(t.x,t.y)}for(let e=0,t=d.length;e<t;e++){const t=d[e],i=t[0]+a,o=t[1]+a,r=t[2]+a;n.push(i,o,r),s+=3}}this.setIndex(n),this.setAttribute("position",new Lo(i,3)),this.setAttribute("normal",new Lo(o,3)),this.setAttribute("uv",new Lo(r,2))}toJSON(){const e=super.toJSON();return function(e,t){if(t.shapes=[],Array.isArray(e))for(let n=0,i=e.length;n<i;n++){const i=e[n];t.shapes.push(i.uuid)}else t.shapes.push(e.uuid);return t}(this.parameters.shapes,e)}static fromJSON(e,t){const n=[];for(let i=0,o=e.shapes.length;i<o;i++){const o=t[e.shapes[i]];n.push(o)}return new ld(n,e.curveSegments)}}class cd extends zo{constructor(e=1,t=32,n=16,i=0,o=2*Math.PI,r=0,a=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:i,phiLength:o,thetaStart:r,thetaLength:a},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const s=Math.min(r+a,Math.PI);let l=0;const c=[],u=new ci,d=new ci,h=[],p=[],f=[],m=[];for(let h=0;h<=n;h++){const g=[],v=h/n;let A=0;0==h&&0==r?A=.5/t:h==n&&s==Math.PI&&(A=-.5/t);for(let n=0;n<=t;n++){const s=n/t;u.x=-e*Math.cos(i+s*o)*Math.sin(r+v*a),u.y=e*Math.cos(r+v*a),u.z=e*Math.sin(i+s*o)*Math.sin(r+v*a),p.push(u.x,u.y,u.z),d.copy(u).normalize(),f.push(d.x,d.y,d.z),m.push(s+A,1-v),g.push(l++)}c.push(g)}for(let e=0;e<n;e++)for(let i=0;i<t;i++){const t=c[e][i+1],o=c[e][i],a=c[e+1][i],l=c[e+1][i+1];(0!==e||r>0)&&h.push(t,o,l),(e!==n-1||s<Math.PI)&&h.push(o,a,l)}this.setIndex(h),this.setAttribute("position",new Lo(p,3)),this.setAttribute("normal",new Lo(f,3)),this.setAttribute("uv",new Lo(m,2))}static fromJSON(e){return new cd(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class ud extends yu{constructor(e=1,t=0){super([1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new ud(e.radius,e.detail)}}class dd extends zo{constructor(e=1,t=.4,n=12,i=48,o=2*Math.PI){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:i,arc:o},n=Math.floor(n),i=Math.floor(i);const r=[],a=[],s=[],l=[],c=new ci,u=new ci,d=new ci;for(let r=0;r<=n;r++)for(let h=0;h<=i;h++){const p=h/i*o,f=r/n*Math.PI*2;u.x=(e+t*Math.cos(f))*Math.cos(p),u.y=(e+t*Math.cos(f))*Math.sin(p),u.z=t*Math.sin(f),a.push(u.x,u.y,u.z),c.x=e*Math.cos(p),c.y=e*Math.sin(p),d.subVectors(u,c).normalize(),s.push(d.x,d.y,d.z),l.push(h/i),l.push(r/n)}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*e+t-1,o=(i+1)*(e-1)+t-1,a=(i+1)*(e-1)+t,s=(i+1)*e+t;r.push(n,o,s),r.push(o,a,s)}this.setIndex(r),this.setAttribute("position",new Lo(a,3)),this.setAttribute("normal",new Lo(s,3)),this.setAttribute("uv",new Lo(l,2))}static fromJSON(e){return new dd(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class hd extends zo{constructor(e=1,t=.4,n=64,i=8,o=2,r=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:i,p:o,q:r},n=Math.floor(n),i=Math.floor(i);const a=[],s=[],l=[],c=[],u=new ci,d=new ci,h=new ci,p=new ci,f=new ci,m=new ci,g=new ci;for(let a=0;a<=n;++a){const A=a/n*o*Math.PI*2;v(A,o,r,e,h),v(A+.01,o,r,e,p),m.subVectors(p,h),g.addVectors(p,h),f.crossVectors(m,g),g.crossVectors(f,m),f.normalize(),g.normalize();for(let e=0;e<=i;++e){const o=e/i*Math.PI*2,r=-t*Math.cos(o),p=t*Math.sin(o);u.x=h.x+(r*g.x+p*f.x),u.y=h.y+(r*g.y+p*f.y),u.z=h.z+(r*g.z+p*f.z),s.push(u.x,u.y,u.z),d.subVectors(u,h).normalize(),l.push(d.x,d.y,d.z),c.push(a/n),c.push(e/i)}}for(let e=1;e<=n;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),o=(i+1)*e+(t-1),r=(i+1)*e+t,s=(i+1)*(e-1)+t;a.push(n,o,s),a.push(o,r,s)}function v(e,t,n,i,o){const r=Math.cos(e),a=Math.sin(e),s=n/t*e,l=Math.cos(s);o.x=i*(2+l)*.5*r,o.y=i*(2+l)*a*.5,o.z=i*Math.sin(s)*.5}this.setIndex(a),this.setAttribute("position",new Lo(s,3)),this.setAttribute("normal",new Lo(l,3)),this.setAttribute("uv",new Lo(c,2))}static fromJSON(e){return new hd(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class pd extends zo{constructor(e=new du(new ci(-1,-1,0),new ci(-1,1,0),new ci(1,1,0)),t=64,n=1,i=8,o=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:i,closed:o};const r=e.computeFrenetFrames(t,o);this.tangents=r.tangents,this.normals=r.normals,this.binormals=r.binormals;const a=new ci,s=new ci,l=new yn;let c=new ci;const u=[],d=[],h=[],p=[];function f(o){c=e.getPointAt(o/t,c);const l=r.normals[o],h=r.binormals[o];for(let e=0;e<=i;e++){const t=e/i*Math.PI*2,o=Math.sin(t),r=-Math.cos(t);s.x=r*l.x+o*h.x,s.y=r*l.y+o*h.y,s.z=r*l.z+o*h.z,s.normalize(),d.push(s.x,s.y,s.z),a.x=c.x+n*s.x,a.y=c.y+n*s.y,a.z=c.z+n*s.z,u.push(a.x,a.y,a.z)}}!function(){for(let e=0;e<t;e++)f(e);f(!1===o?t:0),function(){for(let e=0;e<=t;e++)for(let n=0;n<=i;n++)l.x=e/t,l.y=n/i,h.push(l.x,l.y)}(),function(){for(let e=1;e<=t;e++)for(let t=1;t<=i;t++){const n=(i+1)*(e-1)+(t-1),o=(i+1)*e+(t-1),r=(i+1)*e+t,a=(i+1)*(e-1)+t;p.push(n,o,a),p.push(o,r,a)}}()}(),this.setIndex(p),this.setAttribute("position",new Lo(u,3)),this.setAttribute("normal",new Lo(d,3)),this.setAttribute("uv",new Lo(h,2))}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new pd((new pu[e.path.type]).fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class fd extends zo{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},null!==e){const t=[],n=new Set,i=new ci,o=new ci;if(null!==e.index){const r=e.attributes.position,a=e.index;let s=e.groups;0===s.length&&(s=[{start:0,count:a.count,materialIndex:0}]);for(let e=0,l=s.length;e<l;++e){const l=s[e],c=l.start;for(let e=c,s=c+l.count;e<s;e+=3)for(let s=0;s<3;s++){const l=a.getX(e+s),c=a.getX(e+(s+1)%3);i.fromBufferAttribute(r,l),o.fromBufferAttribute(r,c),!0===md(i,o,n)&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}}else{const r=e.attributes.position;for(let e=0,a=r.count/3;e<a;e++)for(let a=0;a<3;a++){const s=3*e+a,l=3*e+(a+1)%3;i.fromBufferAttribute(r,s),o.fromBufferAttribute(r,l),!0===md(i,o,n)&&(t.push(i.x,i.y,i.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new Lo(t,3))}}}function md(e,t,n){const i=`${e.x},${e.y},${e.z}-${t.x},${t.y},${t.z}`,o=`${t.x},${t.y},${t.z}-${e.x},${e.y},${e.z}`;return!0!==n.has(i)&&!0!==n.has(o)&&(n.add(i),n.add(o),!0)}class gd extends id{constructor(e,t={}){const n=t.font;if(!n||!n.isFont)return console.error("v3d.TextGeometry: font parameter is not an instance of v3d.Font."),new zo;void 0===t.alignX&&(t.alignX="left"),void 0===t.alignY&&(t.alignY="topBaseline"),void 0===t.lineHeight&&(t.lineHeight=-1),void 0===t.scaledEmSize&&(t.scaledEmSize=!1);const i=n.generateShapes(e,t.size,t.alignX,t.alignY,t.lineHeight,t.scaledEmSize);t.depth=void 0!==t.height?t.height:50,void 0===t.bevelThickness&&(t.bevelThickness=10),void 0===t.bevelSize&&(t.bevelSize=8),void 0===t.bevelEnabled&&(t.bevelEnabled=!1),super(i,t),this.type="TextGeometry",this.parameters={text:e,parameters:t}}cloneWithText(e){var t=this.parameters.parameters;return new gd(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,lineHeight:t.lineHeight,scaledEmSize:t.scaledEmSize})}}class vd extends gd{constructor(e,t){super(e,t),function(e,t,n,i,o){e.computeBoundingBox();const r=i.split(/\r\n|\r|\n/).length,a=e.boundingBox.max.x-e.boundingBox.min.x,s=e.boundingBox.max.y-e.boundingBox.min.y;let l,c,u=s/(r+r-1);switch(t){case"left":l=0;break;case"center":l=-.5*a;break;case"right":l=-a;break;default:c=0}const d=u*Math.abs(o.data.descender)/o.data.ascender;switch(n){case"topBaseline":default:c=0;break;case"top":c=-u;break;case"center":c=r>1?.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 vd(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 Ad extends zo{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 zi;v.set(-1,3,-3,1,3,-6,3,0,-3,3,0,0,1,0,0,0);const A=[],_=[],x=[],y=[],b=[],C=[],M=[],S=[],E=[],w=new ci;let T,I,R,L,P=0,B=0;const D=new ci,N=new zi,O=new zi,F=new ii,U=new ii,z=new ii,V=new ii,G=new ci,k=new ci,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++)C[e]=new zi;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<H;e++)if(i||e<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),C[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,P=B=1):(y[L]=P*(3-L),b[L]=B*(3-L),P*=n,B*=i);F.fromArray(_),U.fromArray(x),z.fromArray(y),V.fromArray(b);for(let e=0;e<3;e++)T=F.clone(),T.applyMatrix4(C[e]),M[e]=T.dot(U),T=z.clone(),T.applyMatrix4(C[e]),S[e]=T.dot(U),T=F.clone(),T.applyMatrix4(C[e]),E[e]=T.dot(V);G.fromArray(S),k.fromArray(E),w.crossVectors(k,G),w.normalize(),0===M[0]&&0===M[1]?D.set(0,M[2]>c?1:-1,0):D.set(w.x,w.z,-w.y),f[X++]=u*M[0],f[X++]=u*(M[2]-c),f[X++]=-u*M[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;e<t;e++)for(let n=0;n<t;n++){const t=Y*j*j+e*j+n,i=t+1,o=i+j,r=t+j;W(t,i,o)&&(h[Z++]=t,h[Z++]=i,h[Z++]=o),W(t,o,r)&&(h[Z++]=t,h[Z++]=o,h[Z++]=r)}Y++}this.setIndex(new To(h,1)),this.setAttribute("position",new To(f,3)),this.setAttribute("normal",new To(m,3)),this.setAttribute("uv",new To(g,2)),this.computeBoundingSphere()}}var _d=Object.freeze({__proto__:null,BoxGeometry:rr,CapsuleGeometry:vu,CircleGeometry:Au,ConeGeometry:xu,CylinderGeometry:_u,DodecahedronGeometry:bu,EdgesGeometry:wu,ExtrudeGeometry:id,IcosahedronGeometry:rd,LatheGeometry:gu,OctahedronGeometry:ad,PlaneGeometry:Er,PolyhedronGeometry:yu,RingGeometry:sd,ShapeGeometry:ld,SphereGeometry:cd,TetrahedronGeometry:ud,TorusGeometry:dd,TorusKnotGeometry:hd,TubeGeometry:pd,WireframeGeometry:fd,BlenderTextGeometry:vd,BlenderTextBufferGeometry:vd,TeapotGeometry:Ad,TextGeometry:gd});class xd extends Mo{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new qn(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class yd extends Mo{constructor(e){super(),this.isMeshStandardMaterial=!0,this.defines={STANDARD:""},this.type="MeshStandardMaterial",this.color=new qn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.envMapParallaxType=0,this.envMapParallaxMatrix=new zi,this.envMapParallaxMatrixInv=new zi,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,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.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this.envMapParallaxType=e.envMapParallaxType,this.envMapParallaxMatrix.copy(e.envMapParallaxMatrix),this.envMapParallaxMatrixInv.copy(e.envMapParallaxMatrixInv),this}}class bd extends yd{constructor(e){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new yn(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return nn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new qn(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new qn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new qn(1,1,1),this.specularColorMap=null,this._sheen=0,this._clearcoat=0,this._iridescence=0,this._transmission=0,this.setValues(e)}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=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 iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=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.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,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}}class Cd extends Mo{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new qn(16777215),this.specular=new qn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,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.fog=e.fog,this}}class Md extends Mo{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new qn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(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.fog=!0,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.fog=e.fog,this}}class Sd extends Mo{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=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}}class Ed extends Mo{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new qn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new qn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.combine=Y,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,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.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.fog=e.fog,this}}class wd extends Mo{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new qn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Nt,this.normalScale=new yn(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,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.fog=e.fog,this}}class Td extends Ic{constructor(e){super(),this.isLineDashedMaterial=!0,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}}class Id extends Mo{constructor(e){super(),this.type="MeshMaskMaterial",this.side=m,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=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}}Id.prototype.isMeshMaskMaterial=!0;class Rd{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<i)){for(let r=n+2;;){if(void 0===i){if(e<o)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===r)break;if(o=i,i=t[++n],e<i)break t}r=t.length;break n}if(e>=o)break e;{const a=t[1];e<a&&(n=2,o=a);for(let r=n-2;;){if(void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(n===r)break;if(i=o,o=t[--n-1],e>=o)break t}r=n,n=0}}for(;n<r;){const i=n+r>>>1;e<t[i]?r=i:n=i+1}if(i=t[n],o=t[n-1],void 0===o)return this._cachedIndex=0,this.copySampleValue_(0);if(void 0===i)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,o,i)}return this.interpolate_(n,o,e,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i;for(let e=0;e!==i;++e)t[e]=n[o+e];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Ld extends Rd{constructor(e,t,n,i){super(e,t,n,i)}interpolate_(e){return this.copySampleValue_(e-1)}}var Pd={};!function(e){e.less=function(e,t,n){return n(e,t)<0},e.exchange=function(e,t,n){var i=e[t];e[t]=e[n],e[n]=i};e.StackNode=function(e){this.value=e,this.next=null};var t=function(){this.N=0,this.first=null};t.prototype.push=function(e){this.first=this._push(this.first,e)},t.prototype._push=function(t,n){if(null==t)return this.N++,new e.StackNode(n);var i=t;return this.N++,(t=new e.StackNode(n)).next=i,t},t.prototype.pop=function(){if(null!=this.first){var e=this.first,t=e.value;return this.first=e.next,this.N--,t}},t.prototype.size=function(){return this.N},t.prototype.isEmpty=function(){return 0==this.N},t.prototype.peep=function(){if(null!=this.first)return this.first.value},t.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},e.Stack=t;e.QueueNode=function(e){this.value=e,this.next=null};var n=function(){this.first=null,this.last=null,this.N=0};n.prototype.enqueue=function(t){var n=this.last;this.last=new e.QueueNode(t),null!=n&&(n.next=this.last),null==this.first&&(this.first=this.last),this.N++},n.prototype.dequeue=function(){if(null!=this.first){var e=this.first,t=e.value;return this.first=e.next,null==this.first&&(this.last=null),this.N--,t}},n.prototype.size=function(){return this.N},n.prototype.isEmpty=function(){return 0==this.N},n.prototype.toArray=function(){for(var e=[],t=this.first;null!=t;)e.push(t.value),t=t.next;return e},e.Queue=n;e.LinkMapNode=function(e){this.value=e,this.prev=null,this.next=null};var i=function(){this.first=null,this.last=null,this.map={}};i.prototype.push=function(e,t){this.map[t]=e,null===this.first?(this.first=e,this.last=e):(this.last.next=e,e.prev=this.last,this.last=e)},i.prototype.removeNodeByKey=function(e){var t=this.map[e],n=t.prev,i=t.next;null!==n&&null!==i?(n.next=i,i.prev=n):null===n&&null!==i?(this.first=i,i.prev=null):null!==n&&null===i?(this.last=n,n.next=null):(this.first=null,this.last=null),delete this.map[e]},e.LinkMap=i;var o=function(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})};o.prototype.addNewEdge=function(t,n){this.adjList[t].push(n),this.adjList[n].push(t);var i=t+"_"+n;t>n&&(i=n+"_"+t),this.edges[i]=new e.Edge(t,n,0)},o.prototype.adj=function(e){return this.adjList[e]},o.prototype.node=function(e){return this.nodeInfo[e]},o.prototype.len=function(){return this.V},o.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=o;var r=function(e){this.V=e,this.adjList=[],this.nodeInfo=[],this.edges={};for(var t=0;t<e;++t)this.adjList.push([]),this.nodeInfo.push({})};r.prototype.removeAll=function(){this.V=0,this.adjList=[],this.nodeInfo=[],this.edges={}},r.prototype.addNode=function(e){e=e||{},this.V++,this.adjList.push([]),this.nodeInfo.push(e)},r.prototype.addNewEdge=function(t,n){this.adjList[t].push(n);var i=t+"_"+n,o=new e.Edge(t,n,0);return this.edges[i]=o,o},r.prototype.addEdge=function(e){var t=e.v,n=e.w;this.adjList[t].push(n);var i=t+"_"+n;this.edges[i]=e},r.prototype.removeEdge=function(e,t){for(var n=this.adjList[e],i=0;i<n.length;i++)n[i]==t&&(n.splice(i,1),i--);var o=e+"_"+t;o in this.edges&&delete this.edges[o]},r.prototype.edge=function(e,t){var n=e+"_"+t;return n in this.edges?this.edges[n]:null},r.prototype.adj=function(e){return this.adjList[e]},r.prototype.node=function(e){return this.nodeInfo[e]},r.prototype.nodeIndex=function(e){for(var t=0;t<this.V;++t)if(this.nodeInfo[t]==e)return t;return-1},r.prototype.reverse=function(){for(var e=new r(this.V),t=0;t<this.V;++t)for(var n=this.adjList[t],i=0;i<n.length;++i){var o=n[i];e.addNewEdge(o,t)}return e},r.prototype.len=function(){return this.V},r.prototype.findInEdges=function(e){for(var t=[],n=0;n<this.V;n++)for(var i=this.adjList[n],o=0;o<i.length;o++)i[o]==e&&t.push(this.edge(n,e));return t},r.prototype.findOutEdges=function(e){for(var t=[],n=this.adjList[e],i=0;i<n.length;i++)t.push(this.edge(e,n[i]));return t},r.prototype.disconnect=function(e,t){this.adjList[e].splice(0);for(var n=0;n<this.V;n++){for(var i=this.adjList[n],o=0;o<i.length;o++)i[o]==e&&(i.splice(o,1),o--);var a=n+"_"+e;a in this.edges&&delete this.edges[a],(a=e+"_"+n)in this.edges&&delete this.edges[a]}if(t){var s=new r(this.V-1);for(n=0;n<this.V;n++)if(n!=e)for(i=this.adjList[n],o=0;o<i.length;o++){var l=i[o],c=n>e?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}},r.prototype.insert=function(e,t,n,i=(e=>e),o=(e=>e)){for(var r=this.V,a=e.V,s=0;s<a;s++){this.adjList.push([]),this.nodeInfo.push(i(e.nodeInfo[s]));for(var l=e.adjList[s],c=0;c<l.length;c++){var u=l[c];(d=e.edge(s,u).copy(o)).v+=r,d.w+=r,this.addEdge(d)}}this.V+=a;for(c=0;c<t.length;c++){(d=t[c].copy(o)).w+=r,this.addEdge(d)}for(c=0;c<n.length;c++){var d;(d=n[c].copy(o)).v+=r,this.addEdge(d)}},r.prototype.vis=function(e){e=e||function(e,t){return String(e)};for(var t="digraph G {",n=0;n<this.V;n++){t+=n+' [label="'+e(n,this.nodeInfo[n])+'"];';for(var i=this.adjList[n],o=0;o<i.length;o++){t+=n+" -> "+i[o]+";"}}t+="}",console.log(t)},e.DiGraph=r;var a=function(e,t,n){this.v=e,this.w=t,this.weight=n};a.prototype.either=function(){return this.v},a.prototype.other=function(e){return e==this.v?this.w:this.v},a.prototype.from=function(){return this.v},a.prototype.to=function(){return this.w},a.prototype.copy=function(e=(e=>e)){const t=new a(0,0,0);for(const n in this)this.hasOwnProperty(n)&&("object"==typeof this[n]?t[n]=e(this[n]):t[n]=this[n]);return t},e.Edge=a;var s=function(e,t){this.s=t;var n=e.V;this.marked=[],this.edgeTo=[];for(var i=0;i<n;++i)this.marked.push(!1),this.edgeTo.push(-1);this.dfs(e,t)};s.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),i=0;i<n.length;++i){var o=n[i];this.marked[o]||(this.edgeTo[o]=t,this.dfs(e,o))}},s.prototype.hasPathTo=function(e){return this.marked[e]},s.prototype.pathTo=function(t){var n=new e.Stack;if(t==this.s)return[t];for(var i=t;i!=this.s;i=this.edgeTo[i])n.push(i);return n.push(this.s),n.toArray()},e.DepthFirstSearch=s;var l=function(t,n){var i=t.V;this.s=n;var o=new e.Queue;o.enqueue(n),this.marked=[],this.edgeTo=[];for(var r=0;r<i;++r)this.marked.push(!1),this.edgeTo.push(-1);for(;!o.isEmpty();){r=o.dequeue();this.marked[r]=!0;for(var a=t.adj(r),s=0;s<a.length;++s){var l=a[s];this.marked[l]||(this.edgeTo[l]=r,o.enqueue(l))}}};l.prototype.hasPathTo=function(e){return this.marked[e]},l.prototype.pathTo=function(t){var n=new e.Stack;if(t==this.s)return[t];for(var i=t;i!=this.s;i=this.edgeTo[i])n.push(i);return n.push(this.s),n.toArray()},e.BreadthFirstSearch=l;var c=function(t){this.postOrder=new e.Stack,this.marked=[];for(var n=t.V,i=0;i<n;++i)this.marked.push(!1);for(i=0;i<n;++i)this.marked[i]||this.dfs(t,i)};c.prototype.dfs=function(e,t){this.marked[t]=!0;for(var n=e.adj(t),i=0;i<n.length;++i){var o=n[i];this.marked[o]||this.dfs(e,o)}this.postOrder.push(t)},c.prototype.order=function(){return this.postOrder.toArray()},e.TopologicalSort=c}(Pd);var Bd=[[-1.117001,-.1867262,-11.13505,12.59865,-.03937339,1.167571,.007100686,3.592678,.6083296,-1.152006,-.1926669,6.152049,-4.770802,-.08704701,.7483626,.03372718,4.464592,.4036546,-1.072371,-.2696632,.2816168,1.820571,-.3742666,2.080607,-.07675295,-2.835366,1.129329,-1.109935,-.1532764,1.198787,-.9015183,.005173015,.5749178,.1075633,4.387949,.2650413,-1.052297,-.2229452,1.952347,.5727205,-4.88507,1.984016,-.1106197,-.4898361,.8907873,-1.070108,-.1600465,1.593886,-4479251e-11,-3.306541,.9390193,.09513168,2.343583,.5335404,-1.113253,-.16996,-10.38822,11.37513,-.04040911,1.037455,.04991792,4.801919,.630271,-1.135747,-.1678594,4.970755,-4.43023,-.06657408,.3636161,.1558009,6.01337,.3959601,-1.095892,-.2732595,.7666496,1.350731,-.4401401,2.470135,-.1707929,-3.260793,1.170337,-1.073668,-.02603929,-.1944589,.4575207,.6878164,-.139077,.3690299,7.885781,.1877694,-1.070091,-.2798957,2.338478,-2.647221,-7.387808,2.32921,-.1644639,-2.00371,.9874527,-1.06712,-.1418866,1.25409,6.053048,-2.918892,.5322812,.1613053,3.018161,.527409,-1.129483,-.1890619,-9.065101,9.659923,-.03607819,.8314359,.08181661,4.768868,.6339777,-1.14642,-.1883579,3.309173,-3.127882,-.06938176,.3987113,.1400581,6.283042,.5267076,-1.128348,-.2641305,1.223176,.05514952,-.3490649,1.997784,-.04123709,-2.251251,.9483466,-1.02582,.0140469,-1.187406,2.7299,.5877588,-.276114,.4602633,8.305125,.3945001,-1.083957,-.2606679,2.207108,-7.202803,-5.968103,2.129455,-.07789512,-1.137688,.8871769,-1.062465,-.1512189,1.042881,14.27839,-4.242214,.40381,.199778,2.814449,.5803196,-1.175099,-.2410789,-11.08587,11.33404,-.018193,.6772942,.09605043,4.231166,.6239972,-1.224207,-.2883527,3.002206,-2.649612,-.04795418,.4984398,.03251434,4.851611,.6551019,-1.136955,-.2423048,1.058823,-.2489236,-.2462179,1.93314,.09106828,-.1905869,.8171065,-1.014535,-.0082625,-1.448017,2.295788,.3510334,-1.477418,.5432449,5.762796,.4908751,-1.070666,-.237978,1.844589,-5.442448,-4.012768,2.945275,.009854725,.08455959,.814503,-1.071525,-.1777132,.807659,9.925865,-3.324623,-.6367437,.2844581,2.248384,.6544022,-1.218818,-.2952382,-13.45975,13.47153,-.006814585,.5079068,.119723,3.776949,.5836961,-1.409868,-.511433,2.776539,-2.039001,-.02673769,.4145288,.0007829342,2.275883,.6629691,-1.069151,-.09434247,.7293972,-1.222473,-.1533461,2.160357,.04626837,3.852415,.859357,-1.021306,-.1149551,-1.108414,4.178343,.4013665,-2.222814,.6929462,1.392652,.4401662,-1.074251,-.2224002,1.372356,-8.858704,-3.92266,3.020018,-.01458724,1.511186,.8288064,-1.062048,-.1526582,.4921067,14.85522,-3.229936,-.8426604,.3916243,2.678994,.6689264,-1.257023,-.33647,-15.27795,15.04223,.002717715,.302991,.1636851,3.561663,.5283161,-1.635124,-.7329993,3.523939,-2.566337,-.01902543,.5505483,-.06242176,1.065992,.6654236,-.9295823,.04845834,-.299299,-.2001327,-.08019339,1.807806,.09020277,5.095372,.8639936,-1.09374,-.2148608,-.521624,2.119777,.09506454,-1.831439,.6961204,.1102084,.4384319,-1.044181,-.1849257,.9071246,-4.648901,-2.279385,2.356502,-.04169147,1.932557,.829655,-1.061451,-.1458745,.2952267,8.967214,-3.726228,-.5022316,.5684877,3.102347,.6658443,-1.332391,-.4127769,-9.328643,9.046194,.003457775,.3377425,.1530909,3.301209,.4997917,-1.932002,-.9947777,-2.042329,3.58694,-.05642182,.8130478,-.08195988,.1118294,.5617231,-.8707374,.1286999,1.820054,-4.674706,.003317471,.5919018,.1975278,6.686519,.9631727,-1.070378,-.3030579,-.9041938,6.200201,.1232207,-.3650628,.5029403,-2.903162,.3811408,-1.063035,-.1637545,.5853072,-7.889906,-1.200641,1.035018,.1192093,3.267054,.8416151,-1.053655,-.1562286,.2423683,11.28575,-4.363262,-.0731416,.5642088,2.514023,.6670457,-1.366112,-.4718287,-7.876222,7.7469,-.009182309,.4716076,.08320252,3.165603,.5392334,-2.468204,-1.33634,-5.386723,7.072672,-.08329266,.8636876,-.01978177,-.1326218,.2979222,-.9653522,-.02373416,1.81025,-6.467262,.1410706,-.4753717,.3003095,6.551163,1.151083,-.8943186,-.2487152,-.230896,8.512648,.1298402,1.034705,.2303509,-3.924095,.2982717,-1.146999,-.2318784,.08992419,-9.933614,-.886092,-.03071656,.2852012,3.046199,.8599001,-1.032399,-.1645145,.2683599,13.27701,-4.40767,.07709869,.4951727,1.957277,.6630943,-1.46907,-.6135092,-6.506263,6.661315,-.03835383,.7150413,.007784318,2.820577,.6756784,-2.501583,-1.247404,-15.23462,16.33191,-.01204803,.5896471,-.02002023,1.144647,.06177874,-2.438672,-1.127291,5.731172,-10.2135,.0616561,-.7752641,.4708254,4.176847,1.200881,-.1513427,.09792731,-1.612349,9.814289,.05188921,1.716403,-.07039255,-2.815115,.3291874,-1.318511,-.3650554,.4221268,-9.294529,-.0439752,-.8100625,.3742719,1.834166,.822345,-1.016009,-.1820264,.1278426,11.82696,-4.801528,.4947899,.4660378,1.601254,.6702359,-1.84131,-.9781779,-4.610903,4.824662,-.05100806,.6463776,-6377724e-12,2.216875,.861853,-2.376373,-1.108657,-14.89799,15.46458,.04091025,.0976178,-.01048958,2.165834,-.1609171,-4.710318,-2.261963,6.947327,-10.34828,-.1325542,.7508674,.2247553,2.873142,1.2971,.216375,-.1944345,-2.43786,10.11314,.44505,.3111492,.2751323,-1.627906,.2531213,-1.258794,-.3524641,.8425444,-10.85313,-1.154381,-.4638014,-.002781115,.4344498,.8507091,-1.018938,-.1804153,-.06354054,15.7315,-4.386999,.6211115,.5294648,1.580749,.6586655,-1.116416,-.1917524,-10.68233,12.22221,-.03668978,1.054022,.01592132,3.180583,.562737,-1.132341,-.1671286,5.976499,-4.227366,-.09542489,.8664938,.008351793,4.876068,.4492779,-1.087635,-.3173679,.4314407,1.100555,-.4410057,1.677253,-.03005925,-4.201249,1.070902,-1.083031,-.08847705,1.291773,.4546776,.3091894,.726176,.04203659,5.990615,.3704756,-1.057899,-.2246706,2.329563,-1.219656,-5.33526,.8545378,-.03906209,-.9025499,.7797348,-1.073305,-.1522553,1.767063,1.90428,-3.101673,.3995856,.02905192,2.563977,.5753067,-1.113674,-.1759694,-9.754125,10.87391,-.03841093,.9524272,.05680219,4.227034,.6029571,-1.126496,-.1680281,5.332352,-4.575579,-.06761755,.3295335,.1194896,5.570901,.4536185,-1.103074,-.2681801,.06571479,2.396522,-.455128,2.466331,-.1232022,-3.023201,1.086379,-1.053299,-.02697173,.8379121,-.9681458,.5890692,-.4872027,.2936929,7.510139,.3079122,-1.079553,-.2710448,2.462379,-.3713554,-8.534512,1.828242,-.1686398,-1.96134,.8941077,-1.069741,-.1396394,1.657868,3.236313,-2.706344,-.2948122,.1314816,2.868457,.5413403,-1.131649,-.1954455,-7.751595,8.685861,-.04910871,.8992952,.04710143,4.254818,.6821116,-1.156689,-.1884324,3.163519,-3.091522,-.06613927,-.02575883,.1640065,6.073643,.4453468,-1.079224,-.2621389,.9446437,1.448479,-.3969384,2.626638,-.08101186,-3.016355,1.076295,-1.080832,.01033057,-.3500156,-.03281419,.5655512,-1.156742,.453471,8.774122,.2772869,-1.051202,-.2679975,2.719109,-2.190316,-6.878798,2.250481,-.2030252,-2.026527,.9701096,-1.089849,-.1598589,1.564748,6.869187,-3.05367,-.6110435,.1644472,2.370452,.551177,-1.171419,-.2429746,-8.991334,9.571216,-.02772861,.6688262,.07683478,3.785611,.6347635,-1.228554,-.2917562,2.753986,-2.49178,-.04663434,.3118303,.07546506,4.463096,.5955071,-1.093124,-.2447767,.9097406,.5448296,-.2957824,2.024167,-.0005152333,-1.069081,.9369565,-1.056994,.01569507,-.8217491,1.870818,.706193,-1.483928,.5978206,6.864902,.3673332,-1.054871,-.2758129,2.712807,-5.95011,-6.554039,2.447523,-.1895171,-1.454292,.9131738,-1.100218,-.1746241,1.438505,11.15481,-3.266076,-.8837357,.19701,1.991595,.5907821,-1.207267,-.291361,-11.03767,11.40724,-.014168,.5564047,.08476262,3.371255,.6221335,-1.429698,-.5374218,2.837524,-2.221936,-.02422337,.09313758,.0719025,1.869022,.5609035,-1.002274,-.0697281,.4031308,-.3932997,-.1521923,2.390646,-.0689399,2.999661,1.017843,-1.081168,-.1178666,-.496808,3.919299,.6046866,-2.440615,.7891538,2.140835,.274047,-1.050727,-.2307688,2.276396,-9.454407,-5.505176,2.99262,-.2450942,.6078372,.9606765,-1.103752,-.1810202,1.375044,15.89095,-3.438954,-1.265669,.2475172,1.680768,.5978056,-1.244324,-.3378542,-11.11001,11.37784,-.007896794,.4808023,.09249904,3.025816,.5880239,-1.593165,-.7027621,2.220896,-1.437709,-.01534738,.06286958,.06644555,1.091727,.547008,-.9136506,.01344874,.7772636,-1.209396,-.1408978,2.433718,-.1041938,3.791244,1.037916,-1.134968,-.1803315,-.9267335,4.57667,.6851928,-2.805,.8687208,1.161483,.2571688,-1.017037,-.2053943,2.36164,-9.887818,-5.122889,3.287088,-.2594102,.8578927,.959234,-1.118723,-.1934942,1.226023,16.7414,-3.277335,-1.629809,.2765232,1.637713,.6113963,-1.314779,-.4119915,-12.4115,12.41578,.002344284,.2980837,.1414613,2.781731,.4998556,-1.926199,-1.020038,2.5692,-1.081159,-.02266833,.3588668,.008750078,-.2452171,.4796758,-.7780002,.1850647,.04445456,-2.409297,-.07816346,1.54679,-.02807227,5.998176,1.132396,-1.179326,-.357833,-.2392933,6.467883,.5904596,-1.869975,.8045839,-2.498121,.1610633,-1.009956,-.1311896,1.726577,-12.19356,-3.466239,2.343602,-.2252205,2.573681,1.027109,-1.11246,-.2063093,1.233051,20.58946,-4.578074,-1.145643,.3160192,1.420159,.5860212,-1.371689,-.4914196,-10.7661,11.07405,-.01485077,.5936218,.03685482,2.599968,.6002204,-2.436997,-1.377939,.02130141,1.079593,-.01796232,-.03933248,.1610711,-.6901181,.1206416,-.8743368,.0733137,.8734259,-3.743126,-.03151167,1.297596,-.07634926,6.532873,1.435737,-.9810197,-.3521634,-.2855205,7.134674,.6839748,-1.394841,.6952036,-4.633104,-.02173401,-1.122958,-.1691536,1.38236,-11.02913,-2.608171,1.865111,-.1345154,3.112342,1.094134,-1.075586,-.2077415,1.171477,17.9327,-4.656858,-1.036839,.3338295,1.042793,.5739374,-1.465871,-.6364486,-8.833718,9.34365,-.032236,.7552848,-3121341e-12,2.249164,.8094662,-2.448924,-1.270878,-4.823703,5.853058,-.02149127,.03581132,-.001230276,.4892553,-.1597657,-2.419809,-1.071337,1.575648,-4.98358,.009545185,.5032615,.4186266,4.634147,1.433517,-.1383278,-.02797095,-.1943067,6.679623,.411828,-.2744289,-.02118722,-4.337025,.1505072,-1.341872,-.2518572,1.027009,-6.527103,-1.081271,1.015465,.2845789,2.470371,.927812,-1.04064,-.2367454,1.100744,8.827253,-4.560794,-.7287017,.2842503,.6336593,.6327335,-1.877993,-1.025135,-4.311037,4.715016,-.04711631,.6335844,-7665398e-12,1.788017,.9001409,-2.28154,-1.137668,-10.36869,11.36254,.01961739,-.09836174,-.006734567,1.320918,-.2400807,-4.904054,-2.315781,5.735999,-8.626257,-.1255643,1.545446,.139686,2.972897,1.429934,.4077067,-.1833688,-2.450939,9.119433,.4505361,-1.340828,.397369,-1.78537,.09628711,-1.296052,-.3250526,1.813294,-10.31485,-1.38869,1.239733,-.08989196,-.3389637,.963956,-1.062181,-.2423444,.7577592,15.66938,-4.462264,-.574281,.3262259,.9461672,.6232887],[-1.127942,-.1905548,-12.52356,13.75799,-.03624732,1.055453,.01385036,4.17697,.5928345,-1.15526,-.1778135,6.216056,-5.254116,-.08787445,.8434621,.04025734,6.195322,.3111856,-1.125624,-.3217593,.5043919,1.686284,-.3536071,1.476321,-.07899019,-4.522531,1.271691,-1.081801,-.1033234,.999555,.007482946,-.06776018,1.463141,.09492021,5.612723,.1298846,-1.07532,-.2402711,2.141284,-1.203359,-4.945188,1.437221,-.0809675,-1.028378,1.004164,-1.073337,-.1516517,1.639379,2.304669,-3.214244,1.286245,.05613957,2.480902,.4999363,-1.128399,-.1857793,-10.89863,11.72984,-.03768099,.9439285,.04869335,4.845114,.6119211,-1.114002,-.139928,4.9638,-4.6855,-.07780879,.4049736,.1586297,7.770264,.3449006,-1.185472,-.3403543,.6588322,1.133713,-.4118674,2.061191,-.1882768,-4.372586,1.22353,-1.002272,.02000703,.07073269,1.485075,.5005589,.4301494,.3626541,7.921098,.1574766,-1.121006,-.3007777,2.242051,-4.571561,-7.761071,2.053404,-.1524018,-1.886162,1.018208,-1.058864,-.1358673,1.389667,8.633409,-3.437249,.7295429,.15147,2.842513,.5014325,-1.144464,-.2043799,-10.20188,10.71247,-.03256693,.7860205,.06872719,4.824771,.6259836,-1.170104,-.2118626,4.391405,-4.1989,-.07111559,.3890442,.1024831,6.282535,.5365688,-1.129171,-.255288,.2238298,.7314295,-.356273,1.881931,-.03078716,-1.03912,.9096301,-1.042294,.004450203,-.5116033,2.627589,.6098996,-.1264638,.4325281,7.080503,.4583646,-1.082293,-.2723056,2.065076,-8.143133,-7.892212,2.142231,-.0710624,-1.122398,.8338505,-1.071715,-.1426568,1.095351,17.29783,-3.851931,.4360514,.211444,2.970832,.5944389,-1.195909,-.2590449,-11.91037,12.07947,-.01589842,.6297846,.09054772,4.285959,.5933752,-1.245763,-.3316637,4.29366,-3.694011,-.04699947,.4843684,.02130425,4.097549,.6530809,-1.148742,-.1902509,-.2393233,-.2441254,-.2610918,1.846988,.03532866,2.660106,.8358294,-1.01608,-.0744496,-.5053436,4.388855,.6054987,-1.2083,.5817215,2.54357,.4726568,-1.072027,-.210144,1.518378,-10.60119,-6.016546,2.649475,-.05166992,1.571269,.8344622,-1.072365,-.1511201,.747801,19.00732,-3.950387,-.3473907,.3797211,2.782949,.6296808,-1.239423,-.3136289,-13.511,13.49468,-.007070423,.5012315,.1106008,3.803619,.5577948,-1.452524,-.5676944,2.993153,-2.277288,-.02168954,.305672,.01152338,1.852697,.6427228,-1.061421,-.04590521,.6057022,-1.096835,-.1504952,2.344921,-.05491832,5.268322,.9082253,-1.042373,-.1769498,-1.075388,3.831712,.315414,-2.416458,.7909032,-.01492892,.3854049,-1.064159,-.1892684,1.438685,-8.166362,-3.616364,3.275206,-.1203825,2.039491,.8688057,-1.07012,-.1569508,.412476,13.99683,-3.547085,-1.046326,.4973825,2.791231,.6503286,-1.283579,-.3609518,-13.35397,13.15248,-.0004431938,.3769526,.1429824,3.573613,.4998696,-1.657952,-.7627948,1.958222,-.7949816,-.02882837,.5356149,-.05191946,.8869955,.626332,-.95276,.06494189,.5361303,-2.12959,-.0925863,1.604776,.0506777,6.376055,.9138052,-1.080827,-.252312,-.7154262,4.120085,.1878228,-1.492158,.6881655,-1.446611,.4040631,-1.054075,-.1665498,.9191052,-6.636943,-1.894826,2.10781,-.03680499,2.655452,.841384,-1.061127,-.1448849,.2667493,10.34103,-4.285769,-.3874504,.5998752,3.132426,.6652753,-1.347345,-.4287832,-9.305553,9.133813,-.003173527,.3977564,.115142,3.320564,.4998134,-1.927296,-.9901372,-2.593499,4.087421,-.05833993,.8158929,-.04681279,.2423716,.4938052,-.9470092,.07325237,2.064735,-5.16754,-.01313751,.4832169,.1126295,6.970522,1.035022,-1.022557,-.2762616,-.9375748,6.696739,.2200765,-.1133253,.5492505,-3.109391,.3321914,-1.087444,-.1836263,.6225024,-8.576765,-1.107637,.7859427,.09910909,3.112938,.8596261,-1.051544,-.1546262,.2371731,12.00502,-4.527291,.07268862,.5571478,2.532873,.6662,-1.375576,-.4840019,-8.12129,8.05814,-.01445661,.5123314,.05813321,3.203219,.5442318,-2.325221,-1.241463,-7.06343,8.741369,-.0782995,.8844273,-.03471106,.1740583,.2814079,-1.2287,-.2013412,2.949042,-7.371945,.1071753,-.249197,.2265223,6.391504,1.172389,-.7601786,-.1680631,-.7584444,8.541356,.08222291,.6729633,.3206615,-3.70094,.2710054,-1.191166,-.2672347,.2927498,-9.713613,-.4783721,.2352803,.2161949,2.691481,.8745447,-1.030135,-.1653301,.2263443,12.96157,-4.650644,.007055709,.5091975,2.00037,.6603839,-1.508018,-.6460933,-6.402745,6.545995,-.0375032,.6921803,.003309819,2.797527,.6978446,-2.333308,-1.167837,-17.46787,18.6863,-.008948229,.5621946,-.03402626,1.217943,.01149865,-2.665953,-1.226307,7.169725,-11.59434,.0358342,-.3074378,.3412248,4.422122,1.283791,-.09705116,.08312991,-2.160462,10.28235,.03543357,1.032049,.105831,-2.972898,.2418628,-1.329617,-.3699557,.5560117,-9.730113,.09938865,-.3071488,.2510691,1.777111,.8705142,-1.019387,-.1893247,.1194079,12.39436,-4.799224,.2940213,.4841268,1.529724,.6582615,-1.896737,-1.005442,-6.411032,6.54822,-.03227596,.5717262,-8115192e-12,2.296704,.9000749,-2.411116,-1.225587,-17.53629,18.29393,.01247555,.2364616,-.005114637,1.603778,-.2224156,-4.707121,-2.074977,7.9423,-11.32407,-.05415654,.5446811,.1032493,4.010235,1.369802,.1010482,-.4013305,-2.674579,9.779409,.1782506,.7053045,.4200002,-2.400671,.1953165,-1.243526,-.3391255,.8848882,-9.789025,-.3997324,-.9546227,-.1044017,.6010593,.8714462,-1.014633,-.1730009,-.07738934,13.90903,-4.847307,1.076059,.5685743,1.572992,.6561432,-1.122998,-.1881183,-10.30709,11.58932,-.04079495,.9603774,.03079436,4.009235,.5060745,-1.13479,-.1539688,5.478405,-4.21727,-.1043858,.7165008,.01524765,6.473623,.4207882,-1.134957,-.3513318,.7393837,1.354415,-.4764078,1.690441,-.0549264,-5.563523,1.145743,-1.058344,-.05758503,1.16823,.3269824,.1795193,.7849011,.07441853,6.904804,.281879,-1.075194,-.2355813,2.463685,-1.536505,-7.505771,.9619712,-.06465851,-1.355492,.8489847,-1.07903,-.1465328,1.773838,2.310131,-3.136065,.3507952,.04435014,2.819225,.5689008,-1.125833,-.1870849,-9.555833,10.59713,-.04225402,.9164663,.04338796,4.40098,.6056119,-1.12744,-.1551891,4.755621,-4.408806,-.07851763,.2268284,.146007,7.048003,.3525997,-1.143788,-.3170178,.5480669,2.04183,-.4532139,2.302233,-.1887419,-4.489221,1.250967,-1.032849,.007376031,.5666073,-.2312203,.4862894,-.1748294,.357287,8.380522,.1302333,-1.093728,-.2786977,2.641272,-1.507494,-8.731243,1.684055,-.2023377,-2.176398,1.013249,-1.076578,-.1456205,1.693935,2.945003,-2.822673,-.2520033,.1517034,2.649109,.5179094,-1.146417,-.2119353,-7.187525,8.058599,-.05256438,.8375733,.03887093,4.222111,.6695347,-1.173674,-.2067025,2.899359,-2.804918,-.08473899,.003944225,.1340641,6.160887,.4527141,-1.090098,-.2599633,.9180856,1.09271,-.4215019,2.42766,-.09277667,-2.123523,1.058159,-1.08446,.008056181,-.245351,.6619567,.4668118,-.9526719,.4648454,8.001572,.3054194,-1.053728,-.2765784,2.792388,-3.489517,-8.150535,2.195757,-.2017234,-2.128017,.9326589,-1.099348,-.1593939,1.568292,7.247853,-2.933,-.5890481,.172444,2.433484,.5736558,-1.185983,-.2581184,-7.761056,8.317053,-.03351773,.6676667,.05941733,3.820727,.6324032,-1.268591,-.3398067,2.348503,-2.023779,-.05368458,.1083282,.08402858,3.910254,.5577481,-1.071353,-.1992459,.7878387,.1974702,-.3033058,2.335298,-.08205259,.7954454,.9972312,-1.089513,-.03104364,-.5995746,2.330281,.6581939,-1.821467,.6679973,5.090195,.3125161,-1.040214,-.2570934,2.660489,-6.506045,-7.053586,2.763153,-.2433632,-.7648176,.9452937,-1.116052,-.1831993,1.457694,11.63608,-3.216426,-1.045594,.2285002,1.817407,.5810396,-1.230134,-.3136264,-8.909301,9.145006,-.01055387,.4467317,.1016826,3.342964,.563384,-1.442907,-.5593147,2.156447,-1.241657,-.0351213,.3050274,.01797175,1.742358,.5977153,-1.027627,-.06481539,.4351975,-1.051677,-.2030672,1.942684,-.03615993,4.050266,.9801624,-1.08211,-.1578209,-.3397511,4.163851,.6650368,-1.84173,.7062544,.6789881,.3172623,-1.047447,-.197756,2.183364,-8.805249,-5.483962,2.551309,-.177964,1.519501,.9212536,-1.111853,-.1935736,1.394408,13.92405,-3.46543,-1.068432,.2388671,1.455336,.6233425,-1.262238,-.3546341,-10.08703,10.20084,-.001852187,.353758,.1239199,3.056093,.5132052,-1.61381,-.7355585,2.760123,-1.685253,-.02517552,.2914258,.004743448,.8689596,.5674192,-.9462336,.02950767,-.2613816,-.7398653,-.1315558,1.901042,-.06447844,4.969341,1.027342,-1.111481,-.2194054,-.09004538,3.983442,.4871278,-1.965315,.7956121,-.2363225,.2718037,-1.036397,-.1827106,1.964747,-8.870759,-4.208011,2.461215,-.2158905,1.561676,.9436866,-1.113769,-.1947819,1.30072,15.16476,-4.088732,-1.069384,.2836434,1.671451,.6229612,-1.328069,-.4244047,-8.41704,8.552244,-.006813504,.4127422,.09619897,2.854227,.505988,-1.927552,-1.02529,.9529576,.425595,-.03738779,.2584586,.04911004,-.2640913,.4138626,-.8488094,.1435988,.6356807,-2.895732,-.08473961,1.701305,-.1323908,6.499338,1.210928,-1.128313,-.3397048,-.404314,6.265097,.5482395,-2.057614,.8884087,-2.943879,.09760301,-1.039764,-.1494772,1.781915,-11.53012,-3.379232,2.517231,-.2764393,2.588849,1.05212,-1.108447,-.2012251,1.19864,19.25331,-4.423892,-1.257122,.339569,1.48122,.5880175,-1.374185,-.4967434,-7.401318,7.724021,-.02345723,.5979653,.02436346,2.65897,.6014891,-2.310933,-1.29029,-1.301909,2.557806,-.03744449,.08982861,.1090613,-.4398363,.1184329,-1.12473,-.0992183,1.366902,-4.172489,-.05078016,1.393597,-.09323843,6.452721,1.435913,-.8468477,-.2744819,-.43472,6.713362,.6127133,-1.685634,.7360941,-4.535502,-.02920866,-1.165242,-.2008697,1.438778,-10.08936,-2.214771,2.102909,-.1763085,2.859075,1.09347,-1.074614,-.2066374,1.131891,16.30063,-4.801441,-1.11259,.3595785,1.122227,.579461,-1.521515,-.6835604,-5.571044,6.028774,-.04253715,.6875746,-5279456e-12,2.18015,.8487705,-2.240415,-1.171166,-7.182771,8.417068,-.01932866,.1101887,-.01098862,.6242195,-.2393875,-2.712354,-1.19883,3.1802,-6.76813,-.002563386,.7984607,.2764376,4.695358,1.557045,-.03655172,-.02142321,-.913812,7.932786,.3516542,-.7994343,.1786761,-4.208399,.01820576,-1.36861,-.2656212,1.249397,-8.317818,-.8962772,1.423249,.1478381,2.19166,1.007748,-1.041753,-.2453366,1.061102,11.30172,-4.739312,-.9223334,.2982776,.6162931,.6080302,-1.989159,-1.09516,-2.91555,3.275339,-.05735765,.5742174,-7683288e-12,1.7634,.9001342,-2.07002,-1.086338,-10.95898,12.0696,.03780123,-.01774699,-.0005881348,1.333819,-.2605423,-5.249653,-2.38304,6.160406,-9.097138,-.1955319,1.651785,.0006016463,3.021824,1.493574,.4685432,-.2358662,-2.666433,9.685763,.5804928,-1.521875,.5668989,-1.548136,.01688642,-1.296891,-.3449031,1.928548,-11.6756,-1.627615,1.355603,-.1929074,-.6568952,1.009774,-1.067288,-.2410392,.7147961,17.8384,-4.374399,-.6588777,.3329831,1.012066,.6118645],[-1.310023,-.4407658,-36.4034,36.83292,-.008124762,.5297961,.01188633,3.13832,.5134778,-1.4241,-.5501606,-17.5351,18.22769,-.01539272,.6366826,.002661996,2.659915,.4071138,-1.103436,-.1884105,6.425322,-6.910579,-.02019861,.3553271,-.01589061,5.345985,.8790218,-1.1862,-.4307514,-3.957947,5.979352,-.05348869,1.736117,.03491346,-2.692261,.5610506,-1.006038,-.1305995,4.473513,-3.806719,.1419407,-.02148238,-.05081185,3.735362,.535828,-1.078507,-.1633754,-3.812368,4.3817,.02988122,1.754224,.1472376,3.722798,.4999157,-1.333582,-.4649908,-33.59528,34.04375,-.009384242,.5587511,.00572631,3.073145,.5425529,-1.562624,-.7107068,-14.7817,15.59839,-.01462375,.5050133,.02516017,1.604696,.2902403,-.8930158,.04068077,1.373481,-2.342752,-.02098058,.6248686,-.05258363,7.058214,1.150373,-1.262823,-.4818353,889261e-9,1.92312,-.04979718,1.040693,.1558103,-2.85248,.2420691,-.9968383,-.1200648,1.324342,-.9430889,.1931098,.4436916,-.07320456,4.215931,.7898019,-1.078185,-.1718192,-1.720191,2.358918,.02765637,1.260245,.2021941,3.395483,.5173628,-1.353023,-.4813523,-31.0492,31.40156,-.009510741,.554203,.008135471,3.136646,.5215989,-1.624704,-.7990201,-21.67125,22.46341,-.01163533,.5415746,.02618378,1.139214,.3444357,-.798361,.1417476,9.914841,-10.81503,-.01218845,.3411392,-.06137698,7.445848,1.18008,-1.266679,-.4288977,-5.818701,6.986437,-.08180711,1.397403,.2016916,-1.275731,.2592773,-1.009707,-.1537754,3.496378,-3.013726,.242115,-.2831925,.03003395,3.702862,.774632,-1.075646,-.1768747,-1.347762,1.989004,.01375836,1.76481,.1330018,3.230864,.662621,-1.375269,-.5103569,-34.42661,34.78703,-.008460009,.5408643,.004813323,3.016078,.5062069,-1.821679,-.9766461,-19.26488,19.97912,-.009822567,.3649556,.04316092,.893019,.4166527,-.6633542,.1997841,2.395592,-3.117175,-.01080884,.8983814,-.1375825,6.673463,1.115663,-1.30324,-.3612712,.08292959,.3381364,-.06078648,.3229247,.3680987,.7046755,.3144924,-.9952598,-.2039076,.4026851,.2686684,.1640712,.5186341,-.0120552,2.659613,.8030394,-1.098579,-.2151992,.6558198,-74369e-8,-.001421817,1.073701,.1886875,2.536857,.6673923,-1.457986,-.5906842,-38.12464,38.38539,-.006024357,.4741484,.01209223,2.818432,.5012433,-1.835728,-1.003405,-6.848129,7.601943,-.01277375,.4785598,.03366853,1.097701,.4636635,-.8491348,.009466365,-2.685226,2.00406,-.01168708,.6752316,-.1543371,5.674759,1.039534,-1.083379,-.150679,.7328236,-.5095568,-.08609153,.444882,.4174662,1.481556,.3942551,-1.117089,-.3337605,.2502281,.4036323,.2673899,.2829817,.0224245,2.043207,.7706902,-1.071648,-.21262,.6069466,-.00145629,-.551596,1.046755,.1985021,2.290245,.6876058,-1.483903,-.6309647,-43.80213,44.10537,-.005712161,.5195992,.002028428,2.687114,.5098321,-2.053976,-1.141473,.5109183,.08060391,-.01033983,.4066532,.04869627,1.161722,.4039525,-.6348185,.07651292,-10.31327,10.07598,-.02083688,.7359516,-.2029459,5.013257,1.077649,-1.22863,-.1650496,.04077157,-.7189167,-.0509222,.2959814,.5111496,2.540433,.361533,-1.041883,-.3278413,-.06691911,1.307364,.2166663,.3000595,-.003157136,1.389208,.7999026,-1.103556,-.2443602,.4705347,-.0009296482,-.530992,.9654511,.2142587,2.244723,.6839976,-1.555684,-.6962113,-46.47983,46.7427,-.005034895,.475509,-9.502561e-7,2.626569,.5056194,-1.998288,-1.12472,-1.629586,2.187993,-.008284384,.3845258,.0572624,1.185644,.4255812,-1.03257,-.251385,-3.721112,3.506967,-.02186561,.9436049,-.2451412,4.725724,1.039256,-.8597532,.09073332,-2.553741,1.993237,-.04390891,-.2046928,.5515623,1.909127,.3948212,-1.210482,-.4477622,-.2267805,1.219488,.1336186,.6866897,.02808997,1.600403,.7816409,-1.078168,-.2699261,.2537282,.3820684,-.4425103,.5298235,.2185217,1.728679,.6882743,-1.697968,-.8391488,-57.90105,58.1412,-.00340476,.426514,-1796301e-12,2.368442,.5324429,-2.141552,-1.17223,16.77872,-16.4147,-.005732425,.2002199,.06841834,1.485338,.3215763,-1.442946,-.7264245,-9.503706,9.650462,-.02120995,1.419263,-.2893098,3.860731,1.120857,-.5696752,.3411279,-.2931035,-.6512552,-.1068437,-1.085661,.6107549,1.459503,.3210336,-1.313839,-.5921371,-.2332222,1.648196,.2492787,1.381033,-.01993392,.981256,.8316329,-1.087464,-.3195534,.2902095,.3383709,-.8798482,.01494668,.2529703,1.452644,.669387,-2.068582,-1.118605,-50.81598,50.97486,-.003280669,.4067371,-2544951e-12,2.179497,.5778017,-1.744693,-.8537207,22.34361,-22.08318,-.005932616,.1035049,.05742772,1.97788,.2124846,-3.287515,-2.140268,-12.49566,12.40091,-.02409349,1.397821,-.2371627,2.771192,1.170496,.5502311,1.04663,2.193517,-2.2204,-.1064394,-1.017926,.4795457,1.030644,.3177516,-1.719734,-.9536198,-.6586821,1.386361,-.02513065,1.187011,.06542539,.5296055,.808266,-1.0057,-.3028096,.04470957,1.00776,-.8119016,.03153338,.2311321,1.182208,.6824758,-2.728867,-1.580388,-30.79627,30.92586,-.004197673,.3154759,-3897675e-12,1.920567,.6664791,-1.322495,-.7249275,14.7766,-14.68154,-.009044857,.05624314,.06498392,2.047389,.0636754,-6.102376,-3.473018,-9.926071,9.637797,-.01097909,1.103498,-.2424521,2.520748,1.24026,1.351796,1.018588,2.009081,-1.333394,-.1979125,-.3318292,.4476624,.9095235,.2955611,-1.774467,-1.07988,-.0808468,.2577697,-.1149295,.4975303,.002931611,-.3803171,.8002794,-.9898401,-.2542513,-.07530911,1.870355,-1.521918,.2405164,.2964615,1.3348,.6789053,-1.27973,-.4290674,-42.77972,43.43305,-.006541826,.4945086,.01425338,2.685244,.5011313,-1.449506,-.5766374,-16.88496,17.81118,-.01121649,.354502,.02287338,1.904281,.4936998,-1.02198,-.1897574,2.482462,-2.941725,-.01570448,.7532578,-.042568,5.23966,.4983116,-1.162608,-.3428049,3.974358,-1.527935,-.03919201,.8758593,.07291363,-3.455257,.8007426,-.9929985,-.08712006,-.7397313,1.348372,.09511685,.3233584,-.07549148,5.806452,.4990042,-1.084996,-.1739767,.1580475,.908818,.06871433,.5933079,.1188921,3.074079,.4999327,-1.317009,-.4661946,-42.55347,43.12782,-.005727235,.4285447,.02189854,2.60831,.51907,-1.469236,-.6282139,-12.41404,13.48765,-.0120477,.5070285,-.0007280216,1.491533,.3635064,-.9713808,-.08138038,.3709854,-1.041174,-.01814075,.506086,-.02053756,6.161431,1.093736,-1.159057,-.3698074,2.711209,-.6006479,-.04896926,.9273957,.1137712,-3.496828,.2867109,-1.011601,-.0820189,.2105725,.459752,.1478925,.213894,-.0566067,6.057755,.7859121,-1.07802,-.181158,.1646622,.8348426,.1149064,.4985738,.1376605,2.746607,.4999626,-1.325672,-.4769313,-41.11215,41.68293,-.006274997,.4649469,.01119411,2.631267,.5234546,-1.619391,-.8000253,-15.34098,16.32706,-.01012023,.4242255,.02931597,.8925807,.3314765,-.7356979,.1368406,2.972579,-3.535359,-.01318948,.460762,-.07182778,6.2541,1.236299,-1.316217,-.4194427,.03489902,1.289849,-.0475596,1.138222,.1975992,-.8991542,.2290572,-.9502188,-.1172703,1.405202,-.3061919,.1058772,-.3760592,-.01983179,3.562353,.7895959,-1.100117,-.1900567,.492503,.5250225,.1576804,1.042701,.07330743,2.796064,.6749783,-1.354183,-.5130625,-42.19268,42.71772,-.005365373,.4136743,.01235172,2.520122,.5187269,-1.741434,-.9589761,-8.230339,9.296799,-.009600162,.4994969,.02955452,.3667099,.3526999,-.6917347,.2154887,-.8760264,.2334121,-.01909621,.4748033,-.1138514,6.51536,1.225097,-1.293189,-.42187,1.620952,-.7858597,-.0376941,.6636786,.3364945,-.5341017,.2128347,-.9735521,-.1325495,1.007517,.2598258,.06762169,.001421018,-.06915987,3.185897,.8641956,-1.0948,-.1962062,.5755591,.2906259,.2625748,.7644049,.1347492,2.677126,.646546,-1.393063,-.5578338,-41.85249,42.33504,-.00543564,.4743765,.007422477,2.442801,.5211707,-1.939487,-1.128509,-8.974257,9.978383,-.007965597,.294883,.04436763,.2839868,.3440424,-.6011562,.2354877,-3.07982,2.585094,-.02002701,.7793909,-.1598414,5.834678,1.202856,-1.315676,-.3903446,1.7019,-1.304609,-.01045121,.2747707,.4143967,.3197102,.263758,-.9618628,-.1625841,1.187138,.1497802,-5590954e-12,.03178475,-.04153145,2.496096,.8195082,-1.111554,-.2365546,.7831875,.2018684,.2074369,.7395978,.122573,1.876478,.6821167,-1.427879,-.5994879,-35.31016,35.81581,-.006431497,.4554192,.0007348731,2.334619,.5233377,-1.998177,-1.206633,-21.4651,22.42237,-.005857596,.2755663,.06384795,.1358244,.3328437,-.644063,.2058571,2.155499,-2.587968,-.01840023,.8826555,-.2222452,5.847073,1.228387,-1.229071,-.3360441,-.3429599,.6179469,.00202961,.08899319,.5041624,.1882964,.225204,-1.022905,-.2101621,1.915689,-.6498794,-.03463651,.08954605,-.06797854,2.417705,.8568618,-1.082538,-.2007723,.4731009,.4077267,.1324289,.651488,.1702912,2.309383,.6600895,-1.472139,-.6499815,-34.28465,34.69659,-.005747023,.4174167,.001688597,2.323046,.5395191,-2.161176,-1.353089,-22.26827,23.29138,-.005583808,.2364793,.06096656,.001944666,.2861624,-.6593044,.1393558,4.698373,-5.193883,-.0199839,1.095635,-.2391254,5.598103,1.236193,-1.195717,-.2972715,.04648953,.3024588,.005003313,-.3754741,.5247265,-.1381312,.2493896,-1.020139,-.2253524,.3548437,.7030485,-.02107076,.4581395,-.03243757,2.453259,.8323623,-1.09877,-.243578,.8761614,.1941613,-.1990692,.3761139,.1657412,1.590503,.6741417,-1.648007,-.8205121,-44.35106,44.79801,-.004181353,.385483,-1842385e-12,2.000281,.5518363,-2.140986,-1.282239,-3.979213,4.672459,-.005008582,.242192,.06253602,.6612713,.2555851,-1.300502,-.5137898,.5179821,-.4032341,-.02066785,1.087929,-.2615309,4.225887,1.229237,-.696334,.0924106,.06936356,-.3588571,-.05461843,-.5616643,.5484166,-.04776267,.2414935,-1.233179,-.4325498,.6479813,.8368356,.2458875,.6464752,-.02897097,1.561773,.8518598,-1.051023,-.253369,1.004294,.3028083,-1.520108,.1607013,.1619975,1.131094,.6706655,-1.948249,-1.097383,-44.53697,44.94902,-.003579939,.3491605,-2500253e-12,1.740442,.6188022,-2.154253,-1.209559,4.144894,-3.562411,-.005638843,.1067169,.07594858,1.00528,.1072543,-2.513259,-1.507208,-1.602979,1.404154,-.00556075,1.24049,-.2852117,3.485252,1.349321,-.07832214,.3655626,.3856288,.6867894,-.1609523,-.6704306,.5357301,-.6457935,.1479503,-1.354784,-.5454375,.8797469,-1.466514,.713442,.5934903,-.02911178,.8643737,.9030724,-1.048324,-.2738736,.8783074,3.246188,-4.435369,.1251791,.1783486,1.064657,.6522878,-2.770408,-1.618911,-25.04031,25.31674,-.004239279,.3241013,-3764484e-12,1.586843,.7035906,-1.9135,-1.144014,-10.80587,11.53677,-.01003197,.1577515,.05217789,1.225278,.005172771,-5.293208,-2.876463,2.087053,-3.201552,.003892964,.532393,-.2034512,2.61776,1.273597,.906034,.3773409,-.6399945,3.213979,-.09112172,.6494055,.395328,.5047796,.2998695,-1.482179,-.677831,1.161775,-3.004872,.4774797,-.4969248,-.003512074,-1.30719,.7927378,-.9863181,-.1803364,.5810824,4.58057,-3.863454,.5328174,.2272821,1.771114,.6791814]],Dd=[[1.560219,1.417388,1.206927,10.91949,5.931416,7.304788,1.533049,1.560532,.3685059,13.5504,5.543711,7.792189,1.471043,1.746088,-.9299697,17.20362,5.473384,8.336416,1.355991,2.109348,-3.295855,22.64843,5.454607,9.304656,1.244963,2.547533,-5.841485,27.56879,5.576104,10.43287,1.175532,2.784634,-7.212225,29.75347,6.47298,10.92331,1.082973,3.118094,-8.934293,31.86879,8.473885,11.74019,.96925,3.349574,-10.0381,31.47654,13.38931,12.72547,.8547044,3.151538,-9.095567,25.54995,22.73219,14.10398,.758034,2.311153,-5.170814,12.29669,36.86529,15.98882,1.664273,1.574468,1.422078,9.768247,14.47338,16.44988,1.638295,1.719586,.5786675,12.39846,14.15419,17.28605,1.572623,1.921559,-.7714802,16.09246,14.20954,18.25908,1.468395,2.21197,-2.845869,20.75027,15.24822,19.37622,1.355047,2.556469,-4.96092,24.60237,16.4836,20.65648,1.291642,2.742036,-6.061967,26.02002,18.19144,21.16712,1.194565,2.97212,-7.295779,26.91805,21.2488,22.01819,1.083631,3.047021,-7.766096,24.96261,27.44264,22.91875,.9707994,2.736459,-6.308284,17.6086,37.76291,23.9215,.8574294,1.865155,-2.364707,4.337793,50.92831,25.23432],[1.632341,1.39523,1.375634,12.38193,5.921102,7.766508,1.597115,1.554617,.3932382,15.05284,5.725234,8.158155,1.522034,1.844545,-1.322862,19.18382,5.440769,8.837119,1.403048,2.290852,-4.013792,24.851,5.521888,9.845547,1.286364,2.774498,-6.648221,29.64151,5.923777,10.97075,1.213544,3.040195,-8.092676,31.86082,6.789782,11.58899,1.122622,3.347465,-9.649016,33.43824,9.347715,12.31374,1.007356,3.543858,-10.5352,32.39842,14.83962,13.31718,.8956642,3.2787,-9.254933,25.57923,24.89677,14.76166,.7985143,2.340404,-4.928274,11.41787,39.61501,16.82448,1.745162,1.639467,1.342721,11.66033,14.90124,17.74031,1.708439,1.819144,.2834399,14.48066,14.59214,18.58679,1.63172,2.094799,-1.378825,18.43198,14.63173,19.62881,1.516536,2.438729,-3.624121,22.98621,15.99782,20.70027,1.405863,2.785191,-5.705236,26.45121,17.6833,21.91903,1.344052,2.951807,-6.683851,27.44271,19.85706,22.29452,1.245827,3.182923,-7.82296,27.91395,23.27254,23.1591,1.132305,3.202593,-8.008429,25.21093,30.00014,24.05306,1.02033,2.820556,-6.238704,17.09276,40.77916,25.09949,.903157,1.863917,-1.955738,3.032665,54.3429,26.4178],[1.168084,2.156455,-3.980314,19.89302,13.28335,14.35621,1.135488,2.294701,-4.585886,20.90208,13.4784,14.67658,1.107408,2.382765,-5.112357,21.47823,14.93128,14.60882,1.054193,2.592891,-6.115,22.68967,16.35672,15.18999,1.006946,2.70542,-6.69893,22.9183,18.34324,15.70651,.9794044,2.74244,-6.805283,22.25271,20.50797,15.6313,.9413577,2.722009,-6.760707,20.98242,23.42588,16.05011,.8917923,2.59278,-6.152635,17.74141,28.58324,16.5791,.8288391,2.153434,-4.118327,10.78118,36.8171,17.38139,.7623528,1.418187,-.8845235,.7590129,46.29859,19.21657,1.352858,2.048862,-2.053393,14.05874,30.45344,30.4443,1.330497,2.126497,-2.466296,14.67559,30.90738,30.69707,1.286344,2.200436,-2.877228,14.92701,32.36288,30.77223,1.234428,2.289628,-3.404699,14.99436,34.6839,30.84842,1.17866,2.306071,-3.549159,14.11006,37.54188,30.7973,1.151366,2.333005,-3.728627,13.63374,39.05894,30.92599,1.101593,2.299422,-3.565787,11.96745,41.88472,31.02755,1.038322,2.083539,-2.649585,8.037389,47.00869,30.65948,.9596146,1.67147,-.8751538,1.679772,53.45784,30.5452,.8640731,.9858301,1.854956,-6.798097,59.36468,31.10255]],Nd={getTableValue:function(e,t,n,i,o){return Bd[e][540*t+54*(n-1)+9*i+o]},getTableValueRad:function(e,t,n,i){return Dd[e][60*t+6*(n-1)+i]}};function Od(e,t,n,i,o){return Ud(e).reduce((function(e,r,a){return e+r*Nd.getTableValue(t,n,i,a,o)}),0)}function Fd(e,t,n,i){return Ud(e).reduce((function(e,o,r){return e+o*Nd.getTableValueRad(t,n,i,r)}),0)}function Ud(e){var t=Math.pow(2*e/Math.PI,1/3);return[Math.pow(1-t,5),5*Math.pow(1-t,4)*t,10*Math.pow(1-t,3)*Math.pow(t,2),10*Math.pow(1-t,2)*Math.pow(t,3),5*(1-t)*Math.pow(t,4),Math.pow(t,5)]}var zd={getDistParams:function(e,t,n,i){for(var o=new Array(9),r=Math.trunc(e),a=e-r,s=0;s<9;s++){var l=Od(n,i,0,r,s),c=Od(n,i,1,r,s);if(o[s]=(1-t)*(1-a)*l+t*(1-a)*c,10!=r){var u=Od(n,i,0,r+1,s),d=Od(n,i,1,r+1,s);o[s]+=(1-t)*a*u+t*a*d}}return o},getRadiance:function(e,t,n,i){var o=Math.trunc(e),r=e-o,a=(1-t)*(1-r)*Fd(n,i,0,o)+t*(1-r)*Fd(n,i,1,o);10!=o&&(a+=(1-t)*r*Fd(n,i,0,o+1)+t*r*Fd(n,i,1,o+1));return a}};class Vd extends Rd{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=e*a,l=s-a,c=(n-t)/(i-t),u=1-c;for(let e=0;e!==a;++e)o[e]=r[l+e]*u+r[s+e]*c;return o}}var Gd=[[.1787,-1.463,-.3554,.4275,-.0227,5.3251,.1206,-2.5771,-.067,.3703],[-.0193,-.2592,-.0665,8e-4,-4e-4,.2125,-.0641,-.8989,-.0033,.0452],[-.0167,-.2608,-.095,.0092,-.0079,.2102,-.0441,-1.6537,-.0109,.0529]],kd=[[4.0453,-4.971,-.2155,2.4192],[.00166,-.00375,.00209,0,-.02903,.06377,-.03202,.00394,.11693,-.21196,.06052,.25886],[.00275,-.0061,.00317,0,-.04214,.0897,-.04153,.00516,.15346,-.26756,.0667,.26688]],Qd=function(e,t,n){return Gd[e][2*t+n]},Wd=function(e){return kd[e]};function Hd(e,t,n){return(1+e[0]*Math.exp(e[1]/Math.cos(t)))*(1+e[2]*Math.exp(e[3]*n)+e[4]*Math.pow(Math.cos(n),2))}var jd={getDistParams:function(e,t){for(var n=new Array(5),i=0;i<5;i++)n[i]=Qd(t,i,0)*e+Qd(t,i,1);return n},getZenithParams:function(e,t,n){switch(n){case 0:var i=Wd(n),o=new ii(i[0],i[1],i[2],i[3]),r=Math.tan((4/9-e/120)*(Math.PI-2*t)),a=new ii(e*r,r,e,1);return.06*o.dot(a)/Hd(this.getDistParams(e,n),0,t);case 1:case 2:i=Wd(n);var s=Math.pow(t,2),l=Math.pow(t,3),c=i[0]*l+i[1]*s+i[2]*t+i[3],u=i[4]*l+i[5]*s+i[6]*t+i[7],d=i[8]*l+i[9]*s+i[10]*t+i[11];o=new ci(c,u,d);return new ci(Math.pow(e,2),e,1).dot(o)/Hd(this.getDistParams(e,n),0,t)}},getSunIlluminance:function(e,t){var n=[0,0,0];if(e[1]<0)return n;for(var i,o=[.605,.54,.445],r=[12.25,7.5,.3],a=.04608*t-.04586,s=1/(e[1]+.15*Math.pow(93.885-Math.acos(e[1])*(180/Math.PI),-1.253)),l=[1.05513096,.993359745,.903543472],c=0;c<3;c++){var u=Math.exp(.008735*-s*Math.pow(o[c],-4.08)),d=Math.exp(-s*a*Math.pow(o[c],-1.3)),h=Math.exp(.0035*-r[c]*s);n[c]=128e3*l[c]/(.212671*(i=l[c])+.71516*i+.072169*i),n[c]*=u*d*h}return n},getSunIntegral:function(e,t,n,i){var o=e,r=t,a=n;function s(e){return e*e}var l=1-cos(o),c=((s(Math.PI)-2*s(o-r))*cos(o)-s(Math.PI)*cos(r))/(2*(o-r+Math.PI)*(-o+r+Math.PI)),u=a*((.0892351-.00247875*s(a))*sin(a)+cube(a)+24*a+.029745*a*cos(a))/s(s(a)+36);return 2*Math.PI*(l+c+i*u)}};class Yd{constructor(e=1,t=0,n=0){return this.radius=e,this.phi=t,this.theta=n,this}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){const e=1e-6;return this.phi=Math.max(e,Math.min(Math.PI-e,this.phi)),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(nn(t/this.radius,-1,1))),this}clone(){return(new this.constructor).copy(this)}}const Xd=2,Kd=12,qd=14,Zd=23,Jd=10,$d=12,eh=21,th=20,nh=6,ih=8,oh=0,rh=5,ah=2,sh=8,lh=9,ch=10,uh=18,dh=21,hh=22,ph=0,fh=1,mh=3,gh=0,vh=2,Ah=1,_h=0,xh=1,yh=0,bh=0,Ch=0,Mh=3,Sh=8,Eh=15,wh=25,Th=18,Ih=256,Rh=512,Lh=1500/Math.PI,Ph={LAMBERT_AR:2,STANDARD_SURFACE_AR:24,BEVEL_BL:1,BSDF_DIFFUSE_BL:2,BSDF_GLASS_BL:3,BSDF_GLOSSY_BL:2,BSDF_PRINCIPLED_BL:22,"BSDF_PRINCIPLED_<3.0_BL":20,"BSDF_PRINCIPLED_<2.91.0_BL":19,BSDF_REFRACTION_BL:3,BSDF_TRANSLUCENT_BL:1,BUMP_BL:3,"BUMP_BL_<3.2_BL":5,EEVEE_SPECULAR_BL:5,FRESNEL_BL:1,LAYER_WEIGHT_BL:1,SAMPLER_INFO_MY:0,LAMBERT_MY:5,BLINN_MY:5,PHONG_MY:5,PHONG_E_MY:5};class Bh extends Mo{constructor(e){super();const t=this;function n(e,t){const n=e.node(t);n.originData.type;for(let o=0;o<n.originData.inputs.length;o++)i(e,t,n.originData,o)}function i(e,t,n,i,o){if(Oh(e,t,i))return!1;o=o||"Input "+i;const r=n.inputs[i],a={name:n.name+" "+o,type:"",inputs:[],outputs:[]};switch(I(r)){case"float":a.type="VALUE"+n.type.slice(-3),a.outputs.push(r);break;case"vec3":a.type="RGB"+n.type.slice(-3);const e=r.slice();e.push(1),a.outputs.push(e);break;case"vec4":a.type="RGB"+n.type.slice(-3),a.outputs.push(r);break;default:throw new Error("Unsupported group input")}e.addNode({originData:a});const s=new Pd.Edge(e.len()-1,t,0);s.connections=[];const l={from:0,to:i};return s.connections.push(l),e.addEdge(s),!0}function o(e,t,n){const i={inputs:[],outputs:[],removedNodes:[]};i.removedNodes.push(n);const o=Dh(t,"GROUP_INPUT_BL");if(o>-1){i.removedNodes.push(o+e.len());const r=e.findInEdges(n),s=t.findOutEdges(o);for(let e=0;e<r.length;e++){const t=r[e];for(let e=0;e<s.length;e++){const n=s[e];for(let e=0;e<t.connections.length;e++){const o=t.connections[e];for(let e=0;e<n.connections.length;e++){const r=n.connections[e];if(o.to==r.from){let e=a(i.inputs,t.from(),n.to());e||(e=new Pd.Edge(t.from(),n.to(),0),e.connections=[],i.inputs.push(e));const s={from:o.from,to:r.to};e.connections.push(s)}}}}}}const r=Dh(t,"GROUP_OUTPUT_BL");i.removedNodes.push(r+e.len());const s=e.findOutEdges(n),l=t.findInEdges(r);for(let e=0;e<s.length;e++){const t=s[e];for(let e=0;e<l.length;e++){const n=l[e];for(let e=0;e<t.connections.length;e++){const o=t.connections[e];for(let e=0;e<n.connections.length;e++){const r=n.connections[e];if(o.from==r.to){let e=a(i.outputs,n.from(),t.to());e||(e=new Pd.Edge(n.from(),t.to(),0),e.connections=[],i.outputs.push(e));const s={from:r.from,to:o.to};e.connections.push(s)}}}}}return i}function r(e,t){Array.isArray(t)||(t=[t]);let n=0;for(let i=0;i<e.len();i++){const o=e.node(i);for(let e=0;e<t.length;e++){const i=t[e];o.originData.type==i&&n++}}return n}function a(e,t,n){for(let i=0;i<e.length;i++){const o=e[i];if(o.from()==t&&o.to()==n)return o}return null}function s(e,t,n){const i=n.type;let o=e.findInEdges(t);for(let r=0;r<o.length;r++){const a=o[r];let s=e.node(a.from()).originData;for(let d=0;d<a.connections.length;d++){const h=a.connections[d];if("MATERIAL_MX"==i&&c(s.type)&&(h.to==lh?s.reflectMode="MAX_ENV_COORDS_REFLECT":h.to==ch&&(s.reflectMode="MAX_ENV_COORDS_REFRACT")),u(i,h.to)){if("BITMAP_MX"==s.type||"OUTPUT_MAP_MX"==s.type){e.removeEdge(a.from(),a.to()),"OUTPUT_MAP_MX"==s.type&&(s=Nh(e,a.from(),0).originData);const n={originData:{name:s.name+"Bump"+r,type:"BUMP_MX",texture:s.texture,uvIndex:s.uvIndex,inputs:JSON.parse(JSON.stringify(s.inputs)),outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,h.to),r=-1,o=e.findInEdges(t);break}for(let t=0;t<e.len();t++){const i=e.node(t).originData;if(l(i.type)){const o=i.inputs.length-1;Uh(e,a.from(),h.from,t,o),i.inputFactors[o]=n.inputFactors[h.to]}}}}}}function l(e){return!(!c(e)&&"FALLOFF_MX"!=e)}function c(e){return"BITMAP_ENV_MX"==e||"REFLECT_REFRACT_MX"==e}function u(e,t){switch(e){case"BITMAP_ENV_MX":return t==rh;case"FALLOFF_MX":return t==ah;case"MATERIAL_MX":return t==sh;case"PHYSICAL_MX":return t==dh||t==hh;case"REFLECT_REFRACT_MX":return t==ph;default:return!1}}function d(e,t,n){const i=n.blendMode.length,o=e.findInEdges(t),r=e.findOutEdges(t);for(let t=0;t<i;t++){const i={originData:{name:n.name+"Layer"+t,type:"COMPOSITE_LAYER_MX",blendMode:0!=t?n.blendMode[t]:0,opacity:n.opacity[t],inputs:[[0,0,0,0]].concat(n.inputs.slice(2*t,2*t+2)),outputs:[n.outputs[t]]}};e.addNode(i);for(let i=0;i<o.length;i++){const r=o[i];for(let i=0;i<r.connections.length;i++){const o=r.connections[i];o.to==2*t&&n.mapEnabled[t]?Uh(e,r.from(),o.from,e.len()-1,1):o.to==2*t+1&&n.maskEnabled[t]&&Uh(e,r.from(),o.from,e.len()-1,2)}}t>0&&Uh(e,e.len()-2,0,e.len()-1,0)}for(let t=0;t<r.length;t++){const n=r[t];for(let t=0;t<n.connections.length;t++){const i=n.connections[t];Uh(e,e.len()-1,0,n.to(),i.to)}}}function h(e,t,n){const i=n.output,o=e.findInEdges(t),r=e.findOutEdges(t),a={originData:{name:n.name+"Output",type:"OUTPUT_MAP_MX",invert:i.invert,clamp:i.clamp,alphaFromRGB:i.alphaFromRGB,inputs:[[0,0,0,0],i.rgbLevel,i.rgbOffset,i.outputAmount,i.bumpAmount],outputs:[[0,0,0,0]]}};In(i.colorMap)&&(a.originData.colorMap=i.colorMap),e.addNode(a);for(let t=0;t<r.length;t++){const n=r[t];for(let t=0;t<n.connections.length;t++){const i=n.connections[t];Uh(e,e.len()-1,0,n.to(),i.to)}}e.disconnect(t,!1);for(let t=0;t<o.length;t++)e.addEdge(o[t]);Uh(e,t,0,e.len()-1,0),delete n.output}function p(e,t,n){const i=n.inputs.length/4,o=e.findInEdges(t),r=e.findOutEdges(t);for(let t=0;t<i;t++){const i={originData:{name:n.name+"Layer"+t,type:"LAYERED_TEXTURE_LAYER_MY",inputs:[0,[0,0,0]].concat(n.inputs.slice(4*t,4*t+4)),outputs:[0,[0,0,0]]}};e.addNode(i);for(let n=0;n<o.length;n++){const i=o[n];for(let n=0;n<i.connections.length;n++){const o=i.connections[n];o.to==4*t?Uh(e,i.from(),o.from,e.len()-1,2,o.channelMatrix):o.to==4*t+1?Uh(e,i.from(),o.from,e.len()-1,3,o.channelMatrix):o.to==4*t+2?Uh(e,i.from(),o.from,e.len()-1,4,o.channelMatrix):o.to==4*t+3&&Uh(e,i.from(),o.from,e.len()-1,5,o.channelMatrix)}}t>0&&(Uh(e,e.len()-1,0,e.len()-2,0),Uh(e,e.len()-1,1,e.len()-2,1))}for(let t=0;t<r.length;t++){const n=r[t];for(let t=0;t<n.connections.length;t++){const o=n.connections[t];Uh(e,e.len()-i,o.from,n.to(),o.to,o.channelMatrix)}}}function f(e){return e.type.indexOf("uniform")>-1}function m(e){return e.type.indexOf("varying")>-1}function g(e,n){return n=In(n)?n:"color",t.nodeVCAliases[e]||n}function v(e,t,n,i){const o=new Ac(e,t,1,n,i,ni.DEFAULT_MAPPING,he,he,ve,ve);return o.needsUpdate=!0,o}function A(e){return!0===e.isVideoTexture&&e.encoding===Rt?"1":"0"}function _(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+","+B(o)+")","normal"==i&&(r="normalize("+r+")")),r}function x(e,t,n,i,o){let r;const a=[],s=L(n),l=L(i);for(let n=0;n<l;n++){let i=1==l?o:o+"["+n+"]";for(let o=0;o<e.length;o++){const r=e[o],a=t[o];for(let e=0;e<s;e++)a[e][n]&&(i=1==s?r:r+"["+e+"]")}a.push(i)}return r=i+"("+a.join(",")+")",r}function y(e,t,n,i,o,r){for(let a in e.edges){const s=e.edges[a];if(s.to()==t){const t=e.node(s.from());for(let e=0;e<s.connections.length;e++){const a=s.connections[e];if(a.to==n){const e=t.originData.type;"BITMAP_MX"!=e&&"BITMAP_ENV_MX"!=e||"float"!=I(i)?o.push(t.outputs[a.from]):o.push(t.outputs[a.from+1]),a.channelMatrix&&r.push(a.channelMatrix)}}}}}function b(e){return{name:"",type:I(e),value:e}}function C(e,n){const i=Bh.nodeTexUniName(e,n);return{name:i,type:t.nodeTextures[i].isCubeTexture?"uniform samplerCube":"uniform sampler2D",value:n}}function M(e){return{name:"",type:"int",value:e}}function S(e){return E(e?"true":"false")}function E(e){return{name:e,type:"",value:null}}function w(e,t,n){return n=n||e,{name:"_vary_par_"+e,type:"varying "+R(t),value:null,attrBindName:n}}function T(e){return e?1:0}function I(e){return"number"==typeof e?"float":"boolean"==typeof e?"bool":R(e.length)}function R(e){switch(e){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";case 9:return"mat3";case 16:return"mat4"}}function L(e){switch(e){case"float":return 1;case"vec2":return 2;case"vec3":return 3;case"vec4":return 4;case"mat3":return 9;case"mat4":return 16}}function P(e,t){switch(e){case"float":return B(t);case"bool":case"int":return String(t);default:const n=[];for(let e=0;e<t.length;e++)n.push(B(t[e]));return e+"("+n.join(",")+")"}}function B(e){return e%1?String(e):String(e)+".0"}this.type="MeshNodeMaterial",this.defines={LIGHT_PATH_IS_CAM_RAY:1,WORLD_NODES:0,NORMAL_OUTPUT:0},this.definesFragOnly=["LIGHT_PATH_IS_CAM_RAY","WORLD_NODES","NORMAL_OUTPUT"],this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.extensions={derivatives:!0,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]},this.index0AttributeName=void 0,this.profile="blender",this.nodeTextures={},this.nodeRGB=[],this.nodeRGBMap={},this.nodeRGBArr=null,this.nodeTexCoordObject=[],this.nodeTexCoordObjectMap={},this.nodeTexCoordObjectArr=null,this.nodeValue=null,this.nodeValueMap={},this.needsBoundingBox=!1,this.useFloatTex=!1,this.nodeGraph=null,this.additionalNodeGraphs={},this.nodeChunks={},this.nodeChunksHash=0,this.nodeVCAliases={},this.nodeUVAliases={},this.color=new qn(16777215),this.envMap=null,this.envMapIntensity=1,this.envMapParallaxType=0,this.envMapParallaxMatrix=new zi,this.envMapParallaxMatrixInv=new zi,this.reflectivity=.5,this.materialIndex=0,In(e)&&this.setValues(e),this.nodeGraph||(this.nodeGraph=function(){const e=new Pd.DiGraph(1),n=t.color;return e.node(0).originData={name:"ShadelessOutput",type:"OUTPUT_MATERIAL_BL",inputs:[[n.r,n.g,n.b,1],[0,0,0,0],[0,0,0]],outputs:[],is_active_output:!0},e}()),this.updateNodeGraph=function(){t.nodeRGB=[],t.nodeRGBMap={},t.nodeTexCoordObject=[],t.nodeTexCoordObjectMap={},t.nodeValueMap={},t.needsBoundingBox=!1,t.nodeChunks={};const e=t.nodeGraph;t.nodeRGBArr=new Float32Array(4*r(e,["RGB_BL","RGB_MX","RGB_ALPHA"])),t.nodeTexCoordObjectArr=new Float32Array(16*r(e,"TEX_COORD_BL")),t.nodeValue=new Float32Array(r(e,["VALUE_BL","VALUE_MX","ANIM_CURVE_TA_MY","ANIM_CURVE_TU_MY","VALUE"])),function(e){let n=0,i=0,o=0,a=0;for(let l=0;l<e.len();l++){const c=e.node(l),u=c.originData,d=u.type;let h,p,f,m,_,x,y,R,L,B,D,N,O,F,U,z,V,G;c.attributes=[],c.params=[],c.inputFactors=[],c.inputs=[],c.outputs=[],In(u.inputFactors)&&(c.inputFactors=u.inputFactors.slice(0));for(let e=0;e<u.outputs.length;e++){const t=u.outputs[e],n=u.outputTypes?u.outputTypes[e]:I(t);c.outputs.push({name:d.toLowerCase()+"_out"+e+"_n"+l,type:n,clamp:!1,normalize:!1})}switch("OUTPUT_MATERIAL_BL"!=d&&"OUTPUT_WORLD_BL"!=d&&"OUTPUT_MX"!=d&&"SHADING_ENGINE_MY"!=d&&"SKYDOME_LIGHT_AR"!=d||c.outputs.push({name:"outgoingLight",type:"",clamp:!1,normalize:!1}),d){case"ATAN_AR":c.params.push(E(u.units));break;case"CLAMP_AR":case"COLOR_TO_FLOAT_AR":case"COLOR_TO_FLOAT_AR":case"FLOAT_TO_INT_AR":case"LENGTH_AR":case"MIX_SHADER_AR":case"RGB_TO_FLOAT_AR":case"RGB_TO_VECTOR_AR":case"RGBA_TO_FLOAT_AR":case"RGB_TO_VECTOR_AR":case"VECTOR_TO_RGB_AR":c.params.push(E(u.mode));break;case"COLOR_CONVERT_AR":c.params.push(E(u.from)),c.params.push(E(u.to));break;case"CHECKERBOARD_AR":case"PLACE_2D_TEXTURE_MY":h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"COMPOSITE_AR":c.params.push(E(u.operation)),c.params.push(E(u.alphaOperation));break;case"FACING_RATIO_AR":case"FACING_RATIO_AR":case"SHADOW_MATTE_AR":case"NORMAL":c.params.push(E("normal"));break;case"COMPARE_AR":c.params.push(E(u.test));break;case"IMAGE_AR":f=C(d,u.texture),c.params.push(f),c.params.push(E(A(t.nodeTextures[f.name])));break;case"LAMBERT_AR":case"BSDF_DIFFUSE_BL":case"BSDF_GLASS_BL":case"BSDF_GLOSSY_BL":case"BLINN_MY":case"LAMBERT_MY":case"PHONG_MY":case"PHONG_E_MY":c.params.push(E("geometryNormal"));break;case"MAP_TO_MTL_AR":c.params.push(S(u.opaqueEnabled));break;case"NORMAL_MAP_AR":h="tangent",p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p);break;case"SHUFFLE_AR":case"CHANNELS_MY":c.params.push(E(u.channelR)),c.params.push(E(u.channelG)),c.params.push(E(u.channelB)),c.params.push(E(u.channelA));break;case"STANDARD_SURFACE_AR":c.params.push(E("geometryNormal")),c.params.push(S(u.thinWalled)),(u.inputs[Eh]>0||Oh(e,l,Eh))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[Th]>0||Oh(e,l,Th))&&(t.defines.USE_SHEEN=""),c.inputFactors.length=0;break;case"TRIGO_AR":c.params.push(E(u.function)),c.params.push(E(u.units));break;case"TWO_SIDED_AR":c.params.push(E("faceDirection"));break;case"USER_DATA_COLOR_AR":h=g(u.colorLayer,""),h?(p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(E(P("vec4",u.defaultColor)));break;case"ATTRIBUTE_BL":case"VERTEX_COLOR_BL":h=g(u.colorLayer,""),h?(p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p)):c.params.push(E("vec4(0.0, 0.0, 0.0, 1.0)"));break;case"BSDF_PRINCIPLED_BL":c.params.push(E("geometryNormal")),u.inputs.length<=23?((u.inputs[$d]>0||Oh(e,l,$d))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[Jd]>0||Oh(e,l,Jd))&&(t.defines.USE_SHEEN="")):((u.inputs[qd]>0||Oh(e,l,qd))&&(t.defines.USE_CLEARCOAT=""),(u.inputs[Kd]>0||Oh(e,l,Kd))&&(t.defines.USE_SHEEN=""));break;case"BSDF_REFRACTION_BL":c.params.push(E("geometryNormal")),c.params.push(E("BSDF_REFRACTION_"+u.distribution));break;case"BUMP_BL":c.params.push(b(u.invert));break;case"CAMERA_BL":c.params.push(E("vViewPosition")),r(e,"OUTPUT_MATERIAL_BL")>0||r(e,"OUTPUT_WORLD_BL")>0?c.params.push(S(!0)):c.params.push(S(!1));break;case"CLAMP_BL":c.params.push(E("RANGE"==u.clampType));break;case"COMBINE_COLOR_BL":c.params.push(E("NODE_COMB_COL_"+u.mode));break;case"CURVE_FLOAT_BL":t.useFloatTex?(m=new Float32Array(4*Ih),_=1):(m=new Uint8Array(4*Ih),_=255);for(let e=0;e<Ih;e++){let t=_*(u.curveData[e]/2+.5);m[4*e]=nn(t,0,_)}y=v(m,Ih,Be,t.useFloatTex?Ee:xe),R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++;break;case"CURVE_RGB_BL":case"CURVE_VEC_BL":t.useFloatTex?(m=new Float32Array(4*Ih),_=1):(m=new Uint8Array(4*Ih),_=255);for(let e=0;e<Ih;e++){let t,n,i,o;B=u.curveData.length/Ih,B>3?(t=_*u.curveData[B*e],n=_*u.curveData[B*e+1],i=_*u.curveData[B*e+2],o=_*u.curveData[B*e+3]):(t=_*(u.curveData[B*e]/2+.5),n=_*(u.curveData[B*e+1]/2+.5),i=_*(u.curveData[B*e+2]/2+.5),o=_),m[4*e]=nn(t,0,_),m[4*e+1]=nn(n,0,_),m[4*e+2]=nn(i,0,_),m[4*e+3]=nn(o,0,_)}y=v(m,Ih,Be,t.useFloatTex?Ee:xe),R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++;break;case"EEVEE_SPECULAR_BL":c.params.push(E("geometryNormal")),(u.inputs[nh]>0||Oh(e,l,nh))&&(t.defines.USE_CLEARCOAT="");break;case"FRESNEL_BL":case"LAYER_WEIGHT_BL":case"INCIDENT":case"POSITION":c.params.push(E("vViewPosition"));break;case"GRADIENT_RAMP_MX":t.useFloatTex?(m=new Float32Array(4*Rh),_=1):(m=new Uint8Array(4*Rh),_=255);for(let e=0;e<Rh;e++){let t,n,i,o;t=_*u.gradientData[3*e],n=_*u.gradientData[3*e+1],i=_*u.gradientData[3*e+2],o=1,m[4*e]=nn(t,0,_),m[4*e+1]=nn(n,0,_),m[4*e+2]=nn(i,0,_),m[4*e+3]=nn(o,0,_)}y=v(m,Rh,Be,t.useFloatTex?Ee:xe),R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++,c.params.push(E(P("int",u.gradientType))),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(E("geometryNormal")),c.params.push(E("vViewPosition")),["SPHERICAL_ENVIRONMENT","CYLINDRICAL_ENVIRONMENT","SHRINK_WRAP_ENVIRONMENT","SCREEN"].indexOf(u.mapping)>-1?c.params.push(E("MAPPING_EXPLICIT_MAP_CHANNEL")):c.params.push(E("MAPPING_"+u.mapping)),c.params.push(E("AXIS_"+u.axis)),c.params.push(E(P("ivec2",[T(u.clampToEdgeNoExtend[0]),T(u.clampToEdgeNoExtend[1])])));break;case"MAPPING_BL":c.params.push(E("NODE_MAPPING_"+u.vectorType));break;case"MAP_RANGE_BL":In(u.dataType)&&c.params.push(E("NODE_MAP_RANGE_TYPE_"+u.dataType)),c.params.push(E("NODE_MAP_RANGE_INTERP_"+u.interpolationType)),c.params.push(S(u.clamp));break;case"NEW_GEOMETRY_BL":c.params.push(E("faceDirection")),c.params.push(E("vViewPosition")),c.params.push(E("normal")),Fh(e,l,Xd)&&(t.needsBoundingBox=!0);break;case"NORMAL_MAP_BL":h="tangent",p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(E("vNormal"));break;case"SEPARATE_COLOR_BL":c.params.push(E("NODE_SEP_COL_"+u.mode));break;case"TANGENT_BL":"RADIAL"===u.directionType?(c.params.push(E("TANGENT_AXIS_"+u.axis)),c.params.push(E("vViewPosition")),c.params.push(E("normal")),t.needsBoundingBox=!0):"UV_MAP"===u.directionType&&(h="tangent",p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p));break;case"TEX_BRICK_BL":c.params.push(E(P("float",u.offset))),c.params.push(E(P("int",u.offsetFrequency))),c.params.push(E(P("float",u.squash))),c.params.push(E(P("int",u.squashFrequency)));break;case"TEX_COORD_BL":c.params.push(E(`nodeTexCoordObjectMatrices[${o}]`)),c.params.push(E("vViewPosition")),c.params.push(E("normal")),h="uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),Fh(e,l,oh)&&(t.needsBoundingBox=!0),t.nodeTexCoordObject.push(null),t.nodeTexCoordObjectMap[u.name]=o,o++;break;case"TEX_ENVIRONMENT_BL":case"TEX_IMAGE_BL":if(L=C(d,u.texture),c.params.push(L),c.params.push(E(A(t.nodeTextures[L.name]))),"TEX_ENVIRONMENT_BL"==d){const e=u.projection;c.params.push(E("TEX_PROJ_"+e))}else if("TEX_IMAGE_BL"==d){let t;switch(u.alphaMode||"STRAIGHT"){case"STRAIGHT":t=Fh(e,l,1)?"TEX_ALPHA_CLEAR":"TEX_ALPHA_PREMUL";break;case"PREMUL":t=Fh(e,l,1)?"TEX_ALPHA_UNPREMUL":"TEX_ALPHA_CLEAR";break;case"CHANNEL_PACKED":t="TEX_ALPHA_CLEAR";break;case"NONE":t="TEX_ALPHA_ONE";break;default:console.error("MeshNodeMaterial: incorrect TEX_IMAGE_BL alpha mode"),t="TEX_ALPHA_ONE"}c.params.push(E(t)),c.params.push(E("normal"));const n=u.projection;c.params.push(E("TEX_PROJ_"+n)),c.params.push(b(u.projectionBlend)),c.params.push(S(u.clampToEdgeNoExtend))}break;case"TEX_GRADIENT_BL":c.params.push(E("TEX_GRAD_"+u.gradientType));break;case"TEX_NOISE_BL":c.params.push(E(P("float",In(u.falloffFactor)?u.falloffFactor:0))),c.params.push(E(P("float",In(u.dispersionFactor)?u.dispersionFactor:1)));break;case"TEX_SKY_BL":if(N=(new ci).fromArray(u.sunDirection).angleTo(new ci(0,0,1)),"PREETHAM"==u.skyType)O=jd.getDistParams(u.turbidity,0).concat([0,0,0,0]),F=jd.getDistParams(u.turbidity,1).concat([0,0,0,0]),U=jd.getDistParams(u.turbidity,2).concat([0,0,0,0]),z=jd.getZenithParams(u.turbidity,N,0),V=jd.getZenithParams(u.turbidity,N,1),G=jd.getZenithParams(u.turbidity,N,2);else if("HOSEK_WILKIE"==u.skyType){const e=Math.max(Math.PI/2-N,0);O=zd.getDistParams(u.turbidity,u.groundAlbedo,e,0),F=zd.getDistParams(u.turbidity,u.groundAlbedo,e,1),U=zd.getDistParams(u.turbidity,u.groundAlbedo,e,2),z=zd.getRadiance(u.turbidity,u.groundAlbedo,e,0),V=zd.getRadiance(u.turbidity,u.groundAlbedo,e,1),G=zd.getRadiance(u.turbidity,u.groundAlbedo,e,2)}else O=F=U=new Array(9).fill(0),z=V=G=0;c.params.push(E("TEX_SKY_"+u.skyType)),c.params.push(b([O[0],F[0],U[0]])),c.params.push(b([O[1],F[1],U[1]])),c.params.push(b([O[2],F[2],U[2]])),c.params.push(b([O[3],F[3],U[3]])),c.params.push(b([O[4],F[4],U[4]])),c.params.push(b([O[5],F[5],U[5]])),c.params.push(b([O[6],F[6],U[6]])),c.params.push(b([O[7],F[7],U[7]])),c.params.push(b([O[8],F[8],U[8]])),c.params.push(b([z,V,G])),c.params.push(b(u.sunDirection));break;case"TEX_VORONOI_BL":c.params.push(E("DISTANCE_"+u.distance)),c.params.push(E("FEATURE_"+u.feature));break;case"TEX_WAVE_BL":c.params.push(E("TEX_WAVE_TYPE_"+u.waveType)),c.params.push(E("TEX_WAVE_PROFILE_"+u.waveProfile)),c.params.push(E(`TEX_WAVE_BANDS_DIR_${u.bandsDirection}`)),c.params.push(E(`TEX_WAVE_RINGS_DIR_${u.ringsDirection}`));break;case"MATH_BL":c.outputs[0].clamp=u.useClamp;break;case"MIX_BL":switch(c.originData.blendType){case"HUE":case"SATURATION":case"VALUE":case"COLOR":t.defines.HSV_NODES=""}"RGBA"==u.dataType&&(c.outputs[0].clamp=u.clampResult);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 I=-1;for(let t=1;t<3;t++){const n=Nh(e,l,t);n&&"BSDF_TRANSPARENT_BL"==n.originData.type&&(I=t-1)}c.params.push(E(String(I)));break;case"NORMAL_BL":c.params.push(b(u.outputs[0]));break;case"RGB_BL":case"RGB_MX":L=(new ii).fromArray(u.outputs[0]),t.nodeRGB.push(L),t.nodeRGBMap[u.name]=i,c.params.push(E("nodeRGB["+i+"]")),i++;break;case"UVMAP_BL":s=u.uvLayer,h=t.nodeUVAliases[s]||"uv",p=w(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":L=u.outputs[0],t.nodeValue[a]=L,t.nodeValueMap[u.name]=a,c.params.push(E("nodeValue["+a+"]")),a++;break;case"VALTORGB_BL":D=u.curve;const k=new("STEP"==D.interpolation?Ld:Vd)(new Float32Array(D.input),new Float32Array(D.output),4);t.useFloatTex?(m=new Float32Array(4*Ih),_=1):(m=new Uint8Array(4*Ih),_=255);for(let e=0;e<Ih;e++){const t=k.evaluate(e/(Ih-1));m[4*e]=_*t[0],m[4*e+1]=_*t[1],m[4*e+2]=_*t[2],m[4*e+3]=_*t[3]}y=v(m,Ih,Be,t.useFloatTex?Ee:xe),"STEP"==D.interpolation&&(y.minFilter=fe,y.magFilter=fe),R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++;break;case"VECTOR_ROTATE_BL":c.params.push(E(P("float",u.invert?-1:1)));break;case"VECT_TRANSFORM_BL":const Q=u.vectorType,W=u.convertFrom,H=u.convertTo;"NORMAL"==Q&&(c.outputs[0].normalize=!0);let j="";W==H?j="VEC_TRANS_NONE":(j="VEC_TRANS_"+W[0]+"_"+H[0],"VECTOR"!=Q&&"NORMAL"!=Q||(j+="_DIR")),c.params.push(E(j)),r(e,"OUTPUT_MATERIAL_BL")>0||r(e,"OUTPUT_WORLD_BL")>0?c.params.push(S(!0)):c.params.push(S(!1));break;case"BITMAP_MX":case"BITMAP_ENV_MX":case"REFLECT_REFRACT_MX":if(f=C(d,u.texture),c.params.push(f),"BITMAP_MX"==d){h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p),c.params.push(E("MAPPING_"+u.mapping)),c.params.push(E("AXIS_"+u.axis));const e=P("ivec2",[T(u.clampToEdgeNoExtend[0]),T(u.clampToEdgeNoExtend[1])]);c.params.push(E(e))}else c.params.push(E(u.reflectMode)),c.params.push(b(u.IOR));c.params.push(E(A(t.nodeTextures[f.name]))),"BITMAP_MX"!=d&&"BITMAP_ENV_MX"!=d||(c.params.push(S(u.alphaAsMono)),c.params.push(S(u.alphaAsRGB)),c.outputs.push({name:d.toLowerCase()+"_out1_n"+l,type:"float",clamp:!1,normalize:!1}));break;case"BLEND_MX":c.params.push(S(u.useCurve)),c.params.push(b(u.curveLower)),c.params.push(b(u.curveUpper));break;case"BUMP_MX":f=C("BITMAP_MX",u.texture),c.params.push(f),c.params.push(E("-vViewPosition")),c.params.push(E("normal")),h=u.uvIndex?"uv"+String(u.uvIndex+1):"uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"COLOR_CORRECTION_MX":const Y=P("ivec4",[u.rewireR,u.rewireG,u.rewireB,u.rewireA]);c.params.push(E(Y));break;case"COMPOSITE_LAYER_MX":c.params.push(E(P("int",u.blendMode)));const X=Oh(e,l,1)?u.opacity:0;c.params.push(b(X));break;case"COLOR_MAP_MX":c.params.push(S(u.reverseGamma));break;case"FALLOFF_MX":c.params.push(E("-vViewPosition")),c.params.push(b(u.IOR));break;case"MASK_MX":c.params.push(S(u.maskInverted));break;case"MATERIAL_MX":c.params.push(b(u.inputFactors[lh])),c.params.push(b(u.inputFactors[ch])),u.inputFactors[lh]=1,u.inputFactors[ch]=1,c.params.push(S(u.selfIllumColorOn));break;case"MATTE_SHADOW_MX":c.params.push(E("normal")),c.params.push(S(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=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)):c.params.push(E("vViewPosition")),c.params.push(M(u.noiseType)),c.params.push(M(u.coordType));break;case"NORMAL_BUMP_MX":h="tangent",p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),c.params.push(E("normal"));const K="ivec2("+T(u.flip[0])+","+T(u.flip[1])+")";c.params.push(E(K));break;case"OUTPUT_MAP_MX":if(c.params.push(S(u.invert)),c.params.push(S(u.clamp)),c.params.push(S(u.alphaFromRGB)),u.colorMap){t.useFloatTex?(x=u.colorMap,m=new Float32Array(4*Ih),_=1):(x=Rn(u.colorMap.slice(),0,1),m=new Uint8Array(4*Ih),_=255),B=x.length/Ih;for(let e=0;e<Ih;e++)m[4*e]=_*x[B*e],3==B?(m[4*e+1]=_*x[B*e+1],m[4*e+2]=_*x[B*e+2]):(m[4*e+1]=m[4*e],m[4*e+2]=m[4*e]),m[4*e+3]=_;y=v(m,Ih,Be,t.useFloatTex?Ee:xe),R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++}break;case"PHYSICAL_MX":c.params.push(E("geometryNormal")),c.params.push(b(u.emitLuminance));const q=void 0===u.brdfMode||u.brdfMode,Z=void 0===u.brdfLow?0:u.brdfLow,J=void 0===u.brdfHigh?0:u.brdfHigh,$=void 0===u.brdfCurve?0:u.brdfCurve;c.params.push(S(!q)),c.params.push(E(P("float",Z))),c.params.push(E(P("float",J))),c.params.push(E(P("float",$))),c.params.push(S(In(u.roughnessInv)&&u.roughnessInv)),c.params.push(S(In(u.transRoughnessLock)&&u.transRoughnessLock)),c.params.push(S(In(u.transRoughnessInv)&&u.transRoughnessInv)),c.params.push(S(In(u.thinWalled)&&u.thinWalled)),(u.inputs[uh]>0||Oh(e,l,uh))&&(t.defines.USE_CLEARCOAT="");break;case"PHY_SUN_SKY_ENV_MX":const ee=15*u.haze+2,te=new Yd;N=Math.PI/2-u.sunPolarAngle;const ne=Math.PI-u.sunAzimuthAngle;te.phi=N,te.theta=ne;const ie=(new ci).setFromSpherical(te).toArray();O=jd.getDistParams(ee,0),F=jd.getDistParams(ee,1),U=jd.getDistParams(ee,2),z=jd.getZenithParams(ee,N,0),V=jd.getZenithParams(ee,N,1),G=jd.getZenithParams(ee,N,2),z/=.06,z*=1e3,c.params.push(b([O[0],F[0],U[0]])),c.params.push(b([O[1],F[1],U[1]])),c.params.push(b([O[2],F[2],U[2]])),c.params.push(b([O[3],F[3],U[3]])),c.params.push(b([O[4],F[4],U[4]])),c.params.push(b([z,V,G]));const oe=jd.getSunIlluminance(ie,ee),re=[0,0,0];c.params.push(b(ie)),c.params.push(b(oe)),c.params.push(b(re)),c.params.push(b(u.globalIntensity/Lh)),c.params.push(b(u.groundColor));break;case"REFLECT_REFRACT_COLOR_MX":L=u.outputs[0],c.params.push(b(L));break;case"VERTEX_COLOR_MX":h="color",p=w(h,3),c.attributes.push({name:h,type:"attribute vec3"}),c.params.push(p);break;case"BUMP_2D_MY":c.params.push(E("vNormal")),u.bumpInterp>0&&(h="tangent",p=w(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(E(u.operation));break;case"COLOR_CORRECT_MY":c.params.push(S(u.colClamp)),c.params.push(b(u.colClampMin)),c.params.push(b(u.colClampMax)),c.params.push(S(u.alphaClamp)),c.params.push(b(u.alphaClampMin)),c.params.push(b(u.alphaClampMax)),c.params.push(S(u.unpremultiplyInput)),c.params.push(S(u.premultiplyResult));break;case"COLOR_MASK_MY":c.params.push(S(u.maskAlphaIsLuminance));break;case"COMPOSE_MATRIX_MY":c.params.push(S(u.useEulerRotation)),c.params.push(E(u.inputRotateOrder));break;case"FILE_MY":case"ENV_SPHERE_MY":if(L=C("FILE_MY",u.texture),c.params.push(L),c.params.push(E(A(t.nodeTextures[L.name]))),"ENV_SPHERE_MY"==d)c.params.push(E("normal"));else{const t=!1===u.fileHasAlpha;c.params.push(S(t&&Fh(e,l,_h)))}break;case"RAMP_MY":t.useFloatTex?(m=new Float32Array(4*Rh),_=1):(m=new Uint8Array(4*Rh),_=255);for(let e=0;e<Rh;e++){let t,n,i,o;t=_*u.rampData[3*e],n=_*u.rampData[3*e+1],i=_*u.rampData[3*e+2],o=1,m[4*e]=nn(t,0,_),m[4*e+1]=nn(n,0,_),m[4*e+2]=nn(i,0,_),m[4*e+3]=nn(o,0,_)}y=v(m,Rh,Be,t.useFloatTex?Ee:xe),y.wrapS=u.wrapS,y.wrapT=u.wrapT,R=Bh.nodeTexUniName(d,n),t.nodeTextures[R]=y,c.params.push(C(d,n)),n++,c.params.push(E(P("int",u.rampType)));break;case"SAMPLER_INFO_MY":c.params.push(E("faceDirection")),h="tangent",p=w(h,4),c.attributes.push({name:h,type:"attribute vec4"}),c.params.push(p),h="uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p);break;case"UNIT_CONVERSION_MY":c.params.push(b(u.conversionFactor));break;case"VECTOR_PRODUCT_MY":c.params.push(E(u.operation)),c.params.push(S(u.normalizeOutput));break;case"OSL_NODE":In(u.texture)&&(f=C(d,u.texture),c.params.push(f));const ae=u.globalVariables||[];ae.indexOf("P")>-1&&c.params.push(E("oslGetP(vViewPosition)")),ae.indexOf("I")>-1&&c.params.push(E("oslGetI(vViewPosition)")),ae.indexOf("N")>-1&&c.params.push(E("oslGetN(normal)")),(ae.indexOf("u")>-1||ae.indexOf("v")>-1)&&(h="uv",c.attributes.push({name:h,type:"attribute vec2"}),ae.indexOf("u")>-1&&c.params.push(w(h+"_u",1,h+".x")),ae.indexOf("v")>-1&&c.params.push(w(h+"_v",1,"1.0 - "+h+".y")));break;case"RGB_ALPHA":L=(new ii).fromArray(u.outputs[0].concat([u.outputs[1]])),t.nodeRGB.push(L),t.nodeRGBMap[u.name]=i,c.params.push(E("nodeRGB["+i+"]")),i++;break;case"U_FLOAT":h="uv",p=w(h,2),c.attributes.push({name:h,type:"attribute vec2"}),c.params.push(p)}}var s;for(let t=0;t<e.len();t++){const n=e.node(t),i=n.originData,o=i.type;for(let r=0;r<i.inputs.length;r++){const a=i.inputs[r],s=i.inputTypes?i.inputTypes[r]:I(a),l=[],c=[];y(e,t,r,a,l,c);const d=u(o,r);if(l.length){let e,t;if(e=n.inputFactors.length?n.inputFactors[r]:1,t=d?"normal":P(s,a),c.length){const e=l.map((function(e){return e.name}));n.inputs.push({code:x(e,c,l[0].type,s,t)})}else 1==l.length?n.inputs.push({code:_(l[0].name,l[0].type,s,t,e)}):console.error("MeshNodeMaterial: wrong node connections")}else d?n.inputs.push({code:"normal"}):n.inputs.push({code:P(s,a)})}}}(e),function(e){const n=[],i=[],o=[],r=[],a=new Pd.TopologicalSort(e).order();t.defines.NODE_RGB_NUM=t.nodeRGB.length,t.defines.NODE_VALUE_NUM=t.nodeValue.length,t.defines.NODE_TEX_COORD_NUM=t.nodeTexCoordObject.length,t.definesFragOnly.push("NODE_RGB_NUM"),t.definesFragOnly.push("NODE_VALUE_NUM"),t.definesFragOnly.push("NODE_TEX_COORD_NUM");for(let i=0;i<a.length;i++){const r=e.node(a[i]),s=r.originData.type;let l,c;if(t.defines["NODE_"+s]="","REFLECT_REFRACT_MX"!=s&&"BITMAP_ENV_MX"!=s&&"BUMP_BL"!=s&&"PHY_SUN_SKY_ENV_MX"!=s&&"SKYDOME_LIGHT_AR"!=s&&"ENV_SPHERE_MY"!=s&&t.definesFragOnly.push("NODE_"+s),"OSL_NODE"==s&&(t.defines.USE_OSL=""),"OSL_NODE"!=s){const e="node_"+s.toLowerCase()+"_vert";l=wr[e]}else l=r.originData.vertCode;if(l&&n.indexOf(l)<0&&n.push(l),"OSL_NODE"!=s){const e="node_"+s.toLowerCase()+"_frag";c=wr[e]}else c=r.originData.fragCode;c&&o.indexOf(c)<0&&o.push(c);for(let e=0;e<r.attributes.length;e++){const t=r.attributes[e],i=t.type+" "+t.name+";";"uv"!=t.name&&n.indexOf(i)<0&&n.push(i)}for(let e=0;e<r.params.length;e++){const t=r.params[e];if(f(t)){const e=t.type+" "+t.name+";";o.indexOf(e)<0&&o.push(e)}else if(m(t)){const e=t.type+" "+t.name+";";n.indexOf(e)<0&&n.push(e);const i=t.type+" "+t.name+";";o.indexOf(i)<0&&o.push(i)}}}In(t.defines.USE_OSL)&&o.unshift("#include <node_osl_frag>");for(let t=0;t<a.length;t++){const n=e.node(a[t]),o=n.originData.type;if("CHECKERBOARD_AR"==o||"IMAGE_AR"==o||"TWO_SIDED_AR"==o||"USER_DATA_COLOR_AR"==o||"ATTRIBUTE_BL"==o||"NEW_GEOMETRY_BL"==o||"NORMAL_MAP_BL"==o||"TANGENT_BL"==o||"TEX_COORD_BL"==o||"UVMAP_BL"==o||"VERTEX_COLOR_BL"==o||"BITMAP_MX"==o||"NOISE_MX"==o||"NORMAL_BUMP_MX"==o||"BUMP_MX"==o||"VERTEX_COLOR_MX"==o||"GRADIENT_RAMP_MX"==o||"BUMP_2D_MY"==o||"PLACE_2D_TEXTURE_MY"==o||"SAMPLER_INFO_MY"==o||"OSL_NODE"==o||"U_FLOAT"==o)for(let e=0;e<n.params.length;e++){const t=n.params[e];if(m(t)){const e=t.name+"="+t.attrBindName+";";i.indexOf(e)<0&&i.push(e)}}for(let e=0;e<n.outputs.length;e++){const t=n.outputs[e];t.type&&r.push(t.type+" "+t.name+";")}const s=[];for(let e=0;e<n.params.length;e++){const t=n.params[e];!t.type||f(t)||m(t)?s.push(t.name):s.push(P(t.type,t.value))}for(let e=0;e<n.inputs.length;e++){const t=n.inputs[e];s.push(t.code)}for(let e=0;e<n.outputs.length;e++){const t=n.outputs[e];s.push(t.name)}let l;switch("OSL_NODE"!=o?(l="node_"+o.toLowerCase(),(o.endsWith("_AR")||o.endsWith("_BL")||o.endsWith("_MX")||o.endsWith("_MY"))&&(l=l.slice(0,-3))):l=n.originData.shaderName,o){case"MATH_BL":case"VECT_MATH_BL":l+="_"+n.originData.operation.toLowerCase();break;case"VECTOR_ROTATE_BL":l+="_"+n.originData.rotationType.toLowerCase();break;case"MIX_BL":l+="_"+n.originData.dataType.toLowerCase(),"RGBA"==n.originData.dataType?l+="_"+n.originData.blendType.toLowerCase():"VECTOR"==n.originData.dataType&&(l+="_"+n.originData.factorMode.toLowerCase());break;case"MIX_RGB_BL":l+="_"+n.originData.blendType.toLowerCase();break;case"TEX_WHITE_NOISE_BL":l+="_"+n.originData.noise_dimension.toLowerCase()}r.push(l+"("+s.join(",")+");");for(let e=0;e<n.outputs.length;e++){const t=n.outputs[e],i=t.name;if(t.clamp){const e=t.type;r.push(i+"=clamp("+i+","+e+"(0.0),"+e+"(1.0));")}t.normalize&&r.push(i+"=normalize("+i+");")}}t.nodeChunks.node_pars_vertex=n.join("\n"),t.nodeChunks.node_vertex=i.join("\n"),t.nodeChunks.node_pars_fragment=o.join("\n"),t.nodeChunks.node_fragment=r.join("\n"),t.nodeChunksHash=fn(JSON.stringify(t.nodeChunks))}(e)},function(e){for(let i=0;i<e.len();i++){const r=e.node(i),a=r.originData.type;if("GROUP_BL"!=a)if("REROUTE_BL"!=a)if("OSL_OUTPUT_SELECTOR_MX"!=a);else{const t=e.findInEdges(i),n=e.findOutEdges(i),o=t[0],r=o.connections[0];for(let t=0;t<n.length;t++){const i=n[t],a=new Pd.Edge(o.from(),i.to(),0);a.connections=[];for(let e=0;e<i.connections.length;e++){const t=i.connections[e],n={from:r.from,to:t.to};a.connections.push(n)}e.addEdge(a)}e.disconnect(i,!0),i=-1}else{e.findInEdges(i).length<1&&n(e,i);const t=e.findInEdges(i),o=e.findOutEdges(i),r=t[0],a=r.connections[0];for(let t=0;t<o.length;t++){const n=o[t],i=new Pd.Edge(r.from(),n.to(),0);i.connections=[];for(let e=0;e<n.connections.length;e++){const t=n.connections[e],o={from:a.from,to:t.to};i.connections.push(o)}e.addEdge(i)}e.disconnect(i,!0),i=-1}else{const a=r.originData.nodeGraph,s=t.additionalNodeGraphs[a];if(n(e,i),s.len()<=2){const t=e.findInEdges(i),n=e.findOutEdges(i),o=Math.min(t.length,n.length);for(let i=0;i<o;i++){const o=t[i],r=n[i],a=new Pd.Edge(o.from(),r.to(),0);a.connections=[];const s=Math.min(o.connections.length,r.connections.length);for(let e=0;e<s;e++){const t=o.connections[e],n=r.connections[e],i={from:t.from,to:n.to};a.connections.push(i)}e.addEdge(a)}e.disconnect(i,!0),i=-1;continue}const l=o(e,s,i),c=e=>JSON.parse(JSON.stringify(e)),u=c;e.insert(s,l.inputs,l.outputs,c,u);const d=l.removedNodes.sort((function(e,t){return t-e}));for(let t=0;t<d.length;t++)e.disconnect(d[t],!0);i=-1}}}(t.nodeGraph),function(e){for(let t=0;t<e.len();t++){const n=e.node(t).originData,i=n.type;if("TEX_IMAGE_BL"==i&&!Oh(e,t,0)){const n={originData:{name:"UVMapGenerated",type:"UVMAP_BL",uvLayer:"",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,0)}if(("TEX_BRICK_BL"==i||"TEX_CHECKER_BL"==i||"TEX_GRADIENT_BL"==i||"TEX_NOISE_BL"==i||"TEX_WAVE_BL"==i||"TEX_VORONOI_BL"==i||"TEX_SKY_BL"==i)&&!Oh(e,t,0)){const n={originData:{name:"TexCoordGenerated",type:"TEX_COORD_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,0)}if("TEX_ENVIRONMENT_BL"==i&&!Oh(e,t,0)){const n={originData:{name:"TexCoordObject",type:"TEX_COORD_BL",inputs:[],outputs:[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,3,t,0)}let o=i;if("BSDF_PRINCIPLED_BL"==o)switch(n.inputs.length){case 23:o="BSDF_PRINCIPLED_<3.0_BL";break;case 22:o="BSDF_PRINCIPLED_<2.91.0_BL"}if("BUMP_BL"==o&&6===n.inputs.length)o="BUMP_BL_<3.2_BL";if("STANDARD_SURFACE_AR"==o&&25==n.inputs.length&&(console.warn("v3d.MeshNodeMaterial: adding missing params to standard surface node, please reexport your scene"),n.inputs.push([0,0,0])),o in Ph&&!Oh(e,t,Ph[o])){const n={originData:{name:"Normal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,Ph[o])}if("BSDF_PRINCIPLED_<2.91.0_BL"==o&&!Oh(e,t,th)&&(n.inputs[$d]>0||Oh(e,t,$d))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,th)}if("BSDF_PRINCIPLED_<3.0_BL"==o&&!Oh(e,t,eh)&&(n.inputs[$d]>0||Oh(e,t,$d))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,eh)}if("BSDF_PRINCIPLED_BL"==o&&!Oh(e,t,Zd)&&(n.inputs[qd]>0||Oh(e,t,qd))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,Zd)}if("EEVEE_SPECULAR_BL"==o&&!Oh(e,t,ih)&&(n.inputs[nh]>0||Oh(e,t,nh))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,ih)}if("OSL_NODE"==o){const i=n.initializers;for(let r=0;r<i.length;r++){const a=i[r];if(a&&!Oh(e,t,r)){const i={originData:{name:o+"init"+r,type:"OSL_NODE",shaderName:n.shaderName+"_init_"+r,inputs:[],outputs:[n.inputs[0]],fragCode:a[0],globalVariables:a[1],initializers:[]}};e.addNode(i),Uh(e,e.len()-1,0,t,r)}}}if(!("NORMAL_MAP_AR"!=o||Oh(e,t,fh)&&Oh(e,t,mh))){const n={originData:{name:"SamplerInfo",type:"SAMPLER_INFO_MY",inputs:[[0,0,0]],outputs:[0,!1,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0],[0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0]]}};e.addNode(n),Oh(e,t,fh)||Uh(e,e.len()-1,Mh,t,fh),Oh(e,t,mh)||Uh(e,e.len()-1,Sh,t,mh)}if("IMAGE_AR"==o&&!Oh(e,t,vh)){const n={originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}};e.addNode(n),Uh(e,e.len()-1,bh,t,vh)}if("FILE_MY"==o&&!Oh(e,t,yh)){const n={originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}};e.addNode(n),Uh(e,e.len()-1,bh,t,yh)}if("RAMP_MY"==o&&!Oh(e,t,Ch)){const n={originData:{name:"place2dTexture",type:"PLACE_2D_TEXTURE_MY",inputs:[[0,0],[1,1],0],outputs:[[0,0]],uvIndex:0}};e.addNode(n),Uh(e,e.len()-1,bh,t,Ch)}if(In(n.output)&&h(e,t,n),l(i)){if(!In(n.inputFactors)){n.inputFactors=[];for(let e=0;e<n.inputs.length;e++)n.inputFactors.push(1)}n.inputs.push([0,0,0]),n.inputFactors.push(0)}if("STANDARD_SURFACE_AR"==o&&!Oh(e,t,wh)&&(n.inputs[Eh]>0||Oh(e,t,Eh))){const n={originData:{name:"CoatNormal",type:"NORMAL",inputs:[],outputs:[[0,0,0]]}};e.addNode(n),Uh(e,e.len()-1,0,t,wh)}if("MIX_BL"==o&&n.outputs.length>1){const i=[-1,-1,-1,-1,-1,-1,-1],o=[-1,-1,-1];switch(n.dataType){case"RGBA":n.inputs=[n.inputs[0],n.inputs[6],n.inputs[7]],i[0]=0,i[6]=1,i[7]=2,n.outputs=[n.outputs[2]],o[2]=0;break;case"VECTOR":n.inputs=[n.inputs[0],n.inputs[1],n.inputs[4],n.inputs[5]],i[0]=0,i[1]=1,i[4]=2,i[5]=3,n.outputs=[n.outputs[1]],o[1]=0;break;case"FLOAT":n.inputs=[n.inputs[0],n.inputs[2],n.inputs[3]],i[0]=0,i[2]=1,i[3]=2,n.outputs=[n.outputs[0]],o[0]=0}const r=e.findInEdges(t);for(let e=0;e<r.length;e++){const t=r[e];for(let e=t.connections.length-1;e>=0;e--){const n=t.connections[e];i[n.to]>-1?n.to=i[n.to]:t.connections.splice(e,1)}}const a=e.findOutEdges(t);for(let e=0;e<a.length;e++){const t=a[e];for(let e=t.connections.length-1;e>=0;e--){const n=t.connections[e];o[n.from]>-1?n.from=o[n.from]:t.connections.splice(e,1)}}}if("BUMP_2D_MY"==i&&n.bumpInterp>0){n.inputs[Ah]=[0,0,0];const i=e.findInEdges(t);for(let t=0;t<i.length;t++){const n=i[t],o=e.node(n.from()).originData;for(let e=0;e<n.connections.length;e++){const t=n.connections[e];t.to==Ah&&"FILE_MY"==o.type?t.from=xh:t.to==Ah&&"IMAGE_AR"==o.type&&(t.from=gh)}}}"COLOR_CONSTANT_MY"!=i||Oh(e,t,0)||Oh(e,t,1)||(n.type="RGB_ALPHA",n.inputs=[]),"FLOAT_CONSTANT_MY"!=i||Oh(e,t,0)||(n.type="VALUE",n.inputs=[])}let n=0;for(let t=0;t<e.len();t++){const i=e.node(t).originData,o=i.type;"MATERIAL_MX"!=o&&"PHYSICAL_MX"!=o||(s(e,t,i),"MATERIAL_MX"==o&&(n=i.IOR))}for(let t=0;t<e.len();t++){const i=e.node(t).originData,o=i.type;c(o)&&(i.IOR=n),c(o)&&!In(i.reflectMode)&&(i.reflectMode="MAX_ENV_COORDS_REFLECT")}for(let t=0;t<e.len();t++){const n=e.node(t).originData;"COMPOSITE_MX"==n.type&&(d(e,t,n),e.disconnect(t,!0))}for(let t=0;t<e.len();t++){const n=e.node(t).originData;"LAYERED_TEXTURE_MY"==n.type&&(p(e,t,n),e.disconnect(t,!0))}if(t.hasNode("SKYDOME_LIGHT_AR"))for(let t=0;t<e.len();t++){const n=e.node(t).originData;if("FILE_MY"==n.type||"IMAGE_AR"==n.type){const i={originData:{name:"envSphere",type:"ENV_SPHERE_MY",inputs:[[-1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]],outputs:[0,[0,0,0]],texture:n.texture}};e.addNode(i);const o=e.findOutEdges(t);for(let t=0;t<o.length;t++){const n=o[t];for(let t=0;t<n.connections.length;t++){const i=n.connections[t];i.from<2&&Uh(e,e.len()-1,i.from,n.to(),i.to)}}e.disconnect(t,!0),t=-1}}for(let t=0;t<e.len();t++){const n=e.node(t).originData;if("ENV_SPHERE_MY"==n.type&&2==n.inputs.length){const i=e.findInEdges(t);for(let t=0;t<i.length;t++){const o=i[t],r=e.node(o.from()).originData;"FILE_MY"!=r.type&&"IMAGE_AR"!=r.type||(n.inputs.splice(0,1),n.texture=r.texture,e.removeEdge(o.from(),o.to()))}}}for(let t=0;t<e.len();t++){const n=e.node(t).originData;switch(n.type){case"BSDF_DIFFUSE_BL":case"BSDF_GLOSSY_BL":case"BSDF_TRANSLUCENT_BL":case"BSDF_PRINCIPLED_BL":i(e,t,n,0,"Color");break;case"MATERIAL_MX":i(e,t,n,0,"Ambient Color")&&(n.inputFactors[0]=1),i(e,t,n,1,"Diffuse Color")&&(n.inputFactors[1]=1);break;case"PHYSICAL_MX":i(e,t,n,1,"Base Color")&&(n.inputFactors[1]=1)}}}(t.nodeGraph),zh(t.nodeGraph),this.updateNodeGraph()}static nodeTexUniName(e,t){return e.toLowerCase()+"_par_tex_idx"+t}static nodeGraphFromExtGraph(e){const t=e.nodes,n=e.edges,i=new Pd.DiGraph(t.length);for(let e=0;e<t.length;e++){t[e];i.node(e).originData=t[e]}for(let e=0;e<n.length;e++){const t=n[e];i.edge(t.fromNode,t.toNode)||i.addNewEdge(t.fromNode,t.toNode);const o=i.edge(t.fromNode,t.toNode);if(o.connections=o.connections||[],In(t.fromChannel)||In(t.toChannel)){let e=null;for(let n=0;n<o.connections.length;n++){const i=o.connections[n];if(i.from==t.fromOutput&&i.to==t.toInput&&i.channelMatrix){e=i.channelMatrix;break}}if(!e){e=[[0,0,0],[0,0,0],[0,0,0]];const n={from:t.fromOutput,to:t.toInput,channelMatrix:e};o.connections.push(n)}const n=t.fromChannel||0,i=t.toChannel||0;e[n][i]=1}else{const e={from:t.fromOutput,to:t.toInput};o.connections.push(e)}}return zh(i),i}static nodeGraphTraverse(e,t){for(let n=0;n<e.len();n++){t(e.node(n))}}static nodeGraphDiffuse(e,t,n="blender"){let i,o=new Pd.DiGraph(0);switch(n){case"blender":i=e.toArray(),i.push(1),o.addNode({originData:{name:"Output",type:"OUTPUT_MATERIAL_BL",inputs:[[0,0,0,0],[0,0,0,0],[0,0,0]],outputs:[],is_active_output:!0}}),t<1?(o.addNode({originData:{name:"Mix",type:"MIX_SHADER_BL",inputs:[t,[0,0,0,0],[0,0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1}}),Uh(o,1,0,0,0),o.addNode({originData:{name:"Transparent",type:"BSDF_TRANSPARENT_BL",inputs:[[1,1,1,1]],outputs:[[0,0,0,0]],is_active_output:!1}}),Uh(o,2,0,1,1),o.addNode({originData:{name:"Diffuse",type:"BSDF_DIFFUSE_BL",inputs:[i,0,[0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1}}),Uh(o,3,0,1,2)):(o.addNode({originData:{name:"Diffuse",type:"BSDF_DIFFUSE_BL",inputs:[i,0,[0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1}}),Uh(o,1,0,0,0));break;case"max":i=e.toArray();let r=[t,t,t];o.addNode({originData:{name:"Diffuse",type:"LAMBERT_AR",inputs:[1,i,[0,0,0],r],outputs:[[0,0,0,0],0,[0,0,0]],is_active_output:!1}}),o.addNode({originData:{name:"Output",type:"OUTPUT_MX",inputs:[[0,0,0,0]],outputs:[],is_active_output:!0}}),Uh(o,0,0,1,0);break;case"maya":i=e.toArray();let a=[1-t,1-t,1-t];o.addNode({originData:{name:"Diffuse",type:"LAMBERT_MY",inputs:[i,[0,0,0],[0,0,0],1,.8,[1,1,1],0,a],outputs:[[0,0,0,0]],is_active_output:!1}}),o.addNode({originData:{name:"Output",type:"SHADING_ENGINE_MY",inputs:[[0,0,0,0],[0,0,0,0],[0,0,0]],outputs:[],is_active_output:!0}}),Uh(o,0,0,1,0);break;default:console.error("nodeGraphDiffuse: Incorrect material profile - "+n),o=null}return o}hasNode(e){for(let t=0;t<this.nodeGraph.len();t++){if(this.nodeGraph.node(t).originData.type==e)return!0}return!1}traverseNodes(e){for(let t=0;t<this.nodeGraph.len();t++){e(this.nodeGraph.node(t))}}findNodeByName(e){for(let t=0;t<this.nodeGraph.len();t++){const n=this.nodeGraph.node(t);if(n.originData.name===e)return n}return null}needsLightPathDir(){return!!(this.hasNode("LIGHT_PATH_BL")||this.hasNode("RAY_SWITCH_AR")||"USE_OSL"in this.defines)}canUseGTAO(){return(this.hasNode("BSDF_DIFFUSE_BL")||this.hasNode("SUBSURFACE_SCATTERING_BL")||this.hasNode("PHYSICAL_MX")||this.hasNode("STANDARD_SURFACE_AR")||this.hasNode("BSDF_GLASS_BL")||this.hasNode("BSDF_GLOSSY_BL")||this.hasNode("BSDF_PRINCIPLED_BL")||this.hasNode("EEVEE_SPECULAR_BL"))&&this.gtaoVisible}worldMaterialColor(){const e=this.nodeGraph;let t=Dh(e,"OUTPUT_WORLD_BL");if(t>=0){const n=Nh(e,t,0);if(!n||"BACKGROUND_BL"!=n.originData.type)return null;if(0==e.findInEdges(e.nodeIndex(n)).length)return(new qn).fromArray(n.originData.inputs[0]).multiplyScalar(n.originData.inputs[1]);if(Oh(e,e.nodeIndex(n),1))return null;const i=Nh(e,e.nodeIndex(n),0);if(!i||("MIX_BL"!=i.originData.type||"RGBA"!=i.originData.dataType)&&"MIX_RGB_BL"!=i.originData.type||"MIX"!=i.originData.blendType)return null;const o=Nh(e,e.nodeIndex(i),0);return o&&"LIGHT_PATH_BL"==o.originData.type?Oh(e,e.nodeIndex(i),2)?null:Fh(e,e.nodeIndex(o),0)?(new qn).fromArray(i.originData.inputs[2]):null:null}if(t=Dh(e,"OUTPUT_MX"),t>=0&&0==e.findInEdges(t).length)return(new qn).fromArray(e.node(t).originData.inputs[0]);if(t=Dh(e,"SKYDOME_LIGHT_AR"),t>=0){if(0==e.findInEdges(t).length){const n=e.node(t);return(new qn).fromArray(n.originData.inputs[0]).multiplyScalar(n.originData.inputs[1])}const n=Nh(e,t,0);if(!n||"RAY_SWITCH_AR"!=n.originData.type)return null;if(0==e.findInEdges(e.nodeIndex(n)).length)return(new qn).fromArray(n.originData.inputs[0])}return null}useAddTransparency(){const e=this.nodeGraph,t=Dh(e,"OUTPUT_MATERIAL_BL");if(t>=0){const n=Nh(e,t,0);if(n&&"ADD_SHADER_BL"==n.originData.type){const t=Nh(e,e.nodeIndex(n),0),i=Nh(e,e.nodeIndex(n),1);if(t&&i&&("BSDF_TRANSPARENT_BL"==t.originData.type||"BSDF_TRANSPARENT_BL"==i.originData.type))return!0}}return!1}copy(e){super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=cr.clone(e.uniforms),this.linewidth=e.linewidth,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.clipping=e.clipping,this.index0AttributeName=this.index0AttributeName,this.color.copy(e.color),this.envMap=e.envMap,this.envMapIntensity=e.envMapIntensity,this.envMapParallaxType=e.envMapParallaxType,this.envMapParallaxMatrix.copy(e.envMapParallaxMatrix),this.envMapParallaxMatrixInv.copy(e.envMapParallaxMatrixInv),this.reflectivity=e.reflectivity,this.materialIndex=e.materialIndex,this.extensions=e.extensions,this.profile=e.profile,this.nodeTextures=e.nodeTextures,this.nodeRGB=e.nodeRGB.slice(),this.nodeRGBMap=Object.assign({},e.nodeRGBMap),this.nodeRGBArr=e.nodeRGBArr.slice(),this.nodeTexCoordObject=e.nodeTexCoordObject.slice(),this.nodeTexCoordObjectMap=Object.assign({},e.nodeTexCoordObjectMap),this.nodeTexCoordObjectArr=e.nodeTexCoordObjectArr.slice(),this.nodeValue=e.nodeValue.slice(),this.nodeValueMap=Object.assign({},e.nodeValueMap),this.needsBoundingBox=e.needsBoundingBox,this.useFloatTex=e.useFloatTex,this.nodeGraph=new Pd.DiGraph(e.nodeGraph.len());for(let t=0;t<this.nodeGraph.len();t++)this.nodeGraph.node(t).originData=e.nodeGraph.node(t).originData;for(let t in e.nodeGraph.edges){const n=e.nodeGraph.edges[t];this.nodeGraph.addNewEdge(n.from(),n.to()).connections=n.connections.slice()}return this.additionalNodeGraphs=Object.assign({},e.additionalNodeGraphs),this.nodeChunks=Object.assign({},e.nodeChunks),this.nodeChunksHash=e.nodeChunksHash,this.nodeVCAliases=Object.assign({},e.nodeVCAliases),this.nodeUVAliases=Object.assign({},e.nodeUVAliases),this}toJSON(e){const t=Mo.prototype.toJSON.call(this,e);return t.uniforms=this.uniforms,t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t}}function Dh(e,t){for(let n=0;n<e.len();n++){if(e.node(n).originData.type==t)return n}return-1}function Nh(e,t,n){for(let i in e.edges){const o=e.edges[i];if(o.to()==t){const t=e.node(o.from());for(let e=0;e<o.connections.length;e++){if(o.connections[e].to==n)return t}}}return null}function Oh(e,t,n){const i=e.findInEdges(t);for(let e=0;e<i.length;e++){const t=i[e];for(let e=0;e<t.connections.length;e++){if(t.connections[e].to==n)return!0}}return!1}function Fh(e,t,n){for(let i in e.edges){const o=e.edges[i];if(o.from()==t)for(let e=0;e<o.connections.length;e++){if(o.connections[e].from==n)return!0}}return!1}function Uh(e,t,n,i,o,r){e.edge(t,i)||e.addNewEdge(t,i);const a=e.edge(t,i);a.connections=a.connections||[];const s={from:n,to:o};r&&(s.channelMatrix=r),a.connections.push(s)}function zh(e){let t=-1;for(let n=0;n<e.len();n++)if(e.node(n).originData.is_active_output){t=n;break}if(-1==t)e.removeAll();else{const n=new Pd.DepthFirstSearch(e.reverse(),t),i=[];for(let t=0;t<e.len();t++)n.hasPathTo(t)||i.push(e.node(t));i.forEach((function(t){e.disconnect(e.nodeIndex(t),!0)}))}}function Vh(e,t,n){return kh(e)?new e.constructor(e.subarray(t,void 0!==n?n:e.length)):e.slice(t,n)}function Gh(e,t,n){return!e||!n&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function kh(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Qh(e){const t=e.length,n=new Array(t);for(let e=0;e!==t;++e)n[e]=e;return n.sort((function(t,n){return e[t]-e[n]})),n}function Wh(e,t,n){const i=e.length,o=new e.constructor(i);for(let r=0,a=0;a!==i;++r){const i=n[r]*t;for(let n=0;n!==t;++n)o[a++]=e[i+n]}return o}function Hh(e,t,n,i){let o=1,r=e[0];for(;void 0!==r&&void 0===r[i];)r=e[o++];if(void 0===r)return;let a=r[i];if(void 0!==a)if(Array.isArray(a))do{a=r[i],void 0!==a&&(t.push(r.time),n.push.apply(n,a)),r=e[o++]}while(void 0!==r);else if(void 0!==a.toArray)do{a=r[i],void 0!==a&&(t.push(r.time),a.toArray(n,n.length)),r=e[o++]}while(void 0!==r);else do{a=r[i],void 0!==a&&(t.push(r.time),n.push(a)),r=e[o++]}while(void 0!==r)}Bh.prototype.isMeshNodeMaterial=!0;var jh=Object.freeze({__proto__:null,arraySlice:Vh,convertArray:Gh,isTypedArray:kh,getKeyframeOrder:Qh,sortedArray:Wh,flattenJSON:Hh,subclip:function(e,t,n,i,o=30){const r=e.clone();r.name=t;const a=[];r.tracks.forEach((e=>{if(0===e.times.length)return;const t=[Math.max(n/o,e.times[0]),Math.min(i/o,e.times[e.times.length-1])];if(t[0]>t[1])return;const r=e.times.findIndex((e=>e>=t[0])),s=e.times.findLastIndex((e=>e<=t[1])),l=e.getValueSize();let c=[],u=kh(e.times)?e.times.subarray(r,s+1):e.times.slice(r,s+1),d=[],h=[],p=kh(e.values)?e.values.subarray(r*l,(s+1)*l):e.values.slice(r*l,(s+1)*l),f=[];const m=r>s;let g,v;(m||t[0]<e.times[r])&&(c=[t[0]],h=e.createInterpolant().evaluate(c[0])),t[0]!==t[1]&&(m||t[1]>e.times[s])&&(d=[t[1]],f=e.createInterpolant().evaluate(d[0])),kh(e.times)?(g=new e.times.constructor(c.length+u.length+d.length),g.set(c),g.set(u,c.length),g.set(d,c.length+u.length)):g=c.concat(u,d),kh(e.values)?(v=new e.values.constructor(h.length+p.length+f.length),v.set(h),v.set(p,h.length),v.set(f,h.length+p.length)):v=h.concat(p,f),e.times=g,e.values=v,a.push(e)}));const s=a.reduce(((e,t)=>Math.min(e,t.times[0])),1/0);return a.forEach((e=>e.shift(-s))),r.tracks=a,r.resetDuration(),r},makeClipAdditive:function(e,t=0,n=e,i=30){i<=0&&(i=30);const o=n.tracks.length,r=t/i;for(let t=0;t<o;++t){const i=n.tracks[t],o=i.ValueTypeName;if("bool"===o||"string"===o)continue;const a=e.tracks.find((function(e){return e.name===i.name&&e.ValueTypeName===o}));if(void 0===a)continue;let s=0;const l=i.getValueSize();i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(s=l/3);let c=0;const u=a.getValueSize();a.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(c=u/3);const d=i.times.length-1;let h;if(r<=i.times[0]){const e=s,t=l-s;h=Vh(i.values,e,t)}else if(r>=i.times[d]){const e=d*l+s,t=e+l-s;h=Vh(i.values,e,t)}else{const e=i.createInterpolant(),t=s,n=l-s;e.evaluate(r),h=Vh(e.resultBuffer,t,n)}if("quaternion"===o){(new li).fromArray(h).normalize().conjugate().toArray(h)}const p=a.times.length;for(let e=0;e<p;++e){const t=e*u+c;if("quaternion"===o)li.multiplyQuaternionsFlat(a.values,t,h,0,a.values,t);else{const e=u-2*c;for(let n=0;n<e;++n)a.values[t+n]-=h[n]}}}return e.blendMode=St,e}});class Yh extends Rd{constructor(e,t,n,i){super(e,t,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:yt,endingEnd:yt}}intervalChanged_(e,t,n){const i=this.parameterPositions;let o=e-2,r=e+1,a=i[o],s=i[r];if(void 0===a)switch(this.getSettings_().endingStart){case bt:o=e,a=2*t-n;break;case Ct:o=i.length-2,a=t+i[o]-i[o+1];break;default:o=e,a=n}if(void 0===s)switch(this.getSettings_().endingEnd){case bt:r=e,s=2*n-t;break;case Ct:r=1,s=n+i[1]-i[0];break;default:r=e-1,s=t}const l=.5*(n-t),c=this.valueSize;this._weightPrev=l/(t-a),this._weightNext=l/(s-n),this._offsetPrev=o*c,this._offsetNext=r*c}interpolate_(e,t,n,i){const o=this.resultBuffer,r=this.sampleValues,a=this.valueSize,s=e*a,l=s-a,c=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,h=this._weightNext,p=(n-t)/(i-t),f=p*p,m=f*p,g=-d*m+2*d*f-d*p,v=(1+d)*m+(-1.5-2*d)*f+(-.5+d)*p+1,A=(-1-h)*m+(1.5+h)*f+.5*p,_=h*m-h*f;for(let e=0;e!==a;++e)o[e]=g*r[c+e]+v*r[l+e]+A*r[s+e]+_*r[u+e];return o}}class Xh{constructor(e,t,n,i){if(void 0===e)throw new Error("v3d.KeyframeTrack: track name is undefined");if(void 0===t||0===t.length)throw new Error("v3d.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=Gh(t,this.TimeBufferType),this.values=Gh(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:Gh(e.times,Array),values:Gh(e.values,Array)};const t=e.getInterpolation();t!==e.DefaultInterpolation&&(n.interpolation=t)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Ld(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Vd(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new Yh(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case At:t=this.InterpolantFactoryMethodDiscrete;break;case _t:t=this.InterpolantFactoryMethodLinear;break;case xt:t=this.InterpolantFactoryMethodSmooth}if(void 0===t){const t="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant){if(e===this.DefaultInterpolation)throw new Error(t);this.setInterpolation(this.DefaultInterpolation)}return console.warn("v3d.KeyframeTrack:",t),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return At;case this.InterpolantFactoryMethodLinear:return _t;case this.InterpolantFactoryMethodSmooth:return xt}}getValueSize(){return this.values.length/this.times.length}shift(e){if(0!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]+=e}return this}scale(e){if(1!==e){const t=this.times;for(let n=0,i=t.length;n!==i;++n)t[n]*=e}return this}trim(e,t){const n=this.times,i=n.length;let o=0,r=i-1;for(;o!==i&&n[o]<e;)++o;for(;-1!==r&&n[r]>t;)--r;if(++r,0!==o||r!==i){o>=r&&(r=Math.max(r,1),o=r-1);const e=this.getValueSize();this.times=Vh(n,o,r),this.values=Vh(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&&kh(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=Vh(this.times),t=Vh(this.values),n=this.getValueSize(),i=this.getInterpolation()===xt,o=e.length-1;let r=1;for(let a=1;a<o;++a){let o=!1;const s=e[a];if(s!==e[a+1]&&(1!==a||s!==e[0]))if(i)o=!0;else{const e=a*n,i=e-n,r=e+n;for(let a=0;a!==n;++a){const n=t[e+a];if(n!==t[i+a]||n!==t[r+a]){o=!0;break}}}if(o){if(a!==r){e[r]=e[a];const i=a*n,o=r*n;for(let e=0;e!==n;++e)t[o+e]=t[i+e]}++r}}if(o>0){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=Vh(e,0,r),this.values=Vh(t,0,r*n)):(this.times=e,this.values=t),this}clone(){const e=Vh(this.times,0),t=Vh(this.values,0),n=new(0,this.constructor)(this.name,e,t);return n.createInterpolant=this.createInterpolant,n}}Xh.prototype.TimeBufferType=Float32Array,Xh.prototype.ValueBufferType=Float32Array,Xh.prototype.DefaultInterpolation=_t;class Kh extends Xh{}Kh.prototype.ValueTypeName="bool",Kh.prototype.ValueBufferType=Array,Kh.prototype.DefaultInterpolation=At,Kh.prototype.InterpolantFactoryMethodLinear=void 0,Kh.prototype.InterpolantFactoryMethodSmooth=void 0;class qh extends Xh{}qh.prototype.ValueTypeName="color";class Zh extends Xh{}Zh.prototype.ValueTypeName="number";class Jh extends Rd{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)li.slerpFlat(o,0,r,l-a,r,l,s);return o}}class $h extends Xh{InterpolantFactoryMethodLinear(e){return new Jh(this.times,this.values,this.getValueSize(),e)}}$h.prototype.ValueTypeName="quaternion",$h.prototype.DefaultInterpolation=_t,$h.prototype.InterpolantFactoryMethodSmooth=void 0;class ep extends Xh{}ep.prototype.ValueTypeName="string",ep.prototype.ValueBufferType=Array,ep.prototype.DefaultInterpolation=At,ep.prototype.InterpolantFactoryMethodLinear=void 0,ep.prototype.InterpolantFactoryMethodSmooth=void 0;class tp extends Xh{}tp.prototype.ValueTypeName="vector";class np{constructor(e,t=-1,n,i=2500){this.name=e,this.tracks=n,this.duration=t,this.blendMode=i,this.uuid=tn(),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(ip(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(Xh.toJSON(n[e]));return i}static CreateFromMorphTargetSequence(e,t,n,i){const o=t.length,r=[];for(let e=0;e<o;e++){let a=[],s=[];a.push((e+o-1)%o,e,(e+1)%o),s.push(0,1,0);const l=Qh(a);a=Wh(a,1,l),s=Wh(s,1,l),i||0!==a[0]||(a.push(o),s.push(s[0])),r.push(new Zh(".morphTargetInfluences["+t[e].name+"]",a,s).scale(1/n))}return new this(e,-1,r)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const t=e;n=t.geometry&&t.geometry.animations||t.animations}for(let e=0;e<n.length;e++)if(n[e].name===t)return n[e];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const i={},o=/^([\w-]*?)([\d]+)$/;for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.name.match(o);if(r&&r.length>1){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=[];Hh(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<l.length;e++){const o=l[e].keys;if(o&&0!==o.length)if(o[0].morphTargets){const e={};let t;for(t=0;t<o.length;t++)if(o[t].morphTargets)for(let n=0;n<o[t].morphTargets.length;n++)e[o[t].morphTargets[n]]=-1;for(const n in e){const e=[],r=[];for(let i=0;i!==o[t].morphTargets.length;++i){const i=o[t];e.push(i.time),r.push(i.morphTarget===n?1:0)}i.push(new Zh(".morphTargetInfluence["+n+"]",e,r))}s=e.length*r}else{const r=".bones["+t[e].name+"]";n(tp,r+".position",o,"pos",i),n($h,r+".quaternion",o,"rot",i),n(tp,r+".scale",o,"scl",i)}}if(0===i.length)return null;return new this(o,s,i,a)}resetDuration(){let e=0;for(let t=0,n=this.tracks.length;t!==n;++t){const n=this.tracks[t];e=Math.max(e,n.times[n.times.length-1])}return this.duration=e,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let t=0;t<this.tracks.length;t++)e.push(this.tracks[t].clone());return new this.constructor(this.name,this.duration,e,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function ip(e){if(void 0===e.type)throw new Error("v3d.KeyframeTrack: track type undefined, can not parse");const t=function(e){switch(e.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Zh;case"vector":case"vector2":case"vector3":case"vector4":return tp;case"color":return qh;case"quaternion":return $h;case"bool":case"boolean":return Kh;case"string":return ep}throw new Error("v3d.KeyframeTrack: Unsupported typeName: "+e)}(e.type);if(void 0===e.times){const t=[],n=[];Hh(e.keys,t,n,"value"),e.times=t,e.values=n}return void 0!==t.parse?t.parse(e):new t(e.name,e.times,e.values,e.interpolation)}const op={enabled:!1,files:{},add:function(e,t){!1!==this.enabled&&(this.files[e]=t)},get:function(e){if(!1!==this.enabled)return this.files[e]},remove:function(e){delete this.files[e]},clear:function(){this.files={}}};class rp{constructor(e,t,n){const i=this;let o,r=!1,a=0,s=0;const l=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this.itemStart=function(e){s++,!1===r&&void 0!==i.onStart&&i.onStart(e,a,s),r=!0},this.itemEnd=function(e){a++,void 0!==i.onProgress&&i.onProgress(e,a,s),a===s&&(r=!1,void 0!==i.onLoad&&i.onLoad())},this.itemError=function(e){void 0!==i.onError&&i.onError(e)},this.resolveURL=function(e){return o?o(e):e},this.setURLModifier=function(e){return o=e,this},this.addHandler=function(e,t){return l.push(e,t),this},this.removeHandler=function(e){const t=l.indexOf(e);return-1!==t&&l.splice(t,2),this},this.getHandler=function(e){for(let t=0,n=l.length;t<n;t+=2){const n=l[t],i=l[t+1];if(n.global&&(n.lastIndex=0),n.test(e))return i}return null}}}const ap=new rp;class sp{constructor(e){this.manager=void 0!==e?e:ap,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise((function(i,o){n.load(e,i,t,o)}))}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}const lp={};class cp extends Error{constructor(e,t){super(e),this.response=t}}class up extends sp{constructor(e){super(e)}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=op.get(e);if(void 0!==o)return this.manager.itemStart(e),setTimeout((()=>{t&&t(o),this.manager.itemEnd(e)}),0),o;if(void 0!==lp[e])return void lp[e].push({onLoad:t,onProgress:n,onError:i});lp[e]=[],lp[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||void 0===t.body.getReader)return t;const n=lp[e],i=t.body.getReader(),o=t.headers.get("Content-Length")||t.headers.get("X-File-Size"),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<t;e++){const t=n[e];t.onProgress&&t.onProgress(i)}e.enqueue(o),t()}}))}()}});return new Response(l)}throw new cp(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((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=>{op.add(e,t);const n=lp[e];delete lp[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onLoad&&i.onLoad(t)}})).catch((t=>{const n=lp[e];if(void 0===n)throw this.manager.itemError(e),t;delete lp[e];for(let e=0,i=n.length;e<i;e++){const i=n[e];i.onError&&i.onError(t)}this.manager.itemError(e)})).finally((()=>{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class dp extends sp{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=op.get(e);if(void 0!==r)return o.manager.itemStart(e),setTimeout((function(){t&&t(r),o.manager.itemEnd(e)}),0),r;const a=Tn("img");function s(){c(),op.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.slice(0,5)&&void 0!==this.crossOrigin&&(a.crossOrigin=this.crossOrigin),o.manager.itemStart(e),a.src=e,a}}class hp extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=new Ac,a=new up(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(o.withCredentials),a.load(e,(function(e){const n=o.parse(e);n&&(void 0!==n.image?r.image=n.image:void 0!==n.data&&(r.image.width=n.width,r.image.height=n.height,r.image.data=n.data),r.wrapS=void 0!==n.wrapS?n.wrapS:he,r.wrapT=void 0!==n.wrapT?n.wrapT:he,r.magFilter=void 0!==n.magFilter?n.magFilter:ve,r.minFilter=void 0!==n.minFilter?n.minFilter:ve,r.anisotropy=void 0!==n.anisotropy?n.anisotropy:1,void 0!==n.encoding&&(r.encoding=n.encoding),void 0!==n.flipY&&(r.flipY=n.flipY),void 0!==n.format&&(r.format=n.format),void 0!==n.type&&(r.type=n.type),void 0!==n.mipmaps&&(r.mipmaps=n.mipmaps,r.minFilter=_e),1===n.mipmapCount&&(r.minFilter=ve),void 0!==n.generateMipmaps&&(r.generateMipmaps=n.generateMipmaps),r.needsUpdate=!0,t&&t(r,n))}),n,i),r}}class pp extends sp{constructor(e){super(e)}load(e,t,n,i){const o=new ni,r=new dp(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(e,(function(e){o.image=e,o.needsUpdate=!0,void 0!==t&&t(o)}),n,i),o}}class fp extends uo{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new qn(e),this.intensity=t,this.isFreeLight=void 0}dispose(){}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.isFreeLight=e.isFreeLight,this}getWorldDirection(e){this.updateMatrixWorld(!0);var t=this.matrixWorld.elements;return e.set(-t[8],-t[9],-t[10]).normalize()}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,void 0!==this.groundColor&&(t.object.groundColor=this.groundColor.getHex()),void 0!==this.distance&&(t.object.distance=this.distance),void 0!==this.angle&&(t.object.angle=this.angle),void 0!==this.decay&&(t.object.decay=this.decay),void 0!==this.penumbra&&(t.object.penumbra=this.penumbra),void 0!==this.shadow&&(t.object.shadow=this.shadow.toJSON()),t}}class mp extends fp{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(uo.DefaultUp),this.updateMatrix(),this.groundColor=new qn(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const gp=new ci;class vp extends fp{constructor(e,t,n=0,i=Math.PI/3,o=0,r=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(uo.DefaultUp),this.updateMatrix(),this.target=new uo,this.distance=n,this.angle=i,this.penumbra=o,this.decay=r,this.map=null,this.shadow=new sl}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.isFreeLight&&this.updateFreeLightTarget()}updateFreeLightTarget(){gp.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,gp),this.target.updateMatrixWorld()}}const Ap=new zi,_p=new ci,xp=new ci;class yp extends nl{constructor(){super(new hr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new yn(4,2),this._viewportCount=6,this._viewports=[new ii(2,1,1,1),new ii(0,1,1,1),new ii(3,1,1,1),new ii(1,1,1,1),new ii(3,0,1,1),new ii(1,0,1,1)],this._cubeDirections=[new ci(1,0,0),new ci(-1,0,0),new ci(0,0,1),new ci(0,0,-1),new ci(0,1,0),new ci(0,-1,0)],this._cubeUps=[new ci(0,1,0),new ci(0,1,0),new ci(0,1,0),new ci(0,1,0),new ci(0,0,1),new ci(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,i=this.matrix,o=e.distance||n.far;o!==n.far&&(n.far=o,n.updateProjectionMatrix()),_p.setFromMatrixPosition(e.matrixWorld),n.position.copy(_p),xp.copy(n.position),xp.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(xp),n.updateMatrixWorld(),i.makeTranslation(-_p.x,-_p.y,-_p.z),Ap.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ap)}}class bp extends fp{constructor(e,t,n=0,i=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new yp}get power(){return 4*this.intensity*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}}class Cp extends nl{constructor(){super(new Fr(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Mp extends nl{constructor(){super(new Fr(-5,5,5,-5,.5,500)),this.maxDistance=10,this.isDirectionalLightShadowCSM=!0}copy(e){return super.copy(e),this.maxDistance=e.maxDistance,this}}const Sp=new ci;class Ep extends fp{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(uo.DefaultUp),this.updateMatrix(),this.target=new uo,this.shadow=new Cp}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}updateMatrixWorld(e){super.updateMatrixWorld(e),this.isFreeLight&&this.updateFreeLightTarget()}updateFreeLightTarget(){Sp.set(0,0,-1).applyQuaternion(this.quaternion).normalize(),this.target.position.addVectors(this.position,Sp),this.target.updateMatrixWorld()}}class wp extends fp{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Tp extends yp{constructor(){super()}}Tp.prototype.isRectAreaLightShadow=!0;class Ip extends fp{constructor(e,t,n=10,i=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=i,this.shadow=new Tp}get power(){return 2*this.intensity*Math.PI}set power(e){this.intensity=e/(2*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Rp{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new ci)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,i=e.y,o=e.z,r=this.coefficients;return t.copy(r[0]).multiplyScalar(.282095),t.addScaledVector(r[1],.488603*i),t.addScaledVector(r[2],.488603*o),t.addScaledVector(r[3],.488603*n),t.addScaledVector(r[4],n*i*1.092548),t.addScaledVector(r[5],i*o*1.092548),t.addScaledVector(r[6],.315392*(3*o*o-1)),t.addScaledVector(r[7],n*o*1.092548),t.addScaledVector(r[8],.546274*(n*n-i*i)),t}getIrradianceAt(e,t){const n=e.x,i=e.y,o=e.z,r=this.coefficients;return t.copy(r[0]).multiplyScalar(.886227),t.addScaledVector(r[1],1.023328*i),t.addScaledVector(r[2],1.023328*o),t.addScaledVector(r[3],1.023328*n),t.addScaledVector(r[4],.858086*n*i),t.addScaledVector(r[5],.858086*i*o),t.addScaledVector(r[6],.743125*o*o-.247708),t.addScaledVector(r[7],.858086*n*o),t.addScaledVector(r[8],.429043*(n*n-i*i)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].fromArray(e,t+3*i);return this}toArray(e=[],t=0){const n=this.coefficients;for(let i=0;i<9;i++)n[i].toArray(e,t+3*i);return e}static getBasisAt(e,t){const n=e.x,i=e.y,o=e.z;t[0]=.282095,t[1]=.488603*i,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*i,t[5]=1.092548*i*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-i*i)}}class Lp extends fp{constructor(e=new Rp,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class Pp extends sp{constructor(e){super(e),this.textures={}}load(e,t,n,i){const o=this,r=new up(o.manager);r.setPath(o.path),r.setRequestHeader(o.requestHeader),r.setWithCredentials(o.withCredentials),r.load(e,(function(n){try{t(o.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),o.manager.itemError(e)}}),n,i)}parse(e){const t=this.textures;function n(e){return void 0===t[e]&&console.warn("v3d.MaterialLoader: Undefined texture",e),t[e]}const i=Pp.createMaterialFromType(e.type);if(void 0!==e.uuid&&(i.uuid=e.uuid),void 0!==e.name&&(i.name=e.name),void 0!==e.color&&void 0!==i.color&&i.color.setHex(e.color),void 0!==e.roughness&&(i.roughness=e.roughness),void 0!==e.metalness&&(i.metalness=e.metalness),void 0!==e.sheen&&(i.sheen=e.sheen),void 0!==e.sheenColor&&(i.sheenColor=(new qn).setHex(e.sheenColor)),void 0!==e.sheenRoughness&&(i.sheenRoughness=e.sheenRoughness),void 0!==e.emissive&&void 0!==i.emissive&&i.emissive.setHex(e.emissive),void 0!==e.specular&&void 0!==i.specular&&i.specular.setHex(e.specular),void 0!==e.specularIntensity&&(i.specularIntensity=e.specularIntensity),void 0!==e.specularColor&&void 0!==i.specularColor&&i.specularColor.setHex(e.specularColor),void 0!==e.shininess&&(i.shininess=e.shininess),void 0!==e.clearcoat&&(i.clearcoat=e.clearcoat),void 0!==e.clearcoatRoughness&&(i.clearcoatRoughness=e.clearcoatRoughness),void 0!==e.iridescence&&(i.iridescence=e.iridescence),void 0!==e.iridescenceIOR&&(i.iridescenceIOR=e.iridescenceIOR),void 0!==e.iridescenceThicknessRange&&(i.iridescenceThicknessRange=e.iridescenceThicknessRange),void 0!==e.transmission&&(i.transmission=e.transmission),void 0!==e.thickness&&(i.thickness=e.thickness),void 0!==e.attenuationDistance&&(i.attenuationDistance=e.attenuationDistance),void 0!==e.attenuationColor&&void 0!==i.attenuationColor&&i.attenuationColor.setHex(e.attenuationColor),void 0!==e.fog&&(i.fog=e.fog),void 0!==e.flatShading&&(i.flatShading=e.flatShading),void 0!==e.blending&&(i.blending=e.blending),void 0!==e.combine&&(i.combine=e.combine),void 0!==e.side&&(i.side=e.side),void 0!==e.shadowSide&&(i.shadowSide=e.shadowSide),void 0!==e.opacity&&(i.opacity=e.opacity),void 0!==e.transparent&&(i.transparent=e.transparent),void 0!==e.alphaTest&&(i.alphaTest=e.alphaTest),void 0!==e.depthTest&&(i.depthTest=e.depthTest),void 0!==e.depthWrite&&(i.depthWrite=e.depthWrite),void 0!==e.colorWrite&&(i.colorWrite=e.colorWrite),void 0!==e.stencilWrite&&(i.stencilWrite=e.stencilWrite),void 0!==e.stencilWriteMask&&(i.stencilWriteMask=e.stencilWriteMask),void 0!==e.stencilFunc&&(i.stencilFunc=e.stencilFunc),void 0!==e.stencilRef&&(i.stencilRef=e.stencilRef),void 0!==e.stencilFuncMask&&(i.stencilFuncMask=e.stencilFuncMask),void 0!==e.stencilFail&&(i.stencilFail=e.stencilFail),void 0!==e.stencilZFail&&(i.stencilZFail=e.stencilZFail),void 0!==e.stencilZPass&&(i.stencilZPass=e.stencilZPass),void 0!==e.wireframe&&(i.wireframe=e.wireframe),void 0!==e.wireframeLinewidth&&(i.wireframeLinewidth=e.wireframeLinewidth),void 0!==e.wireframeLinecap&&(i.wireframeLinecap=e.wireframeLinecap),void 0!==e.wireframeLinejoin&&(i.wireframeLinejoin=e.wireframeLinejoin),void 0!==e.rotation&&(i.rotation=e.rotation),1!==e.linewidth&&(i.linewidth=e.linewidth),void 0!==e.dashSize&&(i.dashSize=e.dashSize),void 0!==e.gapSize&&(i.gapSize=e.gapSize),void 0!==e.scale&&(i.scale=e.scale),void 0!==e.polygonOffset&&(i.polygonOffset=e.polygonOffset),void 0!==e.polygonOffsetFactor&&(i.polygonOffsetFactor=e.polygonOffsetFactor),void 0!==e.polygonOffsetUnits&&(i.polygonOffsetUnits=e.polygonOffsetUnits),void 0!==e.dithering&&(i.dithering=e.dithering),void 0!==e.alphaToCoverage&&(i.alphaToCoverage=e.alphaToCoverage),void 0!==e.premultipliedAlpha&&(i.premultipliedAlpha=e.premultipliedAlpha),void 0!==e.visible&&(i.visible=e.visible),void 0!==e.toneMapped&&(i.toneMapped=e.toneMapped),void 0!==e.userData&&(i.userData=e.userData),void 0!==e.vertexColors&&("number"==typeof e.vertexColors?i.vertexColors=e.vertexColors>0: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 qn).setHex(o.value);break;case"v2":i.uniforms[t].value=(new yn).fromArray(o.value);break;case"v3":i.uniforms[t].value=(new ci).fromArray(o.value);break;case"v4":i.uniforms[t].value=(new ii).fromArray(o.value);break;case"m3":i.uniforms[t].value=(new bn).fromArray(o.value);break;case"m4":i.uniforms[t].value=(new zi).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.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(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 yn).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 yn).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=n(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),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}static createMaterialFromType(e){return new{ShadowMaterial:xd,SpriteMaterial:jl,RawShaderMaterial:Ur,ShaderMaterial:ur,PointsMaterial:Vc,MeshPhysicalMaterial:bd,MeshStandardMaterial:yd,MeshPhongMaterial:Cd,MeshToonMaterial:Md,MeshNormalMaterial:Sd,MeshLambertMaterial:Ed,MeshDepthMaterial:Ks,MeshDistanceMaterial:qs,MeshBasicMaterial:So,MeshMatcapMaterial:wd,LineDashedMaterial:Td,LineBasicMaterial:Ic,Material:Mo}[e]}}class Bp{static decodeText(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let n=0,i=e.length;n<i;n++)t+=String.fromCharCode(e[n]);try{return decodeURIComponent(escape(t))}catch(e){return t}}static extractUrlBase(e){const t=e.lastIndexOf("/");return-1===t?"./":e.slice(0,t+1)}static resolveURL(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Dp extends zo{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class Np extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=new up(o.manager);r.setPath(o.path),r.setRequestHeader(o.requestHeader),r.setWithCredentials(o.withCredentials),r.load(e,(function(n){try{t(o.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),o.manager.itemError(e)}}),n,i)}parse(e){const t={},n={};function i(e,i){if(void 0!==t[i])return t[i];const o=e.interleavedBuffers[i],r=function(e,t){if(void 0!==n[t])return n[t];const i=e.arrayBuffers,o=i[t],r=new Uint32Array(o).buffer;return n[t]=r,r}(e,o.buffer),a=wn(o.type,r),s=new Ql(a,o.stride);return s.uuid=o.uuid,t[i]=s,s}const o=e.isInstancedBufferGeometry?new Dp:new zo,r=e.data.index;if(void 0!==r){const e=wn(r.type,r.array);o.setIndex(new To(e,1))}const a=e.data.attributes;for(const t in a){const n=a[t];let r;if(n.isInterleavedBufferAttribute){const t=i(e.data,n.data);r=new Hl(t,n.itemSize,n.offset,n.normalized)}else{const e=wn(n.type,n.array);r=new(n.isInstancedBufferAttribute?bc:To)(e,n.itemSize,n.normalized)}void 0!==n.name&&(r.name=n.name),void 0!==n.usage&&r.setUsage(n.usage),void 0!==n.updateRange&&(r.updateRange.offset=n.updateRange.offset,r.updateRange.count=n.updateRange.count),o.setAttribute(t,r)}const s=e.data.morphAttributes;if(s)for(const t in s){const n=s[t],r=[];for(let t=0,o=n.length;t<o;t++){const o=n[t];let a;if(o.isInterleavedBufferAttribute){const t=i(e.data,o.data);a=new Hl(t,o.itemSize,o.offset,o.normalized)}else{const e=wn(o.type,o.array);a=new To(e,o.itemSize,o.normalized)}void 0!==o.name&&(a.name=o.name),r.push(a)}o.morphAttributes[t]=r}e.data.morphTargetsRelative&&(o.morphTargetsRelative=!0);const l=e.data.groups||e.data.drawcalls||e.data.offsets;if(void 0!==l)for(let e=0,t=l.length;e!==t;++e){const t=l[e];o.addGroup(t.start,t.count,t.materialIndex)}const c=e.data.boundingSphere;if(void 0!==c){const e=new ci;void 0!==c.center&&e.fromArray(c.center),o.boundingSphere=new Ri(e,c.radius)}return e.name&&(o.name=e.name),e.userData&&(o.userData=e.userData),o}}const Op={UVMapping:re,CubeReflectionMapping:ae,CubeRefractionMapping:se,EquirectangularReflectionMapping:le,EquirectangularRefractionMapping:ce,CubeUVReflectionMapping:ue},Fp={RepeatWrapping:de,ClampToEdgeWrapping:he,MirroredRepeatWrapping:pe},Up={NearestFilter:fe,NearestMipmapNearestFilter:me,NearestMipmapLinearFilter:ge,LinearFilter:ve,LinearMipmapNearestFilter:Ae,LinearMipmapLinearFilter:_e};class zp extends sp{constructor(e){super(e),this.isImageBitmapLoader=!0,"undefined"==typeof createImageBitmap&&console.warn("v3d.ImageBitmapLoader: createImageBitmap() not supported."),"undefined"==typeof fetch&&console.warn("v3d.ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"}}setOptions(e){return this.options=e,this}load(e,t,n,i){void 0===e&&(e=""),void 0!==this.path&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,r=op.get(e);if(void 0!==r)return o.manager.itemStart(e),setTimeout((function(){t&&t(r),o.manager.itemEnd(e)}),0),r;const a={};a.credentials="anonymous"===this.crossOrigin?"same-origin":"include",a.headers=this.requestHeader,fetch(e,a).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(o.options,{colorSpaceConversion:"none"}))})).then((function(n){op.add(e,n),t&&t(n),o.manager.itemEnd(e)})).catch((function(t){i&&i(t),o.manager.itemError(e),o.manager.itemEnd(e)})),o.manager.itemStart(e)}}let Vp;class Gp{static getContext(){return void 0===Vp&&(Vp=new(window.AudioContext||window.webkitAudioContext)),Vp}static setContext(e){Vp=e}}const kp=new zi,Qp=new zi,Wp=new zi;class Hp{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=jp(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=jp();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function jp(){return("undefined"==typeof performance?Date:performance).now()}const Yp=new ci,Xp=new li,Kp=new ci,qp=new ci;class Zp extends uo{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("v3d.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("v3d.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("v3d.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,this.source.stop(),this.source.onended=null,this.isPlaying=!1,this;console.warn("v3d.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}getFilters(){return this.filters}setFilters(e){return e||(e=[]),!0===this._connected?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){if(this.detune=e,void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(!1!==this.hasPlaybackControl)return this.playbackRate=e,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this;console.warn("v3d.Audio: this Audio has no playback control.")}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1}getLoop(){return!1===this.hasPlaybackControl?(console.warn("v3d.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(!1!==this.hasPlaybackControl)return this.loop=e,!0===this.isPlaying&&(this.source.loop=this.loop),this;console.warn("v3d.Audio: this Audio has no playback control.")}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}}const Jp=new ci,$p=new li,ef=new ci,tf=new ci;class nf{constructor(e,t,n){let i,o,r;switch(this.binding=e,this.valueSize=n,t){case"quaternion":i=this._slerp,o=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(6*n),this._workIndex=5;break;case"string":case"bool":i=this._select,o=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(5*n);break;default:i=this._lerp,o=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(5*n)}this._mixBufferRegion=i,this._mixBufferRegionAdditive=o,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,i=this.valueSize,o=e*i+i;let r=this.cumulativeWeight;if(0===r){for(let e=0;e!==i;++e)n[o+e]=n[e];r=t}else{r+=t;const e=t/r;this._mixBufferRegion(n,o,0,e,i)}this.cumulativeWeight=r}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,i=n*this._addIndex;0===this.cumulativeWeightAdditive&&this._setIdentity(),this._mixBufferRegionAdditive(t,i,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,i=e*t+t,o=this.cumulativeWeight,r=this.cumulativeWeightAdditive,a=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const e=t*this._origIndex;this._mixBufferRegion(n,i,e,1-o,t)}r>0&&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<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,i,o){if(i>=.5)for(let i=0;i!==o;++i)e[t+i]=e[n+i]}_slerp(e,t,n,i){li.slerpFlat(e,t,e,t,e,n,i)}_slerpAdditive(e,t,n,i,o){const r=this._workIndex*o;li.multiplyQuaternionsFlat(e,r,e,t,e,n),li.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 of="\\[\\]\\.",rf=new RegExp("["+of+"]","g"),af="[^"+of+"]",sf="[^"+of.replace("\\.","")+"]",lf=(/((?:WC+[\/:])*)/.source.replace("WC",af),/(WCOD+)?/.source.replace("WCOD",sf)),cf=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",af),uf=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",af),df=new RegExp("^"+lf+cf+uf+"$"),hf=["material","materials","bones","map"];class pf{constructor(e,t,n){this.path=t,this.parsedPath=n||pf.parseTrackName(t),this.node=pf.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 pf.Composite(e,t,n):new pf(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(rf,"")}static parseTrackName(e){const t=df.exec(e);if(null===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!==hf.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(void 0===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<e.length;i++){const o=e[i];if(o.name===t||o.uuid===t)return o;const r=n(o.children);if(r)return r}return null},i=n(e.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let i=0,o=n.length;i!==o;++i)e[t++]=n[i]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let i=0,o=n.length;i!==o;++i)n[i]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,o=n.length;i!==o;++i)n[i]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let i=0,o=n.length;i!==o;++i)n[i]=e[t++];if(this.targetObject.matrixWorldNeedsUpdate=!0,"morphTargetInfluences"===this.propertyName){const e=this.targetObject.getAuxClippingMeshes();for(let t=0;t<e.length;t++){const n=e[t];if(n.morphTargetInfluences){const e=this.targetObject.morphTargetInfluences;for(let t=0;t<e.length;t++){const i=e[t];n.morphTargetInfluences[t]=i}}}}}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,i=t.propertyName;let o=t.propertyIndex;if(e||(e=pf.findNode(this.rootNode,t.nodeName)||this.rootNode,this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e)return void console.error("v3d.PropertyBinding: Trying to update node for track: "+this.path+" but it wasn't found.");if(n){let i=t.objectIndex;switch(n){case"materials":if(!e.material)return void console.error("v3d.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.materials)return void console.error("v3d.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);e=e.material.materials;break;case"bones":if(!e.skeleton)return void console.error("v3d.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);e=e.skeleton.bones;for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material)return void console.error("v3d.PropertyBinding: Can not bind to material as node does not have a material.",this);if(!e.material.map)return void console.error("v3d.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);e=e.material.map;break;case"constraints":if(void 0===e.constraints)return void console.error("v3d.PropertyBinding: Can not bind to constraints of node undefined.",this);e=e.constraints,i=i.replace(/"/g,"");for(let t=0;t<e.length;t++)if(e[t].name===i){i=t;break}break;default:if(void 0===e[n])return void console.error("v3d.PropertyBinding: Can not bind to objectName of node undefined.",this);e=e[n]}if(void 0!==i){if(void 0===e[i])return void console.error("v3d.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);e=e[i]}}let r=e[i];if(void 0===r){const n=t.nodeName;return void console.error("v3d.PropertyBinding: Trying to update property for track: "+n+"."+i+" but it wasn't found.",e)}let a=this.Versioning.None;this.targetObject=e,void 0!==e.needsUpdate?a=this.Versioning.NeedsUpdate:void 0!==e.matrixWorldNeedsUpdate&&(a=this.Versioning.MatrixWorldNeedsUpdate);let s=this.BindingType.Direct;if(void 0!==o){if("morphTargetInfluences"===i){if(!e.geometry)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);if(!e.geometry.morphAttributes)return void console.error("v3d.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);void 0!==e.morphTargetDictionary[o]&&(o=e.morphTargetDictionary[o]),this.propertyName=i}else if("nodeValue"==i){if(o=o.replace(/"/g,""),!e.nodeValueMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(o=e.nodeValueMap[o],void 0===o)return void console.error("v3d.PropertyBinding: Animated node not found ",this)}if(s=this.BindingType.ArrayElement,"nodeRGB"==i){if(o=o.replace(/"/g,""),!e.nodeRGBMap)return void console.error("v3d.PropertyBinding: Trying to animate nodes in non-node material",this);if(o=e.nodeRGBMap[o],void 0===o)return void console.error("v3d.PropertyBinding: Animated node not found ",this);s=this.BindingType.HasFromToArray,r=e.nodeRGB[o]}this.resolvedProperty=r,this.propertyIndex=o}else void 0!==r.fromArray&&void 0!==r.toArray?(s=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(s=this.BindingType.EntireArray,this.resolvedProperty=r,"morphTargetInfluences"===i&&(this.propertyName=i)):this.propertyName=i;this.getValue=this.GetterByBindingType[s],this.setValue=this.SetterByBindingTypeAndVersioning[s][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}pf.Composite=class{constructor(e,t,n){const i=n||pf.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,i)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];void 0!==i&&i.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,o=n.length;i!==o;++i)n[i].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}},pf.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},pf.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},pf.prototype.GetterByBindingType=[pf.prototype._getValue_direct,pf.prototype._getValue_array,pf.prototype._getValue_arrayElement,pf.prototype._getValue_toArray],pf.prototype.SetterByBindingTypeAndVersioning=[[pf.prototype._setValue_direct,pf.prototype._setValue_direct_setNeedsUpdate,pf.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_array,pf.prototype._setValue_array_setNeedsUpdate,pf.prototype._setValue_array_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_arrayElement,pf.prototype._setValue_arrayElement_setNeedsUpdate,pf.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[pf.prototype._setValue_fromArray,pf.prototype._setValue_fromArray_setNeedsUpdate,pf.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class ff{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:yt,endingEnd:yt};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=gt,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===St)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!==vt)return!0;if(-1==e)return!0;return 0==(1&e)===this._pingIsEven}_updateTime(e){if(0===e)return this.time;if(this.loop!==mt&&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===mt)return this.time+=e,-1===this._loopCount&&(this._loopCount=0,this._setEndings(!0,!0,!1)),(this.time<t||this.time>n)&&(this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=nn(this.time,t,n),this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})),this.time;var o=this.loop===vt,r=this._loopIsPing(this._loopCount)?1:-1;this.time+=r*e;var a=this.time<t||this.time>n,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=nn(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=bt,i.endingEnd=bt):(i.endingStart=e?this.zeroSlopeAtStart?bt:yt:Ct,i.endingEnd=t?this.zeroSlopeAtEnd?bt:yt:Ct)}_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}}const mf=new Float32Array(1);class gf extends qt{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 nf(pf.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<this._nActiveActions}_addInactiveAction(e,t,n){const i=this._actions,o=this._actionsByClip;let r=o[t];if(void 0===r)r={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,o[t]=r;else{const t=r.knownActions;e._byClipCacheIndex=t.length,t.push(e)}e._cacheIndex=i.length,i.push(e),r.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],i=e._cacheIndex;n._cacheIndex=i,t[i]=n,t.pop(),e._cacheIndex=null;const o=e._clip.uuid,r=this._actionsByClip,a=r[o],s=a.knownActions,l=s[s.length-1],c=e._byClipCacheIndex;l._byClipCacheIndex=c,s[c]=l,s.pop(),e._byClipCacheIndex=null;delete a.actionByRoot[(e._localRoot||this._root).uuid],0===s.length&&delete r[o],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let e=0,n=t.length;e!==n;++e){const n=t[e];0==--n.referenceCount&&this._removeInactiveBinding(n)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,i=this._nActiveActions++,o=t[i];e._cacheIndex=i,t[i]=e,o._cacheIndex=n,t[n]=o}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,i=--this._nActiveActions,o=t[i];e._cacheIndex=i,t[i]=e,o._cacheIndex=n,t[n]=o}_addInactiveBinding(e,t,n){const i=this._bindingsByRootAndName,o=this._bindings;let r=i[t];void 0===r&&(r={},i[t]=r),r[n]=e,e._cacheIndex=o.length,o.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,i=n.rootNode.uuid,o=n.path,r=this._bindingsByRootAndName,a=r[i],s=t[t.length-1],l=e._cacheIndex;s._cacheIndex=l,t[l]=s,t.pop(),delete a[o],0===Object.keys(a).length&&delete r[i]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,i=this._nActiveBindings++,o=t[i];e._cacheIndex=i,t[i]=e,o._cacheIndex=n,t[n]=o}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,i=--this._nActiveBindings,o=t[i];e._cacheIndex=i,t[i]=e,o._cacheIndex=n,t[n]=o}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return void 0===n&&(n=new Vd(new Float32Array(2),new Float32Array(2),1,mf),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,i=--this._nActiveControlInterpolants,o=t[i];e.__cacheIndex=i,t[i]=e,o.__cacheIndex=n,t[n]=o}clipAction(e,t,n){const i=t||this._root,o=i.uuid;let r="string"==typeof e?np.findByName(i,e):e;const a=null!==r?r.uuid:e,s=this._actionsByClip[a];let l=null;if(void 0===n&&(n=null!==r?r.blendMode:Mt),void 0!==s){const e=s.actionByRoot[o];if(void 0!==e&&e.blendMode===n)return e;l=s.knownActions[0],null===r&&(r=l._clip)}if(null===r)return null;const c=new ff(this,r,t,n);return this._bindAction(c,l),this._addInactiveAction(c,a,o),c}existingAction(e,t){const n=t||this._root,i=n.uuid,o="string"==typeof e?np.findByName(n,e):e,r=o?o.uuid:e,a=this._actionsByClip[r];return void 0!==a&&a.actionByRoot[i]||null}stopAllAction(){const e=this._actions;for(let t=this._nActiveActions-1;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;e<this._actions.length;e++)this._actions[e].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,i=this._actionsByClip,o=i[n];if(void 0!==o){const e=o.knownActions;for(let n=0,i=e.length;n!==i;++n){const i=e[n];this._deactivateAction(i);const o=i._cacheIndex,r=t[t.length-1];i._cacheIndex=null,i._byClipCacheIndex=null,r._cacheIndex=o,t[o]=r,t.pop(),this._removeInactiveBindingsForAction(i)}delete i[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const e in n){const i=n[e].actionByRoot[t];void 0!==i&&(this._deactivateAction(i),this._removeInactiveAction(i))}const i=this._bindingsByRootAndName[t];if(void 0!==i)for(const e in i){const t=i[e];t.restoreOriginalState(),this._removeInactiveBinding(t)}}uncacheAction(e,t){const n=this.existingAction(e,t);null!==n&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class vf{constructor(e){this.value=e}clone(){return new vf(void 0===this.value.clone?this.value:this.value.clone())}}let Af=0;const _f=new yn;const xf=new ci,yf=new ci;class bf{constructor(e=new ci,t=new ci){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){xf.subVectors(e,this.start),yf.subVectors(this.end,this.start);const n=yf.dot(yf);let i=yf.dot(xf)/n;return t&&(i=nn(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 Cf=new ci;const Mf=new ci,Sf=new zi,Ef=new zi;function wf(e){const t=[];!0===e.isBone&&t.push(e);for(let n=0;n<e.children.length;n++)t.push.apply(t,wf(e.children[n]));return t}const Tf=new ci,If=new qn,Rf=new qn;const Lf=new ci,Pf=new ci,Bf=new ci;const Df=new ci,Nf=new dr;function Of(e,t,n,i,o,r,a){Df.set(o,r,a).unproject(i);const s=t[e];if(void 0!==s){const e=n.getAttribute("position");for(let t=0,n=s.length;t<n;t++)e.setXYZ(s[t],Df.x,Df.y,Df.z)}}const Ff=new hi;class Uf extends Uc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new zo;i.setIndex(new To(n,1)),i.setAttribute("position",new Lo([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3)),super(i,new Ic({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}const zf=new ci;let Vf,Gf;class kf{constructor(){this.type="ShapePath",this.color=new qn,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new mu,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,i){return this.currentPath.quadraticCurveTo(e,t,n,i),this}bezierCurveTo(e,t,n,i,o,r){return this.currentPath.bezierCurveTo(e,t,n,i,o,r),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const n=t.length;let i=!1;for(let o=n-1,r=0;r<n;o=r++){let n=t[o],a=t[r],s=a.x-n.x,l=a.y-n.y;if(Math.abs(l)>Number.EPSILON){if(l<0&&(n=t[r],s=-s,a=t[o],l=-l),e.y<n.y||e.y>a.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 n=ed.isClockWise,i=this.subPaths;if(0===i.length)return[];let o,r,a;const s=[];if(1===i.length)return r=i[0],a=new Tu,a.curves=r.curves,s.push(a),s;let l=!n(i[0].getPoints());l=e?!l:l;const c=[],u=[];let d,h,p=[],f=0;u[f]=void 0,p[f]=[];for(let t=0,a=i.length;t<a;t++)r=i[t],d=r.getPoints(),o=n(d),o=e?!o:o,o?(!l&&u[f]&&f++,u[f]={s:new Tu,p:d},u[f].s.curves=r.curves,l&&f++,p[f]=[]):p[f].push({h:r,p:d[0]});if(!u[0])return function(e){const t=[];for(let n=0,i=e.length;n<i;n++){const i=e[n],o=new Tu;o.curves=i.curves,t.push(o)}return t}(i);if(u.length>1){let e=!1,n=0;for(let e=0,t=u.length;e<t;e++)c[e]=[];for(let i=0,o=u.length;i<o;i++){const o=p[i];for(let r=0;r<o.length;r++){const a=o[r];let s=!0;for(let o=0;o<u.length;o++)t(a.p,u[o].p)&&(i!==o&&n++,s?(s=!1,c[o].push(a)):e=!0);s&&c[i].push(a)}}n>0&&!1===e&&(p=c)}for(let e=0,t=u.length;e<t;e++){a=u[e].s,s.push(a),h=p[e];for(let e=0,t=h.length;e<t;e++)a.holes.push(h[e].h)}return s}}const Qf=function(){const e=new ArrayBuffer(4),t=new Float32Array(e),n=new Uint32Array(e),i=new Uint32Array(512),o=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,o[e]=24,o[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,o[e]=-t-1,o[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,o[e]=13,o[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,o[e]=24,o[256|e]=24):(i[e]=31744,i[256|e]=64512,o[e]=13,o[256|e]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),s=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,n=0;for(;0==(8388608&t);)t<<=1,n-=8388608;t&=-8388609,n+=947912704,r[e]=t|n}for(let e=1024;e<2048;++e)r[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)a[e]=e<<23;a[31]=1199570944,a[32]=2147483648;for(let e=33;e<63;++e)a[e]=2147483648+(e-32<<23);a[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(s[e]=1024);return{floatView:t,uint32View:n,baseTable:i,shiftTable:o,mantissaTable:r,exponentTable:a,offsetTable:s}}();function Wf(e){Math.abs(e)>65504&&console.warn("v3d.DataUtils.toHalfFloat(): Value out of range."),e=nn(e,-65504,65504),Qf.floatView[0]=e;const t=Qf.uint32View[0],n=t>>23&511;return Qf.baseTable[n]+((8388607&t)>>Qf.shiftTable[n])}function Hf(e){const t=e>>10;return Qf.uint32View[0]=Qf.mantissaTable[Qf.offsetTable[t]+(1023&e)]+Qf.exponentTable[t],Qf.floatView[0]}var jf=Object.freeze({__proto__:null,toHalfFloat:Wf,fromHalfFloat:Hf});class Yf extends Tl{constructor(e,t,n){super(),this.damp=t,this.shader=Ir.afterimage,this.uniforms=cr.clone(this.shader.uniforms),this.uniforms.damp.value=this.damp,this.textureComp=new oi(e.x,e.y,n),this.textureOld=new oi(e.x,e.y,n),this.shaderMaterial=new ur({uniforms:this.uniforms,vertexShader:this.shader.vertexShader,fragmentShader:this.shader.fragmentShader}),this.compFsQuad=new Ll(this.shaderMaterial);const i=new So;this.copyFsQuad=new Ll(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 Xf extends Tl{constructor(e,t,n,i,o){super(),this.strength=void 0!==t?t:1,this.radius=n,this.threshold=i,this.resolution=void 0!==e?new yn(e.x,e.y):new yn(256,256),o=o||{minFilter:ve,magFilter:ve,format:Be},this.clearColor=new qn(0,0,0),this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let r=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);this.renderTargetBright=new oi(r,a,o),this.renderTargetBright.texture.name="BloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e<this.nMips;e++){const t=new oi(r,a,o);t.texture.name="BloomPass.h"+e,t.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(t);const n=new oi(r,a,o);n.texture.name="BloomPass.v"+e,n.texture.generateMipmaps=!1,this.renderTargetsVertical.push(n),r=Math.round(r/2),a=Math.round(a/2)}const s=Ir.bloomLumHighPass;this.highPassUniforms=cr.clone(s.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new ur({type:"BloomHighPass",uniforms:this.highPassUniforms,vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,defines:{}}),this.separableBlurMaterials=[];const l=[3,5,7,9,11];r=Math.round(this.resolution.x/2),a=Math.round(this.resolution.y/2);for(let e=0;e<this.nMips;e++)this.separableBlurMaterials.push(this.getSeperableBlurMaterial(l[e])),this.separableBlurMaterials[e].uniforms.texSize.value=new yn(r,a),r=Math.round(r/2),a=Math.round(a/2);this.compositeMaterial=this.getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1,this.compositeMaterial.needsUpdate=!0;this.compositeMaterial.uniforms.bloomFactors.value=[1,.8,.6,.4,.2],this.bloomTintColors=[new ci(1,1,1),new ci(1,1,1),new ci(1,1,1),new ci(1,1,1),new ci(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors;const c=Ir.copy;this.copyUniforms=cr.clone(c.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ur({type:"BloomCopy",defines:Object.assign({},c.defines),uniforms:this.copyUniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader,blending:b,blendEquation:C,blendEquationAlpha:C,blendSrc:P,blendDst:I,blendSrcAlpha:T,blendDstAlpha:I,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this._oldClearColor=new qn,this.oldClearAlpha=1,this.basic=new So,this.fsQuad=new Ll(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose()}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(n,i);for(let e=0;e<this.nMips;e++)this.renderTargetsHorizontal[e].setSize(n,i),this.renderTargetsVertical[e].setSize(n,i),this.separableBlurMaterials[e].uniforms.texSize.value=new yn(n,i),n=Math.round(n/2),i=Math.round(i/2)}render(e,t,n,i,o){e.getClearColor(this._oldClearColor),this.oldClearAlpha=e.getClearAlpha();const r=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),o&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this.fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this.fsQuad.render(e);let a=this.renderTargetBright;for(let t=0;t<this.nMips;t++)this.fsQuad.material=this.separableBlurMaterials[t],this.separableBlurMaterials[t].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[t].uniforms.direction.value=Xf.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[t]),e.clear(),this.fsQuad.render(e),this.separableBlurMaterials[t].uniforms.colorTexture.value=this.renderTargetsHorizontal[t].texture,this.separableBlurMaterials[t].uniforms.direction.value=Xf.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[t]),e.clear(),this.fsQuad.render(e),a=this.renderTargetsVertical[t];this.fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this.fsQuad.render(e),this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,o&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(n),this.fsQuad.render(e)),e.setClearColor(this._oldClearColor,this.oldClearAlpha),e.autoClear=r}getSeperableBlurMaterial(e){return new ur({type:"BloomSeparableBlur",defines:{KERNEL_RADIUS:e,SIGMA:e},uniforms:{colorTexture:{value:null},texSize:{value:new yn(.5,.5)},direction:{value:new yn(.5,.5)}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_bloom_separable_blur_frag})}getCompositeMaterial(e){return new ur({type:"BloomComposite",defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_bloom_composite_frag})}}Xf.BlurDirectionX=new yn(1,0),Xf.BlurDirectionY=new yn(0,1);class Kf extends Tl{constructor(e,t,n){super(),this.scene=e,this.camera=t;const i=n.width||window.innerWidth||1,o=n.height||window.innerHeight||1,r=new oi(i,o,{minFilter:ve,magFilter:ve,format:Be});this.renderTargetDepth=r.clone(),this.renderTargetDepth.texture.name="BokehPass.depth",this.materialDepth=new Ks,this.materialDepth.depthPacking=Lt,this.materialDepth.blending=v;const a=Ir.bokeh,s=cr.clone(a.uniforms);s.tDepth.value=this.renderTargetDepth.texture,s.focus.value=In(n.focus)?n.focus:1,s.aperture.value=In(n.aperture)?n.aperture:1,s.maxblur.value=In(n.maxblur)?n.maxblur:1,s.depthLeakThreshold.value=In(n.depthLeakThreshold)?n.depthLeakThreshold:.2,s.nearClip.value=t.near,s.farClip.value=t.far,s.aspect.value=t.aspect,Object.defineProperties(this,{focus:{get:function(){return this.uniforms.focus.value},set:function(e){this.uniforms.focus.value=e}},aperture:{get:function(){return this.uniforms.aperture.value},set:function(e){this.uniforms.aperture.value=e}},maxblur:{get:function(){return this.uniforms.maxblur.value},set:function(e){this.uniforms.maxblur.value=e}},depthLeakThreshold:{get:function(){return this.uniforms.depthLeakThreshold.value},set:function(e){this.uniforms.depthLeakThreshold.value=e}}}),this.materialBokeh=new ur({type:"Bokeh",defines:Object.assign({},a.defines),uniforms:s,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.uniforms=s,this.camera2=new Fr(-1,1,1,-1,0,1),this.scene2=new zr,this.quad2=new ir(new Er(2,2),null),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2),this.oldClearColor=new qn,this.oldClearAlpha=1}render(e,t,n,i,o){this.quad2.material=this.materialBokeh,this.scene.overrideMaterial=this.materialDepth,e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();e.autoClear;e.autoClear=!1,e.setClearColor(16777215),e.setClearAlpha(1),e.setRenderTarget(this.renderTargetDepth),e.clear(),e.render(this.scene,this.camera),this.uniforms.tColor.value=n.texture,this.uniforms.nearClip.value=this.camera.near,this.uniforms.farClip.value=this.camera.far,this.uniforms.aspect.value=this.camera.aspect,this.renderToScreen?(e.setRenderTarget(null),e.render(this.scene2,this.camera2)):(e.setRenderTarget(t),e.clear(),e.render(this.scene2,this.camera2)),this.scene.overrideMaterial=null,e.setClearColor(this.oldClearColor),e.setClearAlpha(this.oldClearAlpha),e.autoClear=this.oldAutoClear}setCamera(e){this.camera=e}setSize(e,t){this.renderTargetDepth.setSize(e,t)}dispose(){this.renderTargetDepth.dispose()}}class qf extends Tl{constructor(e,t){super(),this.textureID=void 0!==t?t:"tDiffuse",e instanceof ur?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=cr.clone(e.uniforms),this.material=new ur({type:"ShaderPass",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.fsQuad=new Ll(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.texture),this.fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this.fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this.fsQuad.render(e))}dispose(){this.material.dispose()}}class Zf extends qf{constructor(){super(Ir.brightness_contrast),this.material.type="Grayscale"}get brightness(){return this.uniforms.brightness.value}set brightness(e){this.uniforms.brightness.value=e}get contrast(){return this.uniforms.contrast.value}set contrast(e){this.uniforms.contrast.value=e}}class Jf extends qf{constructor(e,t,n,i){super(Ir.fxaa),this.material.type="FXAA",this.width=void 0!==n?n:512,this.height=void 0!==i?i:256,this.needsSwap=!1}setSize(e,t){this.width=e,this.height=t,this.uniforms.resolution.value.set(1/e,1/t)}}class $f extends qf{constructor(){super(Ir.grayscale),this.material.type="Grayscale"}}class em extends Tl{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),o=e.state;let r,a;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0),this.inverse?(r=0,a=1):(r=1,a=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),o.buffers.stencil.setFunc(i.ALWAYS,r,4294967295),o.buffers.stencil.setClear(a),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(i.EQUAL,1,4294967295),o.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),o.buffers.stencil.setLocked(!0)}setCamera(e){this.camera=e}}class tm extends Tl{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}function nm(){this.positions=[],this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[],this.counters=[],this.geometry=new zo,this.widthCallback=null}function im(e,t,n,i,o){var r;if(e=e.subarray||e.slice?e:e.buffer,n=n.subarray||n.slice?n:n.buffer,e=t?e.subarray?e.subarray(t,o&&t+o):e.slice(t,o&&t+o):e,n.set)n.set(e,i);else for(r=0;r<e.length;r++)n[r+i]=e[r];return n}function om(e){this.headEdge=this.tailEdge=e,this.headIndex=e.index0,this.tailIndex=e.index1,this.indexCount=2}function rm(e,t){this.index0=e,this.index1=t,this.edge0=null,this.edge1=null}function am(){this.geometry=new zo}nm.prototype.setGeometry=function(e,t){if(this.widthCallback=t,this.positions=[],this.counters=[],e instanceof Float32Array||e instanceof Array)for(var n=0;n<e.length;n+=3){t=n/e.length;this.positions.push(e[n],e[n+1],e[n+2]),this.positions.push(e[n],e[n+1],e[n+2]),this.counters.push(t),this.counters.push(t)}this.process()},nm.prototype.compareV3=function(e,t){var n=6*e,i=6*t;return this.positions[n]===this.positions[i]&&this.positions[n+1]===this.positions[i+1]&&this.positions[n+2]===this.positions[i+2]},nm.prototype.copyV3=function(e){var t=6*e;return[this.positions[t],this.positions[t+1],this.positions[t+2]]},nm.prototype.process=function(){var e,t,n=this.positions.length/6;this.previous=[],this.next=[],this.side=[],this.width=[],this.indices_array=[],this.uvs=[];for(var i=0;i<n;i++)this.side.push(1),this.side.push(-1);for(i=0;i<n;i++)e=this.widthCallback?this.widthCallback(i/(n-1)):1,this.width.push(e),this.width.push(e);for(i=0;i<n;i++)this.uvs.push(i/(n-1),0),this.uvs.push(i/(n-1),1);t=this.compareV3(0,n-1)?this.copyV3(n-2):this.copyV3(0),this.previous.push(t[0],t[1],t[2]),this.previous.push(t[0],t[1],t[2]);for(i=0;i<n-1;i++)t=this.copyV3(i),this.previous.push(t[0],t[1],t[2]),this.previous.push(t[0],t[1],t[2]);for(i=1;i<n;i++)t=this.copyV3(i),this.next.push(t[0],t[1],t[2]),this.next.push(t[0],t[1],t[2]);t=this.compareV3(n-1,0)?this.copyV3(1):this.copyV3(n-1),this.next.push(t[0],t[1],t[2]),this.next.push(t[0],t[1],t[2]);for(i=0;i<n-1;i++){var o=2*i;this.indices_array.push(o,o+1,o+2),this.indices_array.push(o+2,o+1,o+3)}this.attributes?(this.attributes.position.copyArray(new Float32Array(this.positions)),this.attributes.position.needsUpdate=!0,this.attributes.previous.copyArray(new Float32Array(this.previous)),this.attributes.previous.needsUpdate=!0,this.attributes.next.copyArray(new Float32Array(this.next)),this.attributes.next.needsUpdate=!0,this.attributes.side.copyArray(new Float32Array(this.side)),this.attributes.side.needsUpdate=!0,this.attributes.width.copyArray(new Float32Array(this.width)),this.attributes.width.needsUpdate=!0,this.attributes.uv.copyArray(new Float32Array(this.uvs)),this.attributes.uv.needsUpdate=!0,this.attributes.counters.copyArray(new Float32Array(this.counters)),this.attributes.counters.needsUpdate=!0,this.attributes.index.copyArray(new Uint16Array(this.indices_array)),this.attributes.index.needsUpdate=!0):this.attributes={position:new To(new Float32Array(this.positions),3),previous:new To(new Float32Array(this.previous),3),next:new To(new Float32Array(this.next),3),side:new To(new Float32Array(this.side),1),width:new To(new Float32Array(this.width),1),uv:new To(new Float32Array(this.uvs),2),counters:new To(new Float32Array(this.counters),1),index:new To(new Uint16Array(this.indices_array),1)},this.geometry.setAttribute("position",this.attributes.position),this.geometry.setAttribute("previous",this.attributes.previous),this.geometry.setAttribute("next",this.attributes.next),this.geometry.setAttribute("side",this.attributes.side),this.geometry.setAttribute("width",this.attributes.width),this.geometry.setAttribute("uv",this.attributes.uv),this.geometry.setAttribute("counters",this.attributes.counters),this.geometry.setIndex(this.attributes.index)},nm.prototype.advance=function(e){var t=this.attributes.position.array,n=this.attributes.previous.array,i=this.attributes.next.array,o=t.length;im(t,0,n,0,o),im(t,6,t,0,o-6),t[o-6]=e.x,t[o-5]=e.y,t[o-4]=e.z,t[o-3]=e.x,t[o-2]=e.y,t[o-1]=e.z,im(t,6,i,0,o-6),i[o-6]=e.x,i[o-5]=e.y,i[o-4]=e.z,i[o-3]=e.x,i[o-2]=e.y,i[o-1]=e.z,this.attributes.position.needsUpdate=!0,this.attributes.previous.needsUpdate=!0,this.attributes.next.needsUpdate=!0},nm.updateAttributes=function(e){var t=e.attributes.position.array,n=(e.attributes.previous.array,e.attributes.next.array,new nm);n.positions=t,n.process(),e.attributes.previous=n.attributes.previous,e.attributes.previous.needsUpdate=!0,e.attributes.next=n.attributes.next,e.attributes.next.needsUpdate=!0},Object.assign(om.prototype,{mergeStrip:function(e){var t=this.headIndex,n=e.headIndex,i=this.tailIndex,o=e.tailIndex;t==n?(this.headEdge.linkToEdge(e.headEdge),e.headEdge.linkToEdge(this.headEdge),this.headEdge=e.tailEdge,this.headIndex=e.tailIndex,this.indexCount+=e.indexCount-1):t==o?(this.headEdge.linkToEdge(e.tailEdge),e.tailEdge.linkToEdge(this.headEdge),this.headEdge=e.headEdge,this.headIndex=e.headIndex,this.indexCount+=e.indexCount-1):i==n?(this.tailEdge.linkToEdge(e.headEdge),e.headEdge.linkToEdge(this.tailEdge),this.tailEdge=e.tailEdge,this.tailIndex=e.tailIndex,this.indexCount+=e.indexCount-1):i==o&&(this.tailEdge.linkToEdge(e.tailEdge),e.tailEdge.linkToEdge(this.tailEdge),this.tailEdge=e.headEdge,this.tailIndex=e.headIndex,this.indexCount+=e.indexCount-1)},getIndicesFlat:function(){for(var e=new Float32Array(this.indexCount),t=0,n=null,i=this.headEdge,o=e[t++]=this.headIndex;null!==i;){o=i.index0==o?i.index1:i.index0;e[t++]=o;var r=i.edge0;r!=n&&null!==r||(r=i.edge1),r==n&&(r=null),n=i,i=r}return e}}),Object.assign(rm.prototype,{linkToEdge:function(e){null===this.edge0?this.edge0=e:null===this.edge1&&(this.edge1=e)}}),Object.assign(am.prototype,{fromBufferGeometry:function(){function e(e,t,n){var i=e.headIndex,o=e.tailIndex;return t[i][0]||t[o][0]||n[i][0]||n[o][0]||null}return function(t){var n=t.getAttribute("position"),i=t.getIndex();if(void 0!==n){var o=[];if(null!==i){(function(t){for(var n=t.length%2?t.length-1:t.length,i={},o={},r=0;r<n;r+=2){var a=(d=new om(new rm(t[r],t[r+1]))).headIndex,s=d.tailIndex;i[a]=i[a]||[],i[s]=i[s]||[],o[a]=o[a]||[],o[s]=o[s]||[],i[a].push(d),o[s].push(d)}var l=new Pd.LinkMap;for(var c in i)i[c].length&&l.push(new Pd.LinkMapNode(i[c]),c);for(var u=[],d=l.first&&l.first.value[0];d;){i[a=d.headIndex].splice(i[a].indexOf(d),1),o[s=d.tailIndex].splice(o[s].indexOf(d),1),0==i[a].length&&l.removeNodeByKey(a);for(var h=e(d,i,o);null!==h;)i[a=h.headIndex].splice(i[a].indexOf(h),1),o[s=h.tailIndex].splice(o[s].indexOf(h),1),0==i[a].length&&l.removeNodeByKey(a),d.mergeStrip(h),h=e(d,i,o);u.push(d),d=l.first&&l.first.value[0]}return u})(i.array).forEach((function(e){var t=new nm,i=new Float32Array(3*e.indexCount);e.getIndicesFlat().forEach((function(e,t){i.set(n.array.subarray(3*e,3*e+3),3*t)})),t.setGeometry(i),o.push(t)}))}else{var r=new nm;r.setGeometry(n.array),o.push(r)}var a=[],s=[],l=[],c=[],u=[],d=[],h=[],p=[],f=0;o.forEach((function(e){a=a.concat(e.positions),s=s.concat(e.previous),l=l.concat(e.next),c=c.concat(e.side),u=u.concat(e.width),d=d.concat(e.uvs),h=h.concat(e.counters);var t=e.indices_array.map((function(e){return e+f}));p=p.concat(t),f+=e.positions.length/3})),this.geometry.setAttribute("position",new To(new Float32Array(a),3)),this.geometry.setAttribute("previous",new To(new Float32Array(s),3)),this.geometry.setAttribute("next",new To(new Float32Array(l),3)),this.geometry.setAttribute("side",new To(new Float32Array(c),1)),this.geometry.setAttribute("width",new To(new Float32Array(u),1)),this.geometry.setAttribute("uv",new To(new Float32Array(d),2)),this.geometry.setAttribute("counters",new To(new Float32Array(h),1));var m=Mn(p)>65535?Uint32Array:Uint16Array;this.geometry.setIndex(new To(new m(p),1))}}}()});class sm extends Ur{constructor(e){super(),this.type="MeshLineMaterial",this.lineWidth=1,this.sizeAttenuation=1,this.color=new qn(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 yn(1,1),this.uniforms={lineWidth:{value:1},sizeAttenuation:{value:1},color:{value:new qn(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 yn(1,1)}},this.vertexShader=wr.raw_meshline_vert,this.fragmentShader=wr.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}}sm.prototype.isMeshLineMaterial=!0;class lm extends Tl{constructor(e,t,n,i){super(),this.renderScene=t,this.renderCamera=n,this.selectedObjects=void 0!==i?i:[],this.visibleEdgeColor=new ii(1,1,1,1),this.hiddenEdgeColor=new ii(.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 yn(e.x,e.y):new yn(256,256);const o=Math.round(this.resolution.x/this.downSampleRatio),r=Math.round(this.resolution.y/this.downSampleRatio);this.renderTargetMaskBuffer=new oi(this.resolution.x,this.resolution.y),this.renderTargetMaskBuffer.texture.name="OutlinePass.mask",this.renderTargetMaskBuffer.texture.generateMipmaps=!1,this.renderTargetDepthBuffer=new oi(this.resolution.x,this.resolution.y),this.renderTargetDepthBuffer.texture.name="OutlinePass.depth",this.renderTargetDepthBuffer.texture.generateMipmaps=!1,this.renderTargetMaskDownSampleBuffer=new oi(o,r),this.renderTargetMaskDownSampleBuffer.texture.name="OutlinePass.depthDownSample",this.renderTargetMaskDownSampleBuffer.texture.generateMipmaps=!1,this.renderTargetBlurBuffer1=new oi(o,r),this.renderTargetBlurBuffer1.texture.name="OutlinePass.blur1",this.renderTargetBlurBuffer1.texture.generateMipmaps=!1,this.renderTargetBlurBuffer2=new oi(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 oi(o,r),this.renderTargetEdgeBuffer1.texture.name="OutlinePass.edge1",this.renderTargetEdgeBuffer1.texture.generateMipmaps=!1,this.renderTargetEdgeBuffer2=new oi(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 yn(o,r),this.separableBlurMaterial1.uniforms.kernelRadius.value=1,this.separableBlurMaterial2=this.getSeparableBlurMaterial(4),this.separableBlurMaterial2.uniforms.texSize.value=new yn(Math.round(o/2),Math.round(r/2)),this.separableBlurMaterial2.uniforms.kernelRadius.value=4,this.overlayMaterial=this.getOverlayMaterial();const a=Ir.copy;this.copyUniforms=cr.clone(a.uniforms),this.copyUniforms.opacity.value=1,this.materialCopy=new ur({defines:Object.assign({},a.defines),uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,blending:v,depthTest:!1,depthWrite:!1,transparent:!0}),this.enabled=!0,this.needsSwap=!1,this.oldClearColor=new qn,this.oldClearAlpha=1,this.basic=new So({toneMapped:!1}),this.fsQuad=new Ll(null),this.camera=new Fr(-1,1,1,-1,0,1),this.tempPulseColor1=new ii,this.tempPulseColor2=new ii,this.textureMatrix=new zi,this.visibilityState=new WeakMap,this._depthMaterial=new Ks({blending:v,depthPacking:Lt,side:m}),this._maskMaterial=new Id({side:m})}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 yn(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 yn(n,i)}saveVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof ir&&e.visibilityState.set(t,t.visible)}))}restoreVisibilityState(){const e=this;e.renderScene.traverse((function(t){t instanceof ir&&(t.visible=e.visibilityState.get(t))}))}changeVisibilityOfSelectedObjects(e){const t=this;function n(n){n instanceof ir&&t.visibilityState.get(n)&&(n.visible=e)}for(let e=0;e<t.selectedObjects.length;e++){const i=t.selectedObjects[e];n(i);const o=i.children;for(let e=0;e<o.length;e++){const t=o[e];t.isMesh&&t.isMaterialGeneratedMesh&&n(t)}}}changeVisibilityOfNonSelectedObjects(e){const t=this,n=[];function i(e){e instanceof ir&&t.visibilityState.get(e)&&n.push(e)}for(let e=0;e<t.selectedObjects.length;e++){const n=t.selectedObjects[e];i(n);const o=n.children;for(let e=0;e<o.length;e++){const t=o[e];t.isMesh&&t.isMaterialGeneratedMesh&&i(t)}}t.renderScene.traverse((function(i){if(i instanceof ir&&t.visibilityState.get(i)){let t=!1;for(let e=0;e<n.length;e++){if(n[e].id===i.id){t=!0;break}}t||(i.visible=e)}}))}updateTextureMatrix(){this.textureMatrix.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),this.textureMatrix.multiply(this.renderCamera.projectionMatrix),this.textureMatrix.multiply(this.renderCamera.matrixWorldInverse)}render(e,t,n,i,o){if(this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),0===this.selectedObjects.length)return;e.getClearColor(this.oldClearColor),this.oldClearAlpha=e.getClearAlpha();const r=e.autoClear;e.autoClear=!1,o&&e.context.disable(e.context.STENCIL_TEST),e.setClearColor(16777215,1);const a=this.renderScene.background;if(this.renderScene.background=null,this.renderScene.traverse((function(e){e.isAnnotationControl&&(e._doUpdateSave=e.doUpdate,e.doUpdate=!1)})),this.saveVisibilityState(),e.setRenderTarget(this.renderTargetDepthBuffer),e.clear(),this.changeVisibilityOfSelectedObjects(!1),this.changeVisibilityOfNonSelectedObjects(!0),this.renderScene.overrideMaterial=this._depthMaterial,e.render(this.renderScene,this.renderCamera),this.updateTextureMatrix(),e.setRenderTarget(this.renderTargetMaskBuffer),e.clear(),this.changeVisibilityOfSelectedObjects(!0),this.changeVisibilityOfNonSelectedObjects(!1),this.renderScene.overrideMaterial=this._maskMaterial,this.renderScene.overrideMaterial.cameraNearFar=new yn(this.renderCamera.near,this.renderCamera.far),this.renderScene.overrideMaterial.depthTexture=this.renderTargetDepthBuffer.texture,this.renderScene.overrideMaterial.textureMatrix=this.textureMatrix,e.render(this.renderScene,this.renderCamera),this.renderScene.overrideMaterial=null,this.restoreVisibilityState(),this.renderScene.background=a,this.fsQuad.material=this.materialCopy,this.copyUniforms.tDiffuse.value=this.renderTargetMaskBuffer.texture,e.setRenderTarget(this.renderTargetMaskDownSampleBuffer),e.clear(),this.fsQuad.render(e),this.tempPulseColor1.copy(this.visibleEdgeColor),this.tempPulseColor2.copy(this.hiddenEdgeColor),this.pulsePeriod>0){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 yn(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=lm.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=lm.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=lm.BlurDirectionX,e.setRenderTarget(this.renderTargetBlurBuffer2),e.clear(),this.fsQuad.render(e),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=lm.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 ur({type:"OutlineEdgeDetection",defines:{HIDDEN_EDGE_ALPHA:1},uniforms:{maskTexture:{value:null},texSize:{value:new yn(.5,.5)},visibleEdgeColor:{value:new ii(1,1,1,1)},hiddenEdgeColor:{value:new ii(1,1,1,1)}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_outline_edge_frag})}getSeparableBlurMaterial(e){return new ur({type:"OutlineSeparableBlur",defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new yn(.5,.5)},direction:{value:new yn(.5,.5)},kernelRadius:{value:1}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_outline_blur_frag})}getOverlayMaterial(){return new ur({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:wr.pp_plane_vert,fragmentShader:wr.pp_outline_overlay_frag,blending:b,blendEquation:C,blendEquationAlpha:C,blendSrc:P,blendDst:B,blendSrcAlpha:I,blendDstAlpha:I,depthTest:!1,depthWrite:!1,transparent:!0})}setCamera(e){this.renderCamera=e}}lm.BlurDirectionX=new yn(1,0),lm.BlurDirectionY=new yn(0,1);class cm extends Tl{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 qn}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 um extends Tl{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 qn;const o=Ir.copy;this.copyUniformsAccum=cr.clone(o.uniforms),this.copyMaterialAccum=new ur({type:"SSAACopyAccum",defines:Object.assign({},o.defines),uniforms:this.copyUniformsAccum,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!0,transparent:!0,blending:_,depthTest:!1,depthWrite:!1}),this.fsQuadAccum=new Ll(this.copyMaterialAccum),this.copyUniformsFinal=cr.clone(o.uniforms),this.copyMaterialFinal=new ur({type:"SSAACopyFinal",defines:Object.assign({},o.defines),uniforms:this.copyUniformsFinal,vertexShader:o.vertexShader,fragmentShader:o.fragmentShader,premultipliedAlpha:!1,transparent:!1,blending:v,depthTest:!1,depthWrite:!1}),this.fsQuadFinal=new Ll(this.copyMaterialFinal),this.iterative=!1,this.iterativeFrame=0}_getJitterOffsets(){return dm[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;n<p;n++){this.dispatchEvent({type:"iteration",frame:n});const o=i[n];this.camera.setViewOffset&&this.camera.setViewOffset(s,l,c+.0625*o[0],u+.0625*o[1],s,l);let r=a;if(this.unbiased){r+=.03125*((n+.5)/i.length-.5)}if(this.copyUniformsAccum.opacity.value=r,e.setClearColor(this.clearColor,this.clearAlpha),e.setRenderTarget(this.sampleRenderTarget),e.clear(),e.render(this.scene,this.camera),this.iterative?e.setRenderTarget(this.accumRenderTarget):e.setRenderTarget(this.renderToScreen?null:t),0===n&&(e.setClearColor(0,0),e.clear()),this.fsQuadAccum.render(e),this.iterativeFrame=n,this.iterative&&performance.now()-h>4)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 dm=[[[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 hm extends Tl{constructor(e,t,n){super(),this.enabled=!0,this.needsSwap=!1,n=n||{},this.objects=n.objects||[],this.steps=In(n.steps)||10,this.stride=In(n.stride)||30,this.binarySearchSteps=In(n.binarySearchSteps)||4,this.renderTargetScale=In(n.renderTargetScale)||.5,this.thickness=In(n.thickness)||.01,this.maxDistance=In(n.maxDistance)||100,this.jitter=In(n.jitter)||1,this.useRefract=In(n.useRefract)||!1,this.renderAfter=In(n.renderAfter)||[],this.simpleRefraction=In(n.simpleRefraction)||!1,this.scene=e,this.camera=t,this._prevClearColor=new qn,this._depthBuffer=new oi(256,256,{minFilter:fe,magFilter:fe,format:Be,type:we}),this._depthBuffer.texture.name="SSRPass.Depth",this._depthBuffer.texture.generateMipmaps=!1,this._depthMaterial=new Ks,this._depthMaterial.depthPacking=Pt,this._backfaceDepthBuffer=this._depthBuffer.clone(),this._backfaceDepthBuffer.texture.name="SSRPass.Depth",this._backfaceDepthMaterial=new Ks,this._backfaceDepthMaterial.depthPacking=Pt,this._backfaceDepthMaterial.side=f,this.basic=new So,this.fsQuad=new Ll(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;e<this.objects.length;e++){const t=this.objects[e],n=t.material;n&&(this._setLayer(t,0),delete n.defines.USE_SSR,delete n.defines.USE_SSR_REFRACT,n.needsUpdate=!0)}this.objects.splice(0);for(let e=0;e<this.renderAfter.length;e++){const t=this.renderAfter[e];this._setLayer(t,0)}this.renderAfter.splice(0)}setCamera(e){this.camera=e}setSize(e,t){e*=this.renderTargetScale,t*=this.renderTargetScale,this._depthBuffer.setSize(e,t),this._backfaceDepthBuffer.setSize(e,t)}render(e,t,n,i,o){const r=this;e.getClearColor(this._prevClearColor);const a=e.getClearAlpha(),s=e.autoClear;e.autoClear=!0,e.setClearColor(new qn(0,0,0),0);const l=this.scene.background;this.scene.background=null;const c=this.camera.layers.mask,u=this.camera.ignoreShadowLayers,d=this.scene.overrideMaterial;this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(t),e.clear(),this.fsQuad.render(e),this.useRefract||(this._depthMaterial.side=m),this.camera.layers.enable(this.useRefract?3:5),this.useRefract&&this.simpleRefraction||(this.scene.overrideMaterial=this._depthMaterial,e.setRenderTarget(this._depthBuffer),e.clear(),e.render(this.scene,this.camera)),this.useRefract||(this.scene.overrideMaterial=this._backfaceDepthMaterial,e.setRenderTarget(this._backfaceDepthBuffer),e.clear(),e.render(this.scene,this.camera)),this.scene.overrideMaterial=d,this.scene.traverse((function(e){e.isLight&&(e.userData.oldLayersMask=e.layers.mask,e.layers.enable(r.useRefract?5:3),r.renderAfter.length&&e.layers.enable(r.useRefract?6:4))}));for(let e=0;e<this.objects.length;e++){const n=this.objects[e],i=n.material;i&&i.isMeshNodeMaterial&&(this._setLayer(n,this.useRefract?5:3),i.defines.USE_SSR="",this.useRefract&&(i.defines.USE_SSR_REFRACT="",this.simpleRefraction&&(i.defines.SSR_SIMPLE_REFRACT="")),i.ssrParams={invProjectionMatrix:(new zi).copy(this.camera.projectionMatrix).invert(),sourceBuffer:t,depthBuffer:this._depthBuffer,backfaceDepthBuffer:this._backfaceDepthBuffer,stride:this.stride,thickness:this.thickness,maxDistance:this.maxDistance,jitter:this.jitter},i.needsUpdate=!0,i.defines.MAX_STEPS!==this.steps&&(i.defines.MAX_STEPS=Math.floor(this.steps),i.needsUpdate=!0),i.defines.BINARY_SEARCH_ITERATIONS!==this.binarySearchSteps&&(i.defines.BINARY_SEARCH_ITERATIONS=Math.floor(this.binarySearchSteps),i.needsUpdate=!0))}for(let e=0;e<this.renderAfter.length;e++){const t=this.renderAfter[e];this._setLayer(t,this.useRefract?6:4)}this.camera.layers.set(this.useRefract?5:3),this.camera.ignoreShadowLayers=!0,e.autoClear=!1,e.setRenderTarget(n),e.render(this.scene,this.camera),this.renderAfter.length&&(this.camera.layers.set(this.useRefract?6:4),e.render(this.scene,this.camera)),this.scene.background=l,this.camera.layers.mask=c,this.camera.ignoreShadowLayers=u,this.scene.traverse((function(e){e.isLight&&"oldLayersMask"in e.userData&&(e.layers.mask=e.userData.oldLayersMask,delete e.userData.oldLayersMask)})),this.renderToScreen&&(this.fsQuad.material=this.basic,this.basic.map=n.texture,e.setRenderTarget(null),e.clear(),this.fsQuad.render(e)),e.setClearColor(this._prevClearColor,a),e.autoClear=s}}class pm extends qf{constructor(){super(Ir.tonemap),this.material.type="ToneMap"}}const fm={Afterimage:Yf,Bloom:Xf,Bokeh:Kf,"Brightness/Contrast":Zf,FXAA:Jf,Grayscale:$f,Mask:em,Outline:lm,Render:cm,SSAA:um,SSR:hm,ToneMapping:pm,"Copy/Other":qf},mm={[Be]:"RGBA",[ft]:"RGBA_BPTC",[et]:"RGBA_ASTC_4x4",[Qe]:"RGB_S3TC_DXT1",[je]:"RGBA_S3TC_DXT5",[Ye]:"RGB_PVRTC_4BPPV1",[Ke]:"RGBA_PVRTC_4BPPV1",[Ze]:"RGB_ETC1",[Je]:"RGB_ETC2",[$e]:"RGB_ETC2_EAC"},gm={getPageParams:function(e){let t=(e=e||window).location.href.toString();const n={};if(-1==t.indexOf("?"))return n;const i=t.split("#")[0].split("?")[1].split("&");for(let e=0;e<i.length;e++){const t=i[e].split("="),o=decodeURIComponent(t[0]);1==t.length?n[o]="":n[o]=decodeURIComponent(t[1])}return n},updatePageParam:function(e,t,n){let i,o,r=null,a="",s=e.split("?"),l=s[0],c=s[1],u="";if(c){i=c.split("#"),o=i[0],r=i[1],r&&(c=o),s=c.split("&");for(let e=0;e<s.length;e++)s[e].split("=")[0]!=t&&(a+=u+s[e],u="&")}else i=l.split("#"),o=i[0],r=i[1],o&&(l=o);r&&(n+="#"+r);return l+"?"+a+(u+""+t+"="+n)},loadScript:function(e,t,n,i){function o(e){a.removeEventListener("load",o,!1),a.removeEventListener("error",r,!1),t.removeChild(a),n(e)}function r(e){a.removeEventListener("load",o,!1),a.removeEventListener("error",r,!1),t.removeChild(a),i(e)}const a=document.createElement("script");a.addEventListener("load",o,!1),a.addEventListener("error",r,!1),t.appendChild(a),a.src=e},drawWatermark:function(e){setTimeout((function(){"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t,v3dl:Yt}}))}),0);const n=e.container;if(3483952072!=fn(Yt))return;const i=["color: #fff;","opacity: 0.5;","font-size: 18px;","font-family: sans-serif;","text-align: center;","text-decoration: none;","position: absolute;","bottom: 1%;","right: 1%;","user-select: none;","z-index: 9999;","text-shadow: 1px 1px #000;"].join("\n"),o=document.createElement("div");o.innerHTML=`<a href="https://www.soft8soft.com/verge3d-trial/" target="_blank" style="${i}">MADE WITH VERGE3D TRIAL</a>`,n.appendChild(o),setTimeout((function(){n.contains(o)&&890310108==fn(o.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=Nn();t.v3d&&(t.v3d.apps=t.v3d.apps||[],-1==t.v3d.apps.indexOf(e)&&t.v3d.apps.push(e))},removeFromAppList:function(e){const t=Nn();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;e<n.programs.length;e++)n.programs[e].profile.calcRenderTime=!0;function r(e,t){t?console.log("%c"+e,"color:red"):console.log(e)}setTimeout((function(){if(r("--- Verge3D Performance Profile ("+t+"s) ---"),!e.scene)return void r("Scene not loaded");const p=e.frame-o,f=Math.round(e._loadingTime);r(`Scene Loading Time: ${f}ms`,f>1e4);const m=-1!=e._loadSceneURL.indexOf(".xz",e._loadSceneURL.length-3);r("Asset Compression: "+(m?"yes":"no"),0==m);const g=p/t;r("FPS: "+g,g<30);const v=n.render.calls/p;r("Render Calls: "+v,v>1e3);const A=n.render.triangles/p;r("Triangles Rendered: "+A,A>1e6),r("Geometry Buffers: "+n.memory.geometries,n.memory.geometries>200),r("HDR Rendering: "+(e.useHDR?"yes":"no")),r("Order-Independent Transparency: "+(e.renderer.useOIT?"yes":"no"));const _=e.renderer.getDrawingBufferSize(new yn);r("Viewport Resolution: "+_.x+"x"+_.y),r(`Pixel Ratio: ${e.renderer.getPixelRatio()} (current) / ${window.devicePixelRatio} (device)`);let x="N/A";switch(e._envIBLMode){case 0:x="PMREM",x+=` ${e._pmremMaxTileSize} px`;break;case 2:x="Light Probe",x+=` ${e._pmremMaxTileSize} px`}r(`Image-Based Lighting: ${x}`);let y=0,b=0,C=0,M=0,S=0,E=0;e.scene.traverse((function(e){e.isLight&&(y++,e.castShadow&&e.shadow&&(M++,S=e.shadow.mapSize.width,E=e.shadow.mapSize.height)),e.isCubeReflectionProbe&&b++,e.isPlaneReflectionProbe&&C++})),r("Lights: "+y,y>10),r(`Reflection Probes: ${b} (cube) / ${C} (plane) `,b>3||C>1);const w=[];if(e.postprocessing){e.postprocessing.gtaoGenerator&&w.push("GTAO");e.postprocessing.composer.passes.forEach((function(e){for(let t in fm)if(e instanceof fm[t])return void w.push(t);w.push("Undefined")}))}r(`Post-Processing: ${w.length?w.join(","):"N/A"}`);let T="N/A";if(M&&e.renderer.shadowMap&&e.renderer.shadowMap.enabled){switch(e.renderer.shadowMap.type){case a:T="Basic";break;case h:T="Bilinear";break;case s:T="PCF";break;case l:T="PCF (Bilinear)";break;case d:T="PCF (Poisson Disk)";break;case u:T="ESM";break;case c:T="VSM";break;default:T="Unknown"}T+=` ${M}x${S}x${E}`}r("Shadow Map: "+T,M>4||S>2048||E>2048);const I=n.programs.slice(0);r("Materials and Shaders: "+I.length,I>100),I.sort((function(e,t){return t.profile.renderTime-e.profile.renderTime}));let R=0;for(let e=0;e<I.length;e++){const t=I[e];t.profile.calcRenderTime=!1;const n=t.profile.materials,i=t.profile.renderTime/p;r("    "+(0==n.length?"System Material":n.join(","))+" - "+t.name+" - "+String(Math.round(10*i)/10)+"ms",i>16),R+=i,t.profile.renderTime=0}r("Total Render Time: "+String(Math.round(10*R)/10)+"ms",R>16),r("Textures & Render Buffers: "+n.memory.textures,n.memory.textures>100);const L=Array.from(n.memory.textureSpecs.values());L.sort((function(e,t){return e.type<t.type?1:e.type>t.type?-1:e.width!=t.width?t.width-e.width:t.height-e.height}));for(let e=0;e<L.length;e++){const t=L[e],n="Texture"==t.type?"- "+mm[t.format]:"";r(`    ${t.name||"N/A"} - ${t.type} - ${t.width}x${t.height} ${n}`,t.width>=4096||t.height>=4096)}n.autoReset=i}),1e3*t)}},vm={prepareRenderer:function(e){const t=wl.getGPUVendor(e),n=wl.getGPUModel(e),i=wl.checkAndroid();i&&"ARM"===t&&"Mali-T760"===n&&(e.compatSettings.saturateSpecEnvBlenderApprox=!0),e.compatSettings.gtaoDisableBkgFix=i}};function Am(e){this.sourceTexture=e,this.camera=new Fr(-1,1,1,-1,0,1),this.shader=new ur({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 <tonemapping_fragment>\n\n            gl_FragColor = linearToOutputTexel(gl_FragColor);\n        }\n        "}),this.shader.map=e,this.shader.uniforms.cubemap.value=e,this.planeMesh=new ir(new Er(2,2),this.shader),this.scene=new zr,this.scene.add(this.camera),this.scene.add(this.planeMesh)}Am.prototype={constructor:Am,render:function(e,t,n=1){var i=e.toneMapping,o=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=Z,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 _m=["alphaMap","aoMap","bumpMap","displacementMap","emissiveMap","envMap","gradientMap","lightMap","map","metalnessMap","normalMap","roughnessMap","specularMap"],xm={disposeTextures:function(e){if(_m.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()}};function ym(e,t,n,{camPos:i=new ci,clipStart:o=.1,clipEnd:r=100}={}){const a=function(e){return!(!wl.checkHalfFloatTex(e,!0)||/Firefox/.test(navigator.userAgent)&&/Android/.test(navigator.userAgent))}(t);a||(console.warn("v3d.RenderUtils: disabling half float cubemaps"),n.texture.type=xe);const s=new fr(o,r,n);s.position.copy(i);let l=e.worldMaterial;if(null!==l&&l.isMeshNodeMaterial){const i=new ir(new rr(1,1,1),l);i.material.side=f,i.material.defines.WORLD_NODES=1,new fr(.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,s.update(t,e),t.autoClearColor=r,e.background=o}else s.update(t,e);return s.renderTarget}function bm(e,t,n,i){t.isMeshNodeMaterial||console.error("v3d.RenderUtils.renderWorldNodeMatToCubemap(): material is not an instance of MeshNodeMaterial.");const o=new zr;return o.worldMaterial=t,ym(o,e,new gr(n,i))}var Cm=Object.freeze({__proto__:null,renderSceneToCubemap:ym,renderWorldNodeMatToCubemap:bm,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}});const Mm=new hi,Sm=new Ri,Em=new zi,wm=new ci,Tm=new ci;class Im extends uo{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 gr(e,{encoding:Rt,format:Be,generateMipmaps:!0,minFilter:_e,type:we}),this._exposureRenderTargetCube=this._renderTargetCube.clone(),this.renderTarget=null,this.matrixWorldInverse=new zi}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=Em;try{o.copy(e.matrixWorld).invert()}catch(e){return!1}switch(o.multiply(this.matrixWorld),this.influenceType){case 0:t=!0;break;case 1:Sm.center.setScalar(0),Sm.radius=this.influenceDistance,Sm.applyMatrix4(o),i?t=i.intersectsSphere(e,Sm):(null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsSphere(Sm));break;case 2:const r=wm.setScalar(0),a=Tm.setScalar(2*this.influenceDistance);Mm.setFromCenterAndSize(r,a),i?t=i.intersectsBox(e,Mm,o):(Mm.applyMatrix4(o),null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsBox(Mm))}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),ym(e,t,this._renderTargetCube,{camPos:this.position,clipStart:this.probeClipStart,clipEnd:this.probeClipEnd}),this._exposureRenderTargetCube.texture.type=this._renderTargetCube.texture.type;const a=new Am(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}}Im.prototype.isCubeReflectionProbe=!0;class Rm{constructor(e,t){if(this.renderer=e,void 0===t){const n=e.getSize(new yn);this._pixelRatio=e.getPixelRatio(),this._width=n.width,this._height=n.height,(t=new oi(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 qf(Ir.copy),this.clock=new Hp}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<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){void 0===e&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let t=0,i=this.passes.length;t<i;t++){const i=this.passes[t];if(!1!==i.enabled){if(i.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(t),i.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),i.needsSwap){if(n){const t=this.renderer.getContext(),n=this.renderer.state.buffers.stencil;n.setFunc(t.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),n.setFunc(t.EQUAL,1,4294967295)}this.swapBuffers()}i instanceof em?n=!0:i instanceof tm&&(n=!1)}}this.renderer.setRenderTarget(t)}reset(e){if(void 0===e){const t=this.renderer.getSize(new yn);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,(e=this.renderTarget1.clone()).setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let e=0;e<this.passes.length;e++)this.passes[e].setSize(n,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}getPixelRatio(){return this._pixelRatio}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}getActiveSSAAPass(){return this.passes[0]instanceof um?this.passes[0]:null}insertPassAfter(e,t){let n=0;for(let e=0;e<this.passes.length;e++)t.indexOf(this.passes[e])>-1&&(n=e+1);this.insertPass(e,n)}enableAllPasses(){for(let e=0;e<this.passes.length;e++)this.passes[e].enabled=!0}disableAllPasses(){for(let e=0;e<this.passes.length;e++)this.passes[e].enabled=!1}setStencil(e){this.renderTarget1.stencilBuffer=e,this.renderTarget1.dispose(),this.renderTarget2.stencilBuffer=e,this.renderTarget2.dispose()}}var Lm,Pm,Bm,Dm={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE_BREAK:19,CAPS_LOCK:20,ESCAPE:27,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT_ARROW:37,UP_ARROW:38,RIGHT_ARROW:39,DOWN_ARROW:40,INSERT:45,DELETE:46,0:48,1:49,2:50,3:51,4:52,5:53,6:54,7:55,8:56,9:57,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LEFT_WINDOW_KEY:91,RIGHT_WINDOW_KEY:92,SELECT_KEY:93,NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,MULTIPLY:106,ADD:107,SUBTRACT:109,DECIMAL_POINT:110,DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUM_LOCK:144,SCROLL_LOCK:145,SEMI_COLON:186,EQUAL_SIGN:187,COMMA:188,DASH:189,PERIOD:190,FORWARD_SLASH:191,GRAVE_ACCENT:192,OPEN_BRACKET:219,BACK_SLASH:220,CLOSE_BRAKET:221,SINGLE_QUOTE:222};class Nm{constructor(e,t=null){this.isKeyDown={};for(const e in Dm)this.isKeyDown[Dm[e]]=!1;if(this.onKeyDown=null,this.onKeyUp=null,this._domElement=e,this._keydownCb=function(e){this.isKeyDown[e.keyCode]=!0,this.onKeyDown&&this.onKeyDown(e)}.bind(this),this._keyupCb=function(e){this.isKeyDown[e.keyCode]=!1,this.onKeyUp&&this.onKeyUp(e)}.bind(this),this._mobileControlTouchStartCb=function(e){this._keydownCb({keyCode:Dm.W})}.bind(this),this._mobileControlTouchEndCb=function(e){this._keyupCb({keyCode:Dm.W})}.bind(this),this._domElement.addEventListener("keydown",this._keydownCb,!1),this._domElement.addEventListener("keyup",this._keyupCb,!1),t&&wl.isTouchDevice()){const e=document.createElement("div");e.className="v3d-mobile-forward",t.appendChild(e),e.addEventListener("touchstart",this._mobileControlTouchStartCb),e.addEventListener("touchend",this._mobileControlTouchEndCb),this._mobileForwardElement=e}}dispose(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._domElement.removeEventListener("keyup",this._keyupCb,!1),this._mobileForwardElement&&(this._mobileForwardElement.removeEventListener("touchstart",this._mobileControlTouchStartCb),this._mobileForwardElement.removeEventListener("touchend",this._mobileControlTouchEndCb),this._mobileForwardElement.remove())}}function Om(){this.posFrom=new ci,this.targetFrom=new ci,this.posTo=new ci,this.targetTo=new ci,this.sphericalFrom=new Yd,this.sphericalTo=new Yd,this.finishCb=function(){},this.movementType=Xt,this.active=!1,this.duration=0,this.clock=new Hp}function Fm(){this.posFrom=new ci,this.targetFrom=new ci,this.posTo=new ci,this.targetTo=new ci,this.zoomFrom=0,this.zoomTo=0,this.finishCb=function(){},this.active=!1,this.duration=0,this.clock=new Hp}Object.assign(Om.prototype,{setup:(Bm=new ci,function({posFrom:e=new ci,targetFrom:t=new ci,posTo:n=new ci,targetTo:i=new ci,finishCb:o=function(){},movementType:r=Xt}){if(this.posFrom.copy(e),this.targetFrom.copy(t),this.posTo.copy(n),this.targetTo.copy(i),this.finishCb=o,this.movementType=r,1===this.movementType){Bm.copy(this.posFrom).sub(this.targetFrom),this.sphericalFrom.setFromVector3(Bm),Bm.copy(this.posTo).sub(this.targetTo),this.sphericalTo.setFromVector3(Bm);var a=vn(this.sphericalFrom.theta),s=vn(this.sphericalTo.theta),l=Math.abs(a-s);l>Math.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:(Lm=new ci,Pm=new ci,function(e=function(e,t,n){}){var t=this.clock.getElapsedTime()/this.duration;if(t=an(t,0,1),Pm.lerpVectors(this.targetFrom,this.targetTo,t),this.movementType===Xt)Lm.lerpVectors(this.posFrom,this.posTo,t);else if(1===this.movementType){var n=rn(this.sphericalFrom.radius,this.sphericalTo.radius,t),i=rn(this.sphericalFrom.phi,this.sphericalTo.phi,t),o=rn(this.sphericalFrom.theta,this.sphericalTo.theta,t);Lm.setFromSphericalCoords(n,i,o),Lm.add(Pm)}e(t,Lm,Pm),t>=1&&(this.active=!1,this.finishCb())})}),Object.assign(Fm.prototype,{setup:function({posFrom:e=new ci,targetFrom:t=new ci,posTo:n=new ci,targetTo:i=new ci,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(){new ci;const e=new ci;return function(t=function(e,t,n){}){let n=this.clock.getElapsedTime()/this.duration;n=an(n,0,1),e.lerpVectors(this.targetFrom,this.targetTo,n);let i=rn(this.zoomFrom,this.zoomTo,n);t(n,e,i),n>=1&&(this.active=!1,this.finishCb())}}()});const Um={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 zm=60,Vm=.001,Gm=.001,km=.001;class Qm extends qt{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=Um.enableDamping,this.enableRotate=Um.enableRotate,this.rotateSpeed=Um.rotateSpeed,this.rotateSpeedTouch=Um.rotateSpeedTouch,this.rotateInertia=Um.rotateInertia,this.rotateInertiaTouch=Um.rotateInertiaTouch,this.enableZoom=Um.enableZoom,this.zoomSpeed=Um.zoomSpeed,this.zoomSpeedKey=Um.zoomSpeedKey,this.zoomInertia=Um.zoomInertia,this.enablePan=Um.enablePan,this.panSpeedKey=Um.panSpeedKey,this.panInertia=Um.panInertia,this.enableKeys=Um.enableKeys,this.gazeLevel=Um.gazeLevel,this.storyHeight=Um.storyHeight,this.collisionMeshes=[];let i=!1;Object.defineProperty(this,"enablePointerLock",{get:()=>i,set(e){i!==e&&(i=e,J())}}),Object.defineProperty(this,"inTween",{get:()=>P.active||B.active});var o,r=new Hp,a=1e-6,s=new ci,l=new ci,c=new ci,u=new ci,d=new li,h=new ci,p={};p[Dm.W]=p[Dm.S]=p[Dm.A]=p[Dm.D]=p[Dm.UP_ARROW]=p[Dm.DOWN_ARROW]=p[Dm.LEFT_ARROW]=p[Dm.RIGHT_ARROW]=0;var f=!1,m=new Yd,g=new Yd,v=new yn,A=1,_=1,x=new yn,y=new yn,b=0,C=0,M=1,S=1,E=new yn,w=new yn,T=1,I=1,R=new yl(new ci,new ci(0,-1,0));R.params.checkVisibility=!1;var L=!1,P=new Om;const B=new Fm;var D={type:"change"},N={type:"start"},O={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 F,U=(F=new yn,function(e,t){return F.set((e-.5*n.screen.width-n.screen.left)/(.5*n.screen.width),(n.screen.height+2*(n.screen.top-t))/n.screen.width),F});const z=function(){const e=new yn;return function(t,i){return e.set(t,-i).multiplyScalar(2/n.screen.width)}}();function V(e){!1!==n.enabled&&(e.preventDefault(),!1!==n.enableRotate&&(y.copy(U(e.pageX,e.pageY).negate()),x.copy(y),f=!0,document.addEventListener("mousemove",G),document.addEventListener("mouseup",k),document.addEventListener("mouseleave",k),n.dispatchEvent(N)))}function G(e){if(!1!==n.enabled&&(e.preventDefault(),f)){if(!1===n.enableRotate)return;y.copy(U(e.pageX,e.pageY).negate()),v.add(y).sub(x),x.copy(y),A=n.rotateSpeed,_=n.rotateInertia}}function k(e){!1!==n.enabled&&(e.preventDefault(),f=!1,document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",k),document.removeEventListener("mouseleave",k),n.dispatchEvent(O))}function Q(e){if(!1!==n.enabled&&!1!==n.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:C-=.025*e.deltaY,M=n.zoomSpeed,S=n.zoomInertia;break;case 1:C-=.01*e.deltaY,M=n.zoomSpeed,S=n.zoomInertia;break;default:C-=25e-5*e.deltaY,M=n.zoomSpeed,S=n.zoomInertia}n.dispatchEvent(N),n.dispatchEvent(O)}}function W(e){if(!1!==n.enabled){var t=e.targetTouches[0];f=!0,y.copy(U(t.pageX,t.pageY).negate()),x.copy(y),n.dispatchEvent(N)}}function H(e){if(!1!==n.enabled){e.preventDefault();var t=e.targetTouches[0];!1!==n.enableRotate&&(y.copy(U(t.pageX,t.pageY).negate()),v.add(y).sub(x),x.copy(y),A=n.rotateSpeedTouch,_=n.rotateInertiaTouch)}}function j(e){if(!1!==n.enabled){if(0===e.targetTouches.length)f=!1;else{if(!1===n.enableRotate)return;f=!0,y.copy(U(e.targetTouches[0].pageX,e.targetTouches[0].pageY).negate()),x.copy(y)}n.dispatchEvent(O)}}function Y(e){!1!==n.enabled&&e.preventDefault()}function X(e){n.domElement.requestPointerLock()}function K(e){document.pointerLockElement===n.domElement?(n.dispatchEvent(N),document.addEventListener("mousemove",Z)):(n.dispatchEvent(O),document.removeEventListener("mousemove",Z))}function q(e){console.error("Pointer lock failed")}function Z(e){e.preventDefault(),n.enabled&&n.enableRotate&&(v.add(z(e.movementX,e.movementY).negate()),A=n.rotateSpeed,_=n.rotateInertia)}function J(){$(),n.domElement.addEventListener("contextmenu",Y),n.enablePointerLock?(n.domElement.addEventListener("click",X),document.addEventListener("pointerlockchange",K),document.addEventListener("pointerlockerror",q)):n.domElement.addEventListener("mousedown",V),n.domElement.addEventListener("wheel",Q,{passive:!1}),n.domElement.addEventListener("touchstart",W,{passive:!0}),n.domElement.addEventListener("touchend",j),n.domElement.addEventListener("touchmove",H,{passive:!1}),(o=new Nm(window,n.domElement.parentElement)).onKeyDown=function(e){e.keyCode in p&&(p[e.keyCode]=1)}}function $(){n.domElement.removeEventListener("contextmenu",Y),n.domElement.removeEventListener("click",X),document.removeEventListener("pointerlockchange",K),document.removeEventListener("pointerlockerror",q),document.removeEventListener("mousemove",Z),n.domElement.removeEventListener("mousedown",V),n.domElement.removeEventListener("wheel",Q),n.domElement.removeEventListener("touchstart",W),n.domElement.removeEventListener("touchend",j),n.domElement.removeEventListener("touchmove",H),document.removeEventListener("mousemove",G),document.removeEventListener("mouseup",k),document.removeEventListener("mouseleave",k),o&&o.dispose()}this.update=function(){new ci;return function(){if(P.active?P.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,C=0,E.set(0,0),w.set(0,0),p)p[o]=0;r.getDelta()}})):B.active?B.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,C=0,E.set(0,0),w.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(-E.x),l.add(c.copy(n.object.up).setLength(E.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?gn(v.x,0,e,_,Vm):0,v.y=n.enableDamping?gn(v.y,0,e,_,Vm):0,g.set(g.radius,g.phi-v.y,g.theta-v.x),E.copy(w),w.x=n.enableDamping?gn(w.x,0,e,I,Gm):0,w.y=n.enableDamping?gn(w.y,0,e,I,Gm):0,E.sub(w),E.multiplyScalar(T),b=C,C=n.enableDamping?gn(C,0,e,S,km):0,b-=C,b*=M,p){var i=t==Dm.A||t==Dm.LEFT_ARROW||t==Dm.D||t==Dm.RIGHT_ARROW,a=t==Dm.W||t==Dm.UP_ARROW||t==Dm.S||t==Dm.DOWN_ARROW,s=i?n.panInertia:n.zoomInertia,l=i?n.panSpeedKey:n.zoomSpeedKey,c=i?Gm:km;if(o.isKeyDown[t])var u=p[t]=1;else{var d=p[t];p[t]=gn(p[t],0,e,s,c),u=d-p[t]}n.enabled&&n.enableKeys&&(i&&!n.enablePan||a&&!n.enableZoom||(u*=e*zm*l,t==Dm.A||t==Dm.LEFT_ARROW?E.x+=u:t==Dm.D||t==Dm.RIGHT_ARROW?E.x-=u:t==Dm.W||t==Dm.UP_ARROW?b+=u:t!=Dm.S&&t!=Dm.DOWN_ARROW||(b-=u)))}}()),n.collisionMeshes.length){R.ray.origin.copy(n.object.position),R.far=n.storyHeight;var e=R.intersectObjects(n.collisionMeshes,!1);if(e.length>0){var t=e[0];n.object.position.y=t.point.y+n.gazeLevel,L=!0}else L&&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(D)}}(),this.forceMouseUp=function(){k({preventDefault:function(){}})},this.dispose=$,this.releaseFromCollision=function(){L=!1},this.tween=function(){var e=new ci,t=new ci,i=new ci;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)<h&&r.manhattanDistanceTo(d)<h?void 0!==s&&s():P.setup({posFrom:n.object.position,targetFrom:d,posTo:o,targetTo:r,finishCb:s,movementType:l}).start(a)}}(),this.tweenZoomTo=function(){const e=new ci,t=new ci;return function(i,o,r,a){if(!n.object.isOrthographicCamera)return void console.warn("v3d.FirstPersonControls: .tweenZoomTo() works only for orthographic camera");const s=n.object.getWorldPosition(e);let l=t.subVectors(i,s).length();const c=n.object.getWorldDirection(t).multiplyScalar(l).add(s);B.setup({zoomFrom:n.object.zoom,targetFrom:c,zoomTo:o,targetTo:i,finishCb:a}).start(r)}}(),J(),this.handleResize(),this.update()}}const Wm={panInertia:.05,panInertiaTouch:.05,panSpeed:20,panSpeedKey:.15,panSpeedTouch:15,rotateInertia:.05,rotateInertiaTouch:.05,rotateSpeed:.9,rotateSpeedTouch:.75,zoomInertia:.05,zoomInertiaTouch:.05,zoomSpeed:150,zoomSpeedKey:.5,zoomSpeedTouch:20,enableDamping:!0,enableRotate:!0,enableZoom:!0,enablePan:!0,enableKeys:!0,minAzimuthAngle:-1/0,maxAzimuthAngle:1/0,minPolarAngle:0,maxPolarAngle:Math.PI};var Hm=60,jm=.001,Ym=.001,Xm=.001;class Km extends qt{constructor(e,t){super();var i=this,o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};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=Wm.enableDamping,this.enableRotate=Wm.enableRotate,this.rotateSpeed=Wm.rotateSpeed,this.rotateSpeedTouch=Wm.rotateSpeedTouch,this.rotateInertia=Wm.rotateInertia,this.rotateInertiaTouch=Wm.rotateInertiaTouch,this.enableZoom=Wm.enableZoom,this.zoomSpeed=Wm.zoomSpeed,this.zoomSpeedKey=Wm.zoomSpeedKey,this.zoomSpeedTouch=Wm.zoomSpeedTouch,this.zoomInertia=Wm.zoomInertia,this.zoomInertiaTouch=Wm.zoomInertiaTouch,this.enablePan=Wm.enablePan,this.panSpeed=Wm.panSpeed,this.panSpeedKey=Wm.panSpeedKey,this.panSpeedTouch=Wm.panSpeedTouch,this.panInertia=Wm.panInertia,this.panInertiaTouch=Wm.panInertiaTouch,this.enableKeys=Wm.enableKeys,this.minAzimuthAngle=Wm.minAzimuthAngle,this.maxAzimuthAngle=Wm.maxAzimuthAngle,this.minPolarAngle=Wm.minPolarAngle,this.maxPolarAngle=Wm.maxPolarAngle,this.mouseButtons={ROTATE:n.LEFT,ZOOM:n.MIDDLE,PAN:n.RIGHT},Object.defineProperty(this,"inTween",{get:()=>O.active||F.active});var r=new Hp,a=1e-6,s=new ci,l=new ci,c=new ci,u=new yn,d=new ci,h=new li,p=o.NONE,f=new ci,m={};m[Dm.W]=m[Dm.S]=m[Dm.A]=m[Dm.D]=m[Dm.UP_ARROW]=m[Dm.DOWN_ARROW]=m[Dm.LEFT_ARROW]=m[Dm.RIGHT_ARROW]=0;var g=new Nm(window);g.onKeyDown=function(e){e.keyCode in m&&(m[e.keyCode]=1)};var v=new Yd,A=new Yd,_=new yn,x=1,y=1,b=new yn,C=new yn,M=0,S=0,E=1,w=1,T=0,I=0,R=new yn,L=new yn,P=1,B=1,D=new yn,N=new yn,O=new Om;const F=new Fm;var U={type:"change"},z={type:"start"},V={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 G,k=(G=new yn,function(e,t){return G.set((e-i.screen.left)/i.screen.width,(t-i.screen.top)/i.screen.height),G}),Q=function(){var e=new yn;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 W(e){if(!1!==i.enabled){switch(e.preventDefault(),e.button){case i.mouseButtons.ROTATE:if(!1===i.enableRotate)return;C.copy(Q(e.pageX,e.pageY).negate()),b.copy(C),p=o.ROTATE;break;case i.mouseButtons.ZOOM:case i.mouseButtons.PAN:if(!1===i.enablePan)return;D.copy(k(e.pageX,e.pageY)),N.copy(D),p=e.button==i.mouseButtons.PAN?o.PAN:o.ZOOM}document.addEventListener("mousemove",H),document.addEventListener("mouseup",j),document.addEventListener("mouseleave",j),i.dispatchEvent(z)}}function H(e){if(!1!==i.enabled)if(e.preventDefault(),p===o.ROTATE){if(!1===i.enableRotate)return;C.copy(Q(e.pageX,e.pageY).negate()),_.add(C).sub(b),b.copy(C),x=i.rotateSpeed,y=i.rotateInertia}else if(p===o.PAN||p===o.ZOOM){if(!1===i.enablePan)return;N.copy(k(e.pageX,e.pageY)),L.add(N).sub(D),D.copy(N),P=i.panSpeed,B=i.panInertia}}function j(e){!1!==i.enabled&&(e.preventDefault(),p=o.NONE,document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",j),document.removeEventListener("mouseleave",j),i.dispatchEvent(V))}function Y(e){if(!1!==i.enabled&&!1!==i.enableZoom){switch(e.preventDefault(),e.stopPropagation(),e.deltaMode){case 2:S-=.025*e.deltaY,E=i.zoomSpeed,w=i.zoomInertia;break;case 1:S-=.01*e.deltaY,E=i.zoomSpeed,w=i.zoomInertia;break;default:S-=25e-5*e.deltaY,E=i.zoomSpeed,w=i.zoomInertia}i.dispatchEvent(z),i.dispatchEvent(V)}}function X(e){if(!1!==i.enabled){var t=e.touches[0],n=e.touches[1];if(1===e.touches.length){if(!1===i.enableRotate)return;p=o.TOUCH_ROTATE,C.copy(Q(t.pageX,t.pageY).negate()),b.copy(C)}else{if(!1===i.enableZoom&&!1===i.enablePan)return;if(p=o.TOUCH_ZOOM_PAN,i.enableZoom){var r=k(t.pageX-n.pageX,t.pageY-n.pageY);T=I=r.length()}if(i.enablePan){var a=k((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2);D.copy(a),N.copy(D)}}i.dispatchEvent(z)}}function K(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;C.copy(Q(t.pageX,t.pageY).negate()),_.add(C).sub(b),b.copy(C),x=i.rotateSpeedTouch,y=i.rotateInertiaTouch}else{if(!1===i.enableZoom&&!1===i.enablePan)return;var o=k(t.pageX-n.pageX,t.pageY-n.pageY),r=(I=o.length())-T;T=I;var a=k((t.pageX+n.pageX)/2,(t.pageY+n.pageY)/2);N.copy(a);var s=u.subVectors(N,D),l=s.length();D.copy(N),i.enableZoom&&Math.abs(r)>Math.abs(l)&&(S+=r,E=i.zoomSpeedTouch,w=i.zoomInertiaTouch),i.enablePan&&Math.abs(r)<=Math.abs(l)&&(L.add(s),P=i.panSpeedTouch,B=i.panInertiaTouch)}}}function q(e){if(!1!==i.enabled){switch(e.touches.length){case 0:p=o.NONE;break;case 1:if(!1===i.enableRotate)return;p=o.TOUCH_ROTATE,C.copy(Q(e.touches[0].pageX,e.touches[0].pageY).negate()),b.copy(C)}i.dispatchEvent(V)}}function Z(e){!1!==i.enabled&&e.preventDefault()}this.update=function(){new ci;return function(){O.active?O.update((function(e,t,n){if(i.object.position.copy(t),i.object.lookAt(n),e>=1){for(var o in A.set(0,0,0),_.set(0,0),M=0,S=0,R.set(0,0),L.set(0,0),m)m[o]=0;r.getDelta()}})):F.active?F.update((function(e,t,n){if(i.object.lookAt(t),i.object.zoom=n,i.object.updateProjectionMatrix(),e>=1){A.set(0,0,0),_.set(0,0),M=0,S=0,R.set(0,0),L.set(0,0);for(let e in m)m[e]=0;r.getDelta()}})):(i.object.getLocalDirection(f),v.setFromVector3(f),v.theta+=A.theta*x,v.phi+=A.phi*x,v.theta=Math.max(i.minAzimuthAngle,Math.min(i.maxAzimuthAngle,v.theta)),v.phi=Math.max(i.minPolarAngle,Math.min(i.maxPolarAngle,v.phi)),v.makeSafe(),f.setFromSpherical(v),s.copy(f).add(i.object.position),i.object.lookAtLocal(s),i.object.isPerspectiveCamera?i.object.position.addScaledVector(f,M):i.object.isOrthographicCamera&&(i.object.zoom*=1+.15*M,i.object.updateProjectionMatrix()),l.copy(f).cross(i.object.up).setLength(-R.x),l.add(c.copy(i.object.up).setLength(R.y)),i.object.position.add(l),function(){var e=r.getDelta();for(var t in A.set(A.radius,_.y,_.x),_.x=i.enableDamping?gn(_.x,0,e,y,jm):0,_.y=i.enableDamping?gn(_.y,0,e,y,jm):0,A.set(A.radius,A.phi-_.y,A.theta-_.x),R.copy(L),L.x=i.enableDamping?gn(L.x,0,e,B,Ym):0,L.y=i.enableDamping?gn(L.y,0,e,B,Ym):0,R.sub(L),R.multiplyScalar(P),M=S,S=i.enableDamping?gn(S,0,e,w,Xm):0,M-=S,M*=E,m){var n=t==Dm.A||t==Dm.LEFT_ARROW||t==Dm.D||t==Dm.RIGHT_ARROW,o=t==Dm.W||t==Dm.UP_ARROW||t==Dm.S||t==Dm.DOWN_ARROW,a=n?i.panInertia:i.zoomInertia,s=n?i.panSpeedKey:i.zoomSpeedKey,l=n?Ym:Xm;if(g.isKeyDown[t])var c=m[t]=1;else{var u=m[t];m[t]=gn(m[t],0,e,a,l),c=u-m[t]}i.enabled&&i.enableKeys&&(n&&!i.enablePan||o&&!i.enableZoom||(c*=e*Hm*s,t==Dm.A||t==Dm.LEFT_ARROW?R.x+=c:t==Dm.D||t==Dm.RIGHT_ARROW?R.x-=c:t==Dm.W||t==Dm.UP_ARROW?M+=c:t!=Dm.S&&t!=Dm.DOWN_ARROW||(M-=c)))}}());var e=!1;d.distanceToSquared(i.object.position)>a&&(d.copy(i.object.position),e=!0),h.dot(i.object.quaternion)<1-a&&(h.copy(i.object.quaternion),e=!0),e&&i.dispatchEvent(U)}}(),this.forceMouseUp=function(){j({preventDefault:function(){}})},this.dispose=function(){this.domElement.removeEventListener("contextmenu",Z),this.domElement.removeEventListener("mousedown",W),this.domElement.removeEventListener("wheel",Y),this.domElement.removeEventListener("touchstart",X),this.domElement.removeEventListener("touchend",q),this.domElement.removeEventListener("touchmove",K),document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",j),document.removeEventListener("mouseleave",j),g.dispose()},this.tween=function(){var e=new ci,t=new ci,n=new ci;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)<h&&r.manhattanDistanceTo(d)<h?void 0!==s&&s():O.setup({posFrom:i.object.position,targetFrom:d,posTo:o,targetTo:r,finishCb:s,movementType:l}).start(a)}}(),this.tweenZoomTo=function(){const e=new ci,t=new ci;return function(n,o,r,a){if(!i.object.isOrthographicCamera)return void console.warn("v3d.FlyingControls: .tweenZoomTo() works only for orthographic camera");const s=i.object.getWorldPosition(e);let l=t.subVectors(n,s).length();const c=i.object.getWorldDirection(t).multiplyScalar(l).add(s);F.setup({zoomFrom:i.object.zoom,targetFrom:c,zoomTo:o,targetTo:n,finishCb:a}).start(r)}}(),this.domElement.addEventListener("contextmenu",Z),this.domElement.addEventListener("mousedown",W),this.domElement.addEventListener("wheel",Y,{passive:!1}),this.domElement.addEventListener("touchstart",X,{passive:!0}),this.domElement.addEventListener("touchend",q),this.domElement.addEventListener("touchmove",K,{passive:!1}),this.handleResize(),this.update()}}var qm,Zm=(qm="undefined"==typeof document?new(require("url").URL)("file:"+__filename).href:document.currentScript&&document.currentScript.src||new URL("v3d.js",document.baseURI).href,function(e){e=void 0!==(e=e||{})?e:{};var t,n,i=Object.assign;e.ready=new Promise((function(e,i){t=e,n=i}));var o,r,a,s,l,c,u=i({},e),d="object"==typeof window,h="function"==typeof importScripts,p="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="";p?(f=h?require("path").dirname(f)+"/":__dirname+"/",c=()=>{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),qm&&(f=qm),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;n<e.length;n++){var i=e[n];i>255&&(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&&P("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<e.length;++r){var a=e.charCodeAt(r);if(a>=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,C,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&&M)return M.decode(e.subarray(t,o));for(var r="";t<o;){var a=e[t++];if(128&a){var s=63&e[t++];if(192!=(224&a)){var l=63&e[t++];if((a=224==(240&a)?(15&a)<<12|s<<6|l:(7&a)<<18|s<<12|l<<6|63&e[t++])<65536)r+=String.fromCharCode(a);else{var c=a-65536;r+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else r+=String.fromCharCode((31&a)<<6|s)}else r+=String.fromCharCode(a)}return r}(C,n,i):"":"boolean"===t?Boolean(e):e;var n,i}var s=_(e),l=[],c=0;if(i)for(var u=0;u<i.length;u++){var d=r[n[u]];d?(0===c&&(c=Y()),l[u]=d(i[u])):l[u]=i[u]}var h=s.apply(null,l);return h=function(e){return 0!==c&&X(c),a(e)}(h)}var y,b,C,M="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function S(t){y=t,e.HEAP8=b=new Int8Array(t),e.HEAP16=new Int16Array(t),e.HEAP32=new Int32Array(t),e.HEAPU8=C=new Uint8Array(t),e.HEAPU16=new Uint16Array(t),e.HEAPU32=new Uint32Array(t),e.HEAPF32=new Float32Array(t),e.HEAPF64=new Float64Array(t)}e.INITIAL_MEMORY;var E,w=[],T=[],I=[],R=0,L=null;function P(t){e.onAbort&&e.onAbort(t),g(t="Aborted("+t+")"),A=!0,t+=". Build with -s ASSERTIONS=1 for more info.";var i=new WebAssembly.RuntimeError(t);throw n(i),i}e.preloadedImages={},e.preloadedAudios={};var B,D,N="data:application/octet-stream;base64,";function O(e){return e.startsWith(N)}function F(e){return e.startsWith("file://")}function U(e){try{if(e==B&&m)return new Uint8Array(m);var t=W(e);if(t)return t;if(a)return a(e);throw"both async and sync fetching of the wasm failed"}catch(e){P(e)}}function z(t){for(;t.length>0;){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(B="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=B,B=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=E.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<e.length);return l};function W(e){if(O(e))return function(e){if("boolean"==typeof p&&p){var t=Buffer.from(e,"base64");return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}try{for(var n=Q(e),i=new Uint8Array(n.length),o=0;o<n.length;++o)i[o]=n.charCodeAt(o);return i}catch(e){throw new Error("Converting base64 string to bytes failed.")}}(e.slice(N.length))}var H,j={b:function(e,t,n){C.copyWithin(e,t,t+n)},a:function(e){var t,n,i=C.length,o=2147483648;if((e>>>=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),E=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(B))return fetch(B,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+B+"'";return e.arrayBuffer()})).catch((function(){return U(B)}));if(r)return new Promise((function(e,t){r(B,(function(t){e(new Uint8Array(t))}),t)}))}return Promise.resolve().then((function(){return U(B)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(e){return e})).then(e,(function(e){g("failed to asynchronously prepare wasm: "+e),P(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(B)||F(B)||"function"!=typeof fetch?a(o):fetch(B,{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(),w.unshift(t);var t;z(w)}(),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 Jm=524288,$m=["","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 eg{constructor(e){this.manager=void 0!==e?e:ap,this.crossOrigin="Anonymous",this.xz=null}init(){return this.xz?Promise.resolve():Zm().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=op.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),op.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+" ("+$m[s]+")"),void(i&&i(s));const l=new Uint8Array(e),c=l.length,u=[];let d=0,h=Math.min(Jm,c),p=0;r(l.subarray(d,h)),function e(){const s=o._emDecompress();if(s)console.error("XZLoader._emDecompress: error code "+s+" ("+$m[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+Jm,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 tg extends sp{constructor(e){super(e),this.reversed=!1}load(e,t,n,i){const o=this,r=new up(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<s.length;l++){var c=s[l],u=e.glyphs.glyphs[a[c]];if(void 0!==c){var d={ha:i(u.advanceWidth*r),x_min:i(u.xMin*r),x_max:i(u.xMax*r),o:""};n&&(u.path.commands=t(u.path.commands)),u.path.commands.forEach((function(e){"c"===e.type.toLowerCase()&&(e.type="b"),d.o+=e.type.toLowerCase()+" ",void 0!==e.x&&void 0!==e.y&&(d.o+=i(e.x*r)+" "+i(e.y*r)+" "),void 0!==e.x1&&void 0!==e.y1&&(d.o+=i(e.x1*r)+" "+i(e.y1*r)+" "),void 0!==e.x2&&void 0!==e.y2&&(d.o+=i(e.x2*r)+" "+i(e.y2*r)+" ")})),o[String.fromCodePoint(u.unicode)]=d}}return{glyphs:o,familyName:e.getEnglishName("fullName"),ascender:i(e.tables.os2.sTypoAscender*r),descender:i(e.tables.os2.sTypoDescender*r),lineGap:e.tables.os2.sTypoLineGap*r,underlinePosition:e.tables.post.underlinePosition,underlineThickness:e.tables.post.underlineThickness,boundingBox:{xMin:e.tables.head.xMin*r,xMax:e.tables.head.xMax*r,yMin:e.tables.head.yMin*r,yMax:e.tables.head.yMax*r},resolution:1e3,original_font_information:e.tables.name}}(opentype.parse(e),this.reversed)}}class ng extends hp{constructor(e){super(e),this.type=we}parse(e){const t=function(e,t){switch(e){case 1:console.error("v3d.RGBELoader Read Error: "+(t||""));break;case 2:console.error("v3d.RGBELoader Write Error: "+(t||""));break;case 3:console.error("v3d.RGBELoader Bad File Format: "+(t||""));break;default:console.error("v3d.RGBELoader: Error: "+(t||""))}return-1},n=function(e,t,n){t=t||1024;let i=e.pos,o=-1,r=0,a="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));for(;0>(o=s.indexOf("\n"))&&r<t&&i<e.byteLength;)a+=s,r+=s.length,i+=128,s+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(i,i+128)));return-1<o&&(!1!==n&&(e.pos+=r+o+1),a+s.slice(0,o))},i=function(e,t,n,i){const o=e[t+3],r=Math.pow(2,o-128)/255;n[i+0]=e[t+0]*r,n[i+1]=e[t+1]*r,n[i+2]=e[t+2]*r,n[i+3]=1},o=function(e,t,n,i){const o=e[t+3],r=Math.pow(2,o-128)/255;n[i+0]=Wf(Math.min(e[t+0]*r,65504)),n[i+1]=Wf(Math.min(e[t+1]*r,65504)),n[i+2]=Wf(Math.min(e[t+2]*r,65504)),n[i+3]=Wf(1)},r=new Uint8Array(e);r.pos=0;const a=function(e){const i=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,r=/^\s*FORMAT=(\S+)\s*$/,a=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,s={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let l,c;if(e.pos>=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])),(c=l.match(o))&&(s.exposure=parseFloat(c[1])),(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&&s<e.byteLength;){if(s+4>e.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(;i<l&&s<e.byteLength;){n=e[s++];const o=n>128;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<n;e++)u[i++]=t}else u.set(e.subarray(s,s+n),i),i+=n,s+=n}const h=o;for(let e=0;e<h;e++){let t=0;r[a]=u[e+t],t+=o,r[a+1]=u[e+t],t+=o,r[a+2]=u[e+t],t+=o,r[a+3]=u[e+t],a+=4}d--}return r}(r.subarray(r.pos),e,n);if(-1!==s){let t,r,l;switch(this.type){case Ee:l=s.length/4;const e=new Float32Array(4*l);for(let t=0;t<l;t++)i(s,4*t,e,4*t);t=e,r=Ee;break;case we:l=s.length/4;const n=new Uint16Array(4*l);for(let e=0;e<l;e++)o(s,4*e,n,4*e);t=n,r=we;break;default:console.error("v3d.RGBELoader: unsupported type: ",this.type)}return{width:e,height:n,data:t,header:a.string,gamma:a.gamma,exposure:a.exposure,type:r}}}return null}setDataType(e){return this.type=e,this}load(e,t,n,i){return super.load(e,(function(e,n){switch(e.type){case Ee:case we:e.encoding=It,e.minFilter=ve,e.magFilter=ve,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,n)}),n,i)}}const ig=new hi,og=new zi,rg=new ci,ag=new ci,sg=new ii;class lg extends uo{constructor(){super(),this.type="PlaneReflectionProbe",this.influenceDistance=1,this.falloff=.5,this.probeClipStart=.1,this.planeSize=new yn(1,1),this.qualityFactor=.75,this.visibilityGroup=null,this.visibilityGroupInv=!1,this.reflectorPlane=new xr,this.normal=new ci,this.reflectorWorldPosition=new ci,this.cameraWorldPosition=new ci,this.rotationMatrix=new zi,this.lookAtPosition=new ci(0,0,-1),this.clipPlane=new ii,this.view=new ci,this.target=new ci,this.textureMatrix=new zi,this.virtualCamera=new hr;const e={minFilter:ve,magFilter:ve,format:Be,encoding:Rt};this.renderTarget=new oi(1024,1024,e),this.matrixWorldInverse=new zi,this.boundingBox=new hi}_calcLocalBounding(){const e=rg.setScalar(0),t=ag.set(2*this.planeSize.x,2*this.influenceDistance/this.scale.y,2*this.planeSize.y);this.boundingBox.setFromCenterAndSize(e,t)}makeMultisampleRenderTarget(e){this.renderTarget.samples=e}setSize(e,t){this.renderTarget.setSize(this.qualityFactor*e,this.qualityFactor*t)}setEncoding(e){this.renderTarget.texture.encoding=e}intersectsMesh(e){let t=!1;const n=e.geometry,i=n.boundsTree,o=og;try{o.copy(e.matrixWorld).invert()}catch(e){return!1}return o.multiply(this.matrixWorld),ig.copy(this.boundingBox),i?t=i.intersectsBox(e,ig,o):(ig.applyMatrix4(o),null===n.boundingBox&&n.computeBoundingBox(),t=n.boundingBox.intersectsBox(ig)),t}update(e,t,n){const i={};e.traverse((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),sg.x=(Math.sign(m.x)+h.elements[8])/h.elements[0],sg.y=(Math.sign(m.y)+h.elements[9])/h.elements[5],sg.z=-1,sg.w=(1+h.elements[10])/h.elements[14],m.multiplyScalar(2/m.dot(sg)),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.useOIT;n.xr.enabled=!1,n.shadowMap.autoUpdate=!1,n.useOIT=!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.useOIT=_,n.setRenderTarget(g);const x=t.viewport;void 0!==x&&n.state.viewport(x),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}}lg.prototype.isPlaneReflectionProbe=!0;class cg{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);Tr.LTC_FLOAT_1=new Ac(n,64,64,Be,Ee,re,he,he,ve,fe,1),Tr.LTC_FLOAT_2=new Ac(i,64,64,Be,Ee,re,he,he,ve,fe,1),Tr.LTC_FLOAT_1.needsUpdate=!0,Tr.LTC_FLOAT_2.needsUpdate=!0;const o=new Uint16Array(e.length);e.forEach((function(e,t){o[t]=Wf(e)}));const r=new Uint16Array(t.length);t.forEach((function(e,t){r[t]=Wf(e)})),Tr.LTC_HALF_1=new Ac(o,64,64,Be,we,re,he,he,ve,fe,1),Tr.LTC_HALF_2=new Ac(r,64,64,Be,we,re,he,he,ve,fe,1),Tr.LTC_HALF_1.needsUpdate=!0,Tr.LTC_HALF_2.needsUpdate=!0}}class ug{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;e<s.length;e++){let t=s[e];l[e]=Array.from?Array.from(t):String(t).split("")}let c=t/n.resolution;a&&(c*=(n.ascender-n.descender)/(n.boundingBox.yMax-n.boundingBox.yMin));n.lineGap=n.lineGap||0,-1===r?r=(n.ascender-n.descender+n.lineGap)*c:r*=t;const u=[];let d=0,h=0;const p=l.length,f=r*p,m=r*Math.abs(n.descender)/n.ascender,g=r-m;switch(o){case"topBaseline":default:h=0;break;case"top":h=-g;break;case"center":h=p>1?.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<l.length;e++){const t=l[e];switch(i){case"left":default:d=0;break;case"center":d=-hg(t,c,n)/2;break;case"right":d=-hg(t,c,n)}for(let e=0;e<t.length;e++){const i=dg(t[e],c,d,h,n);d+=i.offsetX,u.push(i.path)}h-=r}return u}(e,t,this.data,n,i,o,r);for(let e=0,t=s.length;e<t;e++)Array.prototype.push.apply(a,s[e].toShapes());return a}}function dg(e,t,n,i,o){const r=o.glyphs[e]||o.glyphs["?"];if(!r)return void console.error('v3d.Font: character "'+e+'" does not exists in font family '+o.familyName+".");const a=new kf;let s,l,c,u,d,h,p,f;if(r.o){const e=r._cachedOutline||(r._cachedOutline=r.o.split(" "));for(let o=0,r=e.length;o<r;){switch(e[o++]){case"m":s=e[o++]*t+n,l=e[o++]*t+i,a.moveTo(s,l);break;case"l":s=e[o++]*t+n,l=e[o++]*t+i,a.lineTo(s,l);break;case"q":c=e[o++]*t+n,u=e[o++]*t+i,d=e[o++]*t+n,h=e[o++]*t+i,a.quadraticCurveTo(d,h,c,u);break;case"b":c=e[o++]*t+n,u=e[o++]*t+i,d=e[o++]*t+n,h=e[o++]*t+i,p=e[o++]*t+n,f=e[o++]*t+i,a.bezierCurveTo(d,h,p,f,c,u)}}}return{offsetX:r.ha*t,path:a}}function hg(e,t,n){let i=0;for(var o=0;o<e.length;o++){const r=e[o];i+=(n.glyphs[r]||n.glyphs["?"]).ha*t}return i}ug.prototype.isFont=!0;const pg=new ci,fg=new ci;class mg extends uo{constructor(){super(),this.type="ClippingPlaneObject",this.plane=new xr,this.clippingGroup=null,this.clipShadows=!1,this.negated=!1,this.clipIntersection=!1,this.crossSection=!1,this.crossSectionColor=new qn(16711680),this.crossSectionOpacity=1,this.crossSectionRenderSide=p,this.crossSectionSize=100,this._crossMatProfile="blender"}updatePlane(){this.updateWorldMatrix(!0,!1),this.getWorldPosition(pg);const e=this.matrixWorld.elements;fg.set(e[4],e[5],e[6]).normalize(),this.plane.setFromNormalAndCoplanarPoint(fg,pg),this.negated&&this.plane.negate()}updateMatrixWorld(e){uo.prototype.updateMatrixWorld.call(this,e),this.updatePlane()}needsClippingPlane(e){return e.isMesh&&(e.groupNames.indexOf(this.clippingGroup)>=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 So;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=In(s)&&s.length>0,c=r.clone();let u;c.name="ClipCrossSectionStencilBack",c.side=f,c.clippingPlanes=[n],c.stencilFail=Gt,c.stencilZFail=Gt,c.stencilZPass=Gt,a?(u=new gc(o,c),u.skeleton=e.skeleton):u=new ir(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=p,d.clippingPlanes=[n],d.stencilFail=kt,d.stencilZFail=kt,d.stencilZPass=kt,a?(h=new gc(o,d),h.skeleton=e.skeleton):h=new ir(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 Bh({name:"ClipCrossSectionColor",nodeGraph:Bh.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:Vt,stencilZFail:Vt,stencilZPass:Vt,side:this.crossSectionRenderSide});this.crossSectionOpacity<1&&(n.transparent=!0,n.premultipliedAlpha=!0,n.blending=b,n.blendEquation=C,n.blendSrc=I,n.blendDst=B);const i=new Er(this.crossSectionSize,this.crossSectionSize);this.negated?i.rotateX(-Math.PI/2):i.rotateX(Math.PI/2);const o=new ir(i,n);o.name="ClipCrossSectionColor",o.isAuxClippingMesh=!0,o.renderOrder=t,o.onAfterRender=function(e){e.clearStencil()},this.add(o)}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}}mg.prototype.isClippingPlaneObject=!0;const gg={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},vg=60,Ag=.2,_g=.1,xg=.01,yg=new ci(0,1,0),bg=(new li).setFromAxisAngle(new ci(0,0,1),Math.PI),Cg={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY_PAN:4},Mg=1e-6,Sg=new ci,Eg=new ci,wg=new li,Tg=new li,Ig={type:"change"},Rg={type:"start"},Lg={type:"end"};class Pg extends qt{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 uo,this.minDistance=gg.minDistance,this.maxDistance=gg.maxDistance,this.minZoom=gg.minZoom,this.maxZoom=gg.maxZoom,this.minPolarAngle=gg.minPolarAngle,this.maxPolarAngle=gg.maxPolarAngle,this.minAzimuthAngle=gg.minAzimuthAngle,this.maxAzimuthAngle=gg.maxAzimuthAngle,this.enableDamping=gg.enableDamping,this.enableZoom=gg.enableZoom,this.zoomSpeed=gg.zoomSpeed,this.zoomSpeedTouch=gg.zoomSpeedTouch,this.zoomInertia=gg.zoomInertia,this.zoomInertiaTouch=gg.zoomInertiaTouch,this.enableRotate=gg.enableRotate,this.rotateSpeed=gg.rotateSpeed,this.rotateSpeedTouch=gg.rotateSpeedTouch,this.rotateInertia=gg.rotateInertia,this.rotateInertiaTouch=gg.rotateInertiaTouch,this.enablePan=gg.enablePan,this.panSpeed=gg.panSpeed,this.screenSpacePanning=gg.screenSpacePanning,this.panSpeedKey=gg.panSpeedKey,this.panInertia=gg.panInertia,this.autoRotate=gg.autoRotate,this.autoRotateSpeed=gg.autoRotateSpeed,this.enableTurnover=gg.enableTurnover,this.enableKeys=gg.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=Sg.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(Ig),i.update(),o=Cg.NONE},this.update=function(){const e=new ci,t=new ci,n=new ci,h=new li;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=wg.setFromUnitVectors(i.object.up,yg),c=Tg.copy(n).invert();if(t.applyQuaternion(n),r.setFromVector3(t),i.autoRotate&&o===Cg.NONE&&P(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==Cg.NONE&&(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=_n(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(bg):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?gn(m.x,0,e,v,Ag):0,m.y=i.enableDamping?gn(m.y,0,e,v,Ag):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;P(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?gn(y.x,0,e,i.panInertia,_g):0,y.y=i.enableDamping?gn(y.y,0,e,i.panInertia,_g):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]=gn(u[o],0,e,i.panInertia,_g),t=n-u[o]),i.enabled&&i.enableKeys&&i.enablePan&&(t*=e*vg*i.panSpeedKey,o==Dm.A||o==Dm.LEFT_ARROW?x.x+=t:o==Dm.D||o==Dm.RIGHT_ARROW?x.x-=t:o==Dm.W||o==Dm.UP_ARROW?x.y+=t:o!=Dm.S&&o!=Dm.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=Sg.setFromMatrixPosition(i.targetObj.matrixWorld),o=i.object.position;let a=Eg.copy(o).sub(n).length();a*=Math.tan(i.object.fov/2*$t),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?gn(S,1,e,w,xg):1,s/=S}()}return i.targetObj.position.copy(e),!!(c||n.distanceToSquared(i.object.position)>Mg||8*(1-h.dot(i.object.quaternion))>Mg)&&(i.dispatchEvent(Ig),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=Sg.setFromMatrixPosition(i.targetObj.matrixWorld);i.object.parent&&(t=Eg.copy(t),i.object.parent.worldToLocal(t)),t.manhattanDistanceTo(i.object.position)<e&&n.manhattanDistanceTo(s)<e?void 0!==r&&r():I.setup({posFrom:i.object.position,targetFrom:s,posTo:t,targetTo:n,finishCb:r,movementType:a}).start(o)}}(),this.tweenZoomTo=function(e,t,n,o){if(!i.object.isOrthographicCamera)return void console.warn("v3d.OrbitControls: .tweenZoomTo() works only for orthographic camera");i.targetObj.updateWorldMatrix(!0,!1);const r=Sg.setFromMatrixPosition(i.targetObj.matrixWorld);R.setup({zoomFrom:i.object.zoom,targetFrom:r,zoomTo:t,targetTo:e,finishCb:o}).start(n)};const i=this;let o=Cg.NONE;const r=new Yd,a=new Yd;let s=1;const l=new ci;let c=!1;const u={};u[Dm.W]=u[Dm.S]=u[Dm.A]=u[Dm.D]=u[Dm.UP_ARROW]=u[Dm.DOWN_ARROW]=u[Dm.LEFT_ARROW]=u[Dm.RIGHT_ARROW]=0;const d=new Nm(window);d.onKeyDown=function(e){e.keyCode in u&&(u[e.keyCode]=1)};const h=new yn,p=new yn,f=new yn,m=new yn;let g=1,v=1;const A=new yn,_=new yn,x=new yn,y=new yn,b=new yn,C=new yn,M=new yn;let S=1,E=1,w=1;const T=new Hp,I=new Om,R=new Fm;function L(e=1){return Math.pow(.95,E*e)}function P(e){a.theta-=e}function B(e,t){p.set(e,t),m.add(p).sub(h),h.copy(p)}function D(e,t){Sg.setFromMatrixColumn(t,0),Sg.multiplyScalar(-e),l.add(Sg)}function N(e,t){!0===i.screenSpacePanning?Sg.setFromMatrixColumn(t,1):(Sg.setFromMatrixColumn(t,0),Sg.crossVectors(i.object.up,Sg)),Sg.multiplyScalar(e),l.add(Sg)}function O(e){i.object.isPerspectiveCamera?S/=e:i.object.isOrthographicCamera?(S/=e,c=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function F(e){i.object.isPerspectiveCamera?S*=e:i.object.isOrthographicCamera?(S*=e,c=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),i.enableZoom=!1)}function U(e){var t,n;t=e.clientX,n=e.clientY,_.set(t,n),y.add(_).sub(A),A.copy(_)}function z(e){if(!1!==i.enabled){switch(e.preventDefault(),e.button){case i.mouseButtons.ROTATE:if(!1===i.enableRotate)return;!function(e){h.set(e.clientX,e.clientY)}(e),o=Cg.ROTATE;break;case i.mouseButtons.ZOOM:case i.mouseButtons.PAN:if(!1===i.enablePan)return;!function(e){A.set(e.clientX,e.clientY)}(e),o=Cg.PAN}o!==Cg.NONE&&(document.addEventListener("mousemove",V),document.addEventListener("mouseup",G),document.addEventListener("mouseleave",G),i.dispatchEvent(Rg))}}function V(e){if(!1!==i.enabled)switch(e.preventDefault(),o){case Cg.ROTATE:if(!1===i.enableRotate)return;!function(e){B(e.clientX,e.clientY),g=i.rotateSpeed,v=i.rotateInertia}(e);break;case Cg.DOLLY:if(!1===i.enableZoom)return;!function(e){C.set(e.clientX,e.clientY),M.subVectors(C,b),M.y>0?O(L()):M.y<0&&F(L()),b.copy(C),i.update()}(e);break;case Cg.PAN: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(Lg),o=Cg.NONE)}function k(e){!1===i.enabled||!1===i.enableZoom||o!==Cg.NONE&&o!==Cg.ROTATE||(e.preventDefault(),e.stopPropagation(),i.dispatchEvent(Rg),function(e){E=i.zoomSpeed,w=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(Lg))}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=Cg.TOUCH_ROTATE;break;case 2:if(!1===i.enableZoom&&!1===i.enablePan)return;!function(e){if(i.enableZoom){E=i.zoomSpeedTouch,w=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=Cg.TOUCH_DOLLY_PAN;break;default:o=Cg.NONE}o!==Cg.NONE&&i.dispatchEvent(Rg)}}function W(e){if(!1!==i.enabled)switch(e.preventDefault(),e.touches.length){case 1:if(!1===i.enableRotate)return;if(o!==Cg.TOUCH_ROTATE)return;!function(e){B(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!==Cg.TOUCH_DOLLY_PAN)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);C.set(0,o),M.subVectors(C,b),b.copy(C);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(M.length())>Math.abs(x.length())&&(M.y>0?F(L()):M.y<0&&O(L())),i.enablePan&&Math.abs(M.length())<Math.abs(x.length())&&y.add(x),i.update()}(e);break;default:o=Cg.NONE}}function H(e){!1!==i.enabled&&(i.dispatchEvent(Lg),o=Cg.NONE)}function j(e){!1!==i.enabled&&e.preventDefault()}i.domElement.addEventListener("contextmenu",j),i.domElement.addEventListener("mousedown",z),i.domElement.addEventListener("wheel",k,{passive:!1}),i.domElement.addEventListener("touchstart",Q,{passive:!0}),i.domElement.addEventListener("touchend",H),i.domElement.addEventListener("touchmove",W,{passive:!1}),this.update()}set target(e){console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead")}get target(){return console.warn("v3d.OrbitControls: .target has been deprecated, use .targetObj instead"),new ci}}Pg.prototype.isOrbitControls=!0;const Bg={ORBIT:gg,FIRST_PERSON:Um,FLYING:Wm};class Dg{constructor(e="ORBIT",t=!0,n=1,i=1){this.type=e,this.enablePan=t,this.enableZoom=!0,this.enableKeys=!0,this.rotateSpeed=n,this.moveSpeed=i,this.orbitMinDistance=gg.minDistance,this.orbitMaxDistance=gg.maxDistance,this.orbitMinZoom=gg.minZoom,this.orbitMaxZoom=gg.maxZoom,this.orbitMinPolarAngle=gg.minPolarAngle,this.orbitMaxPolarAngle=gg.maxPolarAngle,this.orbitMinAzimuthAngle=gg.minAzimuthAngle,this.orbitMaxAzimuthAngle=gg.maxAzimuthAngle,this.orbitEnableTurnover=gg.enableTurnover,this.orbitTarget=null,this.collisionMaterial=null,this.gazeLevel=Um.gazeLevel,this.storyHeight=Um.storyHeight,this.enablePointerLock=!1}copy(e){return this.type=e.type,this.enablePan=e.enablePan,this.enableZoom=e.enableZoom,this.enableKeys=e.enableKeys,this.rotateSpeed=e.rotateSpeed,this.moveSpeed=e.moveSpeed,this.orbitMinDistance=e.orbitMinDistance,this.orbitMaxDistance=e.orbitMaxDistance,this.orbitMinZoom=e.orbitMinZoom,this.orbitMaxZoom=e.orbitMaxZoom,this.orbitMinPolarAngle=e.orbitMinPolarAngle,this.orbitMaxPolarAngle=e.orbitMaxPolarAngle,this.orbitMinAzimuthAngle=e.orbitMinAzimuthAngle,this.orbitMaxAzimuthAngle=e.orbitMaxAzimuthAngle,this.orbitEnableTurnover=e.orbitEnableTurnover,this.orbitTarget=e.orbitTarget,this.collisionMaterial=e.collisionMaterial,this.gazeLevel=e.gazeLevel,this.storyHeight=e.storyHeight,this.enablePointerLock=e.enablePointerLock,this}clone(){return(new this.constructor).copy(this)}assignToControls(e,t){const n=Bg[this.type];switch(this.type){case"ORBIT":e.targetObj=this.orbitTarget,e.minDistance=this.orbitMinDistance,e.maxDistance=this.orbitMaxDistance,e.minZoom=this.orbitMinZoom,e.maxZoom=this.orbitMaxZoom,e.minPolarAngle=this.orbitMinPolarAngle,e.maxPolarAngle=this.orbitMaxPolarAngle,e.minAzimuthAngle=this.orbitMinAzimuthAngle,e.maxAzimuthAngle=this.orbitMaxAzimuthAngle,e.enableTurnover=this.orbitEnableTurnover;break;case"FLYING":e.panSpeedTouch=n.panSpeedTouch*this.moveSpeed,e.zoomSpeedKey=n.zoomSpeedKey*this.moveSpeed;break;case"FIRST_PERSON":e.gazeLevel=this.gazeLevel,e.storyHeight=this.storyHeight,e.zoomSpeedKey=n.zoomSpeedKey*this.moveSpeed,e.enablePointerLock=this.enablePointerLock;const i=this;e.collisionMeshes=[],t.traverse((function(t){const n=t.material;n&&i.collisionMaterial&&n.name==i.collisionMaterial.name&&e.collisionMeshes.push(t)}));break;default:return void console.error("ControlSettings: unsupported control type")}e.enablePan=this.enablePan,e.enableZoom=this.enableZoom,e.enableKeys=this.enableKeys,e.rotateSpeed=n.rotateSpeed*this.rotateSpeed,e.rotateSpeedTouch=n.rotateSpeedTouch*this.rotateSpeed,e.panSpeed=n.panSpeed*this.moveSpeed,e.panSpeedKey=n.panSpeedKey*this.moveSpeed,e.zoomSpeed=n.zoomSpeed*this.moveSpeed,e.zoomSpeedTouch=n.zoomSpeedTouch*this.moveSpeed}}class Ng{constuctor(){this.name="",this.type="Constraint",this.mute=!1}_updateObjMatrixWorld(e){e.matrixAutoUpdate&&e.matrix.compose(e.position,e.quaternion,e.scale),null==e.parent?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix)}update(e){this.mute}copy(e){return this.name=e.name,this.mute=e.mute,this}clone(){return(new this.constructor).copy(this)}}Ng.prototype.isConstraint=!0;class Og extends Ng{constructor(e){super(),this.type="TargetConstraint",this.target=e}copy(e){return super.copy(e),this.target=e.target,this}clone(){return new this.constructor(this.target).copy(this)}}Og.prototype.isTargetConstraint=!0;const Fg=new zi,Ug=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2);class zg extends Og{constructor(e){super(e),this.type="ChildOfConstraint",this.offsetMatrix=new zi,this.fixCameraLightRotation=!1}copy(e){return super.copy(e),this.offsetMatrix.copy(e.offsetMatrix),this.fixCameraLightRotation=e.fixCameraLightRotation,this}update(e){super.update(e),this.mute||(Fg.multiplyMatrices(this.target.matrixWorld,this.offsetMatrix),Fg.decompose(e.position,e.quaternion,e.scale),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Ug))}}zg.prototype.isChildOfConstraint=!0;const Vg=new ci,Gg=new li,kg=new ci;class Qg extends Og{constructor(e){super(e),this.type="CopyLocationConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.invertX=!1,this.invertY=!1,this.invertZ=!1,this.useOffset=!1,this.influence=1,this._firstIteration=!0,this._objPosInit=new ci,this._offset=new ci}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.invertX=e.invertX,this.invertY=e.invertY,this.invertZ=e.invertZ,this.useOffset=e.useOffset,this.influence=e.influence,this._firstIteration=!1,this}update(e){super.update(e),this.mute||(this.target.matrixWorld.decompose(Vg,Gg,kg),this._firstIteration&&(this._updateObjMatrixWorld(e),e.getWorldPositionNU(this._objPosInit),this._offset.subVectors(Vg,this._objPosInit),this._firstIteration=!1),this.useX?(this.invertX&&(Vg.x=-Vg.x),this.useOffset&&(Vg.x-=this._offset.x)):Vg.x=this._objPosInit.x,this.useY?(this.invertY&&(Vg.y=-Vg.y),this.useOffset&&(Vg.y-=this._offset.y)):Vg.y=this._objPosInit.y,this.useZ?(this.invertZ&&(Vg.z=-Vg.z),this.useOffset&&(Vg.z-=this._offset.z)):Vg.z=this._objPosInit.z,e.position.lerpVectors(this._objPosInit,Vg,this.influence),e.parent&&e.parent.worldToLocal(e.position))}}Qg.prototype.isCopyLocationConstraint=!0;const Wg=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),Hg=new ci,jg=new li,Yg=new ci;class Xg extends Og{constructor(e){super(e),this.type="CopyRotationConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.invertX=!1,this.invertY=!1,this.invertZ=!1,this.mixMode="REPLACE",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objQuatInit=new li}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.invertX=e.invertX,this.invertY=e.invertY,this.invertZ=e.invertZ,this.mixMode=e.mixMode,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!1,this}update(e){super.update(e),this.mute||(this.target.matrixWorld.decompose(Hg,jg,Yg),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(Hg,this._objQuatInit,Yg),this._firstIteration=!1),e.quaternion.copy(this._objQuatInit),(this.useX||this.useY||this.useZ)&&("REPLACE"==this.mixMode||"ADD"==this.mixMode||("BEFORE"==this.mixMode?jg.multiply(e.quaternion):"AFTER"==this.mixMode?jg.premultiply(e.quaternion):this.mixMode),e.quaternion.slerp(jg,this.influence)),e.parent&&(e.parent.matrixWorld.decompose(Hg,jg,Yg),e.quaternion.premultiply(jg.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Wg))}}Xg.prototype.isCopyRotationConstraint=!0;const Kg=new ci,qg=new li,Zg=new ci;class Jg extends Og{constructor(e){super(e),this.type="CopyScaleConstraint",this.useX=!0,this.useY=!0,this.useZ=!0,this.power=1,this.useMakeUniform=!1,this.useOffset=!1,this.useAdd=!1,this.influence=1,this._objInitScale=new ci,this._volumeScaleFactor=new ci,this._firstIteration=!0}copy(e){return super.copy(e),this.useX=e.useX,this.useY=e.useY,this.useZ=e.useZ,this.power=e.power,this.useMakeUniform=e.useMakeUniform,this.useOffset=e.useOffset,this.useAdd=e.useAdd,this.influence=e.influence,this._firstIteration=!1,this}update(e){if(super.update(e),!this.mute){if(this.target.matrixWorld.decompose(Kg,qg,Zg),this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(Kg,qg,this._objInitScale),this._volumeScaleFactor.set(Math.pow(Zg.x-this._objInitScale.x,3),Math.pow(Zg.y-this._objInitScale.y,3),Math.pow(Zg.z-this._objInitScale.z,3)),this._firstIteration=!1),this.useMakeUniform){let e=1;this.useX&&(e*=Zg.x),this.useY&&(e*=Zg.y),this.useZ&&(e*=Zg.z),e=Math.pow(Math.cbrt(e),this.power),Zg.set(e,e,e),this.useOffset&&(this.useAdd?(Zg.add(this._objInitScale),Zg.addScalar(-1)):Zg.multiply(this._objInitScale))}else Zg.set(this.useX?Math.pow(Zg.x,this.power):this._objInitScale.x,this.useY?Math.pow(Zg.y,this.power):this._objInitScale.y,this.useZ?Math.pow(Zg.z,this.power):this._objInitScale.z),this.useOffset&&(this.useAdd?Zg.set(this.useX?Zg.x+this._objInitScale.x-1:Zg.x,this.useY?Zg.y+this._objInitScale.y-1:Zg.y,this.useZ?Zg.z+this._objInitScale.z-1:Zg.z):Zg.set(this.useX?Zg.x*this._objInitScale.x:Zg.x,this.useY?Zg.y*this._objInitScale.y:Zg.y,this.useZ?Zg.z*this._objInitScale.z:Zg.z));e.scale.copy(this._objInitScale),e.scale.lerp(Zg,this.influence)}}}Jg.prototype.isCopyScaleConstraint=!0;const $g=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),ev=new zi,tv=new ci,nv=new li,iv=new ci;class ov extends Og{constructor(e){super(e),this.type="CopyTransformsConstraint",this.mixMode="REPLACE",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objMatrixWorldInit=new zi}copy(e){return super.copy(e),this.mixMode=e.mixMode,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!0,this}update(e){super.update(e),this.mute||(this._firstIteration&&(this._updateObjMatrixWorld(e),this._objMatrixWorldInit.copy(e.matrixWorld),this._firstIteration=!1),ev.copy(this.target.matrixWorld),"REPLACE"==this.mixMode||("BEFORE"==this.mixMode?ev.multiply(this._objMatrixWorldInit):"AFTER"==this.mixMode&&ev.premultiply(this._objMatrixWorldInit)),ev.decompose(tv,nv,iv),this._objMatrixWorldInit.decompose(e.position,e.quaternion,e.scale),e.position.lerp(tv,this.influence),e.quaternion.slerp(nv,this.influence),e.scale.lerp(iv,this.influence),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply($g))}}ov.prototype.isCopyTransformsConstraint=!0;const rv=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),av=new ci,sv=new li,lv=new ci,cv=new ci,uv=new ci,dv=new ci,hv=new ci,pv={X:0,Y:1,Z:2,"-X":3,"-Y":4,"-Z":5},fv={0:new ci(1,0,0),1:new ci(0,1,0),2:new ci(0,0,1),3:new ci(-1,0,0),4:new ci(0,-1,0),5:new ci(0,0,-1)};class mv extends Og{constructor(e){super(e),this.type="DampedTrackConstraint",this.trackAxis="X",this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0}copy(e){return super.copy(e),this.trackAxis=e.trackAxis,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!1,this}update(e){if(super.update(e),!this.mute&&(this.target.matrixWorld.decompose(av,sv,lv),this._firstIteration&&(this._updateObjMatrixWorld(e),this._firstIteration=!1),e.matrixWorld.decompose(cv,sv,lv),uv.subVectors(av,cv),0!=uv.length())){let t;if(uv.normalize(),dv.copy(fv[pv[this.trackAxis]]),dv.applyQuaternion(sv),0==dv.length()&&dv.copy(fv[pv[this.trackAxis]]),dv.normalize(),hv.crossVectors(dv,uv),t=dv.angleTo(uv),hv.length()<Number.EPSILON){if(Math.abs(t)<Math.PI-.01)return;if(t=Math.PI,uv.copy(fv[(pv[this.trackAxis]+2)%6]),uv.applyQuaternion(sv),hv.crossVectors(dv,uv),0==hv.length())return}hv.normalize(),e.quaternion.premultiply(sv.setFromAxisAngle(hv,t)),e.parent&&(e.parent.matrixWorld.decompose(av,sv,lv),e.quaternion.premultiply(sv.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(rv)}}}mv.prototype.isDampedTrackConstraint=!0;const gv={X:new ci(1,0,0),Y:new ci(0,1,0),Z:new ci(0,0,1),"-X":new ci(-1,0,0),"-Y":new ci(0,-1,0),"-Z":new ci(0,0,-1)},vv=new ci,Av=new ci,_v=new ci,xv=new ci;class yv extends Og{constructor(e){super(e),this.type="FloorConstraint",this.floorLocation="Y",this.offset=0,this.useRotation=!1}copy(e){return super.copy(e),this.floorLocation=e.floorLocation,this.offset=e.offset,this.useRotation=e.useRotation,this}update(e){if(super.update(e),this.mute)return;const t=e.position;xv.copy(this.target.position);const n=this.target.scale,i=this.offset;if(this.useRotation){let e;switch(vv.copy(gv[this.floorLocation]),vv.applyQuaternion(this.target.quaternion),this.floorLocation){case"X":xv.x+=i*n.x,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.x>t.x?t.copy(Av):t.x=Math.max(t.x,xv.x);break;case"Y":xv.y+=i*n.y,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.y>t.y?t.copy(Av):t.y=Math.max(t.y,xv.y);break;case"Z":xv.z+=i*n.z,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.z>t.z?t.copy(Av):t.z=Math.max(t.z,xv.z);break;case"-X":xv.x+=i*n.x,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.x<t.x?t.copy(Av):t.x=Math.min(t.x,xv.x);break;case"-Y":xv.y+=i*n.y,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.y<t.y?t.copy(Av):t.y=Math.min(t.y,xv.y);break;case"-Z":xv.z+=i*n.z,_v.subVectors(t,xv),e=vv.dot(_v),vv.multiplyScalar(e),Av.subVectors(_v,vv).add(xv),Av.z<t.z?t.copy(Av):t.z=Math.min(t.z,xv.z)}}else switch(this.floorLocation){case"X":t.x=Math.max(t.x,xv.x+i);break;case"Y":t.y=Math.max(t.y,xv.y+i);break;case"Z":t.z=Math.max(t.z,xv.z+i);break;case"-X":t.x=Math.min(t.x,xv.x+i);break;case"-Y":t.y=Math.min(t.y,xv.y+i);break;case"-Z":t.z=Math.min(t.z,xv.z+i)}}}yv.prototype.isFloorConstraint=!0;const bv=new ci,Cv=new li,Mv=new ci,Sv=new ci;class Ev extends Og{constructor(e){super(e),this.type="LimitDistanceConstraint",this.distance=0,this.limitMode="LIMITDIST_ONSURFACE",this.useTransformLimit=!1,this.influence=1,this._objPosInit=new ci,this._distInit=0,this._sfac=1,this._clampSurf=0}copy(e){return super.copy(e),this.distance=e.distance,this.limitMode=e.limitMode,this.useTransformLimit=e.useTransformLimit,this.influence=e.influence,this}update(e){super.update(e),this.mute||(this._sfac=1,this._clampSurf=0,this.target.matrixWorld.decompose(bv,Cv,Mv),this._updateObjMatrixWorld(e),e.getWorldPositionNU(this._objPosInit),Sv.subVectors(this._objPosInit,bv),this._distInit=Sv.length(),"LIMITDIST_INSIDE"==this.limitMode?this._distInit>=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,bv,(1-this._sfac)*this.influence),e.parent&&e.parent.worldToLocal(e.position)))}}Ev.prototype.isLimitDistanceConstraint=!0;class wv extends Ng{constructor(){super(),this.type="LimitLocationConstraint",this.min=(new ci).setScalar(-1/0),this.max=(new ci).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)}}wv.prototype.isLimitLocationConstraint=!0;const Tv=new Ki;class Iv extends Ng{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?(Tv.setFromQuaternion(e.quaternion,"XYZ"),Tv.x=this._clampAngle(Tv.x,this.min,this.max)):"Y"==this.axis?(Tv.setFromQuaternion(e.quaternion,"YZX"),Tv.y=this._clampAngle(Tv.y,this.min,this.max)):"Z"==this.axis&&(Tv.setFromQuaternion(e.quaternion,"ZXY"),Tv.z=this._clampAngle(Tv.z,this.min,this.max)),e.quaternion.setFromEuler(Tv))}_clampAngle(e,t,n){return Math.abs(n-t)<2*Math.PI&&(e=_n(e,t,n)),e}}Iv.prototype.isLimitRotationConstraint=!0;class Rv extends Ng{constructor(){super(),this.type="LimitScaleConstraint",this.min=(new ci).setScalar(-1/0),this.max=(new ci).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)}}Rv.prototype.isLimitScaleConstraint=!0;const Lv=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),Pv=new ci,Bv=new ci,Dv=new ci,Nv=new ci,Ov=new ci,Fv=new xr,Uv=new ci,zv=new ci,Vv=new li;class Gv extends Og{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(Dv.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),Nv.set("X"==this.lockAxis?1:0,"Y"==this.lockAxis?1:0,"Z"==this.lockAxis?1:0),1==Math.abs(Dv.dot(Nv)))return;Pv.setFromMatrixPosition(e.matrixWorld),Bv.setFromMatrixPosition(this.target.matrixWorld),Fv.setFromNormalAndCoplanarPoint(Nv,Pv),Fv.projectPoint(Bv,Ov).sub(Pv);const t=Uv.crossVectors(Dv,Ov).dot(Nv)>0?1:-1;e.setRotationFromAxisAngle(Fv.normal,t*Dv.angleTo(Ov)),e.parent&&(e.parent.matrixWorld.decompose(zv,Vv,zv),e.quaternion.premultiply(Vv.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Lv)}}Gv.prototype.isLockedTrackConstraint=!0;const kv=new ci(0,1,0),Qv=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),Wv=new xr,Hv=new ci,jv=new ci,Yv=new ci,Xv=new ci,Kv=new ci,qv=new zi,Zv=new ci,Jv=new li;class $v extends Og{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;Hv.setFromMatrixPosition(e.matrixWorld),jv.setFromMatrixPosition(this.target.matrixWorld),Yv.subVectors(jv,Hv),Yv.lengthSq()?Yv.normalize():Yv.set(0,-1,0),Wv.set(Yv,0),1!=Math.abs(Yv.dot(kv))?Wv.projectPoint(kv,Xv).normalize():Xv.set(0,0,-1),i&&Yv.negate(),o&&Xv.negate();let r="X"==t?Yv:"X"==n?Xv:null,a="Y"==t?Yv:"Y"==n?Xv:null,s="Z"==t?Yv:"Z"==n?Xv:null;r?a?s||(s=Kv.crossVectors(r,a)):a=Kv.crossVectors(s,r):r=Kv.crossVectors(a,s),qv.makeBasis(r,a,s),e.setRotationFromMatrix(qv),e.parent&&(e.parent.matrixWorld.decompose(Zv,Jv,Zv),e.quaternion.premultiply(Jv.invert())),this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(Qv)}}$v.prototype.isTrackToConstraint=!0;class eA extends Og{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}}eA.prototype.isFixOrthoZoomConstraint=!0;var tA=new ci,nA=new ci,iA=new li,oA=new hi,rA=new Ri;class aA extends Og{constructor(e){super(e),this.type="CanvasFitConstraint",this.edgeH=0,this.edgeV=0,this.offset=0,this.fitShape="BOX"}copy(e){return super.copy(e),this.edgeH=e.edgeH,this.edgeV=e.edgeV,this.offset=e.offset,this.fitShape=e.fitShape,this}update(e){if(super.update(e),this.mute)return;const t=this.target;if(e.parent!==t)return void console.error(`CanvasFitConstraint: object ${e.name} 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=sn(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));e.geometry;let s=0,l=0,c=0,u=0;if(e.matrix.compose(e.position,e.quaternion,e.scale),"BOX"==this.fitShape){if(oA.makeEmpty(),e.resolveMultiMaterial().forEach((function(e){e.geometry&&(null==e.geometry.boundingBox&&e.geometry.computeBoundingBox(),oA.union(e.geometry.boundingBox))})),!oA.isEmpty()){oA.applyMatrix4(e.matrix);const t=oA.getCenter(tA).sub(e.position),n=oA.getSize(nA).addScalar(2*this.offset);s=-(.5*n.x*r+t.x),l=-(.5*n.y*a+t.y),c=n.x,u=n.y}}else if("SPHERE"==this.fitShape&&(rA.makeEmpty(),e.resolveMultiMaterial().forEach((function(e){e.geometry&&(null===e.geometry.boundingSphere&&e.geometry.computeBoundingSphere(),rA.isEmpty()?rA.copy(e.geometry.boundingSphere):rA.union(e.geometry.boundingSphere))})),!rA.isEmpty())){rA.applyMatrix4(e.matrix),rA.radius+=this.offset;const o=tA.copy(rA.center).sub(e.position);s=-(rA.radius*r+o.x),l=-(rA.radius*a+o.y),t.isPerspectiveCamera&&(s/=Math.cos(n),l/=Math.cos(i)),c=2*rA.radius,u=2*rA.radius}"STRETCH"==this.edgeH?(e.position.x=s,0!==c&&(e.scale.applyQuaternion(iA.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.x*=2*o*Math.tan(n)/c:e.scale.x*=(t.right-t.left)/t.zoom/c,e.scale.applyQuaternion(iA.copy(e.quaternion).invert()))):"NONE"!==this.edgeH&&(t.isPerspectiveCamera?e.position.x=o*Math.tan(n)+s:e.position.x=(r<0?t.left:t.right)/t.zoom+s),"STRETCH"==this.edgeV?(e.position.y=l,0!==u&&(e.scale.applyQuaternion(iA.copy(e.quaternion)),t.isPerspectiveCamera?e.scale.y*=2*o*Math.tan(i)/u:e.scale.y*=(t.top-t.bottom)/t.zoom/u,e.scale.applyQuaternion(iA.copy(e.quaternion).invert()))):"NONE"!==this.edgeV&&(t.isPerspectiveCamera?e.position.y=o*Math.tan(i)+l:e.position.y=(a<0?t.bottom:t.top)/t.zoom+l)}}aA.prototype.isCanvasFitConstraint=!0;class sA extends Ng{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<t.constraints.length;e++){let s=t.constraints[e];if(s.isCanvasBreakpointsConstraint){switch(s.orientation){case"ALL":o=!0;break;case"LANDSCAPE":o=n/i>=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}}sA.prototype.isCanvasBreakpointsConstraint=!0;const lA=function(e){return!!e&&(!!e.dtype&&new RegExp("function View[0-9]+d(:?"+e.dtype+")+").test(String(e.constructor)))},cA=function(e){return!!e&&(void 0!==e.data&&Array.isArray(e.shape)&&void 0!==e.offset&&void 0!==e.stride)};function uA(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function dA(e){if(e){if(lA(e)||cA(e))return"generic"===e.dtype?dA.GENERIC_NDARRAY:dA.NDARRAY;if(uA(e))return dA.ARRAY_OF_ARRAYS;throw new Error("Unhandled data type. Got type: "+typeof e)}}dA.ARRAY_OF_ARRAYS="Arr",dA.NDARRAY="Nd",dA.GENERIC_NDARRAY="GenNd",dA.PACKED="PackArr";const hA=function(e,t,n,i,o,r){var a,s,l=[],c=!1;for(a=0;a<e.splineDimension;a++){var u=uA(e.knots)&&uA(e.knots[a]);u&&(c=!0),l.push("Deg"+e.degree[a]+(u?"":"Uniform")+((s=e.boundary[a])[0].toUpperCase()+s.slice(1)))}var d=[[c?"NU":"",e.weights?"RBS":"BS"].join("")+e.dimension+"D",l.join("_")];return i&&d.push(i+"Pts"),o&&d.push(o+"Wts"),r&&d.push(r+"Kts"),t&&d.push("debug"),n&&d.push("chk"),d.join("_")},pA=function(e,t){return function(t,n){void 0===t||Array.isArray(t)||(t=[t]);for(var i=[],o=0;o<t.length;o++)i.push(pA.sum(t[o]));if(n)for(t=0;t<i.length;t++)void 0!==n[t]&&(i[t]="("+i[t]+" + "+n[t]+") % "+n[t]);return e+i.join("_")}};function fA(e){return function(t,n){void 0===t||Array.isArray(t)||(t=[t]);for(var i=[],o=0;o<t.length;o++)i.push(pA.sum(t[o]));if(n)for(t=0;t<i.length;t++)void 0!==n[t]&&(i[t]="("+i[t]+" + "+n[t]+") % "+n[t]);return e(i)}}function mA(e,t){var n;if(t)switch(dA(t)){case dA.ARRAY_OF_ARRAYS:return fA((function(t){return e+"["+t.join("][")+"]"}));case dA.GENERIC_NDARRAY:return fA((function(t){return e+".get("+t.join(",")+")"}));case dA.NDARRAY:return fA((function(t){var i=[e+"Offset"];for(n=0;n<t.length;n++)i.push(e+"Stride"+n+" * ("+t[n]+")");return e+"["+i.join(" + ")+"]"}));case dA.PACKED:default:return}}pA.sum=function(e){return 0===(e=(e=Array.isArray(e)?e:[e]).filter((function(e){return void 0!==e&&0!==e}))).length&&e.push(0),e.join(" + ")};const gA=function(e){var t,n={};return(t=mA("x",e.points))&&(n.point=t),(t=mA("w",e.weights))&&(n.weight=t),(t=mA("k",e.knots))&&(n.knot=t),n};var vA=[],AA=[];const _A=function(e,t,n){if(1!==t)throw new Error("Numerical derivative not implemented for order n = "+t+".");var i,o=void 0===arguments[this.splineDimension+3]?1e-4:arguments[this.splineDimension+3];for(vA.length=this.splineDimension,i=0;i<this.splineDimension;i++)vA[i+1]=arguments[i+3];var r,a,s,l=this.domain,c=l[n][0],u=l[n][1],d=vA[n+1],h=(u-c)*o;for("closed"===this.boundary[n]?(r=c+(d-c-h+(s=u-c))%s,a=c+(d-c+h+s)%s,h*=2):(r=Math.min(u,Math.max(c,d-h)),h=(a=Math.min(u,Math.max(c,d+h)))-r),vA[n+1]=r,vA[0]=AA,this.evaluate.apply(null,vA),vA[n+1]=a,vA[0]=e,this.evaluate.apply(null,vA),i=0;i<this.dimension;i++)e[i]=(e[i]-AA[i])/h;return e},xA=function(e,t){for(var n=1,i=0,o=[];i<e.length;i++)n*=Array.isArray(e[i])?e[i][1]-e[i][0]:e[i],o[i]=Array.isArray(e[i])?e[i][0]:0;for(var r=0;r<n;r++)for(t(o.slice()),i=e.length-1;i>=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}},yA=function(e,t,n,i){var o,r=[];switch(dA(i)){case dA.NDARRAY:for(r.push("  const "+t+" = "+n+".data;"),r.push("  const "+t+"Offset = "+n+".offset;"),o=0;o<i.dimension;o++)r.push("  const "+t+"Stride"+o+" = "+n+".stride["+o+"];");break;case dA.ARRAY_OF_ARRAYS:r.push("  const "+t+" = "+n+";")}return r.join("\n")},bA=function(e,t,n){if(e){if(cA(e))return t+".shape["+n+"]";for(var i=t,o=0;o<n;o++)i+="[0]";return i+".length"}return"this.size["+n+"]"};var CA={},MA={};const SA=function(e,t,n,i,o,r,a){var s,l,c,u,d,h,p=t.splineDimension,f=t.points,m=t.degree,g=t.weights,v=void 0!==g,A=t.knots,_=t.dimension,x=t.boundary;if(null!=a){Array.isArray(a)||(a=[a]);var y=0;for(s=0;s<p;s++)void 0===a[s]&&(a[s]=0),y+=a[s];if(v&&y>1)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=CA[e];if(i)var C="function"==typeof i?i:console.log;if(b)return i&&C(MA[e]),b.bind(t);var M=[],S="evaluate"+e,E=n.point;r&&(E=function(e,t){for(var n=[],i=0;i<e.length;i++){for(var o=e[i],r=[],a=0;a<o.length;a++)0!==o[a]&&r.push(o[a]);o=r.join(" + "),t[i]&&(o="("+o+" + "+t[i]+") % "+t[i]),n.push(o+" === "+P(i))}return"(("+n.join(" && ")+") ? 1 : 0)"});var w=n.weight,T=n.knot,I=pA("k"),R=pA("x"),L=pA("w"),P=pA("i"),B=pA("t"),D=i?"domain":"d",N=pA(i?"size":"s"),O=pA(i?"knotIndex":"j"),F=!0;for(d=0;d<p;d++)uA(A)&&uA(A[d])&&(F=!1);function U(e){M.push("  "+(e||""))}function z(e){i&&U(e)}if(r)var V=[];var G=[];for(s=0;s<p;s++)r&&V.push(P([s])),G.push(B([s]));for(M.push("function "+S+" ("+(r?"":"out, ")+G.join(", ")+(r?", "+V.join(", "):"")+") {"),U("let h, m, a, b;"),o&&(U("const "+D+" = this.domain;"),U("for (let i = 0; i < this.splineDimension; i++) {"),U("  a = arguments[i + 1];"),U("  if (a < "+D+"[i][0] || a > "+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<p;d++)U("let "+N(d)+" = "+bA(f,"this.points",d)+";");function k(e,t,n){return"("+e+") ? ("+t+") : ("+n+")"}M.push(yA(0,"x","this.points",f)),v&&M.push(yA(0,"w","this.weights",g)),F||M.push(yA(0,"k","this.knots",A));var Q=[];for(d=0;d<p;d++)switch(dA(A)){case dA.NDARRAY:Q[d]=!0;break;case dA.ARRAY_OF_ARRAYS:Q[d]=uA(A[d])}for(d=0;d<p;d++)if(Q[d])for(z("\n  // Bisect to locate the knot interval in dimension "+d+"\n"),U("let "+O(d)+" = 0;"),U("h = "+N(d)+";"),U("while(h > "+O(d)+" + 1) {"),U("  m = 0.5 * (h + "+O(d)+") | 0;"),U("  if ("+T([d,"m"])+" > "+B(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)+" = ("+B(d)+" | 0) % "+N(d)+";"):(U(O(d)+" = ("+B(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(B(d)+" %= "+N(d)+";"))}for(d=0,c=[];d<p;d++)c[d]=m[d]+1;for(v&&(z("\n  // Fetch weights\n"),xA(c,(function(e){for(var t=[],n=[],i=0;i<p;i++)t[i]=[O(i),e[i]-m[i]],"closed"===x[i]&&e[i]-m[i]<0&&(n[i]=N(i));U("let "+L(e)+" = "+w(t,n)+";")}))),i&&U(v?"\n  // Fetch points and project into homogeneous (weighted) coordinates\n":"\n  // Fetch points\n"),xA(c,(function(e){for(var t=[],n=[],i=0;i<p;i++)t[i]=[O(i),e[i]-m[i]],"closed"===x[i]&&e[i]-m[i]<0&&(n[i]=N(i));if(r)U(v?"let "+R(e)+" = "+E(t,n)+" * "+L(e)+";":"let "+R(e)+" = "+E(t,n)+";");else for(i=0;i<_;i++){var o=e.concat(i);t[p]=i,U(v?"let "+R(o)+" = "+E(t,n)+" * "+L(e)+";":"let "+R(o)+" = "+E(t,n)+";")}})),z("\n"),z("// Perform De Boor's algorithm"),d=c.length-1;d>=0;d--)for(c[d]=[m[d],m[d]+1],s=0;s<m[d];s++)for(z("\n  // Degree "+m[d]+" evaluation in dimension "+d+", step "+(s+1)+"\n"),l=m[d];l>s;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 = ("+B(d)+" - "+I([d,l-1])+") * m;"),U("b = 1 - a;"))):(U("a = ("+B(d)+" - "+I([d,l-1])+") / ("+I([d,l-s+m[d]-1])+" - "+I([d,l-1])+");"),U("b = 1 - a;")),v&&xA(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)+";")})),xA(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;"),M.push("}"),i){var H=M.join("\n");C(H),MA[e]=H}const j=new Function([M.join("\n"),"; return ",S].join(""))();return CA[e]=j,j.bind(t)};var EA={};const wA=function(e,t,n,i){var o,r,a,s,l,c,u,d,h=EA[e];if(h)return h.bind(t);var p=[],f="transform"+e;p.push("function "+f+"(m) {"),p.push("let i, w;"),p.push(yA(0,"x","this.points",t.points));var m=pA(i?"size":"s");for(o=0;o<t.splineDimension;o++)p.push("let "+m(o)+" = "+bA(t.points,"this.points",o)+";");for(s=[],o=0;o<t.splineDimension;o++)a="i"+o,s.push(a),p.push("for ("+a+" = "+m(o)+"- 1; "+a+" >= 0; "+a+"--) {");for(o=0;o<t.dimension;o++)p.push("x"+o+" = "+n.point(s.concat([o])));for(l=[],o=0;o<t.dimension;o++)l.push("m["+((t.dimension+1)*(o+1)-1)+"] * x"+o);for(l.push("m["+((t.dimension+1)*(t.dimension+1)-1)+"]"),p.push("const w = ("+l.join(" + ")+") || 1.0;"),o=0;o<t.dimension;o++){for(l=[],c=t.dimension,r=0;r<c;r++)l.push("m["+(r*(c+1)+o)+"] * x"+r);l.push("m["+(r*(c+1)+o)+"]"),d=n.point(s.concat([o])),u="("+l.join(" + ")+") / w",p.push(d+" = "+u+";")}for(o=t.splineDimension-1;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")),EA[e]=g,g.bind(t)};var TA={};const IA=function(e,t,n,i,o){var r=TA[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=pA("t"),v=i?"domain":"d",A=pA(i?"size":"s"),_=pA(i?"knotIndex":"i"),x=!0;for(l=0;l<d;l++)uA(u)&&uA(u[l])&&(x=!1);function y(e){p.push("  "+(e||""))}var b=[];for(a=0;a<d;a++)b.push(g([a]));p.push("function "+f+" (out, "+b.join(", ")+") {");var C=0;function M(e,t){y(void 0===t?"out["+C+++"] = "+e.join(" + ")+";":"out["+C+++"] = ("+e.join(" + ")+" + "+t+") % "+t+";")}for(y("let h, m;"),y("let c = 0;"),o&&(y("const "+v+" = this.domain;"),y("for (let i = 0; i < this.splineDimension; i++) {"),y("  a = arguments[i + 1];"),y("  if (a < "+v+"[i][0] || a > "+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<d;l++)y("let "+A(l)+" = "+bA(t.points,"this.points",l)+";");x||p.push(yA(0,"k","this.knots",u));var S=[];for(l=0;l<d;l++)switch(dA(u)){case dA.NDARRAY:S[l]=!0;break;case dA.ARRAY_OF_ARRAYS:S[l]=uA(u[l])}for(l=0;l<d;l++)S[l]?(y("let "+_(l)+" = 0;"),y("h = "+A(l)+";"),y("while(h > "+_(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=[];l<d;l++)s[l]=c[l]+1;xA(s,(function(e){for(var t=[],n=[],i=0;i<d;i++)t[i]=[_(i),e[i]-c[i]],"closed"===h[i]&&e[i]-c[i]<0&&(n[i]=A(i));for(i=0;i<d;i++)M(t[i],n[i])})),y("out.length = "+C+";"),y("return out;"),p.push("}"),i&&console.log(p.join("\n"));const E=new Function([p.join("\n"),"; return ",f].join(""))();return TA[e]=E,E.bind(t)};var RA={open:"open",closed:"closed",clamped:"clamped"};function LA(e){return null==e}function PA(e,t,n,i,o,r){var a,s;!e||uA(e)||lA(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=dA(this.points),c=dA(this.weights),u=dA(this.knots);if(this.points)switch(l){case dA.GENERIC_NDARRAY:case dA.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 dA.ARRAY_OF_ARRAYS:var d=0,h=this.size||[];h.length=0;for(var p=this.points;uA(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;t<this.splineDimension;t++,n=n[0])e[t]=n.length;return e},set:function(){throw new Error("Cannot assign to read only property 'size'")},configurable:!0}});break;case dA.PACKED:default:throw new Error("Expected either a packed array, array of arrays, or ndarray of points")}else{if(void 0===this.size||null===this.size)throw new Error("Either points or a control hull size must be provided.");if(uA(this.size)||Object.defineProperty(this,"size",{value:[this.size],writable:!0,configurable:!0}),0===this.size.length)throw new Error("`size` must be a number or an array of length at least one.");Object.defineProperties(this,{splineDimension:{value:this.size.length,writable:!1,configurable:!0},dimension:{value:0,writable:!1,configurable:!0}})}if(uA(this.degree)){for(a=0;a<this.splineDimension;a++)if(LA(this.degree[a]))throw new Error("Missing degree in dimension "+(a+1))}else{var f=!LA(this.degree),m=LA(this.degree)?2:this.degree;for(this.degree=[],a=0;a<this.splineDimension;a++)if(this.size[a]<=m){if(f)throw new Error("Expected at least "+(m+1)+" points for degree "+m+" spline in dimension "+(a+1)+" but got only "+this.size[a]);this.degree[a]=this.size[a]-1}else this.degree[a]=m}if(s="string"!=typeof this.boundary?"open":this.boundary,!RA[s])throw new Error("Boundary type must be one of "+Object.keys(RA)+". Got "+s);for(this.boundary=uA(this.boundary)?this.boundary:[],this.boundary.length=this.splineDimension,a=0;a<this.splineDimension;a++)if(this.boundary[a]=LA(this.boundary[a])?s:this.boundary[a],!RA[s])throw new Error("Boundary type must be one of "+Object.keys(RA)+". Got "+s+" for dimension "+(a+1));if(u===dA.ARRAY_OF_ARRAYS)for(uA(this.knots)&&this.knots.length>0&&!uA(this.knots[0])&&(this.knots=[this.knots]),a=0;a<this.splineDimension;a++){if(this.size[a]<=this.degree[a])throw new Error("Expected at least "+(this.degree[a]+1)+" points in dimension "+(a+1)+" but got "+this.size[a]+".");if(uA(this.knots[a])){if("closed"!==this.boundary[a]&&this.knots[a].length!==this.degree[a]+this.size[a]+1)throw new Error("Expected "+(this.degree[a]+this.size[a]+1)+" knots in dimension "+(a+1)+" but got "+this.knots[a].length+".");if("closed"===this.boundary[a]&&this.knots[a].length!==this.size[a]+1&&!(this.knots[a].length===this.size[a]+this.degree[a]+1))throw new Error("Expected "+(this.size[a]+1)+" knots for closed spline in dimension "+(a+1)+" but got "+this.knots[a].length+".")}}var g=hA(this,this.debug,this.checkBounds,l,c,u);if(g!==this.__cacheKey){this.__cacheKey=g;var v=gA(this);this.evaluate=SA(this.__cacheKey,this,v,this.debug,this.checkBounds,!1),this.transform=wA(this.__cacheKey,this,v,this.debug),this.support=IA(this.__cacheKey,this,v,this.debug,this.checkBounds),this.evaluator=function(e,t){return SA(this.__cacheKey,this,v,this.debug,this.checkBounds,t,e)}}return this.numericalDerivative=_A.bind(this),this}function BA(){var e,t=[],n=this.points;n?cA(n)&&(e=n.shape):e=this.size;for(var i=0;i<this.splineDimension;i++){var o=e?e[i]:n.length,r=this.degree[i],a="closed"===this.boundary[i];if(this.knots&&this.knots[i]){var s=this.knots[i];t[i]=[s[a?0:r],s[o]]}else t[i]=[a?0:r,o];n&&(n=n[0])}return t}function DA(e,t,n,i,o,r){const a=function(e,t,n,i,o,r){return s(e,t,n,i,o,r),a},s=PA.bind(a);return Object.defineProperty(a,"domain",{get:BA}),s(e,t,n,i,o,r),a}const NA=(new li).setFromAxisAngle(new ci(1,0,0),-Math.PI/2),OA={X:new ci(1,0,0),Y:new ci(0,1,0),Z:new ci(0,0,1),"-X":new ci(-1,0,0),"-Y":new ci(0,-1,0),"-Z":new ci(0,0,-1)},FA=new ci(0,1,0),UA=new ci(0,0,1),zA=0,VA=1,GA=0,kA=1,QA=new ci,WA=new li,HA=new ci,jA=new ci,YA=new ci,XA=new ci,KA=new ci,qA=new ci,ZA=new ci,JA=new zi,$A=new li,e_=[0,0,0];class t_ extends Ng{constructor(){super(),this.type="MotionPathConstraint",this.curve=null,this.firstDerivativeEvaluator=null,this.secondDerivativeEvaluatorForNonUniformBSplines=null,this.derivativeEvaluatorForWeights0=null,this.derivativeEvaluatorForWeights1=null,this.derivativeEvaluatorForWeights2=null,this.degree=3,this.cvs=[],this.knots=[],this.weights=[],this.value=0,this.follow=!0,this.frontAxis="Z",this.upAxis="Y",this.worldUpVector=new ci(0,1,0),this.useChordLength=!1,this.chordsNum=0,this.chordLengths=[],this.bank=!1,this.bankScale=1,this.bankLimit=1/0,this.useFixedLocation=!1,this.fixedValue=0,this.usePointsTilt=!1,this.pointsTilt=[],this.pointsTiltEvaluator=null,this.offsetValue=0,this.useClampValue=!1,this.useCyclic=!1,this.useObjOffset=!1,this.useRelative=!1,this.usePosOffset=!0,this.objOffsetMode=zA,this.objOffsetRotMode=GA,this.influence=1,this.fixCameraLightRotation=!1,this._firstIteration=!0,this._objMatrixWorldInit=new zi,this._objPosWorldInit=new ci,this._objRotWorldInit=new li}copy(e){super.copy(e),this.degree=e.degree,this.cvs=[];for(let t=0;t<e.cvs.length;++t)this.cvs.push(e.cvs[t]);this.knots=[];for(let t=0;t<e.knots.length;++t)this.knots.push(e.knots[t]);this.weights=[];for(let t=0;t<e.weights.length;++t)this.weights.push(e.weights[t]);this.value=e.value,this.follow=e.follow,this.frontAxis=e.frontAxis,this.upAxis=e.upAxis,this.worldUpVector.copy(e.worldUpVector),this.useChordLength=e.useChordLength,this.chordsNum=e.chordsNum,this.bank=e.bank,this.bankScale=e.bankScale,this.bankLimit=e.bankLimit,this.useFixedLocation=e.useFixedLocation,this.fixedValue=e.fixedValue,this.usePointsTilt=e.usePointsTilt,this.pointsTilt=[];for(let t=0;t<e.pointsTilt.length;++t)this.pointsTilt.push(e.pointsTilt[t]);return this.offsetValue=e.offsetValue,this.useClampValue=e.useClampValue,this.useCyclic=e.useCyclic,this.useObjOffset=e.useObjOffset,this.useRelative=e.useRelative,this.usePosOffset=e.usePosOffset,this.objOffsetMode=e.objOffsetMode,this.objOffsetRotMode=e.objOffsetRotMode,this.influence=e.influence,this.fixCameraLightRotation=e.fixCameraLightRotation,this._firstIteration=!0,this}init(){const e=[],t=this.cvs;for(let n=0;n<t.length;n+=3)e.push([t[n],t[n+1],t[n+2]]);this.curve=DA({points:e,knots:this.knots,weights:this.weights,degree:this.degree}),this.firstDerivativeEvaluator=this.curve.evaluator(1);let n=DA({points:e,knots:this.knots,degree:this.degree});this.secondDerivativeEvaluatorForNonUniformBSplines=n.evaluator(2);const i=[];for(let e=0;e<this.weights.length;++e)i.push([this.weights[e]]);let o=DA({points:i,knots:this.knots,degree:this.degree});if(this.derivativeEvaluatorForWeights0=o.evaluator(0),this.derivativeEvaluatorForWeights1=o.evaluator(1),this.derivativeEvaluatorForWeights2=o.evaluator(2),this.usePointsTilt){const e=[];for(let t=0;t<this.pointsTilt.length;++t)e.push([this.pointsTilt[t]]);const t=DA({points:e,knots:this.knots,weights:this.weights,degree:this.degree});this.pointsTiltEvaluator=t.evaluator(0)}else this.pointsTiltEvaluator=null;if(this.useChordLength)if(this.chordLengths=[],this.chordsNum<=0){let e=1==this.degree?1:32;this._calcChordLengths(this.chordLengths,this.cvs.length/3*e)}else this._calcChordLengths(this.chordLengths,this.chordsNum)}update(e){if(super.update(e),this.mute)return;this._firstIteration&&(this._updateObjMatrixWorld(e),e.matrixWorld.decompose(this._objPosWorldInit,this._objRotWorldInit,HA),this._objMatrixWorldInit.copy(e.matrixWorld),this.useRelative&&(this._calcPosition(QA,0),this._objPosWorldInit.sub(QA),this._objMatrixWorldInit.setPosition(this._objPosWorldInit)),this.usePosOffset||(this._objPosWorldInit.set(0,0,0),this._objMatrixWorldInit.setPosition(this._objPosWorldInit)),this._firstIteration=!1);let t=this.useFixedLocation?this.fixedValue:this.value+this.offsetValue;this.useCyclic?t-=Math.floor(t):t=this.useClampValue?nn(t,0,1):Math.max(0,t),this.useChordLength&&(t=this._convertParamToChordLength(t,this.chordLengths));const n=this.curve.domain,i=t*(n[0][1]-n[0][0])+n[0][0];if(this._calcPosition(e.position,i),!this.follow&&this.useObjOffset&&(jA.addVectors(e.position,this._objPosWorldInit),e.position.lerpVectors(this._objPosWorldInit,jA,this.influence)),this.follow&&1!=Math.abs(OA[this.frontAxis].dot(OA[this.upAxis]))){const t=this._calcTangent(jA,i),n=YA.copy(t).normalize();if(this._calcCurveRotMat(JA,n,this.worldUpVector),this._calcFrontAndUpVecsRotQuat(WA,OA[this.frontAxis],OA[this.upAxis]),e.quaternion.setFromRotationMatrix(JA).multiply(WA),this.bank){const n=this._calcSecondDerivative(YA,i,e.position,t),o=this._calcCurvature(t,n),r=XA.copy(OA[this.upAxis]).applyQuaternion(e.quaternion);let a=this._calcBankAngle(o,t,n,r);a=this._limitAngle(a*this.bankScale,this.bankLimit),WA.setFromAxisAngle(OA[this.frontAxis],a),e.quaternion.multiply(WA)}else if(this.usePointsTilt){this.pointsTiltEvaluator(e_,i);let t=e_[0];WA.setFromAxisAngle(OA[this.frontAxis],t),e.quaternion.multiply(WA)}if(this.useObjOffset){if(this.objOffsetMode==VA){const t=jA.setScalar(1);JA.compose(e.position,e.quaternion,t),this.objOffsetRotMode==kA&&JA.multiply(this._objMatrixWorldInit),JA.decompose(QA,WA,HA)}else this.objOffsetMode==zA&&(QA.addVectors(e.position,this._objPosWorldInit),this.objOffsetRotMode==GA?WA.copy(e.quaternion):this.objOffsetRotMode==kA&&WA.multiplyQuaternions(e.quaternion,this._objRotWorldInit));e.position.lerpVectors(this._objPosWorldInit,QA,this.influence),e.quaternion.slerpQuaternions(this._objRotWorldInit,WA,this.influence)}this.fixCameraLightRotation&&(e.isCamera||e.isLight)&&e.quaternion.multiply(NA)}}_calcPosition(e,t){return this.curve.evaluate(e_,t),e.fromArray(e_)}_calcTangent(e,t){return this.firstDerivativeEvaluator(e_,t),e.fromArray(e_)}_calcCurveRotMat(e,t,n){const i=KA.copy(n),o=qA.crossVectors(i,t).normalize();return i.crossVectors(t,o),e.makeBasis(o,i,t),e}_calcFrontAndUpVecsRotQuat(e,t,n){e.setFromUnitVectors(t,UA);const i=KA.copy(FA),o=qA.copy(n).applyQuaternion(e),r=o.dot(i);if(1!=Math.abs(r)){const n=ZA.crossVectors(o,i).dot(UA)>0?1:-1;$A.setFromAxisAngle(t,o.angleTo(i)*n),e.multiply($A)}else r<0&&($A.setFromAxisAngle(t,Math.PI),e.multiply($A));return e}_calcBankAngle(e,t,n,i){const o=KA.copy(t).add(n).normalize();return e*(qA.crossVectors(o,t).normalize().dot(i)>0?1:-1)}_calcCurvature(e,t){return KA.crossVectors(e,t).length()/Math.pow(e.length(),3)}_calcSecondDerivative(e,t,n,i){this.secondDerivativeEvaluatorForNonUniformBSplines(e_,t);const o=KA.fromArray(e_);this.derivativeEvaluatorForWeights1(e_,t);const r=e_[0];this.derivativeEvaluatorForWeights2(e_,t);const a=e_[0];this.derivativeEvaluatorForWeights0(e_,t);const s=e_[0];return e.copy(o).sub(qA.copy(i).multiplyScalar(2*r)),e.sub(qA.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=KA,c=qA;this._calcPosition(l,a);for(let r=0;r<t;++r)this._calcPosition(c,i*s+a),o+=l.subVectors(c,l).length(),e.push(o),l.copy(c),i+=n;return e}_convertParamToChordLength(e,t){if(e<=0)return 0;if(e>=1)return 1;let n=e*t[t.length-1],i=0,o=0,r=t.length-1;for(;i<r;)o=i+Math.floor((r-i)/2),n>t[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)}}t_.prototype.isMotionPathConstraint=!0;const n_=["IMAGE_AR","SKYDOME_LIGHT_AR","TEXTURE_BL","TEX_IMAGE_BL","TEX_ENVIRONMENT_BL","BITMAP_MX","BITMAP_ENV_MX","REFLECT_REFRACT_MX","FILE_MY","AI_SKYDOME_LIGHT_MY","OSL_NODE"];class i_ extends sp{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new c_(e)})),this.register((function(e){return new g_(e)})),this.register((function(e){return new v_(e)})),this.register((function(e){return new d_(e)})),this.register((function(e){return new h_(e)})),this.register((function(e){return new p_(e)})),this.register((function(e){return new f_(e)})),this.register((function(e){return new l_(e)})),this.register((function(e){return new m_(e)})),this.register((function(e){return new u_(e)})),this.register((function(e){return new a_(e)})),this.register((function(e){return new A_(e)})),this.register((function(e){return new __(e)})),this.register((function(e){return new w_(e)})),this.register((function(e){return new T_(e)})),this.register((function(e){return new I_(e)})),this.register((function(e){return new R_(e)})),this.register((function(e){return new L_(e)})),this.register((function(e){return new P_(e)})),this.register((function(e){return new B_(e)})),this.register((function(e){return new D_(e)})),this.register((function(e){return new N_(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:Bp.extractUrlBase(e);const a=-1!=e.indexOf(".xz",e.length-3);let s;a?s=new eg(o.manager):(s=new up(o.manager),s.setResponseType("arraybuffer"));const l=function(e){o.onProgress&&o.onProgress(.3*e*100)};let c=l;s instanceof up&&(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(Bp.decodeText(new Uint8Array(e,0,4))===x_){try{a[r_.KHR_BINARY_GLTF]=new C_(e)}catch(e){return void(i&&i(e))}r=a[r_.KHR_BINARY_GLTF].content}else r=Bp.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")&&(lx("S8S_v3d_animation_data","S8S_v3d_animation",n),(e.animations||[]).forEach((e=>{cx("S8S_v3d_animation_data","S8S_v3d_animation",e)})),ux("S8S_v3d_animation_data"));n.includes("S8S_v3d_node_data")&&(lx("S8S_v3d_node_data","S8S_v3d_node",n),(e.nodes||[]).forEach((e=>{cx("S8S_v3d_node_data",[].concat(["S8S_v3d_node"],t),e)})),ux("S8S_v3d_node_data"));n.includes("S8S_v3d_material_data")&&(lx("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:cx("S8S_v3d_material_data","S8S_v3d_materials",e)})),ux("S8S_v3d_material_data"));n.includes("S8S_v3d_mesh_data")&&(lx("S8S_v3d_mesh_data","S8S_v3d_mesh",n),(e.meshes||[]).forEach((e=>{cx("S8S_v3d_mesh_data","S8S_v3d_mesh",e)})),ux("S8S_v3d_mesh_data"));n.includes("S8S_v3d_camera_data")&&(lx("S8S_v3d_camera_data","S8S_v3d_camera",n),(e.cameras||[]).forEach((e=>{cx("S8S_v3d_camera_data","S8S_v3d_camera",e)})),ux("S8S_v3d_camera_data"));n.includes("S8S_v3d_scene_data")&&(lx("S8S_v3d_scene_data","S8S_v3d_scene",n),(e.scenes||[]).forEach((e=>{cx("S8S_v3d_scene_data","S8S_v3d_scene",e)})),ux("S8S_v3d_scene_data"));n.includes("S8S_v3d_texture_data")&&(lx("S8S_v3d_texture_data","S8S_v3d_texture",n),(e.textures||[]).forEach((e=>{cx("S8S_v3d_texture_data","S8S_v3d_texture",e)})),ux("S8S_v3d_texture_data"));n.includes("S8S_v3d_data")&&(lx("S8S_v3d_data",t,n),cx("S8S_v3d_data",[].concat(t,["S8S_v3d_materials"]),e),ux("S8S_v3d_data"));const i=e.textures||[];i.forEach((t=>{if(In(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 ox(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<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](u);s[t.name]=t,a[t.name]=!0}if(l.extensionsUsed)for(let e=0;e<l.extensionsUsed.length;++e){const t=l.extensionsUsed[e],n=l.extensionsRequired||[];switch(t){case r_.KHR_MATERIALS_UNLIT:a[t]=new s_;break;case r_.KHR_DRACO_MESH_COMPRESSION:a[t]=new M_(l,this.dracoLoader);break;case r_.KHR_TEXTURE_TRANSFORM:a[t]=new S_;break;case r_.KHR_MESH_QUANTIZATION:a[t]=new E_;break;default:n.indexOf(t)>=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 o_(){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 r_={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_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",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",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing",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 a_{constructor(e){this.parser=e,this.name=r_.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<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let a;const s=new qn(16777215);void 0!==r.color&&s.fromArray(r.color);const l=void 0!==r.range?r.range:0;switch(r.type){case"directional":a=new Ep(s),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new bp(s),a.distance=l;break;case"spot":a=new vp(s),a.distance=l,r.spot=r.spot||{},r.spot.innerConeAngle=void 0!==r.spot.innerConeAngle?r.spot.innerConeAngle:0,r.spot.outerConeAngle=void 0!==r.spot.outerConeAngle?r.spot.outerConeAngle:Math.PI/4,a.angle=r.spot.outerConeAngle,a.penumbra=1-r.spot.innerConeAngle/r.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("v3d.GLTFLoader: Unexpected light type: "+r.type)}return a.position.set(0,0,0),a.decay=2,$_(a,r),void 0!==r.intensity&&(a.intensity=r.intensity),a.name=t.createUniqueName(r.name||"light_"+e),i=Promise.resolve(a),t.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}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 s_{constructor(){this.name=r_.KHR_MATERIALS_UNLIT}getMaterialType(){return So}extendParams(e,t,n){const i=[];e.color=new qn(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const t=o.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==o.baseColorTexture&&i.push(n.assignTexture(e,"map",o.baseColorTexture,Rt))}return Promise.all(i)}}class l_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name].emissiveStrength;return void 0!==i&&(t.emissiveIntensity=i),Promise.resolve()}}class c_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];if(void 0!==r.clearcoatFactor&&(t.clearcoat=r.clearcoatFactor),void 0!==r.clearcoatTexture&&o.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),void 0!==r.clearcoatRoughnessFactor&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),void 0!==r.clearcoatRoughnessTexture&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),void 0!==r.clearcoatNormalTexture&&(o.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),void 0!==r.clearcoatNormalTexture.scale)){const e=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new yn(e,e)}return Promise.all(o)}}class u_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return void 0!==r.iridescenceFactor&&(t.iridescence=r.iridescenceFactor),void 0!==r.iridescenceTexture&&o.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),void 0!==r.iridescenceIor&&(t.iridescenceIOR=r.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==r.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),void 0!==r.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),void 0!==r.iridescenceThicknessTexture&&o.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(o)}}class d_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new qn(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];return void 0!==r.sheenColorFactor&&t.sheenColor.fromArray(r.sheenColorFactor),void 0!==r.sheenRoughnessFactor&&(t.sheenRoughness=r.sheenRoughnessFactor),void 0!==r.sheenColorTexture&&o.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,Rt)),void 0!==r.sheenRoughnessTexture&&o.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(o)}}class h_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];return void 0!==r.transmissionFactor&&(t.transmission=r.transmissionFactor),void 0!==r.transmissionTexture&&o.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(o)}}class p_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.thickness=void 0!==r.thicknessFactor?r.thicknessFactor:0,void 0!==r.thicknessTexture&&o.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new qn(a[0],a[1],a[2]),Promise.all(o)}}class f_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const i=n.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class m_{constructor(e){this.parser=e,this.name=r_.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?bd:null}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],r=i.extensions[this.name];t.specularIntensity=void 0!==r.specularFactor?r.specularFactor:1,void 0!==r.specularTexture&&o.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new qn(a[0],a[1],a[2]),void 0!==r.specularColorTexture&&o.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,Rt)),Promise.all(o)}}class g_{constructor(e){this.parser=e,this.name=r_.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const o=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("v3d.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,o.source,r)}}class v_{constructor(e){this.parser=e,this.name=r_.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,r.source,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 A_{constructor(e){this.name=r_.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}}class __{constructor(e){this.name=r_.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const i=t.meshes[n.mesh];for(const e of i.primitives)if(e.mode!==z_.TRIANGLES&&e.mode!==z_.TRIANGLE_STRIP&&e.mode!==z_.TRIANGLE_FAN&&void 0!==e.mode)return null;const o=n.extensions[this.name].attributes,r=[],a={};for(const e in o)r.push(this.parser.getDependency("accessor",o[e]).then((t=>(a[e]=t,a[e]))));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then((e=>{const t=e.pop(),n=t.isGroup?t.children:[t],i=e[0].count,o=[];for(const e of n){const t=new zi,n=new ci,r=new li,s=new ci(1,1,1),l=new InstancedMesh(e.geometry,e.material,i);for(let e=0;e<i;e++)a.TRANSLATION&&n.fromBufferAttribute(a.TRANSLATION,e),a.ROTATION&&r.fromBufferAttribute(a.ROTATION,e),a.SCALE&&s.fromBufferAttribute(a.SCALE,e),l.setMatrixAt(e,t.compose(n,r,s));for(const t in a)"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,a[t]);uo.prototype.copy.call(l,e),l.frustumCulled=!1,this.parser.assignFinalMaterial(l),o.push(l)}return t.isGroup?(t.clear(),t.add(...o),t):o[0]})))}}const x_="glTF",y_=1313821514,b_=5130562;class C_{constructor(e){this.name=r_.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Bp.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==x_)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<n;){const t=i.getUint32(o,!0);o+=4;const n=i.getUint32(o,!0);if(o+=4,n===y_){const n=new Uint8Array(e,12+o,t);this.content=Bp.decodeText(n)}else if(n===b_){const n=12+o;this.body=e.slice(n,n+t)}o+=t}if(null===this.content)throw new Error("v3d.GLTFLoader: JSON content not found.")}}class M_{constructor(e,t){if(!t)throw new Error("v3d.GLTFLoader: No DRACOLoader instance provided.");this.name=r_.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,o=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},s={},l={};for(const e in r){const t=j_[e]||dx(e)||e.toLowerCase();a[t]=r[e]}for(const t in e.attributes){const i=j_[t]||dx(t)||t.toLowerCase();if(void 0!==r[t]){const o=n.accessors[e.attributes[t]],r=V_[o.componentType];l[i]=r,s[i]=!0===o.normalized}}return t.getDependency("bufferView",o).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],i=s[t];void 0!==i&&(n.normalized=i)}t(e)}),a,l)}))}))}}class S_{constructor(){this.name=r_.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('v3d.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class E_{constructor(){this.name=r_.KHR_MESH_QUANTIZATION}}class w_{constructor(e){this.parser=e,this.name=r_.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<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let a;const s=(new qn).fromArray(r.color),l=r.intensity;switch(r.type){case"point":a=new bp(s,l);break;case"directional":a=new Ep(s,l),In(r.shadow)&&In(r.shadow.csm)&&(a.shadow=new Mp);break;case"spot":a=new vp(s,l);break;case"area":a=new Ip(s,l,r.width,r.height);break;case"hemisphere":a=new mp(s,new qn(0,0,0),l);break;case"ambient":a=new wp(s,l)}let c;return In(r.distance)&&(a.distance=r.distance),In(r.decay)&&(a.decay=r.decay,"blender"==r.profile&&(a.userData.usePowerUnits=!0,a.power=a.intensity)),In(r.angle)&&(a.angle=r.angle),In(r.penumbra)&&(a.penumbra=r.penumbra),a.isRectAreaLight&&cg.init(r.ltcMat1,r.ltcMat2),In(r.shadow)?(In(r.shadow.enabled)||(r.shadow.enabled=!0),a.castShadow=r.shadow.enabled,a.shadow.bias=r.shadow.bias,In(r.shadow.expBias)&&(a.shadow.expBias=r.shadow.expBias),In(r.shadow.slopeScaledBias)&&(a.shadow.slopeScaledBias=r.shadow.slopeScaledBias),a.shadow.radius=r.shadow.radius,a.shadow.mapSize.width=r.shadow.mapSize,a.shadow.mapSize.height=r.shadow.mapSize,a.shadow.camera.near=r.shadow.cameraNear,a.shadow.camera.far=r.shadow.cameraFar,a.isSpotLight?(a.shadow.camera.fov=ln(r.shadow.cameraFov),a.shadow.useMinFov90="blender"===r.profile):a.isDirectionalLight&&(In(r.shadow.cameraOrthoLeft)&&In(r.shadow.cameraOrthoRight)&&In(r.shadow.cameraOrthoBottom)&&In(r.shadow.cameraOrthoTop)&&(a.shadow.camera.left=r.shadow.cameraOrthoLeft,a.shadow.camera.right=r.shadow.cameraOrthoRight,a.shadow.camera.bottom=r.shadow.cameraOrthoBottom,a.shadow.camera.top=r.shadow.cameraOrthoTop),a.shadow.isDirectionalLightShadowCSM&&(a.shadow.maxDistance=r.shadow.csm.maxDistance)),a.shadow.camera.updateProjectionMatrix()):a.castShadow=!1,a.name=t.createUniqueName(r.name||"light_"+e),(a.isDirectionalLight||a.isSpotLight)&&In(r.target)?(a.isFreeLight=!1,c=t.getDependency("node",r.target)):(a.isFreeLight=!0,c=Promise.resolve()),c.then((e=>(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 T_{constructor(e){this.parser=e,this.name=r_.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;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].lightProbe&&e._addNodeRef(this.cache,i.extensions[this.name].lightProbe)}}_loadLightProbe(e){const t=this.parser,n="lightProbe:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).lightProbes||[])[e];let a;if("CUBEMAP"==(r.type||"CUBEMAP")){switch(a=new Im,r.influenceType){case"ELIPSOID":a.influenceType=1;break;case"BOX":a.influenceType=2}switch(r.parallaxType){case"ELIPSOID":a.parallaxType=1;break;case"BOX":a.parallaxType=2}a.parallaxDistance=r.parallaxDistance,a.probeClipEnd=r.clipEnd,a.probeIntensity=r.intensity,In(r.influenceGroup)&&(a.influenceGroup=r.influenceGroup),In(r.influenceGroupInv)&&(a.influenceGroupInv=r.influenceGroupInv)}else a=new lg,a.falloff=r.falloff,In(r.planeSize)&&a.planeSize.set(r.planeSize[0],r.planeSize[1]);return a.influenceDistance=r.influenceDistance,a.probeClipStart=r.clipStart,a.visibilityGroup=r.visibilityGroup,a.visibilityGroupInv=r.visibilityGroupInv,a.name=t.createUniqueName(r.name||"lightProbe_"+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]||{}).lightProbe;return void 0===o?null:this._loadLightProbe(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class I_{constructor(e){this.parser=e,this.name=r_.S8S_V3D_CURVES,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].curve&&e._addNodeRef(this.cache,i.extensions[this.name].curve)}}_loadOpenType(){return new Promise((function(e){Un("opentype.js",(function(){e()}),(function(){console.error("GLTFLoader: opentype.js module not found, please copy it to your app directory"),e()}))}))}_loadFont(e){const t=this.parser,n="curve:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).fonts||[])[e];let a=r.uri,s=!1;return void 0!==r.bufferView&&(a=t.getDependency("bufferView",r.bufferView).then((function(e){s=!0;const t=new Blob([e],{type:r.mimeType});return a=URL.createObjectURL(t),a}))),Promise.all([this._loadOpenType(),a]).then((function(e){if(a=e[1],"undefined"==typeof opentype)return null;const n=new tg;return n.setCrossOrigin(t.options.crossOrigin),new Promise((function(e,i){n.load(Bp.resolveURL(a,t.options.path),e,void 0,i)})).then((function(e){return new ug(e)}),(function(e){return null}))})).then((function(e){return!0===s&&URL.revokeObjectURL(a),i=Promise.resolve(e),t.cache.add(n,i),i}))}_loadCurve(e){const t=this.parser,n="curve:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).curves||[])[e];let a,s=r.type;const l=[];return l.push(this._loadFont(r.font)),void 0!==r.material?l.push(t.getDependency("material",r.material)):l.push(Z_(t.cache)),Promise.all(l).then((function(o){const l=o[0],c=o[1];if(null===l&&(s="empty"),"font"===s){const e=r.bevelSize>0||r.bevelThickness>0,t=new gd(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 ir(t,c)}else a=new uo;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 R_{constructor(e){this.parser=e,this.name=r_.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<i;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].clippingPlane&&e._addNodeRef(this.cache,i.extensions[this.name].clippingPlane)}}_loadClippingPlane(e){const t=this.parser,n="clippingPlane:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,r=((o.extensions&&o.extensions[this.name]||{}).clippingPlanes||[])[e],a=new mg;return a.clippingGroup=r.clippingGroup,a.clipShadows=r.clipShadows,a.negated=r.negated,a.clipIntersection=r.clipIntersection,a.crossSection=r.crossSection,a.crossSectionColor=(new qn).fromArray(r.color),a.crossSectionOpacity=r.opacity,a.crossSectionSize=r.size,In(r.renderSide)&&(a.crossSectionRenderSide=q_[r.renderSide]),a.name=t.createUniqueName(r.name||"clippingPlane_"+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]||{}).clippingPlane;return void 0===o?null:this._loadClippingPlane(o).then((function(e){return n._getNodeRef(t.cache,o,e)}))}}class L_{constructor(e){this.name=r_.S8S_V3D_SCENE,this.parser=e}beforeRoot(){const e=this.parser.json.asset.generator||"";if(e.indexOf("Verge3D")>-1&&"ALL"!=jt){[["Blender","BLENDER"],["3ds Max","MAX"],["Maya","MAYA"]].forEach((function(t){const n=t[0],i=t[1];e.indexOf(n)>-1&&jt!=i&&console.warn("The glTF asset was exported from "+n+". It may not be fully compatible with Verge3D "+Ln()+".")}))}}afterRoot(e){const t=this.parser,n=t.json,i=n.scenes[n.scene||0],o=e.scene,r=In(i.extensions)?i.extensions[r_.S8S_V3D_SCENE]:void 0,c=[],g=[],v=[];let A;return A=i&&r&&In(r.worldMaterial)?t.getDependency("material",r.worldMaterial):Promise.resolve(),A.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&&In(n.originData.object)&&n.originData.object>-1&&(c.push(t.getDependency("node",n.originData.object)),g.push(n),v.push(e))}))})),Promise.all(c)))).then((t=>{for(let e=0;e<t.length;e++){const n=t[e],i=g[e],o=v[e],r=o.nodeTexCoordObjectMap[i.originData.name];o.nodeTexCoordObject[r]=n}const n=[];for(let t=0;t<e.cameras.length;t++){const i=e.cameras[t];let r=!1;i.traverseAncestors((function(e){e==o&&(r=!0)})),r&&n.push(i)}e.cameras=n;for(let t=0;t<e.animations.length;t++){const n=e.animations[t];n.clip&&void 0!==n.clip.name&&(n.clip.name=n.clip.name)}const r={};if(i){const e=In(i.extensions)?i.extensions[r_.S8S_V3D_SCENE]:void 0;if(e){if(In(e.shadowMap)){switch(r.shadowMap={enabled:!0},e.shadowMap.type){case"BASIC":r.shadowMap.type=a;break;case"BILINEAR":r.shadowMap.type=h;break;case"PCF":r.shadowMap.type=s;break;case"PCFSOFT":r.shadowMap.type=l;break;case"PCFPOISSON":r.shadowMap.type=d;break;case"ESM":r.shadowMap.type=u}let t;t=e.shadowMap.renderSingleSided?e.shadowMap.renderReverseSided?f:p:m,o.traverse((function(e){const n=e.material;n&&(n.shadowSide=t)})),r.esmDistanceScale=e.shadowMap.esmDistanceScale}if(In(e.physicallyCorrectLights)&&(r.physicallyCorrectLights=e.physicallyCorrectLights),In(e.aaMethod)&&(r.aaMethod=e.aaMethod),In(e.useHDR)&&(r.useHDR=e.useHDR),In(e.useOIT)&&(r.useOIT=e.useOIT),In(e.unitsScaleFactor)&&(r.unitsScaleFactor=e.unitsScaleFactor),In(e.toneMapping))switch(e.toneMapping.type){case"logarithmicMax":r.toneMapping=ne,r.toneMappingBrightness=e.toneMapping.brightness,r.toneMappingContrast=e.toneMapping.contrast,r.toneMappingMidTones=e.toneMapping.midTones,r.toneMappingPhysicalScale=e.toneMapping.physicalScale,r.toneMappingChromaticAdaptation=e.toneMapping.chromaticAdaptation,r.toneMappingWhiteColor=(new qn).fromArray(e.toneMapping.whiteColor),r.toneMappingColorDifferentiation=e.toneMapping.colorDifferentiation,r.toneMappingExteriorDaylight=e.toneMapping.exteriorDaylight;break;case"physicalMax":r.toneMapping=ie,r.toneMappingWhiteBalance=(new qn).fromArray(e.toneMapping.whiteBalance),r.toneMappingHighlights=e.toneMapping.highlights,r.toneMappingMidTones=e.toneMapping.midTones,r.toneMappingShadows=e.toneMapping.shadows,r.toneMappingSaturation=e.toneMapping.saturation,r.toneMappingPhysicalScale=e.toneMapping.physicalScale,r.toneMappingAperture=e.toneMapping.aperture,r.toneMappingShutter=e.toneMapping.shutter,r.toneMappingISO=e.toneMapping.iso,r.toneMappingVignetting=e.toneMapping.vignetting;break;case"filmicBlender":r.toneMapping=oe}if(In(e.pmremMaxTileSize)&&(r.pmremMaxTileSize=e.pmremMaxTileSize),In(e.iblEnvironmentMode))switch(e.iblEnvironmentMode){case"PMREM":default:r.iblEnvironmentMode=0;break;case"PROBE_CUBEMAP":console.warn("v3d.GLTFLoader: Cubemap probes deprecated since Verge3D 4.3, using PMREM instead"),r.iblEnvironmentMode=0;break;case"PROBE":r.iblEnvironmentMode=2;break;case"NONE":r.iblEnvironmentMode=3}In(e.postprocessing)&&(o.postprocessing=e.postprocessing)}}e.renderer=r}))}}class P_{constructor(e){this.name=r_.S8S_V3D_NODE,this.parser=e}extendNodeParams(e,t){const n=t.extensions&&t.extensions[this.name];if(!n)return e;if(n.hidden&&(e.visible=!1),e.isMesh&&(In(n.useCastShadows)?e.castShadow=n.useCastShadows:In(e.material.castShadow)&&(e.castShadow=e.material.castShadow),In(n.useShadows)?e.receiveShadow=n.useShadows:In(e.material.receiveShadow)&&(e.receiveShadow=e.material.receiveShadow)),In(n.objectIndex)&&(e.objectIndex=n.objectIndex),In(n.objectColor)&&(e.objectColor=(new qn).fromArray(n.objectColor),e.objectAlpha=In(n.objectColor[3])?n.objectColor[3]:1),e.renderOrder=n.renderOrder,e.frustumCulled=n.frustumCulling,In(n.groupNames)&&(e.groupNames=n.groupNames),In(n.hidpiCompositing)&&(e.hidpiCompositing=n.hidpiCompositing),e.isMesh&&e.material.isMeshNodeMaterial){const t=e.material;(t.hasNode("MATTE_SHADOW_MX")||t.hasNode("SHADOW_MATTE_AR")||t.hasNode("AI_SHADOW_MATTE_MY"))&&(t.transparent=!1,t.premultipliedAlpha=!0,fx(t),e.renderOrder-=1e3,e.castShadow=!1,e.receiveShadow=!0)}return this.processConstraints(e,n.constraints)}processConstraints(e,t=[]){if(e.isMaterialGeneratedMesh)return e;const n=this.parser,i=[];for(let e=0;e<t.length;e++){const o=t[e];In(o.target)?i.push(n.getDependency("node",o.target)):i.push(Promise.resolve(null))}return Promise.all(i).then((function(n){for(let i=0;i<t.length;i++){const o=t[i],r=n[i];let a;switch(o.type){case"copyLocation":a=new Qg(r),a.useX=!In(o.useX)||o.useX,a.useY=!In(o.useY)||o.useY,a.useZ=!In(o.useZ)||o.useZ,a.invertX=!!In(o.invertX)&&o.invertX,a.invertY=!!In(o.invertY)&&o.invertY,a.invertZ=!!In(o.invertZ)&&o.invertZ,a.useOffset=!In(o.useOffset)||o.useOffset,a.influence=In(o.influence)?o.influence:1;break;case"copyRotation":a=new Xg(r),a.useX=!In(o.useX)||o.useX,a.useY=!In(o.useY)||o.useY,a.useZ=!In(o.useZ)||o.useZ,a.invertX=!!In(o.invertX)&&o.invertX,a.invertY=!!In(o.invertY)&&o.invertY,a.invertZ=!!In(o.invertZ)&&o.invertZ,a.mixMode=In(o.mixMode)?o.mixMode:"REPLACE",a.influence=In(o.influence)?o.influence:1,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"copyScale":a=new Jg(r),a.useX=!In(o.useX)||o.useX,a.useY=!In(o.useY)||o.useY,a.useZ=!In(o.useZ)||o.useZ,a.power=In(o.power)?o.power:1,a.useMakeUniform=!!In(o.useMakeUniform)&&o.useMakeUniform,a.useOffset=!!In(o.useOffset)&&o.useOffset,a.useAdd=!!In(o.useAdd)&&o.useAdd,a.influence=In(o.influence)?o.influence:1;break;case"copyTransforms":a=new ov(r),a.mixMode=In(o.mixMode)?o.mixMode:"REPLACE",a.influence=In(o.influence)?o.influence:1,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"dampedTrack":a=new mv(r),a.trackAxis=o.trackAxis,a.influence=In(o.influence)?o.influence:1,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"limitDistance":a=new Ev(r),a.distance=In(o.distance)?o.distance:0,a.limitMode=In(o.limitMode)?o.limitMode:"LIMITDIST_INSIDE",a.useTransformLimit=!!In(o.useTransformLimit)&&o.useTransformLimit,a.influence=In(o.influence)?o.influence:1;break;case"limitLocation":a=new wv,a.min.set(Number(o.minX),Number(o.minY),Number(o.minZ)),a.max.set(Number(o.maxX),Number(o.maxY),Number(o.maxZ));break;case"limitRotation":a=new Iv,a.axis=o.axis,a.min=o.min,a.max=o.max;break;case"limitScale":a=new Rv,a.min.set(Number(o.minX),Number(o.minY),Number(o.minZ)),a.max.set(Number(o.maxX),Number(o.maxY),Number(o.maxZ));break;case"lockedTrack":a=new Gv(r),a.trackAxis=o.trackAxis,a.lockAxis=o.lockAxis,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"trackTo":a=new $v(r),a.trackAxis=o.trackAxis,a.upAxis=o.upAxis,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"childOf":a=new zg(r),a.offsetMatrix=(new zi).fromArray(o.offsetMatrix),a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation;break;case"floor":a=new yv(r),a.floorLocation=o.floorLocation,a.offset=o.offset,a.useRotation=!!In(o.useRotation)&&o.useRotation;break;case"fixOrthoZoom":a=new eA(r);break;case"canvasFit":a=new aA(r),a.edgeH=o.edgeH,a.edgeV=o.edgeV,a.fitShape=o.fitShape,a.offset=o.offset,"SPHERE"==o.fitShape&&e.resolveMultiMaterial().forEach((function(e){e.geometry&&e.geometry.computeBoundingSphere()}));break;case"canvasBreakpoints":a=new sA,a.minWidth=Number(o.minWidth),a.maxWidth=Number(o.maxWidth),a.minHeight=Number(o.minHeight),a.maxHeight=Number(o.maxHeight),a.orientation=o.orientation;break;case"motionPath":a=new t_,a.degree=o.degree,a.cvs=[];for(let e=0;e<o.cvs.length;++e)a.cvs.push(Number(o.cvs[e]));a.knots=[];for(let e=0;e<o.knots.length;++e)a.knots.push(Number(o.knots[e]));a.weights=[];for(let e=0;e<o.weights.length;++e)a.weights.push(Number(o.weights[e]));if(a.value=In(o.value)?o.value:0,a.follow=!!In(o.follow)&&o.follow,a.frontAxis=In(o.frontAxis)?o.frontAxis:"Z",a.upAxis=In(o.upAxis)?o.upAxis:"Y",a.worldUpVector=In(o.worldUpVector)?(new ci).fromArray(o.worldUpVector).normalize():new ci(0,1,0),a.useChordLength=!!In(o.useChordLength)&&o.useChordLength,a.bank=!!In(o.bank)&&o.bank,a.bankScale=In(o.bankScale)?o.bankScale:1,a.bankLimit=In(o.bankLimit)?o.bankLimit:1/0,a.useFixedLocation=!!In(o.useFixedLocation)&&o.useFixedLocation,a.fixedValue=In(o.fixedValue)?o.fixedValue:0,a.usePointsTilt=!!In(o.usePointsTilt)&&o.usePointsTilt,a.pointsTilt=[],In(o.pointsTilt))for(let e=0;e<o.pointsTilt.length;++e)a.pointsTilt.push(Number(o.pointsTilt[e]));a.offsetValue=In(o.offsetValue)?o.offsetValue:0,a.useClampValue=!!In(o.useClampValue)&&o.useClampValue,a.useCyclic=!!In(o.useCyclic)&&o.useCyclic,a.useObjOffset=!!In(o.useObjOffset)&&o.useObjOffset,a.useRelative=!!In(o.useRelative)&&o.useRelative,a.usePosOffset=!In(o.usePosOffset)||o.usePosOffset,a.objOffsetMode=In(o.objOffsetMode)?o.objOffsetMode:0,a.objOffsetRotMode=In(o.objOffsetRotMode)?o.objOffsetRotMode:0,a.influence=In(o.influence)?o.influence:1,a.fixCameraLightRotation=!!In(o.fixCameraLightRotation)&&o.fixCameraLightRotation,a.init()}a&&(a.name=o.name,a.mute=o.mute,e.constraints.push(a))}return e}))}}class B_{constructor(e){this.name=r_.S8S_V3D_CAMERA,this.parser=e}extendCameraParams(e,t){const n=this.parser,i=t.extensions&&t.extensions[this.name];if(!i)return Promise.resolve(e);if(e.controls=new Dg(i.controls,i.enablePan,i.rotateSpeed,i.moveSpeed),e.viewportFit.type=3,In(i.viewportFitType))switch(i.viewportFitType){case"VERTICAL":e.viewportFit.type=1;break;case"HORIZONTAL":e.viewportFit.type=2;break;case"AUTO":e.viewportFit.type=3;break;case"FILL":e.viewportFit.type=4;break;case"OVERSCAN":e.viewportFit.type=5}In(i.viewportFitInitialAspect)&&(e.viewportFit.initialAspect=i.viewportFitInitialAspect),In(i.orbitMinDistance)&&(e.controls.orbitMinDistance=i.orbitMinDistance),In(i.orbitMaxDistance)&&(e.controls.orbitMaxDistance=i.orbitMaxDistance),In(i.orbitMinZoom)&&(e.controls.orbitMinZoom=i.orbitMinZoom),In(i.orbitMaxZoom)&&(e.controls.orbitMaxZoom=i.orbitMaxZoom),In(i.orbitMinPolarAngle)&&(e.controls.orbitMinPolarAngle=i.orbitMinPolarAngle),In(i.orbitMaxPolarAngle)&&(e.controls.orbitMaxPolarAngle=i.orbitMaxPolarAngle),In(i.orbitMinAzimuthAngle)&&(e.controls.orbitMinAzimuthAngle=i.orbitMinAzimuthAngle),In(i.orbitMaxAzimuthAngle)&&(e.controls.orbitMaxAzimuthAngle=i.orbitMaxAzimuthAngle);const o=[];if(In(i.orbitTarget))if(i.orbitTarget instanceof Array){const e=new uo;e.position.fromArray(i.orbitTarget),o.push(Promise.resolve(e))}else o.push(n.getDependency("node",i.orbitTarget));else o.push(Promise.resolve());return In(i.fpsCollisionMaterial)?o.push(n.getDependency("material",i.fpsCollisionMaterial)):o.push(Promise.resolve()),In(i.fpsGazeLevel)&&(e.controls.gazeLevel=i.fpsGazeLevel),In(i.fpsStoryHeight)&&(e.controls.storyHeight=i.fpsStoryHeight),In(i.enablePointerLock)&&(e.controls.enablePointerLock=i.enablePointerLock),Promise.all(o).then((t=>(t[0]&&(e.controls.orbitTarget=t[0]),t[1]&&(e.controls.collisionMaterial=t[1]),e)))}}class D_{constructor(e){this.name=r_.S8S_V3D_MATERIALS,this.parser=e}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?Bh: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(In(o.nodeGraph)){const e=Bh.nodeGraphFromExtGraph(o.nodeGraph);t.nodeGraph=e,Bh.nodeGraphTraverse(e,(e=>{const n=e.originData;if(n_.indexOf(n.type)>-1&&In(n.texture)){const e=Bh.nodeTexUniName(n.type,n.texture);r.push(this.assignTextureNode(t,e,n.texture))}else"RAMP_MY"==n.type&&(n.wrapS=k_[n.wrapS]||de,n.wrapT=k_[n.wrapT]||de)}));const i=n.extensions&&n.extensions[this.name]||{};if(i&&i.nodeGraphs){t.additionalNodeGraphs={};for(let e in i.nodeGraphs){const n=Bh.nodeGraphFromExtGraph(i.nodeGraphs[e]);t.additionalNodeGraphs[e]=n,Bh.nodeGraphTraverse(n,(e=>{const n=e.originData;if(n_.indexOf(n.type)>-1){const e=Bh.nodeTexUniName(n.type,n.texture);r.push(this.assignTextureNode(t,e,n.texture))}}))}}}return In(o.profile)&&(t.profile=o.profile),In(o.renderSide)&&(t.side=q_[o.renderSide]),In(o.useShadows)&&(t.receiveShadow=o.useShadows),In(o.useCastShadows)&&(t.castShadow=o.useCastShadows),In(o.depthWrite)&&(t.depthWrite=o.depthWrite),In(o.depthPrepass)&&(t.depthPrepass=o.depthPrepass),In(o.depthTest)&&(t.depthTest=o.depthTest),In(o.dithering)&&(t.dithering=o.dithering),In(o.materialIndex)&&(t.materialIndex=o.materialIndex),!0===o.alphaToCoverage&&(t.alphaToCoverage=!0),In(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,n){const i=t.extensions[this.name]||{};if(e.premultipliedAlpha=n==K_.BLEND,n==K_.BLEND)if(In(i.blendMode)){const t=i.blendMode;e.blending=b,In(t.blendEquation)&&(e.blendEquation=Q_[t.blendEquation]),In(t.blendEquationAlpha)&&(e.blendEquationAlpha=Q_[t.blendEquationAlpha]),In(t.srcRGB)&&(e.blendSrc=W_[t.srcRGB]),In(t.dstRGB)&&(e.blendDst=W_[t.dstRGB]),In(t.srcAlpha)&&(e.blendSrcAlpha=W_[t.srcAlpha]),In(t.dstAlpha)&&(e.blendDstAlpha=W_[t.dstAlpha])}else e.useAddTransparency()?e.blending=_:fx(e)}}class N_{constructor(e){this.parser=e,this.name=r_.S8S_V3D_TEXTURE,this.textureLoaderRGBE=new ng,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(!In(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 eg),a.uri){const e=n.options.manager.getHandler(a.uri);null!==e&&(s=e)}return n.loadTextureImage(e,r.source,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?It:Rt;e.encoding=r,(n instanceof ng||n instanceof eg)&&(e.minFilter=ve),In(o.anisotropy)&&(e.anisotropy=o.anisotropy),In(o.uvTransform)&&(e.matrix=(new bn).fromArray(o.uvTransform),e.matrixAutoUpdate=!1)}}class O_ extends Rd{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}interpolate_(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 F_=new li;class U_ extends O_{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return F_.fromArray(o).normalize().toArray(o),o}}const z_={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},V_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},G_={9728:fe,9729:ve,9984:me,9985:Ae,9986:ge,9987:_e},k_={33071:he,33648:pe,10497:de},Q_={32774:C,32778:M,32779:S},W_={0:T,1:I,768:R,769:L,770:P,771:B,772:D,773:N,774:O,775:F,776:U},H_={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},j_={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Y_={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences",intensity:"intensity"},X_={CUBICSPLINE:void 0,LINEAR:_t,STEP:At},K_={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"},q_={FRONT:p,BACK:f,DOUBLE:m};function Z_(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new yd({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:p,receiveShadow:!0,castShadow:!0})),e.DefaultMaterial}function J_(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 $_(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 ex(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,i=t.weights.length;n<i;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,i=n.length;t<i;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("v3d.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function tx(e){const t=e.extensions&&e.extensions[r_.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+nx(t.attributes):e.indices+":"+nx(e.attributes)+":"+e.mode,n}function nx(e){let t="";const n=Object.keys(e).sort();for(let i=0,o=n.length;i<o;i++)t+=n[i]+":"+e[n[i]]+";";return t}function ix(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("v3d.GLTFLoader: Unsupported normalized accessor component type.")}}new zi;class ox{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.onProgress=t.onProgress||function(){},this.cache=new o_,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=!1,o=-1;"undefined"!=typeof navigator&&(n=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=navigator.userAgent.indexOf("Firefox")>-1,o=i?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"undefined"==typeof createImageBitmap||n||i&&o<98?this.textureLoader=new pp(this.options.manager):this.textureLoader=new zp(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new up(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0),this.assignedMaterials=[]}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,o=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const r={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:n,userData:{}};J_(o,r,i),$_(r,i),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(r)}))).then((function(){e(r)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,i=t.length;n<i;n++){const i=t[n].joints;for(let t=0,n=i.length;t<n;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(n[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),o=(e,t)=>{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<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const o=e(t[i]);o&&n.push(o)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return n.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this,n=this.json.buffers[e];if(n.type&&"arraybuffer"!==n.type)throw new Error("v3d.GLTFLoader: "+n.type+" buffer type is not supported.");if(void 0===n.uri&&0===e)return Promise.resolve(this.extensions[r_.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e){let o,r;i.loadBinXZ?(o=Bp.resolveURL(n.uri,i.path)+".xz",r=new eg):(o=Bp.resolveURL(n.uri,i.path),r=t.fileLoader);const a=function(e){if(t.onProgress){const n=100*(.3+.7*e);t.onProgress(n)}};let s=a;r instanceof up&&(s=function(e){const t=e.lengthComputable?e.loaded/e.total:1;a(t)}),r.load(o,e,s)}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+n)}))}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(void 0===i.bufferView&&void 0===i.sparse){const e=H_[i.type],t=V_[i.componentType],n=!0===i.normalized,o=new t(i.count*e);return Promise.resolve(new To(o,e,n))}const o=[];return void 0!==i.bufferView?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),void 0!==i.sparse&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then((function(e){const o=e[0],r=H_[i.type],a=V_[i.componentType],s=a.BYTES_PER_ELEMENT,l=s*r,c=i.byteOffset||0,u=void 0!==i.bufferView?n.bufferViews[i.bufferView].byteStride:void 0,d=!0===i.normalized;let h,p;if(u&&u!==l){const e=Math.floor(c/u),n="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+e+":"+i.count;let l=t.cache.get(n);l||(h=new a(o,e*u,i.count*u/s),l=new Ql(h,u/s),t.cache.add(n,l)),p=new Hl(l,r,c%u/s,d)}else h=null===o?new a(i.count*r):new a(o,c,i.count*r),p=new To(h,r,d);if(void 0!==i.sparse){const t=H_.SCALAR,n=V_[i.sparse.indices.componentType],s=i.sparse.indices.byteOffset||0,l=i.sparse.values.byteOffset||0,c=new n(e[1],s,i.sparse.count*t),u=new a(e[2],l,i.sparse.count*r);null!==o&&(p=new To(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,u[e*r]),r>=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].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const e=n.manager.getHandler(o.uri);null!==e&&(r=e)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const i=this,o=this.json,r=o.textures[e],a=o.images[t],s=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[s])return this.textureCache[s];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,t.name=r.name||a.name||"";const s=(o.samplers||{})[r.sampler]||{};return t.magFilter=G_[s.magFilter]||ve,t.minFilter=G_[s.minFilter]||_e,t.wrapS=k_[s.wrapS]||de,t.wrapT=k_[s.wrapT]||de,i._invokeAll((function(e){return e.extendTextureParams&&e.extendTextureParams(t,r,n)})),i.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[s]=l,l}loadImageSource(e,t){const n=this,i=this.json,o=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const r=i.images[e],a=self.URL||self.webkitURL;let s=r.uri||"",l=!1;if(void 0!==r.bufferView)s=n.getDependency("bufferView",r.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:r.mimeType});return s=a.createObjectURL(t),s}));else if(void 0===r.uri)throw new Error("v3d.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(s).then((function(e){return new Promise((function(n,i){let r=n;!0===t.isImageBitmapLoader&&(r=function(e){const t=new ni(e);t.needsUpdate=!0,n(t)}),t.load(Bp.resolveURL(e,o.path),r,void 0,i)}))})).then((function(e){if(e instanceof ArrayBuffer){return n.plugins[r_.S8S_V3D_TEXTURE].textureLoaderRGBE.loadAsync(a.createObjectURL(new Blob([e],{type:"image/vnd.radiance"})))}return Promise.resolve(e)})).then((function(e){var t;return!0===l&&a.revokeObjectURL(s),e.userData.mimeType=r.mimeType||((t=r.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){return console.error("v3d.GLTFLoader: Couldn't load texture",s),new ni}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,i){const o=this;return this.getDependency("texture",n.index).then((function(r){if(!r)return null;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."),o.extensions[r_.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[r_.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=o.associations.get(r);r=o.extensions[r_.KHR_TEXTURE_TRANSFORM].extendTexture(r,e),o.associations.set(r,t)}}return void 0!==i&&(r.encoding=i),e[t]=r,r}))}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,Mo.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,Mo.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+":";r&&(e+="derivative-tangents:"),a&&(e+="vertex-colors:"),s&&(e+="flat-shading:");const i=tn();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 yd}loadMaterial(e){const t=this,n=this.json,i=this.extensions,o=n.materials[e];let r;const a={},s=[];if((o.extensions||{})[r_.KHR_MATERIALS_UNLIT]){const e=i[r_.KHR_MATERIALS_UNLIT];r=e.getMaterialType(),s.push(e.extendParams(a,o,t))}else{const n=o.pbrMetallicRoughness||{};if(a.color=new qn(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&&s.push(t.assignTexture(a,"map",n.baseColorTexture,Rt)),a.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,a.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(s.push(t.assignTexture(a,"metalnessMap",n.metallicRoughnessTexture)),s.push(t.assignTexture(a,"roughnessMap",n.metallicRoughnessTexture))),r=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),s.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===o.doubleSided&&(a.side=m);const l=o.alphaMode||K_.OPAQUE;if(l===K_.BLEND?(a.transparent=!0,r!==Bh&&(a.depthWrite=!1)):(a.transparent=!1,l===K_.MASK&&(a.alphaTest=void 0!==o.alphaCutoff?o.alphaCutoff:.5)),void 0!==o.normalTexture&&r!==So&&(s.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new yn(1,1),void 0!==o.normalTexture.scale)){const e=o.normalTexture.scale;a.normalScale.set(e,e)}return void 0!==o.occlusionTexture&&r!==So&&(s.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),void 0!==o.occlusionTexture.strength&&(a.aoMapIntensity=o.occlusionTexture.strength)),void 0!==o.emissiveFactor&&r!==So&&(a.emissive=(new qn).fromArray(o.emissiveFactor)),void 0!==o.emissiveTexture&&r!==So&&s.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,Rt)),Promise.all(s).then((function(){const n=new r(a);o.name&&(n.name=o.name),n.map&&(n.map.encoding=Rt),n.emissiveMap&&(n.emissiveMap.encoding=Rt);const s=t.plugins[r_.S8S_V3D_MATERIALS];return n.isMeshNodeMaterial&&s.assignTransparency(n,o,l),n.isMeshStandardMaterial&&n.normalScale&&s&&In(s.profile)&&"max"==s.profile&&(n.normalScale.y=-n.normalScale.y),$_(n,o),t.associations.set(n,{materials:e}),o.extensions&&J_(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[r_.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return ax(n,e,t)}))}const r=[];for(let n=0,a=e.length;n<a;n++){const a=e[n],s=tx(a),l=i[s];if(l)r.push(l.promise);else{let e;e=a.extensions&&a.extensions[r_.KHR_DRACO_MESH_COMPRESSION]?o(a):ax(new zo,a,t),i[s]={primitive:a,promise:e},r.push(e)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,o=n.meshes[e],r=o.primitives,a=[],s=In(o.extensions)?o.extensions[r_.S8S_V3D_MESH]:void 0;for(let e=0,t=r.length;e<t;e++){const t=void 0===r[e].material?Z_(this.cache):this.getDependency("material",r[e].material);a.push(t)}return a.push(t.loadGeometries(r)),Promise.all(a).then((function(n){const a=n.slice(0,n.length-1),l=n[n.length-1],c=[];for(let n=0,u=l.length;n<u;n++){const u=l[n],d=r[n];let h;const p=a[n];if(d.mode===z_.TRIANGLES||d.mode===z_.TRIANGLE_STRIP||d.mode===z_.TRIANGLE_FAN||void 0===d.mode)h=!0===o.isSkinnedMesh?new gc(u,p):new ir(u,p),!0!==h.isSkinnedMesh||h.geometry.attributes.skinWeight.normalized||h.normalizeSkinWeights(),d.mode===z_.TRIANGLE_STRIP?h.geometry=sx(h.geometry,wt):d.mode===z_.TRIANGLE_FAN&&(h.geometry=sx(h.geometry,Tt));else if(d.mode===z_.LINES)if(s){const e=new am;e.fromBufferGeometry(u);const t=new sm({color:In(s.lineColor)?(new qn).fromArray(s.lineColor):new qn(1,1,1),lineWidth:In(s.lineWidth)?s.lineWidth:1,sizeAttenuation:0});h=new ir(e.geometry,t),h.userData.originalLineGeom=u}else h=new Uc(u,p);else if(d.mode===z_.LINE_STRIP)h=new Nc(u,p);else if(d.mode===z_.LINE_LOOP)h=new zc(u,p);else{if(d.mode!==z_.POINTS)throw new Error("v3d.GLTFLoader: Primitive mode unsupported: "+d.mode);h=new Hc(u,p)}Object.keys(h.geometry.morphAttributes).length>0&&ex(h,o),h.name=t.createUniqueName(o.name||"mesh_"+e),$_(h,o),d.extensions&&J_(i,h,d);const f={},m={};if(h.material.isMeshNodeMaterial&&s){if(s.uvLayers)for(let e in s.uvLayers)f[e]=hx(s.uvLayers[e]);if(s.colorLayers)for(let e in s.colorLayers)m[e]=px(s.colorLayers[e])}t.assignFinalMaterial(h,f,m),c.push(h)}for(let n=0,i=c.length;n<i;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(1===c.length)return c[0];const u=new vl;t.associations.set(u,{meshes:e});for(let e=0,t=c.length;e<t;e++)c[e].name+="_"+e,c[e].isMaterialGeneratedMesh=!0,u.add(c[e]);return u}))}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(i)return"perspective"===n.type?t=new hr(ln(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):"orthographic"===n.type&&(t=new Fr(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=n.name),$_(t,n),this._invokeOne((function(e){return e.extendCameraParams&&e.extendCameraParams(t,n)}));console.warn("v3d.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(this.getDependency("node",t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then((function(e){const n=e.pop(),i=e,o=[],r=[];for(let e=0,a=i.length;e<a;e++){const a=i[e];if(a){o.push(a);const t=new zi;null!==n&&t.fromArray(n.array,16*e),r.push(t)}else console.warn('v3d.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}return new yc(o,r)}))}loadAnimation(e){const t=this.json.animations[e],n=[],i=[],o=[],r=[],a=[];for(let e=0,s=t.channels.length;e<s;e++){const s=t.channels[e],l=t.samplers[s.sampler],c=s.target,u=c.node,d=void 0!==t.parameters?t.parameters[l.input]:l.input,h=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",u)),i.push(this.getDependency("accessor",d)),o.push(this.getDependency("accessor",h)),r.push(l),a.push(c)}return Promise.all([Promise.all(n),Promise.all(i),Promise.all(o),Promise.all(r),Promise.all(a),this.getDependencies("material")]).then((function(n){const i=n[0],o=n[1],r=n[2],a=n[3],s=n[4],l=[];for(let e=0,t=i.length;e<t;e++){const t=i[e],c=o[e],u=r[e],d=a[e],h=s[e];if(void 0===t)continue;let p;t.updateMatrix();let f="";switch(Y_[h.path]){case Y_.weights:p=Zh;break;case Y_.rotation:p=$h;break;case Y_.translation:case Y_.scale:p=tp;break;case Y_.intensity:p=Zh;break;default:if(h.path.indexOf("constraint")>-1){p=Zh,f="constraints["+h.path.match(/".*"/g)[0]+"]."+h.path.match(/[^\\.]*$/g)[0]}else{let e;p=tp,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?X_[d.interpolation]:_t,v=[];if(Y_[h.path]===Y_.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=ix(A.constructor),t=new Float32Array(A.length);for(let n=0,i=A.length;n<i;n++)t[n]=A[n]*e;A=t}for(let e=0,t=v.length;e<t;e++){const t=new p(v[e]+"."+(""!==f?f:Y_[h.path]),c.array,A,g);"CUBICSPLINE"===d.interpolation&&(t.createInterpolant=function(e){return new(this instanceof $h?U_:O_)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e,u={clip:new np(c,void 0,l),nodeId:i[0].id,auto:!0,loop:gt,repetitions:1/0,startAt:0},d=In(t.extensions)?t.extensions[r_.S8S_V3D_ANIMATION]:void 0;if(d){u.auto=d.auto;const e=d.repeatInfinite?1/0:d.repeatCount;switch(d.loop){case"ONCE":u.loop=mt;break;case"REPEAT":u.loop=gt,u.repetitions=e;break;case"PING_PONG":u.loop=vt,u.repetitions=e}u.startAt=d.offset}return u}))}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return void 0===i.mesh?null:n.getDependency("mesh",i.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=i.weights.length;t<n;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,i=this,o=t.nodes[e],r=o.name?i.createUniqueName(o.name):"";return function(){const t=[],n=i._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==o.camera&&t.push(i.getDependency("camera",o.camera).then((function(e){return i._getNodeRef(i.cameraCache,o.camera,e)}))),i._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let a;if(a=!0===o.isBone?new vc:t.length>1?new vl:1===t.length?t[0]:new uo,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(o.name&&(a.userData.name=o.name,a.name=r),$_(a,o),o.extensions&&J_(n,a,o),void 0!==o.matrix){const e=new zi;e.fromArray(o.matrix),a.applyMatrix4(e)}else void 0!==o.translation&&a.position.fromArray(o.translation),void 0!==o.rotation&&a.quaternion.fromArray(o.rotation),void 0!==o.scale&&a.scale.fromArray(o.scale);return i.associations.has(a)||i.associations.set(a,{}),i.associations.get(a).nodes=e,a})).then((function(e){return e.resolveMultiMaterial().forEach((t=>{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 zr;i.name&&(r.name=o.createUniqueName(i.name)),$_(r,i),i.extensions&&J_(n,r,i);const a=i.nodes||[],s=[];for(let e=0,n=a.length;e<n;e++)s.push(rx(a[e],r,t,o));return Promise.all(s).then((function(){return o.associations=(e=>{const t=new Map;for(const[e,n]of o.associations)(e instanceof Mo||e instanceof ni)&&t.set(e,n);return e.traverse((e=>{const n=o.associations.get(e);null!=n&&t.set(e,n)})),t})(r),r}))}}function rx(e,t,n,i){const o=n.nodes[e];return i.getDependency("node",e).then((function(e){return void 0===o.skin?e:i.getDependency("skin",o.skin).then((function(t){return e.traverse((function(e){e.isSkinnedMesh&&e.bind(t,e.matrixWorld)})),e}))})).then((function(e){t.add(e),(e.isDirectionalLight||e.isSpotLight)&&e.isFreeLight&&t.add(e.target);const r=[];if(o.children){const t=o.children;for(let o=0,a=t.length;o<a;o++){const a=t[o];r.push(rx(a,e,n,i))}}return Promise.all(r)}))}function ax(e,t,n){const i=t.attributes,o=[];function r(t,i){return n.getDependency("accessor",t).then((function(t){e.setAttribute(i,t)}))}for(const t in i){const n=j_[t]||dx(t)||t.toLowerCase();n in e.attributes||o.push(r(i[t],n))}if(void 0!==t.indices&&!e.index){const i=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));o.push(i)}return $_(e,t),function(e,t,n){const i=t.attributes,o=new hi;if(void 0===i.POSITION)return;{const e=n.json.accessors[i.POSITION],t=e.min,r=e.max;if(void 0===t||void 0===r)return void console.warn("v3d.GLTFLoader: Missing min/max properties for accessor POSITION.");if(o.set(new ci(t[0],t[1],t[2]),new ci(r[0],r[1],r[2])),e.normalized){const t=ix(V_[e.componentType]);o.min.multiplyScalar(t),o.max.multiplyScalar(t)}}const r=t.targets;if(void 0!==r){const e=new ci,t=new ci;for(let i=0,o=r.length;i<o;i++){const o=r[i];if(void 0!==o.POSITION){const i=n.json.accessors[o.POSITION],r=i.min,a=i.max;if(void 0!==r&&void 0!==a){if(t.setX(Math.max(Math.abs(r[0]),Math.abs(a[0]))),t.setY(Math.max(Math.abs(r[1]),Math.abs(a[1]))),t.setZ(Math.max(Math.abs(r[2]),Math.abs(a[2]))),i.normalized){const e=ix(V_[i.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("v3d.GLTFLoader: Missing min/max properties for accessor POSITION.")}}o.expandByVector(e)}e.boundingBox=o;const a=new Ri;o.getCenter(a.center),a.radius=o.min.distanceTo(o.max)/2,e.boundingSphere=a}(e,t,n),Promise.all(o).then((function(){return void 0!==t.targets?function(e,t,n){let i=!1,o=!1,r=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(i=!0),void 0!==n.NORMAL&&(o=!0),void 0!==n.COLOR_0&&(r=!0),i&&o&&r)break}if(!i&&!o&&!r)return Promise.resolve(e);const a=[],s=[],l=[];for(let c=0,u=t.length;c<u;c++){const u=t[c];if(i){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;a.push(t)}if(o){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;s.push(t)}if(r){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(a),Promise.all(s),Promise.all(l)]).then((function(t){const n=t[0],a=t[1],s=t[2];return i&&(e.morphAttributes.position=n),o&&(e.morphAttributes.normal=a),r&&(e.morphAttributes.color=s),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function sx(e,t){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("v3d.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,o=[];if(t===Tt)for(let e=1;e<=i;e++)o.push(n.getX(0)),o.push(n.getX(e)),o.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(o.push(n.getX(e)),o.push(n.getX(e+1)),o.push(n.getX(e+2))):(o.push(n.getX(e+2)),o.push(n.getX(e+1)),o.push(n.getX(e)));o.length/3!==i&&console.error("v3d.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=e.clone();return r.setIndex(o),r}function lx(e,t,n){const i=n.indexOf(e);i>-1&&n.splice(i,1),Array.isArray(t)?t.forEach((e=>{n.push(e)})):n.push(t)}function cx(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 ux(e){console.warn(`Deprecated '${e}' extension found, please reexport your scene file`)}function dx(e){return e.indexOf("TEXCOORD_")>-1?hx(e):e.indexOf("COLOR_")>-1?px(e):""}function hx(e){return"TEXCOORD_0"==e?"uv":"uv"+String(Number(e.split("TEXCOORD_")[1])+1)}function px(e){return"COLOR_0"==e?"color":"color"+String(Number(e.split("COLOR_")[1])+1)}function fx(e){e.blending=b,e.blendEquation=C,e.blendSrc=I,e.blendDst=B}const mx=new qn;class gx extends qt{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 Ll(null);const o=new xl;o.type=Se,this.renderTargetNormalDepth=new oi(this.width,this.height,{format:Be,depthTexture:o,depthBuffer:!0}),this.renderTargetGTAO=new oi(this.width,this.height),this.renderTargetBlurX=new oi(this.width,this.height),this.renderTarget=new oi(this.width,this.height),this.materialNormal=new Sd({}),this.materialGTAO=new ur({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 zi},resolution:{value:new yn}},vertexShader:wr.pp_plane_vert,fragmentShader:wr.pp_gtao_frag}),this.materialBlur=new ur({type:"GTAOBlur",defines:{},uniforms:{tDiffuse:{value:null},tNormal:{value:null},direction:{value:new yn},resolution:{value:new yn}},customPrepTokens:{BLUR_RADIUS_PX:2},vertexShader:wr.pp_plane_vert,fragmentShader:wr.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 ir&&e.material&&!e.material.gtaoVisible,n=e instanceof ir&&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 ir&&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 ir&&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(mx),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(mx),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 Ac(n,32,32,Be,xe);return i.name="GTAONoiseTexture",i.wrapS=de,i.wrapT=de,i.needsUpdate=!0,i}}class vx{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<this.pool;e++)if(!(this.workerStatus&1<<e))return e;return-1}_onMessage(e,t){const n=this.workersResolve[e];if(n&&n(t),this.queue.length){const{resolve:t,msg:n,transfer:i}=this.queue.shift();this.workersResolve[e]=t,this.workers[e].postMessage(n,i)}else this.workerStatus^=1<<e}setWorkerCreator(e){this.workerCreator=e}setWorkerLimit(e){this.pool=e}postMessage(e,t){return new Promise((n=>{const i=this._getIdleWorker();-1!==i?(this._initWorker(i),this.workerStatus|=1<<i,this.workersResolve[i]=n,this.workers[i].postMessage(e,t)):this.queue.push({resolve:n,msg:e,transfer:t})}))}dispose(){this.workers.forEach((e=>e.terminate())),this.workersResolve.length=0,this.workers.length=0,this.queue.length=0,this.workerStatus=0}}const Ax=new WeakMap;let _x=0;class xx extends sp{constructor(e){super(e),this.transcoderPath="",this.transcoderBinary=null,this.transcoderPending=null,this.workerPool=new vx,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 up(this.manager);e.setPath(this.transcoderPath),e.setWithCredentials(this.withCredentials);const t=e.loadAsync("basis_transcoder.js"),n=new up(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=xx.BasisWorker.toString(),i=["/* constants */","let _EngineFormat = "+JSON.stringify(xx.EngineFormat),"let _TranscoderFormat = "+JSON.stringify(xx.TranscoderFormat),"let _BasisFormat = "+JSON.stringify(xx.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}))})),_x>0&&console.warn("v3d.KTX2Loader: Multiple active KTX2 loaders may cause performance issues. Use a single KTX2Loader instance, or call .dispose() on old instances."),_x++}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 up(this.manager);o.setResponseType("arraybuffer"),o.setWithCredentials(this.withCredentials);const r=new Yc;return o.load(e,(e=>{if(Ax.has(e)){return Ax.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 Yc(t,n,i,o,xe);return c.minFilter=1===t.length?ve:_e,c.magFilter=ve,c.generateMipmaps=!1,c.needsUpdate=!0,c.encoding=2===s?Rt:It,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 Ax.set(e[0],{promise:i}),i}dispose(){return URL.revokeObjectURL(this.workerSourceURL),this.workerPool.dispose(),_x--,this}}xx.BasisFormat={ETC1S:0,UASTC_4x4:1},xx.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},xx.EngineFormat={RGBAFormat:Be,RGBA_ASTC_4x4_Format:et,RGBA_BPTC_Format:ft,RGBA_ETC2_EAC_Format:$e,RGBA_PVRTC_4BPPV1_Format:Ke,RGBA_S3TC_DXT5_Format:je,RGB_ETC1_Format:Ze,RGB_ETC2_Format:Je,RGB_PVRTC_4BPPV1_Format:Ye,RGB_S3TC_DXT1_Format:Qe},xx.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<p.length;i++){const o=p[i];if(e[o.if]&&(o.basisFormat.includes(t)&&!(u&&o.transcoderFormat.length<2)&&(!o.needsPowerOfTwo||c(n)&&c(a))))return d=o.transcoderFormat[u?1:0],h=o.engineFormat[u?1:0],{transcoderFormat:d,engineFormat:h}}return console.warn("v3d.KTX2Loader: No suitable compressed texture format found. Decoding to RGBA32."),d=o.RGBA32,h=i.RGBAFormat,{transcoderFormat:d,engineFormat:h}}(d,h,p,m);if(!h||!p||!f)throw u(),new Error("v3d.KTX2Loader:    Invalid texture");if(!a.startTranscoding())throw u(),new Error("v3d.KTX2Loader: .startTranscoding failed");const x=[];for(let e=0;e<f;e++){const t=a.getImageLevelInfo(e,0,0),n=t.origWidth,i=t.origHeight,o=new Uint8Array(a.getImageTranscodedSizeInBytes(e,0,0,A));if(!a.transcodeImage(o,e,0,0,A,0,-1,-1))throw u(),new Error("v3d.KTX2Loader: .transcodeImage failed.");x.push({data:o,width:n,height:i})}return u(),{width:h,height:p,hasAlpha:m,mipmaps:x,format:_,dfdTransferFn:g,dfdFlags:v}}(u.buffers[0]),g=[];for(let e=0;e<h.length;++e)g.push(h[e].data.buffer);self.postMessage({type:"transcode",id:u.id,width:t,height:a,hasAlpha:d,mipmaps:h,format:p,dfdTransferFn:f,dfdFlags:m},g)}catch(e){console.error(e),self.postMessage({type:"error",id:u.id,error:e.message})}}))}var d}));const a=[{if:"astcSupported",basisFormat:[r.UASTC_4x4],transcoderFormat:[o.ASTC_4x4,o.ASTC_4x4],engineFormat:[i.RGBA_ASTC_4x4_Format,i.RGBA_ASTC_4x4_Format],priorityETC1S:1/0,priorityUASTC:1,needsPowerOfTwo:!1},{if:"bptcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[o.BC7_M5,o.BC7_M5],engineFormat:[i.RGBA_BPTC_Format,i.RGBA_BPTC_Format],priorityETC1S:3,priorityUASTC:2,needsPowerOfTwo:!1},{if:"dxtSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[o.BC1,o.BC3],engineFormat:[i.RGB_S3TC_DXT1_Format,i.RGBA_S3TC_DXT5_Format],priorityETC1S:4,priorityUASTC:5,needsPowerOfTwo:!1},{if:"etc2Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[o.ETC1,o.ETC2],engineFormat:[i.RGB_ETC2_Format,i.RGBA_ETC2_EAC_Format],priorityETC1S:1,priorityUASTC:3,needsPowerOfTwo:!1},{if:"etc1Supported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[o.ETC1],engineFormat:[i.RGB_ETC1_Format],priorityETC1S:2,priorityUASTC:4,needsPowerOfTwo:!1},{if:"pvrtcSupported",basisFormat:[r.ETC1S,r.UASTC_4x4],transcoderFormat:[o.PVRTC1_4_RGB,o.PVRTC1_4_RGBA],engineFormat:[i.RGB_PVRTC_4BPPV1_Format,i.RGBA_PVRTC_4BPPV1_Format],priorityETC1S:5,priorityUASTC:6,needsPowerOfTwo:!0}],s=a.sort((function(e,t){return e.priorityETC1S-t.priorityETC1S})),l=a.sort((function(e,t){return e.priorityUASTC-t.priorityUASTC}));function c(e){return e<=2||0==(e&e-1)&&0!==e}};class yx{static fromCubeTexture(e){let t=0;const n=new ci,i=new ci,o=new qn,r=[0,0,0,0,0,0,0,0,0],a=new Rp,s=a.coefficients;for(let a=0;a<6;a++){const l=e.image[a],c=l.width,u=l.height,d=document.createElement("canvas");d.width=c,d.height=u;const h=d.getContext("2d");h.drawImage(l,0,0,c,u);const p=h.getImageData(0,0,c,u),f=p.data,m=p.width,g=2/m;for(let l=0,c=f.length;l<c;l+=4){o.setRGB(f[l]/255,f[l+1]/255,f[l+2]/255),bx(o,e.encoding);const c=l/4,u=(c%m+.5)*g-1,d=1-(Math.floor(c/m)+.5)*g;switch(a){case 0:n.set(-1,d,-u);break;case 1:n.set(1,d,u);break;case 2:n.set(-u,1,-d);break;case 3:n.set(-u,-1,d);break;case 4:n.set(-u,d,1);break;case 5:n.set(u,d,-1)}const h=n.lengthSq(),p=4/(Math.sqrt(h)*h);t+=p,i.copy(n).normalize(),Rp.getBasisAt(i,r);for(let e=0;e<9;e++)s[e].x+=r[e]*o.r*p,s[e].y+=r[e]*o.g*p,s[e].z+=r[e]*o.b*p}}const l=4*Math.PI/t;for(let e=0;e<9;e++)s[e].x*=l,s[e].y*=l,s[e].z*=l;return new Lp(a)}static fromCubeRenderTarget(e,t){let n=0;const i=new ci,o=new ci,r=new qn,a=[0,0,0,0,0,0,0,0,0],s=new Rp,l=s.coefficients,c=t.texture.type;for(let s=0;s<6;s++){const u=t.width,d=new(c===we?Uint16Array:c===Ee?Float32Array:Uint8Array)(u*u*4);e.readRenderTargetPixels(t,0,0,u,u,d,s);const h=2/u;for(let e=0,p=d.length;e<p;e+=4){c===we?r.setRGB(Hf(d[e]),Hf(d[e+1]),Hf(d[e+2])):c===Ee?r.setRGB(d[e],d[e+1],d[e+2]):r.setRGB(d[e]/255,d[e+1]/255,d[e+2]/255),bx(r,t.texture.encoding);const p=e/4,f=(p%u+.5)*h-1,m=1-(Math.floor(p/u)+.5)*h;switch(s){case 0:i.set(1,m,-f);break;case 1:i.set(-1,m,f);break;case 2:i.set(f,1,-m);break;case 3:i.set(f,-1,m);break;case 4:i.set(f,m,1);break;case 5:i.set(-f,m,-1)}const g=i.lengthSq(),v=4/(Math.sqrt(g)*g);n+=v,o.copy(i).normalize(),Rp.getBasisAt(o,a);for(let e=0;e<9;e++)l[e].x+=a[e]*r.r*v,l[e].y+=a[e]*r.g*v,l[e].z+=a[e]*r.b*v}}const u=4*Math.PI/n;for(let e=0;e<9;e++)l[e].x*=u,l[e].y*=u,l[e].z*=u;return new Lp(s)}}function bx(e,t){switch(t){case Rt:e.convertSRGBToLinear();break;case It:break;default:console.warn("WARNING: LightProbeGenerator convertColorToLinear() encountered an unsupported encoding.")}return e}function Cx(e,t,n,i,o){this._domElement=e,this._keyCode=t,this._callback=n,this._repeats=i,this._period=o,this._timer=0,this._counter=0,this._keydownCb=function(e){e.keyCode==this._keyCode&&(this._timer||(this._timer=window.setTimeout(function(){this._counter=0,this._timer=null}.bind(this),1e3*o)),++this._counter>=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 Mx(e){let t,n,i,o=0;for(let r=0;r<e.length;++r){const a=e[r];if(a.isInterleavedBufferAttribute)return console.error("v3d.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("v3d.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===n&&(n=a.itemSize),n!==a.itemSize)return console.error("v3d.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===i&&(i=a.normalized),i!==a.normalized)return console.error("v3d.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;o+=a.array.length}const r=new t(o);let a=0;for(let t=0;t<e.length;++t)r.set(e[t].array,a),a+=e[t].array.length;return new To(r,n,i)}function Sx(e){return e.isInstancedInterleavedBufferAttribute||e.isInterleavedBufferAttribute?Ex(e):e.isInstancedBufferAttribute?(new InstancedBufferAttribute).copy(e):(new To).copy(e)}function Ex(e){const t=e.data.array.constructor,n=e.count,i=e.itemSize,o=e.normalized,r=new t(n*i);let a;a=e.isInstancedInterleavedBufferAttribute?new InstancedBufferAttribute(r,i,o,e.meshPerAttribute):new To(r,i,o);for(let t=0;t<n;t++)a.setX(t,e.getX(t)),i>=2&&a.setY(t,e.getY(t)),i>=3&&a.setZ(t,e.getZ(t)),i>=4&&a.setW(t,e.getW(t));return a}function wx(e){if(0===e.groups.length)return console.warn("v3d.BufferGeometryUtils.mergeGroups(): No groups are defined. Nothing to merge."),e;let t=e.groups;if(t=t.sort(((e,t)=>e.materialIndex!==t.materialIndex?e.materialIndex-t.materialIndex:e.start-t.start)),null===e.getIndex()){const t=e.getAttribute("position"),n=[];for(let e=0;e<t.count;e+=3)n.push(e,e+1,e+2);e.setIndex(n)}const n=e.getIndex(),i=[];for(let e=0;e<t.length;e++){const o=t[e],r=o.start,a=r+o.count;for(let e=r;e<a;e++)i.push(n.getX(e))}e.dispose(),e.setIndex(i);let o=0;for(let e=0;e<t.length;e++){const n=t[e];n.start=o,o+=n.count}let r=t[0];e.groups=[r];for(let n=1;n<t.length;n++){const i=t[n];r.materialIndex===i.materialIndex?r.count+=i.count:(r=i,e.groups.push(r))}return e}Object.assign(Cx.prototype,{dispose:function(){this._domElement.removeEventListener("keydown",this._keydownCb,!1),this._timer&&window.clearTimeout(this._timer)}});var Tx=Object.freeze({__proto__:null,deepCloneAttribute:Sx,deinterleaveAttribute:Ex,deinterleaveGeometry:function(e){const t=e.attributes,n=e.morphTargets,i=new Map;for(const e in t){const n=t[e];n.isInterleavedBufferAttribute&&(i.has(n)||i.set(n,Ex(n)),t[e]=i.get(n))}for(const e in n){const t=n[e];t.isInterleavedBufferAttribute&&(i.has(t)||i.set(t,Ex(t)),n[e]=i.get(t))}},computeTangents:function(){throw new Error("BufferGeometryUtils: computeTangents renamed to computeMikkTSpaceTangents.")},computeMikkTSpaceTangents:function(e,t,n=!0){if(!t||!t.isReady)throw new Error("BufferGeometryUtils: Initialized MikkTSpace library required.");if(!e.hasAttribute("position")||!e.hasAttribute("normal")||!e.hasAttribute("uv"))throw new Error('BufferGeometryUtils: Tangents require "position", "normal", and "uv" attributes.');function i(e){if(e.normalized||e.isInterleavedBufferAttribute){const t=new Float32Array(e.getCount()*e.itemSize);for(let n=0,i=0;n<e.getCount();n++)t[i++]=e.getX(n),t[i++]=e.getY(n),e.itemSize>2&&(t[i++]=e.getZ(n));return t}return e.array instanceof Float32Array?e.array:new Float32Array(e.array)}const o=e.index?e.toNonIndexed():e,r=t.generateTangents(i(o.attributes.position),i(o.attributes.normal),i(o.attributes.uv));if(n)for(let e=3;e<r.length;e+=4)r[e]*=-1;return o.setAttribute("tangent",new To(r,4)),e!==o&&e.copy(o),e},mergeBufferGeometries:function(e,t=!1){const n=null!==e[0].index,i=new Set(Object.keys(e[0].attributes)),o=new Set(Object.keys(e[0].morphAttributes)),r={},a={},s=e[0].morphTargetsRelative,l=new zo;let c=0;for(let u=0;u<e.length;++u){const d=e[u];let h=0;if(n!==(null!==d.index))return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in d.attributes){if(!i.has(e))return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===r[e]&&(r[e]=[]),r[e].push(d.attributes[e]),h++}if(h!==i.size)return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(s!==d.morphTargetsRelative)return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in d.morphAttributes){if(!o.has(e))return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+".  .morphAttributes must be consistent throughout all geometries."),null;void 0===a[e]&&(a[e]=[]),a[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else{if(void 0===d.attributes.position)return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;e=d.attributes.position.count}l.addGroup(c,e,u),c+=e}}if(n){let t=0;const n=[];for(let i=0;i<e.length;++i){const o=e[i].index;for(let e=0;e<o.count;++e)n.push(o.getX(e)+t);t+=e[i].attributes.position.count}l.setIndex(n)}for(const e in r){const t=Mx(r[e]);if(!t)return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+e+" attribute."),null;l.setAttribute(e,t)}for(const e in a){const t=a[e][0].length;if(0===t)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){const t=[];for(let i=0;i<a[e].length;++i)t.push(a[e][i][n]);const i=Mx(t);if(!i)return console.error("v3d.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+e+" morphAttribute."),null;l.morphAttributes[e].push(i)}}return l},mergeBufferAttributes:Mx,interleaveAttributes:function(e){let t,n=0,i=0;for(let o=0,r=e.length;o<r;++o){const r=e[o];if(void 0===t&&(t=r.array.constructor),t!==r.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;n+=r.array.length,i+=r.itemSize}const o=new Ql(new t(n),i);let r=0;const a=[],s=["getX","getY","getZ","getW"],l=["setX","setY","setZ","setW"];for(let t=0,n=e.length;t<n;t++){const n=e[t],i=n.itemSize,c=n.count,u=new Hl(o,i,r,n.normalized);a.push(u),r+=i;for(let e=0;e<c;e++)for(let t=0;t<i;t++)u[l[t]](e,n[s[t]](e))}return a},estimateBytesUsed:function(e){let t=0;for(const n in e.attributes){const i=e.getAttribute(n);t+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const n=e.getIndex();return t+=n?n.count*n.itemSize*n.array.BYTES_PER_ELEMENT:0,t},mergeVertices:function(e,t=1e-4){t=Math.max(t,Number.EPSILON);const n={},i=e.getIndex(),o=e.getAttribute("position"),r=i?i.count:o.count;let a=0;const s=Object.keys(e.attributes),l={},c={},u=[],d=["getX","getY","getZ","getW"],h=["setX","setY","setZ","setW"];for(let t=0,n=s.length;t<n;t++){const n=s[t],i=e.attributes[n];l[n]=new To(new i.array.constructor(i.count*i.itemSize),i.itemSize,i.normalized);const o=e.morphAttributes[n];o&&(c[n]=new To(new o.array.constructor(o.count*o.itemSize),o.itemSize,o.normalized))}const p=Math.log10(1/t),f=Math.pow(10,p);for(let t=0;t<r;t++){const o=i?i.getX(t):t;let r="";for(let t=0,n=s.length;t<n;t++){const n=s[t],i=e.getAttribute(n),a=i.itemSize;for(let e=0;e<a;e++)r+=~~(i[d[e]](o)*f)+","}if(r in n)u.push(n[r]);else{for(let t=0,n=s.length;t<n;t++){const n=s[t],i=e.getAttribute(n),r=e.morphAttributes[n],u=i.itemSize,p=l[n],f=c[n];for(let e=0;e<u;e++){const t=d[e],n=h[e];if(p[n](a,i[t](o)),r)for(let e=0,i=r.length;e<i;e++)f[e][n](a,r[e][t](o))}}n[r]=a,u.push(a),a++}}const m=e.clone();for(const t in e.attributes){const e=l[t];if(m.setAttribute(t,new To(e.array.slice(0,a*e.itemSize),e.itemSize,e.normalized)),t in c)for(let e=0;e<c[t].length;e++){const n=c[t][e];m.morphAttributes[t][e]=new To(n.array.slice(0,a*n.itemSize),n.itemSize,n.normalized)}}return m.setIndex(u),m},toTrianglesDrawMode:function(e,t){if(t===Et)return console.warn("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(t===Tt||t===wt){let n=e.getIndex();if(null===n){const t=[],i=e.getAttribute("position");if(void 0===i)return console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<i.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const i=n.count-2,o=[];if(t===Tt)for(let e=1;e<=i;e++)o.push(n.getX(0)),o.push(n.getX(e)),o.push(n.getX(e+1));else for(let e=0;e<i;e++)e%2==0?(o.push(n.getX(e)),o.push(n.getX(e+1)),o.push(n.getX(e+2))):(o.push(n.getX(e+2)),o.push(n.getX(e+1)),o.push(n.getX(e)));o.length/3!==i&&console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const r=e.clone();return r.setIndex(o),r.clearGroups(),r}return console.error("v3d.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",t),e},computeMorphedAttributes:function(e){if(!0!==e.geometry.isBufferGeometry)return console.error("v3d.BufferGeometryUtils: Geometry is not of type BufferGeometry."),null;const t=new ci,n=new ci,i=new ci,o=new ci,r=new ci,a=new ci,s=new ci,l=new ci,c=new ci;function u(e,u,d,h,p,f,m,g){t.fromBufferAttribute(u,p),n.fromBufferAttribute(u,f),i.fromBufferAttribute(u,m);const v=e.morphTargetInfluences;if(d&&v){s.set(0,0,0),l.set(0,0,0),c.set(0,0,0);for(let e=0,u=d.length;e<u;e++){const u=v[e],g=d[e];0!==u&&(o.fromBufferAttribute(g,p),r.fromBufferAttribute(g,f),a.fromBufferAttribute(g,m),h?(s.addScaledVector(o,u),l.addScaledVector(r,u),c.addScaledVector(a,u)):(s.addScaledVector(o.sub(t),u),l.addScaledVector(r.sub(n),u),c.addScaledVector(a.sub(i),u)))}t.add(s),n.add(l),i.add(c)}e.isSkinnedMesh&&(e.boneTransform(p,t),e.boneTransform(f,n),e.boneTransform(m,i)),g[3*p+0]=t.x,g[3*p+1]=t.y,g[3*p+2]=t.z,g[3*f+0]=n.x,g[3*f+1]=n.y,g[3*f+2]=n.z,g[3*m+0]=i.x,g[3*m+1]=i.y,g[3*m+2]=i.z}const d=e.geometry,h=e.material;let p,f,m;const g=d.index,v=d.attributes.position,A=d.morphAttributes.position,_=d.morphTargetsRelative,x=d.attributes.normal,y=d.morphAttributes.position,b=d.groups,C=d.drawRange;let M,S,E,w,T,I,R;const L=new Float32Array(v.count*v.itemSize),P=new Float32Array(x.count*x.itemSize);if(null!==g)if(Array.isArray(h))for(M=0,E=b.length;M<E;M++)for(T=b[M],I=Math.max(T.start,C.start),R=Math.min(T.start+T.count,C.start+C.count),S=I,w=R;S<w;S+=3)p=g.getX(S),f=g.getX(S+1),m=g.getX(S+2),u(e,v,A,_,p,f,m,L),u(e,x,y,_,p,f,m,P);else for(I=Math.max(0,C.start),R=Math.min(g.count,C.start+C.count),M=I,E=R;M<E;M+=3)p=g.getX(M),f=g.getX(M+1),m=g.getX(M+2),u(e,v,A,_,p,f,m,L),u(e,x,y,_,p,f,m,P);else if(Array.isArray(h))for(M=0,E=b.length;M<E;M++)for(T=b[M],I=Math.max(T.start,C.start),R=Math.min(T.start+T.count,C.start+C.count),S=I,w=R;S<w;S+=3)p=S,f=S+1,m=S+2,u(e,v,A,_,p,f,m,L),u(e,x,y,_,p,f,m,P);else for(I=Math.max(0,C.start),R=Math.min(v.count,C.start+C.count),M=I,E=R;M<E;M+=3)p=M,f=M+1,m=M+2,u(e,v,A,_,p,f,m,L),u(e,x,y,_,p,f,m,P);return{positionAttribute:v,normalAttribute:x,morphedPositionAttribute:new Lo(L,3),morphedNormalAttribute:new Lo(P,3)}},mergeGroups:wx,toCreasedNormals:function(e,t=Math.PI/3){const n=Math.cos(t),i=100*(1+1e-10),o=[new ci,new ci,new ci],r=new ci,a=new ci,s=new ci,l=new ci;function c(e){return`${~~(e.x*i)},${~~(e.y*i)},${~~(e.z*i)}`}const u=e.toNonIndexed(),d=u.attributes.position,h={};for(let e=0,t=d.count/3;e<t;e++){const t=3*e,n=o[0].fromBufferAttribute(d,t+0),i=o[1].fromBufferAttribute(d,t+1),s=o[2].fromBufferAttribute(d,t+2);r.subVectors(s,i),a.subVectors(n,i);const l=(new ci).crossVectors(r,a).normalize();for(let e=0;e<3;e++){const t=c(o[e]);t in h||(h[t]=[]),h[t].push(l)}}const p=new Float32Array(3*d.count),f=new To(p,3,!1);for(let e=0,t=d.count/3;e<t;e++){const t=3*e,i=o[0].fromBufferAttribute(d,t+0),u=o[1].fromBufferAttribute(d,t+1),p=o[2].fromBufferAttribute(d,t+2);r.subVectors(p,u),a.subVectors(i,u),s.crossVectors(r,a).normalize();for(let e=0;e<3;e++){const i=h[c(o[e])];l.set(0,0,0);for(let e=0,t=i.length;e<t;e++){const t=i[e];s.dot(t)>n&&l.add(t)}l.normalize(),f.setXYZ(t+e,l.x,l.y,l.z)}}return u.setAttribute("normal",f),u},batchMeshes:function(e,t){const n={};for(let t=0;t<e.length;t++){const i=e[t],o=i.geometry,r=i.material;let a=[];a.push(r.name),a.push(i.visible),a.push(i.disableChildRendering),a.push(i.castShadow),a.push(i.receiveShadow),a.push(i.renderOrder),a=a.concat(i.groupNames);const s=Object.keys(o.attributes);a=a.concat(s);const l=Object.keys(o.morphAttributes);a=a.concat(l),a=a.join(),n[a]=n[a]||[],-1==n[a].indexOf(i)&&n[a].push(i)}for(let e in n){const i=n[e];if(i.length<2)continue;const o=[];let r=!0;for(let e=0;e<i.length;e++){const t=i[e],n=t.geometry;t.updateMatrixWorld(),o.push(n.clone().applyMatrix4(t.matrixWorld)),n.boundsTree||(r=!1)}const a=i[0],s=a.material,l=`${s.name}_x${i.length}_batch`,c=this.mergeBufferGeometries(o);if(c){const e=new ir(c,s);e.name=l,e.visible=a.visible,e.disableChildRendering=a.disableChildRendering,e.castShadow=a.castShadow,e.receiveShadow=a.receiveShadow,e.renderOrder=a.renderOrder,e.groupNames=a.groupNames;for(let e=0;e<i.length;e++){const t=i[e];t.parent.remove(t)}r&&c.computeBoundsTree({verbose:!1}),console.log("Adding batch object:",l),t.add(e)}else console.warn("Failed to create batch object:",l)}}});const Ix=new qn,Rx=new zi;function Lx(e,t){return Boolean(t._propertyBindings.find((function(t){const n=t.binding.node;return n&&n.findRoot()===e})))}function Px(e){const t=new hi;return t.expandByObject(e),t}function Bx(e,t){const n=new ci,i=2*e.getSize(n).length(),o=new hr(45,t,i/1e4,i);return o.position.copy(e.max).multiplyScalar(2),o.lookAt(e.getCenter(n)),o}function Dx(e,t){const n=new uo;t.getCenter(n.position),e.controls=new Dg,e.controls.orbitMinDistance=e.near,e.controls.orbitMaxDistance=e.far,e.controls.orbitTarget=n}var Nx=Object.freeze({__proto__:null,createMeshesFromInstancedMesh:function(e){const t=new vl,n=e.count,i=e.geometry,o=e.material;for(let r=0;r<n;r++){const n=new ir(i,o);e.getMatrixAt(r,n.matrix),n.matrix.decompose(n.position,n.quaternion,n.scale),t.add(n)}return t.copy(e),t.updateMatrixWorld(),t},createMeshesFromMultiMaterialMesh:function(e){if(!1===Array.isArray(e.material))return console.warn("v3d.SceneUtils.createMeshesFromMultiMaterialMesh(): The given mesh has no multiple materials."),e;const t=new vl;t.copy(e);const n=wx(e.geometry),i=n.index,o=n.groups,r=Object.keys(n.attributes);for(let a=0;a<o.length;a++){const s=o[a],l=s.start,c=l+s.count,u=new zo,d=e.material[s.materialIndex];for(let e=0;e<r.length;e++){const t=r[e],o=n.attributes[t],a=o.itemSize,d=s.count*a,h=new(0,o.array.constructor)(d),p=new To(h,a);for(let e=l,t=0;e<c;e++,t++){const n=i.getX(e);a>=1&&p.setX(t,o.getX(n)),a>=2&&p.setY(t,o.getY(n)),a>=3&&p.setZ(t,o.getZ(n)),a>=4&&p.setW(t,o.getW(n))}u.setAttribute(t,p)}const h=new ir(u,d);t.add(h)}return t},createMultiMaterialObject:function(e,t){const n=new vl;for(let i=0,o=t.length;i<o;i++)n.add(new ir(e,t[i]));return n},reduceVertices:function(e,t,n){let i=n;const o=new ci;return e.updateWorldMatrix(!0,!0),e.traverseVisible((e=>{const{geometry:n}=e;if(void 0!==n){const{position:r}=n.attributes;if(void 0!==r)for(let n=0,a=r.count;n<a;n++)e.isMesh?e.getVertexPosition(n,o):o.fromBufferAttribute(r,n),e.isSkinnedMesh||o.applyMatrix4(e.matrixWorld),i=t(i,o)}})),i},sortInstancedMesh:function(e,t){const n=Sx(e.instanceMatrix),i=e.instanceColor?Sx(e.instanceColor):null,o=new Map;for(const t in e.geometry.attributes){const n=e.geometry.attributes[t];n.isInstancedBufferAttribute&&o.set(n,Sx(n))}const r=[];for(let t=0;t<e.count;t++)r.push(t);r.sort(t);for(let t=0;t<r.length;t++){const a=r[t];Rx.fromArray(n.array,a*e.instanceMatrix.itemSize),Rx.toArray(e.instanceMatrix.array,t*e.instanceMatrix.itemSize),e.instanceColor&&(Ix.fromArray(i.array,a*e.instanceColor.itemSize),Ix.toArray(e.instanceColor.array,t*e.instanceColor.itemSize));for(const n in e.geometry.attributes){const i=e.geometry.attributes[n];if(i.isInstancedBufferAttribute){const e=o.get(i);i.setX(t,e.getX(a)),i.itemSize>1&&i.setY(t,e.getY(a)),i.itemSize>2&&i.setZ(t,e.getZ(a)),i.itemSize>3&&i.setW(t,e.getW(a))}}}},getMaterialByName:function(e,t){const n=this.getMaterialsByName(e,t);return n.length?n[0]:null},getMaterialsByName:function(e,t){const n=[];if(null!==e.scene){e.scene.traverse((function(e){e.material&&e.material.name===t&&-1===n.indexOf(e.material)&&n.push(e.material)}));const i=e.scene.worldMaterial;null!==i&&i.name===t&&-1===n.indexOf(i)&&n.push(i)}return n},getAnimationActionByName:function(e,t){for(let n=0;n<e.actions.length;n++){const i=e.actions[n];if(i.getClip().name==t)return i}return null},checkActionIsUsed:Lx,createEnvironmentMaterial:function(e,t,n){const i=new Pd.DiGraph(6),o={};if(i.node(0).originData={name:"Light Path",type:"LIGHT_PATH_BL",inputs:[],outputs:[0,0,0,0,0,0,0,0,0,0,0,0,0],is_active_output:!1},i.node(1).originData={name:"Lighting Texture",type:"TEX_ENVIRONMENT_BL",projection:"EQUIRECTANGULAR",inputs:[[0,0,0]],outputs:[[0,0,0,0]],texture:0,is_active_output:!1},o[Bh.nodeTexUniName("TEX_ENVIRONMENT_BL",0)]=t,n instanceof qn){const e=[0,0,0,0];e[0]=n.r,e[1]=n.g,e[2]=n.b,e[3]=1,i.node(2).originData={name:"Background Color",type:"RGB_BL",inputs:[],outputs:[e],is_active_output:!1}}else i.node(2).originData={name:"Background Texture",type:"TEX_ENVIRONMENT_BL",projection:"EQUIRECTANGULAR",inputs:[[0,0,0]],outputs:[[0,0,0,0]],texture:1,is_active_output:!1},o[Bh.nodeTexUniName("TEX_ENVIRONMENT_BL",1)]=n;return i.node(3).originData={name:"Mix",type:"MIX_RGB_BL",blendType:"MIX",inputs:[0,[0,0,0,0],[0,0,0,0]],outputs:[[0,0,0,0]],is_active_output:!1},i.node(4).originData={name:"Background",type:"BACKGROUND_BL",inputs:[[0,0,0,0],1],outputs:[[0,0,0,0]],is_active_output:!1},i.node(5).originData={name:"Output",type:"OUTPUT_WORLD_BL",inputs:[[0,0,0,0],[0,0,0,0]],outputs:[],is_active_output:!0},Uh(i,0,0,3,0),Uh(i,1,0,3,1),Uh(i,2,0,3,2),Uh(i,3,0,4,0),Uh(i,4,0,5,0),new Bh({name:e,nodeGraph:i,nodeTextures:o})},calcSceneBox:Px,createDefaultCamera:Bx,assignDefaultControls:Dx}),Ox=function(){var e=0,t=document.createElement("div");function n(e){return t.appendChild(e.dom),e}function i(n){for(var i=0;i<t.children.length;i++)t.children[i].style.display=i===n?"block":"none";e=n}t.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",t.addEventListener("click",(function(n){n.preventDefault(),i(++e%t.children.length)}),!1);var o=(performance||Date).now(),r=o,a=0,s=n(new Ox.Panel("FPS","#0ff","#002")),l=n(new Ox.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var c=n(new Ox.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:t,addPanel:n,showPanel:i,begin:function(){o=(performance||Date).now()},end:function(){a++;var e=(performance||Date).now();if(l.update(e-o,200),e>=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}};Ox.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))}}};const Fx="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiCiAgIGlkPSJzdmcyNzc1IgogICB2ZXJzaW9uPSIxLjEiCiAgIHZpZXdCb3g9IjAgMCAyOS4xMDQxNjYgMzEuNzUwMDAxIgogICBoZWlnaHQ9IjEyMCIKICAgd2lkdGg9IjExMCI+CiAgPGRlZnMKICAgICBpZD0iZGVmczI3NjkiPgogICAgPGxpbmVhckdyYWRpZW50CiAgICAgICBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIKICAgICAgIHkyPSI1My44MDY2MTgiCiAgICAgICB4Mj0iMTkzLjc4NDciCiAgICAgICB5MT0iNzguNjg5NDA3IgogICAgICAgeDE9IjE3Mi45MTMzNiIKICAgICAgIGlkPSJsaW5lYXJHcmFkaWVudDMwNzktOCIKICAgICAgIHhsaW5rOmhyZWY9IiNsaW5lYXJHcmFkaWVudDMwNzciCiAgICAgICBncmFkaWVudFRyYW5zZm9ybT0ibWF0cml4KDEuMTY0NzU5NCwwLDAsMS4xNTgzOTgyLC0xOTcuMTUzMTksMjAzLjUxNjUxKSIgLz4KICAgIDxsaW5lYXJHcmFkaWVudAogICAgICAgaWQ9ImxpbmVhckdyYWRpZW50MzA3NyI+CiAgICAgIDxzdG9wCiAgICAgICAgIGlkPSJzdG9wMzA3MyIKICAgICAgICAgb2Zmc2V0PSIwIgogICAgICAgICBzdHlsZT0ic3RvcC1jb2xvcjojMDA0OGE1O3N0b3Atb3BhY2l0eToxIiAvPgogICAgICA8c3RvcAogICAgICAgICBpZD0ic3RvcDMwNzUiCiAgICAgICAgIG9mZnNldD0iMSIKICAgICAgICAgc3R5bGU9InN0b3AtY29sb3I6IzRiODZkMTtzdG9wLW9wYWNpdHk6MSIgLz4KICAgIDwvbGluZWFyR3JhZGllbnQ+CiAgPC9kZWZzPgogIDxtZXRhZGF0YQogICAgIGlkPSJtZXRhZGF0YTI3NzIiPgogICAgPHJkZjpSREY+CiAgICAgIDxjYzpXb3JrCiAgICAgICAgIHJkZjphYm91dD0iIj4KICAgICAgICA8ZGM6Zm9ybWF0PmltYWdlL3N2Zyt4bWw8L2RjOmZvcm1hdD4KICAgICAgICA8ZGM6dHlwZQogICAgICAgICAgIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiIC8+CiAgICAgICAgPGRjOnRpdGxlPjwvZGM6dGl0bGU+CiAgICAgIDwvY2M6V29yaz4KICAgIDwvcmRmOlJERj4KICA8L21ldGFkYXRhPgogIDxnCiAgICAgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwtMjY1LjI0OTk2KSIKICAgICBpZD0ibGF5ZXIxIj4KICAgIDxwYXRoCiAgICAgICBzdHlsZT0iZGlzcGxheTppbmxpbmU7ZmlsbDp1cmwoI2xpbmVhckdyYWRpZW50MzA3OS04KTtmaWxsLW9wYWNpdHk6MTtzdHJva2U6bm9uZTtzdHJva2Utd2lkdGg6MC45MjA0NTI2NTtzdHJva2UtbWl0ZXJsaW1pdDo0O3N0cm9rZS1kYXNoYXJyYXk6bm9uZTtzdHJva2Utb3BhY2l0eToxIgogICAgICAgZD0ibSAxNC42MjI3OTMsMjY1LjI1MDA0IGMgLTEuNjgyMTUsLTAuMDA3IC0zLjM2OTMsMS4xMDUxMSAtNy4yODAyNDk3LDMuMzI3ODYgLTcuODIxOTEwMDcsNC40NDU1IC03LjI4MTA3MDA3LDMuNTIzMzggLTcuMzIwOTcwMDcsMTIuNDgzMDkgLTAuMDM5OSw4Ljk1OTcxIC0wLjU3MjQ3LDguMDMyODUgNy4yMDk1NTAwNywxMi41NDcwNyA3Ljc4MTk4OTcsNC41MTQyNCA2LjcwODYwOTcsNC41MDk1IDE0LjUzMDQ5OTcsMC4wNjM5IDcuODIxOTEsLTQuNDQ1NDkgNy4yODEwNjIsLTMuNTIzMzcgNy4zMjA5NzEsLTEyLjQ4MzA5IDAuMDM5OSwtOC45NTk3MSAwLjU3MjQ1OCwtOC4wMzI4NSAtNy4yMDk1NTEsLTEyLjU0NzA3IC0zLjg5MSwtMi4yNTcxMiAtNS41NjgxMiwtMy4zODQ0NSAtNy4yNTAyNSwtMy4zOTE4NiB6IG0gLTAuMDEzMywyLjg1MTY3IGMgMS42OTU5NCwwLjAwNyAzLjM4ODMzLDAuODEyODEgNi4xNjAxNiwyLjQyMDY5IDUuNTQzNjIsMy4yMTU3OCA2LjE1MTkzMSw0LjI3NDM4IDYuMTIzNDkxLDEwLjY1Njk2IC0wLjAyODQsNi4zODI2IC0wLjY0NjEwMSw3LjQzNTc2IC02LjIxODE1MSwxMC42MDI1OCAtNS41NzIwMywzLjE2NjgxIC02Ljc5OCwzLjE2MTM5IC0xMi4zNDE2Mzk3LC0wLjA1NDMgLTUuNTQzNjEsLTMuMjE1NzcgLTYuMTUxODksLTQuMjc0MzcgLTYuMTIzNDksLTEwLjY1Njk2IDAuMDI4NiwtNi4zODI1OCAwLjY0NjEsLTcuNDM1NzUgNi4yMTgxNiwtMTAuNjAyNTggMi43ODYwMjk3LC0xLjU4MzQgNC40ODU1Mzk3LC0yLjM3Mzc3IDYuMTgxNDY5NywtMi4zNjYzIHogbSAtMC4xNTUzNywxLjYxNzY5IGMgLTIuNzEzOTEsMC4wMzQxIC01LjcyNDk5OTcsMy4wNzAwOCAtNy4yODkzNTk3LDYuMDc1NDkgLTEuNTg5MjEsMy4wNTMxMSAtMi40OTg1Miw1Ljk0NDU2IC0yLjEyNDA1LDkuNjU3NTEgMC4xNjMwNywxLjYxNjU0IDEuNzEwODIsMy42Nzk4NCAzLjU2Mzc2LDQuNzE0MjYgLTAuMzkzODIsLTMuMjA2MiAtMC4xNzIsLTYuMzQzMDUgMC41NDM5NjEsLTguOTQ2OTIgMC43MTU5NTksLTIuNjAzODcgMi44NTI5Nzg3LC02LjgyODgxIDUuMzc2MjQ4NywtNi44MjMxNiAyLjUyMzMxLDAuMDA2IDQuNjYwMjcsNC4yMjcwNCA1LjM3NjIyLDYuODMwODkgMC43MTU5MywyLjYwMzg4IDAuOTM3NzcsNS43NDA3NSAwLjU0Mzk0LDguOTQ2OTQgMS44NTI5NCwtMS4wMzQ0MyAzLjQwMDcxLC0zLjA5Nzc4IDMuNTYzNzcsLTQuNzE0MzEgMC4zNzQ0OCwtMy43MTI5OCAtMC41MzQ3MSwtNi42MDQyNyAtMi4xMjM5MywtOS42NTc0IC0xLjU1ODkzLC0yLjk5NDk4IC00LjU1NDY1LC02LjAxOTg4IC03LjMwMTU1LC02LjA4MjY2IC0wLjA0MzEsLTkuOGUtNCAtMC4wODYsLTkuOGUtNCAtMC4xMjg5NywtNi4xZS00IHogbSAwLjEzMjY3LDguOTE4NDEgYSAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0xLjE5NzM0LDAuMjkxNTIgMi40OTEyNjMxLDIuNDc3NjU3MyAwIDAgMCAtMS4wMjUzNCwzLjM1MjI5IDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMy4zNzA2OSwxLjAxOTcxIDIuNDkxMjYzMSwyLjQ3NzY1NzMgMCAwIDAgMS4wMjUzNCwtMy4zNTIyOCAyLjQ5MTI2MzEsMi40Nzc2NTczIDAgMCAwIC0yLjE3MzM1LC0xLjMxMTI0IHoiCiAgICAgICBpZD0icGF0aDYwNDctMiIgLz4KICA8L2c+Cjwvc3ZnPgo=",Ux="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAIQXpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZhZltw2DEX/uYosQSQ4LofjOdlBlp8LSqquHt12nD+X3JIKYpEg3sMDZDP/+XuZv/iIOGd8SDmWGA8+vvjiKjf5OD91n+3h93l//PWI76/s5vHAYRKucn7N8bJP7I7x7rL3a56KPTxNVOb1oL1+UK+JXL4WuOz3QmLPBY5rYlOvicRdK18utnNbRyw5PW+hX+PX9XyHgT+jJy/JxRBt8py9O1KKhfvsDp+I21BHV3dFfxfaNdGb7+Ye6vDJTbFycM7qoeC+FKmi93rGaSzCvUjY53J6ClrOHIn7csf1689Xnpvb9QvyV5A+7uwn9iekzQ7o/UDeIBQf1w/tNrzYzTOkG7enlWN8rPzKnufRXu35Rk3/1hp5rXnurvrIluO1qXsr+45xTaO1fxU5En/hyBpsPQpHJiU6PBqQrHF0W6wDxmW9HbbaZee+dttx0bvpElfnuhPbDcYMGMX1DbfXwy6XAH5IBvgOHQSre/hi97JlL9dtZuFhs4E9lsksP/lPh/nOoLU0oaw98iNW+OU00/BCkbPWHJZhIGLXFdSwA3wfbz+Kq4Bg2GHObLAeTWcA/hbsC7lkAy0MDFzPBLZpXBMQIjwIOGMFBI5oJdhoj4SwJWsJZAagiutOvGvAYkNwAyedF4mAQxawNr9Jdg91wZ1mhBAggkQjCWxITcDyPsCf5DMcqkGCDyHEkEIOJdQoUTMsxhRVUWuS5FNIMaWUU0nVZMk+hxxzyjmXXIsrguKGQj6WXEqplUUrM1d+XRlQa3NNmm+hxZZabqXV7kyX7nvosaeee+l1uCGDPB5xpJFHGXXaCZWmn2HGmWaeZdYF1ZYsv8KKK628iln1gdoF67vjJ1CzF2puI6UD0wM1rCndU1iVk6CYgZjzFsCTImDFOKeYHdl67xQ5xewoTkXQ4WRQcIZVxEDQT+vCsg/sXpALRuLvwc0AhPsdyBmF7hvIvcftI9RG3YVONkKahhrUQ8i+VdbM1eWqlfLLq/nRgO9e/0z0Z6LfNtEKlJIcBGEJdi4Y3YtQv/vMn9hbb2uO2qngQp1HkExeIqtF6sbqOjSLnimwjeScNfUo89iTZO/b7GHNot9iXc1v+ypRmpg4x9DZbZ/owSyht5CoP3X52YZQTUprFa0ItmIdx22xPvAvogdcVPyXdoNjrZpJ4+lZTtdDaj62hxnWigOhXduzQx+mQvaPZrNbk99ZfVDsDIMlgtBQLro75kMVI3Xb63P8HRXr6s2O0hI7YuI8TZLWlq8z1NZmxkfWRLdoCMcQIVAj5kCbeFkOhcg11PO8o7M6r+Z4Y/iJq4KdFVJt3w261qI9nXagWtvw6cKp96g4ZMIw/NZERidb2NYSDUzpabXiF3EzpaKqdZNqZSuTXqnN0CtBntdNmZYJStprx7kgxZCka/XWsc9qwzRVdkRnFEWjy8mRQDknXhkExoYgj6QNm96PWsKsM8EoejmdKOblTRMIQOt3ucsgJUigEUldCH5vJRCMcd1I1wWdMmKMNfyqcepalKOCefgzY9iGzOJ/Jd3Mhw9aLbrhTCyntQ44IOYBgdocpAPBbbGP1siF1bRxHYNyFKjJcD0EaAQs0EU0zcCEBBDNiuQn3CFPANTv3epZWd+CRs2zU7Og7coEZKcArFQGA8BOU5faUL/I3J0OuVAw2xqHzAHbywZiudFiNEM9XIMa3edcw7USP5WUzT5RLsA6JZ9SD/K07JoZAFUiPmdQak0CPlGYa/MptVDJT20yYguxkIT0DXQKexSrkjpz8QhlimYmdYF13enoS7Lj9CkCxcXzCa7Esl8AQBq6rDabFASNxDfMWcgaRzTRgIFeBRmje5n4GAJmnGIHE2qUtOBqhOpzOhnrHtCJiJnTPoAA9FmVwgzCETw7yqmHPwbBfIbCOxC6jSogCHVjYzWhLEk1KTQonoYhUIEbIQd4p42Wliu5ngJtT8Le6LXS6CdV5xIA+p3l6GY+dKCrHMp8mK0bSBPGK/WJ/d4U1PdiM3WhDiU9dQCRH6o4sxerpKcUyJGASZrjLVvTQ/XiJ0sAAj9ayPYW+8IbpLzW/3KkLUIvEnQKEG6FLW3OF3aksFMFtoZp+I0+giNUtd4xUutm3LTnZxLXmFQ5el3WkFEIPtPMorRGG2sfslIJ8NIaqxnbBKp7ckpOgDThLLn1kBGbnmRkvcgIlH+WkbLIoOC1LCAksc5RuviYqfE0yZeFd/2vomk+DSfceh1PLZ5k35uI3vXUvC+oKlTrUVBJ56eSyhJ5flhTzS8U1Q+v5ptF9aXK7ZuWNaXDJshY1S4xofutu27qtutxVSPSrffPqhGj39Ujan+5K9IXxXq+FPp3UhsAdw3TwQG5G3aWmEBohrt4qthpkCbBz4ntlcQXXreum5R1sbAXHs2QldBo9LOroE+gIaj52mBwabjzC2+lX17NjwbodeuhtFsPof1Q0UMOyTI0EO45g2lqG8k2i809EsB4quEkUrK1cKgW8mZb+UkcIAdcUXKyI9scHR1MY6I3jzUIZ2ODum6EgoaiEIrp9/YJmYP0QbMBnHLaCW2meqzsfm6AyYtX7S+id3W/vKle3e/OPRojdI/oDyOdRFVlrAORRx/igFKtQDte/oV654VGuvIKzMM2eCFuVB4SbD3CppXcXFE7i8guPY8i0l5XcpVqGsNjp1bjzGyCNLRgySyT5TY9R2fu2joo2cRhR6bsdCYa8P8MEJnzEqJpHiH6KEA6wXcCRHzMrwRovzykVEY/b/U/r81981+vfyb6M9H/MBF5RKaafwEjmLcIrlR0mgAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAAuIwAALiMBeKU/dgAAAAd0SU1FB+MCAwojJyJFeN4AAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAd0lEQVR42u3YUQqAIBAFwLUDdf9zdCH7lwwEI2VnPkWQfWCvigAAAAAAgDTK1wecNWq7dpX+uaP7lw7gaZi3oUb3z3BkvwICEIAW+KcFRte3DWBGO7gCAhCAAHZ9FY6IpC3QG963gGeAAASgBRb6IwQAAAAAQCY34QUtIL9dJTwAAAAASUVORK5CYII=";class zx{constructor(e,t,n,i,o,r=0){this.a=e,this.b=t,this.c=n,this.normal=i&&i.isVector3?i:new ci,this.vertexNormals=Array.isArray(i)?i:[],this.color=o&&o.isColor?o:new qn,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;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}}var Vx,Gx=new ci,kx=new ci,Qx=new ci,Wx=new yn,Hx=new yn,jx=new yn,Yx=new ci,Xx=new ci;function Kx(e,t,n,i,o,r,a,s){Gx.fromBufferAttribute(i,r),kx.fromBufferAttribute(i,a),Qx.fromBufferAttribute(i,s);var l=function(e,t,n,i,o,r,a,s){if(null===(t.side===f?i.intersectTriangle(a,r,o,!0,s):i.intersectTriangle(o,r,a,t.side!==m,s)))return null;Xx.copy(s),Xx.applyMatrix4(e.matrixWorld);var l=n.ray.origin.distanceTo(Xx);return l<n.near||l>n.far?null:{distance:l,point:Xx.clone(),object:e}}(e,e.material,t,n,Gx,kx,Qx,Yx);if(l){o&&(Wx.fromBufferAttribute(o,r),Hx.fromBufferAttribute(o,a),jx.fromBufferAttribute(o,s),l.uv=bo.getUV(Yx,Gx,kx,Qx,Wx,Hx,jx,new yn));var c=new ci;l.face=new zx(r,a,s,bo.getNormal(Gx,kx,Qx,c)),l.faceIndex=r}return l}function qx(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=Kx(e,n,i,t.attributes.position,t.attributes.uv,s,l,c);return u?(u.faceIndex=o,r&&r.push(u),u):null}function Zx(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 Jx(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 $x{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;o<r;o++){var a=e[o][t];n=Math.min(a,n),i=Math.max(a,i)}this.min=n,this.max=i}setFromPoints(e,t){for(var n=1/0,i=-1/0,o=0,r=t.length;o<r;o++){var a=t[o],s=e.dot(a);n=Math.min(s,n),i=Math.max(s,i)}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}$x.prototype.setFromBox=(Vx=new ci,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++){Vx.x=n.x*a+i.x*(1-a),Vx.y=n.y*s+i.y*(1-s),Vx.z=n.z*l+i.z*(1-l);var c=e.dot(Vx);o=Math.min(c,o),r=Math.max(c,r)}this.min=o,this.max=r});var ey,ty,ny,iy,oy,ry,ay,sy,ly,cy,uy,dy,hy,py,fy,my,gy,vy,Ay,_y,xy,yy,by,Cy,My=(ey=new ci,ty=new ci,ny=new ci,function(e,t,n){var i=e.start,o=ey,r=t.start,a=ty;ny.subVectors(i,r),ey.subVectors(e.end,t.start),ty.subVectors(t.end,t.start);var s,l,c=ny.dot(a),u=a.dot(o),d=a.dot(a),h=ny.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}),Sy=(iy=new yn,oy=new ci,ry=new ci,function(e,t,n,i){My(e,t,iy);var o,r,a=iy.x,s=iy.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=oy,c=ry;return e.closestPointToPoint(r,!0,oy),t.closestPointToPoint(o,!0,ry),l.distanceToSquared(r)<=c.distanceToSquared(o)?(n.copy(l),void i.copy(r)):(n.copy(o),void i.copy(c))}),Ey=(ay=new ci,sy=new ci,ly=new xr,cy=new bf,function(e,t){var n=e.radius,i=e.center,o=t.a,r=t.b,a=t.c;if(cy.start=o,cy.end=r,cy.closestPointToPoint(i,!0,ay).distanceTo(i)<=n)return!0;if(cy.start=o,cy.end=a,cy.closestPointToPoint(i,!0,ay).distanceTo(i)<=n)return!0;if(cy.start=r,cy.end=a,cy.closestPointToPoint(i,!0,ay).distanceTo(i)<=n)return!0;var s=t.getPlane(ly);if(Math.abs(s.distanceToPoint(i))<=n){var l=s.projectPoint(i,sy);if(t.containsPoint(l))return!0}return!1});class wy extends bo{constructor(...e){super(...e),this.isSeparatingAxisTriangle=!0,this.satAxes=new Array(4).fill().map((function(){return new ci})),this.satBounds=new Array(4).fill().map((function(){return new $x})),this.points=[this.a,this.b,this.c],this.sphere=new Ri}}wy.prototype.update=(uy=new Array(3),function(){var e=this.a,t=this.b,n=this.c;uy[0]=this.a,uy[1]=this.b,uy[2]=this.c;var i=this.satAxes,o=this.satBounds,r=i[0],a=o[0];this.getNormal(r),a.setFromPoints(r,uy);var s=i[1],l=o[1];s.subVectors(e,t),l.setFromPoints(s,uy);var c=i[2],u=o[2];c.subVectors(t,n),u.setFromPoints(c,uy);var d=i[3],h=o[3];d.subVectors(n,e),h.setFromPoints(d,uy),this.sphere.setFromPoints(this.points)}),wy.prototype.intersectsTriangle=(dy=new wy,hy=new Array(3),py=new Array(3),fy=new $x,my=new $x,gy=new ci,function(e){e.isSeparatingAxisTriangle||(dy.copy(e),dy.update(),e=dy);var t=this.satBounds,n=this.satAxes;py[0]=e.a,py[1]=e.b,py[2]=e.c;for(var i=0;i<4;i++){var o=t[i],r=n[i];if(fy.setFromPoints(r,py),o.isSeparated(fy))return!1}var a=e.satBounds,s=e.satAxes;hy[0]=this.a,hy[1]=this.b,hy[2]=this.c;for(var l=0;l<4;l++){var c=a[l],u=s[l];if(fy.setFromPoints(u,hy),c.isSeparated(fy))return!1}for(var d=0;d<4;d++)for(var h=n[d],p=0;p<4;p++){var f=s[p];if(gy.crossVectors(h,f),fy.setFromPoints(gy,hy),my.setFromPoints(gy,py),fy.isSeparated(my))return!1}return!0}),wy.prototype.distanceToPoint=(vy=new ci,function(e){return this.closestPointToPoint(e,vy),e.distanceTo(vy)}),wy.prototype.distanceToTriangle=(Ay=new ci,_y=new ci,xy=["a","b","c"],yy=new bf,by=new bf,function(e,t=null,n=null){if(this.intersectsTriangle(e))return(t||n)&&(this.getMidpoint(Ay),e.closestPointToPoint(Ay,_y),this.closestPointToPoint(_y,Ay),t&&t.copy(Ay),n&&n.copy(_y)),0;for(var i=1/0,o=0;o<3;o++){var r=void 0,a=xy[o],s=e[a];this.closestPointToPoint(s,Ay),(r=s.distanceToSquared(Ay))<i&&(i=r,t&&t.copy(Ay),n&&n.copy(s));var l=this[a];e.closestPointToPoint(l,Ay),(r=l.distanceToSquared(Ay))<i&&(i=r,t&&t.copy(l),n&&n.copy(Ay))}for(var c=0;c<3;c++){var u=xy[c],d=xy[(c+1)%3];yy.set(this[u],this[d]);for(var h=0;h<3;h++){var p=xy[h],f=xy[(h+1)%3];by.set(e[p],e[f]),Sy(yy,by,Ay,_y);var m=Ay.distanceToSquared(_y);m<i&&(i=m,t&&t.copy(Ay),n&&n.copy(_y))}}return Math.sqrt(i)});class Ty extends hi{constructor(...e){super(...e),this.isOrientedBox=!0,this.matrix=new zi,this.invMatrix=new zi,this.points=new Array(8).fill().map((function(){return new ci})),this.satAxes=new Array(3).fill().map((function(){return new ci})),this.satBounds=new Array(3).fill().map((function(){return new $x})),this.alignedSatBounds=new Array(3).fill().map((function(){return new $x})),this.sphere=new Ri}set(e,t,n){super.set(e,t),this.matrix=n}copy(e){super.copy(e),this.matrix.copy(e.matrix)}}Ty.prototype.update=function(){for(var e=this.matrix,t=this.min,n=this.max,i=this.points,o=0;o<=1;o++)for(var r=0;r<=1;r++)for(var a=0;a<=1;a++){var s=i[1*o|2*r|4*a];s.x=o?n.x:t.x,s.y=r?n.y:t.y,s.z=a?n.z:t.z,s.applyMatrix4(e)}this.sphere.setFromPoints(this.points);for(var l=this.satBounds,c=this.satAxes,u=i[0],d=0;d<3;d++){var h=c[d],p=l[d],f=i[1<<d];h.subVectors(u,f),p.setFromPoints(h,i)}var m=this.alignedSatBounds;m[0].setFromPointsField(i,"x"),m[1].setFromPointsField(i,"y"),m[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert()},Ty.prototype.intersectsBox=(Cy=new $x,function(e){if(!e.intersectsSphere(this.sphere))return!1;var t=e.min,n=e.max,i=this.satBounds,o=this.satAxes,r=this.alignedSatBounds;if(Cy.min=t.x,Cy.max=n.x,r[0].isSeparated(Cy))return!1;if(Cy.min=t.y,Cy.max=n.y,r[1].isSeparated(Cy))return!1;if(Cy.min=t.z,Cy.max=n.z,r[2].isSeparated(Cy))return!1;for(var a=0;a<3;a++){var s=o[a],l=i[a];if(Cy.setFromBox(s,e),l.isSeparated(Cy))return!1}return!0}),Ty.prototype.intersectsTriangle=function(){var e=new wy,t=new Array(3),n=new $x,i=new $x,o=new ci;return function(r){r.isSeparatingAxisTriangle||(e.copy(r),e.update(),r=e);var a=this.satBounds,s=this.satAxes;t[0]=r.a,t[1]=r.b,t[2]=r.c;for(var l=0;l<3;l++){var c=a[l],u=s[l];if(n.setFromPoints(u,t),c.isSeparated(n))return!1}for(var d=r.satBounds,h=r.satAxes,p=this.points,f=0;f<3;f++){var m=d[f],g=h[f];if(n.setFromPoints(g,p),m.isSeparated(n))return!1}for(var v=0;v<3;v++)for(var A=s[v],_=0;_<4;_++){var x=h[_];if(o.crossVectors(A,x),n.setFromPoints(o,t),i.setFromPoints(o,p),n.isSeparated(i))return!1}return!0}}(),Ty.prototype.closestPointToPoint=function(e,t){return t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t},Ty.prototype.distanceToPoint=function(){var e=new ci;return function(t){return this.closestPointToPoint(t,e),t.distanceTo(e)}}(),Ty.prototype.distanceToBox=function(){var e=["x","y","z"],t=new Array(12).fill().map((function(){return new bf})),n=new Array(12).fill().map((function(){return new bf})),i=new ci,o=new ci;return function(r,a=0,s=null,l=null){if(this.intersectsBox(r))return(s||l)&&(r.getCenter(o),this.closestPointToPoint(o,i),r.closestPointToPoint(i,o),s&&s.copy(i),l&&l.copy(o)),0;for(var c=a*a,u=r.min,d=r.max,h=this.points,p=1/0,f=0;f<8;f++){var m=h[f];o.copy(m).clamp(u,d);var g=m.distanceToSquared(o);if(g<p&&(p=g,s&&s.copy(m),l&&l.copy(o),g<c))return Math.sqrt(g)}for(var v=0,A=0;A<3;A++)for(var _=0;_<=1;_++)for(var x=0;x<=1;x++){var y=(A+1)%3,b=(A+2)%3,C=1<<A|_<<y|x<<b,M=h[_<<y|x<<b],S=h[C];t[v].set(M,S);var E=e[A],w=e[y],T=e[b],I=n[v],R=I.start,L=I.end;R[E]=u[E],R[w]=_?u[w]:d[w],R[T]=x?u[T]:d[w],L[E]=d[E],L[w]=_?u[w]:d[w],L[T]=x?u[T]:d[w],v++}for(var P=0;P<=1;P++)for(var B=0;B<=1;B++)for(var D=0;D<=1;D++){o.x=P?d.x:u.x,o.y=B?d.y:u.y,o.z=D?d.z:u.z,this.closestPointToPoint(o,i);var N=o.distanceToSquared(i);if(N<p&&(p=N,s&&s.copy(i),l&&l.copy(o),N<c))return Math.sqrt(N)}for(var O=0;O<12;O++)for(var F=t[O],U=0;U<12;U++){var z=n[U];Sy(F,z,i,o);var V=i.distanceToSquared(o);if(V<p&&(p=V,s&&s.copy(i),l&&l.copy(o),V<c))return Math.sqrt(V)}return Math.sqrt(p)}}();var Iy,Ry,Ly,Py,By,Dy=new hi,Ny=new ci,Oy=["x","y","z"];function Fy(e,t,n,i){var o=e.a,r=e.b,a=e.c,s=n.getX(t);o.x=i.getX(s),o.y=i.getY(s),o.z=i.getZ(s),s=n.getX(t+1),r.x=i.getX(s),r.y=i.getY(s),r.z=i.getZ(s),s=n.getX(t+2),a.x=i.getX(s),a.y=i.getY(s),a.z=i.getZ(s)}class Uy{constructor(){}intersectRay(e,t){return Zx(this.boundingData,Dy),e.intersectBox(Dy,t)}raycast(e,t,n,i){this.count?function(e,t,n,i,o,r,a){for(var s=o,l=o+r;s<l;s++)qx(e,t,n,i,s,a)}(e,e.geometry,t,n,this.offset,this.count,i):(this.left.intersectRay(n,Ny)&&this.left.raycast(e,t,n,i),this.right.intersectRay(n,Ny)&&this.right.raycast(e,t,n,i))}raycastFirst(e,t,n){if(this.count)return function(e,t,n,i,o,r){for(var a=1/0,s=null,l=o,c=o+r;l<c;l++){var u=qx(e,t,n,i,l);u&&u.distance<a&&(s=u,a=u.distance)}return s}(e,e.geometry,t,n,this.offset,this.count);var i,o,r=this.splitAxis,a=Oy[r];n.direction[a]>=0?(i=this.left,o=this.right):(i=this.right,o=this.left);var s=i.intersectRay(n,Ny)?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,Ny)?o.raycastFirst(e,t,n):null;return s&&p?s.distance<=p.distance?s:p:s||p||null}}Uy.prototype.shapecast=(Iy=new wy,Ry=new hi,Ly=new hi,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);l<c;l+=3)if(Fy(Iy,l,r,a),Iy.update(),n(Iy,l,l+1,l+2))return!0;return!1}var u,d,h,p,f=this.left,m=this.right,g=f,v=m;if(i&&(h=Ry,p=Ly,Zx(g.boundingData,h),Zx(v.boundingData,p),u=i(h),(d=i(p))<u)){g=m,v=f;var A=u;u=d,d=A;var _=h;h=p,p=_}return h||(h=Ry,Zx(g.boundingData,h)),!!(t(h,!!g.count,u,g)&&g.shapecast(e,t,n,i)||(p||(p=Ly,Zx(v.boundingData,p)),t(p,!!v.count,d,v)&&v.shapecast(e,t,n,i)))}),Uy.prototype.intersectsGeometry=function(){var e=new wy,t=new wy,n=new ir,i=new zi,o=new Ty,r=new Ty;return function(a,s,l,c=null){if(null===c&&(s.boundingBox||s.computeBoundingBox(),o.set(s.boundingBox.min,s.boundingBox.max,l),o.update(),c=o),!this.count){var u=this.left,d=this.right;return Zx(u.boundingData,Dy),c.intersectsBox(Dy)&&u.intersectsGeometry(a,s,l,c)?!0:(Zx(d.boundingData,Dy),!(!c.intersectsBox(Dy)||!d.intersectsGeometry(a,s,l,c)))}var h=a.geometry,p=h.index,f=h.attributes.position,m=s.index,g=s.attributes.position,v=this.offset,A=this.count;if(i.copy(l).invert(),s.boundsTree){Zx(this.boundingData,r),r.matrix.copy(i),r.update(),n.geometry=s;var _=s.boundsTree.shapecast(n,(function(e){return r.intersectsBox(e)}),(function(e){e.a.applyMatrix4(l),e.b.applyMatrix4(l),e.c.applyMatrix4(l),e.update();for(var n=3*v,i=3*(A+v);n<i;n+=3)if(Fy(t,n,p,f),t.update(),e.intersectsTriangle(t))return!0;return!1}));return n.geometry=null,_}for(var x=3*v,y=A+3*v;x<y;x+=3){Fy(e,x,p,f),e.a.applyMatrix4(i),e.b.applyMatrix4(i),e.c.applyMatrix4(i),e.update();for(var b=0,C=m.count;b<C;b+=3)if(Fy(t,b,m,g),t.update(),e.intersectsTriangle(t))return!0}}}(),Uy.prototype.intersectsBox=(Py=new Ty,function(e,t,n){return Py.set(t.min,t.max,n),Py.update(),this.shapecast(e,(function(e){return Py.intersectsBox(e)}),(function(e){return Py.intersectsTriangle(e)}))}),Uy.prototype.intersectsSphere=function(e,t){return this.shapecast(e,(function(e){return t.intersectsBox(e)}),(function(e){return Ey(t,e)}))},Uy.prototype.closestPointToPoint=(By=new ci,function(e,t,n=null,i=0,o=1/0){var r=1/0;return this.shapecast(e,(function(e,t,n){return n<r&&n<o}),(function(e){e.closestPointToPoint(t,By);var o=t.distanceTo(By);return o<r&&(n&&n.copy(By),r=o),o<i}),(function(e){return e.distanceToPoint(t)})),r}),Uy.prototype.closestPointToGeometry=function(){var e=new wy,t=new Ty,n=new ci,i=new ci;return function(o,r,a,s=null,l=null,c=0,u=1/0){r.boundingBox||r.computeBoundingBox(),t.set(r.boundingBox.min,r.boundingBox.max,a),t.update();var d,h,p=r.attributes.position,f=r.index;s&&(d=n),l&&(h=i);var m=1/0;return this.shapecast(o,(function(e,t,n){return n<m&&n<u}),(function(t){for(var n=t.sphere,i=0,o=f.count;i<o;i+=3){Fy(e,i,f,p),e.a.applyMatrix4(a),e.b.applyMatrix4(a),e.c.applyMatrix4(a),e.sphere.setFromPoints(e.points);var r=e.sphere;if(!(r.center.distanceTo(n.center)-r.radius-n.radius>m)){e.update();var u=t.distanceToTriangle(e,d,h);if(u<m&&(s&&s.copy(d),l&&l.copy(h),m=u),u<c)return!0}}return!1}),(function(e){return t.distanceToBox(e,Math.min(m,u))})),m}}();var zy=["x","y","z"];var Vy=new hi;class Gy{constructor(e,t){if(this.geo=e,this.options=t,this.bounds=function(e){for(var t=e.attributes.position.array,n=e.index.array,i=n.length/3,o=new Float32Array(6*i),r=0;r<i;r++)for(var a=3*n[3*r+0],s=3*n[3*r+1],l=3*n[3*r+2],c=0;c<3;c++){var u=t[a+c],d=t[s+c],h=t[l+c],p=Math.min(u,d,h),f=(Math.max(u,d,h)-p)/2;o[6*r+2*c+0]=p+f,o[6*r+2*c+1]=f}return o}(e),this.sahplanes=null,2===t.strategy){var n=e.index.count/3;this.sahplanes=[new Array(n),new Array(n),new Array(n)];for(var i=0;i<n;i++)for(var o=0;o<3;o++)this.sahplanes[o][i]={p:this.bounds[6*i+2*o],tri:i}}}getAverage(e,t,n){for(var i=0,o=this.bounds,r=e,a=e+t;r<a;r++)i+=o[6*r+2*n];return i/t}getBounds(e,t,n){for(var i=1/0,o=1/0,r=1/0,a=-1/0,s=-1/0,l=-1/0,c=this.bounds,u=e,d=e+t;u<d;u++){var h=c[6*u+0],p=c[6*u+1];i=Math.min(i,h-p),a=Math.max(a,h+p);var f=c[6*u+2],m=c[6*u+3];o=Math.min(o,f-m),s=Math.max(s,f+m);var g=c[6*u+4],v=c[6*u+5];r=Math.min(r,g-v),l=Math.max(l,g+v)}return n[0]=i,n[1]=o,n[2]=r,n[3]=a,n[4]=s,n[5]=l,n}partition(e,t,n){for(var i=e,o=e+t-1,r=n.pos,a=2*n.axis,s=this.geo.index.array,l=this.bounds,c=this.sahplanes;;){for(;i<=o&&l[6*i+a]<r;)i++;for(;i<=o&&l[6*o+a]>=r;)o--;if(!(i<o))return i;for(var u=0;u<3;u++){var d=s[3*i+u];s[3*i+u]=s[3*o+u],s[3*o+u]=d;var h=l[6*i+2*u+0];l[6*i+2*u+0]=l[6*o+2*u+0],l[6*o+2*u+0]=h;var p=l[6*i+2*u+1];l[6*i+2*u+1]=l[6*o+2*u+1],l[6*o+2*u+1]=p}if(c)for(var f=0;f<3;f++){var m=c[f][i];c[f][i]=c[f][o],c[f][o]=m}i++,o--}}getOptimalSplit(e,t,n,i){var o=-1,r=0;if(0===i)-1!==(o=Jx(e))&&(r=(e[o+3]+e[o])/2);else if(1===i)-1!==(o=Jx(e))&&(r=this.getAverage(t,n,o));else if(2===i){for(var a=Zx(e,Vy),s=[a.max.x-a.min.x,a.max.y-a.min.y,a.max.z-a.min.z],l=2*(s[0]*s[1]+s[0]*s[2]+s[1]*s[2]),c=[[],[],[]],u=t,d=t+n;u<d;u++)for(var h=0;h<3;h++)c[h].push(this.sahplanes[h][u]);c.forEach((function(e){return e.sort((function(e,t){return e.p-t.p}))}));var p=function(e,t,n,i,o){return 3+1*(t/e*n+i/e*o)};o=-1;for(var f=1*n,m=0;m<3;m++)for(var g=(m+1)%3,v=(m+2)%3,A=a.min[zy[m]],_=a.max[zy[m]],x=c[m],y=0,b=n,C=0;C<x.length;C++){var M=x[C];y++,b--;var S=M.p-A,E=_-M.p,w=s[g],T=s[g],I=s[v],R=s[v],L=p(l,2*(w*I+w*S+I*S),y,2*(T*R+T*E+R*E),b);L<f&&(o=m,r=M.p,f=L)}}return{axis:o,pos:r}}}class ky{constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.attributes.position.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the position attribute.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");(t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0},t)).strategy=Math.max(0,Math.min(2,t.strategy)),this._roots=this._buildTree(e,t)}_ensureIndex(e){if(!e.index){var t=e.attributes.position.count,n=new(t>65535?Uint32Array:Uint16Array)(t);e.setIndex(new To(n,1));for(var i=0;i<t;i++)n[i]=i}}_getRootIndexRanges(e){if(!e.groups||!e.groups.length)return[{offset:0,count:e.index.count/3}];for(var t=[],n=new Set,i=0,o=e.groups;i<o.length;i++){var r=o[i];n.add(r.start),n.add(r.start+r.count)}for(var a=Array.from(n.values()).sort((function(e,t){return e-t})),s=0;s<a.length-1;s++){var l=a[s],c=a[s+1];t.push({offset:l/3,count:(c-l)/3})}return t}_buildTree(e,t){this._ensureIndex(e);var n=new Gy(e,t),i=!1,o=function(e,r,a,s=0){if(s>=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 Uy,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 Uy,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 Uy,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;c<a.length;c++){var u=a[c],d=new Uy;d.boundingData=n.getBounds(u.offset,u.count,new Float32Array(6)),o(d,u.offset,u.count),r.push(d)}if(i&&t.verbose&&(console.warn(`MeshBVH: Max depth of ${t.maxDepth} reached when generating BVH. Consider increasing maxDepth.`),console.warn(this,e)),null==e.boundingBox){var h=new hi;e.boundingBox=new hi;for(var p=0;p<r.length;p++){var f=r[p];e.boundingBox.union(Zx(f.boundingData,h))}}return r}raycast(e,t,n,i){for(var o=0,r=this._roots;o<r.length;o++){r[o].raycast(e,t,n,i)}}raycastFirst(e,t,n){for(var i=null,o=0,r=this._roots;o<r.length;o++){var a=r[o].raycastFirst(e,t,n);null!=a&&(null==i||a.distance<i.distance)&&(i=a)}return i}intersectsGeometry(e,t,n){for(var i=0,o=this._roots;i<o.length;i++){if(o[i].intersectsGeometry(e,t,n))return!0}return!1}shapecast(e,t,n=null,i=null){for(var o=0,r=this._roots;o<r.length;o++){if(r[o].shapecast(e,t,n,i))return!0}return!1}intersectsBox(e,t,n){for(var i=0,o=this._roots;i<o.length;i++){if(o[i].intersectsBox(e,t,n))return!0}return!1}intersectsSphere(e,t){for(var n=0,i=this._roots;n<i.length;n++){if(i[n].intersectsSphere(e,t))return!0}return!1}closestPointToGeometry(e,t,n,i,o,r,a){for(var s=1/0,l=0,c=this._roots;l<c.length;l++){var u=c[l].closestPointToGeometry(e,t,n,i,o,r,a);if(u<s&&(s=u),u<r)return u}return s}distanceToGeometry(e,t,n,i,o){return this.closestPointToGeometry(e,t,n,null,null,i,o)}closestPointToPoint(e,t,n,i,o){for(var r=1/0,a=0,s=this._roots;a<s.length;a++){var l=s[a].closestPointToPoint(e,t,n,i,o);if(l<r&&(r=l),l<i)return l}return r}distanceToPoint(e,t,n,i){return this.closestPointToPoint(e,t,null,n,i)}}var Qy=new Ic({color:65416,transparent:!0,opacity:.3}),Wy=(new Uf).geometry,Hy=new hi;class jy extends uo{constructor(e,t=10,n=0){super("MeshBVHRootVisualizer"),this.depth=t,this._oldDepth=-1,this._mesh=e,this._boundsTree=null,this._group=n,this.update()}update(){var e=this;if(this._mesh.geometry.boundsTree!==this._boundsTree||this._oldDepth!==this.depth){this._oldDepth=this.depth,this._boundsTree=this._mesh.geometry.boundsTree;var t=0;if(this._boundsTree){var n=function(i,o){var r="count"in i;if(o!==e.depth){if(o===e.depth-1||r){var a=t<e.children.length?e.children[t]:null;a||((a=new Uc(Wy,Qy)).raycast=function(){return[]},e.add(a)),t++,Zx(i.boundingData,Hy),Hy.getCenter(a.position),a.scale.subVectors(Hy.max,Hy.min).multiplyScalar(.5),0===a.scale.x&&(a.scale.x=Number.EPSILON),0===a.scale.y&&(a.scale.y=Number.EPSILON),0===a.scale.z&&(a.scale.z=Number.EPSILON)}r||(n(i.left,o+1),n(i.right,o+1))}};n(this._boundsTree._roots[this._group],0)}for(;this.children.length>t;)this.remove(this.children.pop())}}}var Yy=new Ui,Xy=new zi,Ky=ir.prototype.raycast;function qy(e,t){if(this.geometry.boundsTree){if(this.isAuxClippingMesh)return;if(void 0===this.material)return;try{Xy.copy(this.matrixWorld).invert()}catch(e){return}if(Yy.copy(e.ray).applyMatrix4(Xy),!0===e.firstHitOnly){var n=this.geometry.boundsTree.raycastFirst(this,e,Yy);n&&t.push(n)}else this.geometry.boundsTree.raycast(this,e,Yy,t)}else Ky.call(this,e,t)}function Zy(e){return this.boundsTree=new ky(this,e),this.boundsTree}function Jy(){this.boundsTree=null}const $y=["toneMapping","toneMappingMidTones","toneMappingPhysicalScale","toneMappingBrightness","toneMappingContrast","toneMappingChromaticAdaptation","toneMappingWhiteColor","toneMappingColorDifferentiation","toneMappingExteriorDaylight","toneMappingWhiteBalance","toneMappingHighlights","toneMappingShadows","toneMappingSaturation","toneMappingAperture","toneMappingShutter","toneMappingISO","toneMappingVignetting"],eb=.6,tb=.4,nb={type:"afterFirstRender"},ib={type:"afterRender"},ob={type:"beforeRender"},rb={type:"dispose"},ab={type:"pause"},sb={type:"resume"},lb={type:"sceneLoad"};function cb(e,t,n){return 2*en*Math.atan(Math.tan($t*e/2)*t/n)}class ub extends qt{constructor(e,t,n){if(super(),this.container=e instanceof HTMLElement?e:document.getElementById(e),this.scene=null,this.camera=null,this.clock=new Hp,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.xrCameraParent=null,this.xrControllers=[],!wl.checkWebGL())return void wl.showWebGLErrorMessage(this.container);Qn.legacyMode=!1,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),wl.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy context AA on Safari 15.4"),t.antialias=!1),this.renderer=new zl(t),vm.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=Rt,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._onContextRestoreCb=()=>{this._onContextRestore()},this.renderer.domElement.addEventListener("webglcontextrestored",this._onContextRestoreCb),this.loader=new i_;const i=(new xx).setTranscoderPath(Fn()).detectSupport(this.renderer);this.loader.setKTX2Loader(i),zo.prototype.computeBoundsTree=Zy,zo.prototype.disposeBoundsTree=Jy,ir.prototype.raycast=qy,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,gm.drawWatermark(this),gm.addToAppList(this),this.worldMaterial=null}_updateRendererFromGLTF(e){var t,n;const i=this,o=wl.checkHalfFloatTex(this.renderer,!0);if(e.renderer.shadowMap&&(this.renderer.shadowMap.enabled=e.renderer.shadowMap.enabled,this.renderer.shadowMap.type=e.renderer.shadowMap.type,o||this.renderer.shadowMap.type!==u||(this.renderer.shadowMap.type=l,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 Cp).copy(e.shadow),e.shadow.camera.updateProjectionMatrix()))})))),e.renderer.physicallyCorrectLights&&(this.renderer.physicallyCorrectLights=!0),this.aaMethod=e.renderer.aaMethod||"AUTO",this.useHDR=Boolean(e.renderer.useHDR&&o),this.renderer.useOIT=null!=(t=e.renderer.useOIT)&&t,this.renderer.unitsScaleFactor=null!=(n=e.renderer.unitsScaleFactor)?n:1,e.renderer.toneMapping)for(let t=0;t<$y.length;t++){const n=$y[t];In(e.renderer[n])&&(this.renderer[n]=e.renderer[n])}void 0!==e.renderer.pmremMaxTileSize&&(this._pmremMaxTileSize=e.renderer.pmremMaxTileSize),void 0!==e.renderer.iblEnvironmentMode&&(this._envIBLMode=e.renderer.iblEnvironmentMode),void 0!==e.renderer.esmDistanceScale&&(this.renderer.shadowMap.esmDistanceScale=e.renderer.esmDistanceScale),e.scene.traverse((function(e){e.hidpiCompositing&&(e.traverse((t=>{e.isMesh&&(t.layers.set(7),t.isMaterialGeneratedMesh&&e.parent.layers.set(7))})),i.useHiDPIRenderPass=!0,i.renderer.setPixelRatio(window.devicePixelRatio))})),i.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 2:case 3:e.onUpdate=()=>null}}_prepareReflProbesEncoding(e,t){e.traverse((e=>{(e.isCubeReflectionProbe||e.isPlaneReflectionProbe)&&e.setEncoding(t)}))}_prepareEnvMapProbeWorld(){if(3==this._envIBLMode)return;const e=new zr;e.worldMaterial=this.scene.worldMaterial,null===this.scene.worldEnvMapProbe&&(this.scene.worldEnvMapProbe=new Im(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 2:t.onUpdate=e=>{const t=e.clone();t.setSize(this._lightProbeCubemapRes,this._lightProbeCubemapRes),wl.checkHalfFloatReadPixels(this.renderer)?t.texture.type=we:wl.checkFloatReadPixels(this.renderer)?t.texture.type=Ee:(console.warn("v3d.App: Target platform does not support reading pixels in float format, expect quality loss."),t.texture.type=xe),t.texture.format=Be,t.texture.encoding=It;const n=new Am(e.texture);return n.render(this.renderer,t),n.dispose(),this._disposeEnvLightProbe(),this._envLightProbe=yx.fromCubeRenderTarget(this.renderer,t),this.scene.add(this._envLightProbe),t.dispose(),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;if(n&&t.useHDR&&(n.toneMapped=!1,n.useFloatTex=wl.checkFloatTex(t.renderer,!0),n.isMeshNodeMaterial)){const e=n.nodeTexCoordObject;n.updateNodeGraph(),n.nodeTexCoordObject=e}}))}_updateAnimationsFromGLTF(e,t){const n=this;!n.mixer&&e.animations&&e.animations.length&&(n.mixer=new gf(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<r.length;e++)r[e](o);const a=o.renderer.getRenderTarget();o.renderer.setRenderTarget(n),o.renderer.compileAsync(e,t,(function(e){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=v):n.alphaToCoverage=!1)}))}_onContextRestore(e){this.scene&&this.scene.worldMaterial&&(this.updateEnvironment(this.scene.worldMaterial),this.updateReflectionProbes(this.scene))}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;e<n.length;e++){const t=n[e];t.crossSection&&t.createCrossSectionPlane(i,o[e])}n.length&&(t.renderer.localClippingEnabled=!0,t.postprocessing&&t.postprocessing.composer.setStencil(!0))}updateConstraints(e){const t=this;e.traverse((function(e){for(let n=0;n<e.constraints.length;n++){const i=e.constraints[n];i.isCanvasBreakpointsConstraint&&(i.appInstance=t)}}))}loadScene(e,t,n,i){const o=this;o.renderer?(o._loadSceneURL=e,o._loadingTime=performance.now(),o.preloader&&o.preloader.onUpdate(0),this.loader.load(e,(function(e){o.scene=e.scene||new zr;let i=null;e.cameras&&e.cameras.length?o.camera=e.cameras[0]:(i=Px(o.scene),o.camera=Bx(i,o.container.offsetWidth/o.container.offsetHeight),o.scene.add(o.camera)),o.camera.controls||(i=i||Px(o.scene),Dx(o.camera,Px(o.scene)),o.camera.viewportFit.type=1),o._updateRendererFromGLTF(e),o._prepareReflProbesFromGLTF(e),o._updateMaterialsFromGLTF(e),o._updateAnimationsFromGLTF(e,o.scene);const r=e.world.material;r&&(o.scene.background=new qn,o.scene.worldMaterial=r,o.updateEnvironment(r),o.worldMaterial=r),o.initPostprocessing(),o.assignClippingPlanes(o.scene),o.updateConstraints(o.scene),o.onResize&&o.onResize(),o.scene.updateMatrixWorld(),o.scene.visible=!1,o.scene.disableChildRendering=!0;const a=function(){o.scene&&o._traverseSceneForTexUniforms(o.scene,(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}).`)})),o.removeEventListener("afterFirstRender",a)},s=o.postprocessing?o.postprocessing.composer.renderTarget1:null;o._precompileSceneAsync(o.scene,o.camera,s,(function(i){const r=(60+tb*i)/1;n&&n(r),o.preloader&&o.preloader.onUpdate(r),r>=100&&(o._updateMeshesRaycastFromGLTF(e),o.addEventListener("afterFirstRender",a),t&&setTimeout((function(){o.scene.visible=!0,o.scene.disableChildRendering=!1,o.updateReflectionProbes(o.scene),o._loadingTime=performance.now()-o._loadingTime,o.dispatchEvent(_extends({},lb)),t(o.scene)}),16),e=null)})),o.clearBkgOnLoad&&(o.scene.background=null),o._tripleP=new Cx(window,Dm.P,(function(){gm.printPerformanceInfo(o,1)}),3,1),o._tripleF=new Cx(window,Dm.F,(function(){o.stats?o.hideFPS():o.showFPS()}),3,1),o._tripleH=new Cx(window,Dm.H,(function(){o.enableRender?o.disableRendering():o.enableRendering()}),3,1)}),(function(e){const t=eb*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 zr,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 dr,l,(function(o){const r=(60+tb*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),e=null)}))}),(function(e){const t=eb*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&&(xm.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;xm.disposeTextures(t),t.dispose()}}if(e||(e=t.scene),e===t.scene){if(t.scene&&(t.scene.traverse(n),t.disposeEnvironment(),t.worldMaterial=null),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 Tl||n instanceof Rm)&&n.dispose()}t.disablePostprocessing()}t.postprocessing=null,Ll.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];Lx(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.removeEventListener("webglcontextrestored",this._onContextRestoreCb),this._onContextRestoreCb=null,this.renderer.domElement.parentElement===this.container&&this.container.removeChild(this.renderer.domElement)),this.renderer=null,this.loader=null,window.removeEventListener("resize",this._resizeCb,!1),this._resizeCb=null,this.renderCallbacks.length=0,this.compileCallbacks.length=0,gm.removeFromAppList(this),op.clear(),this.dispatchEvent(_extends({},rb)),delete this._listeners}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<i.viewportFit.initialAspect,t=n<i.viewportFit.initialAspect;switch(i.viewportFit.type){case 1:i.aspect=n;break;case 2:i.fov=cb(i.fov,i.aspect,n),i.aspect=n;break;case 3:e&&t?i.fov=cb(i.fov,i.aspect,n):e&&!t?i.fov=cb(i.fov,i.aspect,i.viewportFit.initialAspect):!e&&t&&(i.fov=cb(i.fov,i.viewportFit.initialAspect,n)),i.aspect=n;break;case 5:e&&t?i.fov=cb(i.fov,i.aspect,n):e&&!t?i.fov=cb(i.fov,i.viewportFit.initialAspect,n):!e&&t&&(i.fov=cb(i.fov,i.aspect,n)),i.aspect=n;break;case 4:e||t?e&&!t?i.fov=cb(i.fov,i.viewportFit.initialAspect,n):!e&&t&&(i.fov=cb(i.fov,i.aspect,i.viewportFit.initialAspect)):i.fov=cb(i.fov,i.aspect,n),i.aspect=n}}else if(i.isOrthographicCamera){let e,t;switch(i.viewportFit.type){case 1:case 5:e=i.top*n,i.left=-e,i.right=e;break;case 2:case 4:t=i.right/n,i.bottom=-t,i.top=t;break;case 3:const o=(i.right-i.left)/(i.top-i.bottom)<i.viewportFit.initialAspect,r=n<i.viewportFit.initialAspect;e=o&&r?i.right:o&&!r?i.right*n/i.viewportFit.initialAspect:!o&&r?i.top*i.viewportFit.initialAspect:i.top*n,i.left=-e,i.right=e,i.bottom=-e/n,i.top=e/n}}i.updateProjectionMatrix()}}run(){this.preloader&&(this.preloader.onFinish(),this.preloader=null),this.animate()}animate(){const e=this;e.renderer.setAnimationLoop((function(){e.stats&&e.stats.begin();const t=e.clock.getDelta();e.elapsed=t,e.mixer&&e.mixer.update(t),e.controls&&!e.xrSession&&e.controls.update(t);const n=e.renderCallbacks;for(let i=0;i<n.length;i++)n[i](t,e.clock.elapsedTime);e.frame%e.frameRateDivider==0&&e.enableRender&&(e.render(),0===e.frame&&e.dispatchEvent(_extends({},nb))),e.frame++,e.disableRenderTrigger&&0==--e.disableRenderTrigger&&(e.enableRender=!1),e.stats&&e.stats.end()}))}enableRendering(){this.disableRenderTrigger=0,this.enableRender=!0,this.ssaaOnPause&&this.enableSSAA(0,!0)}disableRendering(e){((e=e||0)||this.ssaaOnPause)&&this.enableRender&&0==this.disableRenderTrigger?(this.disableRenderTrigger=this.ssaaOnPause?32:e,this.ssaaOnPause&&this.enableSSAA(4,!0)):0==e&&(this.enableRender=!1)}pause(){this.renderer.setAnimationLoop(null),this.clock.stop(),this.dispatchEvent(_extends({},ab))}resume(){this.animate(),this.clock.start(),this.dispatchEvent(_extends({},sb))}setFrameRateDivider(e){this.frameRateDivider=e}render(){this.dispatchEvent(_extends({},ob));const e=!!this.scene&&!!this.camera;if(e&&this.scene.traverse((e=>{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(_extends({},ib))}enableControls(e){const t=this.camera;if(t.controls){if(this.controls&&t===this.controls.object&&(this.controls instanceof Pg&&"ORBIT"===t.controls.type||this.controls instanceof Km&&"FLYING"===t.controls.type||this.controls instanceof Qm&&"FIRST_PERSON"===t.controls.type));else switch(this.controls&&this.controls.dispose(),t.controls.type){case"ORBIT":this.controls=new Pg(t,e||this.renderer.domElement);break;case"FLYING":this.controls=new Km(t,this.renderer.domElement);break;case"FIRST_PERSON":this.controls=new Qm(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<t.length;n++)t[n].setCamera(e);this.postprocessing.renderPass&&this.postprocessing.renderPass.setCamera(e),this.postprocessing.ssaaRenderPass&&this.postprocessing.ssaaRenderPass.setCamera(e),this.postprocessing.gtaoGenerator&&this.postprocessing.gtaoGenerator.setCamera(e)}this.enableControls(),this.onResize()}getCamera(e=!1){return e&&this.camera&&this.renderer&&this.renderer.xr.enabled&&this.renderer.xr.isPresenting?this.renderer.xr.getCamera(this.camera):this.camera}initPostprocessing(){(this.scene.postprocessing&&this.scene.postprocessing.length||this.useHDR||this.useHiDPIRenderPass||"AUTO"!=this.aaMethod||this.renderer.useOIT)&&this.enablePostprocessing(this.scene.postprocessing||[]),this.renderer.useOIT&&this.renderer.setOIT(1,this.postprocessing.composer.writeBuffer.samples),this.postprocessing||this._handleAlphaToCoverage(this.renderer.getContextAttributes().antialias?4:0)}enablePostprocessing(e){var t;const n={format:Be,stencilBuffer:!1};let i;if(this.useHDR?(n.type=we,n.encoding=It):(n.type=xe,n.encoding=Rt),this._prepareReflProbesEncoding(this.scene,n.encoding),this.postprocessing)i=this.postprocessing.composer;else{this.postprocessing={};const e=new cm(this.scene,this.camera);this.postprocessing.renderPass=e;let t=0;switch(this.aaMethod){case"AUTO":case"MSAA4":t=this._checkMSAA(this.renderer,4);break;case"MSAA8":t=this._checkMSAA(this.renderer,8);break;case"MSAA16":t=this._checkMSAA(this.renderer,16)}wl.checkSwiftShader(this.renderer)&&(console.warn("v3d.App: disabling buggy multisampling on SwiftShader renderer"),t=0),wl.isSafariWithMultisamplingBug()&&(console.warn("v3d.App: disabling buggy multisampling on Safari 15.4"),t=0);const o=new oi(this.getWidth(),this.getHeight(),n);o.texture.name="EffectComposer.rt1",o.samples=t,i=new Rm(this.renderer,o),i.addPass(e),this.postprocessing.composer=i;const r=this.renderer.getContextAttributes().alpha,a=0==t&&"NONE"!=this.aaMethod,s=new pm;if(a&&!r&&(s.material.defines.ALPHA_AS_LUMA=1),this.useHDR||(s.material.toneMapped=!1),i.addPass(s),this.postprocessing.toneMapPass=s,a){const e=new Jf(this.scene,this.camera);this.useHDR&&!r&&(e.material.defines.FXAA_GREEN_AS_LUMA=0),i.addPass(e),this.postprocessing.fxaaPass=e}this._handleAlphaToCoverage(t)}e.length&&this.postprocessing.copyPass&&(i.passes.splice(i.passes.indexOf(this.postprocessing.copyPass),1),this.postprocessing.copyPass=null);for(let o=0;o<e.length;o++){const r=e[o];let a=i.passes.length-1;switch(i.passes[a]instanceof Jf&&a--,r.type){case"afterimage":const e=r.damp;let o;this.postprocessing.afterimagePass?(o=this.postprocessing.afterimagePass,o.damp=e):(o=new Yf(new yn(this.getWidth(),this.getHeight()),e,n),i.insertPass(o,a),this.postprocessing.afterimagePass=o);break;case"bloom":const s=r.strength,l=r.radius,c=r.threshold;let u;this.postprocessing.bloomPass?(u=this.postprocessing.bloomPass,u.strength=s,u.radius=l,u.threshold=c):(u=new Xf(new yn(this.getWidth(),this.getHeight()),s,l,c,n),i.insertPass(u,a),this.postprocessing.bloomPass=u);break;case"brightnessContrast":let d;this.postprocessing.brightnessContrastPass?d=this.postprocessing.brightnessContrastPass:(d=new Zf,i.insertPass(d,a),this.postprocessing.brightnessContrastPass=d),d.brightness=r.brightness,d.contrast=r.contrast;break;case"dof":let h;this.postprocessing.bokehPass?h=this.postprocessing.bokehPass:(h=new Kf(this.scene,this.camera,{width:this.getWidth(),height:this.getHeight()}),i.insertPass(h,a),this.postprocessing.bokehPass=h),h.focus=r.focus,h.aperture=r.aperture,h.maxblur=r.maxblur,h.depthLeakThreshold=r.depthLeakThreshold;break;case"grayscale":if(!this.postprocessing.grayscalePass){const e=new $f;i.insertPass(e,a),this.postprocessing.grayscalePass=e}break;case"gtao":if(!wl.checkDepthTex(this.renderer)){console.warn("v3d.App: disabling GTAO since your hardware does not support depth textures");break}if("ARM"===wl.getGPUVendor(this.renderer)&&wl.getGPUModel(this.renderer).startsWith("Mali-")){console.warn("v3d.App: disabling buggy GTAO on Mali devices");break}let p=this.postprocessing.gtaoGenerator;if(!p){p=this.postprocessing.gtaoGenerator=new gx(this.scene,this.camera,this.getWidth(),this.getHeight());const e=t=>{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;this.postprocessing.outlinePass?f=this.postprocessing.outlinePass:(f=new lm(new yn(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),f.hiddenEdgeColor.setW(Number(r.renderHiddenEdge));break;case"ssr":if(!wl.checkHalfFloatTex(this.renderer,!1)){console.warn("v3d.App: disabling SSR since your hardware does not support half float textures");break}let m,g=!1;In(r.useRefract)&&(g=r.useRefract),(g?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect)?m=g?this.postprocessing.ssrPassRefract:this.postprocessing.ssrPassReflect:(m=new hm(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,In(r.objects)&&(m.objects=r.objects),In(r.intensity)&&(m.intensity=r.intensity),In(r.steps)&&(m.steps=r.steps),In(r.stride)&&(m.stride=r.stride),In(r.binarySearchSteps)&&(m.binarySearchSteps=r.binarySearchSteps),In(r.renderTargetScale)&&(m.renderTargetScale=r.renderTargetScale),In(r.thickness)&&(m.thickness=r.thickness),In(r.maxDistance)&&(m.maxDistance=r.maxDistance),In(r.jitter)&&(m.jitter=r.jitter),In(r.renderAfter)&&(m.renderAfter=r.renderAfter),In(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 qf(Ir.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;e<i.length;e++){const t=i[e];this.postprocessing[t]&&(o.passes.splice(o.passes.indexOf(this.postprocessing[t]),1),this.postprocessing[t].dispose(),this.postprocessing[t]=null)}if("AUTO"!=this.aaMethod||1!=o.passes.length||this.postprocessing.gtaoGenerator){if(1==o.passes.length){const e=new qf(Ir.copy);o.passes.push(e),this.postprocessing.copyPass=e}}else this.postprocessing.renderPass.dispose(),this.postprocessing.composer.dispose(),this.postprocessing=null}enableSSAA(e,t){if(this.postprocessing||this.enablePostprocessing([]),!this.postprocessing)return;if(e>0&&(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 cm){let o;this.postprocessing.ssaaRenderPass?o=this.postprocessing.ssaaRenderPass:(o=new um(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 um&&(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;if(this.renderer.xr.enabled=!1,this.disposeEnvironment(),e.toneMapped=!1,null!==this.scene.background){const t=this.renderer.toneMapping===q?e.worldMaterialColor():null;null!==t?this.scene.background=t:(this.scene.background=bm(this.renderer,e,this.worldCubemapRes,{encoding:Rt,format:Be,generateMipmaps:!0,minFilter:_e,type:we}).texture,this.scene.backgroundToneMapped=!this.useHDR)}0===this._envIBLMode&&new Zr(this.renderer,this._pmremMaxTileSize,!0).compileCubemapShader(),this._prepareEnvMapProbeWorld(),this.renderer.xr.enabled=t}disposeEnvironment(){this._disposeEnvLightProbe();let e=this.scene.background;e&&e&&(e.isTexture||e.isCubeTexture)&&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 Zr(this.renderer,this._pmremMaxTileSize,!0);t.flipCubemapX=!1;const n=t.fromCubemap(e.texture);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),o();for(let e=0;e<a.xrControllers.length;e++){const t=a.xrControllers[e];a.scene.remove(t)}if(a.xrControllers=[],a.xrCameraParent){const e=a.camera;e.removeFromParent(),a.scene.add(e),a.scene.remove(a.xrCameraParent),a.xrCameraParent=null}if(a.xrSession=null,a._backgroundSave&&(a.scene.background=a._backgroundSave,a._backgroundSave=null),a.postprocessing=a._postprocessingSave,a._postprocessingSave=null,a.postprocessing){const e=a.postprocessing.gtaoGenerator;e&&(a.renderer.gtaoMap=e.renderTarget.texture)}a.onResize()}function l(e){const t=e.data,n=e.target;if("tracked-pointer"==t.targetRayMode){const e=(new zo).setFromPoints([new ci(0,0,0),new ci(0,0,-1)]),t=new Nc(e);t.name=n.name+"_RAY",t.scale.z=5,n.add(t)}else if("gaze"==t.targetRayMode){const e=(new pp).load(Ux),t=new jl({map:e,sizeAttenuation:!1}),i=new ac(t);i.name=n.name+"_RETICLE",i.scale.multiplyScalar(.1),i.position.z=-5,n.add(i)}n.userData.inputSource=t}function c(e){const t=e.target;for(let e=t.children.length-1;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;e<o;e++){const t=a.renderer.xr.getController(e);a.scene.add(t),a.xrControllers.push(t),t.addEventListener("connected",l),t.addEventListener("disconnected",c)}if("immersive-vr"==e){const e=a.camera;e.parent&&e.parent.isScene&&(a.xrCameraParent=new uo,a.xrCameraParent.name="XR_CAMERA_CONTROL_OBJECT",a.scene.add(a.xrCameraParent),e.removeFromParent(),a.xrCameraParent.add(e))}else a._backgroundSave=a.scene.background,a.scene.background=null;a.renderer.xr.enabled=!0,a.renderer.xr.setSession(i),r.domOverlay&&a.renderer.xr.addEventListener("sessionstart",(function(){setTimeout((function(){a.renderer.domElement.style.width=a.getWidth()+"px",a.renderer.domElement.style.height=a.getHeight()+"px"}),300)})),n()})).catch(i)}endWebXR(){this.xrSession&&this.xrSession.end()}printPerformanceInfo(e){gm.printPerformanceInfo(this,e)}showFPS(){if(this.container){this.hideFPS();const e=new Ox;e.showPanel(0),this.container.appendChild(e.dom),this.stats=e}}hideFPS(){this.container&&this.stats&&(this.container.removeChild(this.stats.dom),this.stats=null)}}function db(e,t){this.sourceTexture=e,this.resolution=void 0!==t?t:256;var n=this.resolution,i={format:this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.renderTarget=new gr(n,n,i),this.renderTarget.texture.name="EquiCube.cube",this.camera=new Fr(-1,1,1,-1,0,1e3),this.shader=new ur(Ir.equicube),this.planeMesh=new ir(new Er(2,2),this.shader),this.planeMesh.material.side=m,this.scene=new zr,this.scene.add(this.planeMesh),this.scene.add(this.camera),this.invertU=!1,this.offsetU=0,this.shader.uniforms.tEquirect.value=this.sourceTexture}ub.prototype.updateObjectMaterialEnv=function(){console.error("v3d.App.updateObjectMaterialEnv has been deprecated: not needed anymore")},ub.prototype.load=function(){console.error("v3d.App.load has been deprecated. Use v3d.App.loadScene instead.")},ub.prototype.cleanup=function(){console.error("v3d.App.cleanup has been deprecated. Use v3d.App.unload or v3d.App.dispose instead.")},gm.createLineObjectHTML=function(){console.error("v3d.AppUtils.createLineObjectHTML has been deprecated. Use v3d.LineHTML instead.")},db.prototype={constructor:db,update:function(e){var t=e.gammaInput,n=e.gammaOutput,i=e.toneMapping,o=e.toneMappingExposure,r=e.getRenderTarget();e.toneMapping=Z,e.toneMappingExposure=1,e.gammaInput=!1,e.gammaOutput=!1,this.renderToCubeMapTarget(e,this.renderTarget),e.setRenderTarget(r),e.toneMapping=i,e.toneMappingExposure=o,e.gammaInput=t,e.gammaOutput=n},renderToCubeMapTarget:function(e,t){this.shader.uniforms.invertU.value=this.invertU,this.shader.uniforms.offsetU.value=this.offsetU;for(var n=0;n<6;n++)this.renderToCubeMapTargetFace(e,t,n)},renderToCubeMapTargetFace:function(e,t,n){this.shader.uniforms.faceIndex.value=n,e.setRenderTarget(t,n),e.render(this.scene,this.camera)},dispose:function(){this.renderTarget.dispose(),this.planeMesh.geometry.dispose(),this.planeMesh.material.dispose()}};var hb,pb,fb={calcCameraZoomToObjectsParams:(hb=new hi,pb=new Ri,function(e,t,n,i,o){var r=hb.makeEmpty();t.forEach((function(e){r.expandByObject(e)}));var a=r.getBoundingSphere(pb);fb.calcCameraZoomToSphereParams(e,a,n,i,o)}),calcCameraZoomToSphereParams:function(){const e=new ci;return function(t,n,i,o,r){if(t.isOrthographicCamera){let e=Math.min(t.top,t.right);r[0]=e/n.radius,i.setFromMatrixPosition(t.matrixWorld),o.copy(n.center)}else{let r=sn(t.fov/2);t.aspect<1&&(r=Math.atan(t.aspect*Math.tan(r)));let a=n.radius/Math.sin(r);const s=t.getWorldDirection(e);i.copy(n.center).addScaledVector(s,-a),o.copy(n.center)}}}()},mb={normalizeDialectOptions:function(e){var t={delimiter:",",doublequote:!0,lineterminator:"\n",quotechar:'"',skipinitialspace:!0,skipinitialrows:0};for(var n in e)t[n.toLowerCase()]=e[n];return t},parse:function(e,t){(!t||t&&!t.lineterminator)&&(e=mb.normalizeLineTerminator(e,t));var n=mb.normalizeDialectOptions(t);e=mb.chomp(e,n.lineterminator);var i,o,r="",a=!1,s=!1,l="",c=[],u=[];for(o=function(e){var t=String.prototype.trim?function(e){return e.trim()}:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")};return!0!==s&&(""===e?e=null:!0===n.skipinitialspace&&(e=t(e)),/^\d+$/.test(e)?e=parseInt(e,10):/^\d*\.\d+$|^\d+\.\d*$/.test(e)&&(e=parseFloat(e,10))),e},i=0;i<e.length;i+=1)r=e.charAt(i),!1!==a||r!==n.delimiter&&r!==n.lineterminator?r!==n.quotechar?l+=r:a?e.charAt(i+1)===n.quotechar?(l+=n.quotechar,i+=1):a=!1:(a=!0,s=!0):(l=o(l),c.push(l),r===n.lineterminator&&(u.push(c),c=[]),l="",s=!1);return l=o(l),c.push(l),u.push(c),n.skipinitialrows&&(u=u.slice(n.skipinitialrows)),u},normalizeLineTerminator:function(e,t){return(t=t||{}).lineterminator?e:e.replace(/(\r\n|\n|\r)/gm,"\n")},chomp:function(e,t){return e.charAt(e.length-t.length)!==t?e:e.substring(0,e.length-t.length)}};const gb=new ci(1,0,0),vb=new ci,Ab=new ci,_b=new li;class xb extends ir{constructor(e,t){e=void 0!==e?e:new qn(1,0,0),t=void 0!==t?t:2;const n=new nm;n.setGeometry([0,0,0,gb.x,gb.y,gb.z]);const i=new sm({color:e,lineWidth:t,sizeAttenuation:0});super(n.geometry,i),this.elemHTML=null,this.offset=5}onBeforeRender(e,t,n,i,o,r){if(super.onBeforeRender(),!this.elemHTML)return;const a=e.domElement.offsetHeight,s=e.domElement.offsetWidth,l=this.elemHTML.getBoundingClientRect(),c=(l.left+l.right)/2,u=(l.top+l.bottom)/2,d=this.getWorldPosition(vb).project(n),h=(d.x+1)/2*s,p=(1-d.y)/2*a,f=(u-p)/(c-h),m=(l.height+2*this.offset)/(l.width+2*this.offset);let g,v;Math.abs(f)>m?(v=p>u?Math.min(l.bottom+this.offset,p):Math.max(l.top-this.offset,p),g=(v-p)/f+h):(g=h<c?Math.max(l.left-this.offset,h):Math.min(l.right+this.offset,h),v=(g-h)*f+p);const A=2*g/s-1,_=1-2*v/a,x=Ab.set(A,_,-1);x.unproject(n),this.parent&&this.parent.worldToLocal(x);const y=x.length();this.scale.setScalar(y),x.normalize();const b=_b.setFromUnitVectors(gb,x);this.setRotationFromQuaternion(b),this.updateMatrixWorld()}}function yb(){}function bb(e){yb.call(this);for(let t in e){const n=e[t];if("container"===t)void 0===n?this.container=document.body:n instanceof HTMLElement?this.container=n:this.container=document.getElementById(n)}this.bar=document.createElement("div"),this.bar.setAttribute("class","v3d-simple-preloader-bar"),this.logo=document.createElement("div"),this.logo.setAttribute("class","v3d-simple-preloader-logo"),this.logoCont=document.createElement("div"),this.logoCont.setAttribute("id","v3d_preloader_container"),this.logoCont.setAttribute("class","v3d-simple-preloader-container"),this.background=document.createElement("div"),this.background.setAttribute("class","v3d-simple-preloader-background"),this.background.appendChild(this.logoCont),this.logoCont.appendChild(this.logo),this.logoCont.appendChild(this.bar),this.container.appendChild(this.background),"none"==getComputedStyle(this.logo).backgroundImage&&this.logo.setAttribute("style",'background-image: url("'+Fx+'");'),this.clock=new Hp}xb.prototype.isLineHTML=!0,Object.assign(yb.prototype,{onUpdate:function(e){},onFinish:function(){}}),bb.prototype=Object.assign(Object.create(yb.prototype),{constructor:bb,onUpdate:function(e){e=Math.round(e),this.bar.style.width=e+"%"},onFinish:function(){this.container.removeChild(this.background)}});function Cb(){}function Mb(e){ir.call(this),this.type="CubeTextureHelper",this.geometry=new rr(2,2,2,1,1,1),this.geometry.computeBoundingSphere(),this.material=new So,this.material.envMap=e}Object.assign(Cb.prototype,{_logicFileLoadError:function(e){const t=new Error(e);return t.name="LogicFileLoadError",t},_editorLoadError:function(e){const t=new Error(e);return t.name="EditorLoadError",t},_getLogicPromise:async function(e){const t=Nn(),n=new URL(e,document.baseURI).href;try{var i,o,r;const e=null==(i=(o=await import(/* webpackIgnore: true */n)).createPL)?void 0:i.call(o);return await(null==e||null==e.loadPhysics?void 0:e.loadPhysics()),null!=(r=null!=e?e:t.v3d.PL)?r:null}catch(e){throw this._logicFileLoadError(`Unable to load the logic file: '${n}'.`)}},_getEditorPromise:function(e,t){const n=this;return new Promise((function(t,i){gm.loadScript(e,document.body,(function(){t()}),(function(){i(n._editorLoadError("Unable to load the Puzzles Editor: '"+e+"'."))}))}))},_getLogicViaEditorPromise:async function(e,t){const n=Nn();if(!n.v3d||!n.v3d.PE)throw this._editorLoadError("Unable to load Puzzles' logic. The Puzzles Editor isn't loaded.");const i=t.split(".");i[i.length-1]="xml";const o=i.join("."),{PL:r,logicXMLLoaded:a}=await n.v3d.PE.init(e,o);if(!a)throw this._logicFileLoadError(`Unable to load the Puzzles Editor's XML logic file: '${o}'.`);return r},_getAmmoJSPromise:function(){const e=document.getElementsByTagName("script");let t=!1;for(let n=e.length-1;n>=0;--n){if(e[n].src.search(/ammo.wasm.js/)>-1){t=!0;break}}return new Promise((function(e,n){if(t&&window.Ammo)console.warn("You have ammo.wasm.js assigned in app html, please remove it"),e();else if(t&&!window.Ammo){console.warn("You have ammo.wasm.js assigned in app html, please remove it and resave Puzzles");const t=Fn("ammo.wasm.js");import(/* webpackIgnore: true */t).then((t=>{let i=t.default;i?(new i).then((t=>{window.Ammo=t,e()})):n(new Error("Failed to load physics module"))}))}else e()}))},loadLogic:async function(e,t,n){try{const n=await this._getLogicPromise(e);return await this._getAmmoJSPromise(),t&&t(),n}catch(e){console.error(e),n&&n(e)}},loadEditorWithLogic:async function(e,t,n,i){try{let i=null;await this._getEditorPromise(e+"puzzles.min.js");try{i=await this._getLogicViaEditorPromise(e,t)}catch(e){if("LogicFileLoadError"!==e.name)throw e}return await this._getAmmoJSPromise(),n&&n(),i}catch(e){console.error(e),i&&i(e)}}}),Mb.prototype=Object.create(ir.prototype),Mb.prototype.constructor=Mb;class Sb extends uo{constructor(e){super(),this.doUpdate=!0,this.projected=new ci,this.container=e,this.updatedCallback=null}clone(){return new this.constructor(this.container).copy(this)}update(e){if(this.doUpdate){var t=this.projected;this.getWorldPosition(t).project(e);var n=this.container.offsetWidth,i=this.container.offsetHeight,o=(.5+t.x/2)*n,r=(.5-t.y/2)*i;t.x=o,t.y=r;var a=t.z<=1&&o>=0&&o<=n&&r>=0&&r<=i;this.visible=a,this.updatedCallback&&this.updatedCallback(t.x,t.y,a)}}}Sb.prototype.isAnnotationControl=!0;var Eb=new yl,wb=new ci,Tb=new ci,Ib=new ci;class Rb extends Sb{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;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(wb),this.getWorldPositionNU(Tb),Ib.copy(Tb).sub(wb).normalize(),Eb.set(wb,Ib),Eb.far=wb.distanceTo(Tb);var i=Eb.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)}}Rb.prototype.isAnnotation=!0;const Lb=new ci,Pb=new li,Bb=new li;var Db=Object.freeze({__proto__:null,translateVRCamera:function(e,t,n){const i=e.parent;i&&!i.isScene&&(Lb.copy(t).applyQuaternion(e.quaternion).applyQuaternion(i.quaternion),i.position.add(Lb.multiplyScalar(n)))},rotateVRCamera:function(e,t,n){const i=e.parent;i&&!i.isScene&&(Pb.setFromAxisAngle(t,n),Pb.premultiply(e.quaternion),Pb.premultiply(i.quaternion),i.quaternion.multiplyQuaternions(Pb,Bb.copy(e.quaternion).invert()))}});class Nb{constructor(){this.pluginCallbacks=[],this.register((function(e){return new uC(e)})),this.register((function(e){return new dC(e)})),this.register((function(e){return new fC(e)})),this.register((function(e){return new mC(e)})),this.register((function(e){return new hC(e)})),this.register((function(e){return new pC(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){const o=new cC,r=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)r.push(this.pluginCallbacks[e](o));o.setPlugins(r),o.write(e,t,i).catch(n)}parseAsync(e,t){const n=this;return new Promise((function(i,o){n.parse(e,i,o,t)}))}}const Ob=0,Fb=1,Ub=2,zb=3,Vb=4,Gb=5121,kb=5123,Qb=5126,Wb=5125,Hb=34962,jb=34963,Yb=9728,Xb=9729,Kb=9984,qb=9985,Zb=9986,Jb=9987,$b=33071,eC=33648,tC=10497,nC={};nC[fe]=Yb,nC[me]=Kb,nC[ge]=Zb,nC[ve]=Xb,nC[Ae]=qb,nC[_e]=Jb,nC[he]=$b,nC[de]=tC,nC[pe]=eC;const iC={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"};function oC(e,t){return e.length===t.length&&e.every((function(e,n){return e===t[n]}))}function rC(e){return 4*Math.ceil(e/4)}function aC(e,t=0){const n=rC(e.byteLength);if(n!==e.byteLength){const i=new Uint8Array(n);if(i.set(new Uint8Array(e)),0!==t)for(let o=e.byteLength;o<n;o++)i[o]=t;return i.buffer}return e}function sC(){return"undefined"==typeof document&&"undefined"!=typeof OffscreenCanvas?new OffscreenCanvas(1,1):document.createElement("canvas")}function lC(e,t){if(void 0!==e.toBlob)return new Promise((n=>e.toBlob(n,t)));let n;return"image/jpeg"===t?n=.92:"image/webp"===t&&(n=.8),e.convertToBlob({type:t,quality:n})}class cC{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"v3d.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(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 FileReader;e.readAsArrayBuffer(s),e.onloadend=function(){const n=aC(e.result),i=new DataView(new ArrayBuffer(8));i.setUint32(0,n.byteLength,!0),i.setUint32(4,5130562,!0);const o=aC((a=JSON.stringify(r),(new TextEncoder).encode(a).buffer),32);var a;const s=new DataView(new ArrayBuffer(8));s.setUint32(0,o.byteLength,!0),s.setUint32(4,1313821514,!0);const l=new ArrayBuffer(12),c=new DataView(l);c.setUint32(0,1179937895,!0),c.setUint32(4,2,!0);const u=12+s.byteLength+o.byteLength+i.byteLength+n.byteLength;c.setUint32(8,u,!0);const d=new Blob([l,s,o,i,n],{type:"application/octet-stream"}),h=new FileReader;h.readAsArrayBuffer(d),h.onloadend=function(){t(h.result)}}}else if(r.buffers&&r.buffers.length>0){const e=new 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,t=!1){if(!1===this.uids.has(e)){const t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const t=new ci;for(let n=0,i=e.count;n<i;n++)if(Math.abs(t.fromBufferAttribute(e,n).length()-1)>5e-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 ci;for(let e=0,t=n.count;e<t;e++)i.fromBufferAttribute(n,e),0===i.x&&0===i.y&&0===i.z?i.setX(1):i.normalize(),n.setXYZ(e,i.x,i.y,i.z);return t.attributesNormalized.set(e,n),n}applyTextureTransform(e,t){let n=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),n=!0),0!==t.rotation&&(i.rotation=t.rotation,n=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.encoding===sRGBEncoding?function(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}:function(e){return e}}console.warn("v3d.GLTFExporter: Merged metalnessMap and roughnessMap textures.");const i=null==e?void 0:e.image,o=null==t?void 0:t.image,r=Math.max((null==i?void 0:i.width)||0,(null==o?void 0:o.width)||0),a=Math.max((null==i?void 0:i.height)||0,(null==o?void 0:o.height)||0),s=sC();s.width=r,s.height=a;const l=s.getContext("2d");l.fillStyle="#00ffff",l.fillRect(0,0,r,a);const c=l.getImageData(0,0,r,a);if(i){l.drawImage(i,0,0,r,a);const t=n(e),o=l.getImageData(0,0,r,a).data;for(let e=2;e<o.length;e+=4)c.data[e]=256*t(o[e]/256)}if(o){l.drawImage(o,0,0,r,a);const e=n(t),i=l.getImageData(0,0,r,a).data;for(let t=1;t<i.length;t+=4)c.data[t]=256*e(i[t]/256)}l.putImageData(c,0,0);const u=(e||t).clone();return u.source=new Source(s),u.encoding=LinearEncoding,u}processBuffer(e){const t=this.json,n=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),n.push(e),0}processBufferView(e,t,n,i,o){const r=this.json;let a;r.bufferViews||(r.bufferViews=[]),a=t===Gb?1:t===kb?2:4;const s=rC(i*e.itemSize*a),l=new DataView(new ArrayBuffer(s));let c=0;for(let o=n;o<n+i;o++)for(let n=0;n<e.itemSize;n++){let i;e.itemSize>4?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)),!0===e.normalized&&(i=pn(i,e.array))),t===Qb?l.setFloat32(c,i,!0):t===Wb?l.setUint32(c,i,!0):t===kb?l.setUint16(c,i,!0):t===Gb&&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===Hb&&(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 FileReader;o.readAsArrayBuffer(e),o.onloadend=function(){const e=aC(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.json;let r;if(e.array.constructor===Float32Array)r=Qb;else if(e.array.constructor===Uint32Array)r=Wb;else if(e.array.constructor===Uint16Array)r=kb;else{if(e.array.constructor!==Uint8Array)throw new Error("v3d.GLTFExporter: Unsupported bufferAttribute component type.");r=Gb}if(void 0===n&&(n=0),void 0===i&&(i=e.count),0===i)return null;const a=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;o<t+n;o++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?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)),!0===e.normalized&&(n=pn(n,e.array))),i.min[t]=Math.min(i.min[t],n),i.max[t]=Math.max(i.max[t],n)}return i}(e,n,i);let s;void 0!==t&&(s=e===t.index?jb:Hb);const l=this.processBufferView(e,r,n,i,s),c={bufferView:l.id,byteOffset:l.byteOffset,componentType:r,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};return!0===e.normalized&&(c.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(c)-1}processImage(e,t,n,i="image/png"){if(null!==e){const o=this,r=o.cache,a=o.json,s=o.options,l=o.pending;r.images.has(e)||r.images.set(e,{});const c=r.images.get(e),u=i+":flipY/"+n.toString();if(void 0!==c[u])return c[u];a.images||(a.images=[]);const d={mimeType:i},h=sC();h.width=Math.min(e.width,s.maxTextureSize),h.height=Math.min(e.height,s.maxTextureSize);const p=h.getContext("2d");if(!0===n&&(p.translate(0,h.height),p.scale(1,-1)),void 0!==e.data){t!==Be&&console.error("GLTFExporter: Only RGBAFormat is supported."),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else p.drawImage(e,0,0,h.width,h.height);!0===s.binary?l.push(lC(h,i).then((e=>o.processBufferViewImage(e))).then((e=>{d.bufferView=e}))):void 0!==h.toDataURL?d.uri=h.toDataURL(i):l.push(lC(h,i).then((e=>(new FileReader).readAsDataURL(e))).then((e=>{d.uri=e})));const f=a.images.push(d)-1;return c[u]=f,f}throw new Error("v3d.GLTFExporter: No valid image data found. Unable to process texture.")}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const n={magFilter:nC[e.magFilter],minFilter:nC[e.minFilter],wrapS:nC[e.wrapS],wrapT:nC[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){const t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||(n.textures=[]);let i=e.userData.mimeType;"image/webp"===i&&(i="image/png");const o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,i)};e.name&&(o.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,o)}));const r=n.textures.push(o)-1;return t.textures.set(e,r),r}processMaterial(e){const t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: v3d.ShaderMaterial not supported."),null;n.materials||(n.materials=[]);const i={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const o=e.color.toArray().concat([e.opacity]);if(oC(o,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=o),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap){const t=this.buildMetalRoughTexture(e.metalnessMap,e.roughnessMap),n={index:this.processTexture(t)};this.applyTextureTransform(n,t),i.pbrMetallicRoughness.metallicRoughnessTexture=n}if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),i.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),n=Math.max(t.r,t.g,t.b);if(n>1&&(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(e.aoMap),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),e.side===m&&(i.doubleSided=!0),""!==e.name&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,i)}));const r=n.materials.push(i)-1;return t.materials.set(e,r),r}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;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);const o=i.join(":");if(t.meshes.has(o))return t.meshes.get(o);const r=e.geometry;let a;a=e.isLineSegments?Fb:e.isLineLoop?Ub:e.isLine?zb:e.isPoints?Ob:e.material.wireframe?Fb:Vb;const s={},l={},c=[],u=[],d={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},h=r.getAttribute("normal");void 0===h||this.isNormalizedNormalAttribute(h)||(console.warn("v3d.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),r.setAttribute("normal",this.createNormalizedNormalAttribute(h)));let p=null;for(let e in r.attributes){if("morph"===e.slice(0,5))continue;const n=r.attributes[e];e=d[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),t.attributes.has(this.getUID(n))){l[e]=t.attributes.get(this.getUID(n));continue}p=null;const i=n.array;"JOINTS_0"!==e||i instanceof Uint16Array||i instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new To(new Uint16Array(i),n.itemSize,n.normalized));const o=this.processAccessor(p||n,r);null!==o&&(l[e]=o,t.attributes.set(this.getUID(n),o))}if(void 0!==h&&r.setAttribute("normal",h),0===Object.keys(l).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const n=[],i=[],o={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)o[e.morphTargetDictionary[t]]=t;for(let a=0;a<e.morphTargetInfluences.length;++a){const s={};let l=!1;for(const e in r.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const n=r.morphAttributes[e][a],i=e.toUpperCase(),o=r.attributes[e];if(t.attributes.has(this.getUID(n,!0))){s[i]=t.attributes.get(this.getUID(n,!0));continue}const c=n.clone();if(!r.morphTargetsRelative)for(let e=0,t=n.count;e<t;e++)for(let t=0;t<n.itemSize;t++)0===t&&c.setX(e,n.getX(e)-o.getX(e)),1===t&&c.setY(e,n.getY(e)-o.getY(e)),2===t&&c.setZ(e,n.getZ(e)-o.getZ(e)),3===t&&c.setW(e,n.getW(e)-o.getW(e));s[i]=this.processAccessor(c,r),t.attributes.set(this.getUID(o,!0),s[i])}u.push(s),n.push(e.morphTargetInfluences[a]),void 0!==e.morphTargetDictionary&&i.push(o[a])}s.weights=n,i.length>0&&(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;e<n;e++){const n={mode:a,attributes:l};if(this.serializeUserData(r,n),u.length>0&&(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:sn(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=Nb.Utils.mergeMorphTargetTracks(e.clone(),t)).tracks,r=[],a=[];for(let e=0;e<o.length;++e){const n=o[e],s=pf.parseTrackName(n.name);let l=pf.findNode(t,s.nodeName);const c=iC[s.propertyName];if("bones"===s.objectName&&(l=!0===l.isSkinnedMesh?l.skeleton.getBoneByName(s.objectIndex):void 0),!l||!c)return console.warn('v3d.GLTFExporter: Could not export animation track "%s".',n.name),null;const u=1;let d,h=n.values.length/n.times.length;c===iC.morphTargetInfluences&&(h/=l.morphTargetInfluences.length),!0===n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",h/=3):d=n.getInterpolation()===At?"STEP":"LINEAR",a.push({input:this.processAccessor(new To(n.times,u)),output:this.processAccessor(new To(n.values,h)),interpolation:d}),r.push({sampler:a.length-1,target:{node:i.get(l),path:c}})}return n.animations.push({name:e.name||"clip_"+n.animations.length,samplers:a,channels:r}),n.animations.length-1}processSkin(e){const t=this.json,n=this.nodeMap,i=t.nodes[n.get(e)],o=e.skeleton;if(void 0===o)return null;const r=e.skeleton.bones[0];if(void 0===r)return null;const a=[],s=new Float32Array(16*o.bones.length),l=new zi;for(let t=0;t<o.bones.length;++t)a.push(n.get(o.bones[t])),l.copy(o.boneInverses[t]),l.multiply(e.bindMatrix).toArray(s,16*t);void 0===t.skins&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new To(s,16)),joints:a,skeleton:n.get(r)});return i.skin=t.skins.length-1}processNode(e){const t=this.json,n=this.options,i=this.nodeMap;let o=!1;if(n.onlyVisible&&!e.visible&&(e.traverse((function(e){e.visible&&(o=!0)})),!o))return null;t.nodes||(t.nodes=[]);const r={};if(n.trs){const t=e.quaternion.toArray(),n=e.position.toArray(),i=e.scale.toArray();oC(t,[0,0,0,1])||(r.rotation=t),oC(n,[0,0,0])||(r.translation=n),oC(i,[1,1,1])||(r.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===oC(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(r.matrix=e.matrix.elements);if(""!==e.name&&(r.name=String(e.name)),this.serializeUserData(e,r),(e.isMesh||e.isLine||e.isPoints)&&!o){const t=this.processMesh(e);null!==t&&(r.mesh=t)}else e.isCamera&&!o&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&!o&&this.skins.push(e),e.children.length>0){const t=[];for(let n=0,i=e.children.length;n<i;n++){const i=e.children[n],o=this.processNode(i);null!==o&&t.push(o)}t.length>0&&(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;t<i;t++){const i=e.children[t];if(i.visible||!1===n.onlyVisible){const e=this.processNode(i);null!==e&&o.push(e)}}o.length>0&&(i.nodes=o),this.serializeUserData(e,i)}processObjects(e){const t=new zr;t.name="AuxScene";for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const n=[];for(let t=0;t<e.length;t++)e[t]instanceof zr?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}}class uC{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("v3d.GLTFExporter: Only directional, point, and spot lights are supported.",e);const n=this.writer,i=n.json,o=n.extensionsUsed,r={};e.name&&(r.name=e.name),r.color=e.color.toArray(),r.intensity=e.intensity,e.isDirectionalLight?r.type="directional":e.isPointLight?(r.type="point",e.distance>0&&(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 dC{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 hC{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 pC{constructor(e){this.writer=e,this.name="KHR_materials_iridescence"}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial)return;const n=this.writer,i=n.extensionsUsed,o={};if(o.iridescenceFactor=e.iridescence,e.iridescenceMap){const t={index:n.processTexture(e.iridescenceMap)};n.applyTextureTransform(t,e.iridescenceMap),o.iridescenceTexture=t}if(o.iridescenceIor=e.iridescenceIOR,o.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],o.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){const t={index:n.processTexture(e.iridescenceThicknessMap)};n.applyTextureTransform(t,e.iridescenceThicknessMap),o.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=o,i[this.name]=!0}}class fC{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 mC{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}}Nb.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;e<i;e++)r[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;o[0]=t,o.set(e.times,1),r.set(a.evaluate(t),0),r.set(e.values,i),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;o[o.length-1]=t,o.set(e.times,0),r.set(e.values,0),r.set(a.evaluate(t),e.values.length),s=o.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<n)return l;if(e.times[l]<t&&e.times[l+1]>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<o.length;++e){let r=o[e];const a=pf.parseTrackName(r.name),s=pf.findNode(t,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){n.push(r);continue}if(r.createInterpolant!==r.InterpolantFactoryMethodDiscrete&&r.createInterpolant!==r.InterpolantFactoryMethodLinear){if(r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("v3d.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("v3d.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),r=r.clone(),r.setInterpolation(_t)}const l=s.morphTargetInfluences.length,c=s.morphTargetDictionary[a.propertyIndex];if(void 0===c)throw new Error("v3d.GLTFExporter: Morph target name not found: "+a.propertyIndex);let u;if(void 0===i[s.uuid]){u=r.clone();const e=new u.ValueBufferType(l*u.times.length);for(let t=0;t<u.times.length;t++)e[t*l+c]=u.values[t];u.name=(a.nodeName||"")+".morphTargetInfluences",u.values=e,i[s.uuid]=u,n.push(u);continue}const d=r.createInterpolant(new r.ValueBufferType(1));u=i[s.uuid];for(let e=0;e<u.times.length;e++)u.values[e*l+c]=d.evaluate(u.times[e]);for(let e=0;e<r.times.length;e++){const t=this.insertKeyframe(u,r.times[e]);u.values[t*l+c]=r.values[e]}}return e.tracks=n,e}};"undefined"!=typeof __V3D_DEVTOOLS__&&__V3D_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:t}})),"undefined"!=typeof window&&(window.__V3D__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__V3D__=t);const gC=Nn();if(gC.v3d&&(gC.THREE=gC.v3d),"undefined"!=typeof document){const e=document.createElement("style");e.appendChild(document.createTextNode('.v3d-container {\n    \n    overflow: hidden;\n    z-index: 0;\n}\n.v3d-canvas {\n    \n    position: absolute;\n    top: 0;\n    bottom: 0;\n    left: 0;\n    right: 0;\n    \n    z-index: -1;\n}\n.v3d-simple-preloader-background {\n    background-color: #fff;\n    position: absolute;\n    top: 0;\n    bottom: 0;\n    left: 0;\n    right: 0;\n    z-index: 1;\n    height: 100%;\n    width: 100%;\n}\n.v3d-simple-preloader-container {\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    margin-top: -90px;\n    margin-left: -90px;\n    width: 180px;\n    height: 180px;\n}\n.v3d-simple-preloader-bar {\n    background: linear-gradient(90deg, #1458ae, #4388e0);\n    width: 0%;\n    height: 3px;\n    margin: 15px -1px;\n    border: 1px solid;\n    border-radius: 5px;\n    border-color: #2b70c7;\n}\n.v3d-simple-preloader-logo {\n    width: 110px;\n    height: 120px;\n    background-repeat: no-repeat;\n    margin: 20px auto;\n}\n.v3d-annotation {\n    position: absolute;\n    top: -16px;\n    left: -16px;\n    width: auto;\n    min-width: 14px;\n    height: 26px;\n    padding: 2px 8px;\n    border: 1px solid #fff;\n    border-radius: 18px;\n    font-size: 16px;\n    font-family: sans-serif;\n    line-height: 26px;\n    color: #fff;\n    text-align: center;\n    user-select: none;\n    background: rgba(0, 0, 0, 0.8);\n}\n.v3d-annotation-transparent {\n    opacity: 0.5;\n}\n.v3d-annotation-dialog {\n    position: absolute;\n    top: 0;\n    left: 0;\n    margin-left: 15px;\n    margin-top: 31px;\n    font-family: sans-serif;\n    user-select: none;\n    padding: 1em;\n    min-width: 200px;\n    color: #fff;\n    background: rgba(0, 0, 0, 0.8);\n    border-radius: .5em;\n    font-size: 12px;\n    line-height: 1.2;\n    transition: opacity .5s;\n    visibility: hidden;\n}\n.v3d-mobile-forward {\n    position: absolute;\n    width: 62px;\n    height: 62px;\n    bottom: 31px;\n    left: 50%;\n    margin-left: -31px;\n    background-image: url(\'data:image/svg+xml,%3C%3Fxml version="1.0" encoding="UTF-8" standalone="no"%3F%3E%3Csvg width="62" height="62" viewBox="0 0 16.404167 16.404167" version="1.1" id="svg2719" sodipodi:docname="move_forward.svg" inkscape:version="1.1.2 (b8e25be833, 2022-02-05)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns%23" xmlns:cc="http://creativecommons.org/ns%23" xmlns:dc="http://purl.org/dc/elements/1.1/"%3E%3Csodipodi:namedview id="namedview7548" pagecolor="%23505050" bordercolor="%23eeeeee" borderopacity="1" inkscape:pageshadow="0" inkscape:pageopacity="0" inkscape:pagecheckerboard="0" showgrid="false" inkscape:snap-global="false" inkscape:zoom="7.1451613" inkscape:cx="42.266366" inkscape:cy="15.814898" inkscape:window-width="1920" inkscape:window-height="1137" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" inkscape:current-layer="svg2719" /%3E%3Cdefs id="defs2713"%3E%3ClinearGradient gradientTransform="translate(-524.2581,-935.78503)" xlink:href="%23linearGradient2768" id="linearGradient2673" x1="501.88306" y1="942.95502" x2="508.08038" y2="935.61182" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient id="linearGradient2768"%3E%3Cstop style="stop-color:%23414141;stop-opacity:1" offset="0" id="stop2764" /%3E%3Cstop style="stop-color:%23767676;stop-opacity:1" offset="1" id="stop2766" /%3E%3C/linearGradient%3E%3ClinearGradient gradientTransform="translate(-521.96226,-941.8579)" xlink:href="%23linearGradient2648" id="linearGradient2665" x1="495.62714" y1="948.00964" x2="508.85629" y2="934.78046" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient id="linearGradient2648"%3E%3Cstop style="stop-color:%23ebebeb;stop-opacity:1" offset="0" id="stop2644" /%3E%3Cstop style="stop-color:%23ffffff;stop-opacity:1" offset="1" id="stop2646" /%3E%3C/linearGradient%3E%3Cfilter style="color-interpolation-filters:sRGB" id="filter2688" x="-0.12" width="1.24" y="-0.12" height="1.24"%3E%3CfeGaussianBlur stdDeviation="0.66145835" id="feGaussianBlur2690" /%3E%3C/filter%3E%3ClinearGradient inkscape:collect="always" xlink:href="%23linearGradient2768" id="linearGradient7749" x1="6.0107598" y1="11.942085" x2="11.430239" y2="4.0917845" gradientUnits="userSpaceOnUse" /%3E%3ClinearGradient inkscape:collect="always" xlink:href="%23linearGradient2648" id="linearGradient8251" x1="4.2536402" y1="13.238126" x2="12.150527" y2="2.9068334" gradientUnits="userSpaceOnUse" /%3E%3Cfilter inkscape:collect="always" style="color-interpolation-filters:sRGB" id="filter8772" x="-0.10840111" y="-0.10840111" width="1.2168022" height="1.2168022"%3E%3CfeGaussianBlur inkscape:collect="always" stdDeviation="0.59752352" id="feGaussianBlur8774" /%3E%3C/filter%3E%3C/defs%3E%3Cmetadata id="metadata2716"%3E%3Crdf:RDF%3E%3Ccc:Work rdf:about=""%3E%3Cdc:format%3Eimage/svg+xml%3C/dc:format%3E%3Cdc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /%3E%3C/cc:Work%3E%3C/rdf:RDF%3E%3C/metadata%3E%3Ccircle style="fill:%23000000;stroke-width:0.230841;stroke-linecap:round;stroke-linejoin:round;fill-opacity:0.5;filter:url(%23filter8772)" id="circle8626" cx="8.2020836" cy="8.2020836" r="6.6145835" /%3E%3Ccircle style="fill:url(%23linearGradient8251);stroke-width:0.230841;stroke-linecap:round;stroke-linejoin:round;fill-opacity:1" id="path7652" cx="8.2020836" cy="8.2020836" r="6.6145835" /%3E%3Cpath d="m 4.2333333,6.7138018 c 0,0.9875367 0.4960933,2.4804692 0.4960933,2.4804692 h 1.984375 c 0,-0.7441408 0.2480473,-1.1782225 0.496094,-1.612305 0.2480467,-0.4340817 0.4960942,-0.8681642 0.4960942,-1.6123037 0,-0.8743657 -0.2480475,-2.7285166 -1.4882817,-2.7285166 -1.240234,0 -1.9843749,1.9843749 -1.9843748,3.4726561 z m 1.4882816,4.4648442 c 0.5472533,0 0.9921867,-0.444934 0.9921867,-0.992188 V 9.6903643 h -1.984375 v 0.4960937 c 0,0.547254 0.4449341,0.992188 0.9921883,0.992188 z M 12.170834,8.6981768 c 0,-1.4882808 -0.744141,-3.4726553 -1.984376,-3.4726553 -1.240234,0 -1.4882807,1.8541503 -1.4882807,2.7285153 0,0.74414 0.2480467,1.1782226 0.4960933,1.6123041 0.2480467,0.4340821 0.4960934,0.8681641 0.4960934,1.6123051 h 1.984376 c 0,0 0.496094,-1.4929325 0.496094,-2.4804692 z m -1.488281,4.4648442 c 0.547253,0 0.992187,-0.444935 0.992187,-0.992188 V 11.674739 H 9.690364 v 0.496094 c 0,0.547253 0.444935,0.992188 0.992189,0.992188 z" id="path7734" style="stroke-width:0.0155029;fill-opacity:1;fill:url(%23linearGradient7749)" /%3E%3C/svg%3E\');\n    touch-action: none;\n    -webkit-user-select: none;\n    user-select: none;\n}\n.v3d-webgl-error {\n    color: #015fb1;\n    background-color: white;\n    position: absolute;\n    top: 50%;\n    left: 50%;\n    margin-top: -44px;\n    margin-left: -256px;\n    text-align: center;\n    border-style: solid;\n    border-width: 3px;\n    border-radius: 8px;\n    border-color: #015fb1;\n    font-size: 20px;\n    font-family: sans-serif;\n    padding: 10px;\n    line-height: 30px;\n    z-index: 10;\n}\n@media only screen and (max-width: 540px) {\n    .v3d-webgl-error {\n        top: 50%;\n        left: 10px;\n        right: 10px;\n        margin-top: -58px;\n        margin-left: 0px;\n    }\n}\n.v3d-webgl-error-link {\n    color: #015fb1;\n}\n.v3d-device-motion-permissions-dialog {\n    z-index: 1;\n    position: absolute;\n    width: 100%;\n    background-color: #f00;\n    color: #000;\n    text-align: center;\n    padding: 10px;\n}\n')),document.head.insertBefore(e,document.head.firstChild)}e.ACESFilmicToneMapping=ee,e.AVERAGE=1,e.AddEquation=C,e.AddOperation=K,e.AdditiveAnimationBlendMode=St,e.AdditiveBlending=_,e.AlphaFormat=Le,e.AlwaysDepth=V,e.AlwaysStencilFunc=519,e.AmbientLight=wp,e.AmbientLightProbe=class extends Lp{constructor(e,t=1){super(void 0,t),this.isAmbientLightProbe=!0;const n=(new qn).set(e);this.sh.coefficients[0].set(n.r,n.g,n.b).multiplyScalar(2*Math.sqrt(Math.PI))}},e.AnimationClip=np,e.AnimationLoader=class extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=new up(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(function(n){try{t(o.parse(JSON.parse(n)))}catch(t){i?i(t):console.error(t),o.manager.itemError(e)}}),n,i)}parse(e){const t=[];for(let n=0;n<e.length;n++){const i=np.parse(e[n]);t.push(i)}return t}},e.AnimationMixer=gf,e.AnimationObjectGroup=class{constructor(){this.isAnimationObjectGroup=!0,this.uuid=tn(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let t=0,n=arguments.length;t!==n;++t)e[arguments[t].uuid]=t;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,i=this._parsedPaths,o=this._bindings,r=o.length;let a,s=e.length,l=this.nCachedObjects_;for(let c=0,u=arguments.length;c!==u;++c){const u=arguments[c],d=u.uuid;let h=t[d];if(void 0===h){h=s++,t[d]=h,e.push(u);for(let e=0,t=r;e!==t;++e)o[e].push(new pf(u,n[e],i[e]))}else if(h<l){a=e[h];const s=--l,c=e[s];t[c.uuid]=h,e[h]=c,t[d]=s,e[s]=u;for(let e=0,t=r;e!==t;++e){const t=o[e],r=t[s];let a=t[h];t[h]=r,void 0===a&&(a=new pf(u,n[e],i[e])),t[s]=a}}else e[h]!==a&&console.error("v3d.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=l}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,i=n.length;let o=this.nCachedObjects_;for(let r=0,a=arguments.length;r!==a;++r){const a=arguments[r],s=a.uuid,l=t[s];if(void 0!==l&&l>=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],l<o){const a=--o,s=e[a],c=--r,u=e[c];t[s.uuid]=l,e[l]=s,t[u.uuid]=a,e[a]=u,e.pop();for(let e=0,t=i;e!==t;++e){const t=n[e],i=t[a],o=t[c];t[l]=i,t[a]=o,t.pop()}}else{const o=--r,a=e[o];o>0&&(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 pf(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()}}},e.AnimationUtils=jh,e.Annotation=Rb,e.AnnotationControl=Sb,e.App=ub,e.AppUtils=gm,e.ArcCurve=qc,e.ArrayCamera=gl,e.ArrowHelper=class extends uo{constructor(e=new ci(0,0,1),t=new ci(0,0,0),n=1,i=16776960,o=.2*n,r=.2*o){super(),this.type="ArrowHelper",void 0===Vf&&(Vf=new zo,Vf.setAttribute("position",new Lo([0,0,0,0,1,0],3)),Gf=new _u(0,.5,1,5,1),Gf.translate(0,-.5,0)),this.position.copy(t),this.line=new Nc(Vf,new Ic({color:i,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new ir(Gf,new So({color:i,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,o,r)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{zf.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(zf,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}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}},e.Audio=Zp,e.AudioAnalyser=class{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}},e.AudioContext=Gp,e.AudioListener=class extends uo{constructor(){super(),this.type="AudioListener",this.context=Gp.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Hp}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(Yp,Xp,Kp),qp.set(0,0,-1).applyQuaternion(Xp),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Yp.x,e),t.positionY.linearRampToValueAtTime(Yp.y,e),t.positionZ.linearRampToValueAtTime(Yp.z,e),t.forwardX.linearRampToValueAtTime(qp.x,e),t.forwardY.linearRampToValueAtTime(qp.y,e),t.forwardZ.linearRampToValueAtTime(qp.z,e),t.upX.linearRampToValueAtTime(n.x,e),t.upY.linearRampToValueAtTime(n.y,e),t.upZ.linearRampToValueAtTime(n.z,e)}else t.setPosition(Yp.x,Yp.y,Yp.z),t.setOrientation(qp.x,qp.y,qp.z,n.x,n.y,n.z)}},e.AudioLoader=class extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=new up(this.manager);r.setResponseType("arraybuffer"),r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(function(n){try{const e=n.slice(0);Gp.getContext().decodeAudioData(e,(function(e){t(e)}))}catch(t){i?i(t):console.error(t),o.manager.itemError(e)}}),n,i)}},e.AxesHelper=class extends Uc{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=new zo;n.setAttribute("position",new Lo(t,3)),n.setAttribute("color",new Lo([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(n,new Ic({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,n){const i=new qn,o=this.geometry.attributes.color.array;return i.set(e),i.toArray(o,0),i.toArray(o,3),i.set(t),i.toArray(o,6),i.toArray(o,9),i.set(n),i.toArray(o,12),i.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}},e.BackSide=f,e.BasicDepthPacking=3200,e.BasicShadowMap=a,e.BilinearShadowMap=h,e.BlenderTextBufferGeometry=vd,e.BlenderTextGeometry=vd,e.BloomPass=Xf,e.BokehPass=Kf,e.Bone=vc,e.BooleanKeyframeTrack=Kh,e.Box2=class{constructor(e=new yn(1/0,1/0),t=new yn(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=_f.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.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.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return _f.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)}},e.Box3=hi,e.Box3Helper=Uf,e.BoxBufferGeometry=class extends rr{constructor(e,t,n,i,o,r){console.warn("v3d.BoxBufferGeometry has been renamed to v3d.BoxGeometry."),super(e,t,n,i,o,r)}},e.BoxGeometry=rr,e.BoxHelper=class extends Uc{constructor(e,t=16776960){const n=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),i=new Float32Array(24),o=new zo;o.setIndex(new To(n,1)),o.setAttribute("position",new To(i,3)),super(o,new Ic({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(e){if(void 0!==e&&console.warn("v3d.BoxHelper: .update() has no longer arguments."),void 0!==this.object&&Ff.setFromObject(this.object),Ff.isEmpty())return;const t=Ff.min,n=Ff.max,i=this.geometry.attributes.position,o=i.array;o[0]=n.x,o[1]=n.y,o[2]=n.z,o[3]=t.x,o[4]=n.y,o[5]=n.z,o[6]=t.x,o[7]=t.y,o[8]=n.z,o[9]=n.x,o[10]=t.y,o[11]=n.z,o[12]=n.x,o[13]=n.y,o[14]=t.z,o[15]=t.x,o[16]=n.y,o[17]=t.z,o[18]=t.x,o[19]=t.y,o[20]=t.z,o[21]=n.x,o[22]=t.y,o[23]=t.z,i.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}},e.BrightnessContrastPass=Zf,e.BufferAttribute=To,e.BufferGeometry=zo,e.BufferGeometryLoader=Np,e.BufferGeometryUtils=Tx,e.ByteType=ye,e.CENTER=0,e.CSVParser=mb,e.Cache=op,e.Camera=dr,e.CameraHelper=class extends Uc{constructor(e){const t=new zo,n=new Ic({color:16777215,vertexColors:!0,toneMapped:!1}),i=[],o=[],r={};function a(e,t){s(e),s(t)}function s(e){i.push(0,0,0),o.push(0,0,0),void 0===r[e]&&(r[e]=[]),r[e].push(i.length/3-1)}a("n1","n2"),a("n2","n4"),a("n4","n3"),a("n3","n1"),a("f1","f2"),a("f2","f4"),a("f4","f3"),a("f3","f1"),a("n1","f1"),a("n2","f2"),a("n3","f3"),a("n4","f4"),a("p","n1"),a("p","n2"),a("p","n3"),a("p","n4"),a("u1","u2"),a("u2","u3"),a("u3","u1"),a("c","t"),a("p","c"),a("cn1","cn2"),a("cn3","cn4"),a("cf1","cf2"),a("cf3","cf4"),t.setAttribute("position",new Lo(i,3)),t.setAttribute("color",new Lo(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();const l=new qn(16755200),c=new qn(16711680),u=new qn(43775),d=new qn(16777215),h=new qn(3355443);this.setColors(l,c,u,d,h)}setColors(e,t,n,i,o){const r=this.geometry.getAttribute("color");r.setXYZ(0,e.r,e.g,e.b),r.setXYZ(1,e.r,e.g,e.b),r.setXYZ(2,e.r,e.g,e.b),r.setXYZ(3,e.r,e.g,e.b),r.setXYZ(4,e.r,e.g,e.b),r.setXYZ(5,e.r,e.g,e.b),r.setXYZ(6,e.r,e.g,e.b),r.setXYZ(7,e.r,e.g,e.b),r.setXYZ(8,e.r,e.g,e.b),r.setXYZ(9,e.r,e.g,e.b),r.setXYZ(10,e.r,e.g,e.b),r.setXYZ(11,e.r,e.g,e.b),r.setXYZ(12,e.r,e.g,e.b),r.setXYZ(13,e.r,e.g,e.b),r.setXYZ(14,e.r,e.g,e.b),r.setXYZ(15,e.r,e.g,e.b),r.setXYZ(16,e.r,e.g,e.b),r.setXYZ(17,e.r,e.g,e.b),r.setXYZ(18,e.r,e.g,e.b),r.setXYZ(19,e.r,e.g,e.b),r.setXYZ(20,e.r,e.g,e.b),r.setXYZ(21,e.r,e.g,e.b),r.setXYZ(22,e.r,e.g,e.b),r.setXYZ(23,e.r,e.g,e.b),r.setXYZ(24,t.r,t.g,t.b),r.setXYZ(25,t.r,t.g,t.b),r.setXYZ(26,t.r,t.g,t.b),r.setXYZ(27,t.r,t.g,t.b),r.setXYZ(28,t.r,t.g,t.b),r.setXYZ(29,t.r,t.g,t.b),r.setXYZ(30,t.r,t.g,t.b),r.setXYZ(31,t.r,t.g,t.b),r.setXYZ(32,n.r,n.g,n.b),r.setXYZ(33,n.r,n.g,n.b),r.setXYZ(34,n.r,n.g,n.b),r.setXYZ(35,n.r,n.g,n.b),r.setXYZ(36,n.r,n.g,n.b),r.setXYZ(37,n.r,n.g,n.b),r.setXYZ(38,i.r,i.g,i.b),r.setXYZ(39,i.r,i.g,i.b),r.setXYZ(40,o.r,o.g,o.b),r.setXYZ(41,o.r,o.g,o.b),r.setXYZ(42,o.r,o.g,o.b),r.setXYZ(43,o.r,o.g,o.b),r.setXYZ(44,o.r,o.g,o.b),r.setXYZ(45,o.r,o.g,o.b),r.setXYZ(46,o.r,o.g,o.b),r.setXYZ(47,o.r,o.g,o.b),r.setXYZ(48,o.r,o.g,o.b),r.setXYZ(49,o.r,o.g,o.b),r.needsUpdate=!0}update(){const e=this.geometry,t=this.pointMap;Nf.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),Of("c",t,e,Nf,0,0,-1),Of("t",t,e,Nf,0,0,1),Of("n1",t,e,Nf,-1,-1,-1),Of("n2",t,e,Nf,1,-1,-1),Of("n3",t,e,Nf,-1,1,-1),Of("n4",t,e,Nf,1,1,-1),Of("f1",t,e,Nf,-1,-1,1),Of("f2",t,e,Nf,1,-1,1),Of("f3",t,e,Nf,-1,1,1),Of("f4",t,e,Nf,1,1,1),Of("u1",t,e,Nf,.7,1.1,-1),Of("u2",t,e,Nf,-.7,1.1,-1),Of("u3",t,e,Nf,0,2,-1),Of("cf1",t,e,Nf,-1,0,1),Of("cf2",t,e,Nf,1,0,1),Of("cf3",t,e,Nf,0,-1,1),Of("cf4",t,e,Nf,0,1,1),Of("cn1",t,e,Nf,-1,0,-1),Of("cn2",t,e,Nf,1,0,-1),Of("cn3",t,e,Nf,0,-1,-1),Of("cn4",t,e,Nf,0,1,-1),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}},e.CameraUtils=fb,e.CanvasBreakpointsConstraint=sA,e.CanvasFitConstraint=aA,e.CanvasTexture=class extends ni{constructor(e,t,n,i,o,r,a,s,l){super(e,t,n,i,o,r,a,s,l),this.isCanvasTexture=!0,this.needsUpdate=!0}},e.CapsuleBufferGeometry=class extends vu{constructor(e,t,n,i){console.warn("v3d.CapsuleBufferGeometry has been renamed to v3d.CapsuleGeometry."),super(e,t,n,i)}},e.CapsuleGeometry=vu,e.CatmullRomCurve3=nu,e.ChildOfConstraint=zg,e.CineonToneMapping=$,e.CircleBufferGeometry=class extends Au{constructor(e,t,n,i){console.warn("v3d.CircleBufferGeometry has been renamed to v3d.CircleGeometry."),super(e,t,n,i)}},e.CircleGeometry=Au,e.ClampToEdgeWrapping=he,e.ClearMaskPass=tm,e.Clock=Hp,e.Color=qn,e.ColorKeyframeTrack=qh,e.ColorManagement=Qn,e.Compat=vm,e.CompressedArrayTexture=class extends Yc{constructor(e,t,n,i,o,r){super(e,t,n,o,r),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=he}},e.CompressedTexture=Yc,e.CompressedTextureLoader=class extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=[],a=new Yc,s=new up(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=ve),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;t<n;++t)c(t);else s.load(e,(function(e){const n=o.parse(e,!0);if(n.isCubemap){const e=n.mipmaps.length/n.mipmapCount;for(let t=0;t<e;t++){r[t]={mipmaps:[]};for(let e=0;e<n.mipmapCount;e++)r[t].mipmaps.push(n.mipmaps[t*n.mipmapCount+e]),r[t].format=n.format,r[t].width=n.width,r[t].height=n.height}a.image=r}else a.image.width=n.width,a.image.height=n.height,a.mipmaps=n.mipmaps;1===n.mipmapCount&&(a.minFilter=ve),a.format=n.format,a.needsUpdate=!0,t&&t(a)}),n,i);return a}},e.ConeBufferGeometry=class extends xu{constructor(e,t,n,i,o,r,a){console.warn("v3d.ConeBufferGeometry has been renamed to v3d.ConeGeometry."),super(e,t,n,i,o,r,a)}},e.ConeGeometry=xu,e.Constraint=Ng,e.CopyLocationConstraint=Qg,e.CopyRotationConstraint=Xg,e.CopyScaleConstraint=Jg,e.CopyTransformsConstraint=ov,e.CubeCamera=fr,e.CubeCopy=Am,e.CubeReflectionMapping=ae,e.CubeReflectionProbe=Im,e.CubeRefractionMapping=se,e.CubeTexture=mr,e.CubeTextureHelper=Mb,e.CubeTextureLoader=class extends sp{constructor(e){super(e)}load(e,t,n,i){const o=new mr,r=new dp(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;t<e.length;++t)s(t);return o}},e.CubeUVReflectionMapping=ue,e.CubicBezierCurve=au,e.CubicBezierCurve3=su,e.CubicInterpolant=Yh,e.CullFaceBack=o,e.CullFaceFront=r,e.CullFaceFrontBack=3,e.CullFaceNone=i,e.Curve=Xc,e.CurvePath=fu,e.CustomBlending=b,e.CustomToneMapping=te,e.CylinderBufferGeometry=class extends _u{constructor(e,t,n,i,o,r,a,s){console.warn("v3d.CylinderBufferGeometry has been renamed to v3d.CylinderGeometry."),super(e,t,n,i,o,r,a,s)}},e.CylinderGeometry=_u,e.Cylindrical=class{constructor(e=1,t=0,n=0){return this.radius=e,this.theta=t,this.y=n,this}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return(new this.constructor).copy(this)}},e.DampedTrackConstraint=mv,e.Data3DTexture=ai,e.DataArrayTexture=ri,e.DataTexture=Ac,e.DataTexture2DArray=class extends ri{constructor(e,t,n,i){console.warn("v3d.DataTexture2DArray has been renamed to DataArrayTexture."),super(e,t,n,i)}},e.DataTexture3D=class extends ai{constructor(e,t,n,i){console.warn("v3d.DataTexture3D has been renamed to Data3DTexture."),super(e,t,n,i)}},e.DataTextureLoader=hp,e.DataUtils=jf,e.DecrementStencilOp=7683,e.DecrementWrapStencilOp=kt,e.DefaultLoadingManager=ap,e.DepthFormat=Oe,e.DepthStencilFormat=Fe,e.DepthTexture=xl,e.Detector=wl,e.DirectionalLight=Ep,e.DirectionalLightHelper=class extends uo{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",void 0===t&&(t=1);let i=new zo;i.setAttribute("position",new Lo([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const o=new Ic({fog:!1,toneMapped:!1});this.lightPlane=new Nc(i,o),this.add(this.lightPlane),i=new zo,i.setAttribute("position",new Lo([0,0,0,0,0,1],3)),this.targetLine=new Nc(i,o),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),Lf.setFromMatrixPosition(this.light.matrixWorld),Pf.setFromMatrixPosition(this.light.target.matrixWorld),Bf.subVectors(Pf,Lf),this.lightPlane.lookAt(Pf),void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Pf),this.targetLine.scale.z=Bf.length()}},e.DiscreteInterpolant=Ld,e.DodecahedronBufferGeometry=class extends bu{constructor(e,t){console.warn("v3d.DodecahedronBufferGeometry has been renamed to v3d.DodecahedronGeometry."),super(e,t)}},e.DodecahedronGeometry=bu,e.DoubleSide=m,e.DstAlphaFactor=D,e.DstColorFactor=O,e.DynamicCopyUsage=35050,e.DynamicDrawUsage=35048,e.DynamicReadUsage=35049,e.ESMDistancePacking=Dt,e.ESMShadowMap=u,e.EdgesGeometry=wu,e.EffectComposer=Rm,e.EllipseCurve=Kc,e.EqualDepth=Q,e.EqualStencilFunc=514,e.EquiCube=db,e.EquirectangularReflectionMapping=le,e.EquirectangularRefractionMapping=ce,e.Euler=Ki,e.EventDispatcher=qt,e.ExtrudeBufferGeometry=class extends id{constructor(e,t){console.warn("v3d.ExtrudeBufferGeometry has been renamed to v3d.ExtrudeGeometry."),super(e,t)}},e.ExtrudeGeometry=id,e.FXAAPass=Jf,e.FileLoader=up,e.FilmicBlenderToneMapping=oe,e.FirstPersonControls=Qm,e.FixOrthoZoomConstraint=eA,e.Float16BufferAttribute=class extends To{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}},e.Float32BufferAttribute=Lo,e.Float64BufferAttribute=class extends To{constructor(e,t,n){super(new Float64Array(e),t,n)}},e.FloatType=Ee,e.FloorConstraint=yv,e.FlyingControls=Km,e.Fog=kl,e.FogExp2=Gl,e.Font=ug,e.FramebufferTexture=class extends ni{constructor(e,t,n){super({width:e,height:t}),this.isFramebufferTexture=!0,this.format=n,this.magFilter=fe,this.minFilter=fe,this.generateMipmaps=!1,this.needsUpdate=!0}},e.FrontSide=p,e.Frustum=Cr,e.GLBufferAttribute=class{constructor(e,t,n,i,o){this.isGLBufferAttribute=!0,this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=i,this.count=o,this.version=0}set needsUpdate(e){!0===e&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}},e.GLSL1="100",e.GLSL3=Wt,e.GLTFExporter=Nb,e.GLTFLoader=i_,e.GTAOMapGenerator=gx,e.GraphUtils=Pd,e.GrayscalePass=$f,e.GreaterDepth=H,e.GreaterEqualDepth=W,e.GreaterEqualStencilFunc=518,e.GreaterStencilFunc=516,e.GridHelper=class extends Uc{constructor(e=10,t=10,n=4473924,i=8947848){n=new qn(n),i=new qn(i);const o=t/2,r=e/t,a=e/2,s=[],l=[];for(let e=0,c=0,u=-a;e<=t;e++,u+=r){s.push(-a,0,u,a,0,u),s.push(u,0,-a,u,0,a);const t=e===o?n:i;t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3,t.toArray(l,c),c+=3}const c=new zo;c.setAttribute("position",new Lo(s,3)),c.setAttribute("color",new Lo(l,3));super(c,new Ic({vertexColors:!0,toneMapped:!1})),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},e.Group=vl,e.HalfFloatType=we,e.HemisphereLight=mp,e.HemisphereLightHelper=class extends uo{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const i=new ad(t);i.rotateY(.5*Math.PI),this.material=new So({wireframe:!0,fog:!1,toneMapped:!1}),void 0===this.color&&(this.material.vertexColors=!0);const o=i.getAttribute("position"),r=new Float32Array(3*o.count);i.setAttribute("color",new To(r,3)),this.add(new ir(i,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");If.copy(this.light.color),Rf.copy(this.light.groundColor);for(let e=0,n=t.count;e<n;e++){const i=e<n/2?If:Rf;t.setXYZ(e,i.r,i.g,i.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(Tf.setFromMatrixPosition(this.light.matrixWorld).negate())}},e.HemisphereLightProbe=class extends Lp{constructor(e,t,n=1){super(void 0,n),this.isHemisphereLightProbe=!0;const i=(new qn).set(e),o=(new qn).set(t),r=new ci(i.r,i.g,i.b),a=new ci(o.r,o.g,o.b),s=Math.sqrt(Math.PI),l=s*Math.sqrt(.75);this.sh.coefficients[0].copy(r).add(a).multiplyScalar(s),this.sh.coefficients[1].copy(r).sub(a).multiplyScalar(l)}},e.IBLEnvironmentNone=3,e.IBLEnvironmentPMREM=0,e.IBLEnvironmentProbe=2,e.IBLEnvironmentProbeCubemap=1,e.IcosahedronBufferGeometry=class extends rd{constructor(e,t){console.warn("v3d.IcosahedronBufferGeometry has been renamed to v3d.IcosahedronGeometry."),super(e,t)}},e.IcosahedronGeometry=rd,e.ImageBitmapLoader=zp,e.ImageLoader=dp,e.ImageUtils=Jn,e.ImmediateRenderObject=function(){console.error("v3d.ImmediateRenderObject has been removed.")},e.IncrementStencilOp=7682,e.IncrementWrapStencilOp=Gt,e.InstancedBufferAttribute=bc,e.InstancedBufferGeometry=Dp,e.InstancedInterleavedBuffer=class extends Ql{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}},e.InstancedMesh=Tc,e.Int16BufferAttribute=class extends To{constructor(e,t,n){super(new Int16Array(e),t,n)}},e.Int32BufferAttribute=class extends To{constructor(e,t,n){super(new Int32Array(e),t,n)}},e.Int8BufferAttribute=class extends To{constructor(e,t,n){super(new Int8Array(e),t,n)}},e.IntType=Me,e.InterleavedBuffer=Ql,e.InterleavedBufferAttribute=Hl,e.Interpolant=Rd,e.InterpolateDiscrete=At,e.InterpolateLinear=_t,e.InterpolateSmooth=xt,e.InvertStencilOp=5386,e.KeepStencilOp=zt,e.KeyframeTrack=Xh,e.Keys=Dm,e.LOD=uc,e.LatheBufferGeometry=class extends gu{constructor(e,t,n,i){console.warn("v3d.LatheBufferGeometry has been renamed to v3d.LatheGeometry."),super(e,t,n,i)}},e.LatheGeometry=gu,e.Layers=qi,e.LessDepth=G,e.LessEqualDepth=k,e.LessEqualStencilFunc=515,e.LessStencilFunc=513,e.Light=fp,e.LightProbe=Lp,e.LightProbeGenerator=yx,e.LimitDistanceConstraint=Ev,e.LimitLocationConstraint=wv,e.LimitRotationConstraint=Iv,e.LimitScaleConstraint=Rv,e.Line=Nc,e.Line3=bf,e.LineBasicMaterial=Ic,e.LineCurve=lu,e.LineCurve3=cu,e.LineDashedMaterial=Td,e.LineHTML=xb,e.LineLoop=zc,e.LineSegments=Uc,e.LinearDepthPacking=Pt,e.LinearEncoding=It,e.LinearFilter=ve,e.LinearInterpolant=Vd,e.LinearMipMapLinearFilter=1008,e.LinearMipMapNearestFilter=1007,e.LinearMipmapLinearFilter=_e,e.LinearMipmapNearestFilter=Ae,e.LinearSRGBColorSpace=Ut,e.LinearToneMapping=Z,e.Loader=sp,e.LoaderUtils=Bp,e.LoadingManager=rp,e.LockedTrackConstraint=Gv,e.LogarithmicMaxToneMapping=ne,e.LoopOnce=mt,e.LoopPingPong=vt,e.LoopRepeat=gt,e.LuminanceAlphaFormat=Ne,e.LuminanceFormat=De,e.MOD_SUITE=jt,e.MOUSE=n,e.MaskPass=em,e.Material=Mo,e.MaterialLoader=Pp,e.MaterialUtils=xm,e.MathUtils=xn,e.Matrix3=bn,e.Matrix4=zi,e.MaxEquation=w,e.Mesh=ir,e.MeshBVH=ky,e.MeshBasicMaterial=So,e.MeshDepthMaterial=Ks,e.MeshDistanceMaterial=qs,e.MeshLambertMaterial=Ed,e.MeshLine=nm,e.MeshLineIndexed=am,e.MeshLineMaterial=sm,e.MeshMaskMaterial=Id,e.MeshMatcapMaterial=wd,e.MeshNodeMaterial=Bh,e.MeshNormalMaterial=Sd,e.MeshPhongMaterial=Cd,e.MeshPhysicalMaterial=bd,e.MeshStandardMaterial=yd,e.MeshToonMaterial=Md,e.MinEquation=E,e.MirroredRepeatWrapping=pe,e.MixOperation=X,e.MotionPathConstraint=t_,e.MultiplyBlending=y,e.MultiplyOperation=Y,e.NearestFilter=fe,e.NearestMipMapLinearFilter=1005,e.NearestMipMapNearestFilter=1004,e.NearestMipmapLinearFilter=ge,e.NearestMipmapNearestFilter=me,e.NeverDepth=z,e.NeverStencilFunc=512,e.NoBlending=v,e.NoColorSpace="",e.NoOIT=Kt,e.NoToneMapping=q,e.NormalAnimationBlendMode=Mt,e.NormalBlending=A,e.NotEqualDepth=j,e.NotEqualStencilFunc=517,e.NumberKeyframeTrack=Zh,e.OITWeighted=1,e.Object3D=uo,e.ObjectLoader=class extends sp{constructor(e){super(e)}load(e,t,n,i){const o=this,r=""===this.path?Bp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const a=new up(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){let r=null;try{r=JSON.parse(n)}catch(t){return void 0!==i&&i(t),void console.error("v3d:ObjectLoader: Can't parse "+e+".",t.message)}const a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())return void 0!==i&&i(new Error("v3d.ObjectLoader: Can't load "+e)),void console.error("v3d.ObjectLoader: Can't load "+e);o.parse(r,t)}),n,i)}async loadAsync(e,t){const n=""===this.path?Bp.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||n;const i=new up(this.manager);i.setPath(this.path),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials);const o=await i.loadAsync(e,t),r=JSON.parse(o),a=r.metadata;if(void 0===a||void 0===a.type||"geometry"===a.type.toLowerCase())throw new Error("v3d.ObjectLoader: Can't load "+e);return await this.parseAsync(r)}parse(e,t){const n=this.parseAnimations(e.animations),i=this.parseShapes(e.shapes),o=this.parseGeometries(e.geometries,i),r=this.parseImages(e.images,(function(){void 0!==t&&t(l)})),a=this.parseTextures(e.textures,r),s=this.parseMaterials(e.materials,a),l=this.parseObject(e.object,o,s,a,n),c=this.parseSkeletons(e.skeletons,l);if(this.bindSkeletons(l,c),void 0!==t){let e=!1;for(const t in r)if(r[t].data instanceof HTMLImageElement){e=!0;break}!1===e&&t(l)}return l}async parseAsync(e){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),i=this.parseGeometries(e.geometries,n),o=await this.parseImagesAsync(e.images),r=this.parseTextures(e.textures,o),a=this.parseMaterials(e.materials,r),s=this.parseObject(e.object,i,a,r,t),l=this.parseSkeletons(e.skeletons,s);return this.bindSkeletons(s,l),s}parseShapes(e){const t={};if(void 0!==e)for(let n=0,i=e.length;n<i;n++){const i=(new Tu).fromJSON(e[n]);t[i.uuid]=i}return t}parseSkeletons(e,t){const n={},i={};if(t.traverse((function(e){e.isBone&&(i[e.uuid]=e)})),void 0!==e)for(let t=0,o=e.length;t<o;t++){const o=(new yc).fromJSON(e[t],i);n[o.uuid]=o}return n}parseGeometries(e,t){const n={};if(void 0!==e){const i=new Np;for(let o=0,r=e.length;o<r;o++){let r;const a=e[o];switch(a.type){case"BufferGeometry":case"InstancedBufferGeometry":r=i.parse(a);break;default:a.type in _d?r=_d[a.type].fromJSON(a,t):console.warn(`v3d.ObjectLoader: Unsupported geometry type "${a.type}"`)}r.uuid=a.uuid,void 0!==a.name&&(r.name=a.name),!0===r.isBufferGeometry&&void 0!==a.userData&&(r.userData=a.userData),n[a.uuid]=r}}return n}parseMaterials(e,t){const n={},i={};if(void 0!==e){const o=new Pp;o.setTextures(t);for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0===n[r.uuid]&&(n[r.uuid]=o.parse(r)),i[r.uuid]=n[r.uuid]}}return i}parseAnimations(e){const t={};if(void 0!==e)for(let n=0;n<e.length;n++){const i=e[n],o=np.parse(i);t[o.uuid]=o}return t}parseImages(e,t){const n=this,i={};let o;function r(e){if("string"==typeof e){const t=e;return function(e){return n.manager.itemStart(e),o.load(e,(function(){n.manager.itemEnd(e)}),void 0,(function(){n.manager.itemError(e),n.manager.itemEnd(e)}))}(/^(\/\/)|([a-z]+:(\/\/)?)/i.test(t)?t:n.resourcePath+t)}return e.data?{data:wn(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){const n=new rp(t);o=new dp(n),o.setCrossOrigin(this.crossOrigin);for(let t=0,n=e.length;t<n;t++){const n=e[t],o=n.url;if(Array.isArray(o)){const e=[];for(let t=0,n=o.length;t<n;t++){const n=r(o[t]);null!==n&&(n instanceof HTMLImageElement?e.push(n):e.push(new Ac(n.data,n.width,n.height)))}i[n.uuid]=new $n(e)}else{const e=r(n.url);i[n.uuid]=new $n(e)}}}return i}async parseImagesAsync(e){const t=this,n={};let i;async function o(e){if("string"==typeof e){const n=e,o=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(n)?n:t.resourcePath+n;return await i.loadAsync(o)}return e.data?{data:wn(e.type,e.data),width:e.width,height:e.height}:null}if(void 0!==e&&e.length>0){i=new dp(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t<i;t++){const i=e[t],r=i.url;if(Array.isArray(r)){const e=[];for(let t=0,n=r.length;t<n;t++){const n=r[t],i=await o(n);null!==i&&(i instanceof HTMLImageElement?e.push(i):e.push(new Ac(i.data,i.width,i.height)))}n[i.uuid]=new $n(e)}else{const e=await o(i.url);n[i.uuid]=new $n(e)}}}return n}parseTextures(e,t){function n(e,t){return"number"==typeof e?e:(console.warn("v3d.ObjectLoader.parseTexture: Constant should be in numeric form.",e),t[e])}const i={};if(void 0!==e)for(let o=0,r=e.length;o<r;o++){const r=e[o];void 0===r.image&&console.warn('v3d.ObjectLoader: No "image" specified for',r.uuid),void 0===t[r.image]&&console.warn("v3d.ObjectLoader: Undefined image",r.image);const a=t[r.image],s=a.data;let l;Array.isArray(s)?(l=new mr,6===s.length&&(l.needsUpdate=!0)):(l=s&&s.data?new Ac:new ni,s&&(l.needsUpdate=!0)),l.source=a,l.uuid=r.uuid,void 0!==r.name&&(l.name=r.name),void 0!==r.mapping&&(l.mapping=n(r.mapping,Op)),void 0!==r.offset&&l.offset.fromArray(r.offset),void 0!==r.repeat&&l.repeat.fromArray(r.repeat),void 0!==r.center&&l.center.fromArray(r.center),void 0!==r.rotation&&(l.rotation=r.rotation),void 0!==r.wrap&&(l.wrapS=n(r.wrap[0],Fp),l.wrapT=n(r.wrap[1],Fp)),void 0!==r.format&&(l.format=r.format),void 0!==r.type&&(l.type=r.type),void 0!==r.encoding&&(l.encoding=r.encoding),void 0!==r.minFilter&&(l.minFilter=n(r.minFilter,Up)),void 0!==r.magFilter&&(l.magFilter=n(r.magFilter,Up)),void 0!==r.anisotropy&&(l.anisotropy=r.anisotropy),void 0!==r.flipY&&(l.flipY=r.flipY),void 0!==r.generateMipmaps&&(l.generateMipmaps=r.generateMipmaps),void 0!==r.premultiplyAlpha&&(l.premultiplyAlpha=r.premultiplyAlpha),void 0!==r.unpackAlignment&&(l.unpackAlignment=r.unpackAlignment),void 0!==r.userData&&(l.userData=r.userData),i[r.uuid]=l}return i}parseObject(e,t,n,i,o){let r,a,s;function l(e){return void 0===t[e]&&console.warn("v3d.ObjectLoader: Undefined geometry",e),t[e]}function c(e){if(void 0!==e){if(Array.isArray(e)){const t=[];for(let i=0,o=e.length;i<o;i++){const o=e[i];void 0===n[o]&&console.warn("v3d.ObjectLoader: Undefined material",o),t.push(n[o])}return t}return void 0===n[e]&&console.warn("v3d.ObjectLoader: Undefined material",e),n[e]}}function u(e){return void 0===i[e]&&console.warn("v3d.ObjectLoader: Undefined texture",e),i[e]}switch(e.type){case"Scene":r=new zr,void 0!==e.background&&(Number.isInteger(e.background)?r.background=new qn(e.background):r.background=u(e.background)),void 0!==e.environment&&(r.environment=u(e.environment)),void 0!==e.fog&&("Fog"===e.fog.type?r.fog=new kl(e.fog.color,e.fog.near,e.fog.far):"FogExp2"===e.fog.type&&(r.fog=new Gl(e.fog.color,e.fog.density))),void 0!==e.backgroundBlurriness&&(r.backgroundBlurriness=e.backgroundBlurriness);break;case"PerspectiveCamera":r=new hr(e.fov,e.aspect,e.near,e.far),void 0!==e.focus&&(r.focus=e.focus),void 0!==e.zoom&&(r.zoom=e.zoom),void 0!==e.filmGauge&&(r.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(r.filmOffset=e.filmOffset),void 0!==e.view&&(r.view=Object.assign({},e.view));break;case"OrthographicCamera":r=new Fr(e.left,e.right,e.top,e.bottom,e.near,e.far),void 0!==e.zoom&&(r.zoom=e.zoom),void 0!==e.view&&(r.view=Object.assign({},e.view));break;case"AmbientLight":r=new wp(e.color,e.intensity);break;case"DirectionalLight":r=new Ep(e.color,e.intensity);break;case"PointLight":r=new bp(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":r=new Ip(e.color,e.intensity,e.width,e.height);break;case"SpotLight":r=new vp(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay);break;case"HemisphereLight":r=new mp(e.color,e.groundColor,e.intensity);break;case"LightProbe":r=(new Lp).fromJSON(e);break;case"SkinnedMesh":a=l(e.geometry),s=c(e.material),r=new gc(a,s),void 0!==e.bindMode&&(r.bindMode=e.bindMode),void 0!==e.bindMatrix&&r.bindMatrix.fromArray(e.bindMatrix),void 0!==e.skeleton&&(r.skeleton=e.skeleton);break;case"Mesh":a=l(e.geometry),s=c(e.material),r=new ir(a,s);break;case"InstancedMesh":a=l(e.geometry),s=c(e.material);const t=e.count,n=e.instanceMatrix,i=e.instanceColor;r=new Tc(a,s,t),r.instanceMatrix=new bc(new Float32Array(n.array),16),void 0!==i&&(r.instanceColor=new bc(new Float32Array(i.array),i.itemSize));break;case"LOD":r=new uc;break;case"Line":r=new Nc(l(e.geometry),c(e.material));break;case"LineLoop":r=new zc(l(e.geometry),c(e.material));break;case"LineSegments":r=new Uc(l(e.geometry),c(e.material));break;case"PointCloud":case"Points":r=new Hc(l(e.geometry),c(e.material));break;case"Sprite":r=new ac(c(e.material));break;case"Group":r=new vl;break;case"Bone":r=new vc;break;default:r=new uo}if(r.uuid=e.uuid,void 0!==e.name&&(r.name=e.name),void 0!==e.matrix?(r.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(r.matrixAutoUpdate=e.matrixAutoUpdate),r.matrixAutoUpdate&&r.matrix.decompose(r.position,r.quaternion,r.scale)):(void 0!==e.position&&r.position.fromArray(e.position),void 0!==e.rotation&&r.rotation.fromArray(e.rotation),void 0!==e.quaternion&&r.quaternion.fromArray(e.quaternion),void 0!==e.scale&&r.scale.fromArray(e.scale)),void 0!==e.castShadow&&(r.castShadow=e.castShadow),void 0!==e.receiveShadow&&(r.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.bias&&(r.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(r.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(r.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&r.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(r.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(r.visible=e.visible),void 0!==e.frustumCulled&&(r.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(r.renderOrder=e.renderOrder),void 0!==e.userData&&(r.userData=e.userData),void 0!==e.layers&&(r.layers.mask=e.layers),void 0!==e.children){const a=e.children;for(let e=0;e<a.length;e++)r.add(this.parseObject(a[e],t,n,i,o))}if(void 0!==e.animations){const t=e.animations;for(let e=0;e<t.length;e++){const n=t[e];r.animations.push(o[n])}}if("LOD"===e.type){void 0!==e.autoUpdate&&(r.autoUpdate=e.autoUpdate);const t=e.levels;for(let e=0;e<t.length;e++){const n=t[e],i=r.getObjectByProperty("uuid",n.object);void 0!==i&&r.addLevel(i,n.distance,n.hysteresis)}}return r}bindSkeletons(e,t){0!==Object.keys(t).length&&e.traverse((function(e){if(!0===e.isSkinnedMesh&&void 0!==e.skeleton){const n=t[e.skeleton];void 0===n?console.warn("v3d.ObjectLoader: No skeleton found with UUID:",e.skeleton):e.bind(n,e.bindMatrix)}}))}},e.ObjectSpaceNormalMap=Ot,e.OctahedronBufferGeometry=class extends ad{constructor(e,t){console.warn("v3d.OctahedronBufferGeometry has been renamed to v3d.OctahedronGeometry."),super(e,t)}},e.OctahedronGeometry=ad,e.OneFactor=I,e.OneMinusDstAlphaFactor=N,e.OneMinusDstColorFactor=F,e.OneMinusSrcAlphaFactor=B,e.OneMinusSrcColorFactor=L,e.OrbitControls=Pg,e.OrthographicCamera=Fr,e.OutlinePass=lm,e.PCFShadowMap=s,e.PCFShadowMapPoissonDisk=d,e.PCFSoftShadowMap=l,e.PMREMGenerator=Zr,e.Pass=Tl,e.Path=mu,e.PerspectiveCamera=hr,e.PhysicalMaxToneMapping=ie,e.Plane=xr,e.PlaneBufferGeometry=class extends Er{constructor(e,t,n,i){console.warn("v3d.PlaneBufferGeometry has been renamed to v3d.PlaneGeometry."),super(e,t,n,i)}},e.PlaneGeometry=Er,e.PlaneHelper=class extends Nc{constructor(e,t=1,n=16776960){const i=n,o=new zo;o.setAttribute("position",new Lo([1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),o.computeBoundingSphere(),super(o,new Ic({color:i,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const r=new zo;r.setAttribute("position",new Lo([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new ir(r,new So({color:i,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}},e.PointLight=bp,e.PointLightHelper=class extends ir{constructor(e,t,n){super(new cd(t,4,2),new So({wireframe:!0,fog:!1,toneMapped:!1})),this.light=e,this.color=n,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)}},e.Points=Hc,e.PointsMaterial=Vc,e.PolarGridHelper=class extends Uc{constructor(e=10,t=16,n=8,i=64,o=4473924,r=8947848){o=new qn(o),r=new qn(r);const a=[],s=[];if(t>1)for(let n=0;n<t;n++){const i=n/t*(2*Math.PI),l=Math.sin(i)*e,c=Math.cos(i)*e;a.push(0,0,0),a.push(l,0,c);const u=1&n?o:r;s.push(u.r,u.g,u.b),s.push(u.r,u.g,u.b)}for(let t=0;t<n;t++){const l=1&t?o:r,c=e-e/n*t;for(let e=0;e<i;e++){let t=e/i*(2*Math.PI),n=Math.sin(t)*c,o=Math.cos(t)*c;a.push(n,0,o),s.push(l.r,l.g,l.b),t=(e+1)/i*(2*Math.PI),n=Math.sin(t)*c,o=Math.cos(t)*c,a.push(n,0,o),s.push(l.r,l.g,l.b)}}const l=new zo;l.setAttribute("position",new Lo(a,3)),l.setAttribute("color",new Lo(s,3));super(l,new Ic({vertexColors:!0,toneMapped:!1})),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}},e.PolyhedronBufferGeometry=class extends yu{constructor(e,t,n,i){console.warn("v3d.PolyhedronBufferGeometry has been renamed to v3d.PolyhedronGeometry."),super(e,t,n,i)}},e.PolyhedronGeometry=yu,e.PositionalAudio=class extends Zp{constructor(e){super(e),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}disconnect(){super.disconnect(),this.panner.disconnect(this.gain)}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),!0===this.hasPlaybackControl&&!1===this.isPlaying)return;this.matrixWorld.decompose(Jp,$p,ef),tf.set(0,0,1).applyQuaternion($p);const t=this.panner;if(t.positionX){const e=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Jp.x,e),t.positionY.linearRampToValueAtTime(Jp.y,e),t.positionZ.linearRampToValueAtTime(Jp.z,e),t.orientationX.linearRampToValueAtTime(tf.x,e),t.orientationY.linearRampToValueAtTime(tf.y,e),t.orientationZ.linearRampToValueAtTime(tf.z,e)}else t.setPosition(Jp.x,Jp.y,Jp.z),t.setOrientation(tf.x,tf.y,tf.z)}},e.Preloader=yb,e.PropertyBinding=pf,e.PropertyMixer=nf,e.PuzzlesLoader=Cb,e.QuadraticBezierCurve=uu,e.QuadraticBezierCurve3=du,e.Quaternion=li,e.QuaternionKeyframeTrack=$h,e.QuaternionLinearInterpolant=Jh,e.REVISION=t,e.RGBADepthPacking=Lt,e.RGBADistancePacking=Bt,e.RGBAFormat=Be,e.RGBAIntegerFormat=ke,e.RGBA_ASTC_10x10_Format=dt,e.RGBA_ASTC_10x5_Format=lt,e.RGBA_ASTC_10x6_Format=ct,e.RGBA_ASTC_10x8_Format=ut,e.RGBA_ASTC_12x10_Format=ht,e.RGBA_ASTC_12x12_Format=pt,e.RGBA_ASTC_4x4_Format=et,e.RGBA_ASTC_5x4_Format=tt,e.RGBA_ASTC_5x5_Format=nt,e.RGBA_ASTC_6x5_Format=it,e.RGBA_ASTC_6x6_Format=ot,e.RGBA_ASTC_8x5_Format=rt,e.RGBA_ASTC_8x6_Format=at,e.RGBA_ASTC_8x8_Format=st,e.RGBA_BPTC_Format=ft,e.RGBA_ETC2_EAC_Format=$e,e.RGBA_PVRTC_2BPPV1_Format=qe,e.RGBA_PVRTC_4BPPV1_Format=Ke,e.RGBA_S3TC_DXT1_Format=We,e.RGBA_S3TC_DXT3_Format=He,e.RGBA_S3TC_DXT5_Format=je,e.RGBELoader=ng,e.RGBFormat=Pe,e.RGB_ETC1_Format=Ze,e.RGB_ETC2_Format=Je,e.RGB_PVRTC_2BPPV1_Format=Xe,e.RGB_PVRTC_4BPPV1_Format=Ye,e.RGB_S3TC_DXT1_Format=Qe,e.RGFormat=Ve,e.RGIntegerFormat=Ge,e.RawShaderMaterial=Ur,e.Ray=Ui,e.Raycaster=yl,e.RectAreaLight=Ip,e.RectAreaLightUniformsLib=cg,e.RedFormat=Ue,e.RedIntegerFormat=ze,e.ReflectionProbeTypeBox=2,e.ReflectionProbeTypeInfinite=0,e.ReflectionProbeTypeSphere=1,e.ReinhardToneMapping=J,e.RenderPass=cm,e.RenderUtils=Cm,e.RepeatWrapping=de,e.ReplaceStencilOp=Vt,e.ReverseSubtractEquation=S,e.RingBufferGeometry=class extends sd{constructor(e,t,n,i,o,r){console.warn("v3d.RingBufferGeometry has been renamed to v3d.RingGeometry."),super(e,t,n,i,o,r)}},e.RingGeometry=sd,e.SAH=2,e.SRGBColorSpace=Ft,e.SSAARenderPass=um,e.SSAOPass=function(){console.error("v3d.SSAOPass has been removed, use v3d.GTAOMapGenerator instead")},e.Scene=zr,e.SceneBackground=qn,e.SceneUtils=Nx,e.ShaderChunk=wr,e.ShaderLib=Ir,e.ShaderMaterial=ur,e.ShaderPass=qf,e.ShadowMaterial=xd,e.Shape=Tu,e.ShapeBufferGeometry=class extends ld{constructor(e,t){console.warn("v3d.ShapeBufferGeometry has been renamed to v3d.ShapeGeometry."),super(e,t)}},e.ShapeGeometry=ld,e.ShapePath=kf,e.ShapeUtils=ed,e.ShortType=be,e.SimplePreloader=bb,e.Skeleton=yc,e.SkeletonHelper=class extends Uc{constructor(e){const t=wf(e),n=new zo,i=[],o=[],r=new qn(0,0,1),a=new qn(0,1,0);for(let e=0;e<t.length;e++){const n=t[e];n.parent&&n.parent.isBone&&(i.push(0,0,0),i.push(0,0,0),o.push(r.r,r.g,r.b),o.push(a.r,a.g,a.b))}n.setAttribute("position",new Lo(i,3)),n.setAttribute("color",new Lo(o,3));super(n,new Ic({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0})),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}updateMatrixWorld(e){const t=this.bones,n=this.geometry,i=n.getAttribute("position");Ef.copy(this.root.matrixWorld).invert();for(let e=0,n=0;e<t.length;e++){const o=t[e];o.parent&&o.parent.isBone&&(Sf.multiplyMatrices(Ef,o.matrixWorld),Mf.setFromMatrixPosition(Sf),i.setXYZ(n,Mf.x,Mf.y,Mf.z),Sf.multiplyMatrices(Ef,o.parent.matrixWorld),Mf.setFromMatrixPosition(Sf),i.setXYZ(n+1,Mf.x,Mf.y,Mf.z),n+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}dispose(){this.geometry.dispose(),this.material.dispose()}},e.SkinnedMesh=gc,e.Source=$n,e.Sphere=Ri,e.SphereBufferGeometry=class extends cd{constructor(e,t,n,i,o,r,a){console.warn("v3d.SphereBufferGeometry has been renamed to v3d.SphereGeometry."),super(e,t,n,i,o,r,a)}},e.SphereGeometry=cd,e.Spherical=Yd,e.SphericalHarmonics3=Rp,e.SplineCurve=hu,e.SpotLight=vp,e.SpotLightHelper=class extends uo{constructor(e,t){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new zo,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,n=32;e<n;e++,t++){const o=e/n*Math.PI*2,r=t/n*Math.PI*2;i.push(Math.cos(o),Math.sin(o),1,Math.cos(r),Math.sin(r),1)}n.setAttribute("position",new Lo(i,3));const o=new Ic({fog:!1,toneMapped:!1});this.cone=new Uc(n,o),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1);const e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),Cf.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Cf),void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}},e.Sprite=ac,e.SpriteMaterial=jl,e.SrcAlphaFactor=P,e.SrcAlphaSaturateFactor=U,e.SrcColorFactor=R,e.StaticCopyUsage=35046,e.StaticDrawUsage=Qt,e.StaticReadUsage=35045,e.Stats=Ox,e.StereoCamera=class{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new hr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new hr,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,Wp.copy(e.projectionMatrix);const n=t.eyeSep/2,i=n*t.near/t.focus,o=t.near*Math.tan($t*t.fov*.5)/t.zoom;let r,a;Qp.elements[12]=-n,kp.elements[12]=n,r=-o*t.aspect+i,a=o*t.aspect+i,Wp.elements[0]=2*t.near/(a-r),Wp.elements[8]=(a+r)/(a-r),this.cameraL.projectionMatrix.copy(Wp),r=-o*t.aspect-i,a=o*t.aspect-i,Wp.elements[0]=2*t.near/(a-r),Wp.elements[8]=(a+r)/(a-r),this.cameraR.projectionMatrix.copy(Wp)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(Qp),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(kp)}},e.StreamCopyUsage=35042,e.StreamDrawUsage=35040,e.StreamReadUsage=35041,e.StringKeyframeTrack=ep,e.SubtractEquation=M,e.SubtractiveBlending=x,e.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e.TTFLoader=tg,e.TangentSpaceNormalMap=Nt,e.TargetConstraint=Og,e.TeapotGeometry=Ad,e.TetrahedronBufferGeometry=class extends ud{constructor(e,t){console.warn("v3d.TetrahedronBufferGeometry has been renamed to v3d.TetrahedronGeometry."),super(e,t)}},e.TetrahedronGeometry=ud,e.TextGeometry=gd,e.Texture=ni,e.TextureLoader=pp,e.ToneMapPass=pm,e.TorusBufferGeometry=class extends dd{constructor(e,t,n,i,o){console.warn("v3d.TorusBufferGeometry has been renamed to v3d.TorusGeometry."),super(e,t,n,i,o)}},e.TorusGeometry=dd,e.TorusKnotBufferGeometry=class extends hd{constructor(e,t,n,i,o,r){console.warn("v3d.TorusKnotBufferGeometry has been renamed to v3d.TorusKnotGeometry."),super(e,t,n,i,o,r)}},e.TorusKnotGeometry=hd,e.TrackToConstraint=$v,e.Triangle=bo,e.TriangleFanDrawMode=Tt,e.TriangleStripDrawMode=wt,e.TrianglesDrawMode=Et,e.TubeBufferGeometry=class extends pd{constructor(e,t,n,i,o){console.warn("v3d.TubeBufferGeometry has been renamed to v3d.TubeGeometry."),super(e,t,n,i,o)}},e.TubeGeometry=pd,e.TweenCameraController=Om,e.TweenLinear=Xt,e.TweenSpherical=1,e.TwoPassDoubleSide=g,e.UVMapping=re,e.Uint16BufferAttribute=Io,e.Uint32BufferAttribute=Ro,e.Uint8BufferAttribute=class extends To{constructor(e,t,n){super(new Uint8Array(e),t,n)}},e.Uint8ClampedBufferAttribute=class extends To{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}},e.Uniform=vf,e.UniformsGroup=class extends qt{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Af++}),this.name="",this.usage=Qt,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return-1!==t&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){return this.dispatchEvent({type:"dispose"}),this}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let e=0,n=t.length;e<n;e++)this.uniforms.push(t[e].clone());return this}clone(){return(new this.constructor).copy(this)}},e.UniformsLib=Tr,e.UniformsUtils=cr,e.UnsignedByteType=xe,e.UnsignedInt248Type=Re,e.UnsignedIntType=Se,e.UnsignedShort4444Type=Te,e.UnsignedShort5551Type=Ie,e.UnsignedShortType=Ce,e.V3DL=Yt,e.VSMShadowMap=c,e.Vector2=yn,e.Vector3=ci,e.Vector4=ii,e.VectorKeyframeTrack=tp,e.VideoTexture=class extends ni{constructor(e,t,n,i,o,r,a,s,l){super(e,t,n,i,o,r,a,s,l),this.isVideoTexture=!0,this.minFilter=void 0!==r?r:ve,this.magFilter=void 0!==o?o:ve,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)}},e.ViewportFitAuto=3,e.ViewportFitFill=4,e.ViewportFitHorizontal=2,e.ViewportFitNone=0,e.ViewportFitOverscan=5,e.ViewportFitVertical=1,e.Visualizer=class extends uo{constructor(e,t=10){super("MeshBVHVisualizer"),this.depth=t,this._mesh=e,this._roots=[],this.update()}update(){for(var e=this._mesh.geometry.boundsTree,t=e?e._roots.length:0;this._roots.length>t;)this._roots.pop();for(var n=0;n<t;n++)if(n>=this._roots.length){var i=new jy(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=Vl,e.WebGL3DRenderTarget=class extends oi{constructor(e=1,t=1,n=1){super(e,t),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new ai(null,e,t,n),this.texture.isRenderTargetTexture=!0}},e.WebGLArrayRenderTarget=class extends oi{constructor(e=1,t=1,n=1){super(e,t),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new ri(null,e,t,n),this.texture.isRenderTargetTexture=!0}},e.WebGLCubeRenderTarget=gr,e.WebGLMultipleRenderTargets=si,e.WebGLMultisampleRenderTarget=class extends oi{constructor(e,t,n){console.error('v3d.WebGLMultisampleRenderTarget has been removed. Use a normal render target and set the "samples" property to greater 0 to enable multisampling.'),super(e,t,n),this.samples=4}},e.WebGLRenderTarget=oi,e.WebGLRenderer=zl,e.WebGLUtils=ml,e.WebXRUtils=Db,e.WireframeGeometry=fd,e.WrapAroundEnding=Ct,e.XZ=Zm,e.XZLoader=eg,e.ZeroCurvatureEnding=yt,e.ZeroFactor=T,e.ZeroSlopeEnding=bt,e.ZeroStencilOp=0,e._SRGBAFormat=Ht,e.acceleratedRaycast=qy,e.arrayMax=Mn,e.arrayMin=function(e){if(0===e.length)return 1/0;let t=e[0];for(let n=1,i=e.length;n<i;++n)e[n]<t&&(t=e[n]);return t},e.clampArray=Rn,e.computeBoundsTree=Zy,e.disposeBoundsTree=Jy,e.engineVersionCmp=function(e,t){const n=Pn(e),i=Pn(t);let o=i.major-n.major;return 0===o&&(o=i.minor-n.minor,0===o&&(o=i.patch-n.patch,0===o&&(o=Bn(i.pre)-Bn(n.pre)))),Math.sign(o)},e.findModulePath=Fn,e.getGlobalScope=Nn,e.isDef=In,e.loadModule=Un,e.sRGBEncoding=Rt,e.shaderFloatStr=Dn,Object.defineProperty(e,"__esModule",{value:!0})}));
